akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	vector<pii> a(n);
	rep(i,n){
		a[i].second = i;
		cin >> a[i].first;
	}
	sort(ALL(a));
	rep(i,n){
		cout << a[i].second+1 << " ";
	}
	cout << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

long long int N, K;
long long int p[2 * 100000 + 1];
long long int e[1000 + 1];
long double E[1000 + 1];
std::vector<long double> EE;
long double ans;

int main() {
  std::cin >> N >> K;
  for (long long int i = 1; i <= N; i++) {
    std::cin >> p[i];
  }

  // 各サイコロの期待値を求める
  for (long long int i = 1; i <= 1000; i++) {
    e[i] += e[i - 1] + i;
    E[i] = (long double)e[i] / i;
  }
  EE.push_back(0.0);
  for (long long int i = 1; i <= N; i++) {
    EE.push_back(E[p[i]]);
  }
  long double sum = 0.0;
  for (long long int i = 1; i <= K; i++) {
    ans += EE[i];
  }
  // K個連続した部分の期待値の合計を比べていく
  sum = ans;
  for (long long int i = 2; i + K - 1 <= N; i++) {
    sum -= EE[i - 1];
    sum += EE[i + K - 1];
    if (ans < sum) {
      ans = sum;
    }
  }

  std::cout << std::fixed << ans << std::endl;

  return 0;
}

Measured memory_bytes: 7792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int D, G;
	cin >> D >> G;
	int p[D], c[D];
	rep(i, D) {
		cin >> p[i] >> c[i];
	}
	int ans = 1000;
	rep(bit, 1 << D) {
		int d[D];
		rep(i, D) d[i] = p[i];
		int sum = 0;
		int cnt = 0;
		rep(i, D) {
			if (bit & (1 << i)) {
				sum += p[i] * (i + 1) * 100 + c[i];
				cnt += p[i];
				d[i] = 0;
			}
		}
		//cout << sum << " " << cnt << endl;
		if (sum >= G) {
			//cout << "*" << sum << " " << cnt << endl;
			ans = min(ans, cnt);
			continue;
		}
		int k = D;
		while (true) {
			//cout << "->" << k << " " << d[k - 1] << endl;
			while (d[k - 1] <= 0) k--;
			sum += 100 * k;
			d[k - 1]--;
			cnt++;
			if (sum >= G) {
				//cout << "**" << sum << " " << cnt << endl;
				ans = min(ans, cnt);
				break;
			}
		}

	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i;
    char s[4];
    for(i=0; i<=3; i++)
    {
        scanf("%c",&s[i]);
    }
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])||(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	int a,b; cin>>a>>b;
	int A,B,C,D;
	A=a+b; B=a-b; C=a*b;
	D=max(A,B);
	cout<<max(C,D)<<endl;
	
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

bool ch(int lb,int mid,string l,string m){
    int ld = mid - lb;
    if(ld % 2 == 1 && l == m)return false;
    else if(ld % 2 == 0 && l != m)return false;
    else return true;
}

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

    int lb = 0; int ub = N-1;
    cout << lb << endl;
    string l;cin >> l;
    cout << ub << endl;
    string r;cin >> r;
    bool ok = true;
    if(l == "Vacant" || r == "Vacant")ok = false;

    while(ok && ub - lb > 1){

        int mid = (ub+lb)/2;
        cout << mid << endl;
        string m;cin >> m;
        if(m == "Vacant")break;


        if(ch(lb,mid,l,m)){
            lb = mid;    // lb,ubは適宜変更
            l = m;
        }
        else{
            ub = mid;
            r = m;
        }
    }
       
}

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

int main(){

    int N,L;
    cin >> N >> L;

    vector<int> v(N);
    for(int i=0;i<N;i++){
        v[i]=L+i;
    }

    int m=100000;
    int t;

    for (size_t i = 0; i < N; i++)
    {
        if(m>abs(v[i])){
            m=abs(v[i]);
            t=i;
        }
    }

    
    int sum = accumulate(v.begin(),v.end(),0)-v[t];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

char S[200020];
int T[200020];
void update(int x, int v) { for(int i=x;i<200020;i+=(i&-i)) T[i] += v; }
int read(int l, int r) {
	int res = 0;
	for(int i=r;i;i-=(i&-i)) res += T[i];
	for(int i=l-1;i;i-=(i&-i)) res -= T[i];
	return res;
}

void solve() {
	scanf("%s", S+1);
	int L = (int)strlen(S+1);
	vector <int> v[30];
	for(int i=1;i<=L;i++) v[S[i]-'a'].pb(i);
	int c = 0;
	rep(i, 26) c += (szz(v[i]) & 1);
	if(c > 1) { puts("-1"); return; }
	ll ans = 0;
	
	int z[26] = {};
	int rr = L / 2;
	for(int i=1;i<=L;i++) {
		int c = S[i] - 'a';
		if(z[c] < szz(v[c]) / 2) {
			int r = v[c][szz(v[c])-1-z[c]];
			int val = L - r - read(r+1, L);
			ans += val;
			update(r, 1);
			--rr;
		}
		else if(z[c] == szz(v[c]) / 2 && szz(v[c]) % 2 == 1) {
			ans += rr;
		}
		z[c]++;
	}
	
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <functional>

template<typename T> class segment_tree {
	int N;
	std::vector<T> value;

public :
	const std::function<T(T, T)> op;
	const T id;

	segment_tree(const std::vector<T>& a, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int n = a.size(), m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
		for (int i = 0; i < n; i++) value[N + i] = a[i];
		for (int i = N - 1; i > 0; i--) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	segment_tree(const int& n, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
	}

	inline const int& size()const{return N;}

	void point_update(int i, const T& t) {
		i += N;
		value[i] = t;
		while (i /= 2) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	T range_fold(const int& L, const int& R, const int& i = 1, const int& l = 0, int r = -1)const{
		if (r == -1) r = N;
		if (L <= l && r <= R) return value[i];
		if (r <= L || R <= l) return id;
		return op(
			range_fold(L, R, i * 2, l, (l + r) / 2),
			range_fold(L, R, i * 2 + 1, (l + r) / 2, r)
		);
	}

	inline const T& operator[](const int& i)const{return value[N + i];}
};

int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<long long> a(n);
	for (int i = 0; i < n; i++) std::cin >> a[i];

	segment_tree<long long> sg(a, [](long long a, long long b){return a + b;}, 0);
	while (q--) {
		int op;
		std::cin >> op;
		if (op == 0) {
			int p; long long x;
			std::cin >> p >> x;
			sg.point_update(p, sg[p] + x);
		} else {
			int l, r;
			std::cin >> l >> r;
			std::cout << sg.range_fold(l, r) << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 16432
a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]

if c != []:
    print(sum(b) + min(c) -10)
else:
    print(sum(b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int x=1;
  for(int i=0; i<n; i++){
    if(x*2 > x+k){
      x += k;
    }
    else x = x * 2;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    ll sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }
    sort(A.rbegin(),A.rend());
    for(int i=0;i<M;i++){
        if(A[i]*4*M<sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
r = 0
for i in range(N):
  A = list(map(int, input().split()))
  s = C
  for j in range(M):
    s += A[j]*B[j]
  r += 1 if s>0 else 0
print(r)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int gcd(int one, int two) {
	while (one != 0 && two != 0) {
		if (one > two) {
			one = one % two;

		}
		else {
			two = two % one;
		}

	}

	return std::max(one, two);

}
int main()
{

	int a = 0, b = 0, c=100, d = 0, e = 0, maxy = 0, max = 0, ans = 0, count = 0, size = 0, n = 0,m=0,x=0,y=0;
	int sa[10000] = {}, xwant[101] = {}, ywant[101] = {};
	int yoko = 0, tate = 0;
	std::string output,output2,output3,output4;
	char changer;
	char changer2;
	bool okada = false;

	cin >> b;
	if (b % 111 == 0) {
		cout << b << endl;
	}
	else {
		cout << ((b / 111) + 1) * 111 << endl;
	}
	}







Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define M 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"

bool check(string s,ll start,ll e)
{
    for(ll i=start,j=e;i<j&&i<s.size();i++,j--)
    {
        if(s[i]!=s[j]) return false ;
    }
    return true;
    
}

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



	return 0;
}

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

using namespace std;

#define INF int(1e9)
#define ii pair<int, int>
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define x first
#define y second


vi BFS(int origem, vector<vi> &graph, int n){
    queue<int> fila;
    fila.push(origem);

    vi dist(n, INF);
    dist[origem] = 0;

    while(!fila.empty()){
        int vertex = fila.front();

        fila.pop();

        for(int i=0; i<graph[vertex].size(); i++){
            int adj = graph[vertex][i];
            if(dist[adj]>dist[vertex]+1)
                dist[adj] = dist[vertex]+1, fila.push(adj);
        }
    }
    return dist;
}

int main () {
    ios_base::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    a--, b--;

    vector<vi> graph(n);

    for(int i=0; i<n-1; i++){
        int X, Y;
        cin >> X >> Y;
        X--, Y--;
        graph[X].pb(Y);
        graph[Y].pb(X);
    }
    vi distA = BFS(a, graph, n);
    vi distB = BFS(b, graph, n);

    int ans = 0;

    for(int i=0; i<n; i++)
        if(distA[i]<distB[i])
            ans = max(ans, distB[i]-1);
        
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1; i<=x+k-1; i++){
        cout << i <<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
 
ab = b-a
nb = n-b
if ab%2 == 0:
  print(ab//2)
else:
  if n-a > b-1:
    t = a-1
    b_i = b-t
    if(b_i-1)%2 == 0:
      print((b_i-1)//2 + t)
    else:
      print((b_i-2)//2 + t+1)
  else:
    t = n-b
    a_i = a + t
    if (n- a_i)%2 ==0:
      print((n- a_i)//2 + t)
    else:
      print( (n-(a_i+1))//2 +t+1 )
    

Measured memory_bytes: 38384
#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>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t A[50];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}
	int32_t abs_max = 0;
	for (size_t i = 0; i < N; i++)
	{
		if (std::abs(A[abs_max]) < std::abs(A[i])) { abs_max = i; }
	}

	if (A[abs_max] == 0) {
		out << 0 << endl; return 0;
	}
	out << 2 * N<<endl;
	if (A[abs_max] > 0) {
		out << abs_max + 1<<' '<<  N << endl;
		out << abs_max + 1 << ' '<<  N << endl;

		for (size_t i = 1; i < N-1; i++)
		{
			out << N << ' ' << N << endl;
			out << N << ' '<<  i+1 << endl;
		}
		out << N << ' ' << N << endl;
		out << N << ' ' << N << endl;
	}
	else {
		out << abs_max + 1<<' '<<  1 << endl;
		out << abs_max + 1 << ' ' << 1 << endl;

		for (size_t i = N - 2; i > 0;--i)
		{
			out << 1 << ' ' << 1 << endl;
			out << 1 << ' ' << i + 1 << endl;
		}
		out << 1 << ' ' << 1 << endl;
		out << 1 << ' ' << 1 << endl;
	}

	return 0;
}
#endif

#if 0
#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>

auto& in = std::cin;
auto& out = std::cout;

int32_t N,K;
int32_t num[200001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>K;
	for (size_t i = 0; i < N; i++)
	{
		int32_t a;
		in >> a;
		num[a]++;
	}
	std::sort(num, num + 200001);

	int32_t sum = 0;
	for (size_t i = 0; i <= 200000-K; i++)
	{
		sum += num[i];
	}

	out << sum << endl;


	return 0;
}
#endif


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

using namespace std;


int main() {
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a * b < c * d)cout << c * d;
	else cout << a * b;
}

Measured memory_bytes: 256
n=int(input())
dic={}
for _ in range(n):
  r=input()
  if r in dic:
    dic[r]+=1
  else:
    dic[r]=1

n=int(input())
for _ in range(n):
  r=input()
  if r in dic:
    dic[r]-=1
  else:
    dic[r]=-1

print(max(max(dic.values()),0))


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

using namespace std;


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

int dx[] = { 0,0,1,-1,-1,-1,1,1 };
int dy[] = { 1,-1,0,0,-1,1,1,-1 };




template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << 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) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    int n;
    cin>>n;

    vector<vector<int>> items(n,vector<int>(3));

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

    vector<vector<int>> dp(n,vector<int>(3,0));

    for(int i=0; i<3; i++)
    {
        dp[0][i]=items[0][i];
    }

    for(int i=0; i<n-1; i++)
    {

        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(j!=k)
                {
                    dp[i+1][k]=max(dp[i][j]+items[i+1][k],dp[i+1][k]);
                }
            }
        }
    }

    int mx=0;

     for(int i=0; i<3; i++)
    {
        mx=max(dp[n-1][i],mx);
    }

    cout<<mx<<nl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int h, w; cin >> h >> w;
  int a[101][101] = {};
  for (int i = 0; i < h; i++) {
    string ss; cin >> ss;
    for (int j = 0; j < w; j++) {
      if (ss[j] == '#') a[i][j] = 1;
    }
  }

  bool no_change = false;
  while(!no_change) {
    // row check
    for (int i = 0; i < h; i++) {
      bool all_white = true;
      for (int j = 0; j < w; j++) {
        if (a[i][j]<0) continue;
        if (a[i][j]>0) {
          all_white = false;
          no_change = true;
          break;
        }
      }
      if (all_white) {
        for (int j = 0; j < w; j++) {
          a[i][j] = -1;
        }
      }
    }

    // col check
    for (int j = 0; j < w; j++) {
      bool all_white = true;
      for (int i = 0; i < h; i++) {
        if (a[i][j]<0) continue;
        if (a[i][j]>0) {
          all_white = false;
          no_change = true;
          break;
        }
      }
      if (all_white) {
        for (int i = 0; i < h; i++) {
          a[i][j] = -1;
        }
      }
    }
  }

  for (int i = 0; i < h; i++) {
    bool need_endl = false;
    for (int j = 0; j < w; j++) {
      if (a[i][j]<0) continue;
      if (a[i][j]>0) cout << '#';
      else cout << '.';
      need_endl = true;
    }
    if (need_endl)
      cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[(int)1e5+5],ans = 0;
int main(){
	cin>>n;
	for(int i =0;i<n;i++){
		cin>>a[i];
	}
	int temp = 0;
	for(int i = 0;i<n;i++){
		if(a[i]==i+1){
//			cout<<a[i]<<" sama "<<ans<<" "<<temp<<"\n";
			temp++;
		}else{
//			cout<<a[i]<<" tidak sama "<<ans<<" "<<temp<<"\n";
			if(temp) ans += max(1,temp/2 + (temp%2));
			temp = 0;
		}
	}
	if(temp) ans += max(1,temp/2 + (temp%2));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
// ----- very fast input/output ----- //
int read_int() {
	char ch = getchar_unlocked();
	int res = 0;
	while('0' <= ch && ch <= '9') {
		res = res * 10 + ch - '0';
		ch = getchar_unlocked();
	}
	return res;
}
void print_str(const char* str) {
	while(*str != '\0') {
		putchar_unlocked(*str);
		++str;
	}
}
char buf[1024];
void print_int(int x) {
	if(x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int ptr = 0, g;
	do {
		g = x / 10;
		buf[ptr++] = x - g * 10;
		x = g;
	} while(x > 0);
	while(ptr--) {
		putchar_unlocked(buf[ptr] + '0');
	}
}
// ----- main part ----- //
int N, sep[102400], dst[102400], depth[102400], par[102400];
int inputs[307200];
void find_depth(int pos) {
	for(int i = sep[pos]; i < sep[pos + 1]; ++i) {
		depth[dst[i]] = depth[pos] + 1;
		find_depth(dst[i]);
	}
}
int main() {
	// #1. read input
	N = read_int();
	for(int i = 0; i < 3 * N - 1; ++i) {
		inputs[i] = read_int();
	}
	// #2. construct tree
	int curpos = 0;
	for(int i = 0; i < N; ++i) {
		sep[inputs[curpos] + 1] = inputs[curpos + 1];
		curpos += inputs[curpos + 1] + 2;
	}
	for(int i = 0; i < N; ++i) {
		sep[i + 1] += sep[i];
	}
	curpos = 0;
	int root = 0;
	for(int i = 0; i < N; ++i) {
		int id = inputs[curpos];
		for(int j = sep[id]; j < sep[id + 1]; ++j) {
			dst[j] = inputs[curpos + j - sep[id] + 2];
			par[dst[j]] = id;
			root ^= dst[j];
		}
		root ^= i;
		curpos += inputs[curpos + 1] + 2;
	}
	par[root] = -1;
	find_depth(root);
	// step #3. print the answer
	for(int i = 0; i < N; ++i) {
		print_str("node ");
		print_int(i);
		print_str(": parent = ");
		print_int(par[i]);
		print_str(", depth = ");
		print_int(depth[i]);
		print_str(i == root ? ", root, [" : (sep[i] == sep[i + 1] ? ", leaf, [" : ", internal node, ["));
		for(int j = sep[i]; j < sep[i + 1]; ++j) {
			if(j != sep[i]) print_str(", ");
			print_int(dst[j]);
		}
		print_str("]\n");
	}
	return 0;
}


Measured memory_bytes: 5192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            int s = 0;
            for (int i = 0; i < 10; i++) {
                s += (line.charAt(i) - '0') * cs[i];
            }
            out.println(s % 10);
        }
    }

    private static final int[] cs = { 1, 9, 36, 84, 126, 126, 84, 36, 9, 1 };
}

Measured memory_bytes: 9128
/*input
7 9
1 7
5 9
5 7
5 9
1 1
6 8
3 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 3e5+1;
int bit[N];
int ans[N];
vector< pair<int,int> > seg;
int n,m;

bool cmp(pair<int,int> a,pair<int,int> b){
	return a.s-a.f < b.s-b.f;
}

void add(int ind,int val){
	while(ind <= m){
		bit[ind] += val;
		ind += ind&(-ind);
	}	
}

int pref(int ind){
	int res = 0;
	while(ind){
		res += bit[ind];
		ind -= ind&(-ind);
	}
	return res;
}

void solve(){
  	cin >> n >> m;
  	RE(i,n){
  		int l,r;cin >> l >> r;
  		seg.pb({l,r});
  	}
  	sort(all(seg),cmp);
  	int cur = 0;
  	RE(i,m){
  		while(seg[cur].s-seg[cur].f+1 < i and cur < n){
  			add(seg[cur].f,1);
  			add(seg[cur].s+1,-1);
  			cur++;
  		}
  		ans[i] = n-cur;
  		int nice = i;
  		while(nice <= m){
  			ans[i] += pref(nice);
  			nice += i;
  		}
  	}
  	RE(i,m){
  		cout << ans[i] << "\n";
  	}
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 10476
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    int l[N];
    for(int i=0;i<N;i++){
        scanf("%d",&l[i]);
    }    
    int ans=0;
    for(int i=0;i<K;i++){
        int max=0;
        int tem=0;
        for(int j=0;j<N;j++){
            if(l[j]>max){
                max=l[j];
                tem=j;
            }
            
        }
        ans=ans+max;
        l[tem]=0;
        
    }
    printf("%d\n",ans);

    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a[][] = new int[n][20];
		for(int i=0;i<n;i++) {
			int x = in.nextInt();
			for(int j=0;j<20;j++) {
				a[i][j] = (x>>j)&1;
			}
		}
		
		long res = 0;
		
		for(long i=0;i<n;) {
			int[] tmp = new int[20];
			long count = 0;
			long j;
			long back=0;
			for(j=i;j<n;j++) {
				if(check(tmp,a[(int) j])) count++;
				else {
					back = reverse(a,j);
					break;
				}
			}
			res += count*(count+1)/2;
			res -= back*(back+1)/2;
			i=j-back;
		}
		
		System.out.println(res);
		in.close();
	}
	
	private static boolean check(int[] tmp,int[] a) {
		for(int i=0;i<20;i++) {
			tmp[i] += a[i];
			if(tmp[i]>=2) return false;
		}
		return true;
	}
	
	private static long reverse(int[][] a,long j) {
		int[] tmp = new int[20];
		for(long i=j;i>=0;i--) {
			if(!check(tmp,a[(int) i])) return j-i-1;
		}
		return j-1;
	}
}


Measured memory_bytes: 112864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;

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;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  int n;
  cin>>n;
  vector<ll>a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll a_total=0,b_total=0;
  rep(i,n)a_total+=a[i];
  rep(i,n)b_total+=b[i];
  bool yes = true;
  ll diff=b_total-a_total;
  if(diff<0)yes=false;
  ll diff_2=diff;
  rep(i, n) {
    if(a[i] == b[i]) continue;
    else if(a[i] > b[i]) {
      diff_2 -= a[i] - b[i];
    }
    else {
      if((b[i]-a[i])%2==0) diff -= (b[i]-a[i])/2;
      else {
        diff -= (b[i]-a[i])/2 + 1LL;
        diff_2--;
      }
    }
  }
  if(diff < 0 || diff_2 < 0) yes = false;
  if(diff * 2 != diff_2) yes = false;
  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

template <long long MOD>
struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv()); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::fact = vector<ModInt<MOD>>();
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::finv = vector<ModInt<MOD>>();
using mint = ModInt<(long long)(1e9 + 7)>;


int n, k;
mint ans = 1;
vector<vector<int>> g;

mint perm(int n, int k) {
  if (n < k) return 0;
  return mint::fact[n] * mint::finv[n - k];
}

void dfs(int s, int p) {
  if (p == -1) {
    ans *= perm(k, g[s].size() + 1);
  } else {
    ans *= perm(k - 2, g[s].size() - 1);
  }
  for (auto&& t : g[s]) {
    if (t == p) continue;
    dfs(t, s);
  }
}


int main() {
  cin >> n >> k;
  g.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b, a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  mint::build(k);
  dfs(0, -1);
  cout << ans << endl;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  
  ll a=X/D;
  if(K<=abs(a)) {
    if(X>=0) cout << abs(X-K*D) << endl;
    else cout << abs(X+K*D) << endl;
  }
  else {
    int l=0;
    if((K-a)%2) l=1;
    if(X>=0) cout << abs(X-(a+l)*D) << endl;
    else cout << abs(X-(a-l)*D) << endl;
  }
}

Measured memory_bytes: 3628
function main()
	x = chomp(readline())
	n = length(x)
	a = 0
	z = 0
	for i in 1:n
		if x[i] == 'A'
			a = i
			break
		end
	end
	for i in 1:n
		if x[n-i+1] == 'Z'
			z = n-i+1
			break
		end
	end
	println(z-a+1)
end

main()

Measured memory_bytes: 123160
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
 
#define F first
#define S second
 
using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;

bool red[maxn];
int num[maxn];

int main () {
	Need_For_Speed();
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		red[i] = 0;
		num[i] = 1;
	}
	red[1] = 1;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		if (red[x]) {
			red[y] = 1;
		}
		num[x]--;
		num[y]++;
		if (!num[x]) {
			red[x] = 0;
		}
	}
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += red[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

double eps = 1e-12;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll tmp_b = b * 100 + 0.5;
    ll ans = a * tmp_b;
    ans /= 100;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

vi A;
ll n;
ll k;

ll memo[100'050];

ll dp(ll at) {
    if(at >= n-1) return 0;
    if(memo[at] != -1) return memo[at];
    ll ans = dp(at+1)+abs(A[at]-A[at+1]);
    for(int i = at+1; i <= min(at+k, n-1); i++) {
        ans = min(ans, dp(i)+abs(A[at]-A[i]));
    }
    return memo[at] = ans;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n >> k;
    A = vi(n+5,INF);
    rep(i,0,n) cin >> A[i];
    cout << dp(0) << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

class DSU {
private:
    vector<ll> d, sz;
public:
    DSU(ll n) {
        d=vector<ll>(n);
        sz=vector<ll>(n, 1);
        REP(i,n) d[i]=i;
    }

    ll p(ll a) {
        if (d[a]==a) return a;
        else return d[a]=p(d[a]);
    }

    ll get_sz(ll a) {
        return sz[p(a)];
    }

    void unite(ll a, ll b) {
        ll pa=p(a);
        ll pb=p(b);
        if (pa==pb) return;
        else {
            sz[pb]+=sz[pa];
            sz[pa]=0;
            d[pa]=pb;
            return;
        }
        return;
    }
};

void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif
//
//    int tc; cin >> tc;
//    TC(tc) solve();
	ll n, m, a, b;
	cin >> n >> m;
//	vi vis(n,0),color(n,0);
//	vvi adj(n);
	DSU dsu=DSU(n);
    REP(i,m){
    	cin >> a >> b;
    	--a,--b;
//    	adj[a].pb(b);
//    	adj[b].pb(a);
		dsu.unite(a,b);
	}
//	int k=0;
//	queue<int> q;
//	q.push(0);
//	while(!q.empty()){
//		int u = q.front();
//		q.pop();
//		int c=k;
//		EACH(v, adj[u]){
//			if(!color[v]){
//				dfs(adj,color,v,c);
//				color[v]=c;
//			}
//		}
//	}
//	int ans=0;
//	REP(i,n) ans+=color[i]?1:0;
//	OUT(ans);
	int ans=-INT_MAX;
	REP(i,n) MAX(ans, (int)dsu.get_sz(i));
	OUT(ans);
    return 0;
}

Measured memory_bytes: 12616
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC099D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var C = ss.Next(int.Parse);
            var D = ss.Next(int.Parse, C, C);

            var cs = new int [3, C + 1];
            for (var i = 0; i < N; i++)
            for (var j = 0; j < N; j++)
            {
                cs[(i + j) % 3, ss.Next(int.Parse)]++;
            }

            var ans = int.MaxValue;
            for (var i = 1; i <= C; i++)
            for (var j = 1; j <= C; j++)
            for (var k = 1; k <= C; k++)
            {
                if (i == j || j == k || k == i) continue;
                var total = 0;
                for (var c = 1; c <= C; c++)
                {
                    total += cs[0, c] * D[c - 1][i - 1];
                    total += cs[1, c] * D[c - 1][j - 1];
                    total += cs[2, c] * D[c - 1][k - 1];
                }
                ans = Math.Min(ans, total);
            }

            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 17484
#include<stdio.h>
#include<utility>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
#define int long long

int a[100000], n, m;
ll sum[300000];
ll sum2[300000];
ll e[300000];
int dist(int a, int b) {
	return (b >= a ? b - a : b + m - a);
}
int dist(int a, int b, int c) {
	int A = dist(a, b), B = 1 + dist(c, b);
	return (A < B ? A : B);
}
signed main() {
	scanf("%lld%lld", &n, &m);
	rep(i, n)scanf("%lld", &a[i]), a[i]--;
	rep(i, n - 1) {
		if (a[i] < a[i + 1]) {
			sum[a[i] + 1]++;
			sum[a[i + 1] + 1]--;
			e[a[i + 1] + 1] -= a[i + 1] - a[i];
		}
		else {
			sum[a[i] + 1]++;
			sum[a[i + 1] + m + 1]--;
			e[a[i + 1] + m + 1] -= a[i + 1] + m - a[i];
		}
	}
	for (int i = 1; i <= 200005; i++)sum[i] += sum[i - 1];
	for (int i = 1; i <= 200005; i++)sum2[i] = sum2[i - 1] + e[i] + sum[i];
	ll id = 0, Max = 0;
	rep(i, m) {
		if (sum2[i] + sum2[i + m] > Max) {
			id = i; Max = sum2[i] + sum2[i + m];
		}
	}
	ll ans = 0;
	rep(i, n - 1) {
		ans += dist(a[i], a[i + 1], id);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7168
#include <iostream>
using namespace std;
int H[100005];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> H[i];
	}

	for (int i = N-1; i > 0; --i)
	{
		if (H[i-1] - H[i] >= 2)
		{
			cout << "No" << endl;
			return 0;
		}
		else if (H[i-1] - H[i] == 1)
		{
			H[i-1] -= 1;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n,s=0,maxn=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		char ch;
		cin>>ch;
		if(ch=='I')
			s++;
		else
			s--;
		maxn=max(s,maxn);
	}
	cout<<maxn<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int64_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if(A + B >= 2 * C){
        if(X >= Y){
            cout << min(A, 2 * C) * (X - Y) + 2 * C * Y << endl;
        } else {
            cout << 2 * C * X + min(B, 2 * C) * (Y - X) << endl;
        }
    } else {
        cout << X * A + Y * B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 2147483647;
const ll INF = 100000000000010000;
const ull B = 998244353;

//ll bit[200010];
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void update(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}*/

/*void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 3004; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N, A[100010], sum, resum;
ll hakidashi[60];
vector<P> trans;
ll ans;

void solve() {
	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) sum ^= A[i];
	resum = sum ^ ((1LL << 60) - 1);
	rep(i, N) A[i] &= resum;
	priority_queue<ll> que;
	ll bit = 59;
	rep(i, N)if (A[i] != 0) que.push(A[i]);
	while (que.size()) {
		ll lar = que.top(); que.pop();
		while ((lar & (1LL << bit)) == 0 && bit >= 0) bit--;
		if (bit < 0) break;
		hakidashi[bit] = lar;
		while (que.size() && que.top() > (1LL << bit)) {
			ll a = que.top(); que.pop();
			que.push(a ^ hakidashi[bit]);
		}
	}
	rep(i, 60)if (hakidashi[i] != 0) trans.pb(P(hakidashi[i], i));
	for (ll i = 0; i < trans.size(); i++) {
		for (ll j = i + 1; j < trans.size(); j++) {
			P p = trans[i], q = trans[j];
			if ((q.f & (1LL << p.s)) != 0) trans[j].f ^= p.f;
		}
	}
	for (P p : trans) ans ^= p.f;
	ans = ans * 2 + sum;
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

map<vector<int>,int> mem;
int dfs(vector<int> &A){
  int n = A.size();  
  if(n<=1) return 0;
  if(mem.count(A)) return mem[A];
  
  int res = A.size()-1;
  for(int i=0;i<w;i++){
    vector<int> T,F;
    for(int j=0;j<n;j++) (A[j]>>i&1)? T.push_back(A[j]) : F.push_back(A[j]);
    if(T.empty() || F.empty()) continue;
    res = min(res,max(dfs(T),dfs(F))+1);
  } 
  return mem[A] = res;
}

int BtoI(string a){
  int res = 0;
  for(int i=0;i<(int)a.size();i++) res = res*2+a[i]-'0';
  return res;
}

int main(){

  while(1){
    int n;
    cin>>w>>n;
    if(w==0&&n==0)break;
    vector<int> A;
    A.resize(n);
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      A[i] = BtoI(s);
    }
    mem.clear();
    cout<<dfs(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5440