akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

typedef struct {
  long a;
  long b;
}seta;

long compare(const void *p,const void *q){
  return ((seta*)p)->b - ((seta*)q)->b;
}

int main(){
  seta sets[200000] = {};
  long n = 0;
  long i = 0;
  int success = 1;
  long sum = 0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&sets[i].a,&sets[i].b);
  }
  qsort(sets,n,sizeof(seta),compare);
  /*for(i=0;i<n;i++){
    printf("%ld %ld\n",sets[i].a,sets[i].b);
  }*/
  for(i=0;i<n;i++){
    sum += sets[i].a;
    if(sum > sets[i].b){
      success = 0;
      break;
    }
  }
  
  if(success){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


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

using namespace std;
 
int main() {

string S;
cin >> S;

int sum = 700;

    if (S.at(0) == 'o')
    {
       sum = sum + 100;
    }

    if (S.at(1) == 'o')
    {
       sum = sum + 100;
    }

    if (S.at(2) == 'o')
    {
       sum = sum + 100;
    }

cout << sum << endl;   

}

Measured memory_bytes: 256
num = gets.split(" ").map(&:to_i)
k = gets.to_i
magic = false

while k != -1
  if (num[0] >= num[1])
    num[1] *= 2
  elsif (num[1] >= num[2])
    num[2] *= 2
  else
    k = 0
    magic = true
  end
  k = k - 1
end

if (magic)
  print 'Yes'
else
  print 'No'
end


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

using namespace std;

const int Mod = 1e9 + 7;

int x, y, mask, m0, m1, res, dp[1 << 15], n, m, i, cntb[1 << 15], go[20], ans = 1;
bool good[1 << 15];

void inm(int &x, int y)
{
    x = (long long) x * y % Mod;
}

void add(int &x, int y)
{
    x += y;
    if(x >= Mod) x -= Mod;
}

int main()
{
 //   freopen("input", "r", stdin);

    cin >> n >> m;
    for(i=1; i<=m; ++i)
    {
        cin >> x >> y;
        --x; --y;
        go[x] |= (1<<y);
        inm(ans, 2);
    }

    for(i = 0; i < (1<<n); ++i)
    {
        good[i] = ((i&3) == 3 || (i&3) == 0);
        cntb[i] = cntb[i>>1] + (i&1);
    }

    dp[0] = 1;
    for(mask = 1; mask < (1<<n); ++ mask)
    if(good[mask])
    {
        dp[mask] = 1;
        for(m1 = mask & (mask - 1); m1; m1 = mask & (m1 - 1))
        {
            m0 = mask ^ m1;
            if(!good[m0] || !good[m1]) continue;

            res = dp[m1];
            for(i=0; i<n; ++i)
                if(m0 & (1<<i))
                    inm(res, (1 << cntb[go[i] & m1]));
                else if(m1 & (1<<i))
                    inm(res, (1 << cntb[go[i] & m0]) - 1);
            add(dp[mask], res);
        }
    }

    add(ans, Mod - dp[mask-1]);
    cout << ans << '\n';

    return 0;
}


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

int main() {
    int x;
    cin >> x;
    int expo[x];
    expo[0] = 1;
    for (int i = 9; i > 1; i--) {
        for (int j = 2; j < sqrt(x); j++) {
            int tmp = pow(j, i);
            while (pow(j, i) <= x) {
                expo[tmp-1] = 1;
                if (tmp%j == 0)tmp /= j;
                else break;
            } 
            if (pow(j, i) > x) continue;
        }
    }
    for (int i = x; i > 0; i--) {
        if (expo[i-1] == 1) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
use proconio::input;

fn main() {
    input! {
        h: usize, w: usize, k: usize,
        tmp: [String; h],
    }
    let mut grid = Vec::new();
    for i in 0..h {
        let row = tmp[i].clone();
        let row = row.chars().collect::<Vec<_>>();
        grid.push(row);
    }

    let mut ret = 0;
    for hbit in 0..1 << h {
        for wbit in 0..1 << w {
            let mut cnt = 0;
            for i in 0..h {
                for j in 0..w {
                    if (hbit & (1 << i) == 0) && (wbit & (1 << j) == 0) {
                        if grid[i][j] == '#' {
                            cnt += 1;
                        }
                    }
                }
            }
            if cnt == k {
                ret += 1;
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2168
using System;

class main{
  public static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    long a = long.Parse(s[0]);
    long b = long.Parse(s[1]);
    long c = long.Parse(s[2]);
    long d = long.Parse(s[3]);
    
    long max = 0;
    long num1 = a*c;
    long num2 = a*d;
    max = Math.Max(num1, num2);
    
    long num3 = b*c;
    max = Math.Max(max, num3);
    
    long num4 = b*d;
    max = Math.Max(max, num4);
    Console.WriteLine(max);
  }
}

Measured memory_bytes: 27540
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    int i;
    int a[n];
    int tmp;
    for(i=0;i<n;i++)a[i]=0;
    for(i=0;i<2*m;i++){
      cin >> tmp;
      a[tmp-1]++;
    }
    for(i=0;i<n;i++)cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Virtual
{
    class ABC109_D
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int h = hw[0];
            int w = hw[1];
            int[,] grid = new int[h, w];
            for(int i = 0; i < h; i++)
            {
                int[] row = ReadInts();
                for(int j = 0; j < w; j++)
                {
                    grid[i, j] = row[j];
                }
            }
            List<int[]> res = new List<int[]>();
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w-1; j++)
                {
                    if (grid[i, j] % 2 == 0) continue;

                    res.Add(new int[4] { i + 1, j + 1, i + 1, j + 2 });
                    grid[i, j + 1]++;
                }
            }
            for(int i = 0; i < h - 1; i++)
            {
                if (grid[i, w - 1] % 2 == 0) continue;

                res.Add(new int[4] { i + 1, w, i + 2, w });
                grid[i + 1, w - 1]++;
            }

            WriteLine(res.Count);
            for (int i = 0; i < res.Count; i++)
            {
                WriteLine(res[i][0] + " " + res[i][1] + " "
                    + res[i][2] + " " + res[i][3]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27924
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
int n;
struct H{
	int x,y;
};
H a[20];
ld dist(H a,H b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
ld solve(int i,int x,ld res, vector<bool>v){
	//今までに何個都市を訪れたか、今いる都市はどこか、今までにかかった移動距離は何か、いままでに訪問した都市はどこか
	if(i==n){
		return res;
	}
	ld sum=0;
	for(int j=1;j<=n;j++){
		if(!v[j]){
			v[j]=1;
			sum+=solve(i+1,j,res+dist(a[x],a[j]),v);
			v[j]=0;
		}
	}
	return sum;
}
signed main(){
	cin>>n;
	int res=1;
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
		res*=i;
	}
	vector<bool>b(n+1,0);
	ld sum=0;
	for(int i=1;i<=n;i++){
		b[i]=1;
		sum+=solve(1,i,0,b);
		b[i]=0;
	}
	printf("%.20LF",sum/res);
}


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

// max, min, log, input is defined

using namespace std; 

unsigned int n, x, a[110];
unsigned long long qs[110];
unsigned long long demand=0;

int main(){
	cin >> n >> x;
	for (int i = 0; i < n; ++i) { cin >> a[i]; demand+=a[i]; }
	if (demand<x) cout << n-1;
	else if (demand==x) cout << n;
	else {
		sort(a,a+n);
		qs[0] = a[0];
		for (int i = 1; i < n; ++i)	qs[i] = qs[i-1] + a[i];
		for (int i = 0; i < n; ++i)
		{
			if(qs[i] < x) continue;
			else if (qs[i] == x) {i++; cout << i; break;}
			else { cout << i; break; }
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;
constexpr ll mod = 1e6 + 3;
//constexpr ll mod = 13;
template<ll mod>
class Fp {
public:
	ll val;

private:
	inline void calc_mod(ll& v) {
		if (v >= mod)v -= mod;
	}
public:
	Fp(){}
	Fp(ll v) :val(v%mod) {
		if (val < 0)val += mod;
	}

	Fp operator+=(const Fp &in) {
		val += in.val;
		calc_mod(val);
		return *this;
	}

	Fp operator+(const Fp &in) const{
		return Fp(*this) += in;
	}

	Fp &operator-=(const Fp &in) {
		val -= in.val;
		calc_mod(val);
		if (val < 0)val += mod;
		return *this;
	}

	Fp operator-(const Fp &in) const{
		return Fp(*this) -= in;
	}

	Fp& operator*=(const Fp& in) {
		val = val * in.val % mod;
		return *this;
	}

	Fp operator*(const Fp &in) const{
		return Fp(*this) *= in;
	}

	Fp& operator/=(const Fp& in) {
		*this *= modpow(in, mod - 2);
		return *this;
	}

	Fp operator/(const Fp& in) const{
		return Fp(*this) /= in;
	}

	bool operator==(const Fp&in)const {
		return val == in.val;
	}

	bool operator!=(const Fp&in)const {
		return val != in.val;
	}

	friend Fp modpow(const Fp& in, ll n){
		if (n == 0)return 1;
		if (n & 1) {
			return in*modpow(in*in, n / 2);
		}
		else {
			return modpow(in*in, n / 2);
		}
	}
};
using modll = Fp<mod>;

class Factorial {
public:
	vector<modll> fact, finv;
	Factorial(ll n) :fact(n, modll(1)), finv(n, modll(1)) {
		for (int i = 2; i < n; i++) {
			modll tmp(i);
			fact[i] = fact[i - 1] * tmp;
			finv[i] = finv[i - 1] / tmp;
		}
	}

	modll com(const ll& n, const ll& k) {
		if (n < k || n < 0 || k < 0)return modll(0);
		return fact[n] * finv[k] * finv[n - k];
	}
};


int main() {
	cin >> Q;
	Factorial f(mod);
	for (int i = 0; i < Q; i++) {
		ll _x, _d, n;
		cin >> _x >> _d >> n;
		modll x(_x), d(_d);
		if (d.val == 0) {
			cout << modpow(x, n).val << endl;
			continue;
		}
		x /= d;

		if (mod <= x.val + n - 1||x.val==0) {
			cout << 0 << endl;
		}
		else {
			modll res = modpow(d, n)*f.fact[x.val + n - 1] * f.finv[x.val - 1];
			cout << res.val << endl;
		}
	}
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> p, q;
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        q.push_back(tmp);
    }
    vector<int> v;
    for(int i=1;i<=n;++i)v.push_back(i);
    int a = -1, b = -1, num = 1;
    do{
        bool flag = true;
        for(int i=0;i<n;++i){
            if(v[i] != p[i]){
                flag = false;
                break;
            }
        }
        if(flag)a = num;
        flag = true;
        for(int i=0;i<n;++i){
            if(v[i] != q[i]){
                flag = false;
                break;
            }
        }
        if(flag)b = num;
        num++;
    }while(next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;

    return 0;
}

Measured memory_bytes: 256
#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() {
   int N, T;
   ll ans = 0;
   cin >> N >> T;
   vector<int> t(N);
   rep(i, N) cin >> t.at(i);

   rep(i, N - 1) {
     ans += min(T, t.at(i + 1) - t.at(i));
   }

   cout << ans + T << endl;
 }


Measured memory_bytes: 1024
#include <iostream>
#define ll unsigned long long
using namespace std;


int main() {
    int x, y;
    cin >> x >> y;

    if (2 * x > y || 4 * x < y || y % 2 == 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string X;
    cin >> X;

    stack<char> s;
    for(int i = 0 ; i < X.size(); i++){

        if( s.empty() ){
            s.push(X[i]);
        }else if( X[i] == 'T' && s.top() == 'S' ){
            s.pop();
        }else{
            s.push(X[i]);
        }
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 644
aa = input()
bb = input()

a = list(aa)
b = list(bb)

a.sort()
b.sort()

b = b[::-1]

S="".join(a)
T="".join(b)


if S<T:
    message = "Yes"
    print(message)
else:
    message = "No"
    print(message)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
static const double EPS = 1e-7;

struct runner {
  int p, t, v;
};

int main()
{
  static double comb[55][55];
  for (int i = 0; i <= 50; i++) {
    comb[i][0] = 1.0;
  }
  for (int i = 1; i <= 50; i++) {
    for (int j = 1; j <= i; j++) {
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
  }

  int N, M, L;
  cin >> N >> M >> L;
  vector<runner> v;
  bool all_zero = true;
  for (int i = 0; i < N; i++) {
    runner r;
    cin >> r.p >> r.t >> r.v;
    v.push_back(r);
    if (r.v != 0) {
      all_zero = false;
    }
  }

  if (all_zero) {
    for (int i = 0; i < N; i++) {
      cout << "0.0000000" << endl;
    }
    return 0;
  }

  vector<vector<double> > ps(N, vector<double>(M+1));
  vector<vector<double> > ps_integral(N, vector<double>(M+1));
  vector<vector<double> > ts(N, vector<double>(M+1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= M; j++) {
      ps[i][j] = pow(v[i].p/100.0, j) * pow((100-v[i].p)/100.0, M-j) * comb[M][j];
      if (j == 0) {
        ps_integral[i][j] = ps[i][j];
      } else {
        ps_integral[i][j] = ps_integral[i][j-1] + ps[i][j];
      }
      ts[i][j] = double(L)/v[i].v + v[i].t*j;
    }
  }

  for (int i = 0; i < N; i++) {
    double ans = 0.0;
    for (int j = 0; j <= M; j++) {
      double p = 1.0;
      for (int k = 0; k < N; k++) {
        if (k != i) {
          int l = lower_bound(ts[k].begin(), ts[k].end(), ts[i][j]+EPS) - ts[k].begin();
          if (l != 0) {
            p *= (1.0 - ps_integral[k][l-1]);
          }
        }
      }
      ans += ps[i][j] * p;
    }
    printf("%.6f\n", ans + EPS);
  }
  return 0;
}

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

int main()
{
    char a; std::cin >> a;
    char b;
    if(a == 'A')b = 'T';
    if(a == 'C')b = 'G';
    if(a == 'T')b = 'A';
    if(a == 'G')b = 'C';
    std::cout << b << std::endl; 
}

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

int n;

int main(){
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++) cin >> a[i];
    int amount = 0;
    int start = 0;
    for(int j = 0; j < n; j++){
        amount += abs(a[j] - start);
        start = a[j];
    }
    amount += abs(0 - start);

    start = 0;
    a.push_back(0);
    for(int i = 0; i < n; i++){
        int ans = amount - ( abs(a[i] - start) + abs(a[i + 1] - a[i]) );
        ans += abs(a[i + 1] - start);
        cout << ans << endl;
        start = a[i];
    }

    return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(v) (v).begin(),(v).end()


struct Node {
    //次のアルファベット
	Node* ch[26];
    //残りの文字にアルファベット'a'+jが何個含まれるか
	int cnt[26];
	Node() {
		rep(i, 26) {
			ch[i] = NULL;
			cnt[i] = 0;
		}
	}
};

void add(Node* nd, string s) {
	reverse(all(s));
	int alf[26] = {};
	rep(i, s.size())alf[s[i] - 'a']++;
	rep(j, 26)if (alf[j] > 0)nd->cnt[j]++;
	rep(i, s.size()) {
		int t = s[i] - 'a';
		alf[t]--;
		if (nd->ch[t] == NULL)nd->ch[t] = new Node();
		nd = nd->ch[t];
		rep(j, 26)if (alf[j] > 0) {
			nd->cnt[j]++;
		}
	}
}
int query(Node* nd, string s) {
	int z = s[0] - 'a';
	for (int i = (int)s.size() - 1; i > 0; i--) {
		int t = s[i] - 'a';
		if (nd->ch[t] == NULL)return 0;
		nd = nd->ch[t];
	}
	return nd->cnt[z];
}
bool comp(string a, string b) {
	return a.size() < b.size();
}
void solve() {
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n)cin >> s[i];
	sort(all(s), comp);
	Node* root = new Node();
	ll ans = 0;
	per(i, n) {
		ans += query(root, s[i]);
		add(root, s[i]);
	}
	cout << ans << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 316828
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;

int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)
    cin>>a[i];
 int nb=0;
 for(int i=0;i<n;i++)
 {
     if((a[i]%2==1)and((i+1)%2==1))
        nb++;
 }
 cout<<nb;


}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define double long double

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;  //セグ木の幅
  F f;  //モノイドの作用
  T ti;  //初期値
  vector<T> dat;  //セグ木で使う配列 一番上に使われるのがdat[1] 一番下の段の左端がdat[n]
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}  //fがモノイドとしての作用、tiが単位元

  SegmentTree(F f,T ti,int n_):f(f),ti(ti){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  SegmentTree(F f,T ti,const vector<T> &v):f(f),ti(ti){
    int n_=v.size();
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
    for(int i=0;i<n_;i++)dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  T get(int x){
    return dat[x+n];
  }

  void init(int n_){  //ただの初期化
    n=1;
    while(n<n_) n<<=1;  //nが実際にとる２べきの幅
    dat.assign(n<<1,ti);  //dat配列は幅の２倍あってその全てにtiを代入
  }

  void build(const vector<T> &v){  //vector vに合わせた初期化
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];  //v[i]を一番子の所に代入
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);  //iの子供は2*i、2*i+1
  }

  void set_val(int k,T x){  //（0-indexedで）kにxを代入
    dat[k+=n]=x;
    while(k>>=1)  //kがどんどん自分の親になっていく、0になったらおしまい
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){  //[a,b)の範囲のモノイドの作用を返す
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);  //左端を使いたくなるのはブロックが奇数の時
      if(r&1) vr=f(dat[--r],vr);  //右端〃偶数の時（開区間なのでr:奇数で反応）
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){  //dat[k]:[l,r)の間にいるenを返す
    //下のfind用なので先にそっち読むべき
    //accはst~lとかで確定している値
    if(l+1==r){  //答えがちゃんと存在するならこのlが答え
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1; //入るならk-n(==l)を、入らないなら-1を返す
    }
    int m=(l+r)>>1;  //にぶたんのそれ
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);  //mがstより後ろなら明らかにl=m;
    if(st<=l&&!check(f(acc,dat[k]))){  //今見てるk全部でもダメ(mだと足りないのでl=mにする）
      acc=f(acc,dat[k]);  //kは全部accに加えた上で-1を返す
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);  //まず[l,m)の中にenがいるか探す
    if(~vl) return vl;  //いたならそれを返す(if(~vl)は-1以外にのみ反応する)
    return find(st,check,acc,(k<<1)|1,m,r);  //いなかったら[m,r)の中にenがいるのでそれを返す
    //acc=f(acc,dat[k]);がここで効いてる
  }

  template<typename C>
  int find(int st,C &check){
    //check(f(dat[st]~dat[en-1]))=false,check(f(dat[st]~dat[en]))＝trueとなるenを返す
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n,k;cin>>n>>k;
  vector<double> p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)p[i]=(p[i]+1)/2;
  auto f=[](double a,double b){return a+b;};
  SegmentTree<double> seg(f,0,p);
  double ans=0;
  for(int i=0;i<n-k+1;i++)chmax(ans,seg.query(i,i+k));
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=1e5+5;
int main()
{
    ios::sync_with_stdio(false);
    ll a,b,n,i;
    scanf("%lld%lld%lld",&a,&b,&n);
    printf("%lld\n",a*min(b-1,n)/b);
    return 0; 
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 400010
#define ll long long
using namespace std;
ll a[22][22];
void work(ll w)
{
    int r2=0,r5=0;
    for(ll u=w;u%2==0;u/=2) r2++;
    for(ll u=w;u%5==0;u/=5) r5++;
    if(r2>=20) r2=20;
    if(r5>=20) r5=20;
    a[r2][r5]++;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        long double a=0;
        cin>>a;
        a=a*1e10;
        work(floor(a+0.49));
    }
    ll ans=0;
    for(int i=0;i<=20;i++)
        for(int j=0;j<=20;j++)
            for(int k=0;k<=20;k++)
                for(int l=0;l<=20;l++)
                if(i+k>=20 && j+l>=20)
                {
                    if(i==k && j==l) ans+=1ll*a[i][j]*(a[i][j]-1);
                    else ans+=1ll*a[i][j]*a[k][l];
                }
    printf("%lld\n",ans/2);
    return 0;
}

Measured memory_bytes: 3824
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
   int n;    
   cin>>n;
   if(n>=400 && n<=599)
   cout<<8;
   else if(n>=600 && n<=799)
   cout<<7;
    else if(n>=800 && n<=999)
   cout<<6;
    else if(n>=1000 && n<=1199)
   cout<<5;
    else if(n>=1200 && n<=1399)
   cout<<4;
    else if(n>=1400 && n<=1599)
   cout<<3;
    else if(n>=1600 && n<=1799)
   cout<<2;
    else if(n>=1800 && n<=1999)
   cout<<1;

    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
using ll = long long;

int main(){
	int N;
	scanf("%d", &N);
	int A[N][N];
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j) scanf("%d", &A[i][j]);
	}
	ll answer = 0;
	for (int i = 0; i < N - 1; ++i){
		for (int j = i + 1; j < N; ++j){
			bool flag = true;
			for (int k = 0; k < N; ++k){
				if(k != i && k != j){
					if(A[i][k] + A[k][j] < A[i][j]){
						printf("-1\n");
						return 0;
					}
					if(A[i][k] + A[k][j] == A[i][j]) flag = false;
				}
			}
			if(flag) answer += A[i][j];
		}
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	vector<int>v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	while(T--){
		int n;cin >>n;
		--n;
		cout << v[(n%32)] << endl;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(W>=x+r&&H>=y+r){
        if(x-r>=0&&y-r>=0){
        printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int ans=0;
  for(int i=0; i<3; i++){
    if(S.at(i) == 'o'){
      ans++;
    }
  }
  cout << ans*100+700 << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  map<string,ll> cnt;
  rep(i,n) {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    cnt[s]++;
  }
  ll a=0;
  for(auto& p : cnt) {
    string s;
    ll c;
    tie(s,c) = p;
    a+=c*(c-1)/2;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<pair<lint, lint>> v(n);
  for(int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    v[i] = {b, a};
  }

  sort(ALL(v));
  int cur = 0;
  for(int i = 0; i < n; i++) {
    cur += v[i].second;
    if(cur > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int k,t;
    cin>>k>>t;
    int s[t];
    for(int i=0;i<t;i++){
        cin>>s[i];
    }
    sort(s,s+t);
    if(k<s[t-1]*2-1){
        cout<<s[t-1]*2-k-1;
    }
    else cout<<0<<endl;
}



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

int main(void){
	string s, p;
	cin >>s;
	cin >>p;
	s+=s;
	if(s.find(p)==-1){
		cout <<"No" <<endl;
	}else{
		cout <<"Yes" <<endl;
	}
    return 0;
}

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

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

int main() {
	int N;
	while (cin >> N, N) {
		int xmax = 0, ymax = 0, xmin = 0, ymin = 0;
		vector<int>x(N, 0), y(N, 0);
		for (int i = 1; i < N; i++) {
			int n, d; cin >> n >> d;
			x[i] = x[n] + dx[d];
			y[i] = y[n] + dy[d];
			xmax = max(x[i], xmax);
			ymax = max(y[i], ymax);
			xmin = min(x[i], xmin);
			ymin = min(y[i], ymin);
		}
		cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
	}
}

Measured memory_bytes: 1196
def main():
    N = int(input())

    num = 1
    for i in range(6):
        if N >= (10**i)**2 and N < (10**(i+1))**2:
            for j in range(10**i, 10**(i+1)):
               if j**2 > 10**9 or j**2 > N:
                   print (num)
                   return
               else:
                   num = j**2
               

    print (num)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

template<typename T> class FloydWarshall{
    private:
        vector<vector<T>> dist;
    public:
        FloydWarshall(int n);
        void add(int from, int to, T cost);
        void build();
        T get(int from, int to);
};

template<typename T> FloydWarshall<T>::FloydWarshall(int n){
    dist = vector<vector<T>>(n + 1, vector<T>(n + 1));
    REP(i,0,n + 1) REP(j,0,n + 1){
        if (i == j) dist[i][j] = 0;
        else dist[i][j] = numeric_limits<T>::max() / 2;
    }
}

template<typename T> void FloydWarshall<T>::add(int from, int to, T cost){
    dist[from][to] = cost;
}

template<typename T> void FloydWarshall<T>::build(){
    int V = dist.size();
    REP(k,0,V)REP(i,0,V)REP(j,0,V){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
}

template<typename T> T FloydWarshall<T>::get(int from, int to){
    return dist[from][to];
}

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> seq(r);
    REP(i,0,r){
        cin >> seq[i];
    }

    FloydWarshall<int> fw(n);
    REP(i,0,m){
        int a, b, c;
        cin >> a >> b >> c;
        fw.add(a, b, c);
        fw.add(b, a, c);
    }

    fw.build();

    int ans = INT_MAX;
    sort(seq.begin(), seq.end());
    do{
        int t = 0;
        REP(i,1,r){
            t += fw.get(seq[i - 1], seq[i]);
        }
        ans = min(ans, t);
    }while(next_permutation(seq.begin(), seq.end()));

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//<(") 
#define ll long long   
using namespace std;
 
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
 
const ll mod = 1e9 + 7;
const ll siz =  2 * (6400 + 10);
const ll base = 32;
const ll MAXX = 1e18;

ll n, m;
ll hold[110][110];

bool res[81][81][siz];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n >> m;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			cin >> hold[i][j];
		}
	}
	
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			ll x;
			cin >> x;
			hold[i][j] = abs(hold[i][j] - x);
		}
	}
	
	res[0][0][0] = true;
	res[0][1][0] = true;
	res[1][0][0] = true;
	
	for (ll i = 1; i <= n; i++) {
		//res[i][0][0] = 0;
		for (ll j = 1; j <= m; j++) {
			for (ll k = 0; k < siz; k++) {
				bool &ans = res[i][j][k];
				ans = ans || res[i][j - 1][k + hold[i][j]];
				ans = ans || res[i][j - 1][abs(k - hold[i][j])];
				ans = ans || res[i - 1][j][k + hold[i][j]];
				ans = ans || res[i - 1][j][abs(k - hold[i][j])];
			}
		}
	}
	
	for (ll i = 0; i < siz; i++) {
		if (res[n][m][i]) {
			cout << i << '\n';
			return 0;
		}
	}
	
	return 0;
} 

Measured memory_bytes: 84180
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   int a,b,k;
   cin>>a>>b>>k;
   vector<int> v(100);
   rep(i,0,100){
      int j=i+1;
      if(a%j==0&&b%j==0){
         v.push_back(j);
      }
   }
   reverse(v.begin(),v.end());
   cout<<v[k-1]<<endl;
}


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

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

    int ans = 0;
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < i + 1; j++){
            sum += A[j];
        }
        for(int j = i; j < N; j++){
            sum += B[j];
        }
        ans = max(sum, ans);
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
N, Y = map(int, input().split())
flag = False
for a in range(N+1):
    for b in range(N-a+1):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y and c >= 0:
            flag = True
            break
    if flag:
        break
if flag:
    print('{} {} {}'.format(a, b, c))
else:
    print('-1 -1 -1')

Measured memory_bytes: 3060
import math
n = str(input()) 
keta = (len(n))
max = int(keta/2)+1

count = 0
t = int(n)
if(keta%2==0):
    for i in range(1,max):
        count += 9*10**((2*(i-1)))
else:
    for i in range(1,max):
        count += 9*10**((2*(i-1)))
    t = t - 10**(keta-1)
    count += t
    count +=1
print(count)


Measured memory_bytes: 3188
n = gets.to_i
ss = gets.chomp.chars
ans = ss.count("R") * ss.count("G") * ss.count("B")

0.upto(n) do |i|
  1.upto(n) do |j|
    k = i + j + j
    next unless k < n

    a = ss[i]
    b = ss[i + j]
    c = ss[k]
    ans -= 1 if [a, b, c].uniq.size == 3
  end
end

puts ans


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

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int _p[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int p[100010];
    rep(i, N) cin >> p[i];
    rep(i, N) p[i]--;
    rep(i, N) _p[p[i]] = i;
    UnionFind UF(N);
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        UF.merge(s, t);
    }
    int ans = 0;
    rep(i, N) {
        if (UF.issame(_p[i], i)) ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second
 
// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];
 
////////////////////////////////////////////////////////
ll n;
Vp adj[100001];
ll col[100001];

void bfs(){
    queue<ll> qu;
    qu.push(0);
    Vl d(n, INF);
    d[0] = 0;
    while(!qu.empty()){
        ll u = qu.front(); qu.pop();
        rep(i, 0, sz(adj[u])){
            ll v = adj[u][i].first;
            ll dist = adj[u][i].second;
            if(d[v]!=INF) continue;
            qu.push(v);
            d[v] = d[u] + dist;
        }
    }
    rep(i, 0, n) co((d[i]%2==0 ? 1 : 0));
}

int main() {
    cin >> n;
    rep(i, 0, n-1){
        ll u, v, w; cin >> u >> v >> w;
        u--, v--;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    bfs();

    return 0;
}
 

Measured memory_bytes: 11356
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    int[][][] residence = new int[4][3][10];
    int n = sc.nextInt();

    IntStream.range(0, n).forEach(i -> {
        int b = sc.nextInt() - 1;
        int f = sc.nextInt() - 1;
        int r = sc.nextInt() - 1;
        int v = sc.nextInt();
        
        residence[b][f][r] += v;
    });

    for (int i = 0; i < residence.length; i++) {
        for (int j = 0; j < residence[i].length; j++) {
            for (int k = 0; k < residence[i][j].length; k++) {
                pw.print(" " + residence[i][j][k]);
            }
            pw.println();
        }

        if (i != residence.length - 1) {
            pw.println("####################");
        }
    }

    pw.flush();
    sc.close();
  }
}


Measured memory_bytes: 33248
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,a[200005],l,r,mid,min1,flag;
int tail,zhan[200005];
map<int,int> mp;
map<int,int> :: iterator it;
int main(){
    n=read();
    for(i=1;i<=n;i++){
        a[i]=read();
        if(a[i]<=a[i-1]&&i!=1)
            flag=1;
    }
    if(flag==0){
        pus(1,2);
        return 0;
    }
    l=2;r=n;mid=(l+r)/2;min1=r;
    while(l<=r){
        tail=0;flag=0;
        for(i=2;i<=n;i++)
			if(a[i]<=a[i-1]){
	            
	            while(mp.size()!=0){
	            	it=mp.end();
	            	it--;
	            	if((it->first)>a[i])
	            		mp.erase(it);
	            	else
	            		break;
	            }
				mp[a[i]]++;
	            j=a[i];
	            while(mp[j]==mid){
	            	mp[j]=0;
	            	j--;
	            	mp[j]++;
	            }
	            if(j==0){
	            	flag=1;
	            	break;
	            }
	        }
        if(flag==1)
            l=mid+1;
        else{
            r=mid-1;
            min1=min(min1,mid);
        }
        mid=(l+r)/2;
        mp.clear();
    }
    pus(min1,2);
}

Measured memory_bytes: 1024
import numpy as np

A = []
for _ in range(3):
    A.append(list(map(int, input().split())))
N = input()
N = int(N)
B = []
for _ in range(N):
    b = input()
    B.append(int(b))
npA = np.array(A)
check = 'No'
for a in npA:
    if a[0] in B and a[1] in B and a[2] in B:
        check = 'Yes'
for a in npA.T:
    if a[0] in B and a[1] in B and a[2] in B:
        check = 'Yes'
dia = np.diag(npA)
if dia[0] in B and dia[1] in B and dia[2] in B:
    check = 'Yes'
diaT = np.diag(np.fliplr(npA))
if diaT[0] in B and diaT[1] in B and diaT[2] in B:
    check = 'Yes'
print(check)

Measured memory_bytes: 12504
A, B = map(int, input().split())
sub = B - A + 1

if A % 2 == 0:
  if sub % 4 == 0:
    print(0)
  elif sub % 4 == 2:
    print(1)
  elif sub % 4 == 1:
    print(B)
  else:#sub%4 == 3 Bは必ず偶数
    print(B + 1)
else:#Aが奇数のときはAは相殺されない
  if sub % 4 == 1:
    print(A)
  elif sub % 4 == 3:
    print(A - 1)
  elif sub % 4 == 2:
    print(A ^ B)
  else:#sub%4 == 0 Bは必ず偶数
    print((A-1) ^ B)

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo& operator += (modulo b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	modulo& operator -= (modulo b) { if ((w -= b.w) < 0) w += mod; return *this; }
	modulo& operator *= (modulo b) { w = (num) w * b.w % mod; return *this; }
	modulo& operator /= (modulo b) { w = (num) w * b.inv() % mod; return *this; }
	modulo inline operator + (modulo b) { modulo r = *this; r += b; return r; }
	modulo inline operator - (modulo b) { modulo r = *this; r -= b; return r; }
	modulo inline operator * (modulo b) { modulo r = *this; r *= b; return r; }
	modulo inline operator / (modulo b) { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9 + 7);
typedef modulo<mod> rem;

const int nsz = int(5e3);
int n, k, a[nsz + 5];
rem dp[nsz + 5], ans;
vector<int> r;

struct union_find {
	int pr[nsz + 5], siz[nsz + 5];
	
	union_find() {
		cont (u, nsz) pr[u] = u, siz[u] = 1;
	}
	
	int inline operator [] (int id) { return qry(id); }
	
	int qry(int u) { return pr[u] == u ? u : pr[u] = qry(pr[u]); }
	
	bool inline link(int u, int v) {
		int pu = qry(u), pv = qry(v);
		if (pu == pv) return 0;
		pr[pv] = pu;
		siz[pu] += siz[pv];
		return 1;
	}
};
union_find uf;

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
		if (a[i] != -1) uf.link(a[i], i);
		if (a[i] == -1) r.push_back(i);
	}
	k = int(r.size());
	
	cont (u, n) {
		if (uf[u] != u || a[u] == -1) continue;
		ans += rem(n - 1).pow(k);
	}
	
	dp[0] = 1;
	loop (i, k) {
		int u = r[i];
		for (int j = i; j >= 0; --j) {
			dp[j + 1] += dp[j] * (j ? rem(j) : rem(1)) * rem(uf.siz[u]);
		}
	}
	
	cont (j, k) {
		ans += dp[j] * rem(n - 1).pow(k - j);
	}
	cont (u, n) {
		if (uf[u] != u || a[u] != -1) continue;
		ans -= rem(n - 1).pow(k - 1);
	}
	
	ans = rem(n) * rem(n - 1).pow(k) - ans;
	printf("%d\n", ans);
}

Measured memory_bytes: 3924
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int dp[50][3001];
int n, m, s;
const int mod = 100000;

int main() {
	while (cin >> n >> m >> s, n || m || s) {
		n *= n;
		
		fill(dp[0], dp[n + 1], 0);
		
		dp[0][0] = 1;
		FOR(i, 1, m + 1) for (int j = n - 1; j >= 0; j--) REP(k, s + 1) {
			if (k + i > s) break;
			dp[j + 1][k + i] += dp[j][k];
			dp[j + 1][k + i] %= mod;
		}
		
		
		cout << dp[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
N = int(input())
ans = N+1
for i in range(1,N//2+1):
    stra = str(i)
    strb = str(N-i)
    a = ''
    b = ''
    for j in range(len(stra)):
        a += stra[j]+'+'
    a = a[:-1]
    for j in range(len(strb)):
        b += strb[j]+'+'
    b = b[:-1]
    ans = min(ans,eval(a)+eval(b))
print(ans)
        

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

int main(){
  int N; cin >> N;
  string s; cin >> s;
  int ans = 0;
  for(int number = 0; number < 1000; number++){
    int c100 = number/100;
    int c10 = (number - 100*c100)/10;
    int c1 = (number - 100*c100 - 10*c10);
    int var = -1;
    bool ok = true;
    for(int i = 0; i < N; i++){
      if(s[i] - '0' == c100){
        var = i;
        break;
      }
    }
    if(var == -1){
      ok = false;
      continue;
    }
    int var1 = -1;
    for(int i = var + 1; i < N; i++){
      if(s[i] - '0' == c10){
        var1 = i;
        break;
      }
    }
    if(var1 == -1){
      ok = false;
      continue;
    }
    int var2 = -1;
    for(int i = var1 + 1; i < N; i++){
      if(s[i] - '0' == c1){
        var2 = i;
        break;
      }
    }
    if(var2 == -1) ok = false;
    if(ok)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

#define ll long long int

int main()
{
    ll n, k;
    cin >> n;
    ll arr[n];
    for (ll x = 0; x < n; x++)
    {
        cin >> arr[x];
    }
    ll sum = 0;
    ll mx = 0;
    for (ll x = 0; x < n; x++)
    {
        if (arr[x] < mx)
        {
            sum = sum + mx - arr[x];
        }
        else
        {
            mx = arr[x];
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,M;

int dist[100][100];
const int INF=LLONG_MAX/1000;
signed main(){
    fill_n(*dist,10000,INF);

    cin>>N>>M;
    for(int i=0;i<N;i++)dist[i][i]=0;
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        dist[a][b]=c;
    }

    for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

    for(int i=0;i<N;i++){
        if(dist[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<(j?" ":"");
            if(dist[i][j]>(1e9)*2)cout<<"INF";
            else cout<<dist[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>

int main()
{
	int k,a,b;
	scanf("%i %i %i",&k,&a,&b);
	if(!(a%k)||!(b%k)) {puts("OK");return 0;}
	int di = a/k;
	di = k*(++di);
	if(di>=a && di<=b) puts("OK");
	else puts("NG");
	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A, B; cin >> A >> B;
    long long C = B - A + 1;
    long long ans = 0;
    for (unsigned long long i = 0; i <= 40; i++) {
        if (i == 0) {
            if (C % 2 == 0) ans = (C / 2) % 2;
            else ans = ((C / 2) + (A & 1)) % 2;
            continue;
        }
        long long T = C % (1LL << (i+1));
        long long M = (1LL << (i+1)) - 1;
        long long start = A & M;
        long long end = start + T;
        long long cnt = max(0LL, min(1LL << (i+1), end) - max(1LL << i, start))
            + max(0LL, min(1LL << (i+2), end) - max((1LL << (i+1)) + (1LL << i), start));
        ans |= (cnt % 2 == 1 ? 1LL : 0LL) << i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256