akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main() {
    cin>>N>>A>>B;
    cout<<min(B,A*N)<<endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	double l;
	double sum,k;
	scanf("%lf",&l);
	k=l/3;
	sum=k*k*k;
	printf("%.12lf\n",sum);
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 45

int Fibo(int);

int i;
int F[MAX];

int main()
{
  int n;

  scanf("%d",&n);

  printf("%d\n",Fibo(n));

  return 0;
}

int Fibo(int N)
{
  
  F[0] = 1;
  F[1] = 1;

  for(i=2;i<=N;i++)
    {
      F[i] = F[i-2] + F[i-1];
    }

  return F[i-1];
}

Measured memory_bytes: 596
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>

using namespace std;
string s,st;
void digui(int w)
{
	if(s[w]=='e')
	{
		st="";
		for(int i=w;i<=w+4;i++)
		{
			st+=s[i];
		}
		if(st=="erase")
		{
			if(w+4==s.size()-1)
			{
				cout<<"YES";
				exit(0);
			}
			if(s[w+5]=='r')
			{
				if(w+5==s.size()-1)
				{
					cout<<"YES";
					exit(0);
				}
				digui(w+5+1);
				cout<<"NO";exit(0);
			}
			else
			{
				digui(w+4+1);cout<<"NO";exit(0);
			}
		}
		else
		return ;
	}
	if(s[w]=='d')
	{
		st="";
		for(int i=w;i<=w+4;i++)
		{
			st+=s[i];
		}
		if(st=="dream")
		{
			if(w+4==s.size()-1)
			{
				cout<<"YES";
				exit(0);
			}
			if(s[w+5]=='e'&&s[w+6]=='r')
			{
				if(w+6==s.size()-1)
				{
					cout<<"YES";
					exit(0);
				}
				digui(w+6+1);
				digui(w+4+1);
				cout<<"NO";
				exit(0);
			}
			else
			{
				digui(w+4+1);cout<<"NO";exit(0);
			}
		}
		else
		return ;
	}
}
int main()
{
	cin>>s;
	if(s[0]!='d'&&s[0]!='e')
	{
		cout<<"NO";
		return 0;
	}
	digui(0);
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println(A <= 9 && B <= 9 ? (A * B) : -1);
        }
    }
}


Measured memory_bytes: 27048
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
ans = [True]*N
for i in range(M):
    ls1=list(map(int,input().split()))
    AB.append(list(ls1))
    ls1.clear()
    #print(AB)
    if H[AB[i][0]-1] <= H[AB[i][1]-1]:
        ans[AB[i][0]-1] = False
    if H[AB[i][0]-1] >= H[AB[i][1]-1]:
        ans[AB[i][1]-1] = False
print(sum(ans))


Measured memory_bytes: 94992
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int n = ni();long g = 0;
        long[] x = new long[n+1];
        for(int i = 0; i<= n; i++)x[i] = nl();
        Arrays.sort(x);
        for(int i = 1; i<= n; i++)g = gcd(g, x[i]-x[i-1]);
        pn(g);
    }
    //SOLUTION ENDS
    long mod = (int)1e9+7, IINF = (long)3e18;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //long ct = System.currentTimeMillis();
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        //pn(System.currentTimeMillis()-ct);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long lcm(long a, long b){return a*b/gcd(a,b);}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

Measured memory_bytes: 40528
//  Code:  || 

#include<bits/stdc++.h>
using namespace std;

#define preTask ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
    preTask
    int n, t=0, x;
    cin>>n;
    // vector<long long> v(n);
    for(int i=0; i<n; i++)
    {
        cin>>x;
        t = t^x;
    }
    if(t==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    ll n,kabu=0,money=1000,kabuk;
    cin>>n;
    
    vll a(n);
    rep(i,n)cin>>a.at(i);
    
    
    rep(i,n-1){
        if(a.at(i)<a.at(i+1)){
            kabuk=money/a.at(i);
            money-=a.at(i)*kabuk;
            kabu+=kabuk;
        }else if(a.at(i)>a.at(i+1)){
            money+=kabu*a.at(i);
            kabu=0;
        }
    }
    money+=a.at(n-1)*kabu;
    cout<<money<<endl;
    
    
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int main(){
    ll n,ik,ans=0;
    string s;
    cin>>n>>s;
    //s="";For(i,0,20) s+="qwertyuiopasdfghjklzxcvbnm";n=s.size();
    if(n<=1000){
        For(i,0,10) s+='*';
        For(i,1,1+n/2){
            map<string,ll> bubun;
            string k=s.substr(0,i);
            bubun[k]=i;
            For(j,i,n){
                k.erase(0,1);
                k+=s.at(j);
                ik=bubun[k];
                if(ik==0){
                    bubun[k]=j+1;
                }
                else if(ik+i<=j+1){
                    ans=i;
                    break;
                }
            }
            if(ans!=i){
                break;
            }
        }
        cout<<ans<<endl;
    }
    else{
        For(l,0,n) s+='*';
        ll kouho=n/4;
        bool flag=false;
        ll kouho2=0;
        For(num,0,10){
            flag=false;
            map<string,ll> bubun;
            string k=s.substr(0,kouho);
            bubun[k]=kouho;
            For(j,kouho,n){
                k.erase(0,1);
                k+=s.at(j);
                ik=bubun[k];
                if(ik==0){
                    bubun[k]=j+1;
                }
                else if(ik+kouho<=j+1){
                    flag=true;
                    break;
                }
            }
            ll div=pow(2,num+2);
            if(flag){
              kouho2=max(kouho2,kouho);
              kouho+=n/div;
            }
            else kouho-=n/div;
        }
        ans=kouho2;
        For(i,ans+1,1+n/2){
            map<string,ll> bubun;
            string k=s.substr(0,i);
            bubun[k]=i;
            For(j,i,n){
                k.erase(0,1);
                k+=s.at(j);
                ik=bubun[k];
                if(ik==0){
                    bubun[k]=j+1;
                }
                else if(ik+i<=j+1){
                    ans=i;
                    break;
                }
            }
            if(ans!=i){
                break;
            }
        }      
        cout<<ans<<endl;
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  K--;
 
  
  for (int i = 0; i < N; i++) {
  	if (i == K) {
    	if(S.at(i) == 'A') {
        	S.at(i) = 'a';
        }
    	else if (S.at(i) == 'B') {
    		S.at(i) = 'b';
        }
    	else {
        	S.at(i) = 'c';
        }
    }
  }
  cout << S << endl;
 }

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,ans;
int a[105];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int now=1;
    for(int i=2;i<=n;i++){
        if(a[i]==a[i-1]){now++; continue;}
        ans+=now/2;
        now=1;
    }
    ans+=now/2;
    printf("%d",ans);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

int main() {

	ll n;
	cin >> n;

	map <ll, int> m;

	ll num = n;
	for (ll i = 2; i * i <= n; i++) {
		while (num % i == 0) {
			m[i]++;
			num /= i;
			
		}

		
	}

	if (num != 1) {
		m[num]++;
	}

	set<ll> s;

	for (auto it = m.begin(); it != m.end();it++) {
		if (it->second == 0) {
			continue;
		}

		ll z = it->first;
		for(int j = 0;j <it->second;j++){
			s.insert(z);
			z *= it->first;

			
		}
	}

	

	num = n;
	int cnt = 0;
	
	for (auto it = s.begin(); it != s.end(); it++) {
		
		if (num % *it ==0) {
			cnt++;
			num /= *it;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3644
n = int(input())
t, a = map(int, input().split())
hs =list(map(int, input().split()))
rh = (t-a)/0.006
dif = []
for h in hs:
    dif.append(abs(h - rh))
    
idx = dif.index(min(dif))
print(idx + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
ll ans=700;
for(int i=0;i<3;i++){
    if(s.at(i)=='o'){
        ans+=100;
    }
}
cout<<ans<<endl;
}









Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


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

	double out = 0.0;
	FOR(i, 1, N) {
		double p = 1;
		double cur = i;
		while (cur < K) {
			p /= 2;
			cur *= 2;
		}
		out += (double)p / (double)N;
	}

	printf("%.10lf\n", out);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
vector<string> vec{"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string S;
  cin>>S;
  for(ll i=0;i<7;i++) {
    if(S==vec[i]) {
cout<<7-i<<endl;
    }
  }
}

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

int n;
vector<int> V;

int main() {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        if (x > i) printf("-1\n"), exit(0);
        V.insert(V.begin() + x - 1, x);
    }
    for (int x : V) printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////////////
                    //                                                //
                    //  For her who keeps the fire kindling in me...  //
                    //                                                //
                    ////////////////////////////////////////////////////

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
// import java.util.Scanner;
// import java.util.Arrays;
// import java.util.ArrayList;
// import java.util.Collections; 
// import java.util.StringTokenizer;
import java.util.*;
import java.lang.Math;
import java.awt.Point;

import java.awt.geom.*;

public class Main {

    public static void main(String args[]) {
        try {
            FastReader s = new FastReader();
            BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
            int i, j;
            long m, n, sum, t, max, k, h, x, y, min, correct_ans, vert, num, size, local_ans, global_ans;
            long a, b;


            // n = s.nextInt();
            // m = s.nextInt();
            
            h = s.nextLong();

            h = (long)((Math.log((double)(h))/Math.log((double)2)) + 1);
            
           // w.write(h+"\n");

            w.write((((long)Math.pow(2, h)) -1 )+"\n");
            w.close();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// ========================================### FAST IO ###=========================================//
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}
// ====================================================================================================//

Measured memory_bytes: 21332
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
    int n,m;
    cin>>n>>m;
    vector<int>l(m),r(m);
    REP(i,m) cin>>l[i]>>r[i];

    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    cout<<max(r[0]-l[m-1]+1,0)<<endl;



   
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] v = new Integer[n];

		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}

		Arrays.sort(v);
		double ans = 0;
		double mae = 0;
		for (int i = 1; i < n; i++) {
			if (i == 1) {
				mae = (double) (v[i] + v[i - 1]) / 2;

			} else {
				mae = (double) (mae + v[i]) / 2;

			}
			ans += mae;
		}
		System.out.println(mae);
		sc.close();

	}

}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,d;
    std::deque<int> deq;
    std::deque<int> ans;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>d;
        deq.emplace_back(d);
    }
    sort(deq.begin(),deq.end(),greater<int>());
    ans.emplace_back(deq[0]);
    for (int j=1;j<n;j++) {
        if (ans.back()!=deq[j]) {
            ans.emplace_back(deq[j]);
        }
    }
    cout<<ans.size()<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>

int main(void){

    char s[3][10];
    int i;

    for(i = 0;i < 3;i++){
        scanf("%s",s[i]);
    }

    for(i = 0;i < 3;i++){
        printf("%c",toupper(s[i][0]));
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 128
function main()
  
  N = parse(Int,readline())
  S = split(chomp(readline()),"")
  
  ans = 0
  
  for i in 1:length(S)-1
    
    if S[i] != S[i+1]
      ans += 1
    end
    
  end
  
  println(ans + 1)
  
end
 
main()

Measured memory_bytes: 180884
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline().rstrip
show_flg=False
show_flg=True

ans=0
n=I()
s=input()
k=1
t=s[:n//2]
u=s[n//2:]
if n%2==1:
    k=1
elif t==u:
    k=0


print(YN[k])


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


lint powll(lint x, int n) {
  lint res = 1;
  for (; n > 0; x *= x, n >>= 1) if (n & 1) res *= x;
  return res;
}

lint rec(int d, lint x, bool first = false) {
  if (d == 2) {
    if (x % 9) return 0;
    x /= 9;
    if (x < -9 or x > 9) return 0;
    if (first) {
      return 9 - x;
    } else {
      return 10 - abs(x);
    }
  }
  if (d == 3) {
    if (x % 99) return 0;
    x /= 99;
    if (x < -9 or x > 9) return 0;
    if (first) {
      return 10 * (9 - x);
    } else {
      return 10 * (10 - abs(x));
    }
  }
  lint r = x % 90;
  lint res = 0;
  for (lint y = -9; y <= 9; ++y) {
    if ((9 * y - r) % 90 == 0) {
      if (!first) {
        res += rec(d - 2, (x - (powll(10, d - 1) - 1) * y) / 10) * (10 - abs(y));
      } else {
        res += rec(d - 2, (x - (powll(10, d - 1) - 1) * y) / 10) * (y < 0 ? 10 + y : 9 - y);
      }
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  lint x; cin >> x;
  lint res = 0;
  for (int d = 2; d <= 19; ++d) {
    res += rec(d, x, true);
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N;
	int a, b, c;
	
	scanf("%d", &N);
	
	while (N--){
		scanf("%d %d %d", &a, &b, &c);
		
		if ( a * a == b * b + c * c){
			printf("YES\n");
		}
		else if ( b * b == a * a + c * c){
			printf("YES\n");
		}
		else if ( c * c == b * b + a * a){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	
	return (0);
	
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n;cin>>n;
	vector<ll> vect;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i!=n){
				vect.push_back(i);
				vect.push_back(n/i);
			}
			else{
				vect.push_back(i);
			}
		}
	}
	ll sum=0;
	for(ll i=0;i<vect.size();i++){
		if(vect[i]>1){
			if(n/(vect[i]-1)==n/vect[i]){
				sum += vect[i]-1;
			}
		}
	}
	cout<<sum<<endl;
}


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

int main()
{
	//freopen("m.txt","r",stdin);
	int n,a,b,c,flag;
	cin>>n;
	while(n--)
	{
		a=b=c=-1,flag=1;
		for(int i=0;i<10;i++)
		{
			cin>>a;
			if(flag)
			{
				if(a>b)
					b=a;
				else if(a>c)
					c=a;
				else
					flag=0;
			}
		}
		cout<<(flag?"YES":"NO")<<endl;
	}
	return 0;
}



Measured memory_bytes: 3080
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

bool check(const string& s) {
  int n = s.size();
  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[n - 1 - i]) return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (check(s) && check(s.substr(0, n / 2)) && check(s.substr(n / 2 + 1, n / 2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

N = len(S)
M = len(T)
ans = M
for i in range(N-M+1):
    cnt = 0
    for j in range(M):
        if T[j] != S[i:i+M][j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define inf 100000000000000ll
using namespace std;

int read();

int n;
long long f[100005][3];
void chmax(long long &x, long long y) { x = x > y ? x : y; }

int main() {
    n = read();
    f[0][0] = 0, f[0][1] = f[0][2] = -inf;
    for (int i = 1, x; i <= n; ++i) {
        x = read();
        {
            f[i][0] = max(f[i - 1][0], f[i - 1][1]),
            f[i][1] = max(f[i - 1][1], f[i - 1][2]);
            f[i][2] = f[i - 1][2];
        }
        f[i][0] += x, f[i][1] -= x, f[i][2] += x;
        if (x < 0) chmax(f[i][2], f[i][1]), chmax(f[i][1], f[i][0]);
    }
    printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2])));
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)998244353;

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow(((b%MOD)*(b%MOD)) % MOD, e >> 1)) % MOD : 1;
}

int n, a[100009];
int vis[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		vis[a[i]]++;
	}
	if (a[0] > 0) {
		cout << 0 << E;
		return 0;
	}
	if (vis[0] != 1) {
		cout << 0 << E;
		return 0;
	}
	long long ans = 1;
	for (int i = 1; i < n; i++) {
		if (i < n - 1 && vis[i] == 0 && vis[i + 1] > 0) {
			cout << 0 << E;
			return 0;
		}
		ans *= quickpow(vis[i - 1], vis[i]);
		ans %= MOD;
	}
	cout << ans << E;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	
	public static void main(String[] $){
		String v=s.next();
		for(int i=v.length();true;i--) {
			if(v.replace(v.substring(0,i),"#").matches("##.+")) {
				System.out.println(i*2);
				return;
			}
		}
	}
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> countNum;
    ll ans = 0;
    REP(i, N)
    {
        cin >> A[i];
    }
    for (ll i = N - 1; i >= 0; --i)
    {
        countNum[i - A[i]]++;
        ans += countNum[A[i] + i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 27380
#include <stdio.h>
const int maxn = 100000 + 10;
int pre[maxn], dist[maxn], n;

int Find(int a)
{
    if(pre[a] != a)
    {
        int tem = Find(pre[a]);
        dist[a] = dist[pre[a]] + dist[a];
        return pre[a] = tem;
    }
    else
        return a;
}
int main()
{
//    freopen("test.in","r",stdin);
    int i,m,n,a,b,fa,fb,w,cha;
    char op;
    while(~scanf("%d%d",&m,&n)){
        if(m+n==0) break;
        for(i=1;i<=m;i++){
            pre[i]=i;
            dist[i]=0;
        }
        while(n--){
            getchar();
            scanf("%c",&op);
            if(op=='!'){
                scanf("%d%d%d",&a,&b,&w);
                fa=Find(a);
                fb=Find(b);
                if(fa!=fb){
                    pre[fb]=fa;
                    dist[fb]=dist[a]+w-dist[b];
                }
            }else if(op=='?'){
                scanf("%d%d",&a,&b);
                fa=Find(a);
                fb=Find(b);
                if(fa!=fb)
                    puts("UNKNOWN");
                else
                    printf("%d\n",dist[b]-dist[a]);
            }
        }
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int arr[n+5];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    int tinggi=arr[0],ans=1;
    for(int i=1; i<n; i++){
        if(arr[i]>=tinggi)ans++;
        tinggi = max(tinggi,arr[i]);
    }
    cout << ans <<endl;
}


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

using namespace std;

struct UnionFind{
private:
  std::vector<int> data;

public:
  UnionFind(int n = 0) : data(n, -1){}

  int find(int x){
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  bool unite(int x, int y){
    x = find(x); y = find(y);

    if(x == y) return false;
    else{
      if(data[x] > data[y]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
      return true;
    }
  }

  bool is_same(int x, int y){
    return find(x) == find(y);
  }

  int size(int x){
    return -data[find(x)];
  }
};

int main(){
  int N, K, L;
  cin >> N >> K >> L;
  
  UnionFind city1(N), city2(N);
  for(int i = 0; i < K; i++){
    int p, q;
    cin >> p >> q;
    p--;
    q--;
    
    city1.unite(p, q);
  }
  
  for(int i = 0; i < L; i++){
    int r, s;
    cin >> r >> s;
    r--;
    s--;
    
    city2.unite(r, s);
  }
  
  map<pair<int, int>, int> m;
  for(int i = 0; i < N; i++){
    m[make_pair(city1.find(i), city2.find(i))]++;
  }
  
  for(int i = 0; i < N - 1; i++){
    cout << m[make_pair(city1.find(i), city2.find(i))] << ' ';
  }
  cout << m[make_pair(city1.find(N - 1), city2.find(N - 1))] << endl;
  
  return 0;
}

Measured memory_bytes: 13568
N, K = map(int,input().split())
count = [0 for i in range(N+1)]
counter = 0
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        count[a[j]] += 1
for i in range(1,N+1):
    if count[i] == 0:
        counter += 1
print(counter)


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

#define int         long long
#define nn          3001
#define FAST        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int n;
int dp[nn][nn][2],a[nn];

int solve(int i,int j,int turn){
    if(i>j)
        return 0;

    if(dp[i][j][turn] != -1)
        return dp[i][j][turn];

    if(turn == 1)
        return dp[i][j][turn] = max(a[i] + solve(i+1,j,0), a[j] + solve(i,j-1,0));
    
    else
        return dp[i][j][turn] = min(solve(i+1,j,1), solve(i,j-1,1));
}

int32_t main() {
    FAST;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum += a[i];
    }

    cout<<2*solve(1,n,1) - sum;
}


Measured memory_bytes: 141184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, k;
	cin >> n >> k;
	int i;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	V ki;
	for (auto c : mp) {
		ki.push_back(c.second);
	}
	sort(all(ki), greater<int>());
	int ans = 0;
	rep(i, ki.size()) if (k < i + 1) ans += ki[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10748
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}

int32_t main()
{
  desperate_optimization(false);
  // freopen("input.txt","r",stdin);
  int n;
  cin>>n;
  vector<long double> dp(n+1);
  dp[0]=1;
  for(int coin=0;coin<n;coin++)
  {
    double h;
    cin>>h;
    for(int i=coin+1;i>=0;i--)
    {
      dp[i]=((i==0?0:dp[i-1]*h) + dp[i]*(1-h));
    }
  }
  long double answer=0;
  for(int heads=0;heads<=n;heads++)
  {
    int tails=n-heads;
    if(heads>tails) answer+=dp[heads];
  }
  printf("%.10Lf",answer);
  return 0;
}


Measured memory_bytes: 256
import sys,math
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
n = int(N**0.5)+1
ANS = 0
for i in range(1,N+1):
    cnt = 0
    for j in range(1,i+1):
        if i%j==0:
            cnt+=1
    if cnt==8:
        if i%2==1:
            ANS+=1
print(ANS)

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

int main(void){
    string s, t;
    cin >> s; cin >> t;
    int count = 0;
    int check = 0;
    vector<string> ans(100000);
    if(s.length()>=t.length()){
    for(int i = 0; i <= s.length()-t.length(); i++){
        count = 0;
        for(int j = 0; j < t.length(); j++){
            if(s[i+j]==t[j]||s[i+j]=='?') count++;
        }
        if(count==t.length()){
            ans[check].insert(0, s, 0, i);
            ans[check]+=t;
            ans[check].insert(i+t.length(), s, i+t.length(), s.length()-t.length()-i);
            check++;
        }
    }}
    if(check==0)
        cout << "UNRESTORABLE" << endl;
    else{
        for(int i = 0; i < check; i++){
            for(int j = 0; j < ans[i].length(); j++){
                if(ans[i][j]=='?') 
                    ans[i][j]='a';
            }
        }
        sort(&ans[0], &ans[check]);
        cout << ans[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, M, k, val, sum;
    int p[100];

    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d", &p[i]);

    scanf("%d", &M);
    for(int i = 0; i < M; i++){
        scanf("%d", &k);
        scanf("%d", &val);

        sum = 0;
        for(int j = 0; j < N; j++){
            if(j == k - 1){
                sum += val;
            }else{
                sum += p[j];
            }
        }

        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

#define MONEY_MAX 1000010

using namespace std;


int main(void){
  bool* prime=(bool*)malloc(MONEY_MAX*sizeof(bool));

  for(int i=0;i<MONEY_MAX;i++){
    prime[i]=true;
  }

  prime[0]=false;
  prime[1]=false;
  for(int i=2;i<sqrt(MONEY_MAX)+10;i++){
    if(prime[i]==false){continue;}
    int k=2;
    while(k*i<MONEY_MAX){
      prime[k*i]=false;
      k++;
    }
  }

  int n,x;
  while(true){
    cin>>n>>x;
    if(n==0 and x==0){break;}
    int v[n];
    for(int i=0;i<n;i++){
      cin>>v[i];
    }
    bool* table[n];
    for(int i=0;i<n;i++){
      table[i]=(bool*)malloc(sizeof(bool)*(x+1));
      for(int j=0;j<=x;j++){
        table[i][j]=false;
      }
    }
    for(int j=0;j<=x;j++){
      table[0][j]=(j%v[0]==0);
    }
    for(int i=1;i<n;i++){
      for(int j=0;j<=x;j++){
        if(j-v[i]>=0){
          table[i][j]=table[i-1][j] or table[i-1][j-v[i]] or table[i][j-v[i]];
        }
        else{
          table[i][j]=table[i-1][j];
        }
      }
    }
    for(int s=x;s>=0;s--){
      if(prime[s] and table[n-1][s]){
        cout<<s<<endl;
        break;
      }
      if(s==0){
        cout<<"NA"<<endl;
      }
    }
    for(int i=0;i<n;i++){
      free(table[i]);
    }
  }

  return 0;
}



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

using namespace std;

class UnionFind {
  public:
   vector<int> Parent;
 
   UnionFind(int N) {
     Parent = vector<int>(N, -1);
   }
 
   int root(int A) {
     if (Parent[A] < 0) return A;
     return Parent[A] = root(Parent[A]);
   }
  
   int size(int A) {
     return -Parent[root(A)];
   }
  
   bool connect(int A, int B) {
     A = root(A);
     B = root(B);
     if (A == B) return false;
     if (size(A) < size(B)) { swap(A, B); }
     Parent[A] += Parent[B];
     Parent[B] = A;
     
     return true;
   }
};

int main() {
  int N, M;
  
  cin >> N >> M;
  
  UnionFind uf(N);
  
  for (int i = 0; i < M; i++) {
    int in1, in2;
    
    cin >> in1 >> in2;
    
    in1--;
    in2--;
    
    uf.connect(in1, in2);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, uf.size(i));
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3984
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] B = new int[N - 1];
        for (int i = 0; i < N - 1; i++) {
            B[i] = Integer.parseInt(sc.next());
        }

        int sumA = B[0] + B[N - 2];
        for (int i = 1; i < N - 1; i++) {
            sumA += Math.min(B[i - 1], B[i]);
        }

        System.out.println(sumA);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int n, i, x;
  scanf("%d" , &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    a[x - 1] = i + 1;
  }
  for (i = 0; i < n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}


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

#define ll long long
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        rep(i, H) {
            rep(j, W) {
                if (i % 2 == 0) {
                    if (j % 2 == 0) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                } else {
                    if (j % 2 != 0) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(){

	int n;
	cin >> n;
	int debt = 100000;
	for(int i = 0; i < n; i++){
		debt += debt/20;
		int lower = debt % 1000;
		debt -= lower;
		if(lower != 0)
			debt += 1000;
	}
	cout << debt << endl;
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <map>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;

bool dot[5010][5010];
P z[3000];
int n;

int pow(int x){
	return x*x;
}

int main(){
	while(scanf("%d", &n),n){
		rep(i,5010) rep(j,5010) dot[i][j] = false;
		rep(i,n){
			scanf("%d%d", &z[i].fi, &z[i].sec);
			dot[z[i].fi][z[i].sec] = true;
		}
		sort(z,z+n);
		int ans = 0;
		rep(i,n){
			for(int j = i+1; j < n; j++){
				int dx = z[j].fi-z[i].fi, dy = z[j].sec-z[i].sec;
				//cout << z[i].fi << "-" << z[i].sec << " " << z[j].fi << "-" << z[j].sec << endl;
				//cout << z[i].fi-dy << "-" << z[i].sec+dx << " " << z[j].fi-dy << "-" << z[j].sec+dx << endl;
				//cout << endl;
				if(0<=z[i].fi-dy&&z[i].fi-dy<5010&&z[i].sec+dx<5010&&0<=z[j].fi-dy&&z[j].fi-dy<5010&&z[j].sec+dx<5010){
					if(dot[z[i].fi-dy][z[i].sec+dx] == true && dot[z[j].fi-dy][z[j].sec+dx] == true){
						ans = max(ans,pow(-min(z[i].fi,z[j].fi)+max(z[i].fi-dy,z[j].fi-dy))-dx*max(dy,-dy)*2);
					}
				}
				//cout << z[i].fi << "-" << z[i].sec << " " << z[j].fi << "-" << z[j].sec << endl;
				//cout << z[i].fi+dy << "-" << z[i].sec+dx << " " << z[j].fi+dy << "-" << z[j].sec+dx << endl;
				//cout << endl;
				if(0<=z[i].fi+dy&&z[i].fi+dy<5010&&z[i].sec+dx<5010&&0<=z[j].fi+dy&&z[j].fi+dy<5010&&z[j].sec+dx<5010){
					if(dot[z[i].fi+dy][z[i].sec+dx] == true && dot[z[j].fi+dy][z[j].sec+dx] == true){
						ans = max(ans,pow(-min(z[i].fi,z[j].fi)+max(z[i].fi-dy,z[j].fi-dy))-dx*max(dy,-dy)*2);
					}
				}
				//cout << z[i].fi << "-" << z[i].sec << " " << z[j].fi << "-" << z[j].sec << endl;
				//cout << z[i].fi-dy << "-" << z[i].sec-dx << " " << z[j].fi-dy << "-" << z[j].sec-dx << endl;
				//cout << endl;
				if(0<=z[i].fi-dy&&z[i].fi-dy<5010&&0<=z[i].sec-dx&&0<=z[j].fi-dy&&z[j].fi-dy<5010&&0<=z[j].sec-dx){
					if(dot[z[i].fi-dy][z[i].sec-dx] == true && dot[z[j].fi-dy][z[j].sec-dx] == true){
						ans = max(ans,pow(-min(z[i].fi,z[j].fi)+max(z[i].fi-dy,z[j].fi-dy))-dx*max(dy,-dy)*2);
					}
				}
				//cout << z[i].fi << "-" << z[i].sec << " " << z[j].fi << "-" << z[j].sec << endl;
				//cout << z[i].fi+dy << "-" << z[i].sec-dx << " " << z[j].fi+dy << "-" << z[j].sec-dx << endl;
				//cout << endl;
				if(0<=z[i].fi+dy&&z[i].fi+dy<5010&&0<=z[i].sec-dx&&0<=z[j].fi+dy&&z[j].fi+dy<5010&&0<=z[j].sec-dx){
					if(dot[z[i].fi+dy][z[i].sec-dx] == true && dot[z[j].fi+dy][z[j].sec-dx] == true){
						ans = max(ans,pow(-min(z[i].fi,z[j].fi)+max(z[i].fi-dy,z[j].fi-dy))-dx*max(dy,-dy)*2);
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 25724