akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, M;
    int k, s, p;
    cin >> N >> M;
    vector<vector<int>> light(M);
    vector<int> P;
    for (int i = 0; i < M; i++){
        cin >> k;
        for (int j = 0; j < k; j++){
            cin >> s;
            light.at(i).push_back(s);
        }
    }
    for (int i = 0; i < M; i++){
        cin >> p;
        P.push_back(p);
    }
    int ans = 0;
    bool all_on;
    for (int bit = 0; bit < (1 << N); bit++){
        all_on = true;
        for (int i = 0; i < M; i++){
            int on = 0;
            for (int j = 0; j < light.at(i).size(); j++){
                if (bit & (1 << light.at(i).at(j) - 1)){
                    on += 1;
                }
            }
            if (on % 2 != P.at(i)){
                all_on = false;
            }            
        }
        if (all_on){
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	double n; cin >> n;
	if ((int)n % 2 == 0) {
		cout << setprecision(10) << (n / 2.0) / n << endl;
	}
	else {
		cout << setprecision(10) << (int)(n / 2.0 + 1) / n << endl;
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
  	cin >> n;
  	vector<string> s(n);
	vi temp(26,100);

  	rep(i,n) {
      cin >> s[i];
      vi cnt(26,0);
      rep(j,s[i].size()) cnt[s[i][j]-'a']++;
      rep(j,26) temp[j] = min(temp[j], cnt[j]);
    }
  
  	rep(i,26){
    	rep(j,temp[i]) cout << (char)('a'+i);
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
// bfs atcoder088-d

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> g(h);
  int black = 0;

  for (int i = 0; i < h; i++) {
    cin >> g[i];
    for (int j = 0; j < w; j++) {
      black += g[i][j] == '#'; //塗りつぶされているところをカウント
    }
  }

  queue<pair<int, int>> q;
  q.emplace(0, 0);

  vector<vector<int>> dist(h, vector<int>(w, -1)); //二次元ベクターを定義
  dist[0][0] = 0;

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

  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int yy = y + dy[k];
      int xx = x + dx[k];
      if (yy < 0 || xx < 0 || yy >= h || xx >= w) continue;  //はみ出た場合
      if (g[yy][xx] == '#') continue;    //塗りつぶされている場合
      if (dist[yy][xx] != -1) continue;  //訪問済みの場合
      dist[yy][xx] = dist[y][x] + 1; //初期位置からの移動距離
      q.emplace(yy, xx);
    }
  }

  if (dist[h - 1][w - 1] == -1) {
    cout << -1 << endl;
  } else {
    cout << (h * w) - dist[h - 1][w - 1] - black - 1 << endl;
  }
}

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

/*
#include <atcoder/all>
using namespace atcoder;
*/

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007; // 10^9+7
const ll INF = 10000000000;

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

    ll ans=0,tmp;

    rep1(i,n){
        tmp =  n/i;
        if(n%i == 0) tmp--;
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
ll h,n;
vector<pair<int, int>> v;
ll ans[10001];

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> h >> n;
	REP(i, n) {
		int a, b;
		//*
		cin >> a >> b;
		v.push_back(make_pair(a, b));
		/*/
		v.push_back(make_pair(1, 1));
		//*/
	}

	ans[0] = 0;
	REPS(i, h) {
		ans[i] = (ll)INF;
	}

	REP(i, n) {
		//cout << i << endl;
		int dmg = v[i].first;
		int mgc = v[i].second;
		REP(j, h) {
			//cout << " " <<j << endl;
			if (ans[j] == INF)continue;
			if (j + dmg >= h) {
				chmin(ans[h], ans[j] + mgc);
				//cout << ans[h] << endl;
				continue;
			}
			chmin(ans[j + dmg], ans[j] + mgc);
		}
	}
	cout << ans[h] << endl;
}

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

int main()
{
  long a, b;
  cin >> a >> b;
  long s = b - a;
  long higashi = 0;
  for (int i = 1; i <= s; i++)
  {
    higashi += i;
  }
  long sekisetu = higashi - b;
  cout << sekisetu << endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    ll n;
    ll a,b;
    cin >> n >> a >> b;

    ll x =n/(a+b);
    ll ans = x*a+min(a,n%(a+b));
    cout << ans << endl;
}

Measured memory_bytes: 256
k, x = gets.split(" ").map(&:to_i)
s = x - (k - 1)
e = x + (k - 1)

if s < -1_000_000
  t = -(s + 1_000_000)
  s = s + t
  e = e + t
end

if e > 1_000_000
  t = (e - 1_000_000)
  s = s - t
  e = e - t
end

puts Range.new(s, e).to_a.join(" ")


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    double n,m,d;
    cin >> n >> m >> d;
    if(d == 0) printf("%.10lf\n", (m - 1) * (n - d) / pow(n, 2));
    else printf("%.10lf\n", 2 * (m - 1) * (n - d) / pow(n, 2));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r,key;};
struct Node T[MAX];

int n, S[MAX],DG[MAX],H[MAX], D[MAX];

void PreorderTreeWalk(int u){
  printf(" %d",u);
  if(T[u].l != NIL)PreorderTreeWalk(T[u].l);
  if(T[u].r != NIL)PreorderTreeWalk(T[u].r);
}

void InorderTreeWalk(int u){
  if(T[u].l != NIL)InorderTreeWalk(T[u].l);
  printf(" %d",u);
  if(T[u].r != NIL)InorderTreeWalk(T[u].r);
}

void PostorderTreeWalk(int u){
  if(T[u].l != NIL)PostorderTreeWalk(T[u].l);
  if(T[u].r != NIL)PostorderTreeWalk(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v,&l,&r);
    /*make tree*/
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
 
  printf("Preorder\n");
  for(i=0; i<n; i++){
    if(T[i].p == NIL)PreorderTreeWalk(i);
  }
  printf("\n");

 printf("Inorder\n");
  for(i=0; i<n; i++){
    if(T[i].p == NIL)InorderTreeWalk(i);
  }
  printf("\n");

 printf("Postorder\n");
  for(i=0; i<n; i++){
    if(T[i].p == NIL)PostorderTreeWalk(i);
  }
  printf("\n");

  return 0;
  
}

Measured memory_bytes: 624
#include <stdio.h>

void sort(long long int *data,long long int left,long long int right){
  long long int i,j,p,tmp;

  i = left;
  j = right;
  p = data[(i+j)/2];

  while(1){
    while(data[i] > p){
      i++;
    }
    while(p > data[j]){
      j--;
    }
    if(i >= j){
      break;
    }

    tmp = data[i];
    data[i] = data[j];
    data[j] = tmp;

    i++;
    j--;
  }

  if(left < i-1){
    sort(data,left,i-1);
  }
  if(j+1 < right){
    sort(data,j+1,right);
  }
}

int main(){
  long long int n,i,sum,pipe;
  long long int joint[65000];
  long long int price;

  while(1){
    scanf("%d",&n);
    if(n == 0){
      break;
    }

    sum = 0;
    for(i = 0;i < n;i++){
      scanf("%d",&pipe);
      sum += pipe;
    }

    for(i = 0;i < n-1;i++){
      scanf("%d",&joint[i]);
    }

    sort(joint,0,n-1);

    price = sum*n;

    for(i = 0;i < n-1;i++){
      if(price < (sum+joint[i])*(n-1-i)){
        price = (sum+joint[i])*(n-1-i);
      }else{
        break;
      }
      sum += joint[i];
    }

    printf("%lld\n",price);
  }

  return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void) {
  int a, b, sum;
  double cnt;
  while(scanf("%d %d", &a, &b) != EOF) {
    sum = a + b;
    cnt = log10(sum);
    cout << (int)cnt + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

pair<vector<int>, vector<int>> convert(const string& moves) {
	vector<int> vert, hor;

	for(auto& chr: moves) {
		if(chr == 'R') {
			vert.push_back(0);
			hor.push_back(1);
		} else if(chr == 'L') {
			vert.push_back(0);
			hor.push_back(-1);
		} else if(chr == 'U') {
			vert.push_back(-1);
			hor.push_back(0);
		} else {
			vert.push_back(1);
			hor.push_back(0);
		}
	}

	return make_pair(vert, hor);
}

int H, W, N;
int sx, sy;

int solve_1D(const vector<int>& a, const vector<int>& b, int pos, int sz) {
	int n = len(a);

	for(auto& dir: {-1, 1}) {
		int cur = pos;

		for(int i = 0; i < n; ++i) {
			if(a[i] == dir) {
				cur += a[i];
			}

			if(cur < 0 || cur >= sz) {
				return 0;
			}

			if(b[i] == -dir) {
				int cur2 = cur + b[i];

				if(cur2 >= 0 && cur2 < sz) {
					cur = cur2;
				}
			}
		}
	}

	return 1;
}

void solve() {
	cin >> H >> W >> N;
	cin >> sx >> sy;
	--sx, --sy;

	string _S, _T;
	cin >> _S >> _T;

	auto S = convert(_S);
	auto T = convert(_T);

	int answ = solve_1D(S.first, T.first, sx, H) && solve_1D(S.second, T.second, sy, W);
	cout << (answ ? "YES\n" : "NO\n");
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 5992
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename T>
struct SegTree{
  using F = function<T(T, T)>;
  T identity;
  F merge;
  int size;
  vector<T> dat;
  
  SegTree(F f,T id):merge(f),identity(id){}

  // initialize (n is number of elements)
  void init(int n){
    size = 1;
    while(size<n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // initialize 
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int k,T a){
    k += size - 1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // return query for [a,b). (k,l,r) = (0,0,seg.size)
  T query(int a,int b,int k,int l,int r){
    // out of range
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<int> c(q);
  vector<ll> x(q),y(q);
  rep(i,q) cin >> c[i] >> x[i] >> y[i];
  auto f = [&](int a,int b){ return min(a,b);};
  ll id = (1LL<<31)-1;
  SegTree<ll> seg(f,id);
  seg.init(n);
  rep(i,q){
    if(c[i]==0) seg.update(x[i],y[i]);
    else cout << seg.query(x[i],y[i]+1,0,0,seg.size) << "\n";
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++) cin >> S.at(i);
  vector<int> comm(26);
  for(int i=0; i<26; i++) comm.at(i)=50;
  for(int i=0; i<N; i++){
    vector<int> cnt(26);
    int L = S.at(i).size();
    for(int j=0; j<L; j++){
      cnt.at(S.at(i).at(j)-97)++;
    }
    for(int j=0; j<26; j++){
      comm.at(j)=min(comm.at(j), cnt.at(j));
    }
  }
  
  for(int i=0; i<26; i++){
    for(int j=0; j<comm.at(i); j++) cout << char(i+97);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
    string S;
    cin >> S;
    int j = 0;
    for (int i = 0; i < S.size(); i++) {
        j++;
        for (int j = 1 + i; j < S.size(); j++) {
            if (S[i] == S[j]) {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define MP make_pair
#define INF 1000000000
using namespace std;

int dp[3][11][85];
vector<pair<int,int> > ve[160];
int main(){
	int N,M,a,b,c,T,I,O,tmp,cnt,cntt,hog,res;
	vector<pair<int,int> >::iterator it,lit;
	while(true){
		cin>>N>>M;
		if(N==0&&M==0) break;
		ve[0].clear();
		for(int i=1;i<=N;i++){
			ve[i].clear();
			cin>>a;
			for(int j=0;j<a;j++){
				cin>>b>>c;
				ve[i].push_back(MP(b,c));
			}
		}
		
		T=0;I=1;O=2;
		for(int i=0;i<3;i++){
			for(int j=0;j<11;j++){
				fill(dp[i][j],dp[i][j]+85,INF);
			}
		}
		for(int i=0;i<(int)ve[2].size();i++){
			ve[0].push_back(ve[2][i]);
			dp[T][i][0]=0;
		}
		for(int i=0;i<(int)ve[1].size();i++){
			dp[I][i][0]=0;
		}
		
		for(int i=2;i<=N;i++){
			cnt=0;
			for(it=ve[i].begin();it!=ve[i].end();it++){
				for(int j=0;j<=M;j++){
					cntt=0;
					hog=INF;
					for(lit=ve[i-1].begin();lit!=ve[i-1].end();lit++){
						hog=min(hog,dp[I][cntt][j]+((lit->second)+(it->second))*abs((lit->first)-(it->first)));
						cntt++;
					}
					if(j!=0){
						cntt=0;
						for(lit=ve[i-2].begin();lit!=ve[i-2].end();lit++){
							hog=min(hog,dp[T][cntt][j-1]+((lit->second)+(it->second))*abs((lit->first)-(it->first)));
							cntt++;
						}
					}
					dp[O][cnt][j]=hog;
					//cout<<i<<" "<<cnt<<" "<<j<<" "<<hog<<endl;//
				}
				cnt++;
			}
			tmp=T;
			T=I;
			I=O;
			O=tmp;
		}
		res=INF;
		for(int i=0;i<=M;i++){
			for(int j=0;j<(int)ve[N].size();j++){
				res=min(res,dp[I][j][i]);
			}
		}
		if(M!=0)for(int i=0;i<M;i++){
			for(int j=0;j<(int)ve[N-1].size();j++){
				res=min(res,dp[T][j][i]);
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(n),c(n); for(auto&i:v)cin>>i; for(auto&i:c)cin>>i;
	int ans=0;
	for(int i=0;i<n;++i){
		int x=v.at(i),y=c.at(i);
		if(x-y>0)ans+=x-y;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int i = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int i = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int i = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int n; cin >> n;
    int ans = 0;
    vector<ll> l(n); rep(i,n) cin >> l[i];
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            for(int k = j+1; k < n; ++k){
                ll max = l[i];
                chmax(max, l[j]);
                chmax(max, l[k]);
                if(max*2 - (l[i]+l[j]+l[k]) < 0 && l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) ++ans;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

multiset <int> adj[MAXN];
map <pii, int> cnt, use;
int n, f[MAXN];
queue <pii> q;

inline pii Mak(int x, int y)
{
	return x < y ? mp(x, y) : mp(y, x);
}

inline int Find(int x)
{
	while (x ^ f[x])
		x = f[x] = f[f[x]];
	return x;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		f[i] = i;
	for (int i = 1, x, y; i <= n - 1 << 1; i ++)
	{
		x = Read(), y = Read();
		adj[x].insert(y), adj[y].insert(x);
		if (cnt[Mak(x, y)] ++ && use.find(Mak(x, y)) == use.end())
			q.push(Mak(x, y)), use[Mak(x, y)] = 1;
	}
	for (int i = 1, x, y; i < n; i ++)
	{
		do
		{
			if (q.empty())
				return puts("NO"), 0;
			x = Find(q.front().xx), y = Find(q.front().yy), q.pop();
		} while (x == y);
		if (adj[x].size() > adj[y].size())
			swap(x, y);
		f[x] = y;
		for (auto z : adj[x])
		{
			z = Find(z);
			if (z == y)
				continue;
			adj[y].insert(z), adj[z].insert(y);
			if (cnt[Mak(y, z)] ++ && use.find(Mak(y, z)) == use.end())
				q.push(Mak(y, z)), use[Mak(y, z)] = 1;
			adj[z].erase(adj[z].find(x));
		}
		adj[y].erase(adj[y].find(x)), adj[x].clear();
	}
	return puts("YES"), 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BHarshadNumber {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    ll n;
	    in >> n;

	    ll buf = n;
	    ll sum = 0;
	    while(buf > 0){
            sum += buf%10;
            buf /= 10;
	    }

	    ans(n%sum == 0, out);
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin >> n;
  vector<int> h(n);
  vector<ll> dp(n);
  REP(i,n){
    cin >> h[i];
    dp[i]=INF;
  }
  dp[0] = 0;

  for(int i=0;i<n;i++){
    for(int j=1;j<=2;j++){
      if(i+j>n-1) continue;
      dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
    }
  }

  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  int h, m, s, S;
  scanf ("%d", &S);

  h = S / 3600;
  m = S / 60 - h * 60;
  s = S % 60;
  printf ("%d:%d:%d\n", h, m, s);
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=LINF;
  {
    ll p=0, m=0;
    ll tmp=0;
    rep(i,n){
      if(i%2==0){
        p+=a[i];
        if(p+m<=0){
          tmp+=abs(p+m)+1;
          p+=abs(p+m)+1;
        }
      }else{
        m+=a[i];
        if(p+m>=0){
          tmp+=abs(p+m)+1;
          m-=abs(p+m)+1;
        }
      }
    }
    chmin(ans,tmp);
  }
  
  {
    ll p=0, m=0;
    ll tmp=0;
    rep(i,n){
      if(i%2==1){
        p+=a[i];
        if(p+m<=0){
          tmp+=abs(p+m)+1;
          p+=abs(p+m)+1;
        }
      }else{
        m+=a[i];
        if(p+m>=0){
          tmp+=abs(p+m)+1;
          m-=abs(p+m)+1;
        }
      }
    }
    chmin(ans,tmp);
  }
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
   fast_io
   ll n;
   cin>>n;
   ll a[n+1][4];
   for(ll i = 1;i<=n;i++){
       for(ll j = 1;j<=3;j++){
               cin>>a[i][j];
       }
   }
   ll dp[n+2][4];
   // Intialization
   for(ll j = 1;j<=3;j++){
       dp[1][j] = a[1][j];
   }
   for(ll i = 2;i<=n;i++){
       for(ll j = 1;j<=3;j++){
           if(j == 1){
                dp[i][j] = a[i][j] + max(dp[i-1][j+1] , dp[i-1][j+2]);
           }
           if(j == 2){
               dp[i][j] = a[i][j] + max(dp[i-1][j-1] , dp[i-1][j+1]);
           }
           if(j == 3){
                dp[i][j] = a[i][j] + max(dp[i-1][j-2] , dp[i-1][j-1]);
           }
       }
   }
   ll ans = 0;
   for(ll i = 1;i<=3;i++){
       ans = max(ans,dp[n][i]);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 9788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int n;
	int maxer = 0;
	bool isans = false;

	std::cin >> n;

	for (int i = 0; i <= 25; ++i) {
		for (int j = 0; j < 15; ++j) {
			if (n == (4 * i) + (j * 7)) {
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "No" << std::endl;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; string s;
	cin >> n >> s;
	if(n<=3){
		cout << 0 << endl;
		return 0;
	}
	int r=0,g=0,b=0;
	for(int i=0; i<n; i++){
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}
	ll ans = r;
	ans *= g;
	ans *= b;
	int ptr = 1;
	while(ptr<=n){
		for(int i=0; i<n; i++){
			if(i+2*ptr>=n)break;
			if(s[i]!=s[i+ptr]&&s[i+ptr]!=s[i+2*ptr]&&s[i]!=s[i+2*ptr])ans--;
		}
		ptr++;
	}
	cout << ans << endl;
}	
/*  Benq's (modified)
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a + b >= c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define int ll

template < typename T > using indexed_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
 
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9+7, INF = INT_MAX, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int r;
   cin >> r;
   db ans = 2*PI*r;
   cout << setprecision(14) << fixed << ans << '\n';
   return 0;
}


Measured memory_bytes: 3780
main = do
    [n,y] <- map read . words <$> getLine
    let ans = [ [a, b, c] | a <- [0..n],
                            b <- [0..n-a],
                            let c = n - a - b,
                            10000 * a + 5000 * b + 1000 * c == y ] ++ [replicate 3 (-1)]
    putStrLn .unwords . map show . head $ ans


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct UnionFind {
    vector<int> par;
    
    //要素nで初期化
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    //xが属する集合の根を返す
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    //xとyが同じ集合に属しているかを判定
    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    //xが属する集合とyが属する集合をマージ
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // 計算量が減るよ
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    //xが属する集合のサイズ
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
	int n,m;cin>>n>>m;
	UnionFind uf(n + 1);
	for(int i = 0; i < m; i++) {
		int a,b;cin>>a>>b;
		uf.merge(a,b);
	}
	int ans = -1;
	for(int i = 1; i <= n; i++) {
		ans = max(ans,uf.size(i));
	}
	cout << ans << endl;
	return 0;
}

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

long long dp2[5][25000005]={};

int main(int argc, char const *argv[])
{
	int n,g[2][3];
	cin>>n;
	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin>>g[i][j];
		}
	}
	int dp1[5][5005]={};
	for (int i = 1; i <= 3; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			dp1[i][j]=dp1[i-1][j];
			if (j-g[0][i-1]>=0)
			{
				dp1[i][j]=max(dp1[i][j],dp1[i][j-g[0][i-1]]+g[1][i-1]-g[0][i-1]);
			}
		}
	}
	for (int i = 1; i <= 3; ++i)
	{
		for (int j = 1; j <= dp1[3][n]+n; ++j)
		{
			dp2[i][j]=dp2[i-1][j];
			if (j-g[1][i-1]>=0)
			{
				dp2[i][j]=max(dp2[i][j],(long long)dp2[i][j-g[1][i-1]]+g[0][i-1]-g[1][i-1]);
			}
		}
	}
	cout<<dp2[3][dp1[3][n]+n]+dp1[3][n]+n<<endl;
	return 0;
}


Measured memory_bytes: 588160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
using ll = long long;
ll gcd(ll p,ll q){
    if (p<q) swap(p,q);
    ll r;
    while (q>0) {
        r=p%q;
        p=q;
        q=r;
    }
    return p;
}
ll lcm(ll m, ll n){
    if (m<n) swap(m,n);
    ll gcd(ll,ll);
    ll x=(m/gcd(m,n))*n; 
    return x;
}

int main() {
    int N;cin >> N;
    vector<ll> A(N);
    ll L = 1;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++){
        // if (i==0) L = A[i];
        // if (i>=1) 
        L = lcm(L,A[i]);
    }
    ll sum_L = 0;
    for(int i=0;i<N;i++){
        sum_L += L/A[i];
    }
    double ans = L*1.0/sum_L*1.0;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include <map>
#include<queue>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef queue<int> IntQueue;
//typedef std::pair<int, int> pair;



void solve(){
  int N,x,l;
  cin>>N;
  vector<pair<int, int>> X;
  rep(i,N){
    cin>>x>>l;
    X.push_back(make_pair(x+l,x-l));
    //X[i].first=x+l;
    //X[i].second=x-l;
  }
  sort(X.begin(), X.end());
  int ans=0;
  int r=-1e9;
  rep(i,N){
    if (X[i].second>=r){
      ans++;
      r=X[i].first;
    }
  }
  cout<<ans<<endl;
  return;
}

int main(){
  solve();
  return 0;
}
      


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    ll d ;
    cin >> d ;

    int ans = 0 ;
    d *= d ;

    for ( int i=0 ; i < n ; i ++ )
    {
        ll x , y ;
        cin >> x >> y ;

        if ( x*x + y*y <= d )
            ans ++ ;
    }

    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3636
n, x = input().split()
n = int(n)
x = int(x)

m_sum = 0
m_min = 1000
for i in range(n):
    m = int(input())
    m_sum += m
    if m < m_min:
        m_min = m

cnt = 0
cnt += n

x -= m_sum

cnt += int(x // m_min)

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	vector<ll> v(n);
	for(auto&i:v)cin>>i;
	sort(rall(v));
	ll aval=-1, ax=1;
	ll anum=0, c[51][51];
	rep(i,n+1)rep(j,i+1) if(!j or j==i){
		c[i][j]=1;
	}else c[i][j]=c[i-1][j-1]+c[i-1][j];
	
	
	for(int i=a;i<=b;i++){
		ll val=0;
		int w=0;
		for(int j=0;j<i;j++){
			val+=v[j];
			w++;
			if(j and v[j]!=v[j-1]) w=1;
		}
		if(val*ax>aval*i){
			aval=val;
			anum=0;
			ax=i;
		}
		if(val*ax==aval*i) {
			int x=count(all(v),v[i-1]);
			anum+=c[x][w];
		}
	}
	cout<<fixed<<setprecision(7)<<(double)aval/ax<<endl;
	cout<<anum<<endl;
		
	return 0;
}




Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int[] A=new int[N];
    int[] B=new int[N-1];
    int ans=0;
    for(int i=0;i<N-1;i++){
      B[i]=scan.nextInt();
    }
    A[0]=B[0];
    for(int i=0;i<N-2;i++){
      if(B[i]<B[i+1]){
        A[i+1]=B[i];
      }else{
        A[i+1]=B[i+1];
      }
    }
    A[N-1]=B[N-2];
    for(int i=0;i<N;i++){
      ans+=A[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
MOD = 10**9 + 7
def Mod_Permutation(n, k, mod):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret = ret * i % mod
    return ret
N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
elif N == M:
    print(int(Mod_Permutation(N, N, MOD) * (2 * Mod_Permutation(N, M, MOD) % MOD) % MOD))
else:
    if N < M:
        T = N
        N = M
        M = T
    print(int(Mod_Permutation(N, N, MOD) * Mod_Permutation(M, M, MOD) % MOD))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int p=1000000007;
  vector<int64_t> f(max(n,m)+1,1);
  for(int i=1;i<=max(n,m);i++)
    f.at(i)=f.at(i-1)*i%p;
  cout<<f.at(n)*f.at(m)*(2-min(abs(n-m),2))%p<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			int n = (int)nk[0];
			int k = (int)nk[1];

			var dic = new Dictionary<long, long>();
			long lastVal = 0;
			for (long i = 1; (i - 1) * (i - 1) < n; i++) {
				long val = n / i;
				if (dic.ContainsKey(val) == false) {
					dic[val] = 1;
				}

				if (i != 1) {
					dic[i - 1] = lastVal - val;
				}

				lastVal = val;
			}

			int m = dic.Count();
			var keys = dic.Keys.OrderBy(x => x).ToArray();

			var mul = new ModInt[m];
			var dp = new ModInt[k + 1, m];
			for (int i = 0; i < m; i++) {
				mul[i] = dic[keys[i]];
				dp[0, i] = 1;
			}

			for (int i = 0; i < k; i++) {
				for (int j = 0; j < m; j++) {
					if (j == 0) {
						dp[i + 1, j] += dp[i, m - 1 - j] * mul[m - 1 - j];
					} else {
						dp[i + 1, j] += dp[i + 1, j - 1] + dp[i, m - 1 - j] * mul[m - 1 - j];
					}
				}
			}

			ModInt ans = dp[k, m - 1];
			Console.WriteLine(ans);
		}
	}

	public struct ModInt
	{
		public static long Mod { get; set; } = (long)1e9 + 7;

		public static ModInt Pow(ModInt value, long k)
		{
			return Pow(value.Value, k);
		}

		public static ModInt Pow(long value, long k)
		{
			long ret = 1;
			for (k %= Mod - 1; k > 0; k >>= 1, value = value * value % Mod) {
				if ((k & 1) == 1) {
					ret = ret * value % Mod;
				}
			}
			return new ModInt(ret);
		}

		public static ModInt Inverse(ModInt value)
		{
			return Pow(value, Mod - 2);
		}

		public long Value;

		public ModInt(long value)
		{
			Value = value;
		}

		public static ModInt operator +(ModInt lhs, ModInt rhs)
		{
			lhs.Value += rhs.Value;
			if (lhs.Value >= Mod) {
				lhs.Value -= Mod;
			}
			return lhs;
		}

		public static ModInt operator -(ModInt lhs, ModInt rhs)
		{
			lhs.Value -= rhs.Value;
			if (lhs.Value < 0) {
				lhs.Value += Mod;
			}

			return lhs;
		}

		public static ModInt operator *(ModInt lhs, ModInt rhs)
		{
			return new ModInt(lhs.Value * rhs.Value % Mod);
		}
		public static ModInt operator /(ModInt lhs, ModInt rhs)
		{
			long exp = Mod - 2;
			while (exp > 0) {
				if (exp % 2 > 0) {
					lhs *= rhs;
				}

				rhs *= rhs;
				exp /= 2;
			}

			return lhs;
		}

		public static implicit operator ModInt(long n)
		{
			n %= Mod;
			if (n < 0) {
				n += Mod;
			}

			return new ModInt(n);
		}

		public override string ToString()
		{
			return Value.ToString();
		}
	}
}

Measured memory_bytes: 66272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll x[100010],y[100010];
char d[100010];

ll t[100],tcnt;
ll f[4][3];


int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld%lld %c",y+i,x+i,d+i);
	
	rep(i,0,4)rep(j,0,3)f[i][j]=-INF;

	rep(i,0,n){
		if(d[i]=='R')f[0][0]=max(f[0][0],y[i]);
		else if(d[i]=='L')f[0][1]=max(f[0][1],y[i]);
		else f[0][2]=max(f[0][2],y[i]);
		
		if(d[i]=='L')f[1][0]=max(f[1][0],-y[i]);
		else if(d[i]=='R')f[1][1]=max(f[1][1],-y[i]);
		else f[1][2]=max(f[1][2],-y[i]);

		if(d[i]=='U')f[2][0]=max(f[2][0],x[i]);
		else if(d[i]=='D')f[2][1]=max(f[2][1],x[i]);
		else f[2][2]=max(f[2][2],x[i]);
		
		if(d[i]=='D')f[3][0]=max(f[3][0],-x[i]);
		else if(d[i]=='U')f[3][1]=max(f[3][1],-x[i]);
		else f[3][2]=max(f[3][2],-x[i]);
	}
	
	double ans=INF;
	rep(t,0,400000010){
		double time=t/2.0;
		double a[4];
		rep(k,0,4)a[k]=max(f[k][0]+time,max(f[k][1]-time,f[k][2]));
		ans=min(ans,(a[0]+a[1])*(a[2]+a[3]));
	}
	printf("%.9f",ans);	
}

Measured memory_bytes: 1792
import sys
from itertools import accumulate
K = int(input())

MAX = 22
dp = [[0]*10 for _ in [0]*MAX]

for j in range(0, 10):
    dp[1][j] = 1

for i in range(2, MAX):
    for j in range(1, 9):
        dp[i][j] = dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1]
    dp[i][0] = dp[i-1][0] + dp[i-1][1]
    dp[i][9] = dp[i-1][8] + dp[i-1][9]

acc = [[] for _ in [0]*MAX]
for i in range(1, MAX):
    acc[i] = accumulate(dp[i])

# i桁で最大のルンルン数(99...9)は何番目か
num = [0]
for i in range(1, MAX):
    num.append(num[i-1] + sum(dp[i][1:]))


cnt = 0
for i, n in enumerate(num):
    if n < K:
        keta = i+1
        cnt = n
    else:
        break

ans = 0

rg = range(1, 10)
p = 1
for i in range(keta, 0, -1):
    for j in rg:
        if cnt + dp[i][j] < K:
            flg = True
            p = j+1
            cnt += dp[i][j]
        else:
            break

    ans += 10**(i-1)*p

    rg = range(max(0, p-1), min(10, p+2))
    p = max(0, p-1)

print(ans)


Measured memory_bytes: 3188