akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, k,ans=INF;
	cin >> n >> k;
	vector<int>vec(n);
	vecin(vec);
	sort(all(vec));
	for (int i = 0; i <= n - k; i++) {
		ans = min(ans, vec[i + k - 1] - vec[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, a[3][110], ca[110] = {}, cb[110] = {};
	cin >> n;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
			if (i == 1) {
				ca[j] = ca[j - 1];
				ca[j] += a[i][j];
			}
			else {
				cb[j] = cb[j - 1];
				cb[j] += a[i][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ca[i] + cb[n] - cb[i - 1], ans);
	}
	cout << ans << endl;
	return 0;
}


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

char p[100][100];
int n,m,ans;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

void dfs(int x,int y,char s)
{
    p[x][y] = 'X';
    int i;
    for(i = 0;i < 4;i++){
        int xx = x + dx[i],yy = y + dy[i];
        if(xx >= 0 && yy >= 0 && xx < m && yy < n){
            if(p[xx][yy] == s)
                dfs(xx,yy,s);
        }
    }
}

int main(void)
{
    while(cin>>n>>m,n && m){
        int i,j;
        ans = 0;
        for(j = 0;j < n;j++){
            for(i = 0;i < m;i++){
                cin>>p[i][j];
            }
        }
        for(j = 0;j < n;j++){
            for(i = 0;i < m;i++){
                if(p[i][j] != 'X'){
                    ans++;
                    dfs(i,j,p[i][j]);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  double n;
  cin >> n;
  int a, b;
  a = n / 2;
  b = n - a;
  double ans = b / n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
int a[111111];

//最大公約数
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
//最小公倍数
ll lcm(ll a,ll b){


    if(a==0 || b==0)return 0;

    return a/gcd(a,b)*b;

}
signed main(){
	
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	if(a[n-1]<k){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	int GCD=gcd(a[0],a[1]);
	rep(i,n){
		GCD=gcd(a[i],GCD);
	}
	if(GCD==gcd(GCD,k))cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}


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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int S,i;
	int n,m;

	i_cin(S); 
	n = S;
	m = S;
	if (S == 4 || S == 2 || S == 1) {
		i_cout(4); return 0;
	}
	n = S; m = S;
	for (i = 1; m <= 1000000; i++) {
		if (n % 2) m = 3 * n + 1;
		else m = n / 2;
		if (m == 4)break;
		n = m;
	}

	
	i_cout(i + 4);
	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
struct edge {
	ll to, cost,toK;

};
vector<edge> ev[100010];
ll k;
ll kc[100010];
ll recur(ll from, ll next,ll cost) {

	kc[next] = cost;

	for (size_t i = 0; i < ev[next].size(); i++)
	{
		if (ev[next][i].to == from) continue;
		recur(next,ev[next][i].to, cost + ev[next][i].cost);
	}
	return 0;
}
void TransitTreePath() {
	int n;
	cin >> n;
	for (size_t i = 0; i < n - 1; i++)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		edge e;
		e.to = b;
		e.cost = c;
		ev[a].push_back(e);
		edge e2;
		e2.to = a;
		e2.cost = c;

		ev[b].push_back(e2);
	}

	ll q;
	cin >> q >> k;

	for (size_t i = 0; i < ev[k].size(); i++)
	{
		int to = ev[k][i].to;
		recur(k, to, ev[k][i].cost);
	}

	for (size_t i = 0; i < q; i++)
	{
		ll x, y;
		cin >> x >> y;
		cout << (kc[x] + kc[y]) << endl;
	}
}
int main() {
	TransitTreePath();
	return 0;
}



Measured memory_bytes: 18944
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    string s;
    int year=0;
    int month=0;
    int day=0;
    cin >> s;
    for(int i=0; i<4; i++)
    {
        if(i!=0)
        {
            year *= 10;
        }
        year += s[i] - '0';
    }
    for(int i=5; i<7; i++)
    {
        if(i!=0)
        {
            month *= 10;
        }
        month += s[i] - '0';
    }
    for(int i=8; i<10; i++)
    {
        if(i!=0)
        {
            day *= 10;
        }
        day += s[i] - '0';
    }
    if(year > 2019 || (year==2019 && month > 4))
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
}



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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) cout << "Yes" << endl;
	else if (a == c && a != b) cout << "Yes" << endl;
	else if (b == c && a != b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
	int N = 0;
	cin >> N;
	auto m = N % 10;
	switch (m)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon";
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon";
		break;
	case 3:
		cout << "bon";
		break;
	default:
		break;
	}

}



Measured memory_bytes: 3132
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>
#include <bitset>

using namespace std;

int main (void)
{
	string s,t;

	cin >> s >> t;
	long k = 0;
	k = t.size();
	long p = 0;
	p = s.size();

	for (long i = 0; i < p - k + 1; i++)
	{
		if (s.substr(i,k) == t)
		{
			cout << i << endl;
		}
	}
}



Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(void) {
	long long d;
	cin >> d;
	return d;
}
void println(void) {
	cout << endl;
}
void printFixed(double d, int digit) {
	cout << fixed << setprecision(digit) << d;
}
void printlnFixed(double d, int digit) {
	printFixed(d, digit);
	println();
}

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

	while(int n = read()) {
		long long sum = 0;
		vector<int> scores(n);
		REP(i, n) {
			scores[i] = read();
			sum += scores[i];
		}
		double mean = (double)sum / n;
		double diff_sum = 0;
		REP(i, n) {
			double diff = scores[i] - mean;
			diff_sum += diff * diff;
		}
		double var = diff_sum / n;
		double sd = sqrt(var);
		printlnFixed(sd, 5);
	}
	return 0;
}



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

using namespace std;

using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

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

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< pair< int, int > > D;
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    int sum = 0, tap = 0;
    for(auto &c : S) {
      sum += (c == '(') ? 1 : -1;
      chmin(tap, sum);
    }
    sum *= -1;
    tap *= -1;
    D.emplace_back(tap, tap - sum);
  }
  sort(begin(D), end(D), [](auto p, auto q) {
    if(p.first <= p.second) {
      if(q.first <= q.second) return p.first < q.first;
      return true;
    } else {
      if(q.first <= q.second) return false;
      return p.second > q.second;
    }
  });

  int64 ret = 0, sum = 0;
  for(auto &p : D) {
    ret += p.first;
    chmax(sum, ret);
    ret -= p.second;
  }
  if(ret == 0 && sum == 0) cout << "Yes\n";
  else cout << "No\n";
}



Measured memory_bytes: 11620
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		String S = sc.get();
		String T = sc.get();
		int count = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) != T.charAt(i)) count++;
		}
		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 36960
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



void outPut(int value){

	stack<int> S;

	for(int loop = 0; loop < 32; loop++){
		if(value & (1 << loop)){

			S.push(1);

		}else{

			S.push(0);
		}
	}

	while(!S.empty()){

		printf("%d",S.top());
		S.pop();
	}

	printf("\n");
}

int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	outPut(A&B);
	outPut(A|B);
	outPut(A^B);

	return 0;
}




Measured memory_bytes: 3224
#include <stdio.h>

int main(void){
	char S[201] = {'\0'};
	int length;
	int oddlength = 0;
	char odd = 'F';
	scanf("%s", S);

	int i, j, k;

	for(i=0; i<201; i+=1){
		if(S[i] == '\0'){
			length = i;
			break;
		}
	}
	if(length%2 == 0){
		for(i=length-3; i>=0; i-=2){
			for(j=i; j>=(i+1)/2; j--){
				if(S[j] != S[j-(i+1)/2])
					break;
				if(j == (i+1)/2)
					odd = 'T';
			}
			if(odd == 'T'){
				oddlength = i+1;
				break;
			}
		}
	}else{
		length = 0;
	}

	printf("%d\n", oddlength);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long long ans = 1;
  long long mod = 1e9 + 7;
  int cl[3];
  cl[0] = cl[1] = cl[2] = 0;
  for (int i = 0; i < N; i ++) {
    bool did = true;
    int a;
    cin >> a;
    int k = 0;
    for (int i_ = 0; i_ < 3; i_ ++) {
      if(cl[i_] == a) {
        k ++;
        if (did) {
          cl[i_] ++;
          did = false;
        }
      }
    }
    ans *= (long long)k;
    ans %= mod;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;cin>>s;
    if(s[0]=='S'){
        cout<<"Cloudy"<<endl;
    }
    else if(s[0]=='C'){
        cout<<"Rainy"<<endl;
    }
    else{
        cout<<"Sunny"<<endl;
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong n, k;
	string s;
	cin >> n >> k >> s;
	vector<llong> zero, one;
	llong sum = 1;
	for (int i = 1; i < n; i++){
		if (s[i] == s[i-1])
			sum++;
		else {
			if (s[i-1] == '0')
				zero.push_back(sum);
			else
				one.push_back(sum);
			sum = 1;
		}
	}
	if (s[n-1] == '0')
		zero.push_back(sum);
	else
		one.push_back(sum);

	vector<llong> zrui(zero.size()+1,0), orui(one.size()+1,0);
	for (int i = 0; i < zero.size(); i++)
		zrui[i+1] = zrui[i] + zero[i];
	for (int i = 0; i < one.size(); i++)
		orui[i+1] = orui[i] + one[i];

	llong ans = 0;
	if (zero.size() <= k){
		ans = zrui[zero.size()] + orui[one.size()];
	}else{
		int c = 0;
		if (s[0] == '0')
			ans = zrui[k] + orui[k], c++;
		for (int i = 0; i+k < orui.size() && i+k+c < zrui.size(); i++){
			int cc = (i+k+1 < orui.size());
			ans = max(ans, zrui[i+k+c]-zrui[i+c] + orui[i+k+cc] - orui[i]);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2164
N, K, L = [int(x) for x in input().split()]
K_lst = [[int(x) for x in input().split()] for i in range(K)]
L_lst = [[int(x) for x in input().split()] for i in range(L)]

ar = [int(i) for i in range(N + 1)]
br = [int(i) for i in range(N + 1)]

def find(x, array):
    if array[x] == x:
        return x
    else:
        array[x] = find(array[x], array)
        return array[x]

def union(x, y, array):
    x = find(x, array)
    y = find(y, array)

    if x == y:
        return
    if x > y:
        x, y = y, x
    array[y] = x

for i in K_lst:
    u, v = i
    union(u, v, ar)
for i in L_lst:
    u, v = i
    union(u, v, br)
for i in range(1, N + 1):
    find(i, ar)
    find(i, br)
dict = {}
for i in range(1, N + 1):
    a = ar[i]
    b = br[i]
    if not (a, b) in dict.keys():
        dict[(a, b)] = 1
    else:
        dict[(a, b)] += 1
a_lst = [0] * N
for i in range(N):
    a = ar[i + 1]
    b = br[i + 1]
    a_lst[i] = dict[(a, b)]
print(*a_lst)


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

struct island {
    bool adj1;
    bool adjN;
    island() : adj1(false), adjN(false) {}
};

int main() {
    bool ans = false;
    int N, M, a, b;
    cin >> N >> M;
    vector<island> islands(N);
    vector<int> adj;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        if (a == 1) {
            islands[b-1].adj1 = true;
            adj.push_back(b - 1);
        }
        if (b == 1) {
            islands[a-1].adj1 = true;
            adj.push_back(a - 1);
        }
        if (a == N) {
            islands[b-1].adjN = true;
        }
        if (b == N) {
            islands[a-1].adjN = true;
        }
    }
    for (int i : adj) {
        if (islands[i].adjN) ans = true;
    }
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 1276
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn option_max<T: Ord>(l: Option<T>, r: Option<T>) -> Option<T> {
    match (l, r) {
        (None, x) | (x, None) => x,
        (Some(l), Some(r)) => Some(max(l, r)),
    }
}

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    // dp[i][b] = s
    // 0..i に総和が決まっている
    // b = 1 なら要素 i に -1 がかかる
    // 0..i の最大の総和が s である
    let mut dp = vec![vec![None, None]; N + 1];
    dp[0][0] = Some(0);

    for i in 0..N {
        for b in 0..2 {
            let sign = if b == 0 { 1 } else { -1 };
            dp[i + 1][0] = option_max(dp[i + 1][0], dp[i][b].map(|s| s + sign * A[i]));
            dp[i + 1][1] = option_max(dp[i + 1][1], dp[i][b].map(|s| s - sign * A[i]));
        }
    }

    debug!(dp);

    println!("{}", dp[N][0].unwrap())
}


Measured memory_bytes: 12540
class Path:
    def __init__(self):
        self.a = -1
        self.b = -1

    def getA(self):
        return self.a
    def setA(self, aa):
        self.a = aa
    def getB(self):
        return self.b
    def setB(self, bb):
        self.b = bb

def trace_path(ps, s, cnt, num):
    res = 0
    
    s2 = []
    ps2 = []
    for i in range(0, len(ps)):
        p = ps[i]
        if p.getA() == s or p.getB() == s:
            s2.append(p)
        else:
            ps2.append(p)
    if len(ps2) == 0:
        if cnt == num:
            res += 1
    else:
        for i in range(0, len(s2)):
            p = s2[i]
            if p.a == s:
                res += trace_path(ps2, p.getB(), cnt+1, num)
            else:
                res += trace_path(ps2, p.getA(), cnt+1, num)
    return res

in1 = input().split()
n = int(in1[0])
m = int(in1[1])

ps = []
for i in range(0, m):
    in2 = input().split()
    p = Path()
    p.a = int(in2[0])
    p.b = int(in2[1])
    ps.append(p)
                       
res = trace_path(ps, 1, 1, n-1)

print(str(res))

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<vector<int>> A(2,vector<int>(N,0));
    REP(i,2){    
        REP(j,N){   
            cin >> A[i][j];
        }
    }
    vector<vector<int>> dp(2,vector<int>(N+1,0));
    dp[0][0] = 0;
    dp[1][0] = 0;

    REP(i,N){
        dp[0][i+1] = dp[0][i] + A[0][i];
    }
    FOR(i,1,N+1){
        dp[1][i] = max(dp[0][i],dp[1][i-1]) + A[1][i-1];
    }


    cout << dp[1][N] << endl;
    return 0;
}

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

int main(){
	long long int n, a, b, c;
	int flag;
	map<int, long long int> m;
	vector<int> v;
	while (cin >> n, n){
		m.clear();
		v.clear();
		flag = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			if(m[a] == 0) v.push_back(a);
			m[a] += b * c;
		}
		for (int i = 0; i < v.size(); i++){
			if (m[v[i]] >= 1000000ll){
				flag = 1;
				cout << v[i] << endl;
			}
		}
		if (!flag) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
A, B = map(int, input().split())
P = [int(_) for _ in input().split()]
cnt = [0]*(21)

for i in P:
    cnt[i] += 1

num1 = sum(cnt[:A+1])
num2 = sum(cnt[A+1:B+1])
num3 = sum(cnt[B+1:])

print(min(num1, num2, num3))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main()
{
    string str;
    int cursor = 0,longs;
    bool ans = true;
     
    while (1) {
        cursor = 0;
        ans = true;
        getline(cin,str);
        longs = str.length();
        if (longs == 1) {
            if (str[0] == '.') {
                break;
            }
        }
        char word[longs];
        for (int i = 0; i < longs; i++) {
            if (str[i] == '(' || str[i] == '[') {
                if (str[i] == '(') {
                    word[cursor] = '(';
                }else{
                    word[cursor] = '[';
                }
                cursor++;
            }
            if (str[i] == ')' || str[i] == ']') {
                cursor--;
                if (str[i] == ')') {
                    if (word[cursor] != '(') {
                        ans = false;
                        break;
                    }
                }else{
                    if (word[cursor] != '[') {
                        ans = false;
                        break;
                    }
                }
            }
        }
        if (ans == true && cursor == 0) {
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1168
n, x, y = map(int, input().split())

res = [0] * n
for i in range(1, n+1):
    for j in range(i+1, n+1):
        res[min(j-i, abs(x-i)+1+abs(y-j))] += 1

print('\n'.join(map(str, res[1:])))


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  for (int k = K; k <= N+1; k++) {
    long long max_sum = (long long)(N + N-(k-1)) * k / 2;
    long long min_sum = (long long)(0 + k-1) * k / 2;
    long long total_sum = max_sum - min_sum + 1;
    ans += total_sum;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	string s;
	cin >> s;
	int count = 0;
	int n = s.size();
	
	for (int i = 0; i < n; ++i)
		if (s[i] == '0')++count;

	cout << 2 * min(n - count, count) << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1000;i++){
		double c,d;
		c=i*0.08;
		d=i*0.1;
		int s,t;
		s=floor(c);
		t=floor(d);
		if(s==a&&t==b){
			cout<<i;
			return 0;
		} 
	}
	cout<<"-1";
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

const int nmax = 8;
//　隣接行列
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax])
{
    // すべての点を見たか
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        //　1つでも見ていない点がある
        if(visited[i]==false)
            all_visited = false;
    }
    
    //　すべての点を見ていたら1を返す
    if(all_visited){
        return 1;
    }

    int ret = 0;
    for (int i = 0; i < N; i++)
    {
        //　vとiを結ぶ線がある　かつ　iをまだ見ていない　なら以下の処理へ
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        //　iへ移動しDFSを続ける
        ret += dfs(i,N,visited);
        visited[i] = false;
    }

    return ret;
}

int main(void){
    int N,M;
    cin >> N >> M;

    for(int i = 0; i < M; i++){
        int A,B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];
    for(int i = 0;i < N; i++){
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0,N,visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque<long long>deq;
int main(){
	deq.push_back(1);
	deq.push_back(2);
	deq.push_back(3);
	deq.push_back(4);
	deq.push_back(5);
	deq.push_back(6);
	deq.push_back(7);
	deq.push_back(8);
	deq.push_back(9);
	int k;
	scanf("%d",&k);
	for(int i=1;i<k;i++){
		long long s=deq.front();
		deq.pop_front();
		if(s%10!=0) deq.push_back(s*10+s%10-1);
		deq.push_back(s*10+s%10);
		if(s%10!=9) deq.push_back(s*10+s%10+1);
	}
	printf("%lld",deq.front());
	return 0;
}

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

int main(){
	int q, h, s, d;
	scanf("%d %d %d %d", &q, &h, &s, &d);
	int a = min(4*q, min(2*h, s)), b = d;
	int n;
	scanf("%d", &n);
	long long ans = 0;
	if(2*a <= b){
		ans = a*1LL*n;
	}else{
		if(n%2) ans = a;
		n /= 2;
		ans += b*1LL*n;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

LL dp[410][410];

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;
  VL acc(N+1);
  REP(i,N) acc[i+1] = acc[i] + xs[i];

  fill((LL*)dp, (LL*)dp+410*410, INF);
  REP(i,N) dp[i][i+1] = 0;
  FOR(len,2,N+1){
    for(int b=0,e=len;e<=N;++b,++e){
      for(int k=b+1;k<e;++k){
        mini(dp[b][e], dp[b][k] + dp[k][e]);
      }
      dp[b][e] += acc[e] - acc[b];
    }
  }

  cout << dp[0][N] << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, V; cin >> A >> V;
    int B, W; cin >> B >> W;
    int T; cin >> T;
    int d = abs(A - B);
    int v = V - W;
    if(v > 0 && d <= T * v) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define i(a,n) int a=n;
#define l(a,n) ll a=n;
#define d(a,n) double a=n;
#define s(a) string a;
#define c(a) ll a; cin>>a;a
#define cd(a) double a; cin>>a;
#define cs(a) string a; cin>>a;
#define ci(a) cin>>a;
#define co(a) cout<<a;
#define cos(a) cout<<a<<" ";
#define con(a) cout<<a<<endl;
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define nl cout<<endl;
#define ca(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n) for(ll i=a;i>=n;i--)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define T ll t=1; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    int r,g,b,k;
    cin>>r>>g>>b>>k;
    while(k--)
    {
        if(g<=r ) g*=2;
        else if(b<=g) b*=2;
        else if(b>g && g>r) b*=2; 
        //cos(r) cos(g) cos(b)
        //nl
    }
    if(b>g && g>r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3664
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> ref a, ref b, c
let _ = for i = 1 to k do if i mod 2 = 1 then (a := !a / 2; b := !b + !a) else (b := !b / 2; a := !a + !b) done; Printf.printf "%d %d\n" !a !b

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int main(int argc, char* argv[])
{
	int n, m;
	scanf("%d%d", &n ,&m);
	printf("%d\n", (n - 1) * (m - 1));

	return 0;
}


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

int main(){
	int k, x;
	cin >> k >> x;
	
    int s=x-k+1, e=x+k-1;
    if(s<-1e6) s=-1e6;
    if(e>1e6) e=1e6;
    for(int i=s; i<=e; i++) cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long N = n;
        int m = sc.nextInt();
        ArrayList<Bridge> bl = new ArrayList<Bridge>();
        long[] ans = new long[m];
        final long ANS = N*(N-1)/2;
        for(int i = 0; i < m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            Bridge br = new Bridge(a, b);
            bl.add(br);
        }
        Collections.reverse(bl);
        UnionFindTree uft = new UnionFindTree(n);
        long cnt = 0;
        ans[m-1] = ANS;
        for(int i = 0; i < bl.size()-1; i++){
            Bridge br = bl.get(i);
            int a = br.getA();
            int b = br.getB();
            if(!uft.same(a,b)){
                cnt += (long)uft.getSize(a)*(long)uft.getSize(b);
                uft.union(a,b);
            }
            ans[m-2-i] = ANS-cnt;
        }
        for(int i = 0; i < m; i++){
            System.out.println(ans[i]);
        }
    }
}
 
class Bridge{
    private int a;
    private int b;
    public Bridge(int a, int b){
        this.a = a;
        this.b = b;
    }
    public int getA(){
        return this.a;
    }
    public int getB(){
        return this.b;
    }
}
 
class UnionFindTree {
	int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納	
	int[] rank; //parentと同様に、木の高さを格納
	int[] size;
	
	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];
		this.size = new int[size];
		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}
	
	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0; //集合の高さ
		size[i] = 1;
	}
	
	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);
		int siz = size[xRoot] + size[yRoot]; 
		//xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) { 
			parent[yRoot] = xRoot; //yの親をxに更新 
			size[xRoot] = siz;
								   
		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;
			size[yRoot] = siz;
			
		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
			size[xRoot] = siz;
		}
		//System.out.println("x:" + x +"  y:" + y + "  size[x]:" + size[x] + "  size[y]:" + size[y]);
		
	}
	
	//引数の属する木のルートのidを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}
	
	//同じ木に属しているか
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
	
	public int getSize(int x){
	    return size[parent[x]];
	}
}

Measured memory_bytes: 98296
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    string a,b; cin>>a>>b;
    if(a.length()!=b.length()){
        if(a.length()>b.length()) puts("GREATER");
        else puts("LESS");
    }else{
        for(int i=0;i<a.length();i++){
            if(a[i]>b[i]){
                puts("GREATER");
                return 0;
            }else if(a[i]<b[i]){
                puts("LESS");
                return 0;
            }
        }
        puts("EQUAL");
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long start = System.currentTimeMillis();

    int N = 26;
    int D = scanner.nextInt();
    int[] c = new int[N];
    int[][] s = new int[D][N];
    for (int i = 0; i < N; i++) c[i] = scanner.nextInt();
    for (int i = 0; i < D; i++) for (int j = 0; j < N; j++) s[i][j] = scanner.nextInt();
    int[] t = new int[D];

    int score = 0;
    List<Integer>[] last = new List[N];
    for (int i = 0; i < N; i++) {
      last[i] = new ArrayList<>();
      last[i].add(0);
    }
    for (int d = 0; d < D; d++) {
      int type = -1;
      int max = -36500 * 26;
      for (int i = 0; i < N; i++) {
        int ss = s[d][i];
        for (int j = 0; j < N; j++)
          if (j != i) ss -= c[j] * (d + 1 - last[j].get(last[j].size() - 1));
        if (ss > max) {
          max = ss;
          type = i;
        }
      }
      t[d] = type;
      last[type].add(d + 1);
      score += max;
    }
    for (int i = 0; i < N; i++) last[i].add(D + 1);

    Random rand = new Random();
    while (System.currentTimeMillis() - start < 1800) {
      int d = rand.nextInt(D) + 1;
      int oldType = t[d - 1];
      int newType = rand.nextInt(N);
      int newScore = update(c, s, t, score, last, d, newType);
      if (newScore > score) {
        score = newScore;
        t[d - 1] = newType;
        int p1 = upperBound(last[newType], d);
        int p2 = upperBound(last[oldType], d);
        last[oldType].remove(p2 + 1);
        last[newType].add(p1 + 1, d);
      }
    }

    for (int i = 0; i < D; i++) {
      System.out.println(t[i] + 1);
    }
  }

  private static int update(int[] c, int[][] s, int[] t, int score, List<Integer>[] last, int d,
      int newType) {
    int oldType = t[d - 1];
    int p1 = upperBound(last[newType], d);
    int p2 = upperBound(last[oldType], d);
    score += s[d - 1][newType] - s[d - 1][oldType];
    score += c[newType] * (d - last[newType].get(p1)) * (last[newType].get(p1 + 1) - d)
        - c[oldType] * (d - last[oldType].get(p2)) * (last[oldType].get(p2 + 2) - d);
    return score;
  }

  public static int upperBound(List<Integer> a, int k) {
    int left = -1;
    int right = a.size();
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a.get(mid) < k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }
}


Measured memory_bytes: 39288
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  RSQ:Range Sum Query
  segment tree を利用
  https://www.youtube.com/watch?v=ReGvflPU81c&list=PL3Hpv03CoZ24p5a6qT0LsFKEhiDWxf_B_&index=4
*/

#define SEG_LEN (1 << 18) //10^5 より大きい２進数, index = 1から利用する．
int seg[SEG_LEN * 2];

void add(int ind, int x){
  ind += SEG_LEN;
  seg[ind] += x;
  while(true){
    ind /= 2;
    if(ind == 0) break;
    seg[ind] = seg[ ind * 2 ]+seg[ ind * 2 + 1 ];
  }

}

int sum(int l, int r){
  l += SEG_LEN;
  r += SEG_LEN;
  int ans = 0;
  while(l < r){
    if(l%2 == 1){
      ans += seg[l];
      l++;
    }
    l /= 2;

    if(r%2 == 1){
      ans += seg[r - 1];
      r--;
    }
    r /= 2;
  }
  return ans;
}

int main(){
  int n, q;
  cin >> n >> q;

  REP(i,q){
    int com;
    cin >> com;
    if(com == 0){//add
      int ind, x;
      cin >> ind >> x;
      add(ind, x);
    }

    if(com == 1){//get sum
      int l,r;
      cin >> l >> r;
      cout << sum(l,r+1) << endl;

    }
  }


  return 0;
}



Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MAXN 200000

/*
Consider N is odd. Solution for N is even is similar.

Assume the ranges are sorted based in non-decreasing order of A.
The minimal value for the median must be A[(N + 1)/2].
If it is smaller than this, then there will be too many larger than the median.

To find the maximum value for the median, we can do binary search.
Assume the maximal value is mid. There must be at most (N + 1)/2 - 1 numbers that is surely smaller than mid.
i.e, the number of ranges that ends before mid must be at most (N + 1)/2 - 1.
*/

int N, suffixMinB[MAXN + 3];
pair<int, int> ranges[MAXN + 3];

//find a number such that there are at most 'threshold' number that is surely smaller than it
int upper(int starting, int threshold) {
    int lo = starting, hi = INF, mid;
    while (hi >= lo) {
        mid = (lo + hi)/2;

        int smaller = 0;
        for (int i = 1; i <= N; i++) {
            if (ranges[i].second < mid)
                smaller += 1;
        }

        if (smaller > threshold)
            hi = mid - 1;
        else
            lo = mid + 1;
    }

    return hi;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++)
        scanf("%d%d", &ranges[i].first, &ranges[i].second);

    sort(ranges + 1, ranges + N + 1);

    suffixMinB[N] = ranges[N].second;
    for (int i = N - 1; i >= 1; i--)
        suffixMinB[i] = min(ranges[i].second, suffixMinB[i + 1]);

    if (N%2 == 1) {
        int smallest = ranges[(N + 1)/2].first;
        int largest = upper(smallest, (N + 1)/2 - 1);

        printf("%d\n", largest - smallest + 1);
    } else {
        int l1 = ranges[N/2].first;
        int r1 = upper(l1, N/2 - 1);
        int l2 = ranges[N/2 + 1].first;
        int r2 = upper(l2, N/2);

        printf("%d\n", (r1 + r2) - (l1 + l2) + 1);
    }
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  cin >> a >> b >> c;

  if ((a * 100 + b * 10 + c) % 4 == 0)
    YES();

  else
    NO();
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
    int n;
    scanf("%d",&n);
    int a,b;
    int i;
    scanf("%d %d",&a,&b);
    int x = a;
    int y = b -a;
    for(i=0;i<=y;i++){
        if(x%n==0){
            printf("OK");
            return 0;
        }
        x = x + 1;
    }
        
    printf("NG");
    return 0;
}


Measured memory_bytes: 1732