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

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

#define NIL NULL

Node *root;

Node * find(Node *u,int k){
  while(u!=NIL &&  k!=u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
  }
  return u;
}
Node * treeMinimum(Node *x){
  while(x->left!=NIL)x=x->left;
  return x;
}

Node * treeSuccessor(Node *x){
  Node *y=x->parent;
  if(x->right!=NIL)return treeMinimum(x->right);
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node *z){
  Node *y,*x;
  if(z->left ==NIL || z->right ==NIL)y=z;
  else y=treeSuccessor(z);
  //y no ko x
  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent==NIL)root=x;
  else{
    if(y==y->parent->left) y->parent->left=x;
  else {
    y->parent->right=x;
  }
  }


if(y!=z)z->key=y->key;

free(y);
}

void insert(int k){
Node *y=NIL;
  Node *x=root;
  Node *z;

  z=malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


while(x!=NIL){
  y=x;
  if(z->key < x->key){
    x=x->left;
  }else {
    x=x->right;
  }
 }

z->parent=y;
if(y==NIL){
  root=z;
 }else{
  if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }
 }
}


void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(strcmp(com,"find")==0){
	scanf("%d",&x);
	Node *t=find(root,x);
	if(t!=NIL)printf("yes\n");
	else printf("no\n");
      }else if(strcmp(com,"insert")==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strcmp(com,"print")==0){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
    }
      else if(strcmp(com,"delete")==0){
	scanf("%d",&x);
	treeDelete(find(root,x));
      }
  
  }


  return 0;
  }

Measured memory_bytes: 19364
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        //System.out.println("s = " + s);
        
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == ','){
                System.out.print(" ");
            }else{
                System.out.print(s.charAt(i));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 23124
class Dice:
  def make_dice(self, value):
    self.face = value
  def move(self, direc):
    if direc == "N":
      self.face = [self.face[1], self.face[5], self.face[2], self.face[3], self.face[0], self.face[4]]
      return self.face
    elif direc == "E":
      self.face = [self.face[3], self.face[1], self.face[0], self.face[5], self.face[4], self.face[2]]
      return self.face
    elif direc == "S":
      self.face = [self.face[4], self.face[0], self.face[2], self.face[3], self.face[5], self.face[1]]
      return self.face
    elif direc == "W":
      self.face = [self.face[2], self.face[1], self.face[5], self.face[0], self.face[4], self.face[3]]
      return self.face

num = list(map(int, input().split()))
direction = input()
dice = Dice()
dice.make_dice(num)
for i in range(len(direction)):
  dice.move(direction[i])
print(dice.face[0])


Measured memory_bytes: 5608
#include<iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int H[N];
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  
  int dif[N-1];
  for(int j=0; j<N-1; j++){
    dif[j] = H[j+1] - H[j];
  }
  
  int tmp = 0;
  int max = 0;
  for(int k=0; k<N-1; k++){
    if(dif[k]<1){
      tmp++;
      if(tmp>max){
        max = tmp;
      }
    }else{
      tmp = 0;
    }
  }
  cout << max;
  return 0;
}

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;
const int inf = 1001001001;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  string ans = "Yes";
  if(s.at(0) != 'h') ans = "No";
  if(s.at(n-1) != 'i') ans = "No";
  
  for(int i = 0; i < n-1; i++){
    
    if(s.at(i) != 'h' && s.at(i) != 'i'){
      ans = "No";
    }
    
    if(s.at(i) == 'h'){
      if(s.at(i+1) != 'i'){
        ans ="No";
      }
    }
    
    if(s.at(i) == 'i'){
    if(s.at(i+1) != 'h'){
        ans ="No";
      }
    }
    
    
    
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int im = n/2 + n%2;
    double ans = (0.0000 + im) / (0.000 + n);
    cout << fixed << setprecision(10) << ans;
    return 0;
}


Measured memory_bytes: 892
using System;

public class AtCoder
{
    public static void Main()
    {
        int n;
        n = int.Parse(Console.ReadLine().Trim());
        string[] s;
        s = Console.ReadLine().Trim().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        Array.Sort(a);
        int[] b = new int[n];
        int x = 1;
        int ans = 0;
        bool fsuc = true;
        int y = (int)Math.Pow(2, 30);
        BinarySearch f = new BinarySearch(a);
        for (int i = n - 1; i > -1; i--)
        {
            if (b[i] == 1) continue;
            while (y / 2 > a[i])
            {
                y /= 2;
            }
            x = y - a[i];
            for (int j = f.UpperBound(x, i) - 1; j > -1; j--)
            {
                if (a[j] == x)
                {
                    if (b[j] == 0)
                    {
                        if (i != j)
                        {
                            b[i] = 1;
                            b[j] = 1;
                            ans++;
                            while (false)
                            {
                                if (i > 0 && j > 0)
                                {
                                    if ((a[i - 1] == a[i]) && (a[j - 1] == x)
                                        && (b[i - 1] == 0) && (b[j - 1] == 0))
                                    {
                                        i--;
                                        j--;
                                        b[i] = 1;
                                        b[j] = 1;
                                        ans++;
                                    }
                                    else fsuc = false;
                                }
                                else fsuc = false;
                            }
                            fsuc = true;
                            break;
                        }
                    }
                }
                if (a[j] < x) j = -1;
            }
        }
        Console.WriteLine(ans);
    }
}

public class BinarySearch
{

    int[] a;
    public BinarySearch(int[] arr)
    {
        a = arr;
    }

    public int LowerBound(int x, int i)
    {
        int l = -1;
        int r = i;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (a[m] >= x) r = m;
            else l = m;
        }
        return r;
    }

    public int UpperBound(int x, int i)
    {
        int l = -1;
        int r = i;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (a[m] > x) r = m;
            else l = m;
        }
        return r;
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  vector<vi32> g(n);
  rep(i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  vi32 ans(n);
  vi32 lis(n + 10, 2e9);
  auto dfs = [&](auto dfs, int u, int p) -> void {
    int x = lower_bound(all(lis), a[u]) - lis.begin();
    int b = lis[x];
    lis[x] = a[u];
    int as = lower_bound(all(lis), 2e9) - lis.begin();
    ans[u] = as;
    for (auto v : g[u]) if (v != p) {
      dfs(dfs, v, u);
    }
    lis[x] = b;
  };
  dfs(dfs, 0, -1);
  rep(i, n) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 36552
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    int n = a.reduce!max;
    // n/2 に最も近い値を選ぶ
    int k = a.filter!(e => e != n).reduce!((a, b) => abs(a - n/2) <= abs(b - n/2) ? a : b);
    writeln(n, " ", k);
}

void main() {
    readint;
    auto a = readints;
    calc(a);
}


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

int main(){
	int n, k;
	string s;
	char c;
	cin >> n >> s >> k;
	c = s[k-1];
	for(int i=0; i<s.length(); i++){
		if(s[i]!=c){
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll x[100000], L;
int p[100001];
int d[100001][20];
int Q;

signed main(){
    cin >> N;
    rep(i, N) cin >> x[i];
    cin >> L;

    int r = 0;
    rep(i, N-1){
        while(r < N && x[r]-x[i] <= L) r++;
        p[i] = r-1;
    }
    p[N-1] = N;

    rep(j, 20) d[N][j] = N;
    for(int i=N-1; i>=0; i--){
        d[i][0] = p[i];
        rep(j, 19){
            d[i][j+1] = d[d[i][j]][j];
        }
    }

    cin >> Q;
    rep(i, Q){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        a--; b--;
        int ans = 1;
        int j = 19;
        while(d[a][0] < b){
            while(d[a][j] >= b){
                j--;
            }
            ans += (1<<j);
            a = d[a][j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 12568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int L, R;
  int Y = 2019;
  cin >> L >> R;
  if(R - L > Y){
    cout << 0 << endl;
  }else{
    L %= Y;
    R %= Y;
    int m = Y - 1;
    for(int j = L + 1;j <= R; j++){
      for(int i = L;i < j; i++){
        int x = i * j;
        int y = x % Y;
        if(m > y){
          m = y;
        }
      }
    }
    cout << m << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;

  string ans = "Yes";
  if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>
using namespace std;
int a[55][55];
char ss[55];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%s", ss);
        int len = strlen(ss);
        for(int j = 0; j < len; ++j){
            a[i][ss[j]-'a'] ++;
        }
    }
    string str = "";
    for(int i = 0; i < 26; ++i){
        //printf("%c\n", i+'a');
        int mi = 55;
        for(int j = 0; j < n; ++j) mi = min(a[j][i], mi);
        while(mi--) str += (i+'a');
    }
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Structured_Program_I
{
    class Print_a_Rectangle
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var H = token[0];
                var W = token[1];

                if (H == 0 && W == 0) break;

                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9316
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

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

	int diff_ab = abs(a - b);
	int diff_bc = abs(b - c);
	int diff_ac = abs(a - c);

	if ((diff_ab <= d && diff_bc <= d) || diff_ac <= d)
		cout << "Yes";
	else
		cout << "No";
}

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    let mut ans = 0;
    for &c in &s {
        if c == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args)
	{
		int N;
		int D;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		D = sc.nextInt();
		int d[] = new int[10];
		for(int i=0;i<D;i++)
		{
			d[sc.nextInt()]=1;
		}
		int sum=0;
		int maxD = String.valueOf(N).length();
		for(int i=maxD-1;i>=0;i--)
		{	
			int x = N/(int)Math.pow(10,i);
			N = N%(int)Math.pow(10, i);
			if(d[x]==1)
			{	
				for(int j=x;j<10;j++)
				{
					if(d[j]!=1)
					{
						x=j;
						N=0;
						break;
					}
					if(j==9)
					{
						j=0;
						N=sum%(int)Math.pow(10, i+2);
						sum = sum - N;
						N = N + (int)Math.pow(10, i+1);
						i=i+2;
						x=0;
						break;
					}
				}
			
			}
			sum = sum + x*(int)Math.pow(10, i);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 9556
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int t=in[0]-1;
	bool h=true;
	loop(i,1,n){
		if(t<in[i])t=in[i]-1;
		else if(t==in[i]);
		else h=false;
	}
	if(h)yes;
	else no;
}


Measured memory_bytes: 1024
//arc078_d.cpp
//Sun Jul 14 17:07:50 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<int> path[n];
	for (int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}

	queue<int> edge;
	edge.push(0);
	int distone[n];
	fill(distone,distone+n,-1);
	distone[0] = 0;
	while (edge.size()){
		int fromedge = edge.front();
		edge.pop();
		for (int i=0;i<path[fromedge].size();i++){
			int toedge = path[fromedge][i];
			if (distone[toedge] == -1){
				distone[toedge] = distone[fromedge]+1;
				edge.push(toedge);
			}
		}
	}

	queue<int> edge2;
	edge2.push(n-1);
	int distn[n];
	fill(distn,distn+n,-1);
	distn[n-1] = 0;
	while (edge2.size()){
		int fromedge = edge2.front();
		edge2.pop();
		for (int i=0;i<path[fromedge].size();i++){
			int toedge = path[fromedge][i];
			if (distn[toedge] == -1){
				distn[toedge] = distn[fromedge]+1;
				edge2.push(toedge);
			}
		}
	}

	int ans = 0;
	for (int i=0;i<n;i++){
		if (distone[i]<=distn[i]){
			ans++;
		}
	}


	if (ans>n-ans){
		cout << "Fennec" << endl;
	}else {
		cout << "Snuke" << endl;
	}
}

Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int num,t;
    cin >> num;
    for(int i=1;i<=num;i++)
        for(int j=0; j<=8 ;j++)
        if(i==pow(2,j))
            t=i;
    cout << t << endl;

return 0;

}


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

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

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i,n){
    cin >> w[i];
  }
  int ans=IINF;
  repp(i,0,101){
    int s=0,t=0;
    rep(j,n){
      if(j<i){
        s+=w[j];
      }else{
        t+=w[j];
      }
    }
    ans=min(ans,abs(s-t));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <array>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void) {

	std::vector<std::pair<int, int>> A;
	A.reserve(100000 + 1);
	long long int N, K;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int ai, bi;
		cin >> ai >> bi;
		A.push_back(make_pair(ai, bi));
	}

	std::sort(A.begin(), A.end(),
		[](pair<int, int> x, pair<int, int> y) -> int {
		return (x.first < y.first);
	});

	long long int k = 0;
	for (int i = 0; i < N; i++) {
		k += (long long int)(A[i].second);
		if (k >= K) {
			cout << A[i].first << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 1024
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/abc161_b

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        Integer[] a = new Integer[n];
        int s = 0;
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
            s += a[i];
        }
        Arrays.sort(a, new Comparator<Integer> () {
            public int compare(Integer x, Integer y) {
                return y - x;
            }
        });
        double t = (1.0 * s)/(4*m);
        for(int i=0; i<m; i++) {
            if(a[i]<t) {
                out.println("No");
                return;
            }
        }
        out.println("Yes");
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

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

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

a,b,c =lr()
k = ir()
flag = False
for i in range(k+1):
    bb = b
    cc = c
    for j in range(i):
        bb*=2
    for l in range(k-i):
        cc*=2
    if a < bb < cc:
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 77300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c;      // un解毒，解毒，毒
    cin>>a>>b>>c;
    ll ans=0;
    if(c>b+a)
    {
        ans=a+b+b+1;
    }
    else
    {
        ans=c+b;
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		out.println(Math.max(0,ir.nextInt()-ir.nextInt()));
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

ll inf=1e18;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  for(ll i=0;i<n;i++) {
    cin >> h[i];
  }
  ll l=0,r=1e9;
  ll temp=(l+r)/2;
  while(l+1<r) {
    ll count=0;
    for(ll i=0;i<n;i++) {
      if(h[i]-b*temp>0) {
        count+=(h[i]-b*temp+(a-b)-1)/(a-b);
      }
    }
    if(count>temp) {
      l=temp;
    }
    else {
      r=temp;
    }
    temp=(l+r)/2;
  }
  cout << r << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

template<typename T>
void fin(T const& v){ std::cout << v << std::endl; exit(0); }
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> a(N), b(N);
  for(auto& ai: a) std::cin >> ai;
  for(auto& bi: b) std::cin >> bi;

  int ans = 0;
  for(int k = 28; k >= 0; --k) {
    int m = 1<<k;
    // a, b in [0, 2m) , a+b in [0, 4m-1)
    std::sort(a.begin(), a.end());
    int sum = 0;
    for(auto bi: b) {
      // count [m, 2m) + [3m, 4m)
      int s1 = std::lower_bound(a.begin(), a.end(), m+m-bi)
             - std::lower_bound(a.begin(), a.end(), m-bi);
      int s2 = a.end() - std::lower_bound(a.begin(), a.end(), m*3-bi);
      sum ^= s1^s2;
    }
    if(sum%2) ans += m;
    for(auto& ai: a) ai &= m-1;
    for(auto& bi: b) bi &= m-1;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

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

        if (N <= 9) {
            System.out.println(N);
            return;
        }

        long curr = 9;
        int res = 9;
        while (curr < N) {
            curr = curr * 10 + 9;
            res += 9;
        }

        if (curr == N) {
            System.out.println(res);
            return;
        }

        int len = res / 9;
        long n = N;
        boolean isFull = true;
        while(len-- > 1) {
            if (n % 10 != 9) isFull = false;
            n /= 10;
        }

        System.out.println(isFull ? res - (9 - n) : res - (10 - n));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }

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

    int N; cin >> N;
    vel A(N), B(N), C(N);
    rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i]; rep(i,N) cin >> C[i];

    sort(all(A)), sort(all(B)) , sort(all(C));

    ll ans = 0;
    rep(i,N) {
        auto it = lower_bound(all(A), B[i]);
        ll index = it - A.begin();
        auto it2 = lower_bound(all(C), B[i]+1);
        ll index2 = C.end() - it2;
        ans += index * index2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>

#define rep(i,b,e) for (int (i) = (b); (i) < (e); (i)++)
typedef long long ll;

using namespace std;
 

int main() {
    ll N, i;
    cin >> N >> i;

    cout << N - i + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int suma = 0, sumb = 0;
	int ac = 0, bc = 0;
	bool flag = true;
	vector<int> a, b;
	
	cin>>N;
	
	a.resize(N);
	b.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		suma += a[i];
	}
	
	for(int i = 0; i < N; i++){
		cin>>b[i];
		sumb += b[i];
		
		if(a[i] < b[i]){
			if((b[i] - a[i])%2 == 0){
				ac += (b[i] - a[i])/2;
				// bc  += (b[i] - a[i])/2;
			} else {
				ac += (b[i] - a[i] + 1)/2;
				bc++;
				// bc  += (b[i] - a[i] + 1)/2 - 1;
			}
		} else if(a[i] > b[i]){
			bc += a[i] - b[i];
			// ac += (a[i] - b[i]);
		}
		// cout<<ac<<" "<<bc<<endl;
		
		if(a[i] != b[i]) flag = false;
	}
	
	
	if(suma > sumb) cout<<"No"<<endl;
	else if(suma == sumb){
		if(flag) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	} else {
		if(ac == bc) cout<<"Yes"<<endl;
		else if(ac > bc){ 
			cout<<"Yes"<<endl;
			// if(ac == bc * 2) cout<<"Yes"<<endl;
			// else cout<<"No"<<endl;
		}			
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include "iostream"
using namespace std;

int main() {
    int i;
	string moji;

	getline(cin, moji);
    
    for (i = 0; i <= moji.size(); i++) {
	    if ((moji[i] >= 'a') && (moji[i] <= 'z')) {
	    	moji[i] += 'A' - 'a';
	    }
	    else if ((moji[i] >= 'A') && (moji[i] <= 'Z')) {
	    	moji[i] += 'a' - 'A';
	    }
    }
    cout << moji << endl;

    return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <cmath>
#include <cctype>

using namespace std;
using ll = long long;

constexpr ll INF = 1LL << 60;

ll scanll(){
    ll ret = 0;
    for(char c = getchar_unlocked(); isdigit(c); c = getchar_unlocked()){
        ret = 10 * ret + c - '0';
    }
    return ret;
}

ll f(ll b, ll n){
    ll ret = 0;
    for(; n; n /= b) ret += n % b;
    return ret;
}

int main(){
    ll n = scanll();
    ll s = scanll();
    ll d = n - s;

    if(d < 0) puts("-1");
    else if(!d) printf("%lld\n", n + 1);
    else{
        ll ans = INF;
        for(ll i = 1; i <= sqrt(d); i++){
            if(d % i) continue;

            ll b = i + 1;
            if(ans > b && f(b, n) == s) ans = b;

            b = d / i + 1;
            if(ans > b && f(b, n) == s) ans = b;
        }

        if(ans == INF) puts("-1");
        else printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int>G[maxn];
queue<int> q;
int in[maxn];
int n,m;
int ans = 0;
int dp[maxn];
void topu(){
	while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(in[i] == 0) q.push(i);
		//if(in[i] == 0) printf("%d\n",i);
	}
	while(!q.empty()){
		int hh = q.front(); q.pop();
		int len = G[hh].size();
		for(int i = 0;i < len;i++){
			int tmp = G[hh][i];
			//printf("%d\n",tmp);
			in[tmp]--;
			dp[tmp] = max(dp[tmp],dp[hh] + 1);
			if(in[tmp] == 0) q.push(tmp);
		}
		//ans++;
		//printf("%d %d\n",ans,hh);
	}
	return ;
}
int main(){
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i = 1;i <= m;i++){
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		in[y]++;
	}
	topu();
	for(int i = 1;i <= n;i++)
		ans = max(dp[i],ans);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

struct UnionFind{
    ll par[201000];
    ll rank[201000];
    ll siz[201000];

    void init(){
        for (ll i = 0; i < 201000; i++){
            par[i] = i;
            rank[i] = 1;
            siz[i] = 1;
        }
    }

    ll find(ll x){
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }
        else{
            par[y] = x;
            siz[x] += siz[y];
            if (rank[y] == rank[x])rank[x]++;
        }
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    ll size(ll x){
        return siz[find(x)];
    }
};

ll n,m;

int main(){
    cin >> n >> m;
    UnionFind uf;
    uf.init();
    rep(i,m){
        ll x,y,z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x,y);
    }
    set<ll> sl;
    rep(i,n){
        sl.insert(uf.find(i));
    }
    cout << sl.size() << endl;
}

Measured memory_bytes: 9600
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;



int main()
{
    int64_t N, X;
    std::cin >> N >> X;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        //t -= X;
        A.push_back(t);
    }
    A.push_back(X);

    N += 1;
    std::sort(std::begin(A), std::end(A));

//    if (N ==1) {
//        std::cout << A[0];
//        return 0;
//    }

    std::vector<int64_t> DD;

    for (int64_t i = 0; i < N - 1; ++i) {
        DD.push_back(A[i+1] - A[i]);
    }

    int64_t result = DD[0];

    for (int64_t i = 1; i < DD.size(); ++i) {
        result = boost::math::gcd(result, DD[i]);
    }

    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int gcd(int a,int b){
    int r;
    if(a<b) swap(a,b);
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    
    //処理
    //出力
    if(b-a==c-b) cout << "YES" << ENT;
    else cout << "NO" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define long long long

const long MOD = 1e9 + 7;
const int N = 1e6 + 10;

int n, m, k;
long res;

long Count_Dis(int i) {return (long) (i + 1)*i/2;}

void Pre()
{
    res = 0;
    for (int i = 1; i <= n; ++i) {
        int tmp = n - i;
        res = (res + Count_Dis(tmp)) % MOD;
    }
    res = (res*m) % MOD, res = (res*m) % MOD;

    long rt = 0;
    for (int i = 1; i <= m; ++i) {
        int tmp = m - i;
        rt = (rt + Count_Dis(tmp)) % MOD;
    }

    rt = (rt*n) % MOD, rt = (rt*n) % MOD;
    res += rt, res %= MOD;
}

long power(long a, long n)
{
    if (n == 1) return a;
    if (n == 0) return 1;
    long tmp = power(a, n/2);
    if (n % 2 == 0) return (tmp * tmp) % MOD;
    tmp = (tmp * tmp) % MOD, tmp = (tmp * a) % MOD;
    return tmp;
}

int main()
{
    cin >> n >> m >> k;
    Pre();
    long nn = (long) n*m - 2, kk = k - 2;
    long tu = 1, mau = 1;
    for (int i = kk + 1; i <= nn; ++i) tu = (tu*i) % MOD;
    for (int i = 1; i <= nn - kk; ++i) mau = (mau*i) % MOD;
    mau = power(mau, MOD - 2);

    res = (res * tu) % MOD;
    res = (res * mau) % MOD;
    cout << res;

    return 0;
}


Measured memory_bytes: 256