akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
ll x, k, d;
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","w",stdout);
    cin >> x >> k >> d;
    ll num = abs(x / d);
    ll ans;
    if (num >= k)
    {
        ans = abs(x) - k * d;
    } else
    {
        k -= num;
        k %= 2;
        x %= d;
        if (k > 0)
        {
            if (x > 0)
            {
                x -= d;
            } else
            {
                x += d;
            }
        }
        ans = abs(x);
    }
    cout << ans << endl;
    return 0;
}




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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

class UF{
    public:
    vector<int> par;
    UF(int n):par(n,-1){}
    int operator[](int x){return (par[x] <= -1)?x:par[x] = operator[](par[x]);}
    void operator()(int x,int y){
        x = operator[](x);
        y = operator[](y);
        if(x == y)return;
        if(x > y)swap(x,y);
        par[x] += par[y];
        par[y] = x;
    }
    int size(int x){x = operator[](x);return -par[x];}
};

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    UF uf(n);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf(a,b);
    }
    int count = 0;
    for(int i=1;i<n;++i){
            if(uf[i] != uf[0]){
                uf(i,0);
                count++;
            }
    }
    cout << count << endl;
    return 0;
    
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;
			
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000001;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	vi ans(n+1);
	int cnt=0;
	for(int i=n;i>=1;i--){
		int len=0;
		for(int j=i;j<=n;j+=i){
			len+=ans[j];
			len%=2;
		}
		if(len!=a[i-1])
		ans[i]=1;
		if(ans[i])cnt++;
	}
	int flag=0;
	for(int i=1;i<=n;i++){
		int len=0;
		for(int j=i;j<=n;j+=i){
			len+=ans[j];
			len%=2;
		}
		if(len!=a[i-1]){
			flag++;
			break;
		}
	}
	if(flag)cout<<-1;
	else{
		cout<<cnt<<"\n";
		for(int i=1;i<=n;i++){
			if(ans[i]){
				cout<<i<<' ';
			}
		}
	}
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 2560
#include <stdio.h>
#define MAX 100000

int n,k;
long long T[MAX];
int i;

int check(long long P)
{
   int  i=0;
    for(int j=0;j<k;j++)
    {
        long long s=0;
        while(s+T[i]<=P)
        {
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve()
{
    long long left=0;
    long long right=100000*10000;
    long long mid;
    while(right-left>1)
    {
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    return right;
}

int main(void)
{
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&T[i]);
    }
    long long ans=solve();
    printf("%d\n",ans);
}




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

int h, w, m;
map<int, vector<int>> ord;
set<pair<int, int>, greater<pair<int, int>>> ops;
map<int, int> cnt;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w >> m;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        ord[x].push_back(y);
        cnt[y]++;
    }
    for(auto &i : cnt) ops.insert({i.second, i.first});
    int ans = 0;
    for(auto &i : ord){
        for(int j : i.second){
            ops.erase({cnt[j]--, j});
            ops.insert({cnt[j], j});
        }
        ans = max(ans, (int)i.second.size() + (ops.begin() -> first));
        for(int j : i.second){
            ops.erase({cnt[j]++, j});
            ops.insert({cnt[j], j});
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 64504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main()
{
  ll MOD = 1000000007;
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h)
    cin >> a[i];
  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  while (!q.empty())
  {
    auto p = q.front();
    int y = p.first;
    int x = p.second;
    q.pop();
    if (x < w - 1 && a[y][x+1] == '.')
    {
      if (dp[y][x+1] == 0)
        q.emplace(y, x + 1);
      dp[y][x+1] = (dp[y][x+1] + dp[y][x]) % MOD;
    }
    if (y < h - 1 && a[y+1][x] == '.')
    {
      if (dp[y+1][x] == 0)
        q.emplace(y + 1, x);
      dp[y+1][x] = (dp[y+1][x] + dp[y][x]) % MOD;
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 9216
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var H = int.Parse(_[0]);
            var W = int.Parse(_[1]);

            var __ = Console.ReadLine().Split();
            var h = int.Parse(__[0]);
            var w = int.Parse(__[1]);

            var s = H * W;
            s -= h * W;
            s -= ((w * H) - (h * w));

            Console.WriteLine(s);
        }
    }
}


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

int main(){
  int N;
  cin >>N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin >>D.at(i);
  }
  int sum=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum += D.at(i)*D.at(j);
    }
  }
  cout <<sum <<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

// ABC062
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveB();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		List<Integer> a = Arrays.asList(0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0);
		if (a.get(x - 1) == a.get(y - 1)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int y = sc.nextInt();
		int x = sc.nextInt();
		// 縦軸
		for (int i = 0; i < (y + 2); i++) {
			for (int j = 0; j < x + 2; j++) {
				if (i == 0 || i == y + 1) {
					System.out.print("#");
					if (j == x + 1) {
						System.out.println();
					}
				} else {
					String a = sc.nextLine();
					if (!a.equals("")) {
						System.out.println("#" + a + "#");
						break;
					}
				}
			}
		}
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 22996
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#define Max 100005
#define INF 1000000000000000000
using namespace std;



int max(int a,int b){
	return (a<b)?b:a;
}

int main(){

	long long int ac[Max],wa[Max],n,m,x;
	string s;
	for(int i=0;i<Max;i++){
		ac[i]=wa[i]=0;
	}
	scanf("%lld%lld",&n,&m);
	while(m--){
		cin >> x >> s;
		if(s == "WA"){
			if(ac[x] == 0)
				wa[x]++;
		}else{
			ac[x]++;
		}
	}

	long long int penalty = 0,solved=0;

	for(int i=1;i<=n;i++){
		if(ac[i] > 0){
			solved++;
			penalty += wa[i];
		}
		
	}

	printf("%lld %lld\n",solved,penalty);

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;

int main()
{
	int N,M;cin >> N >>M;
	vector<int> height(N);
	int h;
	for (int i=0;i<N;i++) 
	{
		cin >>h;
		height[i]=h;
	}
	vvi graph(N,vi());
	int u,v;
	for (int i=0;i<M;i++)
	{
		cin >> u >> v;
		u--;v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	vector<bool> ans(N,false);
	bool can=true;
	for (int i=0;i<N;i++)
	{
		can=true;
		for (int j=0;j<graph[i].size();j++)
		{
			v=graph[i][j];
			if (height[i]<=height[v])
			{
				can=false;
				break;
			}
		}
		if (can) ans[i]=true;
	}
	int cnt=0;
	for (int i=0;i<N;i++)
	{
		if (ans[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;

}

Measured memory_bytes: 8688
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	s := make([]string, n)
	st := make([]int, n)
	for i := range s {
		var title string
		var time int
		fmt.Scan(&title, &time)
		s[i] = title
		if i > 0 {
			st[i] = time + st[i-1]
		} else {
			st[i] = time
		}
	}
	var x string
	fmt.Scan(&x)

	var ans int
	for i := range s {
		if s[i] == x {
			ans = st[len(st)-1] - st[i]
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
N = int(input())
p = [int(i) for i in input().split(" ")]
ans = 0

for i in range(0,N):
    if p[i] == (i+1):
        if i == N-1:
            ans += 1
        elif p[i+1] == (i+2):
            t = p[i]
            p[i] = p[i+1]
            p[i+1] = t
            ans += 1
        else:
            ans += 1
            t = p[i]
            p[i] = p[i+1]
            p[i+1] = t
            
print(ans)


Measured memory_bytes: 13940
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

struct piece{
	int w;
	int d;
	piece(){}
	piece(int w0, int d0){
		w =w0, d = d0;
	}
	int area(){
		return w * d;
	}
};

int main(void)
{
	int n, w, d;
	int p[100], s[100];
	
	vector<piece> cake;
	vector<int> area_array;
	
	while(1){
		cake.clear();
		
		scanf("%d %d %d", &n, &w, &d);
		if(n == 0 && w == 0 && d == 0) break;
		cake.push_back( piece(w, d) );
		
		for(int i = 0; i < n; i++) scanf("%d %d", &p[i], &s[i]);
		
		
		int pos, pw, pd;
		piece pc1, pc2;
		
		for(int i = 0; i < n; i++){
			pw = cake[p[i]-1].w, pd = cake[p[i]-1].d;
			pos = s[i] % (pw + pd);
			if(pos <= pw){
				pc1 = piece(pos, pd);
				pc2 = piece(pw - pos, pd);
			}else{
				pc1 = piece(pw, pos - pw);
				pc2 = piece(pw, (pw + pd) - pos);
			}
			if(pc1.area() < pc2.area()){
				cake.push_back(pc1);
				cake.push_back(pc2);
			}else{
				cake.push_back(pc2);
				cake.push_back(pc1);
			}
			cake.erase(cake.begin() + (p[i]-1));
		}
		
		area_array.clear();
		for(int i = 0; i < (int)cake.size(); i++) area_array.push_back( cake[i].area() );
		sort(area_array.begin(), area_array.end());
		
		for(int i = 0; i < (int)area_array.size(); i++){
			printf("%d", area_array[i]);
			if( i < (int)area_array.size() - 1) printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2664
from itertools import product
n, m = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(m)]
pl = list(map(int, input().split()))
ans = 0
for bits in product([0, 1], repeat=n):
    flag = True
    for i, ss in enumerate(s):
        cnt = 0
        for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
        if not cnt % 2 == pl[i]:
            flag = False
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 73904
#include<stdio.h>

int main (){
	int N;
	scanf ("%d", &N);
	char S[N];
	scanf("%s", S);
	int a = 1;
	if (N%2 != 0){
		printf("No\n");
		return 0;
	}
	for(int i = 0;i<(N/2);i++){
		if (S[i] == S[(N/2)+i]){
			a = 1;
		}
		else {
			a = 0;
			break;
		}
	}
	a == 1?printf("Yes\n"):printf("No\n");
	
	return 0;
}

Measured memory_bytes: 1620
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
lis = [list(map(int, input().split())) for i in range(q)]

ans = 0

for l in list(combinations_with_replacement(range(1, m+1), n)):
    S = 0
    for a, b, c, d in lis:
        if l[b-1] - l[a-1] == c:
            S += d
    if ans < S:
            ans = S

print(ans)


Measured memory_bytes: 21544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ldo;

#define pb push_back
const int MAX = 2e5 + 20;
long long n, p, fard, zoj, res, c[100][100];

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	for (int i = 0; i <= 70; i++) {
		for (int j = 0; j <= 70; j++) {
			if (!i || i==j) c[i][j] = 1;
			else if (j < i || !j) c[i][j] = 0;
			else c[i][j] = c[i][j-1] + c[i-1][j-1];
		}
	}
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a & 1) fard ++;
		else zoj ++;
	}
	if (p) {
		for (int i = 1; i <= fard; i+=2)
			res += c[i][fard];
		for (int j = 0; j < zoj; j++)
			res *= 2;
		cout << res << endl;
	}
	else {
		for (int i = 0; i <= fard; i+=2)
			res += c[i][fard];
		for (int i = 0; i < zoj; i++)
			res *= 2;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        char[] S = scanner.next().toCharArray();

        if ((S[0] == S[1] && S[2] == S[3] && S[0] != S[2])
                || (S[0] == S[2] && S[1] == S[3] && S[0] != S[1])
                || (S[0] == S[3] && S[1] == S[2] && S[0] != S[1])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


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

int main() {
  int D, N;
  cin >> D >> N;

  int ans = 0;

  if (D == 0) {
    if (N == 100) ans = 101;
    else ans = N;
  }
  else if (D == 1) {
    if (N == 100) ans = 10100;
    else ans = N * 100;
  }
  else {
    if (N == 100) ans = 1010000;
    else ans = N * 10000;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def solve():
    N, K = list(map(int, input().split()))

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)


Measured memory_bytes: 42224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		String str = sc.next();
		int len = str.length();
		char[] color = new char[len];
		int count = 1;

		for (int i = 0; i < len; i++) {
			color[i] = str.charAt(i);
		}

		for (int i = 0; i < len - 1; i++) {
			if (color[i] != color[i + 1]) {
				count++;
			}
		}
		System.out.println(count);

	}
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<int, int>
#define MP				make_pair

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

char city[1001][1001];
int d[1001][1001];
char goal = '1';
int H, W, N;

P bfs( P& s ) {
	fill( d[0], d[1001], INF );
	d[s.first][s.second] = 0;

	queue<P> que;
	que.push( s );
	while( !que.empty() ) {
		P p = que.front(); que.pop();
		if( city[p.first][p.second] == goal ) return p;

		REP( i, 4 ) {
			P now( p.first + dx[i], p.second + dy[i] );
			if( now.first >= 0 && now.first < W && now.second >= 0 && now.second < H && city[now.first][now.second] != 'X' && d[now.first][now.second] == INF ) {
				que.push( now );
				d[now.first][now.second] = d[p.first][p.second] + 1;
			}
		}
	}
}

signed main() {
	cin >> H >> W >> N;
	P s;
	REP( i, H ) {
		REP( j, W ) {
			cin >> city[j][i];
			if( city[j][i] == 'S' ) {
				s.first = j;
				s.second = i;
				city[j][i] = '.';
			}
		}
	}

	int ans = 0;
	REP( i, N ) {
		P t = bfs( s );
		ans += d[t.first][t.second];
		s = t;
		goal++;
	}


	cout << ans << endl;
}


Measured memory_bytes: 11952
#include <bits/stdc++.h>
using namespace std;
int a[5];

int main() {
	for(int i = 1; i <= 3; i++) cin >> a[i];
	sort(a + 1, a + 4);
	int ans = a[1] * a[2] / 2.0;
	cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a,b,ans = [[] for _ in range(n)],[],0
def solve(v,aa,bb):
    visited[v] = True
    for n in a[v]:
        if not visited[n] and set([v,n]) != set([aa,bb]):
            solve(n,aa,bb)

for i in range(m):
    x,y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)
    b.append((x-1,y-1))

for i in range(m):
    visited = [True]+[False]*(n-1)
    x,y = b[i]
    solve(0,x,y)
    if visited != [True]*n:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n;multiset<Pll>Set;
int prime[N],len,mrk[N],tot,ans;bool ok;
void getp(int n){
	rep(i,2,n){
		if(!mrk[i])prime[++len]=i;
		rep(j,1,len){
			if(i*prime[j]>n)break;
			mrk[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
int main() {
	read(n);getp(2200);
	rep(t,1,n){
		ll x;read(x);
		for(int i=1;i<=len&&1LL*prime[i]*prime[i]*prime[i]<=x;i++)
			while(x%(1LL*prime[i]*prime[i]*prime[i])==0)x/=1LL*prime[i]*prime[i]*prime[i];
		Pll b(1,1);
		rep(i,1,len)if(x%prime[i]==0){
			int cnt=0;while(x%prime[i]==0)x/=prime[i],cnt++;
			if(cnt==1)b.fi*=prime[i];else b.se*=prime[i];
		}
		ll s=sqrt(x)+0.5;if(s*s==x)b.se*=s;else b.fi*=x;
		if(b.fi==1&&b.se==1)tot++;
		else{
			Pll c(b.se,b.fi);multiset<Pll>::iterator it=Set.find(c);
			if(it!=Set.end())ans++,Set.erase(it);else Set.insert(b);
		}
	}
	ans=n-ans-max(0,tot-1);
	ans+=ok;cout<<ans;
	return 0;
}


Measured memory_bytes: 6656
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    for i in range(N):
        if i==0:
            a = A[i]
        else:
            a = a^A[i]
    if a == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 12416
import sys
from collections import deque
input = sys.stdin.readline


def main():
    N, Q = [int(x) for x in input().strip().split()]
    data = []
    for _ in range(N-1):
        data.append([int(x) for x in input().strip().split()])

    operate = [0] * (N+1)
    for _ in range(Q):
        node, point = [int(x) for x in input().strip().split()]
        operate[node] += point

    tree = [[] for _ in range(N+1)]
    for d in data:
        tree[d[0]].append(d[1])
        tree[d[1]].append(d[0])

    stack = deque()
    stack.append((0,1))  # スタートノード
    while len(stack) > 0:
        parent_node, proc_node = stack.popleft()
        operate[proc_node] += operate[parent_node]
        for child_node in tree[proc_node]:
            if child_node == parent_node:
                continue
            stack.append((proc_node, child_node))

    print(*operate[1:])


if __name__ == "__main__":
    main()


Measured memory_bytes: 118440
import heapq

N, M = map(int, input().split())
A = [-int(a) for a in input().split()]

H = []
for a in A:
    heapq.heappush(H, a)

for m in range(M):
    tmp = abs(heapq.heappop(H)) // 2
    heapq.heappush(H, -tmp)

SUM_A = 0
for h in H:
    SUM_A += int(h)
print(-SUM_A)


Measured memory_bytes: 64920
N,M=map(int,input().split())
mod=10**9+7
dp=[0]*(N+1)
dp[0]=1
dp[-1]=0
A=[]
for i in range(M):
  A.append(int(input()))
A=set(A)
#print(A)
for i in range(1,N+1):
  if dp[i-1]==0 and dp[i-2]==0:
    break
  elif i in A:
    continue
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)



Measured memory_bytes: 13984
#include <bits/stdc++.h>
using namespace std;
int n, x[55], all = 0, ans = 0;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", x + i);
		all += x[i];
	}
	for (int i = 0; i < n; i++)
		ans += (all - x[i]) * x[i];
	printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 256
import sys
f = sys.stdin
w = int(f.readline())
lots = [i + 1for i in range(w)]


n = int(f.readline())
for _ in range(n):
    a, b = map(int , f.readline().split(','))
    lots[a - 1], lots[b - 1] = lots[b - 1], lots[a - 1]

for i in lots:
    print(i)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int ctoi(const char);
int main(){
    string a, b;
    cin >> a >> b;
    string ans = "EQUAL";
    if(a.size() > b.size()) ans = "GREATER";
    else if(a.size() < b.size()) ans = "LESS";
    else{
        for(int i = 0; i < a.size(); i++){
            if(a.at(i) != b.at(i)){
                int aa = ctoi(a.at(i)), bb = ctoi(b.at(i));
                if(aa == bb) continue;
                else if(aa > bb)
                    ans = "GREATER";
                else if(aa < bb)
                    ans = "LESS";
                break;
            }
        }
    }
    cout << ans << endl;
}
int ctoi(const char c){
    switch(c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default : return -1;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

int main() {
	queue<int> q;
	string s;
	int k,n;
	cin >> n >>	k;
	//cout << n << k;
	
	cin >> s;
	//cout << s;
	int sum = 0;
	int maxSum = 0;
	
	if (k == 0) {
		for (int i = 0; i < n;) {
			
			int c = 0;
			
			while(i < n && s[i]=='1') {
				c++;
				i++;
			}
			if (c > maxSum) {
				maxSum = c;
			}
			if (i >= n) {
				break;
			}
			
			while(i < n && s[i]=='0') {
				i++;
			}
		}
	}
	else{
	
	for (int i = 0; i < n;) {
		k--;
		int c = 0;
		
		while(i < n && s[i]=='1') {
			c++;
			i++;
		}
		if (sum == 0)
			sum = c;
		if (i >= n) {
			break;
		}
		
		while(i < n && s[i]=='0') {
			c++;
			sum++;
			i++;
		}
		if (i >= n) {
				if (k < 0) {
					sum -= q.front();
					q.pop();
				}
			break;
		}
		
		int j = i;
		while(j < n && s[j]=='1') {
			sum++;
			j++;
		}
		if (j >= n) {
				if (k < 0) {
					sum -= q.front();
					q.pop();
				}
			break;
		}
		q.push(c);
		
		if (k < 0) {
			sum -= q.front();
			q.pop();
		}
		
		if (sum >= maxSum) {
			maxSum = sum;
		}
	}
	
	if (sum >= maxSum) {
		maxSum = sum;
	}
	
	}
	
	cout << maxSum << endl;
	
	
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    public void solve() {
    	long A = nl();
    	long B = nl();
    	long C = nl();
    	int X = ni();
    	int Y = ni();
    	int max = Math.max(X,  Y);
    	int min = Math.min(X,  Y);
    	long ans = A * X + B * Y;
    	ans = Math.min(ans, C * min * 2 + A * (X - min) + B * (Y - min));
    	ans = Math.min(ans, C * max * 2);
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s;cin>>s;
    if((s[0]==s[1] and s[1]==s[2]) or (s[1]==s[2] and s[2]==s[3])){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pans cout<<ans<<endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
  	string s;cin>>s;
    bool flag=false;
  	for(int i=0;i<3;i++){
      if(s[i]==s[i+1]){
        flag=true;
      }
    }
  int a=0;
  	for(int i=0;i<1000000000;i++){
      a+=1;
    }
  	if(flag){
      cout<<"Bad"<<endl;
    }else{
      cout<<"Good"<<endl;
    }
  
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

left_w = [0 for i in range(n + 2)]
right_e = [0 for i in range(n + 2)]

for idx, ch in enumerate(s, 1):
    if ch == 'E':
        right_e[idx] = 1
    else:
        left_w[idx] = 1

for i in range(1, n + 2):
    left_w[i] += left_w[i - 1]

for i in range(n, 0, -1):
    right_e[i] += right_e[i + 1]

min_turn = n
for i in range(1, n + 1):
    turn = left_w[i - 1] + right_e[i + 1]
    min_turn = min(min_turn, turn)

print(min_turn)


Measured memory_bytes: 28184
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
// const int INF = +100100100;
typedef pair<int,int> P;


#define MAX 10005

struct Node{
    int key;
    Node *r,*l,*p;
};

Node *NIL, *root;


void insert(int v){
    // 以下の命令は、local変数をグローバル変数にするために必要
    Node *z = (Node *)malloc((sizeof(Node)));
    z->key = v;
    z->l = z->r = z->p = NIL;
    // z->l = NIL;z->r = NIL;z->p = NIL;
    //以上でzの初期化終了.以下compare
    Node *c = root;//parent
    Node *pre =NIL;
    while(c!=NIL){
        pre=c;
        if(c->key<z->key){
            c=c->r;
        }else{
            c=c->l;
        }
    }
    z->p = pre;
    if(pre==NIL){
        root = z;
    }else if(pre->key>z->key)pre->l = z;
    else pre->r = z;
}

Node * find(int k, Node *c){
    while(c!=NIL && k!=c->key){
        if(c->key>k)c=c->l;
        else c = c->r;
    }
    return c;
}


void inorder(Node *v){
    if(v==NIL)return;
    inorder(v->l);
    printf(" %d",v->key);
    inorder(v->r);
}


void preorder(Node *v){
    if(v==NIL)return;
    printf(" %d",v->key);
    preorder(v->l);
    preorder(v->r);
}


int main(){
    int n;
    // root = NIL;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(s=="insert"){
            int v;
            cin >> v;
            insert(v);
        }
        else if(s=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(s=="find"){
            int v;
            cin >> v;
            Node *t = find(v,root);
            if(t!=NIL)cout<<"yes"<<endl;
            else cout << "no" << endl;
        }
        else continue;
    }
    return 0;
}


Measured memory_bytes: 21956
import sys

def main():
    n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    x1 = x-1
    y1 = y-1

    score = {i:0 for i in range(n)}

    for i in range(n-1):
        for j in range(i+1, n):
            diff = j - i
            cand = abs(x1 - i) + 1 + abs(y1 - j)
            cand2 = abs(y1 - i) + 1 + abs(x1 - j)
            result = min(diff, cand, cand2)
            score[result] += 1

    for i in range(1, n):
        print(score[i])

main()


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

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

	vector<int> d(N);

	for (int i = 0;i < N;i++) cin >> d[i];

	sort(d.begin(), d.end());
	decltype(d)::iterator result = std::unique(d.begin(), d.end());
	d.erase(result, d.end());

	cout << d.size() << endl;
}

Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using ull = __uint128_t;

using sc = signed char;
using si = signed int;
using sl = signed long long int;
using sll = __int128_t;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

namespace std {
  template <>
  struct is_integral<__int128_t> {
    constexpr static bool value = true;
  };
};

static sl N, R;

void solve(void) {
  if (N < 10) {
    cout << (R + 100 * (10 - N)) << endl;
  } else {
    cout << R << endl;
  }
}

int main(void) {
  cin >> N >> R;
  solve();
  return 0;
}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x = inint()

if x >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61864
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int arr[200000];
int arr2[200000];
int main() {
	cin >> N;
	rep(i, N){
		cin >> arr[i];
		arr2[i] = arr[i];
	}
	sort(arr, arr+N);
	int median1 = arr[N/2-1], median2 = arr[N/2];
	rep(i, N){
		if(arr2[i] <= median1) cout << median2 << endl;
		else cout << median1 << endl;
	}
}



Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N;
    int d[110];

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

    set<int> value;

    for (int i = 0; i < N; i++) {
        value.insert(d[i]);
    }

    cout << value.size() << endl;

    return 0;
}

Measured memory_bytes: 256
h, n = gets.split.map(&:to_i)
min_of = [0] * (h + 1)

magics = n.times.map{|i|
    gets.split.map(&:to_i)
}
(h + 1).times{|hp|
    min_of[hp] = magics.map{|m|
        if hp <= m[0]
            m[1]
        else
            min_of[hp - m[0]] + m[1]
        end
    }.min
}
puts min_of[h]

Measured memory_bytes: 27900
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    int rest = x-y-2*z,ans = 1;
    while(rest >= y+z){
        ans++;
        rest -= y+z;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  int x = 0;
  if (a+b<c) {
    if (4 * a*b < (c - a - b)*(c - a - b)) {
      cout << "Yes" << endl;
      x++;
    }
  }
  if (x == 0) {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var t=Arr.shift()-0;
for(var i=0;i<t;i++){
   var n=Arr.shift()-0;
   var arr=(Arr.shift()).split(" ").map(Number);
   var max=0;
   var min=0;
   var m=arr[0];
   for(var j=1;j<n;j++){
      max=Math.max(arr[j]-m,max);
      min=Math.min(arr[j]-m,min);
      m=arr[j];
   }
   console.log(max+" "+Math.abs(min));
}

Measured memory_bytes: 8960
#include <stdio.h>

void gcd(int x,int y){
	int d;
	d=x%y;
	while(d!=0){
	x=y;
	y=d;
	d=x%y;
	}
	
	printf("%d\n",y);
}

int main(void){
	int x,y,tmp;
	scanf("%d",&x);
	scanf("%d",&y);
	if(x<y){
		tmp=x;
		x=y;
		y=tmp;
	}
	gcd(x,y);
	return 0;
}


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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& 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;
	}
}

struct UnionFind{

	vector<int> parent;
	UnionFind(int N): parent(N){
		for(int i=0; i<N; i++) parent[i] = i;
	}

	int root(int x){
		if(parent[x] == x) return x;
		return parent[x] = root(parent[x]);
	}
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		parent[rx] = ry;
	}
	bool same(int x, int y){ return root(x)==root(y);}

};

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M);
	for(int i=0; i<M; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	int ans = 0;
	for(int i=0; i<M; i++){
		UnionFind tree(N);
		for(int j=0; j<M; j++){
			if(i==j) continue;
			tree.unite(a[j], b[j]);
		}
		bool is_connected = true;
		for(int j=0; j<N; j++){
			for(int k=j+1; k<N; k++){
				if(tree.same(j, k)) continue;
				is_connected = false;
				break;
			}
			if(is_connected==false) break;
		}
		if(is_connected == false) ans++;
	}

	cout << ans << endl;
}



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

using namespace std;

typedef long long ll;

int main()
{
    ll n , k , i , j , den , p , q;
    scanf("%lld %lld",&n,&k);
    ll now;
    double ans , d, ret;
    ans = 0;
    for(i = 1 ; i <= n ; i++)
    {
         p = i;
         now = 1;
         while(1)
         {
            if(p >= k)break;
            p = p*2LL;
            now = now*2LL;


         }
         now = now*n;

         d = now;
        ret = 1.0/d;
        ans += ret;
    }


    printf("%0.15lf\n",ans);


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<stdio.h>
using namespace std;


int main(){

	double x1, x2, y1, y2,L;
	cin >> x1 >> y1 >> x2 >> y2;



	L = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
	printf("%.10lf", L);


	


	return 0;
}

Measured memory_bytes: 1240
a, b, m = map(int, input().split())
a_s = list(map(int, input().split()))
b_s = list(map(int, input().split()))
m_s =[]

for _ in range(m):
    m_s.append(list(map(int, input().split())))

mini = min(a_s) + min(b_s)

for am, bm, sale in m_s:
    mini = min(mini, a_s[am-1]+b_s[bm-1]-sale)

print(mini)

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

class E
{
	static void Main()
	{
		var k = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var q = new Vector(a[0], a[1]);

		if (k % 2 == 0 && q.Norm % 2 == 1)
		{
			Console.WriteLine(-1);
			return;
		}
		var ps = new List<Vector> { new Vector() };
		var l = q.Norm % k == 0 ? 2 : k % 2 == 1 && q.Norm % 2 == 1 && q.Norm < k ? 4 : 3;
		if (l == 4) ps.Add(q.GetShotFor4(k));
		if (l >= 3) ps.Add(ps.Last() + (q - ps.Last()).GetShotFor3(k));
		while ((q - ps.Last()).Norm != 0) ps.Add(ps.Last() + (q - ps.Last()).GetShotFor2(k));
		Console.WriteLine(ps.Count - 1);
		foreach (var p in ps.Skip(1)) Console.WriteLine("{0} {1}", p.X, p.Y);
	}
}

struct Vector
{
	public int X;
	public int Y;
	public int Norm => Math.Abs(X) + Math.Abs(Y);
	bool IsXLong => Math.Abs(X) >= Math.Abs(Y);
	public Vector(int x, int y) { X = x; Y = y; }
	public static Vector operator +(Vector v, Vector w) => new Vector(v.X + w.X, v.Y + w.Y);
	public static Vector operator -(Vector v, Vector w) => new Vector(v.X - w.X, v.Y - w.Y);
	public Vector GetShotFor4(int k) => IsXLong ? new Vector(-Math.Sign(X) * (k - Norm), (Y > 0 ? -1 : 1) * Norm) : new Vector((X > 0 ? -1 : 1) * Norm, -Math.Sign(Y) * (k - Norm));
	public Vector GetShotFor3(int k)
	{
		var w2 = (Norm / k + 1) * k - Norm;
		if (w2 % 2 == 1) w2 += k;
		var w = Norm < k ? k - Norm / 2 : w2 / 2;
		return IsXLong ? new Vector(Math.Sign(X) * (k - w), (Y > 0 ? -1 : 1) * w) : new Vector((X > 0 ? -1 : 1) * w, Math.Sign(Y) * (k - w));
	}
	public Vector GetShotFor2(int k)
	{
		var dx = Math.Min(Math.Abs(X), k);
		return new Vector(Math.Sign(X) * dx, Math.Sign(Y) * (k - dx));
	}
}


Measured memory_bytes: 20924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, 0, N)
    {
        cin >> W.at(i);
    }
    int S1 = 0;
    int S2 = 0;
    int min = 100000;
    rep(i, 1, N)
    {
        rep(j, 0, i)
        {
            S1 += W.at(j);
        }
        rep(k, i, N)
        {
            S2 += W.at(k);
        }
        if (S1 > S2)
        {
            int diff = S1 - S2;
            if (min > diff)
            {
                min = diff;
            }
        }
        else
        {
            int diff = S2 - S1;
            if (min > diff)
            {
                min = diff;
            }
        }
        S1 = 0;
        S2 = 0;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        que.push(in);
    }

    for (int i = 0; i < m; i++) {
        que.push(que.top() >> 1);
        que.pop();
    }

    Int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,x,y,cou=0,v[3];
    char S[10],W[10],s[10],X,Y;
    scanf("%d %d %d",&A,&B,&C);
    if(B-A==C-B){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
//10:12-24+26+10
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<double,null_type,less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
double a[50050],b[50050],c[50050],cut[50050],INF=-1e9;pair<double,int> pm[50050];int n,j;ll med;
void solve() {
    for (int i=0;i<n;i++) pm[i]=make_pair((double)(c[i]-(a[i]*INF))/b[i],i);
    sort(pm,pm+n);// for (int i=0;i<n;i++) cout<<fixed<<setprecision(6)<<pm[i].first<<" ! "<<pm[i].second<<endl;
    double lo=INF,hi=-lo,mid;int cnt=63;
    while (cnt--) {//cout<<fixed<<setprecision(12)<<lo<<" # "<<hi<<" ";
        mid=(lo+hi)*0.5; ordered_set aa; ll inv=0;
        for (int i=0;i<n;i++) j=pm[i].second,cut[j]=((double)(c[j]-(a[j]*mid))/b[j]);
        for (int i=n-1;i>=0;i--) j=pm[i].second,aa.insert(cut[j]),inv+=(aa.order_of_key(cut[j]));
        if (inv<med) lo=mid; else hi=mid;//cout<<inv<<"\n";
    }
    cout<<fixed<<setprecision(12)<<lo;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);
    cin>>n; med=(n*(n-1))/2; med=(med+1)/2;
    for (int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    solve(); swap(a,b); cout<<" "; solve();
}

Measured memory_bytes: 4864