akhauriyash/Code-Regression huggingface dataset:
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    let answer = [];
    
    for(let i=1; i<=N; i++) {
        let now = i;
        let cnt = 1;
        
        while(true) {
            if(now >= K) break;
            now *= 2;
            cnt++;
            // console.log("now:" + now);
            // console.log("cnt:" + cnt);
        }
        
        // console.log(cnt - 1);
        // console.log("----")
        
        let temp = (1 / N) * Math.pow(0.5, cnt - 1)
        
        answer.push(temp);
    }
    
    console.log(answer.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 14796
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, m, l, r, al, ar;
    cin >> n >> m;

    al = 1, ar = n;
    while (m--)
    {
        cin >> l >> r;
        al = max(al, l);
        ar = min(ar, r);
    }
    cout << max(0LL, ar - al + 1) << '\n';

    return 0;
}


Measured memory_bytes: 256
let lines = [];
let reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

// 標準入力の読み込み
reader.on('line', function(line) {
    lines.push(line);
});

reader.on('close', function() {

    // 処理の記述
    let [x, k, d] = lines[0].split(' ');
    x = parseInt(x);
    k = parseInt(k);
    d = parseInt(d);

    let ans = Math.abs(x);

    // xの絶対値がk * dより大きいとき
    if (Math.abs(x) > k * d) {
        if (x < 0) {
            ans = Math.abs(x + k * d);
        } else {
            ans = Math.abs(x - k * d);
        }
    } else {
        if (x < 0) {
            let cnt = 0;
            while( Math.abs(x) > d ) {
                x += d;
                cnt++;
            }

            ans = (k - cnt) % 2 == 0 ? Math.abs(x) : Math.abs(x + d);

        } else {
            let cnt = 0;
            while( Math.abs(x) > d ) {
                x -= d;
                cnt++;
            }
            ans = (k - cnt) % 2 == 0 ? Math.abs(x) : Math.abs(x - d);
        }
    }

    // 表示
    console.log(ans);
});

Measured memory_bytes: 33600
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var answer = 0L;
            var leaves = new long[ai.Length];

            for (var i = ai.Length - 2; i >= 0; i--)
            {
                leaves[i] = leaves[i + 1] + ai[i + 1];
            }

            var count = 1L;
            for (var i = 0; i < ai.Length; i++)
            {
                answer += count;
                count -= ai[i];
                if (count < 0)
                {
                    Console.WriteLine(-1);
                    return;
                }
                count = Math.Min(count * 2, leaves[i]);
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 38244
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1



A=[int(input()) for i in range(5)]
A.sort(key=lambda x:(x-1)%10,reverse=True)
ans=0
for i in range(4):
    ai=A[i]
    ans+=math.ceil(ai/10)*10
ans+=A[-1]
print(ans)


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

int main(){
    int n,m,l;
    cin >> n >> m >> l;

    vector< vector<long long int> > a;
    vector<  vector<long long int> > b;

    a.resize(n);
    for (int i=0;i<n;i++){
        a[i].resize(m);
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }

    b.resize(m);
    for (int i=0;i<m;i++){
        b[i].resize(l);
        for (int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }

    long long int ans =0;
    for (int i=0;i<n;i++){
        for (int k=0;k<l;k++){
            ans = 0;
            for (int j=0;j<m;j++){
                //cout << i << j << k << endl;
                ans += a[i][j] * b[j][k];
            }
            if (k>0){cout << " ";}
            cout << ans;
            if (k==l-1){cout << endl;}
        }
    }

    return 0;
}





Measured memory_bytes: 3212
#include<stdio.h>
int count =0;

void output(int array[], int x){
  int i;
  for(i = 0;i < x;i++){
    if(i > 0 && i < x){
      printf(" ");
    }
    printf("%d",array[i]);
    
  }
  printf("\n%d\n",count);
}
   

 void bubble(int array[], int x ){
  int i,j,tmp;
 
  for(i = 0; i < x-1;i++){
    for(j= x-1;j > i;j--){
      if(array[j-1]>array[j]){
	count++;
	tmp = array[j];
	array[j] = array[j-1];
	array[j-1] = tmp;
      }

    }
   
  }
  }


int main(){
  int x;
 
  int i;
  int array[101];
  scanf("%d",&x);
    for(i = 0;i< x;i++){
      scanf("%d",&array[i]);
    }
  bubble(array ,x);
  output(array ,x);

  return 0;
}



Measured memory_bytes: 2072
// C - Average Length
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi X(N),Y(N); rpz(i, N) cin>>X[i]>>Y[i];
	double sum = 0.0;
	rpz(i, N) rpz(j, i){
		int dx = X[i] - X[j];
		int dy = Y[i] - Y[j];
		sum += sqrt(dx*dx + dy*dy);
	}
	printf("%.10f\n", (sum*2)/N);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> 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<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
string s;
int a;
bool h=false;
int f(){
	vi in;
	while(s[a]!=']'){
		if(s[a]=='['){
			a++;
			in.pb(f());
			a++;
		}else{
			int num=0;
			while(s[a]!=']'){
				num*=10;
				num+=s[a]-'0';
				a++;
			}
			h=true;
			return num;
		}
	}
	sort(all(in));
	int sum=0;
	rep(i,in.size()/2+1)sum+=(h?in[i]/2+1:in[i]);
//	rep(i,in.size())cout<<" "<<in[i];cout<<endl;
	h=false;
	return sum;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		cin>>s;
		a=1;
		cout<<f()<<endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int W, H;
vector<string> m;
bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};
set<char> check(int x, int y, vector< vector<bool> >& checked) {
	set<char> res;
	if ( !inRange(x, y) ) return res;
	if (checked[y][x]) return res;
	checked[y][x] = true;
	if ( m[y][x] != '.' ) {
		res.insert(m[y][x]);
		return res;
	}
	REP(i, 4) {
		set<char> s = check(x+dx[i], y+dy[i], checked);
		EACH(e, s) res.insert(e);
	}
	return res;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while ( cin >> W >> H, W || H ) {
		m = vector<string>(H); cin >> m;
		map<char, int> ans;
		ans['W'] = 0;
		ans['B'] = 0;
		REP(y, H) REP(x, W) {
			switch (m[y][x]) {
				case 'W': break;
				case 'B': break;
				case '.':
				{
					vector< vector<bool> > checked(H, vector<bool>(W, false));
					set<char> s = check(x, y, checked);
					if (s.size() == 1) {
						ans[*s.begin()]++;
					}
				}
			}
		}
		cout << ans['B'] << " " << ans['W'] << endl;
	}
}

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

namespace ProgramingLearning
{
    class Program
    {
        static void Main(string[] args)
        {
            //var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            if(s[s.Length - 1] == 's')
            {
                Console.WriteLine(s + "es");
            }
            else
            {
                Console.WriteLine(s + "s");
            }

        }
    }
}

Measured memory_bytes: 25788
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
     
    static int num;
    static ArrayList<Integer> getsudo;
    static int[] ret;
    
    static void start()
    {
    	// 月土素因数探し
    	System.out.print(num + ":");
    	for (int i = 6; i <= num; i++) {
    		if( (i % 7) != 1 && (i % 7) != 6 ) continue;
    		if(ret[i] == 0) continue;
    		if(num % i == 0) System.out.print(" " + i);
		}
    	System.out.print("\n");
    }
     
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        // 月土数作り
    	getsudo = new ArrayList<Integer>();
    	for (int i = 1; i <= 300000; i++) {
    		if( (i % 7) == 1 || (i % 7) == 6 ) getsudo.add(new Integer(i));
    	}
    	
    	// 月土素数作り
    	ret = new int[300000+1];
    	for (int i = 0; i < (300000+1); i++) ret[i] = 1;
    	ret[0] = ret[1] = 0;
    	int loop = (int)(Math.sqrt(300000) + 1);
    	for (int i = 2; i <= loop; i++) {
    		if( (i % 7) != 1 && (i % 7) != 6 ) continue;
    		if(ret[i] == 0) continue;
    		for (Integer j : getsudo) {
    			if(j == 1) continue;
    			if(300000 < i*j) break;
    			ret[i*j] = 0;
    		}
    	}
        
        while(true)
        {
        	num = sca.nextInt();
        	if(num == 1) break;
            
            start();
        }
        
    }
}

Measured memory_bytes: 29232
#include <stdio.h>

int search(int A[], int n, int key)
{
    int i = 0;
    A[n] = key;
    while (A[i] != key)
        i++;
    return i != n;
}

int main()
{
    int i, n, A[10000 + 1], q, key, sum = 0;

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

    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if (search(A, n, key))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2712
#include <stdio.h>
#include <math.h>


int main(){

    int x;
    for(int i = 0;i<10000;i++){
        scanf("%d",&x);
        if(x == 0){
            break;
        }
        printf("Case %d: %d\n",i+1,x);
    }
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

int lcm(int x,int y){
  return x/__gcd(x,y)*y;
}

signed main() {
  int N, M;
  cin >> N >> M;

  int g = 1;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
    a[i] /= 2;

    g = lcm(g, a[i]);
  }

  int ans = 0;
  int i = 1;
  while(g*i <= M){
    ans++;
    i += 2;
  }

  REP(i, N) if((g/a[i])%2 == 0) {
    cout << 0 << endl;
    return 0;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x - r < 0 || x + r > w || y - r < 0 || y + r > h)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


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

#define MAX_N 100001

int par[MAX_N];  // ???
int depth[MAX_N]; // ??¨?????±???
int club[MAX_N] = {0};

// n????´???§?????????
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    depth[i] = 0;
  }
}

// ??¨??????????±???????
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// x??¨y????±??????????????????????
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (depth[x] < depth[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (depth[x] == depth[y])
      depth[x]++;
  }
}

// x??¨y???????????????????±????????????????
bool same(int x, int y) { return find(x) == find(y); }

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    init(n);
    int ans = 0;
    for(int i=0;i<k;++i){
        int a, b, c;
        cin >> a >> b >> c;
        if(ans != 0)continue;
        else if(a == 1){
            if(club[find(b)] != 0 && club[find(c)] != 0 && club[find(b)] != club[find(c)]){
                ans = i + 1;
                continue;
            }
            int b_par = find(b), c_par = find(c);
            unite(b, c);
            if(club[b_par] != club[c_par]){
                if(club[b_par] == 0)club[find(b)] = club[c_par];
                else club[find(c)] = club[b_par];
            }
        }else{
            if(club[find(b)] != 0 && club[find(b)] != c){
                ans = i + 1;
                continue;
            }
            club[find(b)] = c;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4252
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
#define pb push_back
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	int n;
	int a[200010], b[200010];
	cin >> n;
	rep(i, n)
	{
		cin >> a[i];
		b[i]=a[i];
	}
	sort(a, a+n);
	int x=a[(n/2)-1], y=a[n/2];
	rep(i, n)
	{
		if(b[i]<=x) cout << y << endl;
		else cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

l = [i for i in range(1,n+1)]

cnt = 0
for v in itertools.permutations(l, len(l)):
    if p == list(v):
        pi = cnt
    if q == list(v):
        qi = cnt 
    cnt += 1

print(abs(pi-qi))


Measured memory_bytes: 8904
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

#define INFTY 2000000000

int N;
int aN[100010];
int bN[100010];
int cN[100010];

int scoreA[100010];
int scoreB[100010];
int scoreC[100010];



int main() {

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


	scoreA[0] = aN[0]; scoreB[0] = bN[0]; scoreC[0] = cN[0];
	for (int i = 1; i < N; i++) {
		scoreA[i] = max(scoreB[i - 1], scoreC[i - 1]) + aN[i];
		scoreB[i] = max(scoreC[i - 1], scoreA[i - 1]) + bN[i];
		scoreC[i] = max(scoreA[i - 1], scoreB[i - 1]) + cN[i];
	}
	int out = scoreA[N - 1];
	out = max(out, scoreB[N - 1]);
	out = max(out, scoreC[N - 1]);


	cout << out << endl;
	


	return 0;
}

Measured memory_bytes: 2560
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    a = nl()

    ans = [0]*n

    for num in a:
        ans[num-1] += 1

    for value in ans:
        print(value)


if __name__ == '__main__':
    main()

Measured memory_bytes: 33648
#include <bits/stdc++.h>
#include <time.h>
//#include <random>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
#define re return
#define nins 4294967295
using namespace std;
typedef long long ll;
typedef long double ld;

//mt19937 rnd(0);

void solve() {
    ll n, sum = 0;

    cin >> n;
    for (ll i = 1; i <= n; i++)
    for (ll j = 1; j <= n; j++)
    for (ll k = 1; k <= n; k++)
        sum += __gcd(i, __gcd(j, k));

    cout << sum;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef _LOCAL
        in("input.txt");

        int t = 1;
//        cin >> t;
        for (int i = 1; i <= t; i++) {
            cout << "Test #" << i << elf;

            clock_t start_time = clock();

            solve();

            cerr.precision(4); cerr << fixed;
            cerr << elf;
            cerr << "Time :: " << ld(clock() - start_time) / CLOCKS_PER_SEC << elf;

            cout << elf;
        }
    #else
        int t = 1;
//        cin >> t;

        while (t--) {
            solve();
            cout << el;
        }
    #endif
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for_each(h.begin(), h.end(),[](auto&e){
    cin>>e;
  });
  vector<int> dp(n,0);
  for (int i = 1; i < n; ++i)
  {
    int tmp=dp[i-1]+abs(h[i]-h[i-1]);
    for (int j = 2; j <= k; ++j)
    {
      if(i-j<0) break;
      tmp=min(tmp,
        dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=tmp;
  }
  cout<<dp.back()<<endl;
}

Measured memory_bytes: 4032
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   String S = sc.next();

   
   
   if(N < 3200) System.out.println("red");
   else System.out.println(S);
   
 }
}

Measured memory_bytes: 22868
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)

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

	int d;
	cin >> d;
	
	if (d == 25) cout << "Christmas" << endl;
	else{
	    cout << "Christmas";
	    FOR(i,0,25-d) cout << " Eve";
	    cout << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

        int A=stdIn.nextInt();
        int B=stdIn.nextInt();
        int C=stdIn.nextInt();
        int K=stdIn.nextInt();

        int sum=0;
        while(K>0&&A>0){
            sum++;
            A--;
            K--;
        }
        while(K>0&&B>0){
            B--;
            K--;
        }
        while(K>0&&C>0){
            C--;
            K--;
            sum--;
        }
        System.out.print(sum);
        

        
        
        
    }

}

Measured memory_bytes: 35740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b) {
			System.out.println(c);
		} else if (a == c) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h> 
using namespace std; 
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frj(j,a,n) for(lli j=a;j<(n);j++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define frxj(j,a,n) for(lli j=a;j>(n);j--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define endl '\n'
#define db(x) cout << "[ " << x << " ]" << endl;
#define dbarr(arr,a,n) {fr(i,0,n) cout<<arr[i]<<" "; cout<<endl;}

int main() {
    lli x;
    cin>>x;
    cout<<1-x;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v;
#define all(x) x.begin(),x.end()
ll MOD = 1e9+7 , MAX = 1e18;
int main() 
{
	fast_io;
	ll n,i,a,b,c;
	cin>>n;
	vll dpa(n,0),dpb(n,0),dpc(n,0);
	for(i=0;i<n;i++)
	{
	    cin>>a>>b>>c;
	    if(i)
	    {
	        dpa[i]=max(dpb[i-1],dpc[i-1])+a;
	        dpb[i]=max(dpc[i-1],dpa[i-1])+b;
	        dpc[i]=max(dpb[i-1],dpa[i-1])+c;
	    }
	    else
	    {
	        dpa[i]=a;
	        dpb[i]=b;
	        dpc[i]=c;
	    }
	}
	cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
	return 0;
}

Measured memory_bytes: 2560
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn inc(v: &mut Vec<u8>) {
    let mut i = v.len() - 1;
    while i > 0 {
        if v[i] < 9 && v[i - 1] >= v[i] {
            break;
        }
        i -= 1;
    }

    if i == 0 && v[0] == 9 {
        v[0] = 1;
        for i in 1..v.len() {
            v[i] = 0;
        }
        v.push(0);
    } else {
        v[i] += 1;
        for j in i + 1..v.len() {
            if v[j - 1] > 0 {
                v[j] = v[j - 1] - 1;
            } else {
                v[j] = 0;
            }
        }
    }
}

fn main() {
    let k: u32 = read();
    let mut v: Vec<u8> = vec![1];

    for _ in 1..k {
        inc(&mut v);
    }

    for a in v {
        print!("{}", a);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

vector <int> g[200005];
int diam = 0, deep[200005];

void dfs(int v, int pr)
{
    int mx1 = 0, mx2 = 0;
    for (int i = 0; i < (int) g[v].size(); i++)
    {
        int u = g[v][i];
        if (u == pr) continue;
        dfs(u, v);
        if (deep[u] + 1 >= mx1)
        {
            mx2 = mx1;
            mx1 = deep[u] + 1;
        }
        else mx2 = max(mx2, deep[u] + 1);
        deep[v] = max(deep[v], deep[u] + 1);
    }
    diam = max(diam, mx1 + mx2);
    return;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].pb(b), g[b].pb(a);
    }
    dfs(1, -1);
    if (diam % 3 == 1) cout << "Second\n";
    else cout << "First\n";
    return 0;
}



Measured memory_bytes: 27008
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();

    if a <= 8 && b <= 8 {
        println!("Yay!");
    } else {
        println!(":(");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
void PDF(char A[],int k,int n)
{
    int l,i,c,s,t;
    for(i=1;i<=n;i++)
    {
        if(i==k)
        {
            A[i] = A[i]+32;
        }
    }
    for (i=1;i<=n;i++)
    {
        cout<<A[i];
    }
}
int main()
{
    int n,i,k,j,l;
    cin >> n >>k;
    char A[100];
    for(i=1;i<=n;i++)
    {
        cin>> A[i];
    }
    PDF(A,k,n);
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();

ll GCD(ll a, ll b) {
    if (a > b) swap(a, b);
    while (b != 0) {
        ll c = b;
        ll d = a % b;
        a    = c;
        b    = d;
    }
    return a;
}

int main() {
    ll A, B;
    cin >> A >> B;
    PR(A / GCD(A, B) * B);

    return 0;
}

Measured memory_bytes: 3592
x,y = map(int,input().split())

if y >=x and x>=0:
  ans = y-x
elif x>=y and y >=0:
  if y == 0:
    ans = abs(x)+1
  else:
    ans = 1+(x-y)+1
elif y>=0 and 0 >=x:
  if abs(y) >= abs(x):
    ans = y+x+1
  else:
    if y == 0:
      ans = y-x
    else:
      ans = -y-x+1
elif x>=0 and 0>=y:
  if abs(x) >= abs(y):
    ans = y+x+1
  else:
    ans = -y-x+1
elif 0>=x and x>=y:
  if x == 0:
    ans = 0-y+1
  else:
    ans = 1-y+x+1
elif 0>=y and y>= x:
  ans = y-x
else:
  print(z)
print(ans)

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

const int maxn = 3000+10;
double dp[maxn][maxn], p[maxn];

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	int n;	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
	
	dp[1][0] = 1 - p[1];
	dp[1][1] = p[1];
	for (int i = 2; i <= n; i++) {
		dp[i][0] = dp[i-1][0] * (1 - p[i]);
		dp[i][i] = dp[i-1][i-1] * p[i];
		for (int j = 1; j < i; j++) {
			dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
		}
	}
	double ans = 0.0;
	for (int i = n/2+1; i <= n; i++) ans += dp[n][i];
	printf("%.12f\n", ans);

	return 0;
}


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

int main(){

  int N;
  int amari;
  int sum=0;
  int SUM1=0;
  int SUM2=0;
  int kouho1;
  int kouho2;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum +=A[i];
  }

  amari = sum%N;
  kouho1 = (sum -amari)/N;
  kouho2 = (sum -amari)/N + 1;

  for(int i=0; i<N; i++){
    SUM1 += (A[i] - kouho1)*(A[i] - kouho1);
    SUM2 += (A[i] - kouho2)*(A[i] - kouho2);
  }

  if(SUM1>SUM2)
  cout << SUM2 << endl;
  if(SUM1<=SUM2)
  cout << SUM1 << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll l,r,d;
    cin>>l>>r>>d;

    ll t1 = r/d;
    ll t2 = (l-1)/d;
    cout<<t1-t2;

    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int dd[]={0,1,2,3};
typedef tuple<int,int,int,int>state;

int H,W;
int S[30][30];
int C[4];

const int INF=1001001001;
int dist[30][30][4];
void solve(){
    fill_n(**dist,30*30*4,INF);
    dist[0][0][0]=0;
    priority_queue<state,vector<state>,greater<state>>que;
    que.push(make_tuple(0,0,0,0));
    while(que.size()){
        int c,y,x,d;
        tie(c,y,x,d)=que.top();
        que.pop();
        if(dist[y][x][d]<c)continue;
        rep(i,4){
            int nd=(d+dd[i])%4;
            int ny=y+dy[nd],nx=x+dx[nd];
            if(ny<0||ny>=H||nx<0||nx>=W)continue;
            int nc=c;
            if(S[y][x]!=i)nc+=C[i];
            if(dist[ny][nx][nd]<=nc)continue;
            dist[ny][nx][nd]=nc;
            que.push(make_tuple(nc,ny,nx,nd));
        }
    }

    int mi=INF;
    rep(i,4)chmin(mi,dist[H-1][W-1][i]);
    cout<<mi<<endl;
}

signed main(){
    while(cin>>W>>H,W||H){
        rep(i,H)rep(j,W)cin>>S[i][j];
        rep(i,4)cin>>C[i];
        solve();
    }
    return 0;
}

Measured memory_bytes: 3140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int w, h;
  while (cin >> w) {
    cin >> h;
    if (w == 0 && h == 0) return 0;
    vector<string> in(h);
    for (int i = 0; i < h; i++) {
      cin >> in[i];
    }
    int ans_w = 0, ans_b = 0;
    vector<vector<int>> vis(h, vector<int>(w));
    int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (vis[i][j] || in[i][j] != '.') continue;
        //cerr << i << " " << j << endl;
        vis[i][j] = 1;
        int siz = 1;
        queue<pair<int, int>> que;
        que.push({i, j});
        int col[2] = {};
        while (que.size()) {
          auto cur = que.front();
          que.pop();
          for (int k = 0; k < 4; k++) {
            int x = cur.first + dx[k];
            int y = cur.second + dy[k];
            if (x < 0 || x >= h || y < 0 || y >= w || vis[x][y]) continue;
            if (in[x][y] == 'W') {col[0] = 1; continue;}
            if (in[x][y] == 'B') {col[1] = 1; continue;}
            vis[x][y]++;
            que.push({x, y});
            siz++;
          }
        }
        if (col[0] + col[1] == 2) continue;
        if (col[0] == 1) ans_w += siz;
        if (col[1] == 1) ans_b += siz;
      }
    }
    cout << ans_b << " " << ans_w << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
n,m = map(int,input().split()) #nがIDカード,mがゲートの数
lst = [list(map(int, input().split())) for i in range(m)]

left = 1
right = n
for i in range(m):
  if left < lst[i][0]:
    left = lst[i][0]
  if right > lst[i][1]:
    right = lst[i][1]
if left <= right:
  print(right-left+1)
else:
  print(0)

Measured memory_bytes: 27344
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll k;
  cin >> k;

  if (k % 7 == 0) k /= 7;
  ll res = 0, keta = 1, ans = 0;
  map<ll, bool> visited;
  while (1) {
    res = (res + keta) % k;
    keta = keta * 10 % k;
    ans++;
    if (res == 0) break;
    if (visited[res]) {
      ans = -1;
      break;
    }
    visited[res] = true;
  }
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 66152
#include<bits/stdc++.h>
using namespace std;
void f(int k,int pa,int pac,vector<vector<int>> &g,vector<vector<int>> &t,int &tcnt){
  int co=1;
  for(auto i:g.at(k)){
    if(i!=pa){
      if(co==pac) co++;
      t.at(tcnt).push_back(min(k,i));
      t.at(tcnt).push_back(max(k,i));
      t.at(tcnt).push_back(co);
      tcnt++;
      f(i,k,co,g,t,tcnt);
      co++;
    }
  }
}
int main(){
  int n,a,b,i,mi=0,tcnt=0;
  cin>>n;
  vector<vector<int>> g(n+1,vector<int>(0)),t1(n-1,vector<int>(1)),t2(n-1,vector<int>(0));
  for(i=0;i<n-1;i++){
    cin>>a>>b;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
    t1.at(i).push_back(a);
    t1.at(i).push_back(b);
    t1.at(i).push_back(i);
  }
  for(i=1;i<=n;i++) if(mi<g.at(i).size()) mi=g.at(i).size();
  cout<<mi<<endl;
  f(1,0,0,g,t2,tcnt);
  sort(t1.begin(),t1.end());
  sort(t2.begin(),t2.end());
  for(i=0;i<n-1;i++){
    t1.at(i).push_back(t2.at(i).at(2));
    t1.at(i).at(0)=t1.at(i).at(3);
  }
  sort(t1.begin(),t1.end());
  for(i=0;i<n-1;i++) cout<<t1.at(i).at(4)<<endl;
}

Measured memory_bytes: 19456
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    vector<vector<int> > g(n);
    repeat (i, n - 1) {
        int x, y; scanf("%d%d", &x, &y); -- x; -- y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    // solve
    vector<int> memo(n, -1);
    function<bool (int)> go = [&](int i) {
        if (memo[i] != -1) return memo[i];
        for (int j : g[i]) if (a[i] > a[j]) {
            if (not go(j)) {
                return memo[i] = true;
            }
        }
        return memo[i] = false;
    };
    vector<int> result;
    repeat (i, n) if (a[i]) {
        if (go(i)) {
            result.push_back(i);
        }
    }
    // output
    repeat (i, result.size()) {
        printf("%d%c", result[i] + 1, i + 1 == result.size() ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

int main()
{
    int L, R, d;
    std::cin >> L >> R >> d;

    int ans = 0;
    for(int i=L; i<=R; i++)
    {
        if( i % d == 0 )
        {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3632
// Standard libraries
#include <stdio.h>
#include <vector>

// Typedef
typedef long long int lld;

// Main
int main(int argc, char **argv){
#ifdef __McDic__ // Local testing I/O
    freopen("VScode/IO/input.txt", "r", stdin);
    freopen("VScode/IO/output.txt", "w", stdout);
#endif

    int n; scanf("%d", &n);
    int answer = 0;
    printf("%d", (n+1)/2 - 1);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
xy = sorted([tuple(map(int,input().split())) for i in range(n)])
if n==1:
    print(1)
    exit()
dif = []
for i in range(n):
    for j in range(i+1,n):
        dif.append(tuple([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]]))
from collections import Counter
c = Counter(dif)
print(n-max(c.values()))

Measured memory_bytes: 39664
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args)
	 {
            Scanner sc=new Scanner(System.in);
            int d=sc.nextInt();
            if(d==25)
            	System.out.println("Christmas");
            else if(d==24)
            	System.out.println("Christmas Eve");
            else if(d==23)
            	System.out.println("Christmas Eve Eve");
            else
            	System.out.println("Christmas Eve Eve Eve");
	 }
}

Measured memory_bytes: 19668
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[100005];
vector<int> dist(100005,-1);
vector<int> dist_t(100005,-1);
vector<int> dist_a(100005,-1);
void dfs(int v,int p=-1,int d=0){
    dist[v]=d;
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v,d+1);
    }
}

int main(){
    int n,u,v;
    cin >> n >> u >> v;
    u--,v--;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(u);
    swap(dist,dist_t);
    dfs(v);
    swap(dist,dist_a);
    int ans=0;
    rep(i,n){
        if(dist_t[i]<dist_a[i]){
            chmax(ans,dist_a[i]-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10752
queue=[]
N,M=map(int,input().split())
NE=9223372036854775807
mp=[NE]*(N+1)
lst=[[] for _ in range(N+1)]
for _ in range(M):
    L,R,D = map(int, input().split())
    lst[L].append((L,R,D))
    lst[R].append((L,R,D))

isinit = True
def check(L, R, D):
    if mp[L] == NE and mp[R] == NE:
        return 1
    elif mp[L] == NE:
        mp[L] = mp[R]-D
    elif mp[R] == NE:
        mp[R] = mp[L]+D
    else:
        if mp[L]+D != mp[R]:
            print("No")
            exit()

def check_list(ls, checking):
    while len(ls):
        L,R,D = ls.pop()
        if L == checking:
            check(L,R,D)
            if len(lst[R]):
                queue.append(R)
        else:
            check(L,R,D)
            if len(lst[L]):
                queue.append(L)

# print(lst)
for i in range(1, N+1):
    if mp[i] == NE: mp[i] = 0
    check_list(lst[i], i)

    while(len(queue) > 0):
        num = queue.pop()
        check_list(lst[num], num)
# print(mp)
print("Yes")


Measured memory_bytes: 60856
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, M = map(int, input().split())

class UnionFind(object):
    def __init__(self, n: int):
        """ ノードのつながりを辞書型で表現する
        要素数nであり、要素は0からn-1である想定
        >> - usage
        g = Graph(n=n)

        """
        self.adjacency_dict = {}
        self.parent = [None] * n

        for i in range(n):
            self.add_vertex(i)
            self.parent[i] = i
        self.rank = [0] * n

    def add_vertex(self, v: int):
        """ ノードを追加する """
        self.adjacency_dict[v] = []

    def unite(self, v1: int, v2: int):
        """ ノード同士をつなぐ。"""
        if v1 == v2:
            return

        # すでにつながっている場合は親の更新のみしておく
        if self.same(v1, v2):
            return

        p1 = self.parent[v1]
        p2 = self.parent[v2]

        # つながっていない場合は親同士をつなげる
        # その場合rankが小さい方から大きい方につなげる
        if self.rank[p1] == self.rank[p2]:
            self.update(p1, p2)
            self.rank[p2] += 1
        elif self.rank[p1] < self.rank[p2]:
            self.update(p1, p2)
        else:
            self.update(p2, p1)

    def update(self, v, parent):
        self.adjacency_dict[v].append(parent)

    def same(self, v1, v2):
        """ 親が同一であれば連結 """
        self.parent[v1] = self.root(v1)
        self.parent[v2] = self.root(v2)

        return self.parent[v1] == self.parent[v2]

    def root(self, v1):
        """ vから上向きに辿って根を調べる """
        if self.adjacency_dict[v1] == []:
            return v1

        for v in self.adjacency_dict[v1]:
            parent = self.root(v)
        return parent

    def print_graph(self):
        print(self.adjacency_dict)


u = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    u.unite(a, b)

dic = defaultdict(int)
ans = 0
for i in range(N):
    val = u.root(i)
    # print(i, val)
    dic[val] += 1
    ans = max(ans, dic[val])

print(ans)


Measured memory_bytes: 123692
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int n,m;
     while(cin>>n>>m){
        int nn=(n*(n-1))/2;
        int mm=(m*(m-1))/2;
        cout<<nn+mm<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
import numpy as np

n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

# status=np.array([n,0,0,0,0,0])
# end=np.array([0,0,0,0,0,n])
# t=0

# while (status==end).all()==False:
#     A=min(a,status[0])
#     B=min(b,status[1])
#     C=min(c,status[2])
#     D=min(d,status[3])
#     E=min(e,status[4])
#     status=status-np.array([A,B-A,C-B,D-C,E-D,-E])
#     t+=1
#     # print(status)

# print(t)

m=min(a,b,c,d,e)

if n<=m:
    print(5)
else:
    if n%m==0:
        print(n//m+4)
    else:
        print(n//m+5)



Measured memory_bytes: 12392
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int K,X;
    cin>>K>>X;
    for(int i=X-K+1;i<=X+K-1;i++)cout<<i<<" ";
    cout<<endl;
}

Measured memory_bytes: 256
/*
    A - ABC333
    https://atcoder.jp/contests/abc109/tasks/abc109_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int a, b;
    cin >> a >> b;

    if ((a * b) % 2 != 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2*10**5)
mod = 10**9 + 7
n = int(input())
g = [list() for _ in range(n)]
for _ in range(n-1):
  x,y = map(int, input().split())
  x -= 1; y -= 1
  g[x].append(y)
  g[y].append(x)

def dfs(v,p):
  vb,vw = 1,1
  for x in g[v]:
    if x == p:
      continue
    xb,xw = dfs(x,v)
    vb = vb*xw%mod
    vw = vw*(xb+xw)%mod
  return vb, vw

ab,aw = dfs(n//2,-1)
print((ab+aw)%mod)

Measured memory_bytes: 106416
#include<iostream>
#include<set>
using namespace std;
int N,P[1<<17],A[1<<17];
set<int>S;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		A[P[i]]=i;
	}
	S.insert(A[N]);
	long ans=0;
	for(int i=N-1;i;i--)
	{
		S.insert(A[i]);
		set<int>::iterator id=S.find(A[i]);
		set<int>::iterator L=id,R=id;
		long B,AA,a,b;
		R++;
		if(R==S.end())
		{
			a=N-A[i];
			b=0;
		}
		else
		{
			int t=*R;
			a=t-A[i];
			R++;
			if(R==S.end())b=N-t;
			else b=*R-t;
		}
		if(L==S.begin())
		{
			AA=A[i]+1;
			B=0;
		}
		else
		{
			L--;
			int t=*L;
			AA=A[i]-t;
			if(L==S.begin())B=t+1;
			else
			{
				L--;
				B=t-*L;
			}
		}
		ans+=(AA*b+a*B)*i;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5760