akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


vector<pint> edge[20];
bool visit[20];
int sum, max_save;

void dfs(const pint& in, int sum_cost)
{
	if (visit[in.first])
		return;
	else if (in.first && edge[in.first].size() == 1)
	{
		max_save = max(max_save, sum_cost);
		return;
	}

	visit[in.first] = true;
	sum += in.second;
	foreach (it, edge[in.first])
		dfs(*it, sum_cost + in.second);
}
int main()
{
	int N;
	while (scanf("%d", &N), N)
	{
		for (int i = 0; i < N; ++i)
			edge[i].clear();
		fill(visit, visit+N, false);
		for (int i = 0; i < N-1; ++i)
		{
			int a, b, t;
			scanf("%d%d%d", &a, &b, &t);
			--a; --b;
			edge[a].push_back(pint(b, t));
			edge[b].push_back(pint(a, t));
		}

		sum = max_save = 0;
		dfs(pint(0, 0), 0);
		printf("%d\n", 2*sum - max_save);
	}

	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;

	int n, k; cin >> n >> k;
	n %= k;
	int ans = min(n, k - n);
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)


////////////////////////////////////////////////////////////

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

	vector<long> b(n);
	rep(i,0,n)
		cin >> b[i];
	vsort(b);

	vector<long> c(n);
	rep(i,0,n)
		cin >> c[i];
	vsort(c);
	
	long long ans = 0;
	rep(i,0,n){
		long num = b[i];
		auto itr_a = lb(a,num);
		int idx_a = itr_a - a.begin();
		auto itr_c = ub(c,num);
		int idx_c = itr_c - c.begin();
		
		//cout << "ia:" << idx_a << " ic:" << idx_c << endl;
		
		
		if(idx_a == n)
			if( a[idx_a-1] > num ){
				P("d");
				continue;
			}

		ans += (long long)(idx_a) * ( n - idx_c );

	}
	P(ans);
	ret 0;
}

Measured memory_bytes: 2560
#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 unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
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 rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	int n, m; cin >> n >> m;
	modint ans= 0;
	rep(i, n + 1) {
		modint csum = comb(n, i)*combP(m,i);
		csum *= combP(m - i, n - i) * combP(m - i, n - i);
		if (i % 2 == 0)ans += csum;
		else ans -= csum;
		//cout << i << " " << csum << "\n";
	}
	cout << ans << "\n";
}



signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout << fixed << setprecision(10);
	init_f();
	//int t; cin >> t; rep(i, t)
	solve();
		return 0;
}


Measured memory_bytes: 19988
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int W, H;
    cin >> W >> H;
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    
    pair<int, int> a1 = mp(W - 1, 0), a2 = mp(W - 1, H - 1), b1 = mp(W - 2, 1), b2 = mp(W - 2, H - 2);
    
    int as = 0, bs = 0; // 0, 1, 2
    pair<int, int> anow = mp(0, 0), bnow = mp(0, 1);
    
    int ret = 0;
    
    rep(i, N){
        if (P[i] == 0) {
            if (as == 0) anow.first++;
            if (as == 1) anow.second++;
            if (as == 2) anow.first--;
            if (anow == a1) as = 1;
            if (anow == a2) as = 2;
        }
        if (P[i] == 1) {
            if (bs == 0) bnow.first++;
            if (bs == 1) bnow.second++;
            if (bs == 2) bnow.first--;
            if (bnow == b1) bs = 1;
            if (bnow == b2) bs = 2;
        }
        bool con = false;
        rep(j, 4){
            if (mp(anow.first + dx[j], anow.second + dy[j]) == bnow) {
                con = true;
                break;
            }
        }
        if (con) {
            ret++;
        }
    }
    
    output(ret, 0);
    
    
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>

int main(int argc, char const *argv[])
{
    int K ;
    std::cin >> K ;
    int rest = K%2;
    int num = (K - rest)/2;
    std::cout<<num*(num+rest)<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define NIL -1 

struct Node{
    int parent,left,right;
};


void preorder(Node node[],int n){
    if (n == NIL) return;
    cout << " " << n;
    if (node[n].left != NIL) preorder(node, node[n].left);
    if (node[n].right != NIL) preorder(node,node[n].right);   
}

void inorder(Node node[],int n){
    if (n ==  NIL) return;
    if (node[n].left != NIL) inorder(node,node[n].left);
    cout << " " << n;
    if (node[n].right != NIL) inorder(node,node[n].right);
}

void postorder(Node node[],int n){
    if (n ==  NIL) return;
    if (node[n].left != NIL) postorder(node,node[n].left);
    if (node[n].right != NIL) postorder(node,node[n].right);
    cout << " " << n;
}


int main(){
    int n,num,right,left;
    Node tree[1000];
    cin >> n;

    //初期化
    for (int i =0;i<n;i++){
        tree[i].parent = NIL;tree[i].right= NIL;tree[i].left=NIL;
    }

    for (int i =0;i<n;i++){
            cin >> num >> left >> right;
                tree[num].left = left;
                tree[num].right = right;
                tree[left].parent = num;
                tree[right].parent = num;
    }

    int root =0;
    for(int i =0;i<n;i++){
        if(tree[i].parent == NIL){
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    preorder(tree,root);
    cout << endl;

    cout << "Inorder" << endl;
    inorder(tree,root);
    cout << endl;

    cout << "Postorder" << endl;
    postorder(tree,root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 50
typedef long long ll;
using namespace std;

int main(void){
  int a, b; cin>>a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15)  cout << "*" << endl;
  else  cout << "x"<<endl;
  return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void) {

   int N,M;
   
   scanf("%d%d",&N,&M);
   
   int i;
   int L[M],R[M];

   for (i = 0; i < M; i++) {
      scanf("%d %d",&L[i],&R[i]);
   }
   
   int left_max,right_min;
   
   left_max = 1;
   right_min = N;
   for (i = 0; i < M; i++) {
      if (left_max <= L[i]) {
         left_max = L[i];
      }
      if (right_min >= R[i]) {
         right_min = R[i];
      }
   }
   
   int ans = right_min - left_max + 1;
   
   if (ans < 0) {
      printf("%d\n",0);
   }
   else {
      printf("%d\n",ans);
   }
   
   
   
  return 0;
}


Measured memory_bytes: 896
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

for($j = 2; $j <= $M; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $j--;
    }
}
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
echo $product;

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    static $memo;
    if(isset($memo[$a][$b]))return $memo[$a][$b];
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    $ret = powerm($a, $b>>1)**2 % MOD;
    $memo[$a][$b] = $ret;
    return $ret;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

Measured memory_bytes: 4984
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
constexpr int inf = (1 << 30) - 1;
constexpr lint linf = (1ll << 60) - 1;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    lint A, B, K;
    cin >> A >> B >> K;
    if(K <= A) {
        cout << A - K << ' ' << B << '\n';
        return 0;
    } else if(K <= A + B) {
        cout << "0 " << B - (K - A) << '\n';
        return 0;
    } else {
        cout << "0 0\n";
        return 0;
    }

}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int sx,sy,tx,ty;
		sx = Integer.parseInt(sc.next());
		sy = Integer.parseInt(sc.next());
		tx = Integer.parseInt(sc.next());
		ty = Integer.parseInt(sc.next());
		for(int i=0;i<tx-sx;i++) {
			out.print("R");
		}
		for(int i=0;i<ty-sy;i++) {
			out.print("U");
		}
		for(int i=0;i<tx-sx;i++) {
			out.print("L");
		}
		for(int i=0;i<ty-sy;i++) {
			out.print("D");
		}
		out.print("D");
		out.print("R");
		for(int i=0;i<tx-sx;i++) {
			out.print("R");
		}
		for(int i=0;i<ty-sy;i++) {
			out.print("U");
		}
		out.print("U");
		out.print("L");
		out.print("U");
		out.print("L");
		for(int i=0;i<tx-sx;i++) {
			out.print("L");
		}
		for(int i=0;i<ty-sy;i++) {
			out.print("D");
		}
		out.print("D");
		out.print("R");
		
		out.flush();
	}
	
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	int n, x, cnt = 0, v, ans = 1;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> v;
		cnt += v;
		if (cnt <= x)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

void solve(int n,int k){
  int x[100005]={0},y[100005]={0},in;
  bool is_zero=false;
  
  rep(i,k){
    cin>>in;
    if(in!=0)x[in]=y[in]=1;
    else is_zero=true;
  }

  for(int i=1;i<=n;i++){
    if(x[i]!=0&&x[i-1])x[i]+=x[i-1];
  }
  for(int i=n-1;i>=0;i--){
    if(y[i]!=0&&y[i+1])y[i]+=y[i+1];
  }
  
  int maxi=-INF;
  if(is_zero){
    REP(i,1,n){
      if(x[i]==0&&y[i]==0)maxi=max(maxi,x[i-1]+y[i+1]+1);
      else maxi=max(maxi,x[i]);
    }
    REP(i,1,n+1)maxi=max(maxi,x[i]);
  }else{
    REP(i,1,n+1)maxi=max(maxi,x[i]);
  }
  
  cout<<maxi<<endl;
}

int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0)break;
    solve(n,k);
  }
  return 0;
}



Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
  long long  a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long dist = abs(a-b), power = (v-w)*t;
  puts(dist<=power?"YES":"NO");
  return 0;
}

Measured memory_bytes: 3084
M = {}
for i in range(int(input())):
    query = input().split()
    
    if query[0] == '0': M[query[1]] = query[2]
    elif query[0] == '1': 
        if query[1] in M: print(M[query[1]])
        else: print(0)
    else: M[query[1]] = 0


Measured memory_bytes: 41640
def main():
    from itertools import accumulate
    n = int(input())
    s = input()
    s = s.replace("W", "1")
    s = s.replace("E", "0")
    s = [int(x) for x in s]

    t = list(accumulate(s))
    u = t[-1]
    ans = n

    for i, (j, k) in enumerate(zip(s, t)):
        m = (k - j) + (n - 1 - i) - (u - k)
        ans = min(ans, m)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17868
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,t,h,s,id;
main()
{
	cin>>n>>t>>a;
	t=(t-a)*1000;
	s=1e9;
	for(int i=0;i<n;i++)
	{
		cin>>h;
		h*=6;
		if(abs(t-h)<s)
		{
			s=abs(t-h);
			id=i+1;
		}
	}
	cout<<id<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
	int a,b,c;
	while(~getIII(a,b,c)) printf("%s\n",a+b+c>=22?"bust":"win");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,cnt,ca,cb,cc;
char s[15];
int main(){
	n=read();
	FOR(i,1,n){
		scanf("%s",s+1);
		int l=strlen(s+1);
		FOR(j,1,l-1) if(s[j]=='A' && s[j+1]=='B') cnt++;
		if(s[1]=='B' && s[l]=='A') cc++; 
		else if(s[l]=='A') ca++;
		else if(s[1]=='B') cb++;
	}
	if(ca || cb) cnt+=cc+min(ca,cb);
	else cnt+=max(0,cc-1);
	printf("%d\n",cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <sstream>
#include <bitset>
#include <map>

using namespace std;

typedef long long ll;

int num(int m, vector<int>& v, int N) {
  int res = 0;
  for (int i = 2; i <= N; i++) if(v[i] >= m - 1) res++;
  return res;
}

int main() {
  int N; cin>>N;
  vector<int> Ns(N+1,0);
  for (int i = 2; i <= N; i++) {
    int cur = i;
    for (int j = 2; j < i + 1; j++) {
      while (cur % j == 0) {
        Ns[j]++;
        cur /= j;
      }
    }
  }
  int ans = 0;
  ans += num(75,Ns,N) + num(15,Ns,N) * (num(5,Ns,N) - 1) + num(25,Ns,N) * (num(3,Ns,N) - 1) + num(5,Ns,N) * (num(5,Ns,N) - 1) * (num(3,Ns,N) - 2) / 2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import math 
import fractions

a,b=map(int,input().split())
l=list(map(int,input().split()))
b_l = []
for i in range(a):
    b_l.append(abs(b-l[i]))
ans=b_l[0]
for j in range(1,a):
    ans = fractions.gcd(ans,b_l[j])
print(ans)


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

int main(){
  int na, nb, nm;
  int a[100001] = {}, b[100001] = {};
  int x[100001] = {}, y[100001] = {}, c[100001] = {};
  cin >> na >> nb >> nm;
  for(int i = 0; i < na; i++)cin >> a[i];
  for(int i = 0; i < nb; i++)cin >> b[i];
  for(int i = 0; i < nm; i++)cin >> x[i] >> y[i] >> c[i];
  
  int min_cost = 10000000;
  for(int i = 0; i < nm; i++){
	min_cost = min(min_cost, a[x[i]-1] + b[y[i]-1] - c[i]);
  }
  
  sort(a, a+na);
  sort(b, b+nb);
  min_cost = min(min_cost, a[0] + b[0]);
  
  cout << min_cost << endl;
  
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
int main()
{
  ll n,m; cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(m),c(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i] >> c[i];

  vector<pl> v;
  rep(i,n) {
    v.push_back({a[i], 1});
  }
  rep(i,m) {
    v.push_back({c[i], b[i]});    
  }

  sort(v.begin(), v.end(), [](pl x, pl y){
			     return x.F > y.F;
			   });
  int idx = 0;
  ll res = 0;
  while(n-- > 0) {
    if(v[idx].S > 0) {
      res += v[idx].F;
      v[idx].S--;
    }
    else {
      idx++;
      res += v[idx].F;
      v[idx].S--;      
    }
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 9812
#include<iostream>
#include<cfloat>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
 
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )
#define PI 3.14159265359
#define PI2 6.28318530718
#define INF 9999999.9999

class Point{
public:
  double x, y;
  Point ( double x = 0, double y = 0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  Point operator / ( double a ){ return Point(x/a, y/a); }
  double abs() { return sqrt(norm());}
  double norm() { return x*x + y*y; }
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

class Segment{
public:
  Point p1, p2;
  Segment ( Point p1 = Point(), Point p2 = Point() ): p1(p1), p2(p2){}
  double abs() { return sqrt(norm());}
  double norm() { return (p2.x - p1.x)*(p2.x - p1.x) + (p2.y - p1.y)*(p2.y - p1.y); }
};

typedef Segment Line;
typedef Point Vector;

double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);}
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }

double getDistanceLP(Line s,Point p){
  return abs(cross(s.p2-s.p1,p-s.p1)/abs(s.p2-s.p1));
}
double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

double R;
int N,ans,id;
Point p[100];
double r[100],v[100],d[100],nd[100];
bool die[100];
Segment s;

int main(){
  while(1){
    cin>>R>>N;
    if(R==0&&N==0)break;
    for(int i=0;i<N;i++){
      cin>>p[i].x>>p[i].y>>r[i]>>v[i];
      nd[i]=d[i]=getDistance(p[i],Point(0,0));
      die[i]=false;
    }

    while(1){

      //１分進める
      for(int i=0;i<N;i++){
	nd[i]=max(R,nd[i]-v[i]);
      }
      
      //最も近くにいる敵を探す
      double mini=INF;
      id=-1;
      for(int i=0;i<N;i++){
	if( die[i] )continue;
	if(nd[i] < EPS+R)continue;
	if(nd[i] > mini)continue;
	mini=nd[i];
	id=i;
      }
      if(id==-1)break;

      //レーザー発射の処理
      s = Segment( p[id] , p[id] );
      s.p1 = s.p1 / d[id];
      s.p1 = s.p1 * R;

      s.p2 = s.p2 / d[id];
      s.p2 = s.p2 * 2000.0;
    
      for(int i=0;i<N;i++){
	if( nd[i] < EPS+R ) continue;
	
	Point a = p[i];
	a = a / d[i];
	a = a * nd[i];
	if( getDistanceSP( s, a ) < EPS+r[i] )die[i]=true;

      }
      //１ターン終了
    }

    ans=0;
    for(int i=0;i<N;i++){
      if(die[i]==false)ans++;
    }
    cout<<ans<<endl;
  }
    
  
  return 0;
}



Measured memory_bytes: 3040
def main():
    import sys
    input = sys.stdin.readline
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    S = [0]*(2*M+3)
    for i in range(N-1):
        now = A[i]
        nex = A[i+1]
        L = nex-now
        if L-1>0:
            S[now+2] += 1
            S[nex+1] += -L
            S[nex+2] += L-1
        elif L<0:
            L = L%M
            if L-1>0:
                S[now+2] += 1
                S[nex+1+M] += -L
                S[nex+2+M] += L-1
        #print(S)
    #print(S)
    for i in range(2*M+2):
        S[i+1] += S[i]
    #print(S)
    for i in range(2*M+2):
        S[i+1] += S[i]
    #print(S)
    B = [0]*(M+1)
    for i in range(1,M+1):
        B[i] = S[i] + S[i+M]
    X = 1
    diff = 0
    for i in range(1,M+1):
        if B[i] > diff:
            diff = B[i]
            X = i
    SS = 0
    for i in range(N-1):
        SS += (A[i+1]-A[i])%M
    #print(B)
    print(SS-diff)        
            
    
    
main()

Measured memory_bytes: 54416
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
bef = 999
for idx, val in enumerate(A):
    ans += B[val - 1]
    if val == bef + 1:
        ans += C[val - 2]
    bef = val
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>

int main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    ll c=1e15+1;
    string s="abcdefghijklmnopqrstuvwxyz";
    ll n;cin>>n;
    ll sum=0;ll tmp=26;int res=1;
    while(sum+tmp<n){
        sum+=tmp;
        tmp*=26;
        res++;
    }
    n-=sum;tmp/=26;string ans;ll t;
    rep(i,res){
        t=(n-1)/tmp;
        ans+=s[t];
        n-=t*tmp;
        tmp/=26;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double min = Integer.MAX_VALUE;
		double max = Integer.MIN_VALUE;
		while(sc.hasNext()){
			double x = sc.nextDouble();
			min = Math.min(min, x);
			max = Math.max(max, x);
		}
		System.out.println(max-min);
	}
}

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

int main(){
  ll N;cin>>N;
  vector<ll> x(N),y(N);rep(i,N)cin>>x[i];
  rep(i,N) y[i] = x[i];
  sort(y.begin(),y.end());
  ll med = (y[N/2-1]+y[N/2])/2;
  rep(i,N){
    if(x[i]<=med) cout << y[N/2] << endl;
    else if(x[i]>med) cout << y[N/2-1] << endl;
  }
} 

Measured memory_bytes: 5376
#!/usr/bin/env python3
#ABC96 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())

def get_prime(n):
    prime = []
    limit = math.sqrt(n)
    data = [i+1 for i in range(1,n)]
    while 1:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime = get_prime(55555)
ans = []
cnt = 0
for i in prime:
    if i % 5 == 1:
        ans.append(i)
        cnt += 1
    if cnt == n:
        break
print(*ans)


Measured memory_bytes: 42860
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int N, M;
	struct edge { int from, to, cost; };
	vector<edge> es;
	vector<int> d;

	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		es.push_back(edge{ a - 1, b - 1, -c });
	}
	d.assign(N, INF_L);
	d[0] = 0;

	for (int v = 0; v < N; ++v) {
		/* // 負閉路検出
		if (v == N - 1) {
			d[N - 1] = -INF_L;
			break;
		} */

		bool update = false;
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;
	}
	int ans = d[N - 1];

	

	bool negative[1000];
	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}
	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
			if (negative[e.from] == true) {
				negative[e.to] = true;
			}
		}
	}




	// cout << (d[N - 1] == -INF_L ? "inf" : to_string(-d[N - 1])) << endl;
	cout << (negative[N - 1] ? "inf" : to_string(-d[N - 1])) << endl;




	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    
    for(int i = 0; i < n ; i++){
        // printf("---------\n");
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    
    
    int tmp1, tmp2;
    tmp1 = d[(n/2) - 1];
    tmp2 = d[(n/2)];

    int ans = 0;
    for (int i = tmp1 + 1; i <= tmp2; i++){
        ans += 1;
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {

	long long  h;

	cin >> h;

	if (h == 1) {
		cout << "1" << endl;
		return 0;
	}

	long long counter=1;
	while (h > 1) {

		h /= 2;
		counter=counter*2+1;
	}

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
def count(line):
	count = 0
	if (line[0]+line[1]+line[2])%2 == 0:
		flag = False
		for i in range(3) :
			if line[i]%2 == 1 :
				line[i] += 1
				flag = True

		if flag == True:
			count += 1
		
		max = 0
		
		for i in range(3):
			if max < line[i]:
				max = line[i]
		for i in range(3):
			count += (max - line[i])/2
		return count
	else :
		flag = False
		for i in range(3):
			if line[i]%2 == 0:
				line[i] += 1
				flag = True
		if flag == True:
			count+= 1
		max = 0
		for i in range(3):
			if max<line[i]:
				max =line[i]
		for i in range(3) : 
			count += (max-line[i])/2
		return count

print count(map(int,raw_input().split()))

Measured memory_bytes: 2696
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    map<char, int> data;
    rep(i, n) {
        data[s[i]]++;
    }
    string ans = "Yes";
    //E,Wのどちらか一方が0である条件
    if (data['E'] + data['W'] != 0 && data['E'] * data['W'] == 0) {
        ans = "No";
    }
    if (data['N'] + data['S'] != 0 && data['N'] * data['S'] == 0) {
        ans = "No";
    }
    cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl
#define pb push_back

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
ll xa,xb,ua,ub;
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<ll> st;

#define SIZ 200010


vector<vector<ll>> dp;

vector<vector<ll>> v2vec(int x,int y,int value=0){ return vector<vector<ll>>(y,vector<ll>(x,value)); }

int main(){
    cin>>s;
    n=s.size();
    m=0;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1])m++;   
    }
    C m E;
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll h; cin >> h;
  ll n = 1;
  while(n<=h) n*=2;
  cout <<  n-1 << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int power(int x, int y)
{
    if(y==0) return 1;
    else if(y%2==0)
        return power(x*x%MOD,y/2)%MOD;
    else return (x%MOD*power(x*x%MOD,y/2))%MOD;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, k;
        cin >> n >> k;
        vector<int> ans(k + 1);
        int sum = 0;
        for(int i = k; i > 0; i--){
            ans[i] = power(k / i, n);
            for(int j = 2 * i; j <= k; j += i){
                ans[i] = (ans[i] - ans[j] + MOD) % MOD;
            }
            sum = (sum + (ans[i] * i) % MOD) % MOD;
        }
        cout << sum << '\n';
    }
}

Measured memory_bytes: 35160
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
	int N,K;
	cin>>N>>K;
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N);
 
	int temp=0,min[N],cnt=0;
	int j=0;
	for(int i=0;i<N;i++)min[i]=200001;
	for(int i=0;i<N;i++){
		if(temp==A[i]){
			min[j]++;
			continue;
		}
		else{
			j++;
min[j]=1;
			cnt++;
		}
		temp=A[i];
	}
//	for(int i=j;i<N;i++)min[i]=200001;
//min[0]=200001;
 
	sort(min,min+N);
 
/*	for(int i=0;i<N;i++){
		cout<<min[i];
	}cout<<endl;*/
 
 
/*	for(int i=0;i<N;i++){
		cout<<A[i];
	}cout<<endl;*/
 
/*	cout<<cnt<<endl;*/
	int res=0;
	temp=cnt-K;
	if(temp<=0){res=0;}else{
		for(int i=0;i<temp;i++){
			res+=min[i];
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void){
	double x1, x2, y1, y2;
	double x, y, d;
	
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	
	x = x2 - x1;
	y = y2 - y1;
	d = sqrt(pow(x, 2.0)+pow(y, 2.0));
	
	printf("%f\n", d);
	
	return 0;
}


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

int N;
int A[200010];  //A[i] : iの番号箱内のボール数
vector<int> ball(200010, 0);
int res = 0; 

int main(){
  cin >> N;

  for(int i = 0; i < N; i++) cin >> A[i+1];

 for(int k = N; k >= 1; k--){
  int i = 1;
  int ts = 0;
  while(k * i <= N){ ts += ball[k*i]; ++i; }  //kより大きい、N以下のkの倍数の数字が付いた箱のボールの総数
  ball[k] = abs(ts % 2 - A[k]);   //ズレを番号kが書かれた箱にボールを入れるか否かで調節
  res += ball[k];
  }

  cout << res << endl;
  for(int i = 1; i <= N; i++){ if(ball[i]) cout << i << " "; }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int sum=0;
int A=0;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

 // 椅子の幅 Xcm, 一人あたりの使用幅 Ycm、間隔 Zcm
 // A人座った場合、に必要な幅
 // Z + Y + Z + Y + Z + Y + Z
 // (Z+Y)*A + Z
 while (sum <= X){
   A++;
   sum = (Z+Y)*A+Z;
 }

 A--;

    cout << A << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	static int mod = 1000000007;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
    	PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        long x = sc.nextLong();
        long y = sc.nextLong();
        
        if(Math.abs(x-y) > 1){
        	out.println("Alice");
        }
        else{
        	out.println("Brown");
        }
        
        out.flush();
    }

    
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24660
N,A,B = map(int,input().split())

if (A-B)%2==0:
    print(abs(A-B)//2)
else:
    #A<B
    ans1 = A+(B-A-1)//2
    ans2 = N-B+1+(N-(A+(N-B+1)))//2
    print(min(ans1,ans2))

Measured memory_bytes: 38384
import math
N, D = map(int, input().split())
X_l = []
for i in range(N):
    X_l.append([int(x) for x in input().split()])

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        dist = 0.0
        for d in range(D):
            dist+=(X_l[i][d]-X_l[j][d])**2
        dist = math.sqrt(dist)
        if dist.is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N >> K;
    vi arr(N);
    for (int i = 0; i < N; i++) cin >> arr.at(i);

    N -= K;
    A=1;
    if(N == 0) {cout << A; return 0;}

    A += N /(K-1);
    if(N%(K-1)) cout << A+1;
    else cout << A;


    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>

#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, weight;

	bool operator < (const Edge& obj) const {
		return weight < obj.weight;
	}
};

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main()
{
	int n, m, k;

	cin >> n >> m >> k;
	vector<int> col(n);

	UnionFind uf(n);
	vector<int> bef(k,-1);
	REP(i, n) {
		scanf("%d", &col[i]);
		col[i]--;
		if (col[i] != -1) {
			if (bef[col[i]] == -1)bef[col[i]] = i;
			uf.unionSet(i, bef[col[i]]);
			bef[col[i]] = i;
		}
	}
	

	vector<Edge> ed;
	REP(i, m) {
		int f, t, w;
		scanf("%d %d %d", &f, &t, &w);
		f--, t--;

		if (col[f] != col[t] || col[f] == -1){
			ed.push_back({ f,t,w });
		}
	}
	sort(ALL(ed));
	ll ans = 0;
	int cc = 0;
	for (int i = 0; ed.size() > i; i++) {
		if (!uf.findSet(ed[i].from, ed[i].to)) {
			ans += 1LL*ed[i].weight;
			uf.unionSet(ed[i].from, ed[i].to);
			cc++;
		}
		if (cc == k - 1) break;
	}
	cout << (cc != k-1 ? -1 : ans) << endl;
	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;


// ABC45
void solve()
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;    
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	std::string str;
	std::cin >> str;
	int a = 0;
	for (int i = 0; i < 3; i++) {
		if (str[i] == 'a') {
			a += 1;
		}
		if (str[i] == 'b') {
			a += 5;
		}
		if (str[i] == 'c') {
			a += 8;
		}
	}
	if (a == 14) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

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

int store[100007];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) scanf("%d", &store[i]);

    int ans = store[0];

    for (int i = 1; i < N; i++) {
        ans = __gcd(ans, store[i]);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;

    cin>>a>>b>>c;

    int temp;

    if(a>b)
    {
        temp=a;
        a=b;
        b=temp;
    }

    if(b>c)
    {
        temp=b;
        b=c;
        c=temp;
    }

    if(a>b)
    {
        temp=a;
        a=b;
        b=temp;
    }

    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}



Measured memory_bytes: 3092