akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let r: i32 = itr.next().unwrap().parse().unwrap();
    let s: i32 = itr.next().unwrap().parse().unwrap();
    let p: i32 = itr.next().unwrap().parse().unwrap();
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let t: String = itr.next().unwrap().parse().unwrap();
    let mut t2 = t.chars();

    let mut vec = vec!['\0'; k];
    let mut res = 0;
    for i in 0..n {
        let index = i % k;
        let aitenote = t2.next().unwrap();
        if vec[index] == aitenote {
            vec[index] = '\0';
        } else {
            match aitenote {
                'r' => { res += p; vec[index] = 'r'; }
                's' => { res += r; vec[index] = 's'; }
                'p' => { res += s; vec[index] = 'p'; }
                _ => { /* unreachable code */ }
            }
        }
    }


    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let ans = format!("{}", res);
    writeln!(out, "{}", ans).unwrap();
}

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

int x,y,cn,k,dx[4]={1,0,-1,0},dy[4]={0,-1,0,1},mp[9][9];

void cnt2(int cx,int cy) {
	int i;
	cn++;
	mp[cy][cx]=2;
	for (i=0;i<4;i++) if (mp[cy+dy[i]][cx+dx[i]]==0) cnt2(cx+dx[i],cy+dy[i]);
	}

void cnt() {
	int i,j;
	cn=0;
	for (i=1;i<=y;i++) for (j=1;j<=x;j++) if (mp[i][j]==0) {cn=0; cnt2(j,i); j=i=10;}
	for (i=1;i<=y;i++) for (j=1;j<=x;j++) if (mp[i][j]==2) mp[i][j]=0;
}	
	
	
	
int search(int sx,int sy,int bn) {
	int i,j,c;
	c=0;
	for (i=sy-1;i<=sy+1;i++) for (j=sx-1;j<=sx+1;j++) if (mp[i][j]!=0) c++;
	if (c>2) cnt();
	if (cn+bn!=x*y) return 0;
	for (i=0;i<4;i++) {
		 if (mp[sy+dy[i]][sx+dx[i]]==3 && bn==x*y) return 1;
		 if (mp[sy+dy[i]][sx+dx[i]]==0) {
			 mp[sy+dy[i]][sx+dx[i]]=1;
			 if (search(sx+dx[i],sy+dy[i],bn+1)==1) return 1;
			 mp[sy+dy[i]][sx+dx[i]]=0;
	 }
 }
	 return 0;
 }

int main() {
	int i,j,sx,sy,bn,f;
	while(cin >> x >> y) {
		if (x+y==0) break;
		bn=0; sx=-1; k=0;  
		for (i=0;i<9;i++) for (j=0;j<9;j++) mp[i][j]=1;
		for (i=1;i<=y;i++) for (j=1;j<=x;j++) { 
			cin >> mp[i][j]; bn+=mp[i][j]; if (mp[i][j]==0 && sx==-1) { sx=j; sy=i;} } 
		mp[sy][sx]=3; f=0;
		if ((x*y-bn) % 2==1) f=0; else f=search(sx,sy,bn+1);
		if (f==0) cout << "No" << endl; else cout << "Yes" << endl;
		}
	return 0;
  }

Measured memory_bytes: 1152
inputs = open(0).readlines()
n, m, x = map(int, inputs[0].split())
CA = [list(map(int, x.split())) for x in inputs[1:]]
ans = 10**9
for i in range(2 ** n):
    cost = 0
    B = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            c, *A = CA[j]
            cost += c
            for k in range(m):
                B[k] += A[k]
    if all(b >= x for b in B):
        ans = min(ans, cost)
if ans == 10**9:
    ans = -1
print(ans)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(k>a+b){
    cout<<0<<" "<<0<<endl;
  }
  else{
    cout<<0<<" "<<a+b-k<<endl;
  }
}


Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;
import static java.util.Arrays.sort;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class Token implements Comparable<Token> {
		final int value, id;
		final boolean isB;
		boolean isBig;

		Token(int value, int id, boolean isB) {
			this.value = value;
			this.id = id;
			this.isB = isB;
		}

		public int compareTo(Token o) {
			return value - o.value;
		}
	}

	static void solve() throws Exception {
		int n = scanInt();
		Token a[] = new Token[n], b[] = new Token[n];
		Token tokens[] = new Token[2 * n];
		for (int i = 0; i < n; i++) {
			a[i] = tokens[i] = new Token(scanInt(), i, false);
			b[i] = tokens[i + n] = new Token(scanInt(), i, true);
		}
		sort(tokens);
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += tokens[i].value;
		}
		for (int i = n; i < 2 * n; i++) {
			tokens[i].isBig = true;
		}
		int c1 = 0, c2 = 0, c3 = 0;
		for (int i = 0; i < n; i++) {
			if (!a[i].isBig && b[i].isBig) {
				++c1;
			} else if (a[i].isBig && !b[i].isBig) {
				++c3;
			} else {
				++c2;
			}
		}
		if (c2 == 0 && c1 != 0 && c3 != 0) {
			if (tokens[n - 1].id != tokens[n].id ||
				(c1 == 1 && tokens[n].isB == tokens[n].isBig) ||
				(c3 == 1 && tokens[n].isB != tokens[n].isBig)) {
				sum += tokens[n].value - tokens[n - 1].value;
			} else {
				sum += min(tokens[n].value - tokens[n - 2].value,
					tokens[n + 1].value - tokens[n - 1].value);
			}
		}
		out.print(sum);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 50120
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
nums = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for d in data:
    nums[d[0] - 1][d[1] - 1][d[2] - 1] += d[3]
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' ' + str(nums[i][j][k]), end='')
        print('')
    if i != 3:
        print('#' * 20)

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

int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  int c;
  cin >> c;
  if (a - b > c) {
    cout << 0 << endl;
  }
  else {
    cout << c - a + b << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x;
int main()
{
	cin>>x;
	for(ll i=-120;i<=120;i++)
		for(ll j=-120;j<=120;j++)
			if(i*i*i*i*i-j*j*j*j*j==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, y;
    cin >> n >> y;
    int a, b, c;
    a = y / 10000;
    b = y / 5000;
    c = y / 1000;
    for (int i = 0 ; i <= n ; i++) for (int j = 0 ; j <= n - i ; j++) {
		if (i + j + (n - i - j) == n && i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
			cout << i << ' ' << j << ' ' << (n - i - j); 
			return 0;
		}
	}
	cout << "-1 -1 -1";
}

Measured memory_bytes: 3576
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

#include<vector>
namespace ProconLib{

    // Summation only
    template<typename Int>
    struct BIT{     
        private:
        int N;
        std::vector<Int> dat;
        public:
        BIT(int N):N(N),dat(N,0){}
        void add(int pos,Int x);
        Int sum(int r);
        Int sum(int l,int r);
    };

    template<typename Int>
    void BIT<Int>::add(int pos,Int x){
        pos++;
        while(pos<=N){
            dat[pos-1]+=x;
            pos+=pos&-pos;
        }
    }

    template<typename Int>
    Int BIT<Int>::sum(int r){
        Int res=0;
        while(r>0){
            res+=dat[r-1];
            r-=r&-r;
        }
        return res;
    }

    template<typename Int>
    Int BIT<Int>::sum(int l,int r){
        return sum(r)-sum(l);
    }
  
};
using namespace ProconLib;

struct Query{
    int l,r;
    int id;
};

int main(){
    int n,q;
    cin>>n>>q;
    
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>c[i],c[i]--;

    vector<vector<Query>> query(n);
    for(int i=0;i<q;i++){
        int l,r; cin>>l>>r;
        l--;
        query[l].push_back(Query{l,r,i});
    }

    BIT<int> bit(n+1);
    bit.add(n,n);
    vector<int> lst(n,n);

    vector<int> ans(q);

    for(int i=n-1;i>=0;i--){
        bit.add(lst[c[i]],-1);
        bit.add(i,1);
        lst[c[i]]=i;
        for(auto que:query[i]){
            ans[que.id] = bit.sum(que.l,que.r);
        }
    }

    for(int i=0;i<q;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 34148
cond1 a b c y = 10000 * a + 5000 * b + 1000 * c == y

main = do
  [n,y] <- map read . words <$> getLine
  let combinant = [ [a,b,(n-(b+a))] | a<-[0..n], b<-[0..n],  (n-(a+b) >= 0) && cond1 a b (n-(a+b)) y]
  putStrLn . unwords . map show $ if length combinant > 0 then combinant !! 0 else [-1, -1, -1]



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

int main() {
    ll N;
    cin >> N;

    vl A(N);
    vl E(1e6+5, 0);
    rep(i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    rep(i, N) {
        E[A[i]] = i+1;
    }

    int ans = 0;
    rep(i, N) {
        // cout << "i : " << i << "  A[i] : " << A[i] <<  endl;
        bool ok = true;
        if (i < N-1 && A[i] == A[i+1]) continue;
        if (i > 0 && A[i] == A[i-1]) continue;
        int max_j = floor(sqrt(A[i]));
        for (int j = 1; j <= min(max_j, 1000); ++j) {
            if (A[i] % j == 0) {
                // cout << "j : " << j << endl;
                // auto itr_1 = find(A.begin(), A.end(), j);
                // if (itr_1 != A.end() && itr_1 - A.begin() != i) {
                if (E[j] && E[j]-1 != i) {
                    ok = false;
                    break;
                }
                // auto itr_2 = find(A.begin(), A.end(), A[i]/j);
                // if (itr_2 != A.end() && itr_2 - A.begin() != i) {
                if (E[A[i]/j] && E[A[i]/j]-1 != i) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) {
            // cout << A[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12720
#include<bits/stdc++.h>
const int mod = 1e9 + 7;
const int maxn = 1010;
typedef long long ll;
inline ll pow(ll a,ll b,ll ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(ll x){ return pow(x,mod - 2); }
int h, w; ll k;
char ch[maxn][maxn];
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> h >> w >> k;
	for(int i = 0;i < h;++i) std::cin >> ch[i];
	int c1 = 0,c2 = 0,c3 = 0;
	for(int i = 0;i < h;++i) for(int j = 0;j < w;++j)
		c3 += ch[i][j] = ch[i][j] == '#';
	for(int i = 0;i < h;++i) c1 += ch[i][0] && ch[i][w - 1];
	for(int i = 0;i < w;++i) c2 += ch[0][i] && ch[h - 1][i];
	if(c1 && c2 || k <= 1) return puts("1"), 0;
	if(!c1 && !c2) return std::cout << pow(c3, k - 1) << '\n', 0;
	int v = pow(c3, k - 1), c4 = 0;
	for(int i = 0;i < h;++i) for(int j = 0;j < w;++j)
		c4 += ch[i][j] && ch[i + !!c2][j + !!c1];
	ll s = 0, dt = (c1 + c2) * inverse(c3) % mod, val = pow(c3, k - 2);
	s = (dt == 1 ? k - 1 : (pow(dt, k - 1) - 1) * inverse(dt - 1)) % mod;
	std::cout << (v + (mod - s) * c4 % mod * val) % mod << '\n';
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import numpy as np 
import math

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])


    return arr

a,b = list(map(int,input().split()))
x = gcd(a,b)
# print(gcd)
# print(factorization(gcd))
print(len(factorization(x))+1)


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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
            
        }
        
    }
}

ll f(int x, int y){
    ll res=1;
    bool quo[y+1];
    mem(quo,false);
    
    for(int i=0; i<y; i++){
        res *= x--;
        rep1(j,y){
            if(!quo[j] && res%j==0 ){
                quo[j] = true;
                res /= j;
            }
        }
    }
    return res;
}

int main() {
    int N, A, B;
    scnd3(N,A,B);
    
    vector<ll> nums;
    rep(i,N){
        ll x; cin>>x;
        nums.push_back(x);
    }
    
    sort(nums.begin(), nums.end());
    
    ll sum=0, tcnt=0, tgt = nums[N-A];
    rep(i,A) sum += nums[N-1-i];
    rep(i,N) if(nums[i]==tgt) tcnt++;
    
    comb_table(50);
    
    ll ans=0;
    if(nums[N-1]==tgt){
        for(int i=A; i<=B; i++){
            if(tcnt<i) break;
            ans += C[tcnt][i];
        }
    }else{
        int mcnt=0;
        rep(i,N) {
            if(nums[N-1-i]!=tgt) mcnt++;
            else break;
        }
        ans += C[tcnt][A-mcnt];
    }
    cout.precision(20);
    cout << fixed << 1.0*sum/A << endl;
    cout1(ans);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char s;
  cin >> s;
  if (isupper(s)) {
    cout << "A" << '\n';
  } else {
    cout << "a" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    int N, M; cin >> N >> M;
    vector<string> A(N), B(M);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    bool ans = false;
    for (int i = 0; i+M-1 < N; i++) {
      for (int j = 0; j+M-1 < N; j++) {
	int k;
	for (k = 0; k < M; k++) {
	  string s = A[i+k].substr(j, M);
	  if (s != B[k]) {
	    break;
	  }
	}

	if (k == M) {
	  ans = true;
	  break;
	}
      }
      
      if (ans == true) {
	break;
      }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	if(a.first!=b.first)return a.first>b.first;
	else {
        return a.second>b.second;
    }
}


int main(void){
    int n;
    cin>>n;
    vector<int>odd,even,v(n);
    vector<pair<int,int>>oddnum,evennum;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(i%2==0)even.push_back(v[i]);
        else odd.push_back(v[i]);
    }
    sort(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    int i=0;
    for(i=0;i<(int)even.size();){
        int j=i;
        while(true){
            if(i==(int)even.size()){
                pair<int,int> p=make_pair(i-j,even[j]);
                evennum.push_back(p);
                break;
            }
            if(even[j]==even[i])i++;
            else{
                pair<int,int> p=make_pair(i-j,even[j]);
                evennum.push_back(p);
                break;
            }
        }
    }
    for(i=0;i<(int)odd.size();){
        int j=i;
        while(true){
            if(i==(int)odd.size()){
                pair<int,int> p=make_pair(i-j,odd[j]);
                oddnum.push_back(p);
                break;
            }
            if(odd[j]==odd[i])i++;
            else{
                pair<int,int> p=make_pair(i-j,odd[j]);
                oddnum.push_back(p);
                break;
            }
        }
    }
    int ans=10000000;
    sort(oddnum.begin(),oddnum.end(),cmp);
    sort(evennum.begin(),evennum.end(),cmp);
    int v1=((int)oddnum.size()==1)?0:oddnum[1].second;
    int v2=((int)oddnum.size()==1)?0:oddnum[1].first;
    int u1=((int)evennum.size()==1)?0:evennum[1].second;
    int u2=((int)evennum.size()==1)?0:evennum[1].first;
    if(oddnum[0].second!=evennum[0].second)ans=n-oddnum[0].first-evennum[0].first;
    else{
        if(v1==v2){
            ans=min(ans,
            min(n/2-oddnum[0].first+n/2-u2,n/2-v2+n/2-evennum[0].first));
        }
        else{
            ans=min(ans,
            min(n/2-oddnum[0].first+n/2-u2,n/2-v2+n/2-evennum[0].first));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2168
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
    int H,A;
    cin >> H >> A;
  
    int count = 0;
    while(1){
        if(H > 0){
            H -= A;
            count++;
        }else{
            break;
        }

    }
  
    cout << count << endl;
 
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	static final int INF = -1;
	static char[][] maze;
	static int h;
	static int w;
	static int sx, sy;
	static int[][] d;
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};

	static int bfs() {
		if (maze[sx][sy] == '#') {
			return 0;
		}
		Deque<int[]> que = new ArrayDeque<>();

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				d[i][j] = INF;
			}
		}

		int[] pair = {sx, sy};
		que.add(pair);

		d[sx][sy] = 0;

		while (que.size() > 0) {
			int[] p = que.pop();

			for (int i = 0; i < 4; i++) {
				int nx = p[0] + dx[i];
				int ny = p[1] + dy[i];

				if (0 <= nx
					&& nx < h
					&& 0 <= ny
					&& ny < w
					&& maze[nx][ny] != '#'
					&& d[nx][ny] == INF) {
					int[] arr = {nx, ny};
					que.add(arr);
					d[nx][ny] = d[p[0]][p[1]] + 1;
				}
			}
		}

		int max = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
//				System.out.printf("%3d", d[i][j]);
				if (d[i][j] > max) {
					max = d[i][j];
				}
			}
//			System.out.println();
		}
		return max;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		maze = new char[h][w];
		d = new int[h][w];
		for (int i = 0; i < h; i++) {
			maze[i] = sc.next().toCharArray();
		}

		int max = 0;
		for (int i = 0; i < h; i++) {
			sx = i;
			for (int j = 0; j < w; j++) {
				sy = j;
				int dis = bfs();
				if (dis > max) {
					max = dis;
				}
			}
		}

		System.out.println(max);

		sc.close();
	}


}



Measured memory_bytes: 26404
N = int(input())
T, X, Y = ([] for i in range(3))
ans = True
T.append(0)
X.append(0)
Y.append(0)
for i in range(N):
  t, x, y = map(int, input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
for i in range(N):
  dt = T[i + 1] - T[i]
  dx = X[i + 1] - X[i]
  dy = Y[i + 1] - Y[i]
  if dt >= abs(dx) + abs(dy) and dt % 2 == (abs(dx) + abs(dy)) % 2:
    continue
  else:
    ans = False
    break
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 11736
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        long n = Long.parseLong(in[0]);
        long m = Long.parseLong(in[1]);
        long answer = (n < m / 2) ? ((m + n * 2) / 4) : (m / 2);
        System.out.println(answer);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<char> d;
int main()
{
    string s;  cin>>s;
    for(int i=0;i<s.length();i++)
        d.push_back(s[i]);
    int n;     cin>>n;
    bool flag=1;
    while(n--)
    {
        int t;  cin>>t;
        if(t==1)
        {
            flag=!flag;
        }
        else
        {
            int c; cin>>c;
            char s1;  cin>>s1;
            if(c==1)
            {
                if(flag)
                {
                    d.push_front(s1);
                    //s=s1+s;
                }
                else
                {
                    d.push_back(s1);
                    //s=s+s1;
                }
            }
            else
            {
                if(!flag)
                {
                    d.push_front(s1);
                    //s=s1+s;
                }
                else
                {
                    d.push_back(s1);
                    //s=s+s1;
                }
            }
        }
    }
    if(flag)
    {
        while(!d.empty())
        {
            cout<<d.front();
            d.pop_front();
        }
    }
    else
    {
        while(!d.empty())
        {
            cout<<d.back();
            d.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int IINF = 100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

int n,m;
int dp[1<<15][15];
vector<vector<int>> cost;

int rec(int s, int v){
    if(dp[s][v]!=-1)return dp[s][v];
    if(s == (1<<n)-1 && v == 0){
        return dp[s][v] = 0;
    } 
    int res = IINF;
    REP(u,n){
        if(!(s>>u & 1) && cost[v][u] !=-1){
            res = min(res, rec(s | 1 << u, u) + cost[v][u]);
        }
    }
    return dp[s][v]= res;
}
signed main () {
    scanf("%d %d",&n,&m);
    REP(i,(1<<n))REP(j,n)dp[i][j] = -1;
    cost.assign(n,vector<int>(n,-1));
    REP(i,m){
        int a,b,c;scanf("%d %d %d",&a,&b,&c);
        cost[a][b] = c;
    }
    int ans = rec(0,0);
    if(ans==IINF)ans = -1;
    printf("%d\n",ans);
}


Measured memory_bytes: 5144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;
typedef long long int ll;
set <int> s;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		s.insert(a[i]);
		if(a[i]!=0){
			if(i<n-1){
				s.insert(a[i]*10+a[i+1]);
			}
			if(i<n-2){
				s.insert(a[i]*100+a[i+1]*10+a[i+2]);
			}
		}
	}
	for(int i=0;i<=999;i++){
		if(s.find(i)==s.end()){
			cout << i << endl;
			return 0;
		}
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Enum various numbers
//-------------------------------------------------
namespace Enum
{
    using fint = ::std::int_fast64_t;
    //素因数分解(素因数列挙)
    ::std::map<fint,int> factor(fint n)
    {
        ::std::map<fint,int> ret;
        for(fint i=2; i*i<=n; i++){
            while(n%i==0){
                ret[i]++;
                n/=i;
            }
        }
        if (n!=1) ret[n]++;
        return ret;
    }
    //約数列挙
    ::std::vector<fint> divisor(fint n)
    {
        ::std::vector<fint> ret;
        for(fint i=2; i*i<=n; i++){
            if (n%i==0){
                ret.push_back(i);
                if (i*i!=n) ret.push_back(n/i);
            }
        }
        return ret;
    }
    //商列挙(割る最小の数と商のペア)
    ::std::vector<::std::pair<fint,fint> > quotient(fint n)
    {
        ::std::vector<::std::pair<fint,fint> > ret;
        fint i=0;
        for(i=2; i*i<=n; i++){
            ret.emplace_back(i,n/i);
        }
        for(; i<=n; i++){
            fint d = n/i;
            ret.emplace_back(i,d);
            i+=(n-d*i)/d;
        }
        return ret;
    }
    //素数判定(おまけ)
    bool isprime(fint n)
    {
        for(fint i=2; i*i<=n; i++){
            if (n%i==0) return false;
        }
        return true;
    }
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    auto f = Enum::factor(n);
    vi p;
    for(auto e:f) p.pb(e.fi);
    int sz = p.size();
    ll ans=0;
    rep(i,1<<sz){
        ll c=1;
        rep(j,sz)
            if (i>>j&1) c*=p[j];
        int popcnt = __builtin_popcount(i);
        int sgn = (popcnt&1)?-1:1;
        ans += sgn*(n/c);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(void){
    int h,w,n,c[100][100],m=0;
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        while(a>0){
            int d = m/w;
            int e = m%w;
            if(d%2==1){
                e = w-1-e;
            }
            
            c[d][e]=i;
            
            m++;
            a--;
        }
        
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<c[i][j];
            if(j<w-1){
                cout<<" ";
            }
        }
        cout<<endl;
    }
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())


template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 5e6 + 10, mod = 998244353;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (((ll) x) * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}
int ways(int n, int m){
	if(n == 0 && m == 0) return 1;
	return C(n + m - 1, n - 1);
}
int main(){
	pre();
	int n, m;
	sd(n); sd(m);
	int ans = 0;
	for(int odd = m % 2; odd <= m && odd <= n; odd += 2){
		int req = (3 * m - odd) / 2;
		ans = add(ans, mul(C(n, odd), ways(n, req)));
		// trace(odd, ans, req);
	}
	// trace(ans);
	for(int i = 2 * m + 1; i <= 3 * m; i++){
		ans = sub(ans, mul(n, ways(n - 1, 3 * m - i)));
	}

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

}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 5e5 + 5;
const int inf = 1e16 + 2;

void solve(int z) {
    string s;
    int k;
    cin >> k >> s;
    if(s.size() <= k) cout << s << '\n';
    else {
        for(int i = 0 ; i < k ; i ++) cout << s[i];
        cout << "...";
        cout << '\n';
    }
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int h, r;
    cin >> h >> r;
    if(-h > r) cout << -1 << endl;
    else if(-h == r) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3176
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	g := gcd(a, b)
	ds := make([]int, 0)
	for i := 1; i <= int(math.Sqrt(float64(g))); i++ {
		if g%i == 0 {
			ds = append(ds, i)
			if i != g/i {
				ds = append(ds, g/i)
			}
		}
	}
	sort.Sort(sort.IntSlice(ds))
	pds := make([]int, 0)
	for i := range ds {
		var ng bool
		for j := range pds {
			if gcd(ds[i], pds[j]) != 1 {
				ng = true
				break
			}
		}
		if !ng {
			pds = append(pds, ds[i])
		}
	}
	fmt.Println(len(pds))
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}


Measured memory_bytes: 768
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
        .groupBy { it }
        .map { if (it.key > it.value.count()) it.value.count() else it.value.count() - it.key}
        .sum()
    println(a)
}

Measured memory_bytes: 60148
N,K = [int(i) for i in input().split()]

if (N-1)*(N-2)/2 < K:
    print(-1)
    exit()

p = int((N-1)*(N-2)/2-K)
M = N-1+p
print(M)

for i in range(N-1):
    print(i+1, N)

z = 1
zz = 2
for i in range(p):
    print(z, zz)
    zz += 1
    if zz > N-1:
        z += 1
        zz = z+1


Measured memory_bytes: 42864
#include<stdio.h>

void trace(int * A, int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int *A, int N){
	int i, j, v;
	for(i = 0; i < N ;i++ ){
		v = A[i];
		j = i - 1;
		while(j >=0 && v < A[j]){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A,N);
	}
	return;
}

int main(){
	int N,i;
	int A[100]={};

	scanf("%d",&N);

	for(i = 0; i < N ; i++)scanf("%d",&A[i]);
	insertionSort(A,N);
	return 0;
}






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

int main(){
    int N;
    cin >> N;
    vector <int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int alice=0,bob=0;
    for(int i=0;i<N;i++){
       if(i%2==0){
           alice += vec.at(i);
       }
       else{
           bob += vec.at(i);
       }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
def MI():return map(int,input().split())
def LI():return list(MI())

from collections import Counter

n=int(input())
a=LI()
c=Counter(a)

# print(c)
M=0
for i,j in c.items():
    M+=(j)*(j-1)//2
# print(M)
for i in a:
    t=c[i]
    d=(t-1)
    print(M-d)

Measured memory_bytes: 25896
#include<stdio.h>
int main(void)
{	int i,n,mai=0,min,a[100000]={};
	unsigned long int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	if(a[0]<0)
	{	a[0]*=-1;
		mai++;
	}
	min=a[0];
	sum+=a[0];
	for(i=1;i<n;i++)
	{	if(a[i]<0)
		{	a[i]*=-1;
			mai++;
		}
		sum+=a[i];
		if(a[i]<min)
			min=a[i];
	}
	if(mai%2==1)
		sum-=2*min;
	printf("%ld\n",sum);
	return 0;
}


Measured memory_bytes: 512
using System;


class A
{
    static void Main(string[] args)
    {
        while (true)
        {
            string hsda = Console.ReadLine();
            if (hsda == null) { break; }
            int ans = 0;
            int a = int.Parse(hsda);
            /*int[] s = new int[a + 1];

            if (a > 18) { a = 36 - a; }
            //   if (a == 1) { ans = 4; }else if (a == 0) { ans = 1; }
            if (a >= 1) { s[1] = 4; }
            s[0] = 1;
            if (a >= 2)
            {
                for (int i = 2; i <= a; i++)
                { s[i] = s[i - 2] + (i + 1) * (i + 1); }
            }
            Console.WriteLine(s[a]);
            //Console.ReadLine();
            */
            for(int i = 0; i < 10; i++) { for (int k = 0; k < 10; k++) { for (int m = 0; m < 10; m++) { for (int i1 = 0; i1 < 10; i1++) { if (i + k + m + i1 == a) { ans++; } } } } }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 9080
import java.util.Scanner;

class Main {

    public static void main(String[] av){
	java.util.Scanner sc = new Scanner(System.in);
	//	while(int a < 1 OR 100 < a){
	int a = sc.nextInt();
        int b = sc.nextInt();
  
	int l = 2*a + 2*b;
	int s = a*b;

	System.out.println(s+" "+l);
    }
}



Measured memory_bytes: 26084
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl v(200010);
    vl w(200010);
    exrep(i, 1, n) {
        ll c;
        cin >> c;
        v[i] = w[c];
        w[c] = i;
    }

    vl dp(n+1);
    dp[0] = 1;
    exrep(i, 1, n) {
        dp[i] = dp[i-1];
        if(v[i] > 0 && v[i] != i-1) {
            dp[i] += dp[v[i]];
        }
        dp[i] %= mod;
    }
    
    out(dp[n]);
    re0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int n;
int m;
vector<int> G[100005];
bool reach[100005] = {0};
int par[100005] = {0};
queue<int> Q;

void dfs()
{
    while (!Q.empty()){
    
        int x = Q.front();
        Q.pop();
        for (auto v:G[x]){
            if (reach[v] == false){
                reach[v]  = true;
                par[v] = x;
                Q.push(v);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    
    int a,b;
    
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    par[1] = 1;
    reach[1] = true;
    Q.push(1);
    dfs();
    
    cout << "Yes" << endl;
    for (int i = 2;i <= n;i++){
        cout << par[i] << endl;
    }
}


Measured memory_bytes: 10480
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)
        self.__rank = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x == y:
            return False

        if self.__rank[x] < self.__rank[y]:
            self.__table[x] = y
            self.__size[y] += self.__size[x]
        else:
            self.__table[y] = x
            self.__size[x] += self.__size[y]
            if self.__rank[x] == self.__rank[y]:
                self.__rank[x] += 1
        return True

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g

@mt
def slv(N, M, AB):
    uf = UnionFind()
    p = set()
    for a, b in AB:
        uf.union(a, b)
        p.add(a)
        p.add(b)

    ans = 1
    for c in p:
        ans = max(ans, uf.size(c))
    return ans


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 206396
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
    
a = []
N, M = map(int, input().split())
for i in range(M):
    a.append(int(input()))

results = []

flag = True

for m in range(1, M):
    if a[m] - a[m - 1] == 1:
        flag = False
        break

flag_end = True
if M == 0:
    flag_end = False

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

if flag and flag_end:
    for m in range(M):
        if m == 0:
            results.append(Fib(a[m] + 1))
        else:
            results.append(Fib(a[m] - a[m - 1]))
    results.append(Fib(N - a[m] + 1))
    result = 1
    for i in range(len(results)):
        result = mul(result, results[i])
    print(result % mod)
elif not flag:
    print(0)
else:
    print(Fib(N + 2) % mod)















Measured memory_bytes: 49240
/**********************************************
#code by --> @ { shadat </> sk40 [ o_o  ^_^ ] } }
**********************************************/
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define tezz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define doub long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define stp setprecision(20)
string s;
string dd={'a','e','i','o','u','y'};
ll count1[1<<20];
ll total[1<<20];
bool contains(char c,string f){
	for(int i=0;i<f.length();i++){
		if(c==s[i]){
			return true;
		}
	}
	return false;
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	a=a-b;
	if(a>=c){
		cout<<"0";
	}
	else cout<<abs(a-c);
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int c;
  int i;
  c = getchar();
  if(c >= 'a' && c <= 'z')
  c = 'a';
  else if(c >= 'A' && c <= 'Z')
  c = 'A';

  printf("%c", c);

  return 0;
}


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

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

  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      cin >> a[i][j];

  int N; cin >> N;
  vector<vector<bool>> c(3, vector<bool>(3));
  for (int k = 0; k < N; k++) {
    int b; cin >> b;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][j] == b) c[i][j] = true;
  }

  bool ans = false;
  for (int i = 0; i < 3; i++) {
    int v = 0, h = 0;
    for (int j = 0; j < 3; j++) {
      if (c[i][j]) h++;
      if (c[j][i]) v++;
    }
    if (h == 3 || v == 3) ans = true;
  }

  if (c[0][0] && c[1][1] && c[2][2]) ans = true;
  if (c[0][2] && c[1][1] && c[2][0]) ans = true;

  cout << (ans ? "Yes" : "No") << "\n";
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int h, w, k;
	cin >> h >> w >> k;
	int ans = 0;
	vector<vector<bool>> grid(h, vector<bool>(w));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			grid[i][j] = (c == '#');
		}
	}
	for (int i = 0; i < (1 << h); i++)
	{
		for (int j = 0; j < (1 << w); j++)
		{
			vector<vector<bool>> copy_grid = grid;
			for (int i2 = 0; i2 < h; i2++)
			{
				if ((i >> i2) & 1)
				{
					for (int k2 = 0; k2 < w; k2++) copy_grid[i2][k2] = false;
				}
			}
			for (int j2 = 0; j2 < w; j2++)
			{
				if ((j >> j2) & 1)
				{
					for (int k2 = 0; k2 < h; k2++) copy_grid[k2][j2] = false;
				}
			}
			int tmp = 0;
			for (int i2 = 0; i2 < h; i2++)
			{
				for (int j2 = 0; j2 < w; j2++) tmp += copy_grid[i2][j2];
			}
			if (tmp == k)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;
 
 
int main() {
    char c;
    cin >>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout << "vowel" <<endl;
    else cout <<"consonant" <<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
N = input()

def func(lst):
    if len(lst) == 1:
        return lst[0] // 2 + 1
    res_lst = []
    for l in lst:
        res_lst.append(func(l))
    res_lst.sort()
    ret = 0
    for i in range(len(res_lst) // 2 + 1):
        ret += res_lst[i]
    return ret

for loop in range(N):
    S = raw_input()
    hoge = S.split(']')
    S = '],'.join(hoge)
    exec('piyo = ' + S[:-1])
    print func(piyo)



Measured memory_bytes: 9884
#include <stdio.h>

int main(void) {
	int a, b, c, k=0,j=0;
	scanf("%d %d %d",&a, &b, &c);
	if(a==b && c%a==0){j=j+1;}
	else{
	for(k=a;k<b+1;k++){
		if(c%k==0) {j=j+1;}
	}
	}
	printf("%d\n", j);
	
	
	return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

#ifdef __LINUX__
#define getchar getchar_unlocked
#endif

inline int Read(){
	char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	int x = c - '0'; c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

using namespace std;

const int N = 2e5 + 10;

struct Segment_Tree{
	
	int Min[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	Segment_Tree(){
		memset(Min, 0x3f, sizeof Min);
	}

	void update(int o, int L, int R, int x, int v){
		Min[o] = min(Min[o], v);
		if(L ^ R){
			if(x <= M) update(lc, L, M, x, v);
			else update(rc, M + 1, R, x, v);
		}
	}

	int query(int o, int L, int R, int l, int r){
		if(l <= L && R <= r) return Min[o];
		else{
			int ret = 1e9;
			if(l <= M) ret = query(lc, L, M, l, r);
			if(r > M) ret = min(ret, query(rc, M + 1, R, l, r));
			return ret;
		}
	}
}T;

struct Interval{
	int l, r;
	
	bool operator < (Interval &A) const{
		return l < A.l;	
	}
}A[N];

int n, m;
int S[N];
int cnt0[N], cnt1[N];
int pre[N];

int main(){
	n = Read();
	For(i, 1, n) S[i] = Read(), cnt0[i] = cnt0[i - 1] + (!S[i]), cnt1[i] = i - cnt0[i];
	m = Read();
	For(i, 1, m) A[i].l = Read(), A[i].r = Read();
	sort(A + 1, A + m + 1);

	int ans = cnt1[n];
	For(i, 1, m){
		int L = A[i].l - 1, R = A[i].r;
		For(j, A[i - 1].l, L) pre[j] = min(pre[j], pre[j - 1]);

		int ret = cnt1[L] + cnt0[R] - cnt0[L] + pre[L];
		ret = min(ret, cnt0[R] + T.query(1, 1, n, L + 1, R));

		T.update(1, 1, n, R, ret - cnt0[R]);
		pre[R] = min(pre[R], ret - cnt1[R]);

		ans = min(ans, ret + cnt1[n] - cnt1[R]);
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 8192