akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define se second
#define fi first
#define mk make_pair
using namespace std;
#define int long long
typedef pair<int,int> P;

main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n) cin>>a[i];
  for(int i=1;i<n;i++)a[i]+=a[i-1];
    int ans=a[n-1],ko=1e15;
  for(int i=0;i<n-1;i++)ko=min(ko,abs(a[i]-(ans-a[i])));
    cout<<ko<<endl;
}

Measured memory_bytes: 1792
// Created by Nikolay Budin

#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	if (b * 2 > h || a * 2 > w) {
		cout << "-1\n";
		return;
	}
	vector<vector<int>> field(h, vector<int>(w));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int val = 0;
			if (j < a) {
				val ^= 1;
			}
			if (i < b) {
				val ^= 1;
			}
			field[i][j] = val;
		}
	}
	for (auto& v : field) {
		for (int num : v) {
			cout << num;
		}
		cout << "\n";
	}
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 5248
using System;
using System.Collections.Generic;

namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            var list = new List<int>();

            for (int i = 1; i <= count; i++)
            {
                int nedan = int.Parse(Console.ReadLine());
                list.Add(nedan);
            }

            int Max = 0;
            int goukei = 0;
            foreach (int item in list)
            {
                if(Max<item)
                {
                    Max = item;
                    goukei = goukei + item;
                }
                else if(Max >= item)
                {
                    goukei = goukei + item;
                }
            }
            int z = Max/2;
            Console.WriteLine(goukei-z);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    ll n=str.length(),i;
    for(i=0;i<n;i++){
        if(i%2==0 && str[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
        else if(i%2==1 && str[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
passed = 0
rank = 0
for i in range(N):
    is_pass = False
    if S[i] == 'a' and passed < A+B:
        is_pass = True
    elif S[i] == 'b':
        if passed < A+B and rank < B:
            is_pass = True
        rank += 1
    if is_pass:
        passed += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 53336
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

int a[100000+2]; // 0 ～ 100000+1

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int temp; cin >> temp;
		a[temp - 1]++;
		a[temp]++;
		a[temp + 1]++;
	}
	int max_count = 0;

	for (int i = 0; i <= 100001; i++) {
		if (max_count < a[i]) max_count = a[i];
	}

	cout << max_count << endl;

	return 0;
}

Measured memory_bytes: 640
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int k, n, a[MAXN], f[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> k >> n;
    FOR(i,1,n) cin >> a[i];
    int res = 1e9;
    FOR(i,1,n) {
        if (i == 1) f[i] = k - a[n] + a[i];
        else f[i] = a[i] - a[i-1];
        res = min(res, k - f[i]);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
using namespace std;
static const ll mod = 1000000007;
static const ll max_n = 200000;
vector<ll> factorial(max_n+1);
vector<ll> factorial_inv(max_n+1);

bool is_prime(ll N){
    ll i=2;
    while(i*i<N){
        if(N % i == 0){
            return false;
        }else{
            i ++;
        }
    }
    if(N % i == 0){
        return false;
    }
    return true;
}

template<typename T>
vector<T> divisor(T N){
    vector<T> divisors_list;
    T i = 1;
    for(i = 1;i*i<N;i++){
        if(N % i == 0){
            divisors_list.emplace_back(i);
            divisors_list.emplace_back(N / i);
        }
    }

    if(N % i == 0){
        divisors_list.emplace_back(i);
    }

    return divisors_list;

}

template<typename T>
map<T, T> prime_factor(T N){
    map<T, T> res;
    ll i = 2;
    for(i=2;i*i<=N;i++){
        while(N%i==0){
            ++res[i];
            N /= i;
        }
    }
    if(N!=1){
        res[N] = 1;
    }
    return res;
}

ll mpow(ll base, ll power){
    if(power==0){
        return 1;
    }
    ll b = mpow(base, power/2);
    b *= b;
    b %= mod;
    if(power % 2==1) b = (b * base) % mod;
    return b;
}

void initialze_factorial(){
    factorial[0] = 1;
    factorial[1] = 1;
    ll v = 1;
    for(ll i=2;i<=max_n;i++){
        v *= i;
        v %= mod;
        factorial[i] = v;
    }

    factorial_inv[max_n] = mpow(factorial[max_n], mod-2);
    // printf("max n inv = %lld\n", factorial_inv[max_n]);

    for(ll i=max_n-1;i>=2;i--){
        factorial_inv[i] = (factorial_inv[i+1] * (i+1)) % mod;
    }

    factorial_inv[0] = 1;
    factorial_inv[1] = 1;

}


int main(){
    ll N, M;
    scanf("%lld %lld", &N, &M);
    initialze_factorial();
    map<ll, ll> primes = prime_factor(M);
    // cout << primes <<endl;
    // for(int i=0;i<10;i++){
    //     printf("f[%d]=%lld ", i, factorial[i]);
    // }
    // printf("f^-1[%lld]=%lld", max_n, factorial[max_n]);

    // printf("\n");
    // for(int i=0;i<10;i++){
    //     printf("f^-1[%d]=%lld ", i, factorial_inv[i]);
    // }
    // printf("f^-1[%lld]=%lld", max_n, factorial_inv[max_n]);
    // printf("\n");


    ll ans = 1;
    for(const auto &key: primes){
        ans *= factorial[key.second+N-1];
        ans %= mod;
        ans *= factorial_inv[key.second];
        ans %= mod;
        ans *= factorial_inv[N-1];
        ans %= mod;
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3328
def main():
    cardList = makeCardList()
    n = int(input())
    for a in range(n):
        card = input()
        cardList[cardToIndex(card)] = ''
    for x in range(len(cardList)):
        if cardList[x]:
            print(cardList[x])

def makeCardList():
    cardList = []
    suits = ['S', 'H', 'C', 'D']
    for s in range(4):
        for r in range(13):
            cardList.append(suits[s] + ' ' + str(r+1))
    return cardList

def cardToIndex(c):
    dict = {'S':0, 'H':1, 'C':2, 'D':3}
    return (dict[c[0]] * 13 + int(c[2:]) - 1)

main()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = 703;

bool HasEdge[N][N];
vector<int> a[N], cur[2];
vector<pii> val;
int n, m, u, v, vis[N], cnt, res, f[N][N];

void DFS(int u) {
    for(int v: a[u]) {
        if(!vis[v]) vis[v] = vis[u] + 1, DFS(v);
    }
    cur[vis[u] & 1].pb(u);
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> u >> v;
        HasEdge[u][v] = HasEdge[v][u] = 1;
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(i != j && !HasEdge[i][j]) a[i].pb(j);
        }
    }
    for(int i = 1; i <= n; ++i) {
        if(!vis[i]) {
            cur[0].clear(), cur[1].clear();
            vis[i] = 1, DFS(i);
            for(int j = 0; j < 2; ++j) {
                for(int v: cur[j])
                    for(int u: cur[j])
                        if(u != v && !HasEdge[u][v]) return cout << -1, 0;
            }
            val.pb(mp(cur[0].size(), cur[1].size()));
        }
    }
    fill_n(&f[0][0], N * N, 0);
    res = 1e9; f[0][0] = 1; int j = 1;
    for(pii p: val) {
        for(int i = n; i >= 0; --i) {
            if(!f[j - 1][i]) continue;
            if(i + p.fi <= n) f[j][i + p.fi] = 1;
            if(i + p.se <= n) f[j][i + p.se] = 1;
        }
        ++j;
    }
    for(int i = n; i >= 0; --i) {
        if(f[j - 1][i]) {
            res = min(res, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    cout << res;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pii>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vvd vector<vector<double>>
#define vvc vector<vector<char>>
#define vvs vector<vector<string>>
#define vvpi vector<vector<pii>>
#define vvpl vector<vector<pll>>

const int INF = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;
const int MAX = 1e7;

bool isPrime[MAX + 1];
vector<int> prime(1, 2);
ll dp[MAX + 5];

void getPrime();
ll f(int K);
ll GCD(ll a, ll b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	getPrime();

	memset(dp, -1, sizeof(dp));

	dp[1] = 1;
	for (ll i : prime) {
		dp[i] = 2;
		for (ll l = i * i; l <= MAX; l *= i)
			dp[l] = dp[l / i] + 1;
	}

	int N; cin >> N;

	ll sum = 0;
	for (int K = 1; K <= N; K++) {
		sum += K * f(K);
	}

	cout << sum;

	return 0;
}

void getPrime() {
	fill(isPrime, isPrime + MAX + 1, true);

	for (ll i = 4; i <= MAX; i += 2)
		isPrime[i] = false;
	for (ll i = 3; i <= MAX; i++) {
		if (isPrime[i]) prime.push_back(i);
		for (ll j = i * i; j <= MAX; j += i * 2)
			isPrime[j] = false;
	}
}

ll f(int K) {
	ll& ret = dp[K];
	if (ret != -1) return ret;

	for (ll p : prime) {
		if (K % p == 0) {
			ll cnt = 0, val = p;
			while (K % val == 0) {
				val *= p;
				cnt++;
			}
			val /= p;
			return ret = f(val) * f(K / val);
		}
	}
}

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

vector<vector<int>> G(3e5);
vector<bool> seen(3e5,false);
vector<int> cnt(3e5,0);

void dfs(int u,int id) {
  seen[u]=true;
  cnt[id]++;
  for(auto next:G[u]) {
    if(seen[next]!=false) continue;
    dfs(next,id);
  }
}

int main() {
  int n,m;
  cin>>n>>m;
  int a,b;
  for(int i=0;i<m;i++) {
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int id=0;

  for(int u=0;u<n;u++) {
    if(seen[u]==false) dfs(u,id++);
  }
  auto it=max_element(cnt.begin(),cnt.end());
  cout<<*it<<endl;
}


Measured memory_bytes: 26864
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

template<int MOD> struct Fp{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD){ if(val<0) v += MOD; }
    constexpr int getmod(){ return MOD; }
    constexpr Fp operator - () const noexcept{ return val ? MOD - val : 0; }
    constexpr Fp operator + (const Fp& r) const noexcept{ return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept{ return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept{ return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept{ return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept{ val += r.val; if(val>=MOD) val -= MOD; return *this; }
    constexpr Fp& operator -= (const Fp& r) noexcept{ val -= r.val; if(val<0) val += MOD; return *this; }
    constexpr Fp& operator *= (const Fp& r) noexcept{ val = val*r.val%MOD; return *this; }
    constexpr Fp& operator /= (const Fp& r) noexcept{
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) { long long t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        val = val*u%MOD; if(val<0) val += MOD; return *this; }
    constexpr bool operator == (const Fp& r) const noexcept{ return this->val == r.val; }
    constexpr bool operator != (const Fp& r) const noexcept{ return this->val != r.val; }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept{ return os << x.val; }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept{ return is >> x.val; }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept{
        if (n == 0) return 1; auto t = modpow(a, n/2); t = t*t; if(n & 1) t = t*a; return t; }
};
const int MOD = MODV;
using mint = Fp<MOD>;

int main(){
    Init();
    string s; cin >> s;
    mint ans = 0;
    ll cnt = 0, n = s.size();

    // 先頭から文字をチェックしていく
    rep(i, n){
        // 1の場合:
        // 　後ろは自由なので(0,0), (0,1), (1,0)の3種類が取れる。
        // 　前の部分は1の箇所が(1,0), (0,1)の2種類が取れる。
        if(s[i] == '1'){
            ans += modpow(mint(2), cnt) * modpow(mint(3), n-1-i);
            cnt++;
        }
    }
    // 入力値の1の部分を(1,0), (0,1)で2種類取れる
    ans += modpow(mint(2), cnt);
    cout << ans << endl;
}

Measured memory_bytes: 3712
#include<iostream>

using namespace std;

#define N 100

//grobal
int data[N],num1,num2;

//flag
bool flag=false;

//function solve
bool solve(int i,int m){

  //if i >num1 then false
  if(i>num1) return false;
  //if m<0 then false
  if(m<0) return false;

  //if m=0 then true
  if(m== 0){
    flag=true;
    return true;
  }
  //execute
  solve(i+1,m);
  solve(i+1,m-data[i]);  

}


int main(){

  int i,m;

  //load number
  cin >>num1;

  //load data
  for(i=0;i<num1;i++){
    cin >>data[i];
  }
  //load number
  cin >>num2;
  //load  data and execute
  for(i=0;i<num2;i++){
    cin >>m;
    //initial flag
    flag=false;
    //execute solve
    solve(0,m);

    //print yes or no
    if(flag==true){
      cout <<"yes"<<endl;
    }  
    else cout <<"no"<<endl;
  }

  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    vp[i] = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  ll ans = 0;
  int drink = 0;
  for (int i = 0; i < n; i++) {
    if (vp[i].second >= m - drink) {
      ans += (ll)vp[i].first * (m - drink);
      break;
    } else {
      ans += (ll)vp[i].first * vp[i].second;
      drink += vp[i].second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
   ll n,m;
   cin>>n>>m;
   ll res=0;
   if(2*n <= m)
   {
       res+=n;
       m-=(2*n);
       if(m>=4)
       res+=m/4;
   }
   else res+=m/2;
   cout<<res;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 3600
using System;

namespace ABC094_A_Cats_and_Dogs
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int x = int.Parse(input[2]);

			if (x - a <= b && a <= x)
			{
				Console.WriteLine("YES");
			}
			else
			{
				Console.WriteLine("NO");
			}
		}
	}
}


Measured memory_bytes: 11092
import math
import bisect
from collections import Counter
N = int(input())

cnt = Counter()


def factor(n):
    for i in range(2, int(math.sqrt(n))+2):
        while n % i == 0:
            n //= i
            cnt[i] += 1
    if n > 1:
        cnt[n] += 1

for i in range(1, N+1):
    factor(i)

#cnt = list(cnt.values())[::-1]
cnt = sorted(cnt.values())

cnt_over_n = lambda x: len(cnt)-bisect.bisect_left(cnt, x)
tmp2 = cnt_over_n(2)
tmp4 = cnt_over_n(4)
tmp14 = cnt_over_n(14)
tmp24 = cnt_over_n(24)
tmp74 = cnt_over_n(74)

ans = 0
ans += (tmp2-tmp4)*tmp4*(tmp4-1)//2 + tmp4*(tmp4-1)*(tmp4-2)//6*3
ans += (tmp4-tmp14)*tmp14 + tmp14*(tmp14-1)
ans += (tmp2-tmp24)*tmp24 + tmp24*(tmp24-1)
ans += tmp74
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>

#define all(a) h.begin(),h.end()

#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 1000000;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> P;
typedef long long ll;


void zerofill(int *inp, int size){
    for(auto i= 0; i< size; i++){
        inp[i] = 0;
    }
}

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int getDigit(int num){
    return log10(abs(num))+1;
}


long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

void binom_init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; ////  inv[i] = div(1,i) =  (1/i) mod M;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long binom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int mypush(queue<int> &candidate,int inp, int N){
    
    if (inp <= pow(10,getDigit(N)-1)){
        candidate.push(inp);
    }

    return (inp <= N);
    
}


int consistent(int inp,int N){
    
    string s = to_string(inp);
    
    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());
    
    if (s[0] != '3') return 0;
    if (s[1] != '5') return 0;
    if (s[2] != '7') return 0;
    
    return (inp <= N);
    
}


int ans = 0;


int dfs(vector<int> pos, int beg, int end, int currentheight){
    
    if (beg > end) return 0;
    auto curb = pos.begin()+beg;
    auto cure = pos.begin()+end;
    auto minIt = min_element(curb,cure);
    
    if (minIt ==cure) return 0;

    int index = (int)distance(pos.begin(),minIt);

    ans += (pos[index]-currentheight);
    
    dfs(pos,beg,index,pos[index]);
    dfs(pos,index+1,end,pos[index]);
    
    
    return 0;
}

int main() {
    
    int N  = in();
    vector<int> h(N);
    REP(i,N) cin>>h[i];

    
    dfs(h,0,N,0);
    
    cout << ans << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A,B,C;
    string S;

    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>S;
    REP(i,N){
        set<char> Q;
        ll temp=0;
        REP(j,N){
            if(j<=i){
                Q.insert(S[j]);
            }else{
                if(Q.find(S[j])!=Q.end()){temp++;Q.erase(S[j]);}

            }
        }
        ans=max(temp,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

int main(){
  ll n; cin >> n;
  ll ans = n*(n-1)/2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

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

int main() {
    ll A, B, x;
    cin >> A >> B;
    ll g = x = gcd(A, B);
    map<ll, ll> mp;
    for(ll i = 2; i * i <= g; i++) {
        while(g % i == 0) {
            mp[i]++;
            g /= i;
        }
    }
    if(g != 1) mp[g]++;
    g = x;
    ll ret = 0;
    ll M = 1;
    for(auto &x : mp) {
        M *= (x.second + 1);
    }
    //cout << M << endl;
    for(ll i = 2; i * i <= g; i++) {
        if(g % i == 0) {
            ll now = i;
            ll tmp = M;
            for(ll j = 2; j * j <= now; j++) {
                if(now % j == 0) {
                    tmp /= (mp[j] + 1);
                    while(now % j == 0) {
                        now /= j;
                    }
                }
            }
            if(now != 1) {
                tmp /= (mp[now] + 1);
            }
            ret += tmp;
            if(i == g / i) continue;
            now = g / i;
            tmp = M;
            for(ll j = 2; j * j <= now; j++) {
                if(now % j == 0) {
                    tmp /= (mp[j] + 1);
                    while(now % j == 0) {
                        now /= j;
                    }
                }
            }
            if(now!=1){
                tmp/=(mp[now]+1);
            }
            ret += tmp;
        }
    }
    cout << mp.size()+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    REP (i, N) cin >> H[i];
    sort(H.rbegin(), H.rend());
    int ans = 0;
    FOR (i, K, N) ans += H[i];
    cout << ans << endl;
}

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


int a(int a,int b){
  return a+b;
}
int b(int a,int b){
  return a-b;
}
int c(int a,int b){
  return a*b;
}
int d(int a,int b){
  return a/b;
}


int main() {
  int x,y;
  char op;
  while(cin >> x >> op >> y && op!='?'){
    if(op=='+')
      cout << a(x,y) << endl;
    else if(op=='-')
      cout << b(x,y) << endl;
    else if(op=='*')
      cout << c(x,y) << endl;
    else if(op=='/')
      cout << d(x,y) << endl;
  }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

vector<ll>a(60,1);
vector<ll>p(60,1);
ll f(ll x,ll level){
    if(level==0)return (x<=0?0:1);
    if(x==1)return 0;
    else if(x<=a[level-1]+1)return f(x-1,level-1);
    else if(x==a[level-1]+2)return p[level-1]+1;
    else if(x<=2*a[level-1]+2)return p[level-1]+1+f(x-a[level-1]-2,level-1);
    else return p[level-1]*2+1;
}

int main(){
    ll n;cin >>n;
    for (int i = 0; i <60 ; ++i) {
        a[i+1]=2*a[i]+3;
        p[i+1]=2*p[i]+1;
    }
    ll x;cin>>x;
    ll ans=f(x,n);
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
la=sorted(map(int,input().split()))
lb=sorted(map(int,input().split()))
lc=sorted(map(int,input().split()))
ans=0
for i in range(n):
  index1=bisect.bisect_left(la,lb[i])
  index2=bisect.bisect_right(lc,lb[i])
  ans+=index1*(n-index2)
print(ans)

Measured memory_bytes: 23328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    long long int h, w; std::cin >> h >> w;
    long long int ans = ((h+h%2)/2 * (w+w%2)/2) + ((h-h%2)/2 * (w-w%2)/2);
    if(h==1||w==1) std::cout << 1 << std::endl;
    else std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
/*
Dijkstra
by.YXH_XianYu
   2018.7.17
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define DBL double
#define CHR char
#define BOL bool
#define REG register
#define rep(i, j, k) for(int i = j, lim = k; i <= lim; i++)
#define req(i, j, k) for(int i = j, lim = k; i >= lim; i--)
#define INF 0x3f3f3f3f
#define MXN 100005

LLI L,
	n, m,
	gcd, lcm;
CHR s[MXN],
	t[MXN];


/* Main */
int main() {
	//freopen("Dijkstra.in", "r", stdin);
	//freopen("Dijkstra.out", "w", stdout);
	REG int i, j, t1, t2;

	scanf("%lld %lld", &n, &m);
	scanf("%s", s+1);
	scanf("%s", t+1);
	gcd = std::__gcd(n, m);
	lcm = n * m / gcd;
	t2 = lcm / n,
	t1 = lcm / m;
	for(i = 1, j = 1; i <= n; i += t1, j += t2)
		if(s[i] != t[j]) {
			printf("-1\n");
			return 0;
		}
	printf("%lld\n", lcm);

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  ll vec[n][3];
  ll minabs[n];
  for(int i=0;i<n;i++){
    cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
    minabs[i]=min(abs(vec[i][0]),abs(vec[i][1]));
  }
  ll ans[n+1];
  for(int i=0;i<=n;i++){
    ans[i]=1e13;
  }
  int vecb[n];
  int vecc[n];
  ll cost[n];
  ll sum,x;
  for(int bit=0;bit<(1<<n);bit++){
    int t=0;
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        vecb[i]=1;
        vecc[t]=i;
        t++;
      }
      else{
        vecb[i]=0;
      }
    }
    if(t==n){
      ans[t]=0;
      continue;
    }
    for(int i=0;i<n;i++){
      cost[i]=minabs[i];
    }
    /*x=0;
    for(int i=0;i<n;i++){
      if(vecb[i]==1){
        vecc[x]=i;
        x++;
      }
    }*/
    for(int bitb=0;bitb<(1<<t);bitb++){
      for(int i=0;i<t;i++){
        if(bitb&(1<<i)){ //縦に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][0]-vec[vecc[i]][0]));
          }
        }
        else{ //横に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][1]-vec[vecc[i]][1]));
          }
        }
      }
      sum=0;
      for(int i=0;i<n;i++){
        sum+=cost[i]*vec[i][2];
        cost[i]=minabs[i];
      }
      ans[t]=min(ans[t],sum);
    }
  }
  
  for(int i=0;i<n+1;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 3600
D, N = [int(i) for i in input().split()]
if D == 0 and N != 100:
	ans = N
elif D == 1 and N != 100 :
	ans = N*(100**D)
elif D == 1 and N == 100 :
	ans = 10100
elif D == 2 and N != 100 :
	ans = N*(100**D)
elif D == 2 and N == 100 :
	ans = 1010000 
else :
	ans = 101
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
struct Node
{
	int x,y;
};
struct Edge
{
	int to,next;
}e[5000005];
vector<Node>a[1000005];
int f[100005],rt[100005],d[400005],h[400005],cnt;
inline void Addedge(int x,int y)
{
	e[++cnt]=(Edge){y,h[x]};h[x]=cnt;return;
}
inline int GetFather(int x)
{
	if(f[x]==x)return x;
	return f[x]=GetFather(f[x]);
}
inline void Merge(int x,int y)
{
	x=GetFather(x);
	y=GetFather(y);
	if(x!=y)f[x]=y;
	return;
}
queue<int>q;
int main(void)
{
	int i,j,x,y,n,m,c,id;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		a[c].push_back((Node){x,y});
	}
	id=n;
	for(i=1;i<=1000000;++i)
	{
		for(j=0;j<a[i].size();++j)
		{
			x=a[i][j].x;y=a[i][j].y;
			f[x]=x;f[y]=y;
			rt[x]=rt[y]=0;
		}
		for(j=0;j<a[i].size();++j)Merge(a[i][j].x,a[i][j].y);
		for(j=0;j<a[i].size();++j)
		{
			x=a[i][j].x;y=a[i][j].y;
			if(!rt[GetFather(x)])rt[GetFather(x)]=++id;
			Addedge(x,rt[GetFather(x)]);
			Addedge(rt[GetFather(x)],x);
			Addedge(y,rt[GetFather(y)]);
			Addedge(rt[GetFather(y)],y);
		}
	}
	q.push(1);
	while(!q.empty())
	{
		x=q.front();q.pop();
		for(i=h[x];i;i=e[i].next)
		{
			y=e[i].to;
			if(!d[y]){d[y]=d[x]+1;q.push(y);}
		}
	}
	if(d[n])printf("%d\n",d[n]/2);
	else printf("-1\n");
	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 3e3+5;

int n;
ll a[N];

ll dp[N][N],s;

ll solve(int from,int to){
    if(from>to)return dp[from][to]=0;
    if(from==to)return dp[from][to]=a[from];
    if(from+1==to)return dp[from][to]=max(a[from],a[to]);
    if(dp[from][to]!=-1)return dp[from][to];

    ll b=a[from]+min(solve(from+2,to),solve(from+1,to-1));
    ll c=a[to]+min(solve(from,to-2),solve(from+1,to-1));

    dp[from][to]=max(b,c);
    return dp[from][to];
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s+=a[i];
    }

    memset(dp,-1,sizeof(dp));
    solve(1,n);

    cout<<2LL*dp[1][n]-s;
    return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int x, y, z;
  size_t K;
  cin >> x >> y >> z >> K;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());
  sort(c.begin(), c.end(), greater<ll>());

  vector<ll> ans;
  rep(i, x) {
    rep(j, y) {
      if ((i + 1) * (j + 1) > K) break;
      rep(k, z) {
        if ((i + 1) * (j + 1) * (k + 1) > K) break;
        ans.push_back(a[i] + b[j] + c[k]);
      }
    }
  }

  sort(ans.begin(), ans.end(), greater<ll>());
  rep(i, K) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1404
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(),v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
const int N = 2e5+5;
//vector<ll>v(N, 0);
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //Hey, You
    // Don't practise these
    // easy questions.
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/(__gcd(a,b));
}


Measured memory_bytes: 256
CHARACTER(10) S
INTEGER OTONOKEMONO,ANS
READ*,S
ANS=999
DO I=1, LEN_TRIM(S)-2
  READ(S(I:I+2),*) OTONOKEMONO
  IF(ABS(OTONOKEMONO-753)>ANS)CYCLE
  ANS=ABS(OTONOKEMONO-753)
END DO
PRINT"(I0)",ANS
END

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
typedef pair<int, int> pii;
typedef vector< pii > PArray;

int n, m;
int poyo[1010][110];

void solve() {
	int cnt[110] = { 0 };
	for_(i,0,m) for_(j,0,n) cnt[i] += poyo[j][i];
	
	PArray vp;
	for_(i,0,m) vp.push_back(pii(cnt[i], -(i + 1)));
	sort(allof(vp));
	
	for_rev(i,m-1,0) {
		if (i > 0) cout << -vp[i].second << " ";
		else cout << -vp[i].second << endl;
	}
}

int main() {
	while (cin >> n >> m, n) {
		for_(i,0,n) for_(j,0,m) cin >> poyo[i][j];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1632
n, d = map(int, raw_input().split())
x = []
comb = []
for j in range(n):
    x.append(map(int, raw_input().split()))
    comb.append(j+1)

import itertools
x_comb = list(itertools.combinations(comb,2))

import numpy as np

c = 0

for i in range(len(x_comb)):
    if np.linalg.norm(np.array(x[x_comb[i][0]-1])-np.array(x[x_comb[i][1]-1])).is_integer() == True:
        c +=1

print(c)

Measured memory_bytes: 16008
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int q; cin >> q;
	long double theta1, theta2;
	theta1 = atan2(y2 - y1, x2 - x1);
	while (q--) {
		int x, y; cin >> x >> y;
		theta2 = atan2(y - y1, x - x1);
		long double dist = hypot(x - x1, y - y1) * cos(theta2 - theta1);
		long double dist_x = dist*cos(theta1), dist_y = dist*sin(theta1);
		cout << fixed << setprecision(11) << 2*x1 + (dist_x - x) + dist_x << " " << 2*y1 + (dist_y - y) + dist_y << endl;
	}
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cctype>
#include<array>
#include<climits>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long Int;
typedef string::const_iterator Itr;

array<int,3> flag;

Int ctoi(const char &c)
{
	return c - '0';
}

Int expression(Itr &);
Int term(Itr &);
Int term2(Itr &);
Int factor(Itr &);
Int number(Itr &);

Int expression(Itr &itr)
{
	Int ret = term(itr);

	while (true)
	{
		if (*itr == '+' && flag[0]==0)
		{
			itr++;
			ret += term(itr);
		}
		else if (*itr == '-'&& flag[1] == 0)
		{
			itr++;
			ret -= term(itr);
		}
		else if (*itr == '*'&& flag[2] == 0)
		{
			itr++;
			ret *= term(itr);
		}
		else
		{
			break;
		}
	}

	return ret;
}

Int term(Itr &itr)
{
	Int ret = term2(itr);

	while (true)
	{
		if (*itr == '+'&& flag[0] == 1)
		{
			itr++;
			ret += term2(itr);
		}
		else if (*itr == '-'&& flag[1] == 1)
		{
			itr++;
			ret -= term2(itr);
		}
		else if (*itr == '*'&& flag[2] == 1)
		{
			itr++;
			ret *= term2(itr);
		}
		else
		{
			break;
		}
	}

	return ret;
}

Int term2(Itr &itr)
{
	Int ret = factor(itr);

	while (true)
	{
		if (*itr == '+'&& flag[0] == 2)
		{
			itr++;
			ret += factor(itr);
		}
		else if (*itr == '-'&& flag[1] == 2)
		{
			itr++;
			ret -= factor(itr);
		}
		else if (*itr == '*'&& flag[2] == 2)
		{
			itr++;
			ret *= factor(itr);
		}
		else
		{
			break;
		}
	}

	return ret;
}

Int factor(Itr &itr)
{
	Int ret;

	if (*itr == '(')
	{
		itr++;
		ret = expression(itr);
		itr++;
	}
	else
	{
		ret = number(itr);
	}

	return ret;
}

Int number(Itr &itr)
{
	Int ret = 0;

	while (isdigit(*itr))
	{
		ret *= 10;
		ret += ctoi(*itr);
		itr++;
	}

	return ret;
}

int main()
{
	string s;
	getline(cin, s);
	s.append("_");

	Int max_ans = -LLONG_MIN;

	REP(i,3)REP(j,3)REP(k,3)
	{
		flag[0] = i;
		flag[1] = j;
		flag[2] = k;
		Itr begin = s.begin();
		Int ans = expression(begin);
		if (max_ans < ans)
		{
			max_ans = ans;
		}
	}
	cout << max_ans << endl;
	return 0;
}




Measured memory_bytes: 3216
#include<stdio.h>

int main() {
    int i,j,k, n, L[100], count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&L[i]);
    }
    for(i=0;i<n-2;i++){
        for(j=1+i;j<n-1;j++){
            for(k=1+j;k<n;k++){
                if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i] && L[i] != L[j] && L[i] != L[k] && L[k] != L[j]){
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
string s;
int K;
int cnt;
int main()
{
	cin >> s >> K;
	string t = s;
	string q = s + s;
	for (int i = 1;i < s.size();i++)
	{
		if (s[i] == s[i - 1]) s[i] = '#', cnt++;
	}
	if (s[0] == s[s.size() - 1])
	{
		int cnt2 = 1;
		t[0] = '#';
		for (int i = 1;i < t.size();i++)
		    if (t[i] == t[i - 1]) t[i] = '#', cnt2++;
		int cnt3 = 1;
		q[0] = '#';
		for (int i = 1;i < q.size();i++)
		    if (q[i] == q[i - 1]) q[i] = '#', cnt3++;
		cout << cnt + (K - 1) / 2 * (long long)cnt3 + (K - 1) % 2 * cnt2<< endl;
	}
	else
	    cout << K * (long long)cnt << endl;
	return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  string S;
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
}

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

int main() {
	int N[3], five = 0, seven = 0;
	for (int i = 0; i < 3; i++) {
		cin >> N[i];
		if (N[i] == 5) {
			five++;
		}
		else if (N[i] == 7) {
			seven++;
		}
	}

	if (five == 2 && seven == 1) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lll __int128_t
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdll pair<ld, pll >
#define ppp pair<pii, pii >
#define F first
#define S second
#define pb push_back
#define pp pop_back

const int P = 1000000007;

using namespace std;

vector<lll> c(4), d;
map<ll, lll> dp;

ll dfs(ll n){
	
	if(n == 0) return 0;
	if(dp[n]) return dp[n];

	dp[n] = n*c[3];
	for(ll i=0; i<3; i++){
		ll k = 0;
		while((n-k)%d[i]) k++;
		dp[n] = min(dp[n], dfs((n-k)/d[i])+k*c[3]+c[i]);
		k = 0;
		while((n+k)%d[i]) k++;
		dp[n] = min(dp[n], dfs((n+k)/d[i])+k*c[3]+c[i]);
	}

	return dp[n];
}

int main(){

	d = {2, 3, 5};

	int t;
	cin >> t;

	for(;t--;){
		lll n;
		ll tmpn;
		vector<ll> tmpc(4);
		cin >> tmpn; n = tmpn;
		for(int i=0; i<4; i++){
			cin >> tmpc[i];
			c[i] = tmpc[i];
		}
		dp.clear();
		cout << dfs(n) << '\n';	
	}

	return 0;
}


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

int main(void){
    int A, K;
    int candidate;

    scanf("%d", &A);
    scanf("%d", &K);

    candidate = (A + K);

    if(candidate % 2 == 1){
        printf("IMPOSSIBLE");
    }else{
        printf("%d", candidate / 2);
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		long[] prices = new long[n];
		long answer = 0;

    for(int i = 0; i < n; i++)
    {
      prices[i] = long.Parse(Console.ReadLine());
    }

    Array.Sort(prices);

    for(int i = 0; i < n-1; i++)
    {
      answer += prices[i];
    }
    answer += prices[n-1]/2;
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13268
/*
*分析：对于每一行除最后一列外只要是奇数都往右边移动
*移动完成后只有最后一列可能有奇数
*对于最后一行我们从第一行到倒数第二行从上往下扫一遍
*z只要是奇数我们就把他往下移动，移动完成后最多只有一个奇数
*那就是位置a(h,w)
*/
#include <stdio.h>
#include <vector>

using namespace std;

#define N 550

struct Node {
    int x, y, x_, y_;
};

int h, w;
int a[N][N];

int main() {
    while (scanf("%d%d", &h, &w) != EOF) {
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                scanf("%d", &a[i][j]);
            }
        }
        vector<Node> res;
        for(int i = 1; i <= h; ++i) {
            for (int j = 1; j < w; ++j) {
                if (a[i][j] & 1) {
                    a[i][j]--; a[i][j + 1]++;
                    res.push_back((Node){i, j, i, j + 1});
                }
            }
        }
        for (int i = 1; i < h; ++i) {
            if (a[i][w] & 1) {
                a[i][w]--; a[i + 1][w]++;
                res.push_back((Node){i, w, i + 1, w});
            }
        }
        printf("%d\n", res.size());
        for (int i = 0; i < res.size(); ++i) {
            printf("%d %d %d %d\n", res[i].x, res[i].y, res[i].x_, res[i].y_);
        }
    }
    return 0;
}


Measured memory_bytes: 5232
n, y = map(int, input().split())
# print(n, y)
st = None
for i in range(n+1):
    for j in range(n+1-i):
        # 1000i + 5000j + 10000k =
        # print(i, j)
        k = n-i-j
        if 10000 * i + 5000 * j + 1000 * k == y:
            st = '{} {} {}'.format(i, j, k)

    if st is None:
        continue
    else:
        break

if st is None:
    print(-1, -1, -1)
else:
    print(st)


Measured memory_bytes: 40684