akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B; cin >> A >> B;
	int N[3] = { 1,2,3 };
	rep(i, 3) {
		if (N[i] != A && N[i] != B)cout << N[i] << "\n";
	}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

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


	/*int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k)cout << s;
	else {
		rep(i, k) {
			cout << s[i];
		}
		cout << "...";
	}*/


	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double sita = ((h + m / 60) / 12 - m / 60) * 2 * acos(-1);
	double ans = sqrt(a * a + b * b - 2 * a * b * cos(sita));
	printf("%.9f", ans);
	return 0;
}

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

int main(){
	int height[3] = {0},input;
	for(int i=0;i<10;i++){
		cin >> input;
		for(int j=0;j<3;j++){
			if(height[j] < input){
				for(int k=2;k>j;k--)
					height[k] = height[k-1];
				height[j] = input;
				break;
			}
		}
	}
	for(int i=0;i<3;i++)
		cout << height[i] <<endl;
}

Measured memory_bytes: 1160
#include<cstdio>

using namespace std;



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

int main(){
    long int a, b;
    scanf("%ld %ld", &a, &b);
    long int c = gcd(a, b);
    long int i = 2;
    int ans = 0;
    while (c != 1 and i <= 1000000){
        bool flag = true;
        while (c % i == 0){
            c /= i;
            if (flag){
                ans++;
                flag = false;
            }
        }
        i++;
    }
    if (c != 1) ans++;
    printf("%d\n", ans + 1);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;
using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size() + 1;
    vector<int64> v(n,0);
    int64 now = 0;
    for (int i=1; i<n; i++) {
        if (s[i-1] == '>') continue;
        now = 0;
        while(i<n && s[i-1]=='<') v[i++] = ++now;
    }

    reverse(s.begin(), s.end());
    reverse(v.begin(), v.end());
    for (int i=1; i<n; i++) {
        if (s[i-1] == '<') continue;
        now = 0;
        while(i<n && s[i-1]=='>') {
            v[i] = max(v[i], ++now);
            i++;
        }
    }

    int64 ans = accumulate(v.begin(), v.end(), 0LL);
    cout << ans << endl;
}


Measured memory_bytes: 4728
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
ll a[200000], b[200000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
void ShowData(ll x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%lld  ", x[i]);
	printf("\n");
}
void hSwap(ll x[], int i, int j)
{
	ll temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void QSort2(ll x[], ll y[], int left, int right, int n) {
	int i, j;	//左端,右端
	ll pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		hSwap(y, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort2(x, y, left, i - 1, n);
	if (j + 1 <  right)QSort2(x, y, j + 1, right, n);
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int ng = (n - 1)*(n - 2) / 2;
	if (k > ng) {
		puts("-1");
		return 0;
	}

	int m = n - 1 + (ng - k);

	PRINTD(m);
	REPS(i, n - 1) {
		printf("1 %d\n", i + 1);
		m--;
	}

	FOR(i, 2, n) {
		FOR(j, i + 1, n + 1) {
			if (m == 0)break;
			printf("%d %d\n", i, j);
			m--;
		}
		if (m == 0)break;
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100010
 
int main(){
    int N,W,H;
    int X[MAX],Y[MAX];
    for(int i = 0 ; i < MAX ; i++){
	X[i] = Y[i] = 0;
    }
    cin >> N >> W >> H;
    for(int i = 0 ; i < N ; i++){
	int x,y,w;
	cin >> x >> y >> w;
	X[max(0,x-w)]++;
	Y[max(0,y-w)]++;
	X[min(W,x+w)]--;
	Y[min(H,y+w)]--;
    }
    for(int i = 0 ; i < W ; i++){
	X[i+1] += X[i];
    }
    for(int i = 0 ; i < H ; i++){
	Y[i+1] += Y[i];
    }
    bool can = false, f = true;
    for(int i = 0 ; i < W ; i++){
	if(X[i] == 0){
	    f = false;
	    break;
	}
    }
    can |= f; f = true;
    for(int i = 0 ; i < H ; i++){
	if(Y[i] == 0){
	    f = false;
	    break;
	}
    }
    can |= f;
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
long long  n,i,b[1000006],x;
int main()
{
    
    cin>>n;

    for(i=1;i<n;i++)
    {
        cin>>x;
        b[x]++;
    }
   
    for(i=1;i<=n;i++)
    {
        cout<<b[i]<<"\n";
    }
}

Measured memory_bytes: 5112
#include<cstdio>
#include<algorithm>
#include<iterator>

int s[100000];
int dp[100000];

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

	std::fill_n(dp, n, 1e9);
	for (int i = 0; i < n; i++) {
			*std::lower_bound(dp, dp + n, s[i])=s[i];
	}
	
	printf("%d\n", std::distance(dp, std::lower_bound(dp,dp+n,1e9)));
}


Measured memory_bytes: 3468
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int n,ans=0,sum=0;
    cin>>n;
    vector<int>a(10000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-2;i++){
        if(a[i]<a[i+1]&&a[i+1]<a[i+2]){
            ans++;
        }
        else if(a[i]>a[i+1]&&a[i+1]>a[i+2]){
            ans++;
        }
    }
    cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 39296
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    yn(a + b == c || b + c == a || c + a == b);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
string c;
cin>>c;
const string vowel ="aeiou";
if(vowel.find(c)!=string::npos) cout<<"vowel"<<endl;
else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;

int main(){
	int N,M;
	int i,j;
	bool flag=0,flag2=0;
	char A[50][51],B[50][51];
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++){
		scanf("%s",A[i]);
	}
	for(i=0;i<M;i++){
		scanf("%s",B[i]);
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(A[i][j]==B[0][0]){
				flag=0;
				for(int k=0;k<M;k++){
					for(int l=0;l<M;l++){
						if(i+k>=N || j+l>=N) {
							flag=1;
							k=M;
							break;
						}
						else if(A[i+k][j+l]!=B[k][l]){
							flag=1;
							k=M;
							break;
						}
					}
				}
				if(flag==0) flag2=1;
			}
		}
	}
	if(flag2==1) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N,X;
	cin >> N >> X;
	if(X == 1 || X == N*2-1) cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		if(N == 2) cout << 1 << endl << 2 << endl << 3 << endl;
		else if(N == 3){
			vector<int> tmp;
			tmp.push_back(0);
			for(int i=0; i<N*2-1; i++) tmp.push_back(i+1);
			if(X == 2){
				tmp[1] = 5;
				tmp[2] = 3;
				tmp[3] = 2;
				tmp[4] = 1;
				tmp[5] = 4;
			}
			else if(X == 4){
				tmp[1] = 1;
				tmp[2] = 3;
				tmp[3] = 4;
				tmp[4] = 5;
				tmp[5] = 2;
			}
			else if(X == 3){
				tmp[1] = 1;
				tmp[2] = 2;
				tmp[3] = 3;
				tmp[4] = 4;
				tmp[5] = 5;
			}
			for(int i=1; i<=N*2-1; i++) cout << tmp[i] << endl;
		}
		else{
			vector<int> tmp;
			tmp.push_back(0);
			for(int i=0; i<N*2-1; i++) tmp.push_back(i+1);
			if(X == 2){
				swap(tmp[3],tmp[N-1]);
				swap(tmp[2],tmp[N]);
				swap(tmp[1],tmp[N+1]);
				swap(tmp[4],tmp[N+2]);
			}
			else{
				swap(tmp[X-2],tmp[N-1]);
				swap(tmp[X],tmp[N]);
				swap(tmp[X+1],tmp[N+1]);
				swap(tmp[X-1],tmp[N+2]);
			}
			for(int i=1; i<=N*2-1; i++) cout << tmp[i] << endl;
		}
	}

	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;


int main(){

    int n;
    cin >> n;
    vector<int> a(2*n);
    rep(i, 2*n) scanf("%d", &a[i]);
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, n) ans += a[2*i];
    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;

  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}


void Poor3()
{
  int a, b, c;

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


void Algae()
{
  int r, d, x;
  
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++)
  {
    x = r * x - d;
    cout << x << endl;
  }
}


void cross81()
{
  int n;
  int flag = 0;

  cin >> n;
  for (int i = 1; i < 10; i++)
  {
    for (int j = 1; j < 10; j++)
    {
      if (n == i * j)
      {
        flag = 1;
        cout << "Yes" << endl;
        break;
      }
    }
    if (flag) break;
  }
  if(!flag) cout << "No" << endl;
}


void bite_eating()
{
  int n, l;
  int taste[200];
  int sum = 0, ans_sum = 0;
  int diff = 100;

  cin >> n >> l;
  for (int i = 0; i < n; i++)
  {
    taste[i] = l + i;
    sum += taste[i];
  }
  for (int i = 0; i < n; i++)
  {
    if(std::abs(diff) > std::abs(taste[i])) diff = taste[i];
  }
  ans_sum = sum - diff;
  cout << ans_sum << endl;

}
int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  //SvsM();
  //Poor3();
  //Algae();
  //cross81();
  bite_eating();
}

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

using namespace std;

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    double rad = 180 / M_PI;
    double a, b, x, s, p;
    cin >> a >> b >> x;
    if (x <= a * a * b / 2) {
        s = x / a;
        p = s * 2 / b;
        double ans = atan(b / p);
        cout << ans * rad << endl;
    } else {
        double air = a * a * b - x;
        s = air / a;
        p = s * 2 / a;
        double another = a / p;
        double ans = 90.0 - (atan(another));
        cout << 90.0 - ((90.0 - ans) * rad) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

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

    ll n, m;
    cin>>n>>m;
    ll a[n+1]={0};
    loop(i,0,m){
        ll l, r;
        cin>>l>>r;
        a[l]++;
        a[r+1]--;
    }

    ll ps[n+1];
    ps[0] = 0;
    loop(i,1,n+1){
        ps[i] = ps[i-1] + a[i];
    }
    ll cnt=0;
    loop(i,1,n+1){
        if(ps[i]==m){
            cnt++;
        }
    }
    print(cnt);
    
}



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

using namespace std;

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

    int N, X; cin>>N>>X;
    vector<int> L(N);
    for (auto& l : L) cin>>l;
    int pos = 0;
    int ans = 0;
    while (pos <= X and ans < N) {
        pos += L[ans];
        ans++;
    }
    if (pos <= X)
        ans++;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
"""

AtCoder Beginner Contest 157  D - Friend Suggestions


友達関係でUnionを作る。そのUnion内で、友達関係でも、Union内のブロック関係でもないものが友達候補
なので、
・友達関係でUnionFindでUnion化し、
・それぞれのUnionに所属する人数を調べて、自分を除く所属人数を友達候補の候補（変な表現だが）として、
・自分と友達関係の個数＆おなじUnionかつブロック関係の個数を引く
でOK

"""

class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1

N,M,K = map(int, input().split())

friends = []
for _ in range(M):
    a,b = map(int, input().split())
    friends.append((a-1,b-1))

blocks = []
for _ in range(K):
    c,d = map(int, input().split())
    blocks.append((c-1,d-1))

uf = UnionFind(N)

for a,b in friends:
    if not uf.is_same(a,b):
        uf.unite(a,b)

ans = [0] * N


# i番目のUnionの人数
members = [0] * N
for i in range(N):
    members[uf.root(i)] += 1

for i in range(N):
    # iの人が所属するUnionの人数（i本人を除く）をもっておいて、ここから友達関係と、おなじUnionのブロック関係を除く
    ans[i] = members[uf.root(i)] - 1

# 友達関係にある人は同じUnionかつ、友達候補になりえないから除く
for a,b in friends:
    ans[a] -= 1
    ans[b] -= 1

# ブロック関係にあるc,dが、もし同じUnionであれば友達候補になりえないので除く
for c,d in blocks:
    if uf.is_same(c,d):
        ans[c] -= 1
        ans[d] -= 1


print(*ans)


Measured memory_bytes: 38700
N = int(input())
A = list(map(int, input().split()))

cumsum = [0]
for i in range(N):
    cumsum.append(cumsum[-1] + A[i])

tmp_x = -1
tmp_x_diff = -1
for i in range(N - 1):
    sum1 = cumsum[i + 1]
    sum2 = cumsum[-1] - cumsum[i + 1]
    diff = abs(sum2 - sum1)
    if tmp_x_diff == -1 or diff < tmp_x_diff:
        tmp_x = i
        tmp_x_diff = diff
print(tmp_x_diff)


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

int main(){
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> arf(26);
  for(int i=0; i<n; ++i){
    arf[s[i]-'a'].insert(i);
  }
  for(int i=0; i<q; ++i){
    int q1;
    cin >> q1;
    if(q1 == 1){
      int q2;
      char q3;
      cin >> q2 >> q3;
      --q2;
      arf[s[q2]-'a'].erase(q2);
      s[q2] = q3;
      arf[q3-'a'].insert(q2);
    }else{
      int q2, q3;
      cin >> q2 >> q3;
      --q2;
      int ans = 0;
      for(int j=0; j<26; ++j){
        auto it = arf[j].lower_bound(q2);
        if(it != arf[j].end() && *it < q3) ++ans;
      }
      printf("%d\n",ans);
    }
  }
}


Measured memory_bytes: 27256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[n];
		for(int i=0; i<n; i++) a[i]=sc.nextLong();
		final int MAX = 30;
		int r=0;
		long ans = 0;
		boolean f[] = new boolean[MAX];
		for(int l=0; l<n; l++) {
			if(l>0) {
				for(int i=0; i<MAX; i++) {
					if((a[l-1]>>i&1)==1) {
						f[i]=false;
					}
				}
			}
			while(r<n) {
				boolean ok=true;
				for(int i=0; i<MAX; i++) {
					if((a[r]>>i&1)==1) {
						if(f[i]) {
							ok=false;
							break;
						}
					}
				}
				if(ok) {
					for(int i=0; i<MAX; i++) {
						if((a[r]>>i&1)==1) {
							f[i]=true;
						}
					}
					r++;
				}else {
					break;
				}
			}
			ans += r-l;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 87684
#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 <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int D;
double V[16];

// n,Eを使わないで補完した時,f(n)を返す
double interpolate(int n, int E) {
    double sum = 0;
    for (int i = 0; i < D+3; i++) {
        if (i == n || i == E) continue;
        double p = V[i];
        for (int j = 0; j < D+3; j++) {
            if (j == i || j == n || j == E) continue;
            p = p * (double)(n-j) / (double)(i-j);
        }
        sum += p;
    }
    return sum;
}

bool outlier(int E) {
    for (int i = 0; i < D+3; i++) {
        if (i == E) continue;
        double p = interpolate(i, E);
        if (abs(p-V[i]) > 0.1) return false;
    }
    return true;
}

int main(void) {
    while (cin >> D && D) {
        for (int i = 0; i < D+3; i++) cin >> V[i];
        for (int i = 0; i < D+3; i++) {
            if (outlier(i)) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1240
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
arr=arr.map(v=> v.replace(".","")).map(Number);
var a=[];
for(var i=0;i<=4000;i++)a[i]=0;
arr.forEach(v=> a[v]++);
var ans=[];
var s=[];
s[0]=a[0];
for(var i=1;i<=4000;i++)s[i]=s[i-1]+a[i];
arr.forEach(v=>{
   var point=0;
   point+=a[v]-1;
   if(v!=0)point+=s[v-1]*3;
   ans.push(point);
});
console.log(ans.join("\n"));


Measured memory_bytes: 49532
x=int(input())
b=0;
lst=[]
acs=0
was=0
res=0
tles=0
while(b<x):
    new=input()
    lst.append(new)
    b+=1
for c in lst:
    if(c=='AC'):
        acs+=1
    if(c=='WA'):
        was+=1
    if(c=='RE'):
        res+=1
    if(c=='TLE'):
        tles+=1
print('AC x '+str(acs))
print('WA x '+ str(was))
print('TLE x ' +str(tles))
print('RE x ' +str(res))  

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
const int  MOD = 1e9 + 7;
const int  N = 1e5 + 7;
ll dp[105][N] , we[105] , v[105];


//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    int n , w;
    cin>>n>>w;
    for(ll i = 1 ; i <= n ; i++){
        cin>>we[i]>>v[i];
    }
    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 1 ; j <= w ; j++){
            dp[i][j] = dp[i-1][j];
            if(j >= we[i]) dp[i][j] = max(dp[i][j] , dp[i-1][j-we[i]] + v[i]);
        }
    }

    cout<<dp[n][w]<<endl;


    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

using namespace std;

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

    ll perimeter, houses;

    cin>>perimeter>>houses;
    vector<ll> distances(houses);
    vector<ll> newDistances(houses);


    for(ll i=0;i<houses; ++i)
    {
        cin >> distances[i];
    }

    for(ll i=1;i<houses; ++i)
    {
        newDistances[i-1] = distances[i]-distances[i-1];
    }

    newDistances[houses-1] = perimeter - distances[houses-1] + distances[0];

    ll maxDist = 0;

    for(const auto& d : newDistances)
    {
        maxDist = max(maxDist, d);
    }

    ll sum = std::accumulate(newDistances.begin(), newDistances.end(), 0);

    cout<< sum - maxDist<<'\n';

    return 0;
}

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

template <typename T>
class fenwick_tree {
	const int n;
	vector<T> data;
public:
	fenwick_tree(int n_) : n(n_), data(n + 1) {}
	T find(int p) const {
		T res = 0;
		while (p > 0) {
			res += data[p];
			p -= p & -p;
		}
		return res;
	}
	T find(int l, int r) const {
		return find(r) - find(l);
	}
	void add(int p, T val) {
		++p;
		while (p <= n) {
			data[p] += val;
			p += p & -p;
		}
	}
};

int main()
{
	int n;
	cin >> n;
	vector<pair<ll, int>> sp(n);
	vector<ll> l(n);
	for (int i = 0; i < n; i++) {
		sp[i].second = i;
		cin >> sp[i].first;
		if (0 <= i - 1) sp[i].first += sp[i - 1].first;
	}
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(sp.begin(), sp.end() - 1);
	bool ng = false;
	vector<pair<int, int>> all;
	for (int i = 0; i < n; i++) {
		if ((i ? sp[i].first - sp[i - 1].first : sp[i].first) < l[i]) {
			ng = true;
			break;
		}
		if (i + 1 < n) all.emplace_back(sp[i].second, i);
	}
	if (ng) {
		cout << -1 << endl;
		return 0;
	}
	sort(all.begin(), all.end());
	ll res = 0;
	fenwick_tree<int> ft(n);
	for (auto p : all) {
		res += ft.find(p.second, n);
		ft.add(p.second, 1);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 6348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            String s = sc.next();
            Map<Character, Integer> m = new HashMap<>();

            for (int i = 0; i < s.length(); i++) {
                if (m.containsKey(s.charAt(i)))
                    m.put(s.charAt(i), m.get(s.charAt(i))+1);
                else
                    m.put(s.charAt(i), 1);
            }
            if (m.keySet().size() != 2) {
                System.out.println("No");
                return;
            } else {
                if (m.values().stream().filter(x -> x == 2).toArray().length != 2)
                    System.out.println("No");
                else
                    System.out.println("Yes");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 26708
def exchange(a, b, c):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        return 0

    if a == b == c:
        return -1

    return exchange((b + c) / 2, (c + a) / 2, (a + b) / 2) + 1


def main():
    a, b, c = map(int, input().split())

    ans = exchange(a, b, c)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61916
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
int k;
string s;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> k >>s;
	int a=s.length();
	for (int i=0;i<a;i++)
    {   if (i>=k){cout<<"...";break;}
        cout<<s[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 3668
#include<stdio.h>
int main(void){
	int x,y,r;
	int tmp;
	scanf("%d",&x);
	scanf("%d",&y);
	
	if(x<y){
    		tmp=x;
    		x=y;
    		y=tmp;
 	}

	r=x%y;
	while(r!=0){
		x=y;
		y=r;
		r=x%y;
	}
	
	printf("%d\n",y);
	
	return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    vector<int> B(N-1,0);
    for(int i=0;i<N-1;++i) cin >> B[i];

    A[0] = B[0];
    for(int i=0;i<N-2;++i){
        A[i+1] = min(B[i],B[i+1]);
    }
    A[N-1]=B[N-2];
    int sum=0;
    for(int i=0;i<N;++i){
        sum += A[i];
    }
    
    cout << sum << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;



int main ()
{
  prep();
  int n, m;
  cin >> n >> m;
  int cor = 0;
  int pen = 0;
  bool ac[100001] = {false};
  int was[100001] = {0};
  for (int i=0; i<m; i++){
      int p;
      string ans;
      cin >> p >> ans;
      if (ans == "AC" && !ac[p]){
          ac[p] = true;
          cor++;
      }
      if (!ac[p] && ans == "WA"){
          pen++;
          was[p]++;
      }
  }
  for (int i=1; i<=n; i++){
      if (!ac[i]){
          pen -= was[i];
      }
  }
  cout << cor << " " << pen;
  return 0; 
}

Measured memory_bytes: 768
N,K = map(int,input().split())

M = 10**9+7

ans = 0
for i in range(K,N+2):
    saidai = i*(N-i+1+N)//2
    saisyo = i*(i-1)//2
    ans += saidai - saisyo + 1

print(ans%M)

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B;
signed main() {
    cin >> A >> B;
    if (A < 10 && B < 10) { cout << A * B << endl; }
    else { cout << -1 << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,h,w;

int main(){
	cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
}

Measured memory_bytes: 256
p (a=$<.drop(1).group_by { |s| s.chars.first }.select { |k,_| ["M","A","R","C","H"].include?(k) }.map{ |k, v| [k, v.length]}.to_h).keys.combination(3).inject(0) { |acc, (x,y,z)| acc+a[x]*a[y]*a[z] }


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

using namespace std;

typedef unsigned long ul;

// x以下の整数の排他的論理和
ul F(ul x) {
  if (x % 4 == 3) {
    return 0;
  } else if (x % 4 == 1) {
    return 1;
  } else if (x % 4 == 2) {
    return x + 1;
  } else {
    return x;
  }
}

int main()
{
  ul A, B; cin >> A >> B;
  cout << (F(A-1) ^ F(B)) << endl;
}

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

bool solve(const vector<int> &a, int x) {
    deque<int> b;
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] >= x) b.push_back(1);
        else b.push_back(0);
    }
    b.push_front(b[0]);
    b.push_back(b.back());

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

    int mid = b.size() / 2;
    int left, right;
    for (int i = mid - 1; i >= 0; --i) {
        if (b[i] == b[i+1]) {
            left = i;
            break;
        }
    }
    for (int i = mid + 1; i  < b.size(); ++i) {
        if (b[i-1] == b[i]) {
            right = i;
            break;
        }
    }

    // cout << x << ": " << left << ", " << right << endl;
    
    if (right - mid >= mid - left) return b[left];
    else return b[right];
}

int main() {
    int N, K; cin >> N;
    vector<int> a(N * 2 - 1);
    for (int i = 0; i < N * 2 - 1; ++i) cin >> a[i];

    int low = 0, high = N*2;
    while (high - low > 1) {
        int mid = (high + low) / 2;
        if (solve(a, mid)) low = mid;
        else high = mid;
    }
    cout << low << endl;
}


Measured memory_bytes: 1904
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	ll w,h,x,y;
	cin>>w>>h>>x>>y;

	cout<<double(w)*double(h) / 2 <<" "<< (x+x == w and y + y == h)<<endl;	

	return 0;
}

Measured memory_bytes: 3768
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans;

int main() {
	//freopen("x.in", "r", stdin);
	string s;
	cin >> s >> k;
	n = SZ(s);
	F0(i, n - 1) if (s[i] != 'a') {
		int needed = 'z' - s[i] + 1;
		if (needed <= k) {
			s[i] = 'a';
			k -= needed;
		}
	}
	int i = n - 1;
	s[i] = (((s[i] - 'a') + k) % 26) + 'a';
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 640
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

minus = [0] * N
plus = [0] * N

for i in range(N):
    minus[i] = (i + 1) - A[i]
    plus[i] = (i + 1) + A[i]

count = Counter(minus)
most = count.most_common()
num = len(most)

countPP = Counter(plus)
#mostPP = countPP.most_common()
#check = mostPP[:][0]
ans = 0

for i in range(num):
    elm = most[i]
    fir = elm[0]
    sec = elm[1]
    # if (fir in check):

    aa = countPP[fir]
    #    print(aa)
    ans += aa * sec

    # try countPP[tar]:

print(ans)


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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
const long long Mod = 1e9 + 7;
long long n,a,b;
long long power(long long a,long long n)
{
    if(n==0)
        return 1;
    if(n&1)
        return a*power(a*a%Mod,n/2)%Mod;
    return power(a*a%Mod,n/2);
}
long long Nck(long long n,long long k)
{
    long long ans=1;
    long long G = 1;
    for(int i=1;i<=k;i++)
    {
        ans = ans * (n-i+1) %Mod;
        G = G * i % Mod;
    }
    ans = ans * power(G,Mod-2) % Mod;
    return ans;
}
int main()
{
    cin>>n>>a>>b;
    long long ans = power(2,n)-1;
    ans = ans - Nck(n,a);
    ans = (ans + Mod*Mod) % Mod;
    ans -= Nck(n,b);
    ans = (ans + Mod*Mod) %Mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A == B){
  	cout << C << endl;
  }else if(A == C){
  	cout << B << endl;
  }else{
  	cout << A << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
total = (n - 1) // 2
if n % 2 == 0:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[-total+div-1] = a[i]
        else:
            b[total-div] = a[i]
else:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[total - div] = a[i]
        else:
            b[-total+div] = a[i]

for i in range(n):
    print(b[i], end=' ')

Measured memory_bytes: 26180
#include <stdio.h>

int main(void) {
int a, b;

while (1) {
	scanf ("%d %d", &a, &b);
	if (a+b == 0)
		break;
	if (a<b) {
		printf("%d %d\n", a, b);
	} else {
		printf("%d %d\n", b, a);
	}

}

return 0;
}

Measured memory_bytes: 600
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std;

int main() {
  int A, B, C, D;
  string temp;
  cin >> temp;
  A             = temp[0] - '0';
  B             = temp[1] - '0';
  C             = temp[2] - '0';
  D             = temp[3] - '0';
  string parity = "+++";
  if (A + B + C + D == 7) {

  } else if (A - B + C + D == 7) {
    parity[0] = '-';

  } else if (A + B - C + D == 7) {
    parity[1] = '-';
  } else if (A + B + C - D == 7) {
    parity[2] = '-';
  } else if (A - B - C + D == 7) {
    parity[0] = '-';
    parity[1] = '-';
  } else if (A - B + C - D == 7) {
    parity[0] = '-';
    parity[2] = '-';
  } else if (A + B - C - D == 7) {
    parity[1] = '-';
    parity[2] = '-';
  } else {
    parity = "---";
  }
  cout << A << parity[0] << B << parity[1] << C << parity[2] << D << "=7" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		char [][]grid = new char[h][w];
		
		for(int i = 0 ; i < h ;i++) {
			String s = sc.next();
			for(int j = 0 ; j < w ;j++) {
				grid[i][j] = s.charAt(j);
			}
		}
		
		int ans = 0;
		
		for(int i = 0 ; i < Math.pow(2,h) ; i++) {
			for(int j = 0 ; j < Math.pow(2, w) ; j++) {
				int cnt = 0;
				for(int y = 0 ; y < h ;y++) {
					for(int x = 0 ; x < w ;x++) {
						if(((i>>y)&1)== 1 || ((j>>x)&1)== 1) {
							continue;
						}
						if(grid[y][x] == '#') {
							cnt++;
						}
					}
				}
				if(k == cnt) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);
		
		
	}
}


Measured memory_bytes: 35816
N, X, M = map(int, input().split())

a = X
count = 1
ai = [a]
mapping = [0 for i in range(10**5+1)]
mapping[a] = count
count += 1
for i in range(1, 10**5+1):
    a = (a ** 2 ) % M
    if mapping[a] == 0:
        ai.append(a)
        mapping[a] = count
    else:
        break
    count += 1
s = mapping[a]
e = mapping[ai[-1]]
loop = e - s + 1
# print(s, e, ai)
if N <= e:
    print(sum(ai[:N]))
else:
    syo = (N - e) // loop
    amari = (N - e) % loop
    loop_total = sum(ai[s-1:e])
    # print(loop_total * syo, sum(ai[s-1:s+amari-1]))
    ans = sum(ai) + loop_total * syo + sum(ai[s-1:s+amari-1])
    print(ans)
# print(s, e, syo, amari, loop_total)

Measured memory_bytes: 73528
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200001;
int n, e;
char s[N];
int has[N][2];
vector<multiset<int> > g;
int main()
{
	scanf("%d%d", &n, &e);
	scanf("%s", s);
	for (int i = 0; i < n; ++i)
		s[i] = s[i] == 'B';
	g.resize(n);
	for (int i = 0, a, b; i < e; ++i) {
		scanf("%d%d", &a, &b);
		--a; --b;
		++has[a][s[b]];
		g[a].insert(b);
		if (a == b)
			continue;
		swap(a, b);
		++has[a][s[b]];
		g[a].insert(b);
	}
	queue<int> q;
	vector<char> done(n);
	for (int i = 0; i < n; ++i)
		if (has[i][0] == 0 || has[i][1] == 0) {
			q.push(i);
			done[i] = true;
		}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for(auto x:g[u])
			if (x != u) {
				if (!done[x] && --has[x][s[u]] == 0) {
					q.push(x);
					done[x] = true;
				}
				g[x].erase(g[x].find(u));
			}
		g[u].clear();
	}
	for(auto &x:g)
		if (!x.empty()) {
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

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

using namespace std;
using ll = long long;

int a[3][3];
int color[3][3];
int locs[105];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(locs, -1, sizeof(locs));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) {
            cin>>a[i][j];
            locs[a[i][j]] = i*3+j;
        }

    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(locs[tmp]!=-1){
            color[locs[tmp]/3][locs[tmp]%3] = 1;
        }
    }
    for(int i=0;i<3;i++){
        int j;
        for(j=0;j<3;j++){
            if(!color[i][j]) break;
        }
        if(j==3){
            cout<<"Yes";
            return 0;
        }

        for(j=0;j<3;j++){
            if(!color[j][i]) break;
        }
        if(j==3){
            cout<<"Yes";
            return 0;
        }
    }

    int i;
    for(i=0;i<3;i++){
        if(!color[i][i]) break;
    }
    if(i==3){
        cout<<"Yes";
        return 0;
    }
    for(i=0;i<3;i++){
        if(!color[2-i][i]) break;
    }
    if(i==3){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";

    return 0;
}

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




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()-1) {
		if (s[i] == s[i + 1]) {
			if (s[i + 1] == '0')s[i + 1] = '1';
			else s[i + 1] = '0';
			ans++;
		}
	}
	cout << ans;
	return 0;
}










Measured memory_bytes: 512