akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    vector<stack<int>> s(1100);
    for(int i=0; i<q; i++){
        int a, t;
        cin >> a >> t;
        if(a == 0){
            int x;
            cin >> x;
            s[t].push(x);
        }else{
            if(a == 1){
                if(!(s[t].empty())){
                    cout << s[t].top() << endl;
                }
            }else{
                if(!(s[t].empty())){
                    s[t].pop();
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4340
n = gets.chomp.to_i
brackets = gets.chomp
partical_brackets = brackets

def next_short_brackets(brackets)
  return brackets.split('()').join
end

while partical_brackets.split('()').join != partical_brackets do
  partical_brackets = next_short_brackets(partical_brackets)
end

array = partical_brackets.split('')
lefthand_counts = array.count {|item| item == ')'}
righthand_counts = array.count {|item| item == '('}

input = brackets.split('')
lefthand_insertion = ['('] * lefthand_counts
righthand_insertion = [')'] * righthand_counts

answer = lefthand_insertion.concat(input).concat(righthand_insertion).join
print answer


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

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

int main(){
    int n;
    cin >> n;
    if(!ischeck(1 + 8*n)) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        int k = (1 + (int)sqrt(1 + 8 * n)) / 2;
        cout << k << endl;

        vector<vector<int>> table(k+10, vector<int>(k+10, 0));
        for (int i = 0; i < k; ++i) {
            table[i][0] = k-1;
        }
        table[0][1] = 1;
        for (int i = 0; i < k-1; ++i) {
            for (int j = i+1; j < k; ++j) {
                table[i][j+1] = table[i][j] + 1;
            }
            for (int j = i+1; j < k; ++j) {
                table[j][i+1] = table[i][j];
            }
            table[i+1][i+2] = table[i][k-1] + 1;
        }
        for (int i = 0; i < k; ++i) {
            for (int j = 0; j < k-1; ++j) {
                cout << table[i][j] << " ";
            }
            cout << table[i][k-1] << endl;


        }
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    vector<int> B(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i]; B[i] = A[i];
    }
    sort(B.begin(), B.end(), greater<int>());
    for (int i = 0; i < N; ++i) {
        if (A[i] == B[0]) printf("%d\n", B[1]);
        else printf("%d\n", B[0]);
    }
}


Measured memory_bytes: 3200
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int h;
    int w;
    int ans=0;
    cin >> h >> w;
    vector<vector<char>> s(w, vector<char>(h));
    vector<vector<int>> w_left_light(w, vector<int>(h));
    vector<vector<int>> w_right_light(w, vector<int>(h));
    vector<vector<int>> h_upper_light(w, vector<int>(h));
    vector<vector<int>> h_lower_light(w, vector<int>(h));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> s[j][i];
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[j][i]=='.'){
                if(j==0){
                    w_left_light[j][i]=1;
                }else{
                    w_left_light[j][i]=w_left_light[j-1][i]+1;
                }
            }else{
                w_left_light[j][i]=0;
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=w-1; j>=0; j--){
            if(s[j][i]=='.'){
                if(j==w-1){
                    w_right_light[j][i]=1;
                }else{
                    w_right_light[j][i]=w_right_light[j+1][i]+1;
                }
            }else{
                w_right_light[j][i]=0;
            }
        }
    }

    for(int j=0; j<w; j++){
        for(int i=0; i<h; i++){
            if(s[j][i]=='.'){
                if(i==0){
                    h_upper_light[j][i]=1;
                }else{
                    h_upper_light[j][i]=h_upper_light[j][i-1]+1;
                }
            }else{
                h_upper_light[j][i]=0;
            }
        }
    }
    for(int j=0; j<w; j++){
        for(int i=h-1; i>=0; i--){
            if(s[j][i]=='.'){
                if(i==h-1){
                    h_lower_light[j][i]=1;
                }else{
                    h_lower_light[j][i]=h_lower_light[j][i+1]+1;
                }
            }else{
                h_lower_light[j][i]=0;
            }
        }
    }
    int tmp;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            tmp = w_left_light[j][i] + w_right_light[j][i] + h_upper_light[j][i] + h_lower_light[j][i] - 3;
            if(ans<tmp){
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 69120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, q;
    cin >> n >> q;

    for (int i = 0; i < q; i++) {
        int v, w;
        cin >> v >> w;

        if (n == 1) {
            cout << min(v, w) << '\n';

        } else {
            while (v != w) {
                int& t = v > w ? v : w;
                t = (t + n - 2) / n;
            }
            cout << v << '\n';
        }

    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    string str;
    cin>>str;
    map<char, ll> mp1;
    for(ll i=0; i<3; i++)
    mp1[str[i]]++;
    if(mp1.size()==2)
    cout<<"Yes\n";
    else cout<<"No\n";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 256
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-21 16:56:54
 */
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");

const int N = 2e5 + 105;
const int MOD = 998244353;
ll f[N] = {0}, sum[N] = {0};
int main(){
    int n, k; 
    cin >> n >> k;
    set<pair<int, int> > se;
    for(int i = 1; i <= k; ++i){
        int l, r; cin >> l >> r;
        se.insert(make_pair(l, r));
    }
    f[1] = 1, sum[1] = 1;
    for(int i = 2; i <= n; ++i){
        sum[i] %= MOD;
        for(auto it : se){
            if(it.first >= i) continue;
            int l = max(1, i - it.second);
            int r = i - it.first;
            f[i] += (sum[r] - sum[l - 1]);
            f[i] %= MOD;
            // cout << f[i] << "#######" << i << endl;
        }
        sum[i] = sum[i - 1] + f[i];
    }
    cout << f[n] << endl;
    // system("pause");
}


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

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

using namespace std;

using graph=vector<vector<int>>;

void add_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
	G[v].emplace_back(u);
}

graph G;
vector<int> wt;

vector<bool> vis;

int dfs(int u,int p,bool one){
	vis[u]=true;

	int res=0;
	for(int v:G[u]) if(v!=p) res+=dfs(v,u,false);

	int c;
	if(p==-1){
		c=(one?wt[u]/2:0);
		wt[u]-=c;
	}
	else{
		c=min(wt[u],wt[p]);
		wt[u]-=c;
		wt[p]-=c;
	}
	res+=c;

	return res;
}

int solve_odd(vector<int> a){
	vector<int> X=a;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	int n=X.size();
	G.assign(n,{});
	rep(u,n){
		rep(t,31){
			int v=lower_bound(X.begin(),X.end(),(1<<t)-X[u])-X.begin();
			if(v<X.size() && X[u]+X[v]==(1<<t) && u<v){
				add_edge(G,u,v);
			}
		}
	}
	wt.assign(n,0);
	for(int x:a){
		int u=lower_bound(X.begin(),X.end(),x)-X.begin();
		wt[u]++;
	}
	vis.assign(n,false);

	int res=0;
	rep(u,n) if(!vis[u]) res+=dfs(u,-1,X[u]==1);
	return res;
}

int solve(vector<int> a){
	vector<int> E,O;
	for(int x:a){
		if(x%2==0) E.emplace_back(x/2);
		else       O.emplace_back(x);
	}
	return (E.empty()?0:solve(E))+(O.empty()?0:solve_odd(O));
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	printf("%d\n",solve(a));

	return 0;
}


Measured memory_bytes: 49780
mod = 1000000007

while True:
    try:
        N, M = map(int, input().split())
        
        # check obstacles: O(1)
        a = [0] * (N+1)
        for _ in range(M):
            a[int(input())] = 1
        
        dp = [0] * (N+1)
        dp[0] = 1
        dp[1] = 0 if a[1] else 1
        
        for i in range(2, N+1):
            if a[i]:
                dp[i] = 0
            else:
                dp[i] = dp[i-1] + dp[i-2]
        
        print(dp[N] % mod)
    except:
        break

Measured memory_bytes: 460788
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
const int INF=1e9+7;
using namespace std;
typedef  long long ll;
double a[105];
ll gcd(ll a,ll b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	double fz,fm;
	int n;
    scanf("%d",&n);
    scanf("%lf",&a[0]);
    fz=1;
    fm=a[0];
    for(int i=1;i<n;i++)
    {
    	scanf("%lf",&a[i]);
    	ll k=gcd((ll)fm,(ll)a[i]);
    	fz=fz*a[i]/k+fm/k;
    	fm=a[i]*fm/k;
    }
    printf("%.9f\n",fm/fz);
    return 0;
}



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

int main(){
    string a;
    cin >> a;
    string b = "RRR";
    if (a == b){
        cout << 3 << endl;
    }else if(a == "SRR"){
        cout << 2 << endl;
    }else if(a == "RRS"){
        cout << 2 << endl;
    }else if(a == "SSS"){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3564
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var Ai = Sarray();
            var ans = 0L;
            while (true)
            {
                for (var i = 0; i < N; ++i)
                {
                    if (Ai[i] % 2 == 0)
                    {
                        Ai[i] /= 2;
                    }
                    else
                    {
                        WriteLine(ans);
                        return;
                    }
                }
                ++ans;
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int MAXN=3005;
int n,D;

ll qpow(ll x,ll k,ll mod) {
	ll ret=1;
	while(k) {
		if(k&1) ret=ret*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ret;
}

ll g[MAXN][MAXN],fac[MAXN],inv[MAXN];
void first(int lim) {
	for(int i=0;i<=lim;i++) {
		g[i][0]=1;
		for(int j=1;j<=i;j++)
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1))%D;
	}
	
	fac[0]=inv[0]=1;
	for(int i=1;i<=lim;i++) fac[i]=fac[i-1]*i%D;
	inv[lim]=qpow(fac[lim],D-2,D);
	for(int i=lim-1;i;i--) inv[i]=inv[i+1]*(i+1)%D;
}

ll C(int x,int y,int mod) {
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
ll calc(int x) {
	ll ret=0;
	for(int i=0;i<=x;i++)
		ret=(ret+g[x][i]*qpow(2,(ll)(n-x)*i,D))%D;
	return ret*qpow(2,qpow(2,n-x,D-1),D)%D;
}

ll ans;
int main() {
	scanf("%d%d",&n,&D);
	first(n);
	ans=qpow(2,qpow(2,n,D-1),D);
	for(int i=1;i<=n;i++) {
		ll tmp=C(n,i,D)*calc(i)%D;
		if(i&1) ans=(ans-tmp)%D;
		else ans=(ans+tmp)%D;
	}
	printf("%lld\n",(ans+D)%D);
	return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    for(char &x : S) {
        x = (x - 'A' + N) % 26 + 'A';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
def dist(sx, sy, ex, ey)
    dx = ex-sx
    dy = ey-sy
    return (dx*dx + dy*dy)**0.5
end

n = gets.to_i
x = []
y = []
a = []
for i in 0...n
    x[i], y[i] = gets.split.map(&:to_i)
    a[i] = i
end

sum = 0
a.permutation(n) {|b|
    for i in 0...n-1
        s = b[i]
        t = b[i+1]
        sum += dist(x[s], y[s], x[t], y[t])
    end
}

nn = 1
for i in 1..n
    nn *= i
end

puts sum / nn



Measured memory_bytes: 2044
def gcd(x, y):
    while y >= 1:
        x, y = y, x%y
    return x
def lcm(x,y):
    return int((x*y)/gcd(x,y))

a, b, c, d = list(map(int, input().split()))

lcm_cd = lcm(c, d)
a -= 1
result = int(b - a)
result -= b//c - a//c
result -= b//d - a//d
result += b//lcm_cd -a//lcm_cd

print(result)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char ca[20];
	bool s=true;
	cin>>a>>b;
	cin>>ca;
	for(int i=0;i<a+b+1;i++){
		if(i==a){
			if(ca[i]!='-')s=false;
		}else if(ca[i]=='-')s=false;
	}
	if(s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

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

    int ans = 0;
    vector<int> cur(n, 0);
    for(; ; ans++){
        int left = 0;
        for(;left < n; left++){
            if(cur[left] < h[left]) break;
        }
        if(left == n) break;
        int right = left;
        for(;right < n; right++){
            if(cur[right] >= h[right]) break;
        }
        for(int i = left; i < right; i++) cur[i]++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
use proconio::input;

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
*/
    input! {
        n: usize,
        mut a: [u128; n],
    }

    let mut res:u128 = 1;
    a.sort();
    for x in a.into_iter(){
        if x == 0 {
            println!("0");
            return;
        }
        res = x * res ;
        if res > 10u128.pow(18) {
            println!("-1");
            return
        } 
    }
    println!("{}",res);

}  


Measured memory_bytes: 6124
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL a,b,c,d;

int main()
{
	FIO;
	cin >> a >> b >> c >> d;
	cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
}

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

int main()
{
    int a, b;
    scanf("%d",&a);
    scanf("%d",&b);
    int r = a + b -1;
    int p = a*b;
    int d = p-r;
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compar(const int*,const int*);

int main(void){
  int array[3];
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c );
  array[0] = a;
  array[1] = b;
  array[2] = c;
  qsort(array,sizeof(array)/sizeof(array[0]),sizeof(int),(int (*)(const void *, const void *))compar);
printf("%d",array[2]*10 + array[1] + array[0]);
return 0;
}
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}


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

using namespace std;

typedef pair<long long int, pair<long long int, long long int>>one;

#define mod 1000000007LL


template<typename T>
class UF {
public:
	UF() {
		size = 0;
	}

	//???????????\??????
	void push( T a ) {
		M[a] = size;
		V.push_back( size );
		rank.push_back( 0 );
		C.push_back( 1 );
		size++;
	}

	//????????°??????????????????
	void unite( T a, T b ) {
		long long int x = find( M[a] );
		long long int y = find( M[b] );
		if( x == y )return;
		if( rank[x] < rank[y] ) {
			V[x] = y;
			C[y] += C[x];
		} else {
			V[y] = x;
			C[x] += C[y];
			if( rank[x] == rank[y] )rank[x]++;
		}
	}

	void merge( T a, T b ) {
		unite( a, b );
	}

	//????????°??????????????????????????????????????????
	bool same( T a, T b ) {
		return find( M[a] ) == find( M[b] );
	}

	//????????°????????????????????°?????????
	long long int group() {
		set<long long int>S;
		for( long long int i = 0; i < V.size(); i++ ) {
			S.insert( find( V[i] ) );
		}
		return S.size();
	}

	//??°?????????????±???????????????°?????????
	long long int count( T a ) {
		return C[find( M[a] )];
	}

	//????±???????????????°????????????ID?????????
	long long int groupID( T a ) {
		return find( M[a] );
	}

	//????????°?????????????????????????????????
	vector<T>friendList( T a ) {
		long long int inputID = find( M[a] );
		vector<T>ret;
		for( auto now : M ) {
			if( find( now.second ) == inputID ) {
				ret.emplace_back( now.first );
			}
		}
		return ret;
	}

private:
	vector<long long int>C, V, rank;
	map < T, long long int>M;
	long long int size;

	//?\?????????§?????????
	long long int find( long long int x ) {
		if( V[x] == x )return x;
		else return V[x] = find( V[x] );
	}
};


int main() {
	long long int N, W, H;
	cin >> N >> W >> H;
	UF<long long int>uf;
	for( size_t i = 0; i < N; i++ ) {
		uf.push( i );
	}

	vector<pair<long long int, long long int>>D( N );
	long long int Wsum = 0, Hsum = 0;
	map<long long int, long long int>xmemo, ymemo;
	bool kabef = false;
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i].first >> D[i].second;
		if( !xmemo.count( D[i].first ) ) {
			xmemo[D[i].first] = i;
		} else {
			uf.merge( xmemo[D[i].first], i );
		}
		if( !ymemo.count( D[i].second ) ) {
			ymemo[D[i].second] = i;
		} else {
			uf.merge( ymemo[D[i].second], i );
		}
		if( D[i].first == 1 ) {
			kabef = true;
		}
		if( D[i].first == W ) {
			kabef = true;
		}
		if( D[i].second == 1 ) {
			kabef = true;
		}
		if( D[i].second == H ) {
			kabef = true;
		}
	}
	long long int ans = N - 1;
	if( uf.group() != 1 ) {
		if( kabef ) {
			ans += uf.group() - 1;
		} else {
			ans += (uf.group()-1)+1;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 12284
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n;
    cin>>n;
    long x;
    cin>>x;
    if(x>1&&x<n)
    {
        cout<<"Yes"<<endl;
        for(long i=x+n;i<2*n;i++)cout<<i<<endl;
        for(long i=1;i<x+n;i++)cout<<i<<endl;
        return 0;
    }
    if(x>=n&&x<2*n-1)
    {
        cout<<"Yes"<<endl;
        for(long i=x-n+1;i<2*n;i++)cout<<i<<endl;
        for(long i=1;i<=x-n;i++)cout<<i<<endl;
        return 0;
    }
     cout<<"No"<<endl;




}


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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< std::vector< int > > route(N);
    for(int i=0; i<M; i++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        route[tmp1 - 1].push_back(tmp2 - 1);
    }
    int S, T;
    std::cin >> S >> T;
    
    std::vector< std::vector< bool > > en(3, std::vector< bool >(N, true));
    
    std::deque< int > No_deq;
    std::deque< int > move_deq;
    No_deq.push_back(S - 1);
    move_deq.push_back(0);
    
    while(!No_deq.empty()){
        int cur_No = No_deq[0];
        int cur_move = move_deq[0];
        No_deq.pop_front();
        move_deq.pop_front();
        
        if(cur_No == T - 1 && cur_move % 3 == 0){
            std::cout << cur_move / 3 << std::endl;
            return 0;
        }
        
        if(en[cur_move % 3][cur_No]){
            en[cur_move % 3][cur_No] = false;
        }else{
            continue;
        }
        
        for(int i=0; i<route[cur_No].size(); i++){
            No_deq.push_back(route[cur_No][i]);
            move_deq.push_back(cur_move + 1);
        }
    }
    
    std::cout << -1 << std::endl;
    
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string res;
    for (int i = 0; i < N; i++) {
        res += S[i];
        res += T[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<int> a(m), b(m);
	std::vector<std::vector<int>> g(n), rg(n);
	for(int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);

		g[a[i]].push_back(b[i]);
		rg[b[i]].push_back(a[i]);
	}

	std::vector<int> order;
	std::vector<bool> used(n, false);
	auto dfs = [&](auto&& dfs, int v) {
		if(used[v]) return; used[v] = true;
		for(auto e: g[v]) dfs(dfs, e);
		order.push_back(v);
	};
	for(int i = 0; i < n; i++) dfs(dfs, i);	
	reverse(begin(order), end(order));

	int cnt = 0;
	std::vector<int> comp(n, -1);
	auto dfs2 = [&](auto&& dfs2, int v, int cnt) {
		if(comp[v] != -1) return; comp[v] = cnt;
		for(auto e: rg[v]) dfs2(dfs2, e, cnt);
	};
	for(auto v: order) if(comp[v] == -1) dfs2(dfs2, v, cnt++);

	std::vector<int> in(cnt), out(cnt);
	for(int i = 0; i < m; i++) {
		int x = comp[a[i]], y = comp[b[i]];
		if(x == y) continue;
		in[x]++;
		out[y]++;
	}

	int A = 0, B = 0, ans = 0;
	for(auto v: in) A += !v;
	for(auto v: out) B += !v;
	ans = std::max(A, B);
	if(cnt == 1) ans = 0;
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 6244
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int k2 = 2 * k;
    vector<vector<int>> ys(k2), points(k2, vector<int> (k2));
    for(int i = 0; i < n; i++){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W'){
            y += k;
        }
        x %= k2;
        y %= k2;
        ys[x].push_back(y);
    }
    for(int x = 0; x < k2; x++){
        sort(ys[x].begin(), ys[x].end());
        for(int j = 0; j < k; j++){
            auto l = lower_bound(ys[x].begin(), ys[x].end(), j),
                 r = lower_bound(ys[x].begin(), ys[x].end(), j + k);
            points[x][j] = r - l;
            // points[x][k + j] = ys[x].size() - (r - l);
        }
        for(int j = k; j < k2; j++){
            auto l = lower_bound(ys[x].begin(), ys[x].end(), j),
                 r = lower_bound(ys[x].begin(), ys[x].end(), j - k);
            points[x][j] = ys[x].end() - l + r - ys[x].begin();
        }
    }
    // prints(ys);
    // prints(points);
    vector<vector<int>> anss(k2, vector<int> (k2));
    int ans = 0;
    for(int i = 0; i < k2; i++){
        int cand = 0;
        for(int j = 0; j < k; j++){
            cand += points[j][i];
        }
        ans = max(ans, cand);
        anss[i][0] = cand;
        for(int j = 0; j < k; j++){
            cand -= points[j][i];
            cand += points[k + j][i];
            ans = max(ans, cand);
            anss[i][j] = cand;
        }
        for(int j = 0; j < k; j++){
            cand -= points[k + j][i];
            cand += points[j][i];
            ans = max(ans, cand);
            anss[i][k + j] = cand;
        }
    }
    for(int i = 0; i < k2; i++){
        for(int j = 0; j < k2; j++){
            ans = max(ans, anss[i][j] + anss[(i + k) % k2][(j + k) % k2]);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
#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;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int k, n; cin >> k >> n;
  vector <ll> a(n);
  for(auto &x : a) cin >> x;
  ll sum = 0;
  for(int i = 0; i < n - 1; i++) {
    sum += abs(a[i + 1] - a[i]);
  }
  ll ans = sum;
  //cout << ans << '\n';
  for(int i = 0; i < n - 1; i++) {
    ll cur = sum;
    cur = (cur - abs(a[i + 1] - a[i]));
    cur = cur + (k - abs(a[0] - a[n - 1]));
    ans = min(ans, cur);
  }
  print(ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define rep(i,n) for(int64_t i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr int64_t INF=(1ll<<60);
constexpr int64_t mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;cin>>s;
    sort(s.begin(),s.end());
    ll n=s.size();

    bool ok=false;
    rep(i,n-1){
        if(s[i]!=s[i+1]) ok=true;
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	// adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	// adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	// if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;

	public Graph() {
		totalVertex = 0;
	}

	public int getTotalVertex() {
		return totalVertex;
	}

	// load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for (i = 0; i < totalVertex; i++) {
			ifSettled[i] = false;
			for (j = 0; j < totalVertex; j++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for (i = 0; i < totalVertex; i++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for (j = 0; j < degree; j++) {
				v = in.nextInt();
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}
		}
		in.close();
	}

	// return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}

	// return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if (adjMatrix[u][v] == 1)
				tmp.add(v);
		}
		return tmp;
	}

	// return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if ((adjMatrix[u][v] == 1) && (ifSettled[v] == false))
				tmp.add(v);
		}
		return tmp;
	}

	// return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for (v = 0; v < totalVertex; v++) {
			if ((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}

	// implement the following
	public int[] Dijkstra(int s) {
		int[] out = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++) { // Initialize
			out[i] = Integer.MAX_VALUE;
		}
		out[s] = 0;
		ifSettled[s] = true;

		int set = s;
		boolean cont = true;
		LinkedList<Integer> neighbors;

		while (cont) {
			neighbors = getUnsettledNeighbors(set); // Find next-closest vertex
			for (int i : neighbors) {
				if (out[i] > out[set] + getWeight(set, i)) {
					out[i] = out[set] + getWeight(set, i);
				}
			}
			set = getUnsettledNearest(out);
			ifSettled[set] = true;
			cont = false;
			for (int i = 0; i < totalVertex; i++) {
				if (ifSettled[i] == false) {
					cont = true;
				}
			}
		}
		return out;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for (int i = 0; i < g.getTotalVertex(); i++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40392
/*input
1000000
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld n;
	cin >> n;
	lld sm=(n*(n+1))/2; 
	lld rm=n/3,rm2=n/5,rm3=n/15;
	sm=sm-(3*rm*(rm+1))/2 - (5*rm2*(rm2+1))/2 + (15*rm3*(rm3+1))/2;
	cout << sm << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (1 << 29)
#define MOD 10000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  ll res = 0;
  string s;
  cin >> s;
  REP(i,(s.size()-1)/2+1){
    if(s[i] != s[s.size()-i-1])res++;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
int N,M,A,B,p[1<<17];
vector<int>G[1<<17];
queue<int>q;
bool used[1<<17];
inline void solve(void){
  in(N,M);
  rep(i,M){
    in(A,B);
    A--;
    B--;
    G[A].pb(B);
    G[B].pb(A);
  }
  p[0]=0;
  q.push(0);
  used[0]=true;
  while(!q.empty()){
    int u=q.front();q.pop();
    for(auto e:G[u]){
      if(!used[e]){
        used[e]=true;
        q.push(e);
        p[e]=u;
      }
    }
  }
  out("Yes");
  up(i,1,N-1)out(p[i]+1);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 11400
#include <cstdio>
using namespace std;
int N, A, T[100001], ans;
int main() {
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) {
        scanf("%d", &A);
        T[A] = i;
    }
    for(int i = 1; i <= N; ++i) printf("%d ", T[i]);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;

    string ans;
    rep(i,n){
        ans += s[i];
        ans += t[i];
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, m;
int cnt[114514];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		cnt[a - 1]++; cnt[b - 1]++;
	}
	rep(i, n) {
		if (cnt[i] % 2) {
			cout << "NO" << endl; return 0;
		}
	}
	cout << "YES" << endl;
}

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

typedef long long ll;

int main() {
    string s;
    int K;
    cin >> s >> K;
    rep(i, s.size()) {
        int d = ('a' + 26 - s[i]) % 26;
        if (K >= d) {
            s[i] = 'a';
            K -= d;
        }
    }
    s[s.size() - 1] = (s[s.size() - 1] - 'a' + K) % 26 + 'a';
    cout << s << "\n";
}

Measured memory_bytes: 512
import Data.List
import Data.Maybe

main = do
  [n,k] <- map read.words <$> getLine
  as <- map read.words <$> getLine
  print $ solve n k as

solve :: Int -> Int -> [Int] -> Int
solve n k as = fromJust $ find eval ds where
  eval d = f $ zip ir dr where
    ir = scanl (+) 0 ms
    dr = scanr (+) 0 $ map (d-) ms
    ms = sort $ map (`mod` d) as
    f ((i,d):rest)
      | i == d = i <= k
      | otherwise = i < d && f rest
    f _ = False
  ds = reverse $ divisiors $ sum as

divisiors n = small ++ reverse large where
  (small, large) = f $ takeWhile ((<=n).(^2)) [1..]
  f (x:xs)
    | r == 0 && q /= x = (x:sm, q:la)
    | r == 0 = (x:sm, la)
    | otherwise = (sm, la)
    where
      (sm, la) = f xs
      (q, r) = divMod n x
  f _ = ([], [])

Measured memory_bytes: 1532
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll POW[61],height[62];

ll N,I,J;

void func(){

	ll tmp_h = POW[N]-I+1;

	height[1] = 1;

	for(ll i = N; i >= 1; i--){
		height[i+1] = tmp_h;
		if(tmp_h > POW[i]/2){
			tmp_h = POW[i]-tmp_h+1;
		}
	}

	queue<char> Q;

	ll width,mid,loc = J;

	ll k,R_height,L_height,thick;

	for(ll i = N; i >= 1; i--){

		k = N-i+1;

		width = POW[i];
		mid = width/2;

		thick = POW[k-1];
		tmp_h = height[k];

		if(loc <= mid){

			L_height = thick+(thick-tmp_h)+1;

			R_height = tmp_h;

			if(L_height == height[k+1]){

				loc = mid-(loc-1);
				Q.push('L');

			}else{
				Q.push('R');
			}

		}else{

			L_height = tmp_h;

			R_height = thick+(thick-tmp_h)+1;

			if(R_height == height[k+1]){

				loc = width-loc+1;

				Q.push('R');
			}else{

				loc -= mid;
				Q.push('L');
			}
		}
	}

	while(!Q.empty()){
		printf("%c",Q.front());
		Q.pop();
	}
	printf("\n");
}

int main(){

	POW[0] = 1;
	for(int i = 1; i < 61; i++)POW[i] = 2*POW[i-1];

	while(true){
		scanf("%lld %lld %lld",&N,&I,&J);
		if(N == 0 && I == 0 && J == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>

int main(){
	int i,j;
	int w,n,ab[2][30],wp[30],ans[30];

	for(i=0;i<30;i++){
		ab[0][i]=-1;
		ab[1][i]=-1;
		wp[i]=i+1;
		ans[i]=0;
	}

	scanf("%d %d",&w,&n);
	for(i=0;i<n;i++) scanf("%d,%d",&ab[0][i],&ab[1][i]);

	for(i=0;i<w;i++){
		j=0;
		while(j<n){
			if(ab[0][j]==wp[i]){
				wp[i]=ab[1][j];
			}
			else if(ab[1][j]==wp[i]){
				wp[i]=ab[0][j];
			}
			j++;
		}
		ans[wp[i]-1]=i+1;
	}
	for(i=0;i<w;i++) printf("%d\n",ans[i]);



	return 0;
}

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

int num[15];
int dp[100010];

void setNum()
{
	int cnt=0;
	num[cnt]=1;
	cnt++;
	for(int i=1;pow(6,i)<=100000;i++,cnt++)
		num[cnt]=pow(6,i);
	for(int i=1;pow(9,i)<=100000;i++,cnt++)
		num[cnt]=pow(9,i);
	return;
}

int ans(int n)
{
	if(n==0)return 0;
	if(dp[n]!=-1)return dp[n];	
	
	int tmp=2e9;
	for(int i=0;i<12;i++)
	{
		if(n-num[i]>=0)
			tmp=min(tmp,ans(n-num[i])+1);
	}
	dp[n]=tmp;
	return dp[n];
}

int main()
{
	setNum();
	
	int N;
	cin >> N;
	
	for(int i=0;i<=N;i++)dp[i]=-1;
	cout << ans(N) << endl;
	return 0;
}

Measured memory_bytes: 3712
import Data.List

toInteg :: String -> Integer
toInteg = read :: String -> Integer

prod :: Integer -> [Integer] -> Integer
prod n l
  | n > 10^18 = -1
  | l == [] = n
  | otherwise = prod (n * (head l)) (tail l)

main = do
  n <- toInteg <$> getLine
  a <- map toInteg . words <$> getLine
  print $ prod 1 (sort a)


Measured memory_bytes: 68252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, l;
  string s;
  cin >> n >> l;
  vector<string> vec(n);
    
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  s=vec.at(0);
  
  for(int i=1; i<n; i++){
    s += vec.at(i);
  }
  cout << s <<endl; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int l = sc.nextInt();
                String[] s = new String[n];
                for(int i = 0 ; i < n ; i++){
                        s[i] = sc.next();
                }
                sc.close();
                Arrays.sort(s);
                for(int i = 0 ; i < n - 1 ; i++){
                        System.out.print(s[i]);
                }
                System.out.println(s[n - 1]);
        }
}
//ここに一言添えます
//焼き鳥おいしいですよね

Measured memory_bytes: 37576
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  string s;
  cin >> s;

  int ans = 0;
  if(s[0] == 'R') ans++;
  if(s[1] == 'R'){
    ans++;
  }
  if(s[2] == 'R'){
    if(s[1] == 'R') ans++;
    else ans = 1;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3588
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let nab: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nab[0];
    let a = nab[1];
    let b = nab[2];
    println!("{} {}",  cmp::min(a,b), cmp::max(0, a + b - n));
}


Measured memory_bytes: 4352