akhauriyash/Code-Regression huggingface dataset:
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

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

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
	for (auto x : v)      \
	{                     \
		cout << x << " "; \
	}
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
	ll t;     \
	cin >> t; \
	while (t--)
#define FIO                           \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define FAST                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
	freopen((prob + ".in").c_str(), "r", stdin);
	freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
	if (n < 2)
		return false;
	for (int x = 2; x * x <= n; x++)
	{
		if (n % x == 0)
			return false;
	}
	return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
	vector<int> f;
	for (int x = 2; x * x <= n; x++)
	{
		while (n % x == 0)
		{
			f.push_back(x);
			n /= x;
		}
	}
	if (n > 1)
		f.push_back(n);
	return f;
}

ll c[300007];
multiset<ll> best;

void upd(ll pos, ll delta)
{
	if (best.size())
	{
		best.erase(best.find(c[pos]));
	}
	c[pos] += delta;
	best.insert(c[pos]);
}

void solve()
{
	/* Write Solution Here */
	ll R, C, M;
	cin >> R >> C >> M;
	vll r[R];

	forn(i, C)
	{
		c[i] = 0;
		best.insert(0);
	}

	forn(i, M)
	{
		ll x, y;
		cin >> x >> y;
		--x;
		--y;
		r[x].PB(y);
		// cout << "helo1\n";
		upd(y, 1);
		// cout << "helo2\n";
	}
	ll ans = 0;
	forn(i, R)
	{
		ll cur = r[i].size();

		for (auto x : r[i])
		{
			upd(x, -1);
		}

		if (best.size())
		{
			cur += *best.rbegin();
		}

		ans = max(ans, cur);

		for (auto x : r[i])
		{
			upd(x, 1);
		}
	}

	cout << ans << "\n";
}

int main()
{
	//FIO
	//FAST

	//usaco("cowlands");

	ll TC = 1;
	/*
	Uncomment when multiple test cases
	*/

	// cin>>TC;
	for1(tt, TC)
	{
		solve();
	}
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 36448
from subprocess import call
call(('pypy3','-c',"""N,M,R=map(int,input().split())
r=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
d=[[float("inf")]*N for i in range(N)]

for a,b,c in A:
  d[a-1][b-1]=c
  d[b-1][a-1]=c 
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
      
import itertools 
ans=1000000000
for i in itertools.permutations(range(R),R):
  D=0
  for j in range(R-1):
    D+=d[r[i[j]]-1][r[i[j+1]]-1]
  ans=min(D,ans)
print(ans)
"""))


Measured memory_bytes: 76520
#include<iostream>
#include <cstdlib>
using namespace std;
int main(){
int x,y,z;
cin>>x>>y;
int i=0;
bool c=1;
if((x+y)%2==0)
{


while(c)
{
  if(abs(x-i)==abs(y-i))
    {
        z=i;
        c=0;
    }

i++;
}

cout<<z;
}
else cout<<"IMPOSSIBLE";
return 0;
}



Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

flag = True
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
if flag:
    print('Yes')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;

using namespace std;
lli con = (int)pow(10,9) + 7;

int main()
{
    int n;
    cin>>n;
    lli arr[n];
    lli pref[n];
    
    lli sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    pref[0] = arr[0];
    for(int i=1;i<n;i++){
        //cin>>arr[i];
        //sum+=arr[i];
        pref[i] = pref[i-1] + arr[i];
    }
    
    
    lli res = 0;
    
    for(int i=0;i<n;i++){
        //cin>>arr[i];
        //sum+=arr[i];
        
        res += ( (arr[i] % con)*((sum - pref[i]) % con ) )%con;
    }
    cout<<(res)%con<<"\n";
    
    return 0;
}

Measured memory_bytes: 6756
n = int(input())
a = list(map(int, input().split()))
h = {}
for x in a:
    if h.get(x):
        h[x] += 1
    else:
        h[x] = 1
ans = 0
for k in h:
    if h[k] > k:
        ans += h[k] - k
    elif h[k] < k:
        ans += h[k]
print(ans)

Measured memory_bytes: 17780
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int n; cin >> n;
    
    switch(n) {
        case 3 : 
        case 5 : 
        case 7 : cout << "YES" << endl; break; 
        default: cout << "NO" << endl; break;

    }
    
    return 0;
}



Measured memory_bytes: 256
def month(num):
    if 0 < num <= 12:
        return True
    else:
        return False


S = input()
first = int(S[:2])
second = int(S[2:])

if month(first):
    if month(second):
        print('AMBIGUOUS')
    else:
        print('MMYY')

elif not month(first) and month(second):
    print('YYMM')

else:
    print('NA')





Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int dp[N];
int n, ans[N], a[N];
vector <int> gr[N];

void dfs(int u, int par) {
	int pos = lower_bound(dp, dp + N, a[u]) - dp - 1;
	ans[u] = max(ans[par], pos + 1);
	int pval = dp[pos + 1];
	uin(dp[pos + 1], a[u]);
	for (int v : gr[u]) {
		if (v == par)
			continue;
		dfs(v, u);
	}
	dp[pos + 1] = pval;
}

void solve() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	fill(dp, dp + N, INF);
	dp[0] = 0;
	dfs(0, 0);
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

int main() {
    long Q, H, S, D;
    cin>>Q>>H>>S>>D;
    long N;
    cin>>N;
    long ans;
    if(N==1){
        ans = min(Q*4, min(H*2, S));
        cout<<ans<<endl;
    }
    else if(N==3){
        int dp[13];
        dp[0] = 0;
        dp[1] = Q;
        dp[2] = min(dp[0]+H, dp[1]+Q);
        dp[3] = min(dp[1]+H, dp[2]+Q);
        dp[4] = min(dp[0]+S, min(dp[2]+H, dp[3]+Q));
        dp[5] = min(dp[1]+S, min(dp[3]+H, dp[4]+Q));
        dp[6] = min(dp[2]+S, min(dp[4]+H, dp[5]+Q));
        dp[7] = min(dp[3]+S, min(dp[5]+H, dp[6]+Q));
        dp[8] = min(dp[0]+D, min(dp[4]+S, min(dp[6]+H, dp[7]+Q)));
        for(int i=9;i<13;++i){
            dp[i] = min(dp[i-8]+D, min(dp[i-4]+S, min(dp[i-2]+H, dp[i-1]+Q)));
        }
        cout<<dp[12]<<endl;
    }
    else if(N%2==0){
        ans = min(Q*(N*4), min(H*(N*2), min(S*N, D*(N/2))));
        cout<<ans<<endl;
    }
    else {
        ans = min(Q*((N-3)*4), min(H*((N-3)*2), min(S*(N-3), D*((N-3)/2))));
        int dp[13];
        dp[0] = 0;
        dp[1] = Q;
        dp[2] = min(dp[0]+H, dp[1]+Q);
        dp[3] = min(dp[1]+H, dp[2]+Q);
        dp[4] = min(dp[0]+S, min(dp[2]+H, dp[3]+Q));
        dp[5] = min(dp[1]+S, min(dp[3]+H, dp[4]+Q));
        dp[6] = min(dp[2]+S, min(dp[4]+H, dp[5]+Q));
        dp[7] = min(dp[3]+S, min(dp[5]+H, dp[6]+Q));
        dp[8] = min(dp[0]+D, min(dp[4]+S, min(dp[6]+H, dp[7]+Q)));
        for(int i=9;i<13;++i){
            dp[i] = min(dp[i-8]+D, min(dp[i-4]+S, min(dp[i-2]+H, dp[i-1]+Q)));
        }
        cout<<ans + dp[12]<<endl;
    }
}


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

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if ((i < B && j < A) || (i >= B && j >= A)) {
                cout << '0';
            } else {
                cout << '1';
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);char s[1];
    cin>>s;
    if(s[0]>=65 && s[0]<=90)
     cout<<"A";
     
    else 
     cout<<"a";
    return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	char a[100];
	int b;
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;

	for (int i = 0; i < 100; i++)a[i] = 0;
	scanf("%s", a);


	if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
N,K,Q=map(int,input().split())
A=[0]*Q
for i in range(0,Q):
    A[i]=int(input())

B=[0]*(N+1)
for i in range(0,Q):
    B[A[i]-1]=B[A[i]-1]+1#各参加者の正解数

for i in range(0,N):
    s=0
    if K>Q-B[i]:
        print('Yes')
    else:
        print('No')


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

int main() {
    long long a,b,x;
    cin >> a >> b >> x;
    if(a>=1){
        cout << (b/x)-((a-1)/x) << endl;
    }
    else if(a==0){
        cout << b/x+1 << endl;
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

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

    vector<int> tmp=sieve_of_eratosthenes(55555);
    vector<vector<int>> primes(5);
    for(int i=2;i<55555;i++){
        if(tmp[i]==0) continue;
        int idx=i%5;
        primes[idx].push_back(i);
        //cout<<idx<<" "<<i<<endl;
    }
    int n;cin>>n;
    vector<int> res;
    for(int i=0;i<n;i++) res.push_back(primes[1][i]);
    for(int i=0;i<n;i++){
        if(i==0) cout<<res[i];
        else cout<<" "<<res[i];
    }
    cout<<endl;
}


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

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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    
    int l, m, n;
    l = a * x + b * y;
    m = c * max(x, y) * 2;
    n = c * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y));
    cout << min(l, min(m, n)) << endl;

    return 0;
}

Measured memory_bytes: 256
n,c,k=map(int, input().split())
t=[]
for _ in range(n):
  tmp=[int(input())]
  t.extend(tmp)
t.sort()
t.append(10**10)
ans=0
cnt_pssngr=1
fst_pssnger_t=t[0]
for i in range(1,n+1):
  if cnt_pssngr<c and t[i]<=fst_pssnger_t+k:
    cnt_pssngr+=1
  else:
    ans+=1
    cnt_pssngr=1
    fst_pssnger_t=t[i]
print(ans)

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<Int> res;
    Int n;
    while (cin >> n and n) {
        vector<double> x(n), y(n);
        rep(i, 0, n) cin >> x[i] >> y[i];
        Int ma = 1;
        rep(i, 0, n - 1) rep(j, i + 1, n) {
            double d = sqrt(pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0));
            if (d > 2.0) continue;
            complex<double> m((x[i] + x[j]) / 2.0, (y[i] + y[j]) / 2.0);
            complex<double> mv(1.0, -1.0 / ((y[i] - y[j]) / (x[i] - x[j])));
            mv /= abs(mv);
            complex<double> ml(abs(x[i] - x[j]) / 2.0, abs(y[i] - y[j]) / 2.0);
            mv *= sqrt(1.0 - pow(d / 2.0, 2.0));
            complex<double> a = m + mv, b = m - mv;
            // printf("a : %.12lf %.12lf\n", a.real(), a.imag());
            // printf("b : %.12lf %.12lf\n", b.real(), b.imag());
            Int cnt_a = 0;
            rep(k, 0, n) {
                double xx = pow(x[k] - a.real(), 2.0);
                double yy = pow(y[k] - a.imag(), 2.0);
                // printf("xx + yy = %.12lf\n", xx + yy);
                if (xx + yy <= 1.0 + EPS) cnt_a++;
            }
            Int cnt_b = 0;
            rep(k, 0, n) {
                double xx = pow(x[k] - b.real(), 2.0);
                double yy = pow(y[k] - b.imag(), 2.0);
                // printf("xx + yy = %.12lf\n", xx + yy);
                if (xx + yy <= 1.0 + EPS) cnt_b++;
            }
            ma = max(ma, max(cnt_a, cnt_b));
        }
        res.push_back(ma);
    }
    rep(i, 0, res.size()) dump(res[i]);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>v(n+1,0);
    for(int i=1; i<n; i++){
        int t;
        cin >> t;
        v[t]++;
    }
    for(int i=1; i<=n; i++)
        cout << v[i] << endl;
    return 0;
}


Measured memory_bytes: 3980
const SIZE: usize = 600;
const C: usize = 8;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let mut dp: [[u64; C]; SIZE] = [[0; C]; SIZE];
    for i in 0..SIZE {
        dp[i][0] = 1;
    }
    for cur in 0..SIZE {
        for next in cur..SIZE {
            for cur_c in 0..(C - 1) {
                dp[next][cur_c + 1] += dp[cur][cur_c];
            }
        }
    }

    let mut k: u64 = sc.read();
    let mut ans = vec![0; SIZE];
    for i in (0..SIZE).rev() {
        ans[i] = k / dp[i][C - 1];
        k -= ans[i] * dp[i][C - 1];
    }

    let mut s = String::new();
    for i in 0..SIZE {
        s.push_str("FESTIVA");
        for _ in 0..ans[i] {
            s.push('L');
        }
    }
    assert!(s.len() <= 5000);
    println!("{}", s);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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




int main(){

int X,i,j,max;

vector< vector<int> > v;

std::cin >> X;

//重要
v.resize(11111);		// ()内の数字が要素数になる
	for( int i=0; i<11111; i++ ){
		v[i].resize(11111);
	}


max=1;


for(i=0;i<=X/2;i++){
  v[i][0]=pow(i+2,2);
  for(j=0;v[i][j]<=X;j++){
    v[i][j+1]=pow(i+2,j+3);
    if(max<=v[i][j]) max=v[i][j];
  }
}


std::cout << max << '\n';






  return 0;
}


Measured memory_bytes: 483072
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using lli=long long int;
using ld=long double;
 
lli N;
lli memo[1001][10001];
 
struct element
{
    lli w;
    lli s;
    lli v;
    lli w_plus_s;
};
 
element arr[1001];
 
bool compare(element i,element j)
{
    return(i.w_plus_s > j.w_plus_s);
}
 
 
 
lli max_value(lli index,lli wt)
{
    if(wt>1e4)
        return 0;
    if(index==-1)
        return 0;
    if(memo[index][wt]!=-1)return memo[index][wt];
    if(wt>arr[index].s)
        return ( memo[index][wt] = max_value(index-1,wt) );
    return( memo[index][wt] =   max( max_value(index-1,wt) , max_value(index-1,wt+arr[index].w)+arr[index].v )   );
}
 
 
int main()
{
    lli i,j;
    for(i=0;i<=1000;i++)
        for(j=0;j<=10000;j++)
            memo[i][j]=-1;
 
 
    cin>>N;
 
    for(i=0;i<N;i++)
    {
        cin>>arr[i].w>>arr[i].s>>arr[i].v;
        arr[i].w_plus_s=arr[i].w + arr[i].s;
    }
    sort(arr,arr+N,compare);
 
 
    lli ans=max_value(N-1,0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 78592
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238;
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int N = 1 << 18;

class Node {
public:
    ll max;
    int l, r;

    Node() : max(-LINF), l(-1), r(-1) {}

    Node(ll val, int l, int r) : max(val), l(l), r(r) {}

    Node operator+(const Node& other) const {
        return Node(std::max(max, other.max), l, other.r);
    }
};

Node tree[2 * N];

void build() {
    for (int i = 0; i < N; ++i) {
        tree[i + N] = Node(0, i, i + 1);
    }
    for (int i = N - 1; i > 0; --i) {
        tree[i] = tree[i * 2] + tree[i * 2 + 1];
    }
}

Node get(int v, int l, int r) {
    if (tree[v].r <= l || r <= tree[v].l) {
        return Node();
    }
    if (l <= tree[v].l && tree[v].r <= r) {
        return tree[v];
    }
    return get(v * 2, l, r) + get(v * 2 + 1, l, r);
}

void upd(int pos, ll newVal) {
    pos += N;
    tree[pos].max = newVal;
    pos /= 2;

    while (pos > 0) {
        tree[pos] = tree[pos * 2] + tree[pos * 2 + 1];
        pos /= 2;
    }
}

int h[N], a[N];

void run() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    build();

    for (int i = 0; i < n; ++i) {
        Node val = get(1, 0, h[i]);
        upd(h[i], val.max + a[i]);
    }

    printf("%lld\n", get(1, 0, N).max);
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    auto start = std::chrono::high_resolution_clock::now();
    run();
    auto end = std::chrono::high_resolution_clock::now();

    #ifdef PERVEEVM_LOCAL
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	maked(r);
	printf("%.12f %.12f\n", r * r * M_PI, 2 * r * M_PI);
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
using namespace std;

class Card{
public:
  int n;
  int m;
  bool operator <(const Card &c) const {
    if(n != c.n) return n < c.n;
    if(m != c.m) return m < c.m;
    return false;
  }
};

bool isOneM(Card card[5]) {
  int m = card[0].m;
  for(int i = 1; i < 5; i++) {
    if(card[i].m != m) return false;
  }
  return true;
}

int isSt(Card card[5]) {
  if(card[0].n == 1 && card[1].n == 10 && card[2].n == 11
     && card[3].n == 12 && card[4].n == 13) return 2;

  for(int i = 1; i < 5; i++) {
    if(card[i].n - card[i-1].n != 1) return 0;
  }
  return 1;
}

int main() {
  static map<char, int> mark;
  mark['S'] = 0;
  mark['C'] = 1;
  mark['H'] = 2;
  mark['D'] = 3;
  static map<char, int> number;
  number['A'] = 1;
  number['T'] = 10;
  number['J'] = 11;
  number['Q'] = 12;
  number['K'] = 13;

  int N;
  int cp[4][13];
  int rate[10];
  Card card[5];
  int cnum[5];
  int numSize;

  bool flag = false;

  while(1) {
    cin >> N;
    if(cin.eof()) break;
    if(!flag) flag = true;
    else      cout << endl;

    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 13; j++) {
	cin >> cp[i][j];
      }
    }
    rate[0] = 0;
    for(int i = 1; i <= 9; i++) {
      cin >> rate[i];
    }
    for(int t = 0; t < N; t++) {
      for(int i = 0; i < 5; i++) {
	string str;
	cin >> str;
	if(str[0] >= '0' && str[0] <= '9') card[i].n = str[0] - '0';
	else                               card[i].n = number[str[0]];
	card[i].m = mark[str[1]];
      }

      sort(card, card+5);

      cnum[0] = 1;
      numSize = 1;
      int bfr = card[0].n;
      for(int i = 1; i < 5; i++) {
	if(card[i].n != bfr) {
	  numSize++;
	  cnum[numSize-1] = 0;
	}
	cnum[numSize-1]++;
	bfr = card[i].n;
      }
      sort(cnum, cnum+5, greater<int>());

      int yaku;
      bool flash = isOneM(card);
      int suto = isSt(card);
      if(flash && suto == 2) {
	yaku = 9;
      } else if(flash && suto == 1) {
	yaku = 8;
      } else if(cnum[0] == 4) {
	yaku = 7;
      } else if(numSize == 2 && cnum[0] == 3 && cnum[1] == 2) {
	yaku = 6;
      } else if(flash) {
	yaku = 5;
      } else if(suto != 0) {
	yaku = 4;
      } else if(cnum[0] == 3) {
	yaku = 3;
      } else if(cnum[0] == 2 && cnum[1] == 2) {
	yaku = 2;
      } else if(cnum[0] == 2) {
	yaku = 1;
      } else {
	yaku = 0;
      }

      int point = 0;
      for(int i = 0; i < 5; i++) {
	point += cp[card[i].m][card[i].n-1];
      }
      point *= rate[yaku];

      cout << point << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    for (ll i = 3; i*i <= num; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  ll M = N;
  ll j=0;
  for(ll i=2;i*i<=N+10;i++){
    if(M%i==0 && IsPrime(i)){
      ll k=i;
      while (M%k==0){
        //cout << k << endl;
	M/=k;
	k=k*i;
	ans++;
      }
    }
    j=i;
  }
  if(M>j)ans++;
  if(ans==0 && N>1) ans=1;
  cout << ans << endl;
}

/*
int main() {
  ll N;
  cin>>N;
  ll p=sqrt(N);
  vector<ll>a(p+10);
  for(ll i=0;i<p+10;i++) a[i]=0;
  ll n=N;
  ll ans=0;
  for(ll i=2;i<=p+10;i++){
    while(1){
      if(n%i==0)n/=i;
      else break;
      a[i]++;
    }
    if(n<i)break;
  }
  for(ll i=2;i<p+10;i++){
    if(a[i]!=0){
      for(ll u=1;;u++){
	if(a[i]>=u){
	  ans++;
	  a[i]-=u;
	}
	else break;
      }
    }
  }
  if(n!=1)ans++;
  if(N==1)cout<<0<<endl;
  else cout<<ans<<endl;
}
*/


Measured memory_bytes: 3176
import java.util.Scanner;


public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T_i[] =new long[N];
		for(int i=0;i<N;i++)
		{
			T_i[i]= Long.parseLong(sc.next());
		}
	
		long lcm = N>1 ?lcm(T_i[0],T_i[1]):T_i[0];
		for(int i=2;i<T_i.length;i++)
		{
			
			lcm=lcm(lcm,T_i[i]);
		}
		System.out.println(lcm);
		
	}
	
	static long lcm(long t1,long t2)
	{
		
		if(t1==t2)
		{
			return t1;
		}
		long x=t1;
		long y=t2;

		long gcd=1;
		for(;;)
		{
			if(x<y)
			{
//				System.out.println("x<y:"+x+"/"+y);
				y=y%x;
				if(y==0)
				{
					gcd=x;
					break;
				}
			}
			else if(y<x)
			{
//				System.out.println("y<x:"+x+"/"+y);
				x=x%y;
				if(x==0)
				{
					gcd=y;
					break;
				}
			}
		}
		return t1*(t2/gcd);

	}

}


Measured memory_bytes: 22100
#include<iostream>
using namespace std;
#define LL long long
int main()
{
	
	LL k,a,b,ans;
	cin>>k>>a>>b;
	if(a+2>b) cout<<k+1;
	else if(k+1<a+2) cout<<k+1;
	else
	{
		k=k-a-1;
		cout<<k/2*(b-a)+k%2+b; 
	}
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int>> A(3, vector<int>(3, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  vector<vector<bool>> X(3, vector<bool>(3, false));
  auto f = [&](int b) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (A[i][j] == b) X[i][j] = true;
      }
    }
  };
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    f(b);
  }
  bool flag = false;

  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (X[i][j]) cnt++;
    }
    if (cnt == 3) flag = true;
  }
  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (X[j][i]) cnt++;
    }
    if (cnt == 3) flag = true;
  }
  if (X[0][0] && X[1][1] && X[2][2]) flag = true;
  if (X[0][2] && X[1][1] && X[2][0]) flag = true;

  if (flag) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  load(v, n);

  sort(v);
  int m = v[n - 1];
  int sum = accumulate(v.begin(), v.end() - 1, 0);
  if (m < sum) {
    py();
  } else {
    pn();
  }
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {

    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val A = Array.fill(N)(sc.nextLong)

    def gcd(x: Long, y: Long): Long = {
      if (y == 0) x else gcd(y, x % y)
    }

    val L = new Array[Long](N + 1)
    L(0) = 0
    val R = new Array[Long](N + 1)
    R(N) = 0

    for (i <- 0 until N) {
      L(i + 1) = gcd(A(i), L(i))
    }

    for (i <- N - 1 to 0 by -1) {
      R(i) = gcd(A(i), R(i + 1))
    }

    var result = 0L

    for (i <- 0 until N) {
      val tmp = gcd(L(i), R(i + 1))
      if (result < tmp) {
        result = tmp
      }
    }

    println(result)
  }
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pib = pair<int, bool>;

inline void Main() {
  // code
  int n, l;
  pib x[200];
  int g = 0;
  cin>>n>>l;

  rep(i, n) {
    g += l+i;
    x[i] = pib(abs(l + i), l+i>=0);
  }
  sort(x, x+n);
  cout << g - (x[0].second?x[0].first:-1*x[0].first) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

int main() {
    int n, a, b;
    long long maxt = 0, maxa = 0;

    cin >> n;

    vector<int> sum(n);

    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        sum.at(i) = a + b;
        maxt += b;
    }

    sort(sum.begin(), sum.end(), greater<int>());

    for(int i = 0; i < n; i++) {
        if(i % 2 == 0)
        maxa += sum.at(i);
    }

    cout << maxa - maxt << endl;

    return 0;
}

Measured memory_bytes: 640
s=input()
n=len(s)
p=q=0
for i in range(n):
  if s[i]=="R":
    p+=1
  else:
    q+=1
    if i<n-1:
      if s[i+1]=="R":
        for j in range(p-1):
          print(0)
        if (p+q)%2==0:
          print((p+q)//2)
          print((p+q)//2)
        else:
          if p%2==0:
            print((p+q)//2)
            print((p+q)//2+1)
          else:
            print((p+q)//2+1)
            print((p+q)//2)
        for j in range(q-1):
          print(0)
        p=q=0
for j in range(p-1):
  print(0)
if (p+q)%2==0:
  print((p+q)//2)
  print((p+q)//2)
else:
  if p%2==0:
    print((p+q)//2)
    print((p+q)//2+1)
  else:
    print((p+q)//2+1)
    print((p+q)//2)
for j in range(q-1):
  print(0)

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

int main()
{
    string f,r;
    cin >> f >> r;

    int cnt = 0;

    for(int i = 0; i < 3; i++)
    {
        if(f.at(i) == r.at(i))cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int main()
{
	char a[3];
	cin>>a;
	int c1=0,c2=0;
	for(int i=0;i<3;i++)
	{if(a[i]=='A')
	c1++;
	else
	c2++;}
	if(c1>0 && c2>0)
	cout<<"Yes";
	else
	cout<<"No";
	
	
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math/big"
	"strconv"
)

var N int
var Kstr string
var K = big.NewInt(0)
var cycleStartAt, cycleStart int
var cycle []int

func main() {
	fmt.Scan(&N, &Kstr)
	ctr := int64(0)
	ten := big.NewInt(10)
	for i := len(Kstr) - 1; i >= 0; i-- {
		val, _ := strconv.Atoi(string(Kstr[i]))
		K = new(big.Int).Add(K, new(big.Int).Mul(big.NewInt(int64(val)), new(big.Int).Exp(ten, big.NewInt(ctr), nil)))
		ctr++
	}
	towns := make([]*town, N+1)
	towns[0] = &town{
		next: 1,
		came: false,
	}
	for i := 1; i <= N; i++ {
		var next int
		fmt.Scan(&next)
		towns[i] = &town{
			next: next,
			came: false,
		}
	}
	s := 1
	cur := 1
	for {
		if towns[cur].came {
			cycleStartAt = cur
			cycleStart = s
			break
		}
		towns[cur].came = true
		cur = towns[cur].next
		s++
	}
	cur = 0
	for i := 0; i <= N; i++ {
		if towns[cur].next == cycleStartAt {
			t := towns[cur]
			for {
				cycle = append(cycle, t.next)
				t = towns[t.next]
				if t.next == cycleStartAt {
					break
				}
			}
			break
		}
		cur = towns[cur].next
	}
	step := big.NewInt(0)
	cur = 1
	if K.Int64() <= int64(cycleStart) {
		for i := int64(1); i <= K.Int64(); i++ {
			cur = towns[cur].next
		}
		fmt.Println(cur)
		return
	}
	for {
		step = new(big.Int).Add(step, big.NewInt(1))
		currentTown := towns[cur]
		if currentTown.next == cycleStartAt {
			addr := new(big.Int).Mod(new(big.Int).Sub(K, step), big.NewInt(int64(len(cycle))))
			fmt.Print(cycle[addr.Int64()])
			return
		}
		cur = currentTown.next
	}
}

type town struct {
	next int
	came bool
}


Measured memory_bytes: 16640
#include <cstdio>

typedef long long LL;

LL N, X;

LL f(LL a, LL b) {
	return b ? a / b * b * 2 + f(b, a % b) : -a;
}

int main() {
	scanf("%lld%lld", &N, &X);
	printf("%lld\n", N + f(X, N - X));
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

int main() {
  int n;
  while (cin >> n) {
    long long res = 0;
    rep (a, 1001) rep (b, 1001) if (a + b <= n) {
      int nn = n - a - b;
      if (nn <= 1000) res += nn + 1;
      else if (nn <= 2000) res += 2000 - nn + 1;
    }
    cout << res << endl;
  }
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string res;
    while (n != 0) {
        if (n%2) {
            res += '1';
            n -= 1;
        } else {
            res += '0';
        }
        n /= -2;
    }
    reverse(res.begin(), res.end());
    if (res.length() == 0) {
        res = "0";
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
 int n,m;
 cin>>n>>m;
 bitset<400> b[n];
 for(int i=0;i<n;i++)b[i].set(i);
 int x,y;
 for(int i=0;i<m;i++){
   cin>>x>>y;x--;y--;
   if((b[x]&b[y]).none())b[x]|=b[y];
   else b[x]|=(~b[x]);
     
 

    b[y]=b[x];
  
 }
 int ans=0;
 for(int i=0;i<n;i++)for(int j=0;j<i;j++)if((b[i]&b[j]).none())ans++;
 cout<<ans<<endl;



}


        


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 2e5 + 10;
int par[MAXN];
int find(int i) {
  if (par[i] == i) return i;
  return par[i]=find(par[i]);
}
void add(int i, int j) {
  int a = find(i);
  int b = find(j);
  par[a] = b;
}





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, m; cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    add(a, b);
  }
  map<int, int> table;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    table[find(i)]++;
    ret = max(ret, table[find(i)]);
  }
  cout << ret << '\n';






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 13336
a,b=map(int,input().split())
sum=0
if a > b:
    sum+=a
    if (a-1) > b:
        sum+=(a-1)
    elif (a-1)<b:
        sum+=b
    else:
        sum+=(a-1)
elif a < b:
    sum+=b
    if a < (b-1):
        sum+=(b-1)
    elif a > (b-1):
        sum+=a
    else:
        sum+=(b-1)
else:
    sum=a+a
print(sum)

Measured memory_bytes: 9220
#include<stdio.h>

int main(){
  int n;
  int arr[100];
  int input;
  int i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &input);
    arr[i] = input;
  }

  for(j = i - 1; j >= 0; j--){
    printf("%d", arr[j]);
    if(j != 0){
      printf(" ");
    }
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 2076
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

ll n,a,b;
ll fastPower(ll b,ll p)
{
    if(p==0)
        return 1LL;
    ll res=fastPower(b,p/2LL);
    res%=MOD;
    res*=res;
    res%=MOD;
    if(p&1)
        res*=b;
    return (res%MOD);
}
ll binomialCoeff(ll n, ll k)
{
    ll res = 1;

    if ( k > n - k )
        k = n - k;

    for (ll i = 0; i < k; ++i)
    {
        res *= (n - i);
        res%=MOD;
        res *= fastPower(i + 1LL,MOD-2);
        res%=MOD;
    }
    return res;
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    ll ans= fastPower(2LL,n);
    ans--;
    ans=(ans%MOD+MOD)%MOD;

    ll aa= binomialCoeff(n,a)%MOD;
    ll bb= binomialCoeff(n,b)%MOD;

    ans=((ans-aa)%MOD+MOD)%MOD;
    ans=((ans-bb)%MOD+MOD)%MOD;

    printf("%lld\n",ans);
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    while (cin >> n && n > 0){
        int t[n][n+1];
        REP(i,n) REP(j,n+1) cin >> t[i][j];
        VI dp(1<<n,1e9);
        dp[0] = 0;
        REP(i,1<<n){
            REP(j,n){
                if ((i>>j) & 1) continue;
                int c = t[j][0];
                REP(k,n){
                    if ((i>>k) & 1) c = min(c,t[j][k+1]);
                }
                dp[i | (1<<j)] = min(dp[i | (1<<j)], dp[i]+c);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3352
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read::<String>()
        .chars()
        .map(|x| x.to_digit(10).unwrap() as usize)
        .collect::<Vec<_>>();
    let mut poses = vec![vec![]; 10];
    for i in 0..n {
        poses[v[i]].push(i);
    }

    let mut ans = 0;
    for number in 0..1000 {
        let s = format!("{0: >03}", number);
        let s = s.chars()
            .map(|x| x.to_digit(10).unwrap() as usize)
            .collect::<Vec<_>>();
        if poses[s[0]].is_empty() {
            continue;
        }
        let mut cur = poses[s[0]][0];
        let idx = poses[s[1]].lower_bound(&(cur + 1));
        if idx == poses[s[1]].len() {
            continue;
        }
        cur = poses[s[1]][idx];
        let idx = poses[s[2]].lower_bound(&(cur + 1));
        if idx == poses[s[2]].len() {
            continue;
        }
        ans += 1;
    }
    println!("{}", ans);
}

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

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

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    ll n,m;cin>>n>>m;
    ll s[n];rep(i,0,n)cin>>s[i];
    ll t[m];rep(i,0,m)cin>>t[i];
    ll dp[n+1][m+1];
    ll cnt[100001];
    fill(cnt,cnt+100001,0);
    rep(i,0,n+1){
        rep(j,0,m+1)dp[i][j]=0;
    }
   // nckinit(2001);
    //ll summ[2001][2001];
    //rep(i,0,2001)summ[i][0]=1;
    //rep(i,1,2001){
       // rep(j,1,i+1){
          //  summ[i][j]=summ[i][j-1]+nck(i,j);
           // summ[i][j]%=mod;
       // }
   // }
    rep(i,1,n+1){
        
        rep(j,1,m+1){
            
            
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+mod)%mod;
            if(s[i-1]==t[j-1])dp[i][j]+=dp[i-1][j-1]+1;
            dp[i][j]%=mod;
        }
    }
    cout<<(dp[n][m]+1)%mod<<endl;
    rep(i,0,n+1){
        //rep(j,0,m+1)cout<<dp[i][j]<<" ";
        //cout<<endl;
    }
}


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

using namespace std;

int main() {
    int i;
    string s;
    cin >> s;
    int n = s.length();
    bool a = false, z = false;
    int n_a, n_z;

    for (i = 0; i < n; i++) {
        if (a == false && s[i] == 'A') {
            n_a = i;
            a = true;
        }
        if (z == false && s[n-1-i] == 'Z') {
            n_z = n-i-1;
            z = true;
        }
    }
    cout << n_z - n_a + 1;
    return 0;
}

Measured memory_bytes: 832
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<vector<int>> scores(n,vector<int>(3));
  for(int i=0;i<n;i++){
      cin>>scores[i][0]>>scores[i][1]>>scores[i][2];
  }
  vector<vector<int>> dp(n,vector<int>(3));
  for(int i=0;i<3;i++){
      dp[0][i]=scores[0][i];
  }
  for(int i=1;i<n;i++){
      dp[i][0]=max(dp[i-1][1],dp[i-1][2])+scores[i][0];
      dp[i][1]=max(dp[i-1][0],dp[i-1][2])+scores[i][1];
      dp[i][2]=max(dp[i-1][1],dp[i-1][0])+scores[i][2];
  }
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 11136