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

// 1-indexed
template <class T>
struct BIT {
  vector<T> lst;
  int treesize;
  // constructor
  BIT(int newn = 0) {
    treesize = newn;
    lst.resize(treesize + 1);
    for(int i = 0; i <= treesize; ++i) lst[i] = 0;
  }
  // a_place += num
  bool add(int place, T num) {
    while(place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
    return 1;
  }
  // add wide ver.(add num between l and r)
  bool addw(int left, int right, T num) {
    while(left <= right && left >= 1 && right <= treesize)
      add(left++, num);
    return 1;
  }
  // sum between [1,place]
  T calcsum(int place) {
    T answer = 0;
    while(place > 0) {
      answer += lst[place];
      place -= place & -place;
    }
    return answer;
  }
  // sum [l,r]
  T calcsumw(int left, int right) {
    return calcsum(right) - calcsum(left - 1);
  }
};

struct data {
  long long x, h;
};
bool operator<(const data &l, const data &r) {
  return l.x < r.x;
}

long long n, d, a;
vector<data> v;
BIT<long long> bit;

long long solve();

int main() {
  cin >> n >> d >> a;
  v.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> v[i].x >> v[i].h;
    v[i].h = (v[i].h + a - 1) / a;
  }
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, r = 0;
  bit = BIT<long long>(n + 2);
  for(int i = 0; i < n; ++i) {
    long long now = v[i].h - bit.calcsum(i + 1);
    if(now <= 0) continue;
    while(r < n && v[r].x <= v[i].x + 2 * d) ++r;
    res += now;
    bit.add(i + 1, now);
    bit.add(r + 1, -now);
  }
  return res;
}


Measured memory_bytes: 4992
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[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 calc(x: usize, y: usize, z: usize) -> usize {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

fn main() {
    let n: usize = read_as_vec()[0];

    let mut v: Vec<usize> = vec![0; n + 1];

    for x in 1..=100 {
        for y in 1..=100 {
            for z in 1..=100 {
                let f = calc(x, y, z);
                if f < v.len() {
                    v[f] += 1;
                }
            }
        }
    }
    for i in 1..v.len() {
        println!("{}", v[i]);
    }

    // let mut t: Vec<Vec<(usize, usize, usize)>> = vec![vec![]; n + 1];
    // v[6] = 1;
    // t[6].push((1, 1, 1));
    // for i in 6..=n {
    //     for ti in 0..t[i].len() {
    //         let tr = t[i][ti];
    //         if tr.0 == tr.1 && tr.1 == tr.2 {
    //             let j = calc(tr.0 + 1, tr.1, tr.2);
    //             v[j] += 3;
    //             t[j].push((tr.0 + 1, tr.1, tr.2));
    //         } else {
    //         }
    //     }
    // }
}


Measured memory_bytes: 2032
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      auto B = new long[N];
      foreach (i; 0 .. N) {
        B[i] = readLong();
      }
      
      const im = A.maxIndex;
      A = A[im .. N] ~ A[0 .. im + 1];
      B = B[im .. N] ~ B[0 .. im];
      debug {
        writeln("A = ", A);
        writeln("B = ", B);
      }
      
      auto sumB0 = new long[N + 1];
      auto sumB1 = new long[N + 1];
      auto sumB2 = new long[N + 1];
      foreach (i; 0 .. N) {
        sumB0[i + 1] = sumB0[i] + B[i];
        sumB1[i + 1] = sumB1[i] + B[i] * i;
        sumB2[i + 1] = sumB2[i] + B[i] * i * i;
      }
      
      long f(int j, int i) {
        return (i - j) * (A[j] + A[i])
            + 2 * (sumB0[i] - sumB0[j + 1]) * j * i
            - 2 * (sumB1[i] - sumB1[j + 1]) * (j + i)
            + 2 * (sumB2[i] - sumB2[j + 1]);
      }
      
      auto dp = new long[N + 1];
      dp[] = long.min;
      dp[0] = 0;
      
      auto que = new int[N + 1];
      int qb, qe;
      foreach (i; 1 .. N + 1) {
        long g(int j) {
          return dp[j] + f(j, i);
        }
        que[qe++] = i - 1;
        for (; qe - qb >= 2 && g(que[qe - 2]) >= g(que[qe - 1]); --qe) {}
        dp[i] = g(que[qe - 1]);
      }
      const ans = cast(real)(dp[N]) / 2.0L / N;
      writefln("%.20f", ans);
      
      debug {
        auto brt = new long[N + 1];
        brt[] = long.min;
        brt[0] = 0;
        auto cut = new int[N + 1];
        cut[] = -1;
        foreach (i; 1 .. N + 1) {
          foreach (j; 0 .. i) {
            if (chmax(brt[i], brt[j] + f(j, i))) {
              cut[i] = j;
            }
          }
        }
        writeln("dp = ", dp);
        writeln("brt = ", brt);
        writeln("cut = ", cut);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 27192
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=300000+10;

int n,w,h;
struct Point { int x,y; } p[N];

#define ls (o<<1)
#define rs (o<<1|1)
int maxv[N<<2],addv[N<<2];
void pushup(int o) { maxv[o]=max(maxv[ls],maxv[rs]); }
void pushdown(int o) {
	if (addv[o]) {
		maxv[ls]+=addv[o],addv[ls]+=addv[o];
		maxv[rs]+=addv[o],addv[rs]+=addv[o];
		addv[o]=0;
	}
}
void build() { memset(maxv,0,sizeof(maxv)),memset(addv,0,sizeof(addv)); }
void modify(int o,int l,int r,int ql,int qr,int w) {
	if (ql<=l&&r<=qr) { maxv[o]+=w,addv[o]+=w; return; }
	int mid=(l+r)>>1; pushdown(o);
	if (ql<=mid) modify(ls,l,mid,ql,qr,w);
	if (qr>mid) modify(rs,mid+1,r,ql,qr,w);
	pushup(o);
}
int query(int o,int l,int r,int ql,int qr) {
	if (ql<=l&&r<=qr) return maxv[o];
	int mid=(l+r)>>1,res=0; pushdown(o);
	if (ql<=mid) res=max(res,query(ls,l,mid,ql,qr));
	if (qr>mid) res=max(res,query(rs,mid+1,r,ql,qr));
	pushup(o); return res;
}
#undef ls
#undef rs

int x[N],u[N],d[N];
int su[N],topu=0,sd[N],topd=0;
int calc(int n,int w,int h) {
	build(),su[topu=1]=sd[topd=1]=0; int mid=h>>1,res=0;
	for (int i=1,j=0;i<=n;) {
		++j,x[j]=p[i].x,u[j]=h-mid,d[j]=mid;
		while (i<=n&&p[i].x==x[j]) {
			if (p[i].y>=mid) u[j]=min(u[j],p[i].y-mid);
			if (p[i].y<=mid) d[j]=min(d[j],mid-p[i].y);
			++i;
		}
		while (topu&&u[su[topu]]>u[j]) {
			int t=su[topu--];
			modify(1,1,n,su[topu]+1,t,u[j]-u[t]);
		}
		su[++topu]=j;
		while (topd&&d[sd[topd]]>d[j]) {
			int t=sd[topd--];
			modify(1,1,n,sd[topd]+1,t,d[j]-d[t]);
		}
		sd[++topd]=j;
		modify(1,1,n,j,j,u[j]+d[j]-x[j-1]);
		res=max(res,query(1,1,n,1,j)+p[i].x);
	}
	return res;
}

int main() {
	w=read(),h=read(),n=read();
	for (int i=1;i<=n;++i) p[i].x=read(),p[i].y=read();
	int ans=0;
	sort(p+1,p+n+1,[](Point a,Point b) { return a.x<b.x; });
	p[0].x=0,p[n+1].x=w;
	for (int i=0;i<=n;++i) ans=max(ans,h+(p[i+1].x-p[i].x));
	ans=max(ans,calc(n,w,h));
	for (int i=1;i<=n;++i) swap(p[i].x,p[i].y);
	sort(p+1,p+n+1,[](Point a,Point b) { return a.x<b.x; });
	p[0].x=0,p[n+1].x=h;
	for (int i=0;i<=n;++i) ans=max(ans,w+(p[i+1].x-p[i].x));
	ans=max(ans,calc(n,h,w));
	printf("%d\n",ans<<1);
	return 0;
}

Measured memory_bytes: 19712
a = input()
total = 1 + (len(a) * (len(a) - 1) // 2)
trash = 0

for i in range(97, 97 + 26):
    atoz = (a.count(chr(i)) * (a.count(chr(i)) - 1)) // 2
    trash += atoz

print(total - trash)

Measured memory_bytes: 3500
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    char[] S = in.nextLine().toCharArray();
    int[] ans = new int[S.length];
    int l = 0;
    while (l < S.length) {
      int r = l + 1;
      while (r < S.length && S[r] == 'R') {
        r++;
      }
      int firstL = r;
      while (r < S.length && S[r] == 'L') {
        r++;
      }
      for (int i = l; i < r; i++) {
        int d = Math.abs(firstL - i);
        ans[firstL - d % 2]++;
      }
      // RRLLLL RL RRLL
      // System.out.println(l + " " + (r - 1) + " " + firstL);
      l = r;
    }
    show(ans);
  }

  public static void show(int[] ans) {
    for (int i = 0; i < ans.length; i++) {
      if (i != 0) {
        System.out.print(" ");
      }
      System.out.print(ans[i]);
    }
    System.out.println();
  }
}


Measured memory_bytes: 45872
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    // if(A>=B){
    //     for (long long i = 0; i < K; i++) {
    //         if(A>=B){
    //             B*=2;
    //         }else{
    //             K-=i;
    //             break;
    //         }
    //         if(i==K-1){
    //             K=0;
    //         }
    //     }
    // }
    // // debg(K)
    // if(B>=C){
    //     for (long long i = 0; i < K; i++) {
    //         if(B>=C){
    //             C*=2;
    //         }else{
    //             K-=i;
    //             break;
    //         }
    //     }
    // }
    // judge(A<B&&B<C);
    int cnt=0;
    while(A>=B) {cnt++;B*=2;}
    while(B>=C) {cnt++;C*=2;}
    judge(cnt<=K)
    return 0;
}


Measured memory_bytes: 3660
#include <stack>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

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

int main()
{
	// ------ Variable, Input ------ //

	int H, W, ptr, cnt, sec, x, y, d; bool clear;

	vector<int> Par;

	vector<string> MAP; string S;

	cin >> H >> W;

	MAP = vector<string>(H);

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

	cin >> S;


	// ------ Prepare ------ //

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (MAP[i][j] == 's')
			{
				x = j; y = i;
			}
		}
	}

	Par = vector<int>(S.size(), -1);

	stack<int> Par2;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '[' || S[i] == '{')
		{
			Par2.push(i);
		}
		
		if (S[i] == ']' || S[i] == '}')
		{
			Par[i] = Par2.top();
			Par[Par2.top()] = i;

			Par2.pop();
		}
	}

	d = 0; ptr = 0; cnt = 0, sec = 0; clear = false;


	// ------ Move ------ //

	while (ptr < S.size())
	{
		if (sec++ > 30000000)
		{
			break;
		}

		if (S[ptr] == '^')
		{
			if (MAP[y + dy[d]][x + dx[d]] != '#')
			{
				x += dx[d];
				y += dy[d];
			}

			cnt++;
		}
		else if (S[ptr] == 'v')
		{
			if (MAP[y - dy[d]][x - dx[d]] != '#')
			{
				x -= dx[d];
				y -= dy[d];
			}

			cnt++;
		}
		else if (S[ptr] == '<')
		{
			d -= 1;

			if (d < 0)
			{
				d += 4;
			}

			cnt++;
		}
		else if (S[ptr] == '>')
		{
			d += 1;

			if (d > 3)
			{
				d -= 4;
			}

			cnt++;
		}
		else if (S[ptr] == '[' || S[ptr] == '{')
		{
			string S2; S2 = S[ptr + 1];

			if (S2 == "~") { S2 += S[ptr + 2]; }

			bool ok = false;

			if (S2 == "T")
			{
				ok = true;
			}
			else if (S2 == "N")
			{
				ok = (d == 0);
			}
			else if (S2 == "E")
			{
				ok = (d == 1);
			}
			else if (S2 == "S")
			{
				ok = (d == 2);
			}
			else if (S2 == "W")
			{
				ok = (d == 3);
			}
			else if (S2 == "~N")
			{
				ok = (d != 0);
			}
			else if (S2 == "~E")
			{
				ok = (d != 1);
			}
			else if (S2 == "~S")
			{
				ok = (d != 2);
			}
			else if (S2 == "~W")
			{
				ok = (d != 3);
			}
			else if (S2 == "C")
			{
				ok = (MAP[y + dy[d]][x + dx[d]] == '#');
			}
			else if (S2 == "~C")
			{
				ok = (MAP[y + dy[d]][x + dx[d]] != '#');
			}

			if (ok == true)
			{
				ptr += S2.size();
			}
			else
			{
				ptr = Par[ptr];
			}
		}
		else if (S[ptr] == '}')
		{
			ptr = Par[ptr] - 1;
		}

		if (MAP[y][x] == 'g')
		{
			clear = true; break;
		}

		ptr++;
	}

	if (clear == false)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 3220
#include<stdio.h>

int main(){
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(true){
    	C = C - B;
        if (C <= 0){
        	printf("Yes\n");
        	break;
		}
		A = A - D;
        if(A <= 0){
        	printf("No\n");
        	break;
		}
    }
    
    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 1000000007
#define mod 1000000007
#include <iostream>
const lli infl=0x3f3f3f3f3f3f3f3fLL;

int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
  // test(t)
   {
       //lli a,b,c,d;
       float a,b;
       string s;

       cin>>a;
       b=float((2*22*a)/7);
       cout<<float(b);

     cout<<endl;
   }


return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    vector<bool>data(2000000);
    rep(i,2000000)data[i] = false;
    rep(i,n)data[a[i]] = true;
    int ans = 0;
    rep(i,n){
        if(data[a[i]]){
            ans++;
            if(i < n-1){
                if(a[i]==a[i+1])ans--;
            }
            for(int j = 1;j*a[i] <= a[n-1];j++){
                data[j*a[i]] = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4312
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	string s;
	cin>>s;
	bool a=false,b=false;
	if(s[0]==s[s.size()-1])a=true;
	if(s.size()%2==1)b=true;
	if(a&&b || !a&&!b){
		printf("Second\n");
	}else{
		printf("First\n");
	}
	return 0;
}

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

int main(){
  long long X;
  long long K;
  long long D;
  cin>>X>>K>>D;
  long long ans=0;
  
  if(abs(abs(X)/D)>=K){
    if(X>0){
      ans=X-K*D;
      cout<<abs(ans)<<endl;
      return 0;
    }
    if(X<0){
      ans=X+K*D;
      cout<<abs(ans)<<endl;
      return 0;
    }
  }
  
  long long A,B;
  if(X>=0){
    A=X%D;
    B=A-D;
    if((X/D)%2==K%2){
      ans=A;
    }
    else ans=B;
    //cout<<A<<" "<<B<<endl;        
  }else if (X<0){
    A=X%D;
    B=A+D;  
    //cout<<"###"<<endl;
    if(abs((X/D)%2)==K%2){
      ans=A;
    }
    else ans=B;
    
  }
  //cout<<A<<" "<<B<<endl;  

  cout<<abs(ans)<<endl;
  return 0;
}


Measured memory_bytes: 3640
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = max(A_arr)-min(A_arr)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
#set
n = gets.chomp.to_i
bottun_num_arr = []
0.upto(n - 1) do |i|
  bottun_num_arr[i] = gets.chomp.to_i
end

position = 1
count = 0

#main
loop do
  position = bottun_num_arr[position - 1]
  count += 1


  break if position == 2 || count == n + 1
end

if count == n + 1 then
  count = -1
end
print ("#{count}\n")

Measured memory_bytes: 2756
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      boolean n3 = (n%3==0);

      int[] a = new int[n];

      for(int i=0;i<n;i++){
        a[i] = Integer.parseInt(sc.next());
      }

      String ans = "No";

      Arrays.sort(a);

///////////////////////////////////////////////
if(a[n-1]==0){
  ans ="Yes";
}
///////////////////////////////////////////////

///////////////////////////////////////////////
if(n3 && a[n/3-1]==0 && a[n/3]==a[n-1]){
  ans ="Yes";
}
///////////////////////////////////////////////

///////////////////////////////////////////////
int c = a[0]^a[n/3]^a[n-1];
boolean OOO = (c==0);
boolean a1 = (a[0]==a[n/3-1]);
boolean a2 = (a[n/3]==a[2*n/3-1]);
boolean a3 = (a[2*n/3]==a[n-1]);
boolean xyz1 = (a[0]!=a[n/3]);
boolean xyz2 = (a[n/3]!=a[n-1]);
if(n3 && a1 && a2 && a3 && xyz1 && xyz2 & OOO){

    ans ="Yes";
}
///////////////////////////////////////////////


      System.out.println(ans);

    }
}


Measured memory_bytes: 48848
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int dp[100001][3]={};
    
    
    for(int i=1; i<=N; i++){
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j!=k){
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[j]);
                }
            }
        }
    }
    
    cout<< max(dp[N][0],max(dp[N][1],dp[N][2]))<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


struct UnionFind{

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1) {}
	
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	int size(int x){
		return -data[ root(x) ];
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	map<int,vector<int>> mp;

	cin >> N;
	rep(i,N){
		int x, y;
		cin >> x >> y;
		mp[x].push_back(y);
	}

	UnionFind uf(200005);
	for(auto p: mp){
		auto ys = p.Y;
		for(int y: ys) uf.unite(ys[0], y);
	}

	for(auto p: mp){
		auto ys = p.Y;
		ans += uf.size(ys[0]) - ys.size();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int k;
int f[100005][3];
int memo[100005][3];

int dp(int pos, int now){
    if(pos==k) return 0;
    if(memo[pos][now]!=-1) return memo[pos][now];
    else{
        for(int i=0;i<3;i++){
            if(now==i) continue;
            else{
            memo[pos][now]=max(memo[pos][now],dp(pos+1,i)+f[pos][i]);
            }
        }
    }
    return memo[pos][now];
    
}

int main(){
    cin>>k;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<k;i++){
        for(int j=0;j<3;j++){
            cin>>f[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(ans,dp(0,i));
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 13732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class Point {
        public int a, b, c, d;
        public Point(int a, int b, int c, int d) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
        }
    }

    class MainClass {

        public static void Main() {
            var H = NextInt();
            var W = NextInt();
            var process = new List<Point>();
            var matrix = new List<List<int>>();
            for (int i = 0; i < H; i++) {
                matrix.Add(IntList());
            }

            // 横に運ぶ
            for (int i = 0; i < H; i++) {
                bool moving = false;
                for (int j = 0; j < W; j++) {
                    if(moving) {
                        process.Add(new Point(i + 1, j, i + 1, j + 1));
                        matrix[i][j - 1]--;
                        matrix[i][j]++;
                    }
                    moving = matrix[i][j] % 2 == 1;
                }
            }

            // 縦に運ぶ
            bool isMoving = false;
            for (int i = 0; i < H; i++) {
                if(isMoving) {
                    process.Add(new Point(i, W, i + 1, W));
                    matrix[i - 1][W - 1]--;
                    matrix[i][W - 1]++;
                }
                isMoving = matrix[i][W - 1] % 2 == 1;
            }

            // 表示
            Console.WriteLine(process.Count);
            foreach(var point in process) {
                Console.WriteLine($"{point.a} {point.b} {point.c} {point.d}");
            }
        }
    }

    class MyMath {
        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 28448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a= sc.nextInt();
		int b = sc.nextInt();
		if((a-b)%2==0) {
			System.out.println((a+b)/2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(void){
int n,z;cin>>z>>n;
pair<int,int> mi;
mi.first = 150;
int x[n],y[104]={0};
for(int i=0;i<n;i++)
    {cin>>x[i];
    y[x[i]]=1;}
for(int i=0;i<104;i++)
    if(y[i]==0&&mi.first>abs(z-i))
        mi=make_pair(abs(z-i),i);
cout<<mi.second<<endl;
return 0;}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr ll MOD = 1'000'000'007LL;
ll pw(ll a, ll b){
	ll c = 1;
	do {
		if(b%2) c = c*a % MOD;
		a = a*a % MOD;
	} while(b/=2);
	return c;
}
ll inv(ll a){
	return pw(a%MOD, MOD-2);
}

#define N 32
ll memo[6][N*8] = {};

ll f(int a, int b){
	if(a == 0) return 1;
	ll &ret = memo[a][b];
	if(ret == -1){
		ret = 0;
		REP(i, b+1){
			FOR(j, i+1, b-i+1){
				ret += 1LL * (j-i) * f(a-1, b-i-j) % MOD;
				ret %= MOD;
			}
		}
		// DEBUG("f_%d(%d) = %lld\n", a, b, ret);
	}
	return ret;
}

ll calc(ll a, ll b[N]){
	ll sm = 0, pw = 1;
	REP(j, N){
		sm = (sm + b[j] * pw) % MOD;
		pw = pw * a % MOD;
	}
	return sm;
}

ll a[N][N+1] = {}, b[N];

void solve(){
	REP(i, N){
		a[i][0] = 1;
		FOR(j, 1, N) a[i][j] = a[i][j-1] * i % MOD;
		a[i][N] = b[i];
	}
	REP(i, N){
		assert(a[i][i] != 0);
		{
			ll x = inv(a[i][i]);
			REP(j, N+1) a[i][j] = a[i][j] * x % MOD;
		}
		REP(j, N){
			if(i == j) continue;
			ll x = a[j][i] * inv(a[i][i]) % MOD;
			REP(k, N+1) a[j][k] = (a[j][k] - a[i][k] * x % MOD + MOD) % MOD;
		}
	}
	REP(i, N) DEBUG("%d %lld %lld\n", i, b[i], a[i][N]);
	REP(i, N) b[i] = a[i][N];
}

ll d[2][N];
ll g(ll a){
	// i * 2 + 6 - a%2 = a
	// (a + a%2 - 6) / 2 = i
	return calc((a + a%2 - 6)/2, d[a%2]);
}

int main(){
	REP(i, 6) REP(j, N*8) memo[i][j] = -1;
	REP(k, 2){
		REP(i, N) b[i] = f(5, i*2+6-k);
		solve();
		REP(i, N) d[k][i] = b[i];
	}
	FOR(i, 5, 100) assert(f(5, i) == g(i));

	int tq; scanf("%d", &tq);
	REP(iq, tq){
		int n; scanf("%d", &n);
		printf("%lld\n", g(n));
	}
}




Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int n;
double p[3009],dp[3009][3009],ans;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
			dp[i][j]=dp[i-1][j]*(1.0-p[i])+(j==0?0.0:dp[i-1][j-1]*p[i]);
	for(int i=n/2+1;i<=n;i++) ans+=dp[n][i];
	cout<<setprecision(15)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 69120
import sys
import math
from itertools import permutations
from itertools import combinations

#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1!=m2:
    print(1)
else:
    print(0)



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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int K, A, B;
    cin >> K >> A >> B;

    string ans = "NG";
    RPT(i, A, B) if (i % K == 0)
    {
        ans = "OK";
        break;
    }
    cout << ans << endl;
}

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


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

int main() {
    int num, scan, key, j;
    cin >> num;
    int array[num] = {};
    for(int i = 0; i < num; i++) {
        cin >> scan;
        array[i] = scan;

    }
    for (int i = 0; i < num; i++) {
        if (i == num - 1) {
            cout << array[i] << endl;
        } else {
            cout << array[i] << " ";
        }
    }
    for(int i = 1; i < num; i++) {
        key = array[i];
        j = i - 1;
        while (j >= 0 && array[j] > key) {
            array[j +1] = array[j];
            j--;
        }
        array[j +1] = key;
        for (int i = 0; i < num; i++) {
            if (i == num - 1) {
                cout << array[i] << endl;
            } else {
                cout << array[i] << " ";
            }
        }
    }
    return 0;
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 083 D / Link: http://abc083.contest.atcoder.jp/tasks/abc083_d  ----- */

struct Cumusum {
	vector<LL>csum;
	Cumusum(vector<LL>&a) {
		csum.assign((int)a.size() + 1, 0);
		for (int i = 0; i < (int)a.size(); i++) {
			csum[i + 1] = csum[i] + a[i];
		}
	}
	LL query(int l, int r) {
		return csum[r] - csum[l];
	}
};

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

	string s; cin >> s;
	VL z(SZ(s));
	FOR(i, 0, SZ(s)) {
		z[i] = s[i] == '0';
	}
	Cumusum zeros(z);

	LL ans = (SZ(s) + 1) / 2;

	int L = SZ(s) / 2 - 1;
	int R = (SZ(s) & 1 ? SZ(s) / 2 + 1 : SZ(s) / 2);
	while (10) {
		if (L < 0 || R >= SZ(s))break;
		int W = R - L + 1;
		LL sum = zeros.query(L, R + 1);
		if (W == sum || !sum) {
			// ok
			ans = max(ans, (LL)SZ(s) - L);
		}
		else break;

		L--, R++;
	}

	cout << (ans) << "\n";

	return 0;
}


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

 
int main() {
    ll x;
    cin>>x;
    
    int a=1,b;
    while(1){
        b=a;
        while(1){
            
            if(pow(a,5)-pow(b,5)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
            b--;
            if(pow(a,5)-pow(b,5)>x)break;
        }
        
        a++;
    }
}

Measured memory_bytes: 4028
#include<stdio.h>
 int main(void){
 int n,m;
 scanf("%d%d",&n,&m);
 
 int i,j,A[n][m],b[m],c,x;
 for(i=0;i<n;i++){
	 for(j=0;j<m;j++){
		 scanf("%d",&A[i][j]);
 	 }
 }
 for(i=0;i<m;i++){
	 scanf("%d",&b[i]);
 }
 for(i=0;i<n;i++){
	 c = 0;
 	for(j=0;j<m;j++){
		 x = A[i][j]*b[j];
 		 c = c+x;
	 }
	printf("%d\n",c);
 }
 return (0);
 }



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  ll N;
  cin >> N;

  unordered_map<int, int> mp;
  for (int i = 1; i <= 200; ++i) {
    for (int j = 1; j <= 200; ++j) {
      for (int k = 1; k <= 200; ++k) {
        ll t = i * i + j * j + k * k + i * j + j * k + k * i;
        mp[t] += 1;
      }
    }
  }

  for (int i = 1; i <= N; ++i) {
    cout << mp[i] << endl;
  }
}


Measured memory_bytes: 10604
import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=np.sort(n)

mn = n[np.where(n<0)]
mz = n[np.where(n==0)]
mp = n[np.where(n>0)]
M = 10**18
m = -1*M-1
pos = 0

while M-m > 1:
    a = 0
    pos=(M+m)//2
    a+=np.searchsorted(n,pos//mp,side="right").sum()
    if pos >= 0: a+=len(mz)*N
    a+=N*len(mn) - np.searchsorted(n,-(-pos//mn),side="left").sum()
    a-=np.count_nonzero(n*n <= pos)
    a=a//2
    if a >= K:
        M=pos
    else:
        m=pos
        
print(M)

Measured memory_bytes: 34248
#include <stdio.h>
#define endl printf("\n")

int
main(int argc, char *argv[])
{
  int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

  int c[100] = {};

  int n; int temp; int m = sizeof(prime) / sizeof(int);
  scanf("%d", &n);
  for(int i = 2; i <= n; i++){
    for(int j = 0; j < m && i >= prime[j]; j++){
      temp = i;
      while(temp % prime[j] == 0){
	c[prime[j]]++;
	temp /= prime[j];
      }
    }
  }

  int c24 = 0, c2 = 0; int ans;
  for(int i = 0; i < m; i++){
    temp = c[prime[i]];
    if(temp >= 2 && temp < 24) c2++;
    if(temp >= 24) c24++;
  }

  ans = c2 * c24 + c24 * (c24 - 1);

  int c4 = 0; c2 = 0;
  for(int i = 0; i < m; i++){
    temp = c[prime[i]];
    if(temp >= 2 && temp < 4) c2++;
    if(temp >= 4) c4++;
  }

  int c74 = 0;
  for(int i = 0; i < m; i++){
    if(c[prime[i]] >= 74) c74++;
  }
  ans += ((c4 * (c4 - 1))/2) * c2 + (c4 * (c4 - 1) * (c4 - 2)) / 2 + c74;

  

  int c14 = 0; c4 = 0;
  for(int i = 0; i < m; i++){
    temp = c[prime[i]];
    if(temp >= 14) c14++;
    if(temp >= 4 && temp < 14) c4++;
  }
  
  ans += c14 * c4 + c14 * (c14 - 1);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var D, N int
	fmt.Scan(&D, &N)
	c := 0
	for i := 1; true; i++ {
		d := 0
		j := i
		for j > 0 && j%100 == 0 {
			j /= 100
			d++
		}
		if d == D {
			c++
		}
		if c == N {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,h;
int a[100100],b[100100];
int ans;
int amax=0;

int main(){
	cin>>n>>h;
	REP(i,n){
		cin>>a[i]>>b[i];
		amax=max(amax,a[i]);
	}
	sort(b,b+n,greater<int>());
	REP(i,n){
		if(amax<b[i]){
			ans++;
			h-=b[i];
			if(h<=0){
				cout<<ans<<endl;
				return 0;
			}
		}
		
	}
	ans+=((h+amax-1)/amax);
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	char a[3];
	scanf("%s",&a );
	if ((a[0] == a[1]) && (a[2] == a[3]) && (a[0] != a[2]))
	{
		printf("Yes");
	}
	else
	{
		if ((a[0] == a[2]) && (a[1] == a[3]) && (a[0] != a[1]))
		{
			printf("Yes");
		}
		else
		{
			if((a[0]==a[3])&&(a[1]==a[2])&&(a[0]!=a[1]))
			{
				printf("Yes");
			}
			else
			{
				printf("No");
			}
		}
	}
}

Measured memory_bytes: 128
# 2019-11-18 23:58:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n = int(sys.stdin.readline().rstrip())
    if n % 2 == 0:
        ans = 0.5
    else:
        ans = (n // 2 + 1) / n

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
//蓝莲花__ 
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=666,mod=1e9+7;
int n,d[N];
ll inv[N],finv[N],f[N][N][2];
ll qm(ll x,ll k){ll s=1,t=x;while(k){if(k&1)s=s*t%mod;k>>=1;t=t*t%mod;}return s;}
ll add(ll &x,ll y){x+=y;x-=(x>=mod)?mod:0;}
void sp_ch(){
	bool bb=1;
	rep(i,1,n)if(d[i]!=2)bb=0;
	if(bb){
		ll now=inv[n-1];
		now+=(now&1)?mod:0;
		cout<<now/2%mod;
		exit(0); 
	}
}
int main(){
	inv[0]=1;rep(i,1,N-1)inv[i]=inv[i-1]*1ll*i%mod;
	finv[N-1]=qm(inv[N-1],mod-2);
	per(i,N-2,0)finv[i]=finv[i+1]*1ll*(i+1)%mod;
	
	cin>>n;
	rep(i,1,n)cin>>d[i];
	sp_ch();
	
	f[0][0][0]=1;
	rep(i,1,n)rep(j,0,i)rep(k,0,1){
		if(d[i]>=1)add(f[i][j][k],f[i-1][j][k]*finv[d[i]-1]%mod);
		if(d[i]>=2&&j)add(f[i][j][k],f[i-1][j-1][k]*finv[d[i]-2]%mod);
		if(d[i]>=3&&!k&&j)add(f[i][j][1],f[i-1][j-1][0]*finv[d[i]-3]%mod);
	}
	
	ll ans=0;
	rep(i,3,n-1)add(ans,f[n][i][1]*inv[n-i-1]%mod*inv[i-1]%mod);
	ans+=ans&1?mod:0;
	cout<<ans/2%mod; 
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
 
void dfs(ll node,ll &c,vector<bool> &visit,vector<ll> adj[])
{
    visit[node]=true;
    c++;
    for(auto child:adj[node])
    {
        if(visit[child]==false)
        {
            dfs(child,c,visit,adj);
        }
    }
}
 
void solve()
{
    ll n,e,a,b,res=0,c,i;
    cin>>n>>e;
    vector<ll> adj[n+1];
    vector<bool> visit(n+1,false);

    while(e--)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
 
    for(i=1;i<=n;i++)
    {
        if(visit[i]==false)
        {
            c=0;
            dfs(i,c,visit,adj);
            res=max(res,c);
        }
    }
 
    cout<<res;
}
 
int main()
{
   solve();
}

Measured memory_bytes: 26968
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		List<Integer> list = new ArrayList<Integer>();
		
		for(int i=0; i<n; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		int sum = 0;
		for(int i=0; i<list.size()-1; i++) {
			sum += list.get(i);
		}
		if(sum>list.get(n-1)) {
			System.out.println("Yes");
		}else if(sum <= list.get(n-1)){
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22612
n,x = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 1,0, 0
res = []
while(i < len(ais)):
	cur += ais[i]
	if cur <= x:
		count+=1
	else:
		break

	i +=1
print count
#print len([e for e in res if e <= x])

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

int main() {
int A,B  ;
    cin >> A >> B ;
 int N;
 int count =0;
  
  for (int i=A; i<=B; i++){
    N=i ;
   if (N/10000==N%10 &&N/1000%10==N/10%10)
     count ++;
  }
  cout << count << endl;  
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vl vector<ll>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()

#define MAX 400005

struct llll{
    ll a, b, c, d;
};

ll n, m, q;

bool cmp(llll p, llll q)
{
    return p.d>q.d;
}

vector<ll> temp;
vector<vector<ll>> all;

void generate(ll pos, ll val)
{
    if(pos>=n)
    {
        all.push_back(temp);
        return;
    }

    for(int i=1;i<=m;i++)
    {
        if(i>=val)
        {
            temp.push_back(i);
            generate(pos+1,i);
            temp.pop_back();
        }
    }
}

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

    cin >> n >> m >> q;

    generate(0,0);

    vector<llll> v(q);

    for(int i=0;i<q;i++)
    {
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    }

    sort(all(v), cmp);
    vector<ll> ans(n+1, 50);

    ll tot= 0;
    for(vector<ll> p: all)
    {
        ll ans = 0;
        for(llll x: v)
        {   
            x.a--, x.b--;

            if(p[x.b] - p[x.a] == x.c) ans+=x.d;
        }

        tot=max(tot,ans);
    }

    cout << tot << endl;

    return 0;
}

Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
const int sz=2e5+9;
int a[sz],ans[sz];
int n;
int sum;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);

    for(int i=n;i>=1;i--){
        int j=i<<1;
        sum=0;
        while(j<=n){
            sum^=ans[j];
            j+=i;
        }
        ans[i]=(sum!=a[i]);
    }
    sum=0;
    for(int i=1;i<=n;i++) sum+=ans[i];
    printf("%d\n",sum);
    for(int i=1;i<=n;i++) if(ans[i]) printf("%d ",i);
    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
int sw(char n);
int tm(int x,int y);
int N[3]={1,0,0};
int main(void) {
	int x,y,ans;
	char str[100],n,m,*line;

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		line=strtok(str," ,");
		sscanf(line,"%s",&n);
		x=sw(n);
		line=strtok(NULL," ,");
		sscanf(line,"%s",&m);
		y=sw(m);
		ans=tm(x,y);
	}
	switch(ans){
		case 0: printf("A\n"); return 0;
		case 1: printf("B\n"); return 0;
		case 2: printf("C\n"); return 0;
		default:  return -1;
	}
}

int sw(char n){	
	switch(n){
		case 'A': return 0;
		case 'B': return 1;
		case 'C': return 2;
		default:  return -1;
	}
}

int tm(int x,int y){
	int i,tmp;
	tmp = N[x];
	N[x] = N[y];
	N[y] = tmp;
	for(i=0;i<3;i++){
		if(N[i]==1)
			return i;
	}
	return -1;
}

	

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

long long gcd(long long , long long);
long long gcd(long long [], int);

long long lcm(long long , long long);
long long lcm(long long [], int);

//最大公約数を求める(2変数)
long long gcd(long long a, long long b){
    long long r;
    while(1){
        if(a < b){
            long long tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        if(r == 0){
            return b;
        }
        a = r;
    }
}

//最大公約数を求める(多変数)
long long gcd(long long a[], int size){
    long long x = a[0];
    for(int i=1; i<size; i++){
        x = gcd(x, a[i]);
    }
    return x;
}

//最小公倍数を求める(2変数)
long long lcm(long long a, long long b){
    return (a/gcd(a, b))*b;
}

//最小公倍数を求める(多変数)
long long lcm(long long a[], int size){
    long long x = a[0];
    for(int i=1; i<size; i++){
        x = lcm(x, a[i]);
    }
    return x;
}

int main(){
    int N;
    cin >> N;
    long long T_list[100];
    for(int i=0; i<N; i++){
        cin >> T_list[i];
    }
    cout << lcm(T_list, N);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll h, w, d;
    cin >> h >> w >> d;
    vector<ll> x(1<<17, 0), y(1<<17, 0);
    rep(i, 0, h) rep(j, 0, w) {
        ll a;
        cin >> a;
        x[a] = i;
        y[a] = j;
    }
    vector<ll> s(1<<17, 0);
    rep(i, 1, h*w+1-d) {
        s[i+d] = s[i] + abs(x[i+d] - x[i]) + abs(y[i+d] - y[i]);
    }

    ll q;
    cin >> q;
    rep(i, 0, q) {
        ll l, r;
        cin >> l >> r;
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 4224
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] + A[i+1]:
        cnt += A[i] + A[i+1]
        A[i+1] = 0
    elif A[i] < B[i]:
        cnt += A[i] + (B[i] - A[i])
        A[i+1] =  A[i+1] - (B[i] - A[i])
    elif A[i] > B[i]:
        cnt += B[i]
    elif A[i] == B[i]:
        cnt += A[i]
print(cnt)
        


Measured memory_bytes: 18752
#include <iostream>
#include <algorithm>
#include <string> 
using namespace std;

typedef long long ll;

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


Measured memory_bytes: 256
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    x = 0
    twon = 0
    c = collections.Counter(A)
    for k in c.keys():
        if c[k] >= 2:
            if c[k] % 2 == 0:
                x += c[k] - 2
                twon += 1
            else:
                x += c[k] - 1

    x += twon
    if twon & 1:
        x += 1

    print(N - x)



if __name__ == '__main__':
    main()


Measured memory_bytes: 18584