akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) (x).begin(),(x).end()


void dfs(vector<vector <ll>> &v,ll p ,vector <bool> &vis)
{

vis[p]=true;

for(auto it=v[p].begin();it!=v[p].end();++it)
{
if(vis[*it]==false)
	dfs(v,*it,vis);

}

}


int main()
{
fast;
ll n,m;
cin>>n>>m;

vector <vector <ll>> v(n+1);

for(int i=1;i<=m;i++)
{
ll x,y;
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
	
}

vector <bool> vis(n+1,false);

ll ans=0;

for(int i=1;i<=n;i++)
{
if(vis[i])continue;
dfs(v,i,vis);
ans++;

}

cout<<ans-1<<endl;
		
}



Measured memory_bytes: 10308
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int r = line[0];
            int g = line[1];
            int b = line[2];
            int n = 100 * r + 10 * g + b;
            Console.WriteLine(n % 4 == 0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 11476
#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
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    pair<int, int> A[100010];
    rep(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A + N);
    int ans = 0;
    rep(i, N) {
        if (A[i].second < M) {
            ans += A[i].first * A[i].second;
            M -= A[i].second;
        } else {
            ans += A[i].first * M;
            break;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  vector<i64> t(2), a(2), b(2);
  for (auto &x : t) cin >> x;
  for (auto &x : a) cin >> x;
  for (auto &x : b) cin >> x;
  if (a[0] * t[0] + a[1] * t[1] == b[0] * t[0] + b[1] * t[1]) kek("infinity");
  if (a[0] > b[0]) swap(a, b);
  if (a[1] < b[1]) kek(0);
  if (a[0] * t[0] + a[1] * t[1] < b[0] * t[0] + b[1] * t[1]) kek(0);
  //~ error(a, b);
  i64 d = a[0] * t[0] + a[1] * t[1] - b[0] * t[0] - b[1] * t[1];
  i64 p = b[0] * t[0] - a[0] * t[0];
  //~ error(d, p, p/d, d/p);
  i64 c = (p - 1) / d * 2 + 1 + (p % d == 0);
  kek(c);
  
  return 0;
}


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

int main() {
    ll N, M; cin >> N >> M;
    if (N > M) swap(N, M);

    if (N == 2) cout << 0 << endl;
    else cout << max(1LL, N - 2) * max(1LL, M - 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	int n;
	string s;
	cin >> s;
	bool flag = false;
	rep(i,s.size()){
		if(i%2){
			if(!(s[i] == 'L' || s[i]=='U'|| s[i]=='D')){
				flag = true;
			}
		}
		else{
			if(!(s[i] == 'R' || s[i]=='U'|| s[i]=='D')){
				flag = true;
			}
		}
	}
	cout << (flag?"No":"Yes") << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int r;

    cin >> r;

    if (r < 1200) {
        cout << "ABC\n";
    } else if (r < 2800) {
        cout << "ARC\n";
    } else {
        cout << "AGC\n";
    }
    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

string S;

// *********************************************************
int main(){

    cin >>  S;

    int len = S.length() -1;
    
    if(S[len]=='s'){
        cout << S << "es" <<endl;
    }else{
        cout << S << "s"<<endl;
    }





    return 0;
}

Measured memory_bytes: 3636
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
 
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion
lint n;
vector<int> a;
bool isOK(int index, int key) {
	if (a[index] >= key) return true;
	else return false;
}
 
int binary_search(int key) {
	int ng = -1; 
	int ok = (int)a.size();
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (isOK(mid, key)) ok = mid;
		else ng = mid;
	}
	if (a[ok] == key)
		return ok;
	else
		return -1;
}
 
 
int main(void) {
    vl e = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,4294967296,8589934592,17179869184};
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	lint ans = 0;
	lint cnt = 0;
 	while (a.size() > 1) {
		for (int i = 30; i >= 0; i--) {
			if (a[a.size() - 1] >= e[i]) {
				cnt = e[i + 1];
				break;
			}
		}
		int d = a[a.size() - 1];
		a.pop_back();
		int x = binary_search(cnt - d);
		if (x != -1 && x != a.size()) {
			ans++;
            a.erase(a.begin() + x);
		}
	}
	printf("%lld\n", ans);
 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> t0(N);
  for (int i = 0; i < N; i++)
    cin >> t0.at(i);
  
  int M;
  cin >> M;
  
  vector<int> prob(M), t(M);
  for (int i = 0; i < M; i++) {
    cin >> prob.at(i) >> t.at(i);
    prob.at(i)--;
  }
  
  for (int i = 0; i < M; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if (j != prob.at(i))
        sum += t0.at(j);
      else
        sum += t.at(i);
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
#[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, isize1) => {
        read_value!($iter, isize) - 1
    };
    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

    ($iter:expr, $t:tt) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

#[allow(dead_code)]
fn to_yesno(yesno: bool) -> &'static str {
    if yesno {
        "Yes"
    } else {
        "No"
    }
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}

#[allow(unused_mut)]
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    #[allow(unused_macros)]
    macro_rules! out {
        ($arg:expr) => {{
            let _ = out.write_fmt(format_args!("{}",$arg));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    #[allow(unused_macros)]
    macro_rules! outln {
        ($arg:expr) => {{
            out!("{}\n",$arg);
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "\n"), $($args)*);
        }};
    }

    input! {
        source = src,
        a:isize,
        b:isize,
        c:isize,
        d:isize,
    }

    let r_ac = a * c;
    let r_bd = b * d;
    let r_ad = a * d;
    let r_bc = b * c;
    out!(max(max(r_ac, r_bd), max(r_ad, r_bc)));
}
test! {}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL x;
    cin >> x;
    LL res = x / 11 * 2;
    x %= 11;
    if(x >= 7) res++;
    if(x > 0) res++;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,i=100000,b;
scanf("%d",&a);
for(b=0;b<a;b++){
i=i*1.05;
if(i%1000!=0){
i=i/1000;
i=i*1000+1000;
}
}
printf("%d\n",i);
return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#define int long long
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int N,M,K;
int p[2][100000];
signed main(){
	int i,j,k;
	cin>>K;
	if(K==100000){
		cout<<1<<endl;
		return 0;
	}
	for(i=0;i<2;i++)
		for(j=0;j<100000;j++)
			p[i][j]=inf;
	int f=0;
	int q[2][100000]={};
	vector<int> ve[2];
	for(i=1;i<10;i++)
		if(chmin(p[f][(K*i)/10],(K*i)%10))
			if(q[f][(K*i)/10]==0){
				q[f][(K*i)/10]=1;
				ve[f].push_back((K*i)/10);
			}
	int ans=inf;
	for(;!ve[f].empty();f=1-f){
		for(auto j:ve[f]){
			q[f][j]=0;
			for(k=0;k<10;k++)
				if(chmin(p[1-f][(j+(K*k))/10],p[f][j]+(j+(K*k))%10))
					if(q[1-f][(j+(K*k))/10]==0){
						q[1-f][(j+(K*k))/10]=1;
						ve[1-f].push_back((j+(K*k))/10);
					}
			int u=j;
			int x=p[f][j];
			for(k=0;k<5;k++){
				x+=u%10;
				u/=10;
			}
			chmin(ans,x);
		}
		ve[f].clear();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FSmallProducts {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll N, K;
	    in >> N >> K;
	    vector<ll> range, tails;
	    REP(i,1,N+1) {
	        const ll counterpart = N / i + 1;
	        if (counterpart < i) break;
	        if (!tails.empty() && counterpart == tails.back()) continue;
	        range.push_back(i);
	        if (i != counterpart) tails.push_back(counterpart);
	    }
	    reverse(all(tails));
	    copy(all(tails), back_inserter(range));
	    vector<ll> dp(range.size());

	    // range: {1,2,...,N/2+1,N+1}
	    REP(i,0,range.size()-1) {
            dp[i] = range[i+1] - range[i];
        }
	    REP(i,1,K) {
	        vector<ll> sum(range.size());
	        REP(j,0,range.size()-1) {
	            sum[0] += dp[j];
	            if (sum[0] > MOD) sum[0] %= MOD;
	            sum[range.size()-j-1] -= dp[j];
                sum[range.size()-j-1];
	        }
	        ll currentSum = 0;
	        REP(j,0,range.size()-1) {
	            currentSum += sum[j];
	            if (currentSum < 0) currentSum += MOD;
	            currentSum %= MOD;
	            dp[j] = currentSum * (range[j+1] - range[j]);
	            dp[j] %= MOD;
	        }
	    }
	    ll answer = 0;
	    REP(i,0,range.size()-1) {
	        answer += dp[i];
	        answer %= MOD;
	    }
	    out << answer << "\n";
	}
};


int main() {
	FSmallProducts solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <string.h>

int main(void){
    int a,b;
    char s[10],t[10],u[10];

    scanf("%s%s",s,t);
    scanf("%d%d",&a,&b);
    scanf("%s",u);
    
    if(strcmp(s,u)==0){
        printf("%d\t%d",a-1,b);
    }

    else if(strcmp(t,u)==0){
        printf("%d\t%d",a,b-1);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
main()
{
    int a;
    cin >> a;
    int b[a];
    int c[a] ;
    for( int i = 0; i < a; i++ )
    {
        cin >> b[i];
        c[i] = b[i];
    } 
    int cnt = 0;
    sort( c, c + a );
    for( int i = 0; i < a; i++ ) 
    {
        if( c[i] != b[i] )cnt++;
        if( cnt > 2 ){puts("NO");return 0;}
        
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// from std...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize, fmt::Debug};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

/// `l`が`pred`に対し`true`, `r`が`pred`に対し`false`を返す時
/// `l`と`r`の中間の値のうちで最後に`pred`を満たすものを返す
pub fn binary_search<T, F>(l: T, r: T, pred: F) -> T
where
    T: Add<Output = T> + Div<Output = T> + PartialEq + From<u8> + Copy + Debug,
    F: Fn(T) -> bool,
{
    let mut l = l;
    let mut r = r;
    let two = T::from(2u8);

    loop {
        let m = (l + r) / two;
        dbg!(m);
        if l == m || r == m {
            break l;
        }
        if pred(m) {
            l = m;
        } else {
            r = m;
        }
    }
}

/// vの要素について最初に現れたval以上の要素のインデックスを返す
pub fn lower_bound<T: PartialOrd>(v: &[T], val: &T) -> usize {
    (binary_search(-1i64, v.len() as i64, |i| v[i as usize] < *val) + 1) as usize
}

/// vの要素について最初に現れたvalより大きい要素のインデックスを返す
pub fn upper_bound<T: PartialOrd>(v: &[T], val: &T) -> usize {
    (binary_search(-1i64, v.len() as i64, |i| v[i as usize] <= *val) + 1) as usize
}

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, m: usize,
    }
    if n * 2 > m {
        println!("{}", m / 2);
    } else {
        let f = |i| {
            let s = i;
            let c = 2 * n + m - 2 * s;
            s * 2 <= c
        };
        let ans = binary_search(n, n + m / 2, f);
        println!("{}", ans);
    }
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int INF = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s=="RRR"){
		cout<<3<<'\n';
	}
	else if(s[0]=='R' && s[1]=='R'){
		cout<<2<<'\n';
	}
	else if(s[1]=='R' && s[2]=='R'){
		cout<<2<<'\n';
	}
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
		cout<<1<<'\n';
	}
	else{
		cout<<0<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3616
function main(input) {
  var input = input.split("\n")
  var text = input[0].slice()
  text = text.split("")
  
  for (var i = 0; i <= text.length; i++) {
    var p = text.shift()
    text.push(p)
    if(text.join("") === input[1]) {
      console.log("Yes")
      return
    }
  }
  console.log("No")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define K (26) // コンテストの種類

int D;
vector<int> c(K);
vector<vector<int>> s;

// コンテストのタイプおよび日付は0-indexedで数える
void input(void){
	cin >> D;
	for (auto& ci : c)
		cin >> ci;
	s.resize(D, vector<int>(K));
	for (int i = 0; i < D; ++i)
		for (auto& sij : s[i])
			cin >> sij;
}

vector<int> t; // 暫定解
vector<set<int>> c_day(K); // c_day[i] : コンテストiが開催される日程
int score; // 暫定解のスコア

int calc_score(void){
	vector<int> lst_held(K, -1);
	int score = 0;
	for (int i = 0; i < D; ++i){
		score += s[i][t[i]];
		lst_held[t[i]] = i;
		for (int c_id = 0; c_id < K; ++c_id){
			score -= c[c_id] * (i - lst_held[c_id]);
		}
	}
	return score;
}

void init_t(void){
	t.resize(D);
	for (auto& ti : t){
		cin >> ti; --ti;
	}
	for (int c_id = 0; c_id < K; ++c_id)
		c_day[c_id].insert(-1);
	for (int i = 0; i < D; ++i)
		c_day[t[i]].insert(i);
	for (int c_id = 0; c_id < K; ++c_id)
		c_day[c_id].insert(D);
	score = calc_score();
}

void print_t(void){
	for (auto ti : t)
		cout << (ti + 1) << endl;
}

// d日目をc_idに変更する
void update_t(int d, int c_id){
	// 消す処理
	int del_c = t[d];
	auto iter = c_day[del_c].lower_bound(d);
	int prv = *(--iter); ++iter;
	int nx = *(++iter); --iter;
	c_day[del_c].erase(iter);
	score -= s[d][del_c];
	score -= c[del_c] * (d - prv) * (nx - d);
	// 増やす処理
	iter = c_day[c_id].lower_bound(d);
	nx = *iter;
	--iter;
	prv = *iter;
	score += c[c_id] * (d - prv) * (nx - d);
	score += s[d][c_id];
	c_day[c_id].insert(d);
	// tの変更
	t[d] = c_id;
}

int main(void){
	input();
	init_t();
	int M; cin >> M;
	while (M--){
		int d, q; cin >> d >> q;
		--d, --q;
		update_t(d, q);
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    int[][] card = new int[3][3];
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        card[i][j] = in.nextInt();
      }
    }
    int n = in.nextInt();
    int[] target = new int[n];
    for(int i=0; i<n; i++){
      target[i] = in.nextInt();
    }
    System.out.println(bingo(card, target));
  }
  
  static String bingo(int[][] card, int[] target){
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        for(int k=0; k<target.length; k++){
          if(card[i][j] == target[k]){
            card[i][j] = 0;
            break;
          }
        }
      }
    }
    if(card[0][0]==0 && card[0][1]==0 && card[0][2]==0) return "Yes";
    if(card[1][0]==0 && card[1][1]==0 && card[1][2]==0) return "Yes";
    if(card[2][0]==0 && card[2][1]==0 && card[2][2]==0) return "Yes";

    if(card[0][0]==0 && card[1][0]==0 && card[2][0]==0) return "Yes";
    if(card[0][1]==0 && card[1][1]==0 && card[2][1]==0) return "Yes";
    if(card[0][2]==0 && card[1][2]==0 && card[2][2]==0) return "Yes";

    if(card[0][0]==0 && card[1][1]==0 && card[2][2]==0) return "Yes";
    if(card[0][2]==0 && card[1][1]==0 && card[2][0]==0) return "Yes";
    return "No";
  }
}


Measured memory_bytes: 23764
from collections import Counter
n, k = map(int, input().split())
ns = list(map(int, input().split()))
dic = Counter(ns)
result = 0
len_dic = len(dic)
for key, value in sorted(dic.items(), key=lambda x: x[1]):
    if len_dic <= k:
        break
    len_dic -= 1
    result += value
print(result)

Measured memory_bytes: 39340
import math

#n = int(input())
a, b = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = input()
#list = list(s)

if ( (a + b) % 2 == 1 ) :
    print("IMPOSSIBLE")
else :
    print(int((a+b)/2))



Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

long long C(long long n) {
    return (n * (n-1)) / 2;
}

void solve(long long N, vector<long long> A){
    vector<long long> cums(N+1);
    cums[0] = 0;
    for (int i = 1; i < N+1; i++) {
        cums[i] = cums[i-1] + A[i-1];
    }
    sort(cums.begin(), cums.end());
    long long ret = 0;
    long long n = 1;
    for (int i = 1; i < N+1; i++) {
        if (cums[i-1] == cums[i]) {
            n++;
        } else {
            ret += C(n);
            n = 1;
        }
    }
    ret += C(n);
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var S = new List<int>();
        var c0 = 0;
        var c1 = 0;
        var c2 = 0;
        var c3 = 0;
        for(int i = 0; i < N; i++)
        {
            var s = Console.ReadLine();
            if (s == "AC") c0++;
            else if (s == "WA") c1++;
            else if (s == "TLE") c2++;
            else c3++;
        }

        Console.WriteLine($"AC x {c0}");
        Console.WriteLine($"WA x {c1}");
        Console.WriteLine($"TLE x {c2}");
        Console.WriteLine($"RE x {c3}");
    }
}


Measured memory_bytes: 30892
#include <iostream>

using namespace std;

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(d%s==0)
    {
        if(d/s<=t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    else
    {
        if(d/s<t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
int flag=1;
int c=0;
int k;
void runnrunn(int number,int place,string s){
	char num='0'+number;
	s+=num;
	if(place==1){
		c++;
		if(c==k){
			cout <<s;
			flag=0;
		}
		return;
	}
	else{
		if(number-1>=0 && flag)runnrunn(number-1,place-1,s);
		if(flag)runnrunn(number,place-1,s);
		if(number+1<=9&&flag)runnrunn(number+1,place-1,s);
	}
	return;
}
		
int main(){
	cin>>k;
	string s;
	int i=0;
	while(flag){
		i++;
		rep(j,9){
			runnrunn(j+1,i,s);
		}
	}
	return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
ab = []
for i in range (m):
    ab.append(list(map(int, input().split())))

par = [-1] * (n+1)
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        tank = []
        while par[x] >= 0:
            tank.append(x)
            x = par[x]
        for elt in tank:
            par[elt] = x
        return x
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return 

for j in range(m):
    unite(ab[j][0], ab[j][1])

m = -1*min(par)
print(m)



Measured memory_bytes: 47112
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 3e5 + 10;

typedef vector<vector<ll> > mtrx;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int n, a[N], cnt[N];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	int ans = 0;
	for (int i = 1; i < N - 1; i++) {
		ans = max(cnt[i] + cnt[i - 1] + cnt[i + 1], ans);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ABC089_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = new string[n].Select(x => Console.ReadLine()).Distinct().ToArray();
            var m = 0;
            var a = 0;
            var r = 0;
            var c = 0;
            var h = 0;
            foreach (var ch in s)
            {
                if (ch[0] == 'M')
                    m++;
                else if (ch[0] == 'A')
                    a++;
                else if (ch[0] == 'R')
                    r++;
                else if (ch[0] == 'C')
                    c++;
                else if (ch[0] == 'H')
                    h++;

            }
            long ans = 0;
            var d = new int[10] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
            var e = new int[10] { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
            var f = new int[10] { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };

            var num = new long[5] { m, a, r, c, h };
            for (var i = 0; i < 10; i++)
            {
                ans += num[d[i]] * num[e[i]] * num[f[i]];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25312
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a = input()
n = len(a)
s = set()
l = []
i = n-1
prv = n
for c in a[::-1]:
    s.add(c)
    if len(s)==26:
        s = set()
        l.append((i,prv))
        prv = i
    i -= 1
def sub(i,j):
    """[i,j)に含まれない文字のうちの最小
    """
#     print(i,j)
    al = set([chr(v) for v in range(ord("a"), ord("z")+1)])
    for ind in range(i,j):
        al.discard(a[ind])
    return min(al)
ans = []
c = sub(0,prv)
ans.append(c)
while l:
    i,j = l.pop()
    for ind in range(i,n):
        if a[ind]==c:
            break
    c = sub(ind+1,j)
    ans.append(c)
ans = "".join(ans)
# else:
#     ans = "a" * (len(l)+1)
print(ans)

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

int main(){
  int64_t A,B,K;
  cin>>A>>B>>K;
  if(A>=K){
    cout<<A-K<<" "<<B<<endl;
  }
  else if(B>=K-A){
    cout<<0<<" "<<B-(K-A)<<endl;
  }
  else{
    cout<<0<<" "<<0<<endl;
  }
}

Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << cnk(a, 2) + cnk(b, 2);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int x;
	int sum;
	int i;
	cin>>n;
	x=n;
	sum=0;
	while(x>0){
		sum+=x%10;
		x/=10;
	}
	if(n%sum==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
using namespace std;
string s[300009];
ll ans = 0;
ll mypow(ll a, ll b, ll modd) {
    ll rv = 1;
    while (b) {
        if (b % 2)
            rv = 1ll * rv * a%modd;
        a = 1ll * a * a %modd;
        b /= 2;
    }
    return rv;
}
int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) {
        ll x;
        cin>>x;
        while(x != 0) {
            s[i].push_back(x % 2 + 48);
            x /= 2;
        }
    }
    for(int j = 0; j < 64; j++) {
        int cnt0 = 0, cnt1 = 0;
        for(int i = 0; i < n; i++) {
            if(s[i].size() > j) {
                cnt0 += (s[i][j] == '0');
                cnt1 += (s[i][j] == '1');
            }
            else
                cnt0++;
        }
        ans += (1ll * cnt0 * cnt1) % mod * 1ll * mypow(2, j, mod) % mod;
        ans %= mod;
        //cout<<j<<" "<<ans<<endl;
    }
    cout<<ans;
}
/*
 9 2
 6 19 3 4 4 2 6 7 8
 1 7 21
 1 5 18
 1 3 14
 1 1 8
 0 8 38
 0 6 36
 0 4 32
 0 2 26
 */


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int dp[100100][20];
string s;

signed main() {

    cin >> s;

    //for(int i = 0; i <= 13; i++) dp[0][i] = 1;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++) {
        int t = s[i] - '0';
        for(int j = 0; j <= 13; j++) {
            if(s[i]=='?') {
                for(int k = 0; k < 10; k++) {
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                    dp[i+1][(j*10+k)%13] %= SMOD;
                }
            }else {
                dp[i+1][(j*10+t)%13] += dp[i][j];
                dp[i+1][(j*10+t)%13] %= SMOD;
            }
        }
    }
    
    cout << dp[s.size()][5] << endl;
    
  
    return 0;
}



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

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for (ll b = 1; b <= n; b++) {
    ans += n / b * max((ll)0, b - k);
    ans += max((ll)0, n % b - k + 1);
  }
  if (k == 0) ans -= n;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    Vl csum(N + 1);
    for (int i = 0; i < N; i++) {
        csum[i + 1] = csum[i] + A[i];
    }
    int a = -1;
    for (int i = 0; i < N - 1; i++) {
        if (csum[i + 1] * 2 < A[i + 1]) {
            a = max(a, i);
        }
    }

    cout << N - a - 1 << endl;

    return 0;
}

Measured memory_bytes: 1792
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

typedef pair<Pii, Pii> P;

P change(P x, P y) {
    set<Pii> pq;
    pq.insert(x.first);   
    pq.insert(x.second);   
    pq.insert(y.first);   
    pq.insert(y.second);
    auto a = *(--pq.end());
    pq.erase(a);
    auto b = *(--pq.end());
    return {a, b};
}

int main() {
    int n; cin >> n;
    vector<int> da((1 << n));
    rip(i,1 << n,0) cin >> da[i];
    vector<pair<Pii,Pii>> dp((1 << n));
    int m = 1 << n;
    rip(i,m,0) {
        dp[i] = {{da[i], i},{da[0], 0}};
        int now = 1;
        rip(j,n,0) {
            if(now&i) {
                dp[i] = change(dp[i], dp[i-now]);
            }
            now <<= 1;
        }
    }
    vector<int> ans(m);
    rip(i,m,1) {
        ans[i] = max(ans[i-1], dp[i].first.first + dp[i].second.first);
    }
    rip(i,m,1) {
        printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 9216
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,D,count;
  	count=0;
    cin >> N >> D;
    long long x[N],y[N];
    for(int i=0; i<N; i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0; i<N; i++){
        if(sqrt(abs(x[i]*x[i])+abs(y[i]*y[i]))<=D){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 6796
class UnionFind:
    def __init__(self, n):
        self.sz = [ -1 for i in range(n)]

    # 検索
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]


    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x,y = y,x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def size(self,x):
        return -self.sz[self.find(x)]


N,M = map(int,input().split())
ab = []
for i in range(M):
    a,b = map(int,input().split())
    ab.append([a-1,b-1])
uf = UnionFind(N)

ansl = [0]*(M)
ma = N*(N-1)//2
for i in range(M-1,-1,-1):
    ansl[i] = ma
    if uf.find(ab[i][0]) != uf.find(ab[i][1]):
        ma -= uf.size(ab[i][0])*uf.size(ab[i][1])
        uf.union(ab[i][0],ab[i][1])

for i in range(len(ansl)):
    print(ansl[i])



Measured memory_bytes: 105560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0;
    int tmp=0;
    vector<int> natural;


    cin>>N;
    for(int i=0;i<N;i++){
        cin>> tmp;
        natural.push_back(tmp);
    }

    sort(natural.begin(), natural.end());

    for(auto itr=natural.end()-1;itr!=natural.begin();--itr){
        for(auto pulled=natural.begin();pulled!=natural.end();++pulled){
            if((*itr-*pulled)%(N-1)==0&&*itr!=*pulled){
                cout<<*itr<<" "<<*pulled<<"\n";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3172
from collections import Counter

S = input()
T = input()

alps_counter_s = Counter(S).most_common()
alps_counter_t = Counter(T).most_common()

for s, t in zip(alps_counter_s, alps_counter_t):
    if s[1] != t[1]:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 9588
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        int max = 0;
        for (char c : s.toCharArray()) {
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                count++;
            } else {
                max = Math.max(max, count);
                count = 0;
            }
        }
      	max = Math.max(max, count);
        System.out.println(max);
    }
}


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

int main() {
    long long N; cin >> N;
    vector<char> name;
    
    long long syou = N;
    while (syou > 0) {
        int amari, e = 0;
        amari = syou % 26;
        if (amari == 0) {
            amari = 26;
            e = -1;
        }
        name.push_back(amari+96);
        syou = syou / 26 + e;
    }
    
    for (int i = name.size()-1; i >= 0; i--) cout << name.at(i);
    cout << endl;
}

Measured memory_bytes: 3628
N, Y = gets.chomp.split.map(&:to_i)

0.upto(N) do |x|
  0.upto(N-x) do |y|
    if 10000 * x + 5000 * y + (N - x - y) * 1000 == Y
      puts "#{x} #{y} #{N - x - y}"
      exit
    end
  end
end
puts '-1 -1 -1'


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)

int main() { 
  int n;cin>>n;
  cout << n/3 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
long long N,D,po,o=0;
  double pu;
  long long x,y;
  cin>>N>>D;
  for(int i=0;i<N;i++){
cin>>x>>y;
    po=pow(x,2)+pow(y,2);
    pu=sqrt(po);
    if(pu<=D){
o++;
    }
  }
    cout<<o<<endl;
  return(0);
}

Measured memory_bytes: 3672