akhauriyash/Code-Regression huggingface dataset:
// author: Saman Mahdanian
#include<bits/stdc++.h>

const int N = 1e5 + 10;
using namespace std;

struct person {
	int a, b, c;
	void read() {
		cin >> a >> b >> c;
	}
};

long long n, X, Y, Z, a[N], b[N], c[N];
set <pair <long long, int> > leftHand[3], rightHand[3];
person p[N];

int main() {
	cin >> X >> Y >> Z;
	n = X + Y + Z;
	for (int i = 0; i < n; i++) 
		p[i].read();

	sort (p, p + n, [] (person i, person j) {
		return i.b - i.c > j.b - j.c;
	});
	for (int i = 0; i < n; i++)
		a[i] = p[i].a, b[i] = p[i].b, c[i] = p[i].c;

	long long curVal = 0;

	for (int i = 0; i < Y; i++) {
		leftHand[0].insert({b[i] - a[i], i});
		curVal += b[i];
	}

	for (int i = Y; i < n; i++) {
		rightHand[0].insert({c[i] - a[i], i});
		curVal += c[i];
	}
	for (int i = 0; i < X; i++) {
		auto h = *rightHand[0].begin();
		rightHand[0].erase(h);
		rightHand[1].insert(h);
		curVal += a[h.second] - c[h.second];
	}

	long long ans = curVal;

	for (int e = Y; e < Y + X; e++) {
		int flag = -1;
		for (auto i: {0, 1})
			if (rightHand[i].find({c[e] - a[e], e}) != rightHand[i].end()) {
				rightHand[i].erase({c[e] - a[e], e});
				curVal -= (i == 0)? c[e] : a[e];
				flag = i;
				if (i == 0) {
					auto h = *rightHand[1].rbegin();
					rightHand[1].erase(h);
					rightHand[0].insert(h);
					curVal += c[h.second] - a[h.second];
				}
			}
		assert(flag > -1);

		leftHand[1].insert({b[e] - a[e], e});
		curVal += a[e];

		assert (leftHand[0].size() == Y && rightHand[0].size() == Z
			&& leftHand[1].size() + rightHand[1].size() == X);

		if (*leftHand[1].rbegin() > *leftHand[0].begin()) {
			auto v = *leftHand[1].rbegin();
			auto u = *leftHand[0].begin();
			curVal += a[u.second] - a[v.second];
			curVal += b[v.second] - b[u.second];
			leftHand[0].erase(u);
			leftHand[1].erase(v);
			leftHand[1].insert(u);
			leftHand[0].insert(v);
		}

		ans = max(ans, curVal);
	}
	cout << ans << endl;
}

// SamMHD :: May24-2019 :: Another Soale Jazzzzab...

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

const int mxN = 1e5 + 1;

typedef long long int64;

int main() {
	int64 a, b, k;
	cin >> a >> b >> k;
	if(a < k && k > 0)
	{
		int64 aux = a;
		a -= a % k;
		k -= aux % k;
		//cout << a % k << endl;
	}	
	else
	{
		a -= k;
		k = 0;
	}
	//cout << k << endl;
	if(b < k && k > 0)
		b -= b % k;
	else
		b -= k;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
def subset_sum(s, a):
	dict = {}
	return subset_rec(0, s, a, dict)
	
def subset_rec(i, s, a, dict):
	key = str(i) + '-' + str(s)
	ret = False
	if key in dict:
		ret = dict[key]
	elif s == 0:
		ret = True
	elif i >= len(a):
		ret =  False
	else:
		ret = subset_rec(i+1, s-a[i], a, dict) or subset_rec(i+1, s, a, dict)
	dict[key] = ret
	return ret	

n = int(input())
a = list(map(int, input().split()))
p = int(input())
q = list(map(int, input().split()))
for i in range(p):
	if subset_sum(q[i], a):
		print('yes')
	else:
		print('no')



Measured memory_bytes: 6412
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll n;cin>>n;
    ll N=1<<n;
    vi s(N);
    REP(i,N) cin >> s[i];

    multiset<ll> S;
    REP(i,N)S.insert(s[i]);

    priority_queue<ll> q1,q2;
    auto it = S.end();it--;
    q1.push(*it);
    S.erase(it);

    while(S.size()!=0){
        while(q1.size()!=0){
            ll q=q1.top();q1.pop();
            auto it2=S.lower_bound(q);
            if(it2==S.begin()){cout<<"No\n";exit(0);}

            it2--;
            q2.push(*it2);
            S.erase(it2);
            q2.push(q);
        }
        swap(q1,q2);
    }
    cout<<"Yes\n";
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";

    return 0;
}

Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(H, W, M, HW):
    row = [0] * (H)
    col = [0] * (W)
    for h, w in HW:
        h, w = h - 1, w - 1
        row[h] += 1
        col[w] += 1
    mh = max(row)
    mw = max(col)
    mhc = len([i for i, h in enumerate(row) if h == mh])
    mwc = len([i for i, w in enumerate(col) if w == mw])
    cnt = 0
    for h, w in HW:
        h, w = h - 1, w - 1
        if row[h] == mh and col[w] == mw:
            cnt += 1

    print(mh + mw - (1 if mhc * mwc <= cnt else 0))

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, M = map(int, input().split())
    HW = [tuple(map(int, input().split())) for _ in range(M)]
    main(H, W, M, HW)


Measured memory_bytes: 161544
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    int W, H;
    cin >> W >> H;
    vector<ll> p(W), q(H);
    vector<pair<ll,int> > v;
    rep(i, 0, W) {
        int inp;
        cin >> inp;
        v.emplace_back(inp,0);
    }
    rep(i, 0, H) {
        int inp;
        cin >> inp;
        v.emplace_back(inp,1);
    }

    sort(all(v));
    int a = W+1;
    int b = H+1;

    ll ans = 0ll;
    rep(i,0,v.size()){
        if(v[i].second == 0){
            a--;
            ans += b * v[i].first;
        }else{
            b--;
            ans += a * v[i].first;
        }
    }

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


Measured memory_bytes: 7792
#include <stdio.h>

int main(void)
{
    int i, j, cnt, n1, n2, sum = 0, pivot;
    //int A[100000000], B[100000000];

    scanf("%d", &n1);
    int A[n1];
    for (i = 0; i < n1; i++)
    {
        scanf("%d", &A[i]);
    }

    scanf("%d", &n2);
    int B[n2];
    for (j = 0; j < n2; j++)
    {
        scanf("%d", &B[j]);
    }

    pivot = A[n1 / 2];

    for (j = 0; j < n2; j++)
    {
        if (B[j] < pivot)
        {
            //cnt = 0;
            for (i = 0; i < n1 / 2; i++)
            {
                if (A[i] == B[j])
                {
                    sum += 1;
                    //cnt += 1;
                    break;
                }
            }
        }
        else
        {
            for (i = n1 / 2; i < n1; i++)
            {
                if (A[i] == B[j])
                {
                    sum += 1;
                    //cnt += 1;
                    break;
                }
            }
        }
    }

    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;

int ar[ms]={0};

int main()
{
    idfc;

    int n;
    cin>>n;
    int e;
    int i;

    for(i=1;i<=n;i++)
    {
        cin>>e;
        ar[e]++;
        ar[e+1]++;
        if(e)ar[e-1]++;
    }
    int mx=1e5+1;
    e=0;
    for(i=0;i<=mx;i++)e=max(e,ar[i]);
    cout<<e;
    
    return 0;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N;
    cin >> N;
    set<int> xs, ys;
    UnionFind uf(N);
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(xs.count(x) || ys.count(y)){
            cout << -1 << endl;
            return 0;
        }
        xs.insert(x);
        ys.insert(y);
        uf.unite(x, y);
    }
    int ans = 0;
    for(int i=0; i<N; i++) if(uf.find(i) == i) ans += uf.size(i)-1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12872
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::{max, min};
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let waru = 1_000_000_000 + 7;
    let mut ans = 0;
    let diff = max(n, m) - min(n, m);
    if diff == 0 {
        ans = 2 * factorial(n, waru) * factorial(m, waru) % waru;
    } else if diff == 1 {
        ans = factorial(n, waru) * factorial(m, waru) % waru;
    }
    println!("{}", ans);
}
fn factorial(a: usize, waru: usize) -> usize {
    if a < 2 {
        1
    } else {
        a * (factorial(a - 1, waru) % waru) % waru
    }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std; 
long long
 n,m;
int a[200010];
long long ans=0;
long long pos=1;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	while(n>0){
		ans+=(long long)pos;
		pos*=2;
		n/=2;
	}
	cout<<ans<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  if (x % y == 0) {
    cout << -1 << endl;
    return 0;
  }

  int k = 2;
  while (x * k % y == 0) k++;

  cout << k * x << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

ll N, M, Q;
vll a, b, c, d;
ll ans;

void dfs(vll A) {
  if ((ll)A.size() == N + 1) {
    ll now = 0;
    rep(i, Q) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        now += d[i];
      }
      ans = max(ans, now);
    }
    return;
  }

  A.pb(A.back());
  while (A.back() <= M) {
    dfs(A);
    A.back()++;
  }
}

signed main() {
  cin >> N >> M >> Q;

  a = b = c = d = vll(Q);
  rep(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  dfs(vll(1, 1));
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, a, i;
	cin >> a;
	int ans = a + a * a + a * a * a;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3632
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
map<ll,ll> ma,mb;
map<ll,ll> fac(ll n)
{
	map<ll,ll> f;
	while(n%2==0)
	{
		n/=2;
		f[2]++;
	}
	for(ll i=3;i<=sqrt(n);i+=2)
	{
		while(n%i==0)
		{
			n/=i;
			f[i]++;
		}
	}
	if(n>1)
	f[n]++;
	return f;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll a,b;
	cin>>a>>b;
	ll gcd=__gcd(a,b);
	ll ans=1;
	for(ll i=2;i*i<=gcd;i++)
	{
		if(gcd%i==0)
		ans++;
		while(gcd%i==0)
		{
			gcd/=i;
		}
	}
	if(gcd>1)
	ans++;
	cout<<ans<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
const int MAX = 2e5;
int a[MAX + 1];
ll n, k;

bool lessThanK(ll x, ll k) {
    ll skip = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < 0) {
            int l = -1, h = n;
            while (l + 1 < h) {
                int m = l + (h - l) / 2;
                if (1ll * a[i] * a[m] < x) {
                    h = m;
                } else {
                    l = m;
                }
            }
            skip += n - h;
        } else {
            int l = -1, h = n;
            while (l + 1 < h) {
                int m = l + (h - l) / 2;
                if (1ll * a[i] * a[m] < x) {
                    l = m;
                } else {
                    h = m;
                }
            }
            skip += h;
        }

        if (1ll * a[i] * a[i] < x) skip--;
    }

    skip /= 2;
    return skip < k;
}

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a, a + n);

    ll lo = ll(-1e18);
    ll hi = ll(1e18) + 1;
    while (lo + 1 < hi) {
        ll x = lo + (hi - lo) / 2;
        if (lessThanK(x, k)) {
            lo = x;
        } else {
            hi = x;
        }
    }

    cout << lo;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m,r; cin >> n >>m>>r;
    vi od(r);
    rep(i,r){cin >> od[i]; od[i]--;} sort(all(od));
    vvi g(n,vi(n,INF));
    rep(i,m){
        int a,b,c; cin >> a >> b >> c; a--; b--;
        g[a][b]=c;
        g[b][a]=c;
    }
    rep(i,n)g[i][i]=0;

    rep(k,n){
        rep(i,n){
            rep(j,n){
                chmin(g[i][j],g[i][k]+g[k][j]);
            }
        }
    }

    int res=INF;
    do{
        int tmp=0;
        rep(i,r-1){
            tmp+=g[od[i]][od[i+1]];
        }
        chmin(res,tmp);
    }while(next_permutation(all(od)));
    cout<<res<<endl;
}

Measured memory_bytes: 3800
def main():
    a, b, c = map(int, input().split())
    if a == b and b == c:
        print("No")
    elif a == b:
        print("Yes")
    elif b == c:
        print("Yes")
    elif c == a:
        print("Yes")
    else:
        print("No")


def main1():
    if len(set(input().split())) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main1()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int a,b;
	while(cin>>a){
		cin>>b;
		cout<<a+b<<endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

const ll INF = 1e18;
ll dist[310][310];
ll dist2[310][310];

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  REP(i, n) REP(j, n) {
    dist[i][j] = INF;
    if (i == j) dist[i][j] = 0;
  }
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = dist[b][a] = c;
  }
  REP(k, n) REP(i, n) REP(j, n) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  REP(i, n) REP(j, n) {
    dist2[i][j] = INF;
    if (dist[i][j] <= l) {
      dist2[i][j] = dist2[j][i] = 1;
    }
    if (i == j) dist2[i][j] = 0;
  }
  REP(k, n) REP(i, n) REP(j, n) {
    dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
  }
  int q;
  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    cout << (dist2[s][t] == INF ? -1 : dist2[s][t] - 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
using ll = long long;
constexpr int MOD = 1e9 + 7;
constexpr int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int app_x[1000005], app_y[1000005], idx_x[1000005], idx_y[1000005];
int px[65], py[65], dis[65][65], que[100005], sz_x[65], sz_y[65], ans;
bool ban[65][65];
void compress(int n, int m, int k, int *app, int *idx, int *sz)
{
	sz[0] = 1;
	int u = m - app[0], d = ((ll)n * m - k - u) % MOD;
	for (int i = 1; i < n; i++)
	{
		idx[i] = idx[i - 1];
		if (!app[i] && !app[i - 1])
			ans = (ans + (ll)2 * u * d) % MOD;
		else
			idx[i]++;
		sz[idx[i]]++;
		u = (u + m - app[i]) % MOD;
		d = (d + app[i] - m + MOD) % MOD;
	}
}
inline int calc(int x, int y) { return (ll)sz_x[x] * sz_y[y] % MOD; }
inline void bfs(int n, int m, int sx, int sy)
{
	memset(dis, 0x3f, sizeof(dis));
	int he = 0, ta = 0;
	que[ta++] = sx;
	que[ta++] = sy;
	dis[sx][sy] = 0;
	while (he < ta)
	{
		int x = que[he++], y = que[he++];
		ans = (ans + (ll)calc(x, y) * calc(sx, sy) % MOD * dis[x][y]) % MOD;
		for (int i = 0; i < 4; i++)
		{
			int xx = x + dx[i], yy = y + dy[i];
			if (xx < 0 || xx >= n || yy < 0 || yy >= m)
				continue;
			if (!ban[xx][yy] && dis[xx][yy] > 1e9)
			{
				dis[xx][yy] = dis[x][y] + 1;
				que[ta++] = xx;
				que[ta++] = yy;
			}
		}
	}
}
int main()
{
	// freopen("J.in", "r", stdin);
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < k; i++)
	{
		scanf("%d%d", px + i, py + i);
		app_x[px[i]]++;
		app_y[py[i]]++;
	}
	compress(n, m, k, app_x, idx_x, sz_x);
	compress(m, n, k, app_y, idx_y, sz_y);
	for (int i = 0; i < k; i++)
		ban[idx_x[px[i]]][idx_y[py[i]]] = true;
	for (int i = 0; i <= idx_x[n - 1]; i++)
	{
		for (int j = 0; j <= idx_y[m - 1]; j++)
		{
			if (!ban[i][j])
				bfs(idx_x[n - 1] + 1, idx_y[m - 1] + 1, i, j);
		}
	}
	printf("%lld\n", (ll)ans * (MOD + 1) / 2 % MOD);
	return 0;
}


Measured memory_bytes: 14208
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),a[]=new int[n],fac[]=new int[1000001],i,c=0;
        String s[]=bu.readLine().split(" ");
        HashMap<Integer,Integer> hm=new HashMap<>();
        for(i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(s[i]);
            fac[a[i]]++;
            hm.put(a[i],hm.getOrDefault(a[i],0)+1);
        }
        if(a.length==1) {System.out.print(1); return;}

        ArrayList<Integer> al=new ArrayList<>();
        for(i=0;i<n;i++)
        if(hm.get(a[i])==1) al.add(a[i]);

        for(i=0;i<al.size();i++)
        {
            int j,fl=0,k=al.get(i);
            if(fac[k]>1 || (k!=1 && fac[1]>0)) continue;
            for(j=2;j*j<=k;j++)
            if(k%j==0)
            {
                if(fac[j]>0) {fl=1; break;}
                if(fac[k/j]>0) {fl=1; break;}
            }
            if(fl==0) c++;
        }
        System.out.print(c);
    }
}


Measured memory_bytes: 84252
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    vector<string> s(3);
    REP(i,3) {
        cin >> s[i];
        cout << s[i][i];
    }
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 256
# ABC148 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a=ni()
b=ni()

ans=[1,1,1]

ans[a-1]=0
ans[b-1]=0

for i,aa in enumerate(ans):
    if aa==1:
        print(i+1)


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

const int maxl=3e5+10;

int n,m,cas,k,cnt,tot,ans;
int a,b,c;
char s[maxl];
bool in[maxl]; 

inline void prework()
{
	scanf("%d%d%d%d",&a,&b,&c,&k);
	ans=0;
	while(b<=a)
		b*=2,ans++;
	while(c<=b)
		c*=2,ans++;
} 

inline void mainwork()
{
	
}

inline void print()
{
	if(ans<=k)
		puts("Yes");
	else
		puts("No");
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}

Measured memory_bytes: 3768
#include<stdio.h>

int gcd( int greater,  int lower);

int main(){
	int num[2], ans[2];
	
	while(scanf("%d %d", num, num+1) != EOF)
	{
		if(num[0] >= num[1])
		{
			ans[0] = gcd(num[0], num[1]);
		}
		else
		{
			ans[0] = gcd(num[1], num[0]);
		}
		ans[1] = (num[0] / ans[0]) * num[1];
		
		printf("%d %d\n", ans[0], ans[1]);
	}
	
	return 0;
}

int gcd( int greater,  int lower)
{
	int mod = greater % lower;
	
	if(mod == 0)
	{
		return lower;
	}
	else
	{
		return gcd(lower, mod);
	}
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll n,k;
set<vector<ll> > s;

void dfs(vector<ll> v) {
  if(s.count(v)) return;
  s.in(v);
  rep(i,n-k+1) {
    vector<ll> a=v;
    rotate(a.begin()+i,a.begin()+i+1,a.begin()+i+k);
    dfs(a);
  }
}

class BIT{
public:
  ll n,bit[555555];
  BIT(){fill(bit,bit+555555,0);}
  void add(ll i,ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

BIT b;
ll calc(vector<ll> a) {
  b=BIT();
  b.n=n+1;
  ll ans=0;
  rep(i,a.size()) {
    b.add(a[i],1);
    ans+=b.sum(n+1)-b.sum(a[i]);
  }
  return ans;
}

void solve(vector<ll> a) {
  if(n==k) {
    int k=-1;
    rep(i,n) {
      if(a[i]==1) k=i;
    }
    rotate(a.begin(),a.begin()+k,a.end());
    rep(i,n) {
      if(i+1!=a[i]) {
        //pr("No");
        PR(a,a.size());
        exit(0);
        return;
      }
    }
    //pr("Yes");
    return;
  }
  vector<ll> v;
  rep(i,n-k) v.pb(a[i]);
  ll x=calc(v);
  v.clear();
  REP(i,n-k,n) v.pb(a[i]);
  ll y=calc(v);
  if(x%2==y%2);
  else {
    pr(x,y);
    PR(a,a.size()),exit(0);
  }
  //if(x%2==y%2) pr("Yes");
  //else pr("No"),exit(0);
}

void Main() {
  cin >> n >> k;
  vector<ll> a(n);
  /*
  rep(i,n) a[i]=i+1;
  dfs(a);
  tr(it,s) {
    vector<ll> v=*it;
    PR(v,v.size());
    pr(calc(v));
    //solve(v);
  }
  return;
  */
  rep(i,n) R a[i];
  if(n==k) {
    int k=-1;
    rep(i,n) {
      if(a[i]==1) k=i;
    }
    rotate(a.begin(),a.begin()+k,a.end());
    rep(i,n) {
      if(i+1!=a[i]) {
        pr("No");
        return;
      }
    }
    pr("Yes");
    return;
  }
  if(k%2==0) pr("Yes");
  else if(calc(a)%2==0) pr("Yes");
  else pr("No");
}

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



Measured memory_bytes: 13104
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(void)
{
    int n;
    cin >>n;

    vector<pair<int, int> > balls;
    for(int i = 0; i < n; i++){
        int x,y;
        cin >>x >>y;
        balls.push_back(make_pair(x, y));
    }

    sort(balls.begin(), balls.end());
    map<pair<int, int>, int> diffct;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int diffx = balls[i].first - balls[j].first;
            int diffy = balls[i].second - balls[j].second;
            pair<int, int> diffs = make_pair(diffx, diffy);
            map<pair<int, int>, int>::iterator it = diffct.find(diffs);
            if(it == diffct.end()){
                diffct[diffs] = 0;
            }
            diffct[diffs]++;
        }
    }
    int maxCt = 0;
    for(map<pair<int, int>, int>::iterator it = diffct.begin(); it != diffct.end(); it++){
        maxCt = max(maxCt, (*it).second);
    }

    printf("%d\n", n - maxCt);

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String sk = sc.next();
		String s = sc.next();
		int k = Integer.parseInt(sk);
		if(s.length()<=k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0,k) + "...");
		}
		sc.close();
	}
}

Measured memory_bytes: 38460
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;

	vector<int> vec(n);

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

	int t = 1;
	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (vec[i] == t) {
			t++;
		}
		else {
			ans++;
		}
	}

	if (ans == n) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
object Main extends App {
  import scala.io.StdIn._
  val Array(width, height) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.fill(height){readLine.trim.toCharArray}
  val moveCost = Array.fill(height){Array.fill(width){1}}
  for (hole ← (0 until height).flatMap(y ⇒ (0 until width).map(Coordinate(_, y))) if state(hole) == '#') {
    for (dx ← -3 to 3; dy ← -3 to 3; pos ← Some(hole + Coordinate(dx, dy)) if state.isDefinedAt(pos)) {
      moveCost(pos) = math.max(moveCost(pos), 4 - math.max(dx.abs, dy.abs))
    }
  }
  val paper = Array.fill(height){Array.fill(width){-1}}
  val makimono = (0 until height).flatMap(y ⇒ (0 until width).collect { case x if state(y)(x) == 'M' ⇒ Coordinate(x, y) })
  for ((p, i) ← makimono.zipWithIndex) {
    paper(p) = i
  }
  val start = (0 until height).flatMap(y ⇒ (0 until width).collect { case x if state(y)(x) == 'S' ⇒ Coordinate(x, y) }).head
  val goal = (0 until height).flatMap(y ⇒ (0 until width).collect { case x if state(y)(x) == 'G' ⇒ Coordinate(x, y) }).head
  val minCost = Array.fill(height){Array.fill(width){Array.fill(1 << makimono.length){Int.MaxValue}}}
  minCost(start)(0) = 0
  val queue = mutable.PriorityQueue[((Coordinate, Int), Int)](((start, 0), 0))(Ordering.by[((Coordinate, Int), Int), Int](_._2).reverse)
  while(queue.nonEmpty) {
    val ((current, pat), cost) = queue.dequeue()
    if (minCost(current)(pat) == cost){
      for (next ← current.neighbors if paper.isDefinedAt(next) && state(next) != '#') {
        paper(next) match {
          case -1 ⇒
            if (minCost(next)(pat) > cost + moveCost(current)) {
              minCost(next)(pat) = cost + moveCost(current)
              queue.enqueue(((next, pat), cost + moveCost(current)))
            }
          case m ⇒
            if (minCost(next)(pat | (1 << m)) > cost + moveCost(current)) {
              minCost(next)(pat | (1 << m)) = cost + moveCost(current)
              queue.enqueue(((next, pat | (1 << m)), cost + moveCost(current)))
            }
        }
      }
    }
  }
  println(minCost(goal).last)
  implicit class WrapArray[T](val array: Array[Array[T]]) extends AnyVal {
    def isDefinedAt(coordinate: Coordinate): Boolean = array.indices.contains(coordinate.y) && array(coordinate.y).indices.contains(coordinate.x)
    def apply(coordinate: Coordinate): T = array(coordinate.y)(coordinate.x)
    def update(coordinate: Coordinate, value: T): Unit = array(coordinate.y)(coordinate.x) = value
  }
}

case class Coordinate(x: Int, y: Int) {
  def neighbors: Iterable[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
  def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
}



Measured memory_bytes: 448060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int s = 100;
            for (int i = 0; i < n; i++)
                s = (int)Math.Ceiling(s * 1.05);
            Console.WriteLine("{0}000", s);
        }
    }
}

Measured memory_bytes: 5624
#include <stdio.h>

int main() {

	int N;
	double S[100000] = { 0 };
	double temp = 0;
	int i, j;

	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++) {
		scanf("%lf", &S[i]);
	}

	for (i = N-1; i >= 0; i--) {
		for (j = 0; j < i; j++) {
			if (S[j] > S[j + 1]) {
				temp = S[j];
				S[j] = S[j + 1];
				S[j + 1] = temp;

			}
		}
	}

	//昇順に並び替えた。

	double total;
	
	for (i = 0; i < N-1; i++) {
		total = (S[i] + S[i + 1]) / 2;
		S[i + 1] = total;
	}
	total = (total + S[N - 1]) / 2;

	printf("%lf\n", total);
	

	return 0;

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
const int N=1e5+1;
int n, from[N], ans[N];
bool vis[N];
std::vector<int> e[N], lp;
int bfs(int src) {
	static int queue[N];
	int *head=queue, *tail=queue;
	memset(vis+1, 0, n);
	from[*tail++=src]=0;
	while(head!=tail) {
		int u=*head++;
		vis[u]=true;
		for(int v: e[u]) if(!vis[v]) from[*tail++=v]=u;
	}
	return tail[-1];
}
int main() {
	assert(scanf("%d", &n)==1);
	for(int i=1; i<n; ++i) {
		int u, v;
		assert(scanf("%d%d", &u, &v)==2);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for(int i=bfs(bfs(1)); i; i=from[i]) lp.push_back(i);
	memset(vis+1, 0, n);
	for(int u: lp) for(int v: e[u]) vis[v]=true;
	for(int i=1; i<=n; ++i) if(!vis[i]) {
		puts("-1");
		return 0;
	}
	for(int i=0, j=lp.size(); i<--j; ++i) {
		if(e[lp[i]].size()<e[lp[j]].size()) break;
		if(e[lp[i]].size()>e[lp[j]].size()) {
			std::reverse(lp.begin(), lp.end());
			break;
		}
	}
	for(int i=0, j=0, k=1; i<lp.size(); ++i) {
		int siz=i==0||i==lp.size()-1?0:e[lp[i]].size()-2;
		for(int i=1; i<=siz; ++i) ans[j++]=k+i;
		ans[j++]=k;
		k+=siz+1;
	}
	for(int i=0; i<n; ++i) printf("%d%c", ans[i], " \n"[i==n-1]);
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

int N;

signed main() {
  cin >> N;

  vector<P> arm(N);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    P p;
    p.first = a + b;
    p.second = a - b;

    arm[i] = p;
  }

  sort(all(arm));

  int lastArmPos = -INF_INT;
  int ans = 0;
  rep(i, N) {
    if(lastArmPos <= arm[i].second){
      ans++;
      lastArmPos = arm[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,a,b;
  cin>>n>>a>>b;
  if(a==0 && b==0){
    cout<<0;
    return (0);
  }
  if(n<=a){
    cout<<n;
    return (0);
  }
  if(n<=a+b){
    cout<<a;
  }
  else{
    ll sum=0;
    sum+=(n/(a+b)*a);
    if(n%(a+b)>a){
      sum+=a;
    }
    else{
      sum+=n%(a+b);
    }
    cout<<sum;
  }
  return(0);
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll L, A, B, MOD, ten;

struct mll {
    ll x;
    mll(ll x=0): x(x%MOD){
    }
    mll& operator+=(const mll a) {
        (x += a.x) %= MOD;
        return *this;
    }
    mll& operator-=(const mll a) {
        (x += MOD-a.x) %= MOD;
        return *this;
    }
    mll& operator*=(const mll a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mll operator+(const mll a) const {
        mll res(*this);
        return res+=a;
    }
    mll operator-(const mll a) const {
        mll res(*this);
        return res-=a;
    }
    mll operator*(const mll a) const {
        mll res(*this);
        return res*=a;
    }
};

// x^y
mll pow_(mll x, ll y) {
    if (y==0)
        return mll(1);
    else if(y%2==1) {
        return pow_(x, y-1) * x;
    } else {
        mll z = pow_(x, y/2);
        return z*z;
    }
}

mll f(ll l) {
    if (l==0)
        return 0;

    if (l%2==1){
        ll pl = l-1;
        mll x = f(pl);
        return x*mll(ten)*mll(10)+mll(1);
    } else {
        ll pl = l/2;
        mll x = f(pl);
        return x*pow_(mll(ten)*mll(10), pl) + x;
    }
    return 0;
}

mll g(ll l) {
    if (l==0)
        return 0;

    if (l%2==1) {
        ll pl = l-1;
        mll x = g(pl);
        return x*mll(ten)*mll(10) + B*pl;
    } else {
        ll pl = l/2;
        mll x = g(pl);
        return x*pow_(mll(ten)*mll(10), pl) + x + mll(B)*mll(pl)*f(pl);
    }
}

signed main() {
    cin>>L>>A>>B>>MOD;
    mll ans(0);

    ten = 1;
    for (ll k=0; k<18; k++, ten*=10) { // [ 10^k  10^(k+1) ) の区間について
        if (A+B*(L-1) < ten) continue;
        if (10*ten <= A) continue;
        ll a; // 区間内での初項
        if (ten <= A) {
            a = A;
        } else{
            a = (ten-A + B-1)/B * B + A;
        }
        ll last; // 区間内での最後の項
        if (A+B*(L-1) < 10*ten) {
            last = A+B*(L-1);
        } else {
            last = (10*ten-1 - A)/B * B + A;
        }
        ll l = (last-a)/B + 1; // 区間内での項の数

        if (last < a) continue;


        mll ans_k = mll(a)*f(l) + g(l);
        ans *= pow_(mll(10*ten), l);
        ans += ans_k;

        //printf("k=%d [%2lld %2lld) %2lld -> %2lld (%lld) ans_k=%d\n",
        //        k, ten, ten*10, a, last, l, ans_k.x);
    }
    cout<<ans.x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// const int N = 1e5 + 7;
typedef long long int lli;
// int a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, w;
    cin >> n >> w;
    vector<lli> value(w + 1, 0), val(n), wei(n);
    for (int i = 0; i < n; i++) cin >> wei[i] >> val[i];

    for (int i = 0; i < n; i++) {
        vector<lli> temp(w + 1);
        for (int j = 1; j <= w; j++) {
            temp[j] = max(
                value[j],
                j - wei[i] >= 0 ? value[j - wei[i]] + val[i] : INT_MIN);
        }
        value = temp;
    }

    cout << value[w] << endl;
    return 0;
}

Measured memory_bytes: 1908
def main():
    nums = list(map(int, input().split()))

    res = 0

    while len(set(nums)) != 1:
        maxIdx = nums.index(max(nums))
        minIdx = nums.index(min(nums))

        if nums[maxIdx] - nums[minIdx] >= 2:
            nums[minIdx] += 2
            res += 1
        else:
            nums[minIdx] += 1
            nums[nums.index(min(nums))] += 1

            res += 1
    
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9144
import java.util.Scanner;

//Anipero
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int L = sc.nextInt(), n = sc.nextInt(), m = sc.nextInt(), X = sc.nextInt();
			if((L|n|m|X)==0)break;
			int[] e1 = new int[n], s1 = new int[n];
			for(int i=0;i<n;i++){
				sc.next(); e1[i] = sc.nextInt(); s1[i] = sc.nextInt();
			}
			int[] e2 = new int[m], s2 = new int[m];
			for(int i=0;i<m;i++){
				sc.next(); e2[i] = sc.nextInt(); s2[i] = sc.nextInt();
			}
			int[][][] dp1 = new int[n][3][L+1];
			//-1: À»sÂ\Ì}[N
			for(int i=0;i<n;i++)for(int x=1;x<=2;x++)for(int l=0;l<=L;l++)dp1[i][x][l] = -1;
			for(int l=e1[0];l<=L;l++)dp1[0][1][l] = s1[0];
			for(int i=1;i<n;i++)for(int x=1;x<=2;x++)for(int l=0;l<=L;l++){
				int max = -1;
				if(l>0)max = dp1[i][x][l-1];
				if(l-e1[i]<0){
					max = Math.max(max, dp1[i-1][x][l]); 
				}
				else {
					if(dp1[i-1][x][l]>=0)max = Math.max(max, dp1[i-1][x][l]);
					if(dp1[i-1][x-1][l-e1[i]]>=0)max = Math.max(max, dp1[i-1][x-1][l-e1[i]]+s1[i]);
				}
				dp1[i][x][l] = max;
			}
			int[][][] dp2 = new int[m][m+1][L+1];
			for(int i=0;i<m;i++)for(int x=1;x<=m;x++)for(int l=0;l<=L;l++)dp2[i][x][l] = -1;
			for(int l=e2[0];l<=L;l++)dp2[0][1][l] = s2[0];
			for(int i=1;i<m;i++)for(int x=1;x<=m;x++)for(int l=0;l<=L;l++){
				int max = -1;
				if(l>0)max = dp2[i][x][l-1];
				if(l-e2[i]<0){
					max = Math.max(max, dp2[i-1][x][l]); 
				}
				else {
					if(dp2[i-1][x][l]>=0)max = Math.max(max, dp2[i-1][x][l]);
					if(dp2[i-1][x-1][l-e2[i]]>=0)max = Math.max(max, dp2[i-1][x-1][l-e2[i]]+s2[i]);
				}
				dp2[i][x][l] = max;
			}
			int max = 0;
			for(int x=X;x<=m;x++)for(int l=0;l<=L;l++){
				if(dp2[m-1][x][l]==-1)continue;
				if(dp1[n-1][1][L-l]==-1&&dp1[n-1][2][L-l]==-1)continue;
				int v = dp2[m-1][x][l] + Math.max(dp1[n-1][1][L-l], dp1[n-1][2][L-l]);
				max = Math.max(max, v);
			}
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 57000
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    ll N, K;

    cin >> N >> K;

    ll sum = 0;
    for (ll i = K; i <= N + 1; i++) {
        ll mn = i * (0 + i - 1) / 2;
        ll mx = i * (N - (i - 1) + N) / 2;
        sum += mx - mn + 1;
    }

    cout << sum % 1000000007 << endl;

    return 0;
}


Measured memory_bytes: 3636