akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    int n, k, sm = 0;
    cin >> n >> k;

    vector<int> arr(n);

    for(int i = 0; i < n; i++){
        cin >> arr[i];
        sm += arr[i];
    }

    vector<int> fct;
    for(int i = 1; i <= sqrt(sm); i++)
        if( sm%i == 0 ){
            fct.push_back(i);
            fct.push_back(sm/i);
        }

    int ans = 1, tot, used;
    for(int f : fct){
        tot = 0;
        vector<int> tmp;
        for(int i = 0; i < n; i++){
            tmp.push_back(arr[i]%f);
            tot += (f - arr[i]%f);
        }
        sort(tmp.begin(), tmp.end());
        used = 0;
        for(int i = 0; i < tmp.size(); i++){
            used += tmp[i];
            tot -= (f - tmp[i]);
            if( used == tot && used <= k ){
                ans = max(ans, f);
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,i,b,k,d;
    float sum=0.0;
    int c[100];
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&c[i]);
    }
    for(i=0;i<a-1;i++)
    {
       for(b=i+1;b<a;b++)
       {
       if(c[i]>c[b])
       {
           k=c[i];
           c[i]=c[b];
           c[b]=k;
       }
       }
    }
    if(a==2)
    sum=(c[0]+c[1])/2.0;
    else
    {
        sum=(c[0]+c[1])/2.0;
        for(i=2;i<a;i++)
        sum=(sum+c[i])/2.0;
    }
    printf("%f",sum);
    return 0;
}
    

    


Measured memory_bytes: 128
/******************************************
* AUTHOR : SHUBHAM KUMAR *
* NICK : { "CODECHEF" : "SCHELEON",
		   "CODEFORCES" : "SCH3130N" } * 	
* INSTITUTION : BIT MESRA *
******************************************/

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define ll long long int
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end())  

ll ModE(ll x, unsigned ll y, ll p = MOD) 
{ 
    ll res = 1;
    x = x % p;    
    while (y > 0) 
    {   if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

using namespace std;

ll dp[100][large],a[large][3];
ll n;
ll v[100],w[100];
ll solve(ll i, ll weight){
	if(i<0)
		return 0;
	if(dp[i][weight] != -1)
		return dp[i][weight];

	if(weight-w[i]>=0)
		dp[i][weight] = max(v[i]+solve(i-1, weight-w[i]), solve(i-1, weight));
	else
		dp[i][weight] = solve(i-1, weight);
	return dp[i][weight];

	// if(weight-w[i]>=0)
	// 	return max(v[i]+solve(i-1, weight-w[i]), solve(i-1, weight));
	// else
	// 	return solve(i-1, weight);
	//return dp[i][weight];
}

int main() {
	//#ifndef _DEBUG
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
   // freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
	#endif

	fastio
	//ios_base& scientific (ios_base& str);

	//ll T; cin>>T; while(T--){}
	ll W;
	cin>>n>>W;
	rep0(i,n){
		cin>>w[i]>>v[i];
	}
	rep0(i,large)
		rep0(j,n)
			dp[j][i] = -1;
	
	// rep0(i,10){
	// 	rep0(j,10)
	// 		cout<<dp[i][j]<<" ";
	// 		cout<<endl;}
	//cout<<"hello"<<endl;
	cout<<solve(n-1, W);

	return 0;
}

Measured memory_bytes: 78720
#include <iostream>
#include<cmath>
using namespace std;
int isPrime(long long n) {
    if(n==1) return 0;
    long long i;
    for (i = 2; i * i <= n; ++i) {
        if (n % i == 0) return 0;
    }
    return 1;
}
int main()
{
    int q;
    cin>>q;
    int a[100001];
    int s1=0;
    for(int i=1;i<=100000;i++)
    {
        if(isPrime(i)&&isPrime((i+1)/2))
            s1++;
        a[i]=s1;
    }
    for(int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;
        cout<<(isPrime(l)&&isPrime((l+1)/2))+a[r]-a[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    int64_t count = 1;
    int32_t now = N;
    while (now != 0) {
        now += N;
        now %= 360;
        ++count;
    }
    out << count << endl;

    return 0;
}
#endif


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	int n;
	string s,s1;
	cin>>n>>s;
	s1=s;
	s1[0]='S';s1[1]='S';
	for(int i=1;i<n-1;i++)
	if(s1[i]=='S')
	{
		if(s[i]=='o')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	else
	{
		if(s[i]=='x')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	bool f=true;
	if(s1[n-1]=='S')
	{
		if(s[n-1]=='o'&&s1[n-2]!=s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]==s1[0])f=false;
	}
	else
	{
		if(s[n-1]=='o'&&s1[n-2]==s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]!=s1[0])f=false;
	}
	if(s1[0]=='S')
	{
		if(s[0]=='x'&&s1[n-1]==s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]!=s1[1])f=false;
	}
	else
	{
		if(s[0]=='x'&&s1[n-1]!=s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]==s1[1])f=false;
	}
	if(f)
	{
		cout<<s1<<endl;
		return 0;
	}
	s1[0]='S';s1[1]='W';
	for(int i=1;i<n-1;i++)
	if(s1[i]=='S')
	{
		if(s[i]=='o')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	else
	{
		if(s[i]=='x')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	f=true;
	if(s1[n-1]=='S')
	{
		if(s[n-1]=='o'&&s1[n-2]!=s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]==s1[0])f=false;
	}
	else
	{
		if(s[n-1]=='o'&&s1[n-2]==s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]!=s1[0])f=false;
	}
	if(s1[0]=='S')
	{
		if(s[0]=='x'&&s1[n-1]==s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]!=s1[1])f=false;
	}
	else
	{
		if(s[0]=='x'&&s1[n-1]!=s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]==s1[1])f=false;
	}
	if(f)
	{
		cout<<s1<<endl;
		return 0;
	}
	s1[0]='W';s1[1]='S';
	for(int i=1;i<n-1;i++)
	if(s1[i]=='S')
	{
		if(s[i]=='o')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	else
	{
		if(s[i]=='x')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	f=true;
	if(s1[n-1]=='S')
	{
		if(s[n-1]=='o'&&s1[n-2]!=s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]==s1[0])f=false;
	}
	else
	{
		if(s[n-1]=='o'&&s1[n-2]==s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]!=s1[0])f=false;
	}
	if(s1[0]=='S')
	{
		if(s[0]=='x'&&s1[n-1]==s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]!=s1[1])f=false;
	}
	else
	{
		if(s[0]=='x'&&s1[n-1]!=s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]==s1[1])f=false;
	}
	if(f)
	{
		cout<<s1<<endl;
		return 0;
	}
	s1[0]='W';s1[1]='W';
	for(int i=1;i<n-1;i++)
	if(s1[i]=='S')
	{
		if(s[i]=='o')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	else
	{
		if(s[i]=='x')s1[i+1]=s1[i-1];else s1[i+1]='S'+'W'-s1[i-1];
	}
	f=true;
	if(s1[n-1]=='S')
	{
		if(s[n-1]=='o'&&s1[n-2]!=s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]==s1[0])f=false;
	}
	else
	{
		if(s[n-1]=='o'&&s1[n-2]==s1[0])f=false;
		if(s[n-1]=='x'&&s1[n-2]!=s1[0])f=false;
	}
	if(s1[0]=='S')
	{
		if(s[0]=='x'&&s1[n-1]==s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]!=s1[1])f=false;
	}
	else
	{
		if(s[0]=='x'&&s1[n-1]!=s1[1])f=false;
		if(s[0]=='o'&&s1[n-1]==s1[1])f=false;
	}
	if(f)
	{
		cout<<s1<<endl;
		return 0;
	}
	cout<<-1<<endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int x = n % 10;
  if(x == 2||x ==4||x == 5||x ==7||x ==9){
    cout << "hon" << endl;
  }
  else if(x ==0||x==1||x==6||x==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
}

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


int main() {
    ll N; cin >> N;
    vector<ll> A(N); for(ll i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans;
    if(N % 2 == 0){
        ll temp=0;
        for(int i = 0; i < N/2-1; i++) temp-=2*A[i];
        temp-=A[N/2-1];
        temp+=A[N/2];
        for(int i = N/2+1; i < N; i++)  temp += 2 * A[i];
        ans = temp;
    }
    else {
        ll temp = 0;
        for(int i = 0; i < N/2-1; i++) temp -= 2*A[i];
        for(int i = N/2+2; i < N; i++) temp += 2*A[i];
        ans = max( temp - 2*A[N/2-1] + A[N/2] + A[N/2+1], temp - A[N/2-1] - A[N/2] + 2*A[N/2+1] );


    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N=int(input())
now=0
T=list(map(int,input().split()))
for i in range(1,N):
    T[i]+=T[i-1]
T=[-1*float('inf'),0]+T+[float('inf')]
V=list(map(int,input().split()))
V=[0]+V+[0]
vt=[float('inf')]*(T[-2]+1)
for t in range(len(vt)):
    now=t
    for k in range(N+2):
        if now<T[k]:
            vt[t]=min(vt[t],V[k]+T[k]-now)
        elif T[k]<=now<=T[k+1]:
            vt[t]=min(vt[t],V[k])
        elif T[k+1]<now:
            vt[t]=min(vt[t],V[k]+now-T[k+1])
ans=0
for i in range(len(vt)-1):
    if abs(vt[i+1]-vt[i])==1:
        ans+=0.5*(vt[i]+vt[i+1])
    elif vt[i+1]==vt[i]:
        for k in range(N+2):
            if T[k]<=i and i+1<=T[k+1]:
                vv=V[k]
                break
        if vv>vt[i]:
            ans+=0.5*(vt[i]*2+0.5)
        else:
            ans+=vt[i]
print(ans)

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

int main(){
  int N,K;
  cin >> N >> K;
  
  int cnt = 0;
  vector<int> A(N);
  vector<int> B(200000,0);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(A.at(i)) ++;
    if(B.at(A.at(i)) == 1){
      cnt ++;
    }
  }
    
  sort(B.begin(),B.end(),greater<int>());
  int mi = 0;

  for(int i=0;i<K;i++){
    mi += B.at(i);
  }

  if(N-mi <= 0){
    cout << 0 << "\n";
  }else{
    cout << N-mi << "\n";
  }  
}
    
  

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e4+5;
 
int main()
{
    int n,ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < s.size()-2;++i){
    	if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
    		ans++;
    		i += 2;
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class Test{
  public static void Main(){ 
    var NXY =  Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    var N = NXY[0];
    var X = NXY[1];
    var Y = NXY[2];
    int[] count = new int[N];
    for(int i =1; i<N; i++){
      for(int j =i+1; j<=N; j++){
        int a = j-i;
        int b = Math.Abs(X-i)+1+Math.Abs(Y-j);
        int len = Math.Min(a,b);
        count[len]++;
      }
    }
    for(int x=1;x<N;x++){
      Console.WriteLine(count[x]);
    }
  }
}

Measured memory_bytes: 13268
x = list(input())
y = list(input())
for a in range(len(y)):
    x.append(x[a])

i = 0
j = 0
while True :
    if y[j] == x[i]:
        j += 1
        if j == len(y):
            print("Yes")
            break
        i += 1
        if i == len(x):
            print("No")
            break
    else :
        i += (1 - j)
        if i == len(x):
            print("No")
            break
        j = 0


Measured memory_bytes: 5560
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long double ld;
typedef pair<ld,ld> P;
int n;
P p[50];

bool equal(ld a,ld b){
  return a-(1e-5)<=b&&b<=a+(1e-5);
}

ld getdis(P a,P b){
  return (a.f-b.f)*(a.f-b.f)+(a.s-b.s)*(a.s-b.s);
}

P cal(){
  ld a=0,cx=0,cy=0;
  for (int i=n,u=0;i-->0;u=i) {
    ld k=p[i].f*p[u].s-p[u].f*p[i].s;
    a+=k;
    cx+=k*(p[u].f+p[i].f);
    cy+=k*(p[u].s+p[i].s);
  }
  cx/=3*a;
  cy/=3*a;
  return P(cx,cy);
}

int main(){
  bool an=1;
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i].f>>p[i].s;
  P a=cal();
  for(int i=0;i<n/2;i++){
    if(!equal(getdis(a,p[i]),getdis(a,p[n/2+i])))an=0;
  }
  double x=a.f,y=a.s;
  if(!an||n%2)cout<<"NA"<<endl;
  else printf("%.8f %.8f\n",x,y);
  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define R double

//メモリ注意
const int max_n=50;
ll c[max_n+1][max_n+1];

void comb_table(int n){
  for(int i=0;i<=n;++i){
    for(int j=0;j<=i;++j){
      if(j==0 || j==i){
        c[i][j]=1LL;
      }else{
        c[i][j]=(c[i-1][j-1]+c[i-1][j]);
      }
    }
  }
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  
  ll v[max_n];

  for(int i=0;i<n;++i){
    cin>>v[i];
  }

  comb_table(n);
  sort(v,v+n);
  reverse(v,v+n);

  R max_average=0.0;
  for(int i=0;i<a;++i){
    max_average+=v[i];
  }
  max_average/=a;

  int all_num_va=0,unt_a_num_va=0;
  for(int i=0;i<n;++i){
    if(v[i]==v[a-1]){
      ++all_num_va;
      if(i<a){
        ++unt_a_num_va;
      }
    }
  }
  ll sec_ans=0LL;
  if(unt_a_num_va==a){
    for(ll i=a;i<=b;++i){
      sec_ans+=c[all_num_va][i];
    }
  }else{
    sec_ans=c[all_num_va][unt_a_num_va];
  }

  cout.precision(20);
  cout<<fixed<<max_average<<endl;
  cout<<sec_ans<<endl;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int h, w; cin >> h >> w;
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<vector<int>> s(h, vector<int> (w));
    int pos = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < a[i]; j++) {
            s[pos / w][pos % w] = i + 1;
            pos++;
        }
    }

    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) cout << s[i][j] << " \n"[j == w - 1];
        } else {
            for (int j = w - 1; j >= 0; j--) cout << s[i][j] << " \n"[j == 0];
        }
    }
    return 0;
}


Measured memory_bytes: 384
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Measured memory_bytes: 14244
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
using namespace std;

int main() {
  int a,b,c,d;
  int cnt = 0;
  cin >> a >> b ;
  c = b;
  while(c >= 1){
    c /= 10;
    cnt++;
  }
  int j = pow(10,cnt);
  d = a * j + b;
  int d2 = sqrt(d);
  if(sqrt(d) == d2)
    cout << "Yes" << '\n';
  if(sqrt(d) != d2)
    cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 384
def num_2n(i):
    count = 0
    while(i % 2 == 0):
        i = i / 2
        count += 1
    return count


def main():
    num_a = int(input())
    num_b = int(input())
    num_c = int(input())
    num_x = int(input())
    count = 0
    for in_a in range(num_a + 1):
        for in_b in range(num_b + 1):
            for in_c in range(num_c + 1):
                if num_x == in_a * 500 + in_b * 100 + in_c * 50: count += 1 
    print(count)

    
    


if __name__ == '__main__':
    main()


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

int main(){
    long long n,k;
    cin>>n>>k;
    long long tmpmin=0,tmpmax=0;
    long long sum=1;
    for(long long i=k;i<=n;i++){
        tmpmin=0,tmpmax=0;
        tmpmin=(i*(i-1))/2;
        tmpmax=(i*(2*n-i+1))/2;
        
        sum=(sum+(tmpmax-tmpmin+1))%1000000007;
        //cout<<"max="<<tmpmax<<"\n";
        //cout<<"min="<<tmpmin<<"\n";
        //cout<<sum<<"\n";
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

"""Disjoint Set"""

import sys
import os
import pprint


class Node:
    def __init__(self, key):
        self.parent = self
        self.key = key
        self.rank = 0  # ???????????????????????¨????????¨????????¨?????????

    def get_root(self):
        """
        :rtype: Node
        :return:
        """
        n = self
        while n.parent is not n:
            n = n.parent
        return n


# ????????????????????????
def unite(x, y):
    node_x = nodes[x]
    node_y = nodes[y]

    root_x = node_x.get_root()
    root_y = node_y.get_root()

    if root_x.rank > root_y.rank:
        # root x???????????????
        root_y.parent = root_x
    elif node_x.rank == node_y.rank:
        # root x???????????????
        root_y.parent = root_x
        # root x?????????????????´
        root_x.rank += 1
    else:
        # node y?????????????????????
        root_x.parent = root_y

# ??£??¨??????????????????
def find_set(x):
    node = nodes[x]
    return node.get_root().key


#fd = os.open('DSL_1_A.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

lis = list(map(int, input().split()))
n = lis[0]
q = lis[1]

nodes = []
for i in range(n):
    nodes.append(Node(i))

for _ in range(q):
    com, x, y = list(map(int, input().split()))
    if com == 0:
        # unite
        unite(x, y)
    else:
        # same
        id0 = find_set(x)
        id1 = find_set(y)
        if id0 == id1:
            print(1)
        else:
            print(0)



def node_test():
    node0 = Node(0)
    node1 = Node(1)
    node1.parent = node0
    node2 = Node(2)
    node2.parent = node1
    n = node2.get_root()
    print(n.key)
    print(node2.key)

if __name__ == '__main__':
    #node_test()
    pass

Measured memory_bytes: 10292
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

struct UnionFind
{
  vector<i64> data;
  UnionFind(i64 size) : data(size, -1) {}
  bool merge(i64 x, i64 y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool check(i64 x, i64 y)
  {
    return root(x) == root(y);
  }
  i64 root(i64 x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  i64 size(i64 x)
  {
    return -data[root(x)];
  }
};

int main()
{
  i64 N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for (i64 i = 0; i < M; i++)
  {
    i64 A, B;
    cin >> A >> B;
    uf.merge(A - 1, B - 1);
  }
  i64 ans = 1;
  for (i64 i = 0; i < N; i++)
    ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vvl ans(n-1);
    range(i,1,n+1)range(j,i+1,n+1){
        rep(k,10){
            if((((i^j)>>k)&1)==0)continue;
            ans[i-1].push_back(k+1);
            break;
        }
    }
    rep(i,n-1)puta(ans[i]);
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
#import heapq
#from fractions import gcd
#from collections import defaultdict
#sys.setrecursionlimit(10**9)
#map(int,input().split())

def main():
    h,w=map(int,input().split())
    A=[]
    ans=[]
    n=0
    for i in range(h):
        a=list(map(int,input().split()))
        if i%2==0:
            for j in range(w):
                A.append([i+1,j+1,a[j]])
        else:
            for j in reversed(range(w)):
                A.append([i+1,j+1,a[j]])
    for i in range(h*w-1):
        if A[i][2]%2==1:
            ans.append([A[i][0],A[i][1],A[i+1][0],A[i+1][1]])
            A[i+1][2]+=1
            n+=1
    print(n)
    for l in ans:
        print(*l)

if __name__ == '__main__':
    main()

Measured memory_bytes: 53688
typedef long long ll;

#include <numeric>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(const int n = getInt()){
    int s = 0;
    REP(i,n) s += getInt();

    vector<int> joint(n - 1);

    REP(i,n - 1) joint[i] = getInt();
    sort(joint.begin(), joint.end());

    ll jsum = accumulate(joint.begin(), joint.end(), 0);
    ll ans = 0;
    REP(i,n){
      ans = max(ans, (jsum + s) * (i + 1));
      if(i != n - 1) jsum -= joint[i];
    }

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

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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<x<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx==ry;
    }
    int size(int x){
        return root(x);
    }
};

int i, j, k;
int main()
{
	int n,m;
	cin >> n >> m;
	int count = 0;
	pii p[m];
	rep(i, m) {
		int x,y;
		cin >> x >> y;
		p[i] = make_pair(x,y);
	}
	rep(i, m) {
		UnionFind uf(n + 1);
		rep(j, m) {
			if (i != j) {
				uf.unite(p[j].first, p[j].second);
			}
		}
		if (!uf.same(p[i].first, p[i].second)) count++;
	}
	print(count);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 400005
#define maxm 400005
#define maxb
#define maxr 200000
#define maxs
#define M 
#define pii pair<int, int>
#define pdd pair<double, double>
#define uint unsigned int
#define ull unsigned long long int
#define ll long long int 
#define lowbit(x) x & -x
#define fi first
#define se second
#define pb push_back
#define next NEXT
#define hash HASH
#define ls ch[x][0]
#define rs ch[x][1]
#define pi 3.141592653589793
#define ei 2.718281828459045
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
#define END return 0
//#define ONLINE_JUDGE
//#define DEBUG
using namespace std;

char *p1, *p2, buffer[maxr];
template <class T> void read(T& x){
    char ch = gc(); x = 0; bool f = 1;
    while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
    if (ch == '-') f = 0, ch = gc();
    while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = gc();
    x = f ? x : -x;
}
int n;
pii out[maxn];
int ct = 0;
int main(){
    read(n);
    if (n <= 2) {printf("No"); END;}
    int s = -1, __n = n;
    while (n) n >>= 1, s++; n = __n;
    if (n == (1 << s)) {printf("No"); END;}
    printf("Yes\n");
    out[++ct] = pii(1, 2);
    out[++ct] = pii(2, 3);
    out[++ct] = pii(3, n + 1);
    out[++ct] = pii(n + 1, n + 2);
    out[++ct] = pii(n + 2, n + 3);
    if (n & 1){
        for (register int i = 4; i <= n - 1; i += 2){
            out[++ct] = pii(i, i + 1);
            out[++ct] = pii(n + i, n + i + 1);
            out[++ct] = pii(i, 1);
            out[++ct] = pii(n + i + 1, n + 1);
        }
    }
    else {
        for (register int i = 4; i <= n - 1; i += 2){
            out[++ct] = pii(i, i + 1);
            out[++ct] = pii(n + i, n + i + 1);
            out[++ct] = pii(i, 1);
            out[++ct] = pii(n + i + 1, n + 1);
        }
        int s = 0, _n = n;
        while (n) n >>= 1, s++; s--;
        n = _n;
        if (n - (1 << s) == 2){
            out[++ct] = pii(n, n + 2); n ^= 3;
            out[++ct] = pii((_n << 1), n + _n);
        }
        else {
            out[++ct] = pii((1 << s), n); n ^= (1 << s); n ^= 1;
            out[++ct] = pii((_n << 1), n + _n);
        }
        
    }
    rep(i, 1, ct) printf("%d %d\n", out[i].fi, out[i].se);
    return 0;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
    ll N, M, K;
    cin >> N >> M >> K;

    vector<ll> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];

    vector<ll> wa_a(N+1), wa_b(M+1);
    wa_a[0] = 0; wa_b[0] = 0;
    for(int i=1; i<=N; i++) wa_a[i] = wa_a[i-1] + A[i-1];
    for(int i=1; i<=M; i++) wa_b[i] = wa_b[i-1] + B[i-1];
    wa_a.push_back(3e16);
    wa_b.push_back(3e16);
    // cout << "  wa_a:  "; print_vec(wa_a);
    // cout << "  wa_b:  "; print_vec(wa_b);

    ll ans = 0;
    ll num_a = N;// Aから読む冊数
    for(int num_b=0; num_b<=M; num_b++){
      if(wa_b[num_b] > K) break;
      while(wa_a[num_a] + wa_b[num_b] > K){
        num_a--;
      }

      ans = max(ans, num_a + num_b);
    }

    cout << ans << endl;


}


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

#include <string.h>

#define MIN       (1)
#define MAX       (100)
#define INFTY (0x7FFFFFFF)

typedef enum
{
    ERROR  =-1,
    SUCCESS= 0
} ResultType;

static ResultType checkRangeOfNum(int, int, int);
static int getMinimumOfScalarMultiplication(int);

int R[MAX + 1];      // row and column table R[x], as follows;
                     // R[0]=row    of 1st Matrix "M1" (x=0)
                     // R[1]=column of 1st Matrix "M1" (x=1)
                     // R[2]=column of 2nd Matrix "M2" (x=2)
                     // R[3]=column of 3rd Matrix "M3" (x=3)
                     // ...

int C[MAX][MAX + 1]; // cost table C[i][i+j], which means 
                     // minimum of scalar multiplication (Mi * Mi+1 * ... Mi+j)
                     // (where i>=1, j>=1)
int main(void)
{

int x, y;
int N;

    ResultType eResult;

    /* input line 1 */
    scanf("%d",&N);
    eResult = checkRangeOfNum(N, MIN, MAX);
    if(eResult < SUCCESS)
    {
        printf("Err: %d is out of range.", N);
        return eResult;
    }

    /* input line 2 */
    for(x=0; x<=1; x++)
    {
        scanf("%d",&R[x]);
        eResult = checkRangeOfNum(R[x], MIN, MAX);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", R[x]);
            return eResult;
        }
    }

    /* input line from 3 to (N + 1) */
    for(y=2; y<N*2; y++)
    {
        x = (y+1)/2;
        scanf("%d",&R[x]);
        eResult = checkRangeOfNum(R[x], MIN, MAX);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", R[x]);
            return eResult;
        }
    }

    /* print minimum of scalar multiplication */
    printf("%d\n", getMinimumOfScalarMultiplication(N));

    return SUCCESS;
}

static ResultType checkRangeOfNum(int n, int nMin, int nMax)
{
    if((n < nMin) || (nMax < n))
    {
        return ERROR;
    }
    return SUCCESS;
}

static int getMinimumOfScalarMultiplication(int n)
{
    int i, j, k;
    int cost;
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++)
        {
            C[i][j] = INFTY;
        }
    }
    
    for(i = 1; i <= n; i++)
    {
        C[i][i] = 0;
    }
    
    for(j = 1; j <= n - 1; j++)
    {
        for (i = 1; i <= n - j; i++)
        {
            for (k = i + 1; k <= i + j; k++)
            {
                // C[i][i+j] = min( C[i][i+j], 
                //                  C[i][k-1] + C[k][i+j] + R[i-1]*R[k-1]*R[i+j] );
                cost = C[i][k-1] + C[k][i+j] + R[i-1]*R[k-1]*R[i+j];
                if (cost < C[i][i+j])
                {
                    C[i][i+j] = cost;
                }
                
            }
        }
    }
    return C[1][n];
}



Measured memory_bytes: 2100
s=input()
if(s=='SUN'):
  print(7)
if(s=='SAT'):
  print(1)
if(s=='FRI'):
  print(2)
if(s=='THU'):
  print(3)
if(s=='WED'):
  print(4)
if(s=='TUE'):
  print(5)
if(s=='MON'):
  print(6)


Measured memory_bytes: 3060
/**
 *      ABC 70 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-06 10:59:19
**/

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

unsigned long long gcd(unsigned long long x, unsigned long long y){
	if (x % y == 0){
		return y;
    }
	else {
		return gcd(y ,x % y);
    }
}

unsigned long long lcm(unsigned long long x, unsigned long long y){
    return x / gcd(x, y) * y;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    long long T[N + 10] = {};
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    unsigned long long x = 1;
    for (int i = 0; i < N; ++i) {
        x = lcm(T[i], x);
    }
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        int a = sc.Int;
        int b = sc.Int;

        Console.WriteLine((a + b) % 24);
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Console.ReadLine().Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
ll X;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>X;
    
    ll l=0ll,r=1e5;
    while(r-l>1){
        ll m=(l+r)/2; //r=l+1の時m=l
        if(m*(m+1)>2*X)r=m;
        else l=m;
    }
    
    if(l*(l+1)==2*X)cout<<l<<"\n";
    else cout<<r<<"\n";
    
    return 0;
}

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

typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define all(a) begin(a), end(a)
#define watch(x) cerr << (#x) << " is " << (x) << '\n';

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

    int n, m;
    cin >> n >> m;

    multiset<int> S;

    FOR(i, 1, n) {
        int x;
        cin >> x;
        S.insert(x);
    }

    FOR(i, 1, m) {
        int x = *(prev(S.end()));
        // watch(x);
        S.erase(prev(S.end()));
        S.insert(x / 2);
    }

    ll res = 0;

    while (!S.empty()) {
        res += *(prev(S.end()));
        S.erase(prev(S.end()));
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using i64 = long long;

i64 abs(i64 a) { return a < 0 ? -a : a; }

int main() {
    int n, neg = 0;
    std::cin >> n;
    i64 sum = 0, min = std::numeric_limits<i64>::max();
    for (int i = 0; i < n; i++) {
        i64 in;
        std::cin >> in;
        if (in < 0) neg++;
        sum += abs(in);
        min = std::min(min, abs(in));
    }
    if (neg % 2) sum -= min * 2;
    std::cout << sum << std::endl;

    return 0;
}


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

int main(void)
{
  int N,a[110];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> a[i];
  }

  sort(a,a+N);
  reverse(a,a+N);
  int count=1;
  for(int i=0; i<N-1; i++){
    if(a[i] != a[i+1]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    private static void chmin<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == 1 ? val : num;
    private static void chmax<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == -1 ? val : num;
    static void Main(string[] args)
    {
        var pr = new Program();
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        pr.Solve();
        Console.Out.Flush();
    }
    void Solve()
    {
        var str = ReadLine();var c = str.IndexOf('C');
        if (str[0] != 'A' || (2 > c || c > str.Length - 2)) { WriteLine("WA");return; }
        var ct = 0;
        for (var i = 0; i < str.Length; i++)
            if (str[i] != str.ToLower()[i]) ct++;
        WriteLine(ct != 2 ? "WA" : "AC");
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll l, r, minN = INF;
	cin >> l >> r;
	r = min(r,l+2019*2);
	for (ll i = l; i <= r; i++) {
		for (ll k = i + 1; k <= r; k++) {
			ll x = (i * k) % 2019;
			minN = min(minN,x);
		}
	}
	cout << minN << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll find(ll x, ll par[])
{
    if(x == par[x])
        return x;
    return par[x] = find(par[x], par);
}
 
void unio(ll x, ll y, ll par[], ll rank[], ll siz[])
{
    x = find(x,par);
    y = find(y,par);
    if(x == y)
        return;
    if(rank[x]>rank[y])
    {
        siz[x]+=siz[y];
        rank[x] = max(rank[x], rank[y] + 1);
        par[y] = x;
    }
    
    else
    {
        siz[y]+=siz[x];
        rank[y] = max(rank[y], rank[x] + 1);
        par[x] = y;
    }
}

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll m;
   cin>>m;
   
   ll par[n], rank[n], siz[n];
   rep(n)
       par[i] = i, rank[i] = 0, siz[i] = 1;
   
   rep(m)
   {
       ll a,b;
       cin>>a>>b;
       
       a--,b--;
       unio(a,b,par,rank,siz);
   }
   ll ans = 0;
   rep(n)
        ans = max(ans, siz[find(i,par)]);
   
   cout<<ans;
   
   return 0;        
}  

  
          
   

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

int main(){
    int n, sum = 0;
    int d[52];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    for(int i = 0; i < n-1; i++){
        for(int j = i + 1; j < n; j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
from itertools import chain
n=int(input())
c=list(range(1,1+2*n))
for _ in[0]*int(input()):
    k=int(input())
    c=c[k:]+c[:k]if k else list(chain.from_iterable(x for x in zip(c[:n],c[n:])))
for x in c:print(x)


Measured memory_bytes: 5680
n = int(input())

a = 0
b = 0

for _ in range(n):
    word_a, word_b = input().split()

    words = [word_a, word_b]
    words.sort()

    if word_a == word_b:
        a += 1
        b += 1
    elif words.index(word_a) == 1:
        a += 3
    else:
        b += 3

print(a, b)

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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	SORT(a);
	rep(i,n-1){
		if(a[i] == a[i+1]){
			 cout <<"NO"<<endl;
			 return 0;
		}
	}
	cout <<"YES"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long

using namespace std;

int main()
{
	string inp;
	cin >> inp;
	if (inp == "Sunny")
	{
		cout << "Cloudy";
	}
	
	if (inp == "Rainy")
	{
		cout << "Sunny";
	}
	
	if (inp == "Cloudy")
	{
		cout << "Rainy";
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;



int main(){
	
	
	bool f[100]={};
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0,y=0;;

	while(1){
		if(f[y]){cout<<"-1"<<endl;break;}
		int x=y%60;
		f[y]++;
		if(c>=y&&c<=y+a){
			ans+=(c-y);
			cout<<ans<<endl;
			break;
		}
		else if(c<y&&(y+a)%60>=c&&y+a>=60){
			ans+=60-y+c;
			cout<<ans<<endl;
			
			break;
		}
		else {y+=a+b;
		ans+=a+b;
		y%=60;
		//cout<<y;
		}


	}
	

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

int main() {

	int n;
	cin >> n;
	int x, y, z;
	cin >> x;
	vector<int>a(x);
	rep(i, x) cin >> a[i];
	cin >> y;
	vector<int>b(y);
	rep(i, y) cin >> b[i];
	cin >> z;
	vector<int>c(z);
	rep(i, z) cin >> c[i];

	vector<vector<bool>>user(n, vector<bool>(3, false));

	rep(i, x) {
		user[a[i] - 1][0] = true;
	}
	rep(i, y) {
		user[b[i] - 1][1] = true;
 	}
	rep(i, z) {
		user[c[i] - 1][2] = true;
	}

	vector<bool> ok(n, false);
	rep(i, n) {
		if ((!user[i][0] && user[i][2]) || (user[i][1] && user[i][2]))
			ok[i] = true;
	}

	int ans = 0;
	rep(i, n) {
		if (ok[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
    long ans;
    
    if((a-b)%2==0){//端以外で合流できる場合
      ans = (b-a)/2;
    }else{
      ans = Math.min(a-1,n-b)+1;
      ans += (b-a-1)/2;
    }
    
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back


void solve()
{
	ll N,inp;
	cin>>N;

	vector<ll>V;

	for(ll i = 0;i<N;i++)
	{
		cin>>inp;
		V.pb(inp);
	}

	if(N == 2)
		cout<<*max_element(V.begin(),V.end());
	
	else
	{
		sort(V.begin(),V.end());

		// for(int i = 0;i<V.size();i++)
		// 	cout<<V[i]<<" ";
		// cout<<endl;

		ll sum = V.back();

		//cout<<sum<<endl;

		V.pop_back();

		ll index = 0;

		sort(V.begin(),V.end(),greater<ll>());

		// for(int i = 0;i<V.size();i++)
		// 	cout<<V[i]<<" ";
		// cout<<endl;

		N = N - 2;

		if(N % 2 == 0)
		{
			ll index = 0;
			
			ll t = N/2;

			//cout<<t<<endl;

			ll cnt = 0;

			while(cnt < t)
			{
				//cout<<V[index]<<endl;
				sum = sum + (V[index]*2);
				//cout<<sum<<endl;
				index++;
				cnt++;
			}
		}

		else
		{
			ll index = 0;
			
			ll t = N/2;

			ll cnt = 0;

			while(cnt < t)
			{
				sum = sum + (V[index]*2);
				index++;
				cnt++;
			}

			sum = sum + V[index];
		}

		cout<<sum<<endl;
	}


}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
} 

Measured memory_bytes: 5300
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e16;

ll n, m;
ll dp[3000][3000][3];
ll a[3000][3000];
ll recur(ll i , ll j, ll rem) {
	if (rem < 0 || i < 0 || j < 0) {
		return 0;
	}
	if (dp[i][j][rem] == -1) {
		if (a[i][j] > 0) {
			dp[i][j][rem] = max(dp[i][j][rem], a[i][j] + recur(i - 1, j, 2));
			dp[i][j][rem] = max(dp[i][j][rem], a[i][j] + recur(i, j - 1, rem - 1));

		}
		dp[i][j][rem] = max(dp[i][j][rem], recur(i - 1, j, 2));
		dp[i][j][rem] = max(dp[i][j][rem], recur(i, j - 1, rem));

	}
	return dp[i][j][rem];
}

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,   N;
	cin >> n >> m >> k;
	mset(a, 0);
	mset(dp, -1);
	rep(i, k) {
		cin >> x >> y >> z;
		a[x - 1][y - 1] = z;
	}
	cout << recur(n - 1, m - 1, 2);


	return 0;
}

Measured memory_bytes: 285420
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


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

  string s;

  cin >> s;

  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }


  return 0;
}


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

int main(){
  int A;
  cin>>A;
  vector<int> B(A);
  for(int i=0;i<A;i++)
    cin>>B.at(i);
  int C,D,E,F,count;
  count=0;
    cin>>C;
  for(int i=0;i<C;i++){
     cin>>D>>E;
     F=B.at(D-1);
     B.at(D-1)=E;
    for(int j=0;j<A;j++){
     count+=B.at(j);
    }
    cout<<count<<endl;
    count=0;
    B.at(D-1)=F;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char S[4];
  char T[4];
  
  scanf("%s", S);
  scanf("%s", T);
  
  int count = 0;
  for(int i=0; i<3; i++)
  {
    if (S[i] == T[i]) count++;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128