akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

char s[510];
int a[128];
int c[10];
int main(){
	int n;
	scanf("%d %s",&n,s);
	for(int i=0;i<n;i+=2)a[s[i]]++;
	for(int i='a';i<='z';i++)c[a[i]]++;
	
	int ans=c[1]*2;
	for(int i=2;i<10;i++){
		if(c[i]==1)ans+=4;
		else if(c[i]>=2)ans+=c[i]*2+4;
	}
	printf("%d\n",ans-1);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin>>s;
    string t="FESTIVAL";
    cout<<s.substr(0,SZ(s)-SZ(t))<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e5+5;
int bin[maxn];
int ans[maxn]; 
int answ[maxn];

vector<int> fri[maxn],blo[maxn];

int find(int n)
{
	if(n==bin[n]) return n;
	else bin[n]=find(bin[n]);
	return bin[n];
}

void join(int a,int b)
{
	int aa=find(a);
	int bb=find(b);
	if(aa<bb) 
	{
		bin[bb]=aa;
		ans[aa]=ans[aa]+ans[bb];
	}
	else if(aa>bb)
	{
		bin[aa]=bb;
		ans[bb]=ans[aa]+ans[bb];
	}
}

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		fri[a].push_back(b);
		fri[b].push_back(a);
	}
	for(int i=0;i<k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		blo[a].push_back(b);
		blo[b].push_back(a);
	}
	for(int i=0;i<=n;i++)
	{
		ans[i]=1;
		bin[i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<fri[i].size();j++)
		{
			join(i,fri[i][j]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		answ[i]=ans[find(i)]-1-fri[i].size();
		for(int j=0;j<blo[i].size();j++)
		{
			if(find(i)==find(blo[i][j])) answ[i]--;
		}
	}
	int ca=0;
	for(int i=1;i<=n;i++)
	{
		if(ca++) cout<<' ';
		cout<<answ[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 13048
#include <iostream>
#include <cstdio>

using namespace std;

const int N = 3005, P = 998244353;

typedef long long LL;

int n, S, a[N], f[N];

int ans = 0;

int main() {
	scanf("%d%d", &n, &S);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i <= n; i++) {
		if (S - a[i] > 0) ans = (ans + (LL) (n - i + 1) * f[S - a[i]]) % P;
		else if (S == a[i]) ans = (ans + (LL) i * (n - i + 1)) % P;
		
		for (int j = S; j > a[i]; j--) 
			(f[j] += f[j - a[i]]) %= P;
		(f[a[i]] += i) %= P;
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool set(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;

	UnionFind uf(m + 1);

	vector<vector<int>> v(n);
	rep(i, n) {
		int k;
		cin >> k;
		int o;
		cin >> o;
		v[i].push_back(o);
		rep(j, k - 1) {
			int l;
			cin >> l;
			v[i].push_back(l);
			uf.set(o, l);
		}
	}

	map<int, int> mp;
	rep(i, n) {
		set<int> se;
		each(j, v[i]) {
			se.insert(uf.root(j));
		}
		each(j, se) {
			mp[j]++;
		}
	}

	each(i, mp) {
		if (i.second == n) {
			cout << "YES" << endl; return 0;
		}
	}
	cout << "NO" << endl; return 0;

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    ll ans = 1e12;
    ll s1, s2, s3, d, min_val, max_val;
    rep(i,1,H){
        s1 = i * W;
        d = W/2;
        s2 = (H - i) * d;
        s3 = (H - i) * (W - d);
        min_val = min(s1,min(s2,s3));
        max_val = max(s1,max(s2,s3));
        ans = min(ans, max_val - min_val);

        d = (H-i)/2;
        s2 = W * d;
        s3 = W * (H - i - d);
        min_val = min(s1,min(s2,s3));
        max_val = max(s1,max(s2,s3));
        ans = min(ans, max_val - min_val);
    }
    swap(H,W);
    rep(i,1,H){
        s1 = i * W;
        d = W/2;
        s2 = (H - i) * d;
        s3 = (H - i) * (W - d);
        min_val = min(s1,min(s2,s3));
        max_val = max(s1,max(s2,s3));
        ans = min(ans, max_val - min_val);

        d = (H-i)/2;
        s2 = W * d;
        s3 = W * (H - i - d);
        min_val = min(s1,min(s2,s3));
        max_val = max(s1,max(s2,s3));
        ans = min(ans, max_val - min_val);
    }

    print(ans);



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n, p, k = 0, tmp;
    cin >> n;
    while (n--)
    {
        cin >> p;
        tmp = upper_bound(a, a + k, p, greater<int>()) - a;
        if (tmp == k)
        {
            a[k] = p;
            ++k;
        }
        else
            a[tmp] = p;
    }
    cout << k << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Question
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var (a, b) = ReadHelper.ReadValue<int, int>();
            Console.WriteLine(a * b);
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27532
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
typedef long long int ll;
int main()
{
    ll n,k,sum=0;
    string s;
    cin>>n>>k;
    if(n<=k)
        cout<<"unsafe\n";
    else if(n>k)
        cout<<"safe\n";
}


Measured memory_bytes: 3600
use proconio::{input, fastout};
use std::time::{Duration, Instant};
use rand::prelude::*;

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }
    let start = Instant::now();

    let mut last = vec![0; TYPE_COUNT];

    let mut ans = vec![];

    for s in ss.iter() {
        let mut max = 0;
        let mut index = 0;
        for (i, &x) in s.iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        ans.push(index);
    }

    let mut score = calc_score(&cc, &ss, &ans);
    let mut rng = thread_rng();

    while Instant::now().duration_since(start) < Duration::from_millis(1980) {
        let mut dts = vec![];
        let mut olds = vec![];

        for _ in 0..(d/100)+1 {
            let day = rng.gen_range(0, d);
            let ty = rng.gen_range(0, 26);
            dts.push((day, ty));
            let old = ans[day];
            ans[day] = ty;
            olds.push((day, old));
        }

        let new_score = calc_score(&cc, &ss, &ans);
        if new_score < score {
            for (day, old) in olds.into_iter().rev() {
                ans[day] = old;
            }
        } else {
            score = new_score;
        }
    }

    for x in ans {
        println!("{}", x+1);
    }
    
}

fn calc_score(cc: &Vec<usize>, ss: &Vec<Vec<usize>>, tt: &Vec<usize>) -> isize {
    let mut last = vec![0; TYPE_COUNT];

    let mut v = 0;
    for (s, &t) in ss.iter().zip(tt.iter()) {
        v += s[t] as isize;
        for l in last.iter_mut() {
            *l += 1;
        }
        last[t] = 0;
        v -= last.iter().zip(cc.iter()).map(|(&l, &c)| (l * c) as isize).sum::<isize>();
    }
    v
}

Measured memory_bytes: 2768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();

            if (a * b >= c * d) {
                out.println(a * b);
            } else {
                out.println(c * d);
            }
        }

    }
}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
const int N=503;
using namespace std;
typedef long long ll;
ll a[N][N];
int n,p[N*2],tot;
bool np[N*30];
inline int F(int x){
	return p[n+x/2];
}
inline int G(int x){
	return p[(x+n/2*2)/2];
}
int main(){
	scanf("%d",&n);
	for(int i=2;tot<2*n;i++){
		if(!np[i])p[tot++]=i;
		for(int j=i*i;j<N*30;j+=i)np[j]=1;
	}
	for(int i=0;i<n;i++,puts(""))
	for(int j=0;j<n;j++)
	if(i+j&1){
		printf("%lld ",1ll*F(i+j-1)*F(i+j+1)
		*G(i-j-1)*G(i-j+1)+1);
	}else printf("%d ",F(i+j)*G(i-j));
}

Measured memory_bytes: 3200
# DP : 自力実装
#dp = [i=0 [w=0,...,w=W],
#      ...,
#      i=N-1 [w=0,...,w=W],
#      i=N [w=0,...,w=W] ]

N,W = map(int,input().split())
value,weight = [],[]
for i in range(N):
   v,w =  map(int,input().split())
   value.append(v)
   weight.append(w) 

# DP配列の初期化
dp = [[0 for w in range(W+5)] for i in range(N+5)] # 配列の各要素i番目の荷物(重さw)の状態での「value(の最大値)」

# DP遷移式
#for w=0,1,2,...,W :
# if w>=weight :  荷物i+1をのせて重さをwにすることができる
#  dp[i+1][w] = max(dp[i][w-weghit[i]], # 荷物i番目を乗せ終わった遷移のうち重さw-weight[i]の状態 + 荷物i+1をのせる
#                    dp[i][w]) 　　　　 # 荷物i+1をのせない
# elif w<weght : そもそも荷物i+1をのせることができない(重量がWを超えるので)
#  dp[i+1][w] = dp[i][w] # 荷物i+1をのせない
for i in range(N):
  for w in range(W+1): # w=0,...Wまで調べる必要があるので W+1
    if(w>=weight[i]):
        dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
    else:
        dp[i+1][w] = dp[i][w]

# アルゴリズムから必ず右下のvalueが最大となる        
print(dp[N][W])        


Measured memory_bytes: 42632
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

string res;

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

    string s;
    int count = 0;
    cin >> s;
    for(int i = 0; i < s.length(); i++ )
    {
        if(s[i]=='0'){
            res.push_back('0');
        }else if(s[i]=='1'){
            res.push_back('1');
        }
        else
        {
            if(0<res.length())
                res.pop_back();
        }
    }
    cout << res << endl;
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const long long INF = 2e18;

long long a[100005], suff[100005];

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

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

    for (int i=n; i>=0; i--)
        suff[i] = suff[i+1] + a[i];

    long long ret = 0, nodes = 1;
    bool infinity = false;
    for (int i=0; i<=n; i++) {
        if (infinity) {
            ret += suff[i];
        } else {
            ret += min(nodes, suff[i]);
            nodes -= a[i];
            if (nodes < 0) {
                cout << "-1\n";
                return 0;
            }
            nodes *= 2;
            if (nodes > INF)
                infinity = true;
        }
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  vector<double> b(a);
  rep(i,a)
    cin>>b.at(i);
  sort(all(b));
  double c=(b.at(0)+b.at(1))/2;
  rep(i,a-2)
    c=(c+b.at(i+2))/2;
  cout<<c;
}


Measured memory_bytes: 256
import core.stdc.stdio;
import std.typecons;
import std.algorithm;

void main(){
	int n,e,t;
	scanf("%d%d%d",&n,&e,&t);
	--t;
	long[] cost = new long[n];
	static immutable int inf = 1145141919;
	bool[] used = new bool[n];
	foreach(i;0..n){
		int w;
		scanf("%d",&w);
		if(w==1){
			cost[i]=1;
			used[i]=true;
		}else
			cost[i]=inf;
	}
	alias Tuple!(long,"cost",int,"g",int[],"f") cgf;
	cgf[] rec = new cgf[e];
	int[][] h = new int[][n];
	void CalcCost(ref cgf r){
		sort!((a,b)=>cost[a]<cost[b])(r.f);
		r.cost=0;
		foreach(i,v;r.f)
			r.cost=max(r.cost,r.f.length-i-1+cost[v]);
	}
	foreach(i;0..e){
		int c;
		scanf("%d%d",&rec[i].g,&c);
		rec[i].g--;
		rec[i].f=new int[c];
		foreach(ref v;rec[i].f){
			scanf("%d",&v);
			h[--v]~=i;
		}
		CalcCost(rec[i]);
	}
	while(cost[t]==inf){
		cgf mn = cgf(cast(long)inf,-1,[]);
		foreach(r;rec)
			if(!used[r.g]&&r.cost<mn.cost)
				mn=r;
		if(mn.g==-1){
			printf("-1\n");
			return;
		}
		used[mn.g]=true;
		cost[mn.g]=mn.cost;
		foreach(j;h[mn.g])
			CalcCost(rec[j]);
	}
	printf("%lld\n",cost[t]);
}

Measured memory_bytes: 2548
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	
	
	
	
	public static int gcd(int n1, int n2)
    {
        if (n2 != 0)
            return gcd(n2, n1 % n2);
        else
            return n1;
    }
	
	
	
	
	static class pair {
        Integer x,y;
        pair (int x,int y){
            this.x=x;
            this.y=y;
        }
    }
	
	
	
	static class length implements Comparator<String>
	{
		public int compare(String a,String b)
		{
			return(a.length()-b.length());
		}
	}
	
	
	
	
	   static class FastReader
	   {
		   BufferedReader br;
		   StringTokenizer st;
		   public FastReader()
		   {
			   br = new BufferedReader(new InputStreamReader(System.in));
		   }
		   
		   
		   String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
		   
		   
		   int nextInt()
		   {
			   return Integer.parseInt(next());
		   }
		   long nextLong()
		   {
			   return Long.parseLong(next());
		   }
		   double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
		   
		   String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	   }

		public static void main(String []args) throws Exception
		{
			//Scanner sc=new Scanner(System.in);
			FastReader in =new FastReader();
			//Scanner in=new Scanner(System.in);
			PrintWriter pw = new PrintWriter(System.out);
			int n1=in.nextInt();
			double n=n1;
			pw.println(new DecimalFormat("0.0000000000").format((Math.ceil(n/2))/n));
			
			
			
			
			pw.flush();
			pw.close();
			
	}
		
		
}		
		
		
		
		
		
		
		
	

Measured memory_bytes: 21588
d = [1,3,5,7,8,10,12]
s = [4,6,9,11]
a = [2]

x,y = map(int,input().split())

if (x in d and y in d) or (x in s and y in s) or (x in a and y in a):
    print("Yes")
else:
    print("No")

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

const int MAX = 1e5+1;
bool A[MAX];
int B[MAX];

int main(){
    int n, m, sum = 0;
    cin >> n >> m;
    A[1] = true;
    for (int i = 1; i <= n; i++)
    {
        B[i] = 1;
    }
    
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        if (A[x] && B[x] > 1)
        {
            A[y] = true;
            B[x]--; B[y]++;
        }
        else if (A[x] && B[x] == 1)
        {
            A[x] = false;
            A[y] = true;
            B[x]--;
            B[y]++;
        }
        else if (!A[x])
        {
            B[x]--;
            B[y]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (A[i])
        {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] l = sc.next().toCharArray();
        long mod = 1_000_000_007;
        long[] dp = new long[l.length+1];
        long[] dp2 = new long[l.length+1];
        dp[0] = 1L;
        dp2[0] = 1L;
        for (int i = 0; i < l.length; i++) {
            dp[i+1] = (dp[i] * 3) % mod;
            if(l[l.length - i -1] == '1') dp2[i+1] = (dp2[i] * 2 + dp[i]) % mod;
            else dp2[i+1] = dp2[i];
        }
        System.out.println((dp[l.length-1] + dp2[l.length-1]*2) % mod);
        sc.close();

    }

}


Measured memory_bytes: 28460
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0;i<(int)n;++i)

int dx[] ={0,1,0,-1};
int dy[] = {1,0,-1,0};
struct P {
  int d;
  int x,y;
  P(int d,int x,int y):d(d),x(x),y(y){}
};
bool operator<(const P &a, const P &b) {
  return a.d > b.d;
}
int main() {
  int r;
  while(cin >> r, r) {
    int w[2],h[2],sx[2],sy[2];
    int ba[2][500][500];
    rep(k,2) {
      cin >> w[k]>>h[k]>>sx[k]>>sy[k];
      sx[k]--;sy[k]--;
      rep(y,h[k])
        rep(x, w[k])
        cin >> ba[k][x][y];
    }
    int table[2][250001];
    rep(k,2) {
      priority_queue<P> Q;
      Q.push(P(1, sx[k], sy[k]));
      bool visited[w[k]][h[k]];
      memset(visited,0,sizeof(visited));
      int nowd = 0;
      int cnt = 0;
      while(!Q.empty()) {
        P p = Q.top();
        int x = p.x;
        int y = p.y;
        Q.pop();
        if (visited[x][y]) continue;
        nowd = max(nowd, p.d);
        table[k][++cnt] = nowd;
        if(cnt>=r) break;
        //      printf("%d,%d -> %d\n",k,cnt,nowd);
        visited[x][y] = 1;
        rep(i,4) {
          int xx = x+dx[i];
          int yy = y+dy[i];

          if (xx<0||xx>=w[k]||yy<0||yy>=h[k]) continue;
          if (visited[xx][yy]) continue;
          Q.push(P(ba[k][xx][yy], xx, yy));
        }
      }
    }
    int res = 1<<29;
    for (int i=0; i<=r; ++i) {
      if (i>w[0]*h[0] || r-i>w[1]*h[1]) continue;
      //  printf("%d->%d %d->%d\n", i,table[0][i], r-i,table[1][r-i]);
      res = min(res, table[0][i]+table[1][r-i]);
    }
    cout << res << endl;
  
  }
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int N;
	cin >> N;
	priority_queue<int> a;
	rep(i, 3*N) {
		int A;
		cin >> A;
		a.push(A);
	}
	int64_t ans = 0;
	rep(i, N) {
		a.pop();
		ans += a.top();
		a.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long a, N, i, cnt = 0;
  cin >> N;
  map<long long, long long> R, L;
  
  for(i = 0; i < N; i++){
    
    cin >> a;
    R[i + 1 + a]++;
    L[i + 1 - a]++;
  }
 
  for(auto j : R){
  
    cnt += j.second * L[j.first];
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 37804
import sys
sys.setrecursionlimit(10**7)

# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    p, q, r = map(int, input().split())
    import math
    print(p+q+r - max([p, q, r]))
solve()

Measured memory_bytes: 2940
from itertools import accumulate

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


like_numbers = [0] * (10 ** 6)
for p in primes(10 ** 5):
    like_numbers[p * 2 - 1] += 1
    like_numbers[p] += 1

like_numbers = [1 if i == 2 else 0 for i in like_numbers]
like_numbers = list(accumulate(like_numbers))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(like_numbers[r] - like_numbers[l-1])

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

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

            choice[] val = new choice[4];
            val[0] = new choice(0.25, in.nextLong());
            val[1] = new choice(0.50, in.nextLong());
            val[2] = new choice(1, in.nextLong());
            val[3] = new choice(2, in.nextLong());

            int n = in.nextInt();

            Arrays.sort(val, Comparator.comparing(o -> (long) ((long) ((2.0 / o.sz)) * o.v)));

            long ans = 0;

            for (int i = 0; n > 0 && i < 4; ++i) {
                double cap = val[i].sz;
                if (n >= cap) {
                    long tmp = (long) (n / cap) * val[i].v;
                    ans += tmp;
                    n %= cap;
                }
            }

            out.println(ans);

        }

        class choice {
            long v;
            double sz;

            public choice(double sz, long v) {
                this.v = v;
                this.sz = sz;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public Long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 28116
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>mx(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i) mx[i] = mx[i - 1];
		mx[i] = max(mx[i], a[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= mx[i]) ans++;
	}
	cout << ans;
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque<long long> a;
int main()
{
	int n,cn=9;
	cin>>n;
	if(n<10)
	{
		cout<<n;
		return 0;
	}
	for(int i=1;i<=9;i++)
		a.push_back(i);
	while(cn<n)
	{
		if(a.front()==0)
		{
			a.pop_front();
			cn--;
		}
		if(a.front()%10!=0)
		{
			a.push_back(a.front()*10+a.front()%10-1);
			cn++;
		}
		if(cn==n)break;
		a.push_back(a.front()*10+a.front()%10);
		cn++;
		if(cn==n)break;
		if(a.front()%10!=9)
		{
			a.push_back(a.front()*10+a.front()%10+1);
			cn++;
		}
		a.pop_front();
	}
	cout<<a.back();

	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)
	
int main(){
	int H,W;
	cin >> H >> W;
	string S[H];
	For(i,0,H) cin >> S[i];
	
	//S[H-1][W-1]
	int w[H][W],h[H][W];
	
	For(i,0,H){
		For(j,0,W){
			w[i][j]=h[i][j]=0;
		}
	}
	
	For(i,0,H){
		int cnt=0;
		For(j,0,W){
			if(S[i][j]=='#'){
				w[i][j]=0;
				cnt=0;
			}
			else{
				cnt++;
				w[i][j]=cnt;
			}
			//cout << w[i][j] << " ";
		}
		//cout << endl;
		int val=0;
		for(int j=W-1;j>=0;j--){
			if(S[i][j]=='#') val=0;
			else{
				if(val==0) val=w[i][j];
				else w[i][j]=val;
			}
			//cout << w[i][j] << " ";
		}
		//cout << endl;
	}
	
	For(j,0,W){
		int cnt=0;
		For(i,0,H){
			if(S[i][j]=='#'){
				h[i][j]=0;
				cnt=0;
			}
			else{
				cnt++;
				h[i][j]=cnt;
			}
		}
		int val=0;
		for(int i=H-1;i>=0;i--){
			if(S[i][j]=='#') val=0;
			else{
				if(val==0) val=h[i][j];
				else h[i][j]=val;
			}
		}
	}
	
	int ans=1;
	For(i,0,H){
		For(j,0,W){
			ans=max(ans,w[i][j]+h[i][j]-1);
		}
	}
	cout << ans;
	/*
	cout << endl;
	For(i,0,H){
		For(j,0,W){
			cout << "(" << w[i][j] << "," << h[i][j] << ") ";
		}
		cout << endl;
	}*/
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct city{
  ll zero;
  ll one;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  vector<city> C(6);
  C[0].zero = 1;
  C[0].one = 2;
  C[1].one = 3;
  C[1].zero = -1;
  C[2].zero = 1;
  C[2].one = -1;
  C[3].zero = 4;
  C[3].one = 5;
  C[4].zero = 5;
  C[4].one = 2;
  C[5].zero = 2;
  C[5].one = 1;
  while(cin >> s && s != "#"){
    ll pos = 0;
    rep(i,s.size()){
      if(s[i] == '0'){
        pos = C[pos].zero;
      }
      else{
        pos = C[pos].one;
      }
      if(pos == -1 || i == s.size()-1 && pos != 5){
        cout << "No"<<endl;
        break;
      }
      else if(i == s.size()-1 && pos == 5){
        cout << "Yes" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    string s;cin>>s;
    ll n = s.size()-1;
    ll res = 0;
    rep(i,0,(1<<n)){
        vector<ll> v;
        v.pb(0);
        rep(j,0,n){
            if((i>>j) & 1){
                v.pb(j+1);
            }
        }
      	v.pb(n+1);
        rep(j,0,v.size()){
          	//cout << v[j] << endl;
          	if(s.substr(v[j],v[j+1]-v[j]) == "") continue;
            res += stoll(s.substr(v[j],v[j+1]-v[j]));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int taro = 0;
        int hanako = 0;
        for(int i = 0 ; i < n ; i++)
        {
            String Taro = sc.next();
            String Hanako = sc.next();
            int x = Taro.compareTo(Hanako);
            if(x > 0)
                taro += 3;
            else if(x == 0)
            {
                taro++;
                hanako++;
            }
            else
                hanako += 3;
        }
        System.out.println(taro + " " + hanako);
    }
}


Measured memory_bytes: 29428
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x<b&&a<y){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}


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


int main(){
    int n; cin >> n;
    map<int, int> mp;

    int maxv = 0;
    for(int i=0; i<n; i++){
        int a, b; cin >> a >> b;
        maxv = max(maxv, a);
        mp[a] = b;
    }

    cout << maxv + mp[maxv] << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ull unsigned long long
void fast_IO() { ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main()
{
	ll n; cin>>n;
	ll a[n],b[n],c[n];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];

	ll dp[n][3];
	dp[0][0]= a[0];
	dp[0][1]= b[0];
	dp[0][2]= c[0];

	for(ll i=1;i<n;i++)
	{
		dp[i][0]= a[i]+ max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]= b[i]+ max(dp[i-1][0], dp[i-1][2]); 
		dp[i][2]= c[i]+ max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 8284
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<ll,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=2e5+5;

int head[N],to[N<<1],nxt[N<<1],w[N<<1],cnt,val[N];
inline void add(int u,int v,int c)
{to[++cnt]=v,nxt[cnt]=head[u],w[head[u]=cnt]=c;}

struct node{int u,v;ll w;}E[N*40];int tot;
inline bool operator<(const node &a,const node &b){return a.w<b.w;}

ll dis[N];int siz[N],SZ,rt,ms[N],o[N];
void getrt(int u,int pa=0)
{
	siz[u]=1,ms[u]=0;
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i])!=pa&&!o[v])
		{
			getrt(v,u),siz[u]+=siz[v];
			ms[u]=std::max(ms[u],siz[v]);
		}
	ms[u]=std::max(ms[u],SZ-siz[u]);
	if(ms[rt]>ms[u])rt=u;
}

P tmp[N];int tt;
void Dfs(int u,int pa=0,ll d=0)
{
	tmp[++tt]=mk(d+val[u],u);
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i])!=pa&&!o[v])
			Dfs(v,u,d+w[i]);
}

void calc(int u)
{
	tt=0,Dfs(u);std::sort(tmp+1,tmp+tt+1);
	ll fz=tmp[1].fr;int v=tmp[1].sc;
	for(int i=2;i<=tt;++i)
		E[++tot]=(node){v,tmp[i].sc,fz+tmp[i].fr};
}

void solve(int u)
{
	calc(u),o[u]=1;int nsz=SZ;
	for(int i=head[u],v;i;i=nxt[i])
		if(!o[v=to[i]])
		{
			SZ=siz[v]>siz[u]?nsz-siz[u]:siz[v];
			rt=0,getrt(v),solve(rt);
		}
}

int fa[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	int n=in();ms[0]=2e9;
	for(int i=1;i<=n;++i)val[i]=in();
	for(int i=2;i<=n;++i)
	{
		int u=in(),v=in(),c=in();
		add(u,v,c),add(v,u,c);
	}
	SZ=n,rt=0,getrt(1),solve(rt);
	std::sort(E+1,E+tot+1);
	ll mst=0;int cnt=1;
	for(int i=1;i<=n;++i)fa[i]=i;
	for(int i=1;i<=tot&&cnt<n;++i)
	{
		int u=find(E[i].u),v=find(E[i].v);
		if(u==v)continue;++cnt;fa[u]=v;mst+=E[i].w;
	}
	printf("%lld\n",mst);
	return 0;
}


Measured memory_bytes: 74880
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve(t,n):
    if t == n:
        print(t,n)
        return
    a = list(map(int,list(str(n))))
    s = sum(a)
    m = len(a)
    if s > t:
        print("error")
        return
    nm = m-1
    f = [0]*nm
    d = defaultdict(lambda : 0)
    d[tuple(f)] = 1
    l = [[] for i in range(t+1)]
    q = [(s,f)]
    l[s].append(f)
    ans = s
    while q:
        s,f = heappop(q)
        for i in range(nm):
            if f[i]:
                continue
            nf = [1 if j == i else f[j] for j in range(nm)]
            ns = 0
            ms = a[0]
            for j in range(1,m):
                if nf[j-1]:
                    ms *= 10
                    ms += a[j]
                else:
                    ns += ms
                    ms = a[j]
            ns += ms
            if ns <= t:
                tf = tuple(nf)
                if not d[tf]:
                    d[tf] = 1
                    if ns >= ans:
                        ans = ns
                        l[ns].append(nf)
                    heappush(q,(ns,nf))
    if len(l[ans]) > 1:
        print("rejected")
        return
    s = [ans]
    f = l[ans][0]
    k = a[0]
    for i in range(nm):
        if f[i]:
            k *= 10
            k += a[i+1]
        else:
            s.append(k)
            k = a[i+1]
    s.append(k)
    print(*s)
    return

#Solve
if __name__ == "__main__":
    while 1:
        t,n = LI()
        if t == n == 0:
            break
        solve(t,n)



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

bool calculate(int& value, int a, int b, char op)
{    
    bool isFinished = true;
    switch(op)
    {
        case '+':   value = a + b;  break;
        case '-':   value = a - b;  break;
        case '*':   value = a * b;  break;
        case '/':   value = a / b;  break;
        case '?':   isFinished = false;     break;
        default:    isFinished = false;
    }
    
    return isFinished;
}

int main()
{
    int value=0;
    int a=0, b=0;
    char op;

    while(true)
    {
        cin >> a >> op >> b;
        
        if (!calculate(value, a, b, op))    break;
        
        cout << value << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    map<string, ll> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    rep(i,N) {
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

}


Measured memory_bytes: 3648
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int num = s.length();
      	int min = 10;
      	int max = 0;
      	for(int i = 0; i < num; i++){
        	if(s.charAt(i) == 'A'){
            	min = i;	
              	break;
            }
        }
      	for(int i = 0; i < num; i++){
          	if(s.charAt(i) == 'Z'){
            	max = i;
            }
        }
      	System.out.print(max - min + 1);
    }
}

Measured memory_bytes: 27932
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)


H, W, M = map(int, input().split())

num_bombs_each_row = [0] * H
num_bombs_each_col = [0] * W
bombs = set()

for _ in range(M):
    h, w = map(int, input().split())
    # 0-index
    h -= 1
    w -= 1

    bombs.add((h, w))
    num_bombs_each_row[h] += 1
    num_bombs_each_col[w] += 1

max_bombs_in_row = max(num_bombs_each_row)
max_bombs_in_col = max(num_bombs_each_col)

rows_with_max_bombs = []
for row in range(H):
    if num_bombs_each_row[row] == max_bombs_in_row:
        rows_with_max_bombs.append(row)

cols_with_max_bombs = []
for col in range(W):
    if num_bombs_each_col[col] == max_bombs_in_col:
        cols_with_max_bombs.append(col)

found = False
for row in rows_with_max_bombs:
    for col in cols_with_max_bombs:
        if (row, col) not in bombs:
            found = True
            break

ans = max_bombs_in_row + max_bombs_in_col
if found:
    print(ans)
else:
    print(ans - 1)


Measured memory_bytes: 179756
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; //0290の文字列
  cin >> s;
  vector<int>v(4); //要素が4つの配列v
  for(int i = 0; i < 4; i++)v[i] = s[i] - '0'; //文字列を配列に順番に入れる。-0は数値への変換。配列vは0,2,9,0の数値が入った配列

  for(int j = 0; j < (1 << 3); j++){ //+か-の2択が3回。jを0から2^3=8通りをループ。jがいわゆるbit整数値。
    int tmp = v[0]; //tmpに0を代入
    for(int k = 0; k < 3; k++){ //3回ループ
      if(j & (1 << k))tmp += v[k+1]; //jでk桁目が1だったら、数値の配列k+1番目の数字を加算
      else tmp -= v[k+1]; //jでk桁目が0だったら、k+1番目の数字を減算
    }
    if(tmp == 7){ //合計が7のとき
      cout << v[0];
      for(int k = 0; k < 3; k++){
        if(j & (1 << k))cout << '+'; //jでk桁目が1だったらプラスを表示
        else cout << '-';
        cout << v[k+1]; //数値配列のk+1番目を表示
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,M;
	scanf("%d%d",&N,&M);
	printf("%d\n",(N-1)*(M-1));
}


Measured memory_bytes: 256
count :: [Integer] -> Integer
count [a, b] = 
    let sumInt :: Integer -> Integer
        sumInt n = (n * (n + 1)) `div` 2
        loop :: Integer -> Integer 
        loop 1000 = 0
        loop n = if ((sumInt n) - a /= 0 && (((sumInt n) - a) == ((sumInt (n + 1)) - b))) then (sumInt n) - a else loop $ n + 1
        in loop 0
main = print =<< (count . (map (\a -> read a :: Integer)) . words) <$> getLine


Measured memory_bytes: 764
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		System.out.println(S*T>=D ? "Yes" : "No");
		
		sc.close();
	}
}


Measured memory_bytes: 27056