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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int A, B;
    vector<int> a(3);

    cin >> A >> B;

    a[0] = A + B, a[1] = A - B, a[2] = A * B;

    cout << *max_element(ALL(a)) << endl;

    return 0;
}

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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define OF(i,a,b) for (int (i) = (a)-1; (i) >= (b); --(i))
#define SZ(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/



int main() {
    ll a,b,c;
    scanf ("%lld %lld %lld", &a, &b, &c);
    ll ans = (a-a/2-a/2)*b*c;
    ans = min (ans, (b-b/2-b/2)*a*c);
    ans = min (ans, (c-c/2-c/2)*a*b);
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i = 0; i < int(n); ++i)
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MAX 100000000
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>             vi;
typedef vector<ll>              vl;
typedef vector<pii>             vpii;
typedef vector<pl>              vpl;
typedef vector<vi>              vvi;
typedef vector<vl>              vvll;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//=====================================================================================================
// CODE

int main() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        char c; cin >> c;
        if (c >= 65 && c <= 90)cout << 'A';
        else if (c >= 97 && c <= 122)cout << 'a';
        return 0;
}

Measured memory_bytes: 3644
S = input()[::-1]
T = input()[::-1]
ns, nt = len(S), len(T)
ans = None
for i in range(ns-nt+1):
    _S = S[i:i+nt]
    f = True
    for s,t in zip(_S,T):
        if not (s=='?' or s==t):
            f = False
            break
    if f:
        ans = S[:i].replace('?', 'a')+T+S[i+nt:].replace('?', 'a')
        break
print("UNRESTORABLE" if not ans else ans[::-1])

Measured memory_bytes: 9148
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main() {
  int n;

  cin >> n;
  cin.ignore();
  
  for (int i=0; i<n; i++) {
    string str;
    const string from = "Hoshino";
    const string to = "Hoshina";
    
    getline(cin, str);
    
    string::size_type pos = str.find(from);
    while (pos != string::npos) {
      str.replace(pos, from.size(), to);
      pos = str.find(from, pos + to.size());
    }

    cout << str << endl;
  }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int X;cin>>X;
  for(int Y=X;;Y++){
    if(IsPrime(Y)){
      cout<<Y<<endl;break;
    }
  }
}

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

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

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    if(n%2==0){
        ll c5=0;
        ll p=n/2;
        while(p){c5+=p/5;p/=5;}
        ll c2=0;
        p=n/2;
        while(p){c2+=p/2;p/=2;}
        puta(min(c2, c5));
    }else puta(0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long double n, m, d;
  cin >> n >> m >> d;
  long double ans = (m - 1) * (n - d) / n / n;
  if (d != 0)
    ans *= 2;
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    vector<int> price(3); cin >> price[0] >> price[1] >> price[2];
    sort(price.begin(), price.end());

    cout << price[0]+price[1] << endl;

    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (a, b) = (line[0], line[1]);

    println!("{}", (a+b)%24);
}


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

int main(){
  int n; long c; cin >> n >> c;
  long x[n], v[n];
  long vsum[n+1];
  vsum[0] = 0;
  rep(i, n){
    cin >> x[i] >> v[i];
    vsum[i+1] = vsum[i] + v[i];
  }
  
  long score[n];
  score[n-1] = 0;
  for(int i=n-2; i>=0; i--) score[i] = max(score[i+1], vsum[n]-vsum[i+1]-(c-x[i+1]));
  long ans = 0;
  rep(i, n) ans = max(ans, vsum[i+1]-2*x[i]+score[i]);
  rep(i, n) ans = max(ans, vsum[i+1]-x[i]);
  
  score[0] = 0;
  for(int i=1; i<n; i++) score[i] = max(score[i-1], vsum[i]-x[i-1]);
  rep(i, n) ans = max(ans, vsum[n]-vsum[i]-2*(c-x[i])+score[i]);
  rep(i, n) ans = max(ans, vsum[n]-vsum[i]-(c-x[i]));
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	int n;
	cin >> n;
	int c1 = (n/500);
	c1 *= 1000;
	n %= 500;
	c1 += (n/5)*5;
	cout << c1;	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

int G[15][15];

signed main() {
	int N;
	cin >> N;
	vector<int> P(N), Q(N), v(N);

	rep(i, N) {
		cin >> P[i];
	}
	rep(j, N) {
		cin >> Q[j];
	}
	rep(i, N) {
		v[i] = i+1;
	}

	int a, b;
	int cnt = 1;

	do {
		bool samp = true;
		bool samq = true;

		rep(i, N) {
			if (v[i] != P[i]) {
				samp = false;
			}
			if (v[i] != Q[i]) {
				samq = false;
			}
		}

		if (samp) {
			a = cnt;
		}
		if (samq) {
			b = cnt;
		}
		cnt++;

	} while (next_permutation(ALLOF(v)));

	cout << abs(a - b) << "\n";

	return 0;
}

Measured memory_bytes: 3608
x,y=map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")


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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    int H,W;
    while(1<2){
    cin>>H>>W;
    if(H==0&&W==0)break;
    rep(y,H){
        rep(x,W){
        if((x+y)%2==0)cout<<"#";
        if((x+y)%2==1)cout<<".";
        }
        cout<<endl;
    }
    cout<<endl;
}
}





Measured memory_bytes: 3080
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a[]= {0,-1,0,1};
	static int b[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		K=sc.nextInt();
		for(int i=1;i<=K;i++) {
			if(i<10) {
				cc.add(i+"");
				continue;
			}else {
				dfs(cc.get(i-10));
			}
			if(cc.size()==K) {
				break;
			}
		}
		p(cc.get(K-1));
	}
	static ArrayList<String> cc=new ArrayList<>(10001);
	static int t[]={-1,0,1};
	
	//次のルンルン数を返す関数
	static void dfs(String s) {
		for(int a=0;a<3;a++) {
			if(s.charAt(s.length()-1)==48&&a==0) continue;
			if(s.charAt(s.length()-1)==57&&a==2) continue;
			String v=s+(s.charAt(s.length()-1)-48+t[a]);
			cc.add(v);
			if(cc.size()==K)break;
		}
		
	}
}


Measured memory_bytes: 45164
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


ll ceil_div(ll v, ll d)
{
	return (v+d-1)/d;
}

struct l_t
{
	int id;
	ll a, l, d;
};


bool div_next(l_t&v)
{
	ll x=ceil_div(v.a, v.d)-1;
	if(x<=0) return false;
	v.d=ceil_div(v.a, x);
	v.l=ceil_div(v.a, v.d);
	return true;
}


struct stree_t
{
	int n, base;
	vector<l_t> t;

	stree_t(int n) : n(n)
	{
		for(base=1;base<n;base*=2)
			;
		t.resize(base*2, l_t{0,0,-1,1});
	}
	void set_i(int x)
	{
		if(x<=0) return;
		if(t[x*2].l>t[x*2+1].l) t[x]=t[x*2];
		else t[x]=t[x*2+1];
		set_i(x/2);
	}
	ll set(int x)
	{
		int y=base+x;
		ll pd=t[y].d;
		if(!div_next(t[y])) return -1;
		set_i(y/2);
		return t[y].d-pd;
	}
	void set_1st(int x, ll a, ll d)
	{
		int y=base+x;
		t[y].id=x;
		t[y].a=a;
		t[y].d=d;
		t[y].l=ceil_div(a, d);
		set_i(y/2);
	}
	l_t get(void)
	{
		return t[1];
	}
};


struct solve
{
	solve(){}
	ll operator()(int n, ll k, vll&a) {
		ll a_sum=0;
		for(auto m:a) a_sum+=m;

		if(a_sum<=n+k) return 1;

		ll base=ceil_div(a_sum, k+1);
		stree_t st(n);
		for(int i=0;i<n;i++)
		{
			ll d=(a[i]-1)/base;
			st.set_1st(i, a[i], d+1);
			k-=d;
		}
		for(;k>0;)
		{
//cout << "k=" << k << "  ans=" << st.get().l << "\n";
			ll prev=st.get().l;
			ll d=st.set(st.get().id);
			k-=d;
			if(d<0 || k<0) return prev;
		}
		return st.get().l;
	}
};

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

	for(;;)
	{
		int n;
		ll k;
		cin >> n >> k;
		if(cin.fail()) break;
		vll a(n);
		for(auto&m:a) cin >> m;

		cout << solve()(n, k, a) << "\n";
	}
	return 0;
}


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

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

    int ans=0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            ans += d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define PI 3.14159265358979323846264338327950

int main(){
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double Aangle = double(60 * H + M) / 720 * 2 * PI;
    double Bangle = double(M) / 60 * 2 * PI;
    double rad = max(Aangle, Bangle) - min(Aangle, Bangle);

    double ans = sqrt( A * A + B * B - 2 * A * B * cos(rad) );

    printf("%.10f\n", ans);
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
int main(){
string z,x;
  cin>>z>>x;

  sort(z.begin(),z.end());
  sort(x.rbegin(),x.rend());
  if(z<x){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, ans;
	cin>>a>>b;
	int cur = 1, e = 1, i;
	ans = 0;
	while(e < b){
		for(i=0; i<e; i++){
			if(cur >= b) break;
			cur = cur - 1 + a;
			ans++;
		}
		e = cur;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a, b, c) = (
        iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap());
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5036
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

class Node
{
public:
    int location;
    int p, l, r;
    Node(){};
};

class Point
{
public:
    int id, x, y;
    Point(){}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < (const Point &p) const{
        return id<p.id;
    }

    void print(){
        printf("%d\n", id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N, np;
Point P[MAX];
Node T[MAX];
vector<Point> ans;

bool lessX(const Point &p1, const Point &p2)
{
    return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2)
{
    return p1.y < p2.y;
}

int makeKDTree(int l, int r, int depth)
{
    if(l==r) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    if(depth%2==0)
        sort(P+l, P+r, lessX);
    else
        sort(P+l, P+r, lessY);
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(mid+1, r, depth+1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans)
{
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if(sx<=x && tx>=x && sy<=y && ty>=y)
    {
        ans.push_back(P[T[v].location]);
    }

    if(depth%2==0)
    {
        if(T[v].l!=NIL && sx<=x)
        {
            find(T[v].l, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].r!=NIL && tx>=x)
        {
            find(T[v].r, sx, tx, sy, ty, depth+1, ans);
        }
    }
    else
    {
        if(T[v].l!=NIL && sy<=y)
        {
            find(T[v].l, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].r!=NIL && ty>=y)
        {
            find(T[v].r, sx, tx, sy, ty, depth+1, ans);
        }
    }
}
int main()
{
    int x, y, q;
    scanf("%d", &N);
    for(int i=0; i<N; i++)
    {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }
    np = 0;
    int root = makeKDTree(0, N, 0);
    int sx, sy, tx, ty;
    scanf("%d", &q);

    for(int i=0; i<q; i++)
    {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(int j=0; j<ans.size(); j++)
        {
            ans[j].print();
        }
        printf("\n");
        ans.clear();
    }
    return 0;
}



Measured memory_bytes: 16396
// a,bを決めてcをにぶたんする cを最長とする
// sort.Searchのせいで4時間くらいバグらせた （対処法不明
package main
import (
	"fmt"
	"sort"
)
func main(){
	var N int
	fmt.Scan(&N)
	L := make([]int, N)
	for i:=0; i<N; i++{
		fmt.Scan(&L[i])
	}
	sort.Ints(L)
	ans := 0
	for a:=0; a<N-2; a++{
		for b:=a+1; b<N-1; b++{
			// cを最長とおいたのでb以上（for的にL[b]>=L[a]なので）
			// searchIntsつかう
			c := sort.SearchInts(L, L[a]+L[b])
			if c > b{
				ans += (c-1-b)
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 2044
/*  ex4_3
    hangan2020 */

#include <stdio.h>

//プロトタイプ宣言
//T_a:Tower_a, T_b:Tower_b
int SnowDepth(int T_a, int T_b);

main(void){
    int T_a, T_b;
    int snowdepth;
    scanf("%d %d", &T_a, &T_b);
    //雪積りを計算する関数の実施
    snowdepth = SnowDepth(T_a, T_b);
    printf("%d\n", snowdepth );
    return 0;
}

int SnowDepth(int T_a, int T_b){
    int towerb_no, towerb_len;
    //towerb_no:塔の低いほうからの番号; towerb_len:塔の実際の高さ
    int snowdepth;
    //塔の高さは隣の低い塔の高さ足す自分の番号である。
    //高い塔(b)の番号を計算
    towerb_no = T_b - T_a;
    //高い塔の高さ
    towerb_len = (towerb_no*(1+towerb_no))/2;
    snowdepth = towerb_len - T_b;
    return(snowdepth);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	int res = 0;
	for(auto i = 0; i < n; ++ i){
		for(auto j = i + 1; j < n; ++ j){
			for(auto k = j + 1; k < n; ++ k){
				if(a[i] ^ a[j] && a[j] ^ a[k] && a[k] ^ a[i] && a[i] + a[j] + a[k] - max({a[i], a[j], a[k]}) > max({a[i], a[j], a[k]})){
					++ res;
				}
			}
		}
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    string s;
    cin >> s;
    bool hard=false;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]) hard= true;
    }
    if(hard) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


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

remind = []
for i in range(n):
   remind.append(input())

egaraList = ["S ", "H ", "C ", "D "]
for egara in egaraList:
   for j in range(1, 14):
      if egara + str(j) not in remind:
         print(egara + str(j))



Measured memory_bytes: 5592
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 0,cnt=0;
	int l = 0;
	rep(i, 0, n) {
		if (s[i] == '0') {
			if (i == 0 || s[i - 1] == '1') cnt++;
		}
		if (cnt > k) {
			while (s[l] == '1') l++;
			while (s[l] == '0') l++;
			cnt--;
		}
		ans = max(ans, i - l + 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define be(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)return 0;
        vector<int>a(n);
        REP(i,n)cin>>a[i];
        sort(a.begin(),a.end());
        vector<int>s(n-1);
        REP(i,n-1)s[i]=abs(a[i]-a[i+1]);
        sort(s.begin(),s.end());
        cout<<s[0]<<endl;
    }
}


Measured memory_bytes: 3152
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a  = sc.nextInt();
        int b = sc.nextInt();
        int n = a/k;
        while(n*k<=b){
            if(n*k>=a && n*k<=b){
                System.out.println("OK");
                return;
            }
            n++;
        }
        System.out.println("NG");
        return;
    }
}


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

int main() {
    queue<pair<string, int> > Q;
    int n, q; cin >> n >> q;
    for (int i = 0; i < n; i++) {
        string name; int t;
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    int elaps = 0;
    while (!Q.empty()) {
        pair<string, int> u = Q.front(); Q.pop();
        int a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0) {
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int n; cin >> n;
  	float ans;
  	if(n%2==0){
      ans=1.0/2.0;
    }else{
      ans = (n/2+1.0)/n;
    }
  	cout << setprecision(10) << ans << endl;
}

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

void testCase(){
    long long a, b, c, k;
    cin>>a>>b>>c>>k;
    long long sum = 0;
    if(k < a){
        sum = k;
    }
    else if(k <= a+b){
        sum = a;
    }
    else{
        sum = a;
        k -= (a+b);
        sum -= k;
    }
    cout<<sum<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 3676
L,R=map(int, input().split())

ans=2019
for i in range(L,R+1):
    for j in range(L,R+1):
        #print(i,j)
        if i==j:
            pass
        else:
            ans=min(ans,i*j%2019)
        if ans==0:
            print(ans)
            quit()
    
print(ans)

Measured memory_bytes: 3060
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
xy.sort()

if N==1:
  print(1)
  exit()

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Measured memory_bytes: 3700
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC103_A_Task_Scheduling_Problem
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] aArr = Console.ReadLine().Split(' ');
			List<int> aArrInt = new List<int>();

			for (int i = 0; i < aArr.Length; i++)
			{
				aArrInt.Add(int.Parse(aArr[i]));
			}

			aArrInt.Sort();
			aArrInt.Reverse();
			int result = 0;

			for (int i = 0; i < aArrInt.Count() - 1; i++)
			{
				result += aArrInt[i] - aArrInt[i + 1];
			}
			
			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n, m, x, ans = 0, sum = 0;
map<ll, ll> mp;

int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> x;
        sum = (sum+x)%m;
        if (sum == 0) ans++;
        mp[sum]++;
    }
    map<ll, ll>::iterator it;
    for (it = mp.begin(); it != mp.end(); it++){
        if (it->second > 1){
            x = it->second;
            ans += x*(x-1)/2;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4224
import itertools


def is_compatible(hyp, testimonies):
    return all([(key in hyp) == (val == 1) for key, val in testimonies.items()])


def is_compatible_all(hyp, all_testimonies):
    return all([is_compatible(hyp, all_testimonies[i]) for i in hyp])


def main():
    n = int(input())

    all_testimonies = [{}]
    for _ in range(n):
        ai = int(input())
        statements = {}
        for _ in range(ai):
            x, y = input().split()
            statements[int(x)] = int(y)
        all_testimonies.append(statements)

    for e in all_cases(n):
        if is_compatible_all(e, all_testimonies):
            print(len(e))
            return

    print(0)


def all_cases(n):
    for r in range(n, 0, -1):
        for ensemble in itertools.combinations(range(1, n + 1), r):
            yield set(ensemble)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::max;
use im_rc::HashSet;

fn main() {
    input! {
    n: usize,
    m: usize,
    a: [usize; m]
    }
    let set_a = a.into_iter().collect::<HashSet<usize>>();
    let p = 1_000_000_007;
    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    if !set_a.contains(&1) {dp[1] = 1}
    for i in 2..=n {
        if set_a.contains(&i){ continue }
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= p;
    }
    println!("{}", dp[n]);
}



Measured memory_bytes: 20308
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

bool ns[201];

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

    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        ns[p] = true;
    }

    int ans = -1;

    for (int i = 0; i <= 200; i++) {
        if (X - i >= 0 && !ns[X - i]) {
            ans = X - i;
            break;
        } else if (X + i <= 200 && !ns[X + i]) {
            ans = X + i;
            break;
        }
    }

    assert(ans >= 0 && ans <= 200);
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define fi first
#define se second
#define inf 1e9
const int mod=(int)1e9+7;
vector<int> adj[2005];
vector<int> vis(2005),dist(2005),ans(2005);

void bfs(int v){
	queue<int> q;
	q.push(v);
	vis[v]=1;
	dist[v]=0;
	while(!q.empty()){
		auto x=q.front();
		q.pop();
		for(auto u:adj[x]){
			if(vis[u])continue;
			q.push(u);
			dist[u]=dist[x]+1;
			vis[u]=1;
		}
	}
}

void test_case(){
	int n,x,y;
	cin>>n>>x>>y;
	--x,--y;
	for(int i=0;i<n-1;i++){
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
	adj[x].push_back(y);
	adj[y].push_back(x);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)vis[j]=0,dist[j]=0;
		bfs(i);
		for(int j=0;j<n;j++)ans[dist[j]]++;
	}
	for(int i=1;i<=n-1;i++)cout<<ans[i]/2<<"\n";
}

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


Measured memory_bytes: 384
read
d=0
e=0
for a in `dd`;do
 if [ $a -ge 3200 ];then
  e=$[e+1]
 else
  if [ $[c[a/400]] -eq 0 ];then
   d=$[d+1]
  fi
  : $[c[a/400]++]
 fi
done
echo $[d>0?d:1] $[d+e]

Measured memory_bytes: 3832
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = 10000000000000
for i in range(n-k+1):
    ans1 = abs(l[i]) + abs(l[i+k-1] - l[i])
    ans2 = abs(l[i+k-1]) + abs(l[i+k-1] - l[i])
    ans = min(ans, ans1, ans2)
print(ans)


Measured memory_bytes: 20044
import math
a,b,c=map(float,raw_input().split())
c = c / 180 * math.pi

print "%.10f" % float(a*b*math.sin(c)/2)
x = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(c))
print "%.10f" % float(a + b + x)
print "%.10f" % float(b*math.sin(c))

Measured memory_bytes: 4428
import collections

n = int(input())

nums = list(map(int, input().split()))

cnt = collections.Counter(nums)

def c2(n):
    return int(n * (n-1) / 2)

total = 0

for c in cnt.values():
    total += c2(c)

for i in range(n):
    d = cnt[nums[i]]
    diff = c2(d) - c2(d-1)
    print(total - diff)

Measured memory_bytes: 26780
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

int n, m;
vi cost;
vvi TREE;
vector<P> ans;

void dfs(int v = 0, int p = -1){ 
    for(auto u : TREE[v]){
        if(u == p) continue;
        dfs(u, v);
    }    
    // go back : v -> p
    if(p == -1) return;
    if(cost[v] % 2 == 0){
        ans.pb({p, v});
        cost[p]++;
    }else{
        ans.pb({v, p});
        cost[v]++;
    }
}

void Main(){
    cin >> n >> m;
    if(m % 2){
        cout << -1 << endl;
        return;
    }
    
    TREE.resize(n);
    cost.resize(n, 0);
    UnionFind UF(n); 

    rep(i, m){
        int a, b; cin >> a >> b; a--; b--;
        if(!UF.same(a, b)) {
            UF.unite(a, b);
            TREE[a].pb(b);
            TREE[b].pb(a);
        }else{
            // 全域木に入らない辺の向きを先に決める
            ans.pb({a, b});
            cost[a]++;
        }
    }
    
    dfs();
    for(auto [x, y] : ans){
        cout << x+1 << " " << y+1 << endl;
    }

    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/twosat>
//python3 ac-library/expander.py sol.cpp

int main(){
   int n,d; cin>>n>>d;
   vector<int> x(n),y(n);
   rep(i,0,n)cin>>x[i]>>y[i];
   atcoder::two_sat g(n*2);
   rep(i,0,n)g.add_clause(i,1,i+n,1);
   rep(i,0,n)rep(j,0,n)if(i!=j){
      if(abs(x[i]-x[j])<d){
         g.add_clause(i,0,j,0);
      }
      if(abs(y[j]-y[i])<d){
         g.add_clause(j+n,0,i+n,0);
      }
      if(abs(x[j]-y[i])<d){
         g.add_clause(j,0,i+n,0);
      }
      if(abs(y[j]-x[i])<d){
         g.add_clause(j+n,0,i,0);
      }
   }
   bool can=g.satisfiable();
   if(can){
      puts("Yes");
      auto res=g.answer();
      rep(i,0,n){
         if(res[i])cout<<x[i]<<endl;
         else cout<<y[i]<<endl;
      }
   }
   else puts("No");
   return 0;
}

Measured memory_bytes: 3776
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long x = in.nextLong();

            if (a == 0) {
                out.println(b / x + 1);
            } else {
                out.println(b / x - (a - 1) / x);
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}


Measured memory_bytes: 30548
#include <cassert>
#include <cstdio>
#include <vector>

using namespace std;

int
main()
{
    int N;
    assert(scanf("%d", &N) == 1);
    vector<int> trav[N];
    int M = N - 1;
    for (int i = 0; i < M; i++) {
        int n1, n2;
        assert(scanf("%d %d", &n1, &n2) == 2);
        trav[n1].push_back(n2);
        trav[n2].push_back(n1);
    }

    // If there is a branch and it has two or more leaves,
    // we need a antenna.
    vector<int> leafy_path(N, 0);
    for (int i = 0; i < N; i++) {
        // Find a tip of a leaf.
        if (trav[i].size() == 0)
            leafy_path[i] = 2;
        if (trav[i].size() != 1)
            continue;
        // Trace it to the branch point.
        int prev = i;
        int cur = trav[i][0];
        while (trav[cur].size() == 2) {
            if (trav[cur][0] == prev) {
                prev = cur;
                cur = trav[cur][1];
            } else {
                prev = cur;
                cur = trav[cur][0];
            }
        }
        // Count leafy path on the branch.
        if (trav[cur].size() == 1) {
            // Non-branching path is special.
            // Treat the yonger node as a branch point.
            if (i < cur)
                leafy_path[i] = 2;
        } else {
            leafy_path[cur]++;
        }
    }

    // Count the answer.
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (leafy_path[i] >= 2)
            ans += leafy_path[i] - 1;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 6528
import sys
input = sys.stdin.readline

def find_root(root, size, x):
    y = root[x]
    if y is None:
        root[x] = x
        size[x] = 1
        return x
    if x == y:
        return y
    z = find_root(root, size, y)
    root[x] = z
    return z


def merge(root, size, cnt, x, y):
    rx = find_root(root, size, x)
    ry = find_root(root, size, y)
    if rx == ry:
        return
    sx = size[rx]
    sy = size[ry]
    if sx > sy:
        root[ry] = rx
        size[rx] += sy
        cnt[rx] += cnt[ry]
    else:
        root[rx] = ry
        size[ry] += sx
        cnt[ry] += cnt[rx]
    return


def main():
    N = int(input())
    U = 10 ** 5
    root_x = [None] * (U + 1)
    root_y = [None] * (U + 1)
    size_x = [0] * (U + 1)
    size_y = [0] * (U + 1)
    cnt_x = [0] * (U + 1)
    cnt_y = [0] * (U + 1)
    x_to_y = [None] * (U + 1)
    y_to_x = [None] * (U + 1)

    for _ in range(N):
        x, y = map(int, input().split())
        rx = find_root(root_x, size_x, x)
        ry = find_root(root_y, size_y, y)
        cnt_x[rx] += 1
        cnt_y[ry] += 1
        if x_to_y[rx] is None:
            x_to_y[rx] = ry
        if y_to_x[ry] is None:
            y_to_x[ry] = rx
        merge(root_y, size_y, cnt_y, x_to_y[rx], ry)
        merge(root_x, size_x, cnt_x, y_to_x[ry], rx)
        x_to_y[root_x[rx]] = root_y[ry]
        y_to_x[root_y[ry]] = root_x[rx]

    ans = 0
    for x in range(1, U + 1):
        if root_x[x] is None:
            continue
        rx = find_root(root_x, size_x, x)
        if x != rx:
            continue
        y = x_to_y[x]
        ry = find_root(root_y, size_y, y)
        sx = size_x[rx]
        sy = size_y[ry]
        cnt = cnt_x[rx]
        ans += sx * sy - cnt
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 13160
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	i, j := 0, 0

	for k := range s {
		if s[k] == 'A' {
			i = k
			break
		}
	}

	for k := range s {
		if s[k] == 'Z' {
			j = k
		}
	}

	fmt.Println(j - i + 1)
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    reps(i, n) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int d, n; cin >> d >> n;
    int ans = 1;
    if (d > 0) {
        if (n == 100) {
            ans = pow(100, d) * (n + 1);
        } else {
            ans = pow(100, d) * n;
        }
    } else {
        if (n == 100) {
            ans = n + 1;
        } else {
            ans = n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool dp[2][8010][20010];
int main()
{
	string S;
	int x, y;
	cin >> S >> x >> y;
	vector<int> F[2];
	int d = 1, sum = 0, x0 = 0;
	bool Turn = true;
	for (int i = 0; i < S.size(); i++) {
		if (Turn) {
			if (S[i] == 'T') Turn = false;
			else x0++;
		}
		else {
			if (S[i] == 'F') sum++;
			else {
				F[d].push_back(sum);
				sum = 0;
				d = (d + 1) % 2;
			}
		}
	}
	F[d].push_back(sum);
	dp[0][0][8000 + x0] = true;
	dp[1][0][8000] = true;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < F[i].size(); j++) {
			for (int k = 0; k < 16000; k++) {
				if (dp[i][j][k]) {
					dp[i][j + 1][k + F[i][j]] = true;
					dp[i][j + 1][k - F[i][j]] = true;
				}
			}
		}
	}
	/*for (int i = 0; i < 2; i++) {
		for (int j = 0; j < F[i].size(); j++) {
			cout << F[i][j] << " ";
		}
		cout << endl;
	}*/
	if (dp[0][F[0].size()][x + 8000] && dp[1][F[1].size()][y + 8000]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 156416
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 1e9;

map<char,char>m;
map<char,char>n;

char a[maxn];
char b[maxn];

int main(){
	for(int i = 0 ; i < 26 ; i++){
		char c = 'a' + i;
		m[c] = '.';
		n[c] = '.';
	}
	
	scanf("%s",b+1);
	scanf("%s",a+1);

	int len = strlen(a+1);
	for(int i = 1 ; i <= len ; i++){
		if(m[b[i]] == '.' || m[b[i]] == a[i]){
			m[b[i]] = a[i];
		}
		else{
			printf("No\n");
			return 0;
		}
	}

	for(int i = 1 ; i <= len ; i++){
		if(n[a[i]] == '.' || n[a[i]] == b[i]){
			n[a[i]] = b[i];
		}
		else{
			printf("No\n");
			return 0;
		}
	}

	cout << "Yes\n";

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int K, S;
	cin >> K >> S;
	int rsl = 0;
	rep(x, 0, K + 1) rep(y, 0, K + 1) {
		int z = S - x - y;
		if(0 <= z and z <= K) rsl++;
	}

	cout << rsl << endl;

}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

void Main() {
  //自動整形防止用コメント
  string s, t;
  cin >> s;
  std::cin >> t;
  int counter = 0;
  rep(i, 3) {
    if (s[i] == t[i]) {
      counter++;
    }
  }

  std::cout << counter << '\n';
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt = 0 

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        cnt += A[i]
        cnt += min(B[i],A[i+1])
        A[i+1] -= min(B[i],A[i+1])
    else:
        cnt += B[i]
print(cnt)


Measured memory_bytes: 19116