akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int](n)//((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def innerLoop(j: Int, p: Int): Unit = {
      notPrime(j)
      if(j + p <= top)innerLoop(j + p, p)
    }

    def loop(i: Int): Unit = {
      val p = 2 * i + 3
      if(isPrime(i))innerLoop((p * p - 3) / 2, p)
      if(i < sqrtLimit)loop(i + 1)
    }

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 124972
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
        String str = sc.next();
        
        if (n < str.length()) {
          	System.out.print(str.substring(0,n));
          	System.out.println("...");
        } else {
          	System.out.println(str);
        }
        
    }
}

Measured memory_bytes: 35736
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let d: u32 = read(&mut stdin_lock, &mut buf, b' ');
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = 100i32.pow(d) * if n == 100 { 101 } else { n };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll c[n], s[n], f[n];
    rep1(i,n-1){
        cin >> c[i]>>s[i] >> f[i];
    }
    rep1(i,n-1){
        long double l = 0;
        for(ll j = i;j < n-1; j++){
            long double tmp = s[j] + c[j] +l*f[j] - s[j+1];
            if(tmp < 0){
                l = 0;
            }else{            
                l = ceil(tmp/f[j+1]);
            }
        }
        cout << s[n-1] + l*f[n-1] + c[n-1] << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3212
n, m = list(map(int, input().split()))
#隣接するマスの個数が偶数であれば終わったときに裏を向いている
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    k = m * 2 + n * 2 - 4
    print(m * n - k)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x = sc.nextDouble();
		int h;
		int m;
		int s;
		
		h = (int)Math.floor(x / 3600);
		x = x % 3600;
		m = (int)Math.floor(x / 60);
		x = x % 60;
		s = (int)x;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 27996
# coding: utf-8
# Your code here!

a, b = map(int, input().split())

if a > 0:
    print("Positive")
elif a == 0:
    print("Zero")
else:
    if b >= 0:
        print("Zero")
    else:
        if abs(b - a) % 2 == 0:
            print("Negative")
        else:
            print("Positive")

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(void){
	//01234567
	//01235789
	int n;
	while(cin >> n && n){
		string str = "";
		
		while(n > 0){
			str += n % 8 + '0';
			n /= 8;
		}
		for(int i=0;i<str.size();i++){
			if(str[str.size() - 1 - i] <= '3' ){
				cout << str[str.size() - 1 - i];
			}else if(str[str.size() - 1 - i] >=  '5'){
				cout << (char)(str[str.size() - 1 - i]+2);
			}else{
				cout << (char)(str[str.size() - 1 - i]+1);
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 904
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll r, d, x;
	cin >> r >> d >> x;
	rep(i, 10){
		x = r*x-d;
		co(x);
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n);
    a[0] = n;
    set<char>st;
    int c = 0;
    for(int i=n-1;i>=0;i--){
        st.insert(s[i]);
        if(st.size()==26){
            c++;
            a[c] = i;
            st.clear();
        }
    }
    int m = c;
    int l = 0;
    string ans;
    if(a[m]==0){
        ans.PB('a');
        for(int j=a[m];j<a[m-1];j++){
            if(s[j]=='a'){
                l = j+1;
                break;
            }
        }
        m--;
    }
    //cerr << m << endl;
    for(int i=m;i>=0;i--){
        st.clear();
        //cerr << l << " " << a[i] << endl;
        for(int j=l;j<a[i];j++){
            st.insert(s[j]);
        }
        char p;
        rep(j,26){
            if(st.count('a'+j)==0){
                ans.PB('a'+j);
                p = 'a'+j;
                break;
            }
        }
        if(i!=0){
            for(int j=a[i];j<a[i-1];j++){
                if(s[j]==p){
                    l = j+1;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

ll dp[8][1001][1001] = {};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ll x[3][1000];
    rep (i, 8) rep (j, 1001) repp (k, 1, 1001) dp[i][j][k] = -1000000000000000;
    rep (i, n) rep (j, 3) cin >> x[j][i];
    rep (i, n) {
        rep (j, i + 1) {
            rep (k, 8) {
                ll tmp = 0;
                rep (l, 3) {
                    if (k & (1 << l)) tmp += x[l][i];
                    else tmp -= x[l][i];
                }
                chmax(dp[k][i + 1][j + 1], dp[k][i][j] + tmp);
                chmax(dp[k][i + 1][j], dp[k][i][j]);
            }
        }
    }
    rep (i, n + 1) {
        rep (j, i + 1) eprintf("%lld ", dp[7][i][j]);
        eprintf("\n");
    }
    ll ans = dp[0][n][m];
    rep (k, 8) chmax(ans, dp[k][n][m]);
    cout << ans << "\n";
    return 0;
}

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

ll n, m, ans, A[100001];
int main() {
	cin >> n;
	if(n==25) cout << "Christmas" << endl;
	else if (n == 24) cout << "Christmas Eve" << endl;
	else if (n == 23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	
        // 入力
        int n = sc.nextInt();
      	int count=0;
      
      	for(int i=0;i<n;i++){
          int a =sc.nextInt();
          int b =sc.nextInt();
          if(a==b){
            count+=1;
          }else{
            count=0;
          }
          
          if(count==3){
            break;
          }
          
        }
      
      if(count==3){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
    }
}




Measured memory_bytes: 35996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=1e6;
int n,m,vis[N+10],head[N+10],tot;
LL cnt1=0,cnt2=0,cnt3=0;
struct data {
    int next,num;
}edge[N+10];
void Add(int u,int v) {
    edge[++tot].next=head[u];
    edge[tot].num=v;
    head[u]=tot;
}
int dfs(int x,int k) {
    if (vis[x]!=-1&&vis[x]!=k) return 0;
    if (vis[x]!=-1) return 1;
    vis[x]=k;
    int ans=1;
    for (int i=head[x];i!=-1;i=edge[i].next) {
	int kx=edge[i].num;
	int nowk=dfs(kx,k^1);
	if (nowk==0) ans=0;
    }
    return ans;
}
int main() {
    memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
	int u,v;
	scanf("%d%d",&u,&v);
	Add(u,v);
	Add(v,u);
    }
    memset(vis,-1,sizeof(vis));
    for (int i=1;i<=n;i++) {
	if (vis[i]!=-1) continue;
	if (head[i]==-1) {
	    cnt3++;
	    continue;
	}
	int k=dfs(i,1);
	if (k==0) cnt1++;
	else cnt2++;
    }
    LL ans=(LL)n*n-(n-cnt3)*(n-cnt3);
    ans+=cnt1*cnt1+cnt1*cnt2*2+cnt2*cnt2*2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 16640
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    ll n,s=0;
    cin>>n;
    cout<<(n*(n+1)/2)-n<<endl;




}
//Alhamdulillah













Measured memory_bytes: 3652
x1, y1, w1, h1 = gets.chomp.split.map(&:to_i)
x2, y2, w2, h2 = gets.chomp.split.map(&:to_i)
left = [x1, x2].max
right = [x1 + w1, x2 + w2].min
bottom = [y1, y2].max
top = [y1 + h1, y2 + h2].min
width = (left < right ? right - left : 0)
height = (bottom < top ? top - bottom : 0)
puts w1 * h1 + w2 * h2 - width * height * 2


Measured memory_bytes: 6876
using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>

#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

vi dp;
int mincost(vi& ht, int n, int idx, int k)
{
	if (idx == n - 1)
		return 0;
	if (dp[idx] != -1)
		return dp[idx];

	int minc = INT_MAX;
	for (int i = 1; i <= k; ++i)
	{
		if (idx + i < n)
		{
			int mincst = abs(ht[idx + i] - ht[idx]) + mincost(ht, n, idx + i, k);
			minc = min(mincst, minc);
			dp[idx] = minc;
		}
	}

	return dp[idx];
}

int main()
{
	int n, k;
	cin >> n >> k;
	vi ht(n);
	rep(n)
		cin >> ht[i];

	dp.resize(n, -1);
	auto ans = mincost(ht, n, 0, k);
	cout << ans;
	ret(0);
}


Measured memory_bytes: 10368
n,x,y=map(int,input().split())
res=[0]*n
for i in range(1,n):
  for j in range(i+1,n+1):
    s=(min(j-i,abs(x-j)+1+abs(y-i),abs(x-i)+1+abs(y-j)))
    res[s]+=1
for k in range(1,n):
  print(res[k])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
//not so imp
#define fill0(ar) fill((ar), 0)
#define fillinf(ar) fill((ar), inf)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;
ll dp1[maxn], dp2[maxn];

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        string s;
        cin>>s;
        s = ' '+s;
        fr(i,1,n){
            if(s[i] == '.'){
                dp1[i] = dp1[i-1];
                dp2[i] = min(dp1[i-1]+1, dp2[i-1]+1);
            }
            else{
                dp1[i] = dp1[i-1]+1;
                dp2[i] = min(dp2[i-1], dp1[i-1]);
            }
        }
        ll ans = min(dp1[n],dp2[n]);
        cout<<ans;
    }
    end_routine();
}

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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a - 1] = i + 1;
  }

  for (int i = 0; i < N; i++) {
    cout << A[i];
    if (i != N - 1) {
      cout << " ";
    }
  }

  cout << endl;

}

Measured memory_bytes: 1152
#include <stdio.h>
int main(void){
    int i,j,r,c;
    static int s[101][101];
    scanf("%d %d",&r,&c);
    for(i=0;i<=r;i++){
        for(j=0;j<c;j++){
            scanf("%d", &s[i][j]);
            printf("%d ", s[i][j]);
            s[i][c] += s[i][j];
            s[r][j] += s[i][j];
        }
        printf("%d\n",s[i][c]);
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

int t[100005] , x[100005] , y[100005];
int main(){
	dhoom;
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i = 1 ; i <= n ; i++){
		int dx = abs(x[i] - x[i-1]);
		int dy = abs(y[i] - y[i-1]);
		int d = dx + dy;
		if(d > t[i] - t[i-1] || (d%2 != (t[i] - t[i-1])%2))
		{
				cout << "No" << endl;
				return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main(){
string a;
int n[1000]={};
cin>>a;
for(int i=0;i<a.size();i++){
int h=a[i];
n[h]++;
}
char b='a';
int i,j=b;
for(i=0;i<26;i++){
if(!n[i+j]){
b=i+j;
cout<<b;
break;
}
}
if(i==26)cout<<"None";
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using Graph = vector<vector<int>>;
// 木上の探索
vector<int> depth;
vector<int> subtree_size;
void dfs(const Graph &G, int v, int p, int d) {
    depth[v] = d;
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v, d+1);
    }

    // 帰りがけ時に、部分木サイズを求める
    subtree_size[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        subtree_size[v] += subtree_size[c]; // 子のサイズを加える
    }
}
signed main()
{
  int n,a,b;
  cin >> n >> a >> b;
  cout << (a*n<=b?a*n: b);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long cc;
typedef pair <int, int> pii;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
const int N = 100005;
vector <pii> e[N];
bool False = false;
int n, m;
int d[N], deg[N];
vector <int> x;
queue <int> Set;
bool was[N];
bool xetted[N];
void dfs(const int u, const int cost) {
    xetted[u] = true;
    if (d[u] != -1 && d[u] != cost) {
        False = true;
        return;
    }
    if (was[u]) return;
    was[u] = true;
    Set.push(u);
    d[u] = cost;
    for (auto v: e[u])
        dfs(v.X, cost + v.Y);
}
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    memset(d, -1, sizeof(d));
    memset(was, 0, sizeof(was));
    for (int i = 1; i <= m; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        deg[v]++;
        e[u].pb(mp(v, c));
    }
    for (int i = 1; i <= n; i++) if (deg[i] == 0) x.pb(i);
    for (auto u: x) {
        while (Set.size()) Set.pop();
        dfs(u, 0);
        if (False) {
            cout << "No";
            return 0;
        }
        while (Set.size()) {
            int v = Set.front();
            was[v] = false;
            d[v] = -1;
            Set.pop();
        }
    }
    for (int i = 1; i <= n; i++) if (!xetted[i]) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
void earn();
char p[8][8];
char exe[8][8];
int h,w,k;
int ct=0;
int ans=0;
int main()
{
	int i,j;
	scanf("%d %d %d",&h,&w,&k);
	getchar();
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			scanf("%c",&p[i][j]);
			if(p[i][j]=='#')
			ct++;
		}
		getchar();
	}
	earn();
	printf("%d",ans);
}
void earn()
{
	int i,j;
	int all = pow(2,h+w);
	for(i=0;i<all;i++)
	{
		int flag = i;
		memcpy(exe,p,sizeof(p));
		int cnt = 1;
		int allcnt = ct;
		int cp = i;
		while(cp>0)
		{
			if(cnt<=h)
			{
				if(cp&1)
				{
					for(j=1;j<=w;j++)
					{
						if(exe[cnt][j]=='#')
						{
							allcnt--;
							exe[cnt][j]=0;
						}
					}
				}
			}
			else
			{
				if(cp&1)
				{
					for(j=1;j<=h;j++)
					{
						if(exe[j][cnt-h]=='#')
						{
							allcnt--;
							exe[j][cnt-h]=0;
						}
					}
				}
			}
			cp>>=1;
			cnt++;
		}
		if(allcnt==k)
		ans++;
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll T; cin >> T;
  rep(_,T) {
    ll N; cin >> N;
    ll A[N]; rep(i,N) cin >> A[i];
    string S; cin >> S;

    ll usebit[63] = {};
    ll result = 0;
    per(i,N) {
      if (S[i]=='0') {
        per(j,63) {
          if (A[i]&(1ll<<j)) {
            // cout << j << " " << A[i] << endl;
            if (usebit[j]&(1ll<<j)) A[i] ^= usebit[j];
            else { usebit[j] = A[i]; break; }
          }
        }
        // debug(usebit,usebit+4);
      }
      else {
        per(j,63) {
          if (A[i]&(1ll<<j)) {
            if (usebit[j]&(1ll<<j)) A[i] ^= usebit[j];
          }
        }
        if (A[i]) {
          result = 1;
          break;
        }
      }
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
from operator import itemgetter
n,m = map(int,input().split())
lis = []
for _ in range(m):
    lis.append(list(map(int,input().split())))
lis.sort(key = itemgetter(1))
ans = 0
last = 0
for i in range(m):
    if last <= lis[i][0]:
        ans += 1
        last = lis[i][1]
print(ans)

Measured memory_bytes: 28588
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**9
for i in range(n-k+1):
  if x[i]*x[i+k-1] < 0:
    temp = min(abs(x[i])+abs(2*x[i+k-1]), abs(2*x[i])+abs(x[i+k-1]))
  else:
    temp = max(abs(x[i]), abs(x[i+k-1]))
  #print(temp)
  if temp< ans:
    ans = temp
print(ans)

Measured memory_bytes: 14252
#include<stdio.h>
char change(char);

int main(){
  char c;
  int i;

  for(i=0;i<1200;i++){
    scanf("%c",&c);
  if(c=='\n') break; 
    printf("%c",change(c));
  }
  printf("\n");
  
  return 0;
}

char change(char c){
  if('a'<=c && c<='z') return c+'A'-'a';
  else if('A'<=c && c<='Z') return c+'a'-'A';
  else return c;
}

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

int main(){
  string S;
  cin >> S;
  ll a=0,b=0;
  rep(i,S.size()){
    if(S.at(i)=='0') a++;
    else b++;
  }
  cout << 2*min(a,b) << endl;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
vector<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
vector<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    V<P> r(n), b(n);
    rep(i, n) {
        int a, b; cin >> a >> b;
        r[i].first = b; r[i].second = a;
    }
    rep(i, n) {
        int c, d; cin >> c >> d;
        b[i].first = c; b[i].second = d;
    }
    sort(allr(r));
    sort(all(b));
    
    V<bool> used_r(n, false);
    int ans = 0;
    rep(i, n) {
        int bx = b[i].first, by = b[i].second;
        rep(i, n) {
            int rx = r[i].second, ry = r[i].first;
            if (used_r[i]) continue;
            if (rx < bx && ry < by) {
                ans++;
                used_r[i] = true;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string[] ranks = new string[] { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] time = Array.ConvertAll(input.Split(' '), double.Parse);

                int res = Math.Max(CheckRank1(time[0]), CheckRank2(time[1]));

                sb.AppendLine(ranks[res]);
            }
            Console.Write(sb);
        }

        static int CheckRank1(double time)
        {
            if (time < 35.50) return 0;
            if (time < 37.50) return 1;
            if (time < 40.00) return 2;
            if (time < 43.00) return 3;
            if (time < 50.00) return 4;
            if (time < 55.00) return 5;
            if (time < 70.00) return 6;
            return 7;
        }

        static int CheckRank2(double time)
        {
            if (time < 71.00) return 0;
            if (time < 77.00) return 1;
            if (time < 83.00) return 2;
            if (time < 89.00) return 3;
            if (time < 105.00) return 4;
            if (time < 116.00) return 5;
            if (time < 148.00) return 6;
            return 7;
        }
    }
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
ll int t;
t=1;

while(t--)
{ ll int n,m,i,j,k,count=0,flag=0;
string a,b;
cin>>a>>b;
char z = '0';
char tem=a[0];
//count = 
k=b[0]-'0';
for(i=0;i<k-1;i++)
{
    a+=a[0];
}
k=a[0]-'0';
for(i=0;i<k-1;i++)
{
    b+=b[0];
}
  if(a<b)
  cout<<a<<endl;
  else
  cout<<b<<endl;
    
    
    
    
    
    
    
}



 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    string a,b,ans;
    cin >>a>>b;
    int as = a.size(), bs = b.size(), ms = (as>bs)? as:bs,t=0;
    for(int i=0; i<ms; i++){
      if(i<as && i<bs){t = a[as-i-1]+b[bs-i-1]+t/10-2*'0';}
      else if(i<as){t = a[as-i-1]+t/10-'0';}
      else if(i<bs){t = b[bs-i-1]+t/10-'0';}
      ans+=(char)(t%10)+'0';
    }
    if(t/10){ans+='1';}
    if(ans.size()>80){cout <<"overflow"<<endl;}
    else{for(int i=0; i<ans.size(); i++){cout <<ans[ans.size()-i-1];}cout <<endl;}
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
Node T[MAX];
int n;

void preParse(int u) {
    if (u == NIL) {
        return ;
    }
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == NIL) {
        return;
    }
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == NIL) {
        return;
    }
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int i, v, l, r, root;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        T[i].p = NIL;
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) {
            T[l].p = v;
        }
        if (r != NIL) {
            T[r].p = v;
        }
    }
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) {
            root = i;
        }
    }
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
   

fast;

ll n,m;
cin>>n>>m;

ll k;
cin>>k;

ll a[n],b[m];
for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<m;i++)cin>>b[i];

ll ans=0;

vector<ll> p1(n,0),p2(m,0);
p1[0]=a[0],p2[0]=b[0];
for(ll i=1;i<n;i++)p1[i]=p1[i-1]+a[i];
for(ll i=1;i<m;i++)p2[i]=p2[i-1]+b[i];


for(ll i=-1;i<n;i++)
{
    ll use=0;
    if(i!=-1)use=p1[i];

    if(use>k)break;

    ll rem=k-use;
    ans=max(ans,i+1);

    auto it=upper_bound(p2.begin(),p2.end(),rem);
    if(it!=p2.begin())
    {
        ll idx=it-p2.begin();
        ans=max(ans,i+1+idx);
    }

}
cout<<ans;
}


Measured memory_bytes: 9480
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int k, a, b;cin>>k>>a>>b;
  if(a%k==0 || int(a/k)*k+k<=b)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e5+10;
int mp1[maxn],mp2[maxn];
int main(){
	int n=read();
	REP(i,1,n){
		int x=read();
		if(i&1) mp1[x]++;
		else mp2[x]++;
	}
	int Max1=0,Max2=0,Sec1=0,Sec2=0;
	REP(i,1,1e5){
		if(mp1[Max1]<mp1[i]) Sec1=mp1[Max1],Max1=i;
		else chkmax(Sec1,mp1[i]);
		if(mp2[Max2]<mp2[i]) Sec2=mp2[Max2],Max2=i;
		else chkmax(Sec2,mp2[i]);
	}
	if(Max1!=Max2) printf("%d\n",n-mp1[Max1]-mp2[Max2]);
	else printf("%d\n",n-max(mp1[Max1]+Sec2,mp2[Max2]+Sec1));
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
import itertools

if __name__ == "__main__":
    n = list(map(int, input().split()))
    l = [np.array(list(map(int, input().split()))) for i in range(n[0])]

    n = 0

    for v in itertools.combinations(l, 2):
        #print(v)
        distance = np.linalg.norm((v[0] - v[1]), ord=2)
        #print(distance)
        #print(distance % 1)
        if distance % 1 == 0:
            n += 1

    print(n)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
string s;
void solve(){
	cin >> s;
	n = s.size();
	
	int a = 0;
	for(int i = 0; i < n; i++){
		if(s[i]&1) a++;
	}
	cout << min(a,n-a)*2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = 105;
vector < pair < int, int > > ans;
int main (){
  int n, k ;
  cin >> n >> k;
  int K = (n - 1) * (n - 2) / 2;
  for(int i = 2 ; i <= n ; i++){
    ans.push_back({1, i});
  }
  for(int i = 2 ; i <= n && K > k; i++){
    for(int j = i + 1 ; j <= n && K > k; j++){
      ans.push_back({i, j});
      K--;
    }
  }
  if (k == K){
    cout << ans.size() << "\n";
    for(int i = 0; i < ans.size() ; i++)
      cout << ans[i].first <<' ' << ans[i].second <<"\n";
  }
  else
    cout << -1;
  return 0;
}


Measured memory_bytes: 384
/*
 * Author: Anmol Choudhary
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    int k,n;
    cin>>k>>n;
    int arr[n];
    rep0(i,n) cin>>arr[i];
    sort(arr,arr+n);
    int mx=-1;
    rep1(i,n-1){
        mx=max(mx,arr[i]-arr[i-1]);
    }
    mx=max(mx,arr[0]+k-arr[n-1]);
    pr(k-mx);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
	int w,n;
	int d[100],e[100];
	int a[100];
	char c;
	cin>>w>>n;
	for(int i=0;i<n;i++)
		cin>>d[i]>>c>>e[i];
	for(int i=1;i<=w;i++)
		a[i]=i;
	for(int j=0;j<n;j++){
		int tmp=a[d[j]];
		a[d[j]]=a[e[j]];
		a[e[j]]=tmp;
	}
	for(int i=1;i<=w;i++)
		cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
open System

let mutable  [|N; M|] = stdin.ReadLine().Split(' ') |> Array.map int

N <- N-1
M <- M-1

let mutable parent = [| for i in 0 .. N -> i  |]
let mutable size = [| for i in 0 .. N -> 1 |]

let rec root a = if a = parent.[a] then a else root parent.[a]

let unit a b = 
        let ra = root a
        let rb = root b
        if ra <> rb then 
            if ra < rb then 
                parent.[rb] <- ra
                size.[ra] <- size.[ra] + size.[rb]
                parent.[b] <- ra
            else 
                parent.[ra] <- rb
                size.[rb] <- size.[rb] + size.[ra]
                parent.[a] <- rb

for i in 0 .. M do
    let [|A; B|] = stdin.ReadLine().Split(' ') |> Array.map int
    let j = A - 1
    let k = B - 1
    unit j k

let mutable max = 0
for i in 0 .. N do
    max <- if max > size.[i] then max else size.[i]

max |> printf "%d"    


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;

    return u;
}
ll modpow(ll a, ll n) {
  ll ret = 1LL;
  while(n > 0) {
    if(n & 1) ret = a * ret % MOD;
    a = a * a % MOD;
    n >>= 1;
  }

  return ret;
}
ll modminus(ll a, ll b) {
  ll ret = (a - b) % MOD;
  return (ret >= 0) ? ret : ret + MOD;
}

int dfs(int pos, int prev, std::vector<std::vector<int>> &from, std::vector<int> &cnt) {
  int ret = 1;
  for(auto b : from[pos]) {
    if(b == prev) {
      continue;
    }

    ret += dfs(b, pos, from, cnt);
  }

  return cnt[pos] = ret;
}

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

  std::vector<int> A(N - 1), B(N - 1);
  std::vector<std::vector<int>> from(N);
  rep(i, N - 1) {
    std::cin >> A[i] >> B[i];
    --A[i];
    --B[i];
    from[A[i]].push_back(B[i]);
    from[B[i]].push_back(A[i]);
  }

  std::vector<ll> pow(N + 1), inv(N + 1);
  pow[0] = 1;
  inv[0] = 1;
  rep(i, N) {
    pow[i + 1] = pow[i] * 2 % MOD;
    inv[i + 1] = modinv(pow[i + 1]);
  }

  std::vector<int> cnt(N);
  dfs(0, 0, from, cnt);

  ll EV = 1;
  rep(i, N - 1) {
    int na = std::min(cnt[A[i]], cnt[B[i]]);
    int nb = N - na;

    EV += modminus(1, inv[na]) * modminus(1, inv[nb]) % MOD;
    EV %= MOD;
  }

  ll ans = modminus(modminus(EV, inv[1] * N % MOD), inv[N]); // erase
  std::cout << ans << '\n';
}


Measured memory_bytes: 27776
n = int(input())
b = [int(i) for i in input().split()]

a = [0]*n
a[0] = b[0]

for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])

a[n-1] = b[n-2]

#print(a)
print(sum(a))

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

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    int A[210];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    bool flag = true;
    int cnt = 0;
    while (flag)
    {
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 0)
            {
                A[i] /= 2;
            }
            else
            {
                flag = false;
                break;
            }
        }
        cnt++;
    }
    cout << cnt - 1 << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    int ans = 0;
    rep(i, 3) {
      if (s[i] == '1') ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <ll> A(n,0);
    vector <ll> B(n,0);
    for (int i=0;i<n;i++) {cin>>A[i]; cin>>B[i];}
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if (n%2==1) {cout<<B[n/2]-A[n/2]+1<<endl;}
    else {cout<<B[n/2]+B[n/2-1]-A[n/2]-A[n/2-1]+1<<endl;}
    return 0;
}


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

using namespace std;

int main(){
  int n;
  map<string, bool> mp;
  string bef, s;
  bool shiritori = true;
  
  cin >> n;
  cin >> bef;
  mp[bef] = true;
  for(int i = 1 ; i < n ; i++){
  	cin >> s;
    if (mp.find(s) != mp.end() || s.front() != bef.back()){
    	shiritori = false;
    }
    mp[s] = true;
    bef = s;
  }
  
  if(shiritori)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */
bool ispalin(string s,ll l,ll r)
{
    ll cnt=0;
    f(i,l,r)
    {
        
        if(s[i]!=s[r-cnt])
        return false;
        cnt++;
    }
    return true;
}

int main()
{
    string s;
    cin >>  s;
 
  
  ll n=s.length();


     if(ispalin(s,0,n-1)&&ispalin(s,0,((n-1)/2)-1)&&ispalin(s,((n+3)/2)-1,n-1))
    cout << "Yes" ;
    else
    {
        cout << "No";
    }
    
}

Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

class UnionFind {
	vector<int> data,sz;
public:
	UnionFind(int n) {
		data = vector<int>(n);
		sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			data[i] = i;
			sz[i] = 1;
		}
	}
	int root(int x) {
		if (data[x] == x) {
			return x;
		}
		else {
			data[x] = root(data[x]);
			return data[x];
		}
	}
	int size(int x) {
		return sz[root(x)];
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}
		if (sz[x] > sz[y]) {
			sz[x] = sz[x] + sz[y];
			data[y] = x;
		}
		else {
			sz[y] = sz[x] + sz[y];
			data[x] = y;
		}
	}
 };
int main()
{
	int n,m;
	cin >> n >>m;
	vector<int> a, b;
	int ain, bin;
	for (int i = 0; i < m; i++) {
		cin >> ain >> bin;
		a.push_back(ain - 1);
		b.push_back(bin - 1);
	}

	UnionFind uf(n);

	long long ans = n*(long long)(n-1)/2;
	vector<long long> answers;
	for(int i = m-1;i >= 0;i--){
		answers.push_back(ans);
		if (uf.same(a[i], b[i])) {
			continue;
		}
		else {
			ans = ans - uf.size(a[i]) * (long long)uf.size(b[i]);
			uf.unite(a[i], b[i]);
			continue;
		}
	}

	reverse(answers.begin(), answers.end());

	for (int i = 0; i < m; i++) {
		cout << answers[i] << endl;
	}
	return 0;

}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    unordered_set<char>s;
    for (int i = 0; i < 3; ++i) {
        char c;cin >>c;
        s.insert(c);
    }
    if(s.size()==3)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256