akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
const ll M = 1000000007;
 
vector<ll> fac(10000001); //n!(mod M)
vector<ll> ifac(10000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<10000001; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;
    ans += comb(H+W-2, H-1);
    rep(i, 0, B){
        ll mi = 1;
        mi *= comb(H-A-1+i,i);
        mi *= comb(W+A-i-2,A-1);
        mi %= M;
        ans -= mi;
        ans %= M;
    }
    if(ans < 0){
        ans = M - abs((ans%M));
    }
    prtl(ans);
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<vector<ll>> ans(H, vector<ll>(W, 0));
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      if ((i < B) && (j < A)) {
        ans.at(i).at(j) = 1;
      }
      if ((i >= B) && (j >= A)) {
        ans.at(i).at(j) = 1;
      }
    }
  }
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cout << ans.at(i).at(j);
    }
    cout << "\n";
  }
}


Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X;
  int tmp;
  for (int i = 0; i < M; i++) {
    cin >> tmp;
    X.push_back(tmp);
  }
  int ans = 0;
  if (N < M) {

    sort(X.begin(), X.end());
    vector<int> L;

    for(int i = 0; i < M-1; i++) L.push_back(X[i+1] - X[i]);

    sort(L.begin(), L.end(), greater<int>());

    int lsum = 0;
    for (int i = 0; i < N-1; i++) lsum += L[i];

    ans = X[M-1] - X[0]  - lsum;
  }

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

Measured memory_bytes: 1400
package main

import (
	"fmt"
)

func main() {
	var a, b, c int64
	fmt.Scanf("%d %d %d", &a, &b, &c)
	answer := compareSqrt(a, b, c)
	if answer {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func compareSqrt(a, b, c int64) bool {
	if c-a-b < 0 {
		return false
	}
	return 4*a*b < (c*c + a*a + b*b - 2*c*a - 2*c*b + 2*a*b)
}


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s, t; cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int cmp(long long int a,long long int b)
{
	if(b==0) return a;
	return cmp(b,a%b);
}
int main()
{
	long long int n;
	scanf("%lld",&n);
	long long int i,sum;
	long long int a[1000];a[1]=1;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sum=a[0]/cmp(a[0],a[1])*a[1];
	for(i=2;i<n;i++)
	{
		sum=sum/cmp(sum,a[i])*a[i];
	}
	if(n==1)
	printf("%lld\n",a[0]);
	else
	printf("%lld\n",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int>v, w;
	rep(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		int j(0);
		while (c) {
			int x(min(c, 1 << j++));
			c -= x;
			v.emplace_back(a*x);
			w.emplace_back(b*x);
		}
	}
	vector<int>dp(W + 1, 0);
	rep(i, 0, w.size())rrep(j, w[i], W + 1)
		chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, k, a, ss[200005], sum, ans;
vector<ll> v;
ll ft[200005];              // 1-index
ll ls(ll x){
	return (x & (-x));
}
// N means the largest possible index you need for the fenwick!! Refer to flowering for more.
void update(ll l, ll r, ll v){ // Updates from l to r inclusive
	r++;           // Update the difference at r+1 not r
	for(; l <= n; l += ls(l)) ft[l] += v;// Add v to the diff at l
	for(; r <= n; r += ls(r)) ft[r] -= v;// Minus v from diff at r+1
}
ll query(ll p){                     // Returns the element at p
	ll sum = 0;
	for(; p; p -= ls(p)) sum += ft[p];
	return sum; 
}

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, n) {
		cin >> a;
		sum += a;
		ss[i] = sum - i*k;
		v.pb(ss[i]);
	}
	sort(v.begin(), v.end());
	FOR(i, 1, n) {
		if (ss[i] >= 0) ans++;
		ss[i] = lower_bound(v.begin(), v.end(), ss[i]) - v.begin() + 1;
		ans += query(ss[i]);
		update(ss[i], n, 1);
	}
	cout << ans;
}

Measured memory_bytes: 5104
#B-FizzBuss Sum
N = int(input())
terms = list(range(1,N+1))
terms_fb = []
for n in terms:
    if n%3 ==0 and n%5 ==0:
        terms_fb.append('FizzBuzz')
    elif n%3 ==0:
        terms_fb.append('Fizz')
    elif n%5 ==0:
        terms_fb.append('Buss')
    else:
        terms_fb.append(n)
a =0
for c in terms_fb:
    if isinstance(c, int):
        a += c
print(a)


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

double sigma[200001];

int main(){
	sigma[0]=0;
	for(int i=1;i<=200000;i++){
		sigma[i]=(double)i;
		sigma[i]+=sigma[i-1];
	}

	int n,k;	cin>>n>>k;
	vector<double> P(n+1);	for(int i=1;i<=n;i++)cin>>P[i];
	P[0]=0;
	for(int i=1;i<=n;i++){
		int cnt=(int)P[i];
		P[i]=sigma[cnt]/P[i];
		P[i]+=P[i-1];
	}

	double ans=0;
	for(int i=k;i<=n;i++){
		double x=P[i]-P[i-k];
		ans=max(ans,x);
	}

	//cout<<ans<<endl;
	printf("%.8lf\n",ans);

	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int cnt = 0;
  string w, t;
  cin >> w >> t;
  while (t != "END_OF_TEXT") {
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    if (t == w) {
      cnt++;
    }
    cin >> t; 
  }
  cout << cnt << "\n";
  return 0;
}



Measured memory_bytes: 3208
#include <stdio.h>
int G = 1, n;
int c[101][101], d[101]={0};
int first[101], second[101];
void DFS(int u);
int main(){
  int i, j, k, u, v;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
c[i][j] = 0; }
}
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      c[u-1][v-1] = 1;
    }
}
  for(i = 0; i < n; i++){
    if(d[i] == 0){
DFS(i); }
}
  for(i = 0; i < n; i++){
    printf("%d %d %d\n", i+1, first[i], second[i]);
}
return 0; }
void DFS(int u){
  int v;
  first[u] = G++;
  d[u] = 1;
  for(v = 0; v < n; v++){
    if(c[u][v]==1 && d[v]==0){
      DFS(v);
} }
  second[u] = G++;
}



Measured memory_bytes: 2048
#include<stdio.h>

int main(){
    int a,b;
    scanf("%2d%2d",&a,&b);
    if((a<13)&&(a>0)){
        if((b>12)||(b==0)){
            printf("MMYY\n");
        }
        else{
            printf("AMBIGUOUS\n");
        }
    }
    else{
        if((b<13)&&(b>0)){
            printf("YYMM\n");
        }
        else{
            printf("NA\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
K, A, B = map(int, input().split())

efficiency = B - A
change_cnt = K - A + 1
if efficiency <= 2 or change_cnt < 2:
    print(1 + K)
else:
    if change_cnt % 2 ==0:
        print( int(change_cnt/2)*efficiency+A )
    else:
        print( int(change_cnt/2)*efficiency+A+1)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
	int a,b,c,f=0;
	cin>>a>>b>>c;
	int d[1000],e[1000];
	for(int i=0;i<a;i++){
		cin>>d[i]>>e[i];
		if(d[i]>=b&&e[i]>=c)
			f++;
	}
	cout<<f<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a - b, 0);
}


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

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
  string s;
  s += ch;
  return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second  
#define sz(x) ((int)x.size())


void solve() {
	ld r;
	cin >> r;
	cout << fixed << setprecision(10);
	cout << 2 * acos(-1) * r << endl;
}	

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0); 
  
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

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

int main(){
  long long n, k; cin >> n >> k;
  long long ans = 0;
  
  for(long long i = 1; i <= n; i++){
    ans += max((i - k) * (n/i), 0LL);
    ans += max(n - (n/i * i) - k + 1, 0LL);
  }
  
  if(k==0) ans = n * n;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll N;
    cin >> N;
    srep(n,1,3501){
        srep(h,1,3501){
            ll x = N*n*h;
            ll y = 4*n*h - N*h - N*n;
            if(y<=0)continue;
            if(y*3500<x)continue;
            if(x%y==0){
                cout << n << ' ' << h << ' ' << x/y << endl;
                return 0;
            }
        }
    }
    


    return 0;
}
 
 


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

int main(){
    string S;
    cin >> S;
    long long K;
    cin >> K;
    
    for(long long i=0;i<K;i++){
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << S[K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

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

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    std::sort(a.begin(), a.end());
    int x = 1;
    int y = 1;
    for (auto p : a) {
        if (x < p.first) {
            int d = p.first - 1 - x;
            x += d;
            y += d;
            if (y >= p.second) {
                cout << p.first - 1 << "\n";
                return 0;
            } else {
                x++;
                y = std::min(y + 1, p.second - 1);
            }
        }
    }
    cout << h << "\n";

    return 0;
} 

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

int calc(int num)
{
    int ret = 0;
    while(num)
    {
        num /= 10;
        ++ret;
    }
    return ret;
}

int main()
{
    int a,b;
    cin >> a >> b;
    int cnt = calc(b);
    while(cnt--)
        a = a*10;
    int num = a+b;
    int st = sqrt(num);
    if(st*st == num) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
a = gets.split.map(&:to_i)
odd = []
even = []
cnt = 0
(0..2).each do |i|
    a[i] % 2 == 0 ? even << i : odd << i   
end
if odd.length == 2
    a[odd[0]] += 1
    a[odd[1]] += 1
    cnt += 1
elsif even.length == 2
    a[even[0]] += 1
    a[even[1]] += 1
    cnt += 1
end


a.sort!
cnt += (a[2] - a[0]) / 2 
cnt += (a[2] - a[1]) / 2
puts cnt


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

int N,M;
int ans=0;
int maxm=0;

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    if(a>=N)continue;
    ans+=(N-a);
    maxm=max(maxm,N-a);    
  }
  cout<<ans-maxm<<endl;
  return 0;
}

Measured memory_bytes: 3112
function main(input) {
  var a = input[0].split(" ")[0]-0;
  var b = input[0].split(" ")[1]-0;
 
  var ans = 0;
  var num = 1;
  while(num<b){
    ans++;
    num+=a-1;
  }
  console.log(ans);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))

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

int main() {
    int n;
    cin >> n;
    
    int cnt = 0;
    bool ok = false;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a == b) {
            cnt++;
            if (cnt >= 3) ok = true;
        } else {
            cnt = 0;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main (String [] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int k = sc.nextInt() - 1;
		int trees [] = new int [N];
		for (int i = 0; i < N; i++) 
			trees[i] = sc.nextInt();
		
		Arrays.sort(trees);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < N - k; i++) 
			min = Math.min(min, trees[i + k] - trees[i]);
		System.out.println(min);
	}
}


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

#define Max(a,b) max({a,b})
#define Min(a,b) min({a,b})
#define rep(i,m,n) for(int (i)=(m);(i)<(int)(n);(i)++)
#define len(n) n.size()
#define print(n) cout << (n) << endl;


// s.substr(i,n)

typedef long long ll;

using namespace std;

//char a = 65;
long long int inf = 1000000007;
int n,m,a,b,c,d,cou,co;
long long int lla,llb,llc;
double k;
const ll LINF = 1e18;
char num = 65;
string s,t;
int lis[20];
/*
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
*/

int main(){
    
    cin >> a >> b >> c >> d;

    print(max(0,min(b,d)-max(a,c)))

    return 0;
}

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

int main(){
	int n, ans = 0, tmp;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++){
		cin >> tmp;
		ans += tmp;
	}
	vector<int> c(n - 1);
	for(int i = 0; i < n - 1; i++) cin >> c[i];
	//cout << ans << ' ' << c[0] << ' ' << c[1] << endl;
	for(int i = 0; i < n - 1; i++){
		if(a[i] + 1 == a[i + 1]){
			ans += c[a[i] - 1];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;
    std::cout << ((x>=r && x<=w-r && y>=r && y<=h-r)?"Yes\n":"No\n");
    return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    ll n;

    cin >> n;

    ll a[n+1];


    int zero = 0;



    for(int i=0; i<n; i++)
    {


        cin >> a[i];

        if(a[i]==0)
        {
            zero = 1;
        }
    }

    if(zero)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(a,a+n);

    ull sum = 1;

    ull sum1 = 1000000000000000000;



    for(int i=n-1; i>=0; i--)
    {
        if(a[i]<=sum1/sum)
        {
            sum *= a[i];
        }
        else{
            cout<< -1 << endl;
            return 0;
        }
    }

    cout << sum << endl;







    return 0;
}


Measured memory_bytes: 4400
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 2050;
int N;
long long x, a[MAX_N];

int best_base[MAX_N][MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> x;

    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    long long ret = 0;
    for (int i = 0; i < N; i++) {
        best_base[0][i] = i;
        ret += a[i];
    }

    for (int mn = 1; mn < N; mn++) {
        for (int i = 0; i < N; i++) {
            int prev = (i - 1 + N) % N;
            if (a[best_base[mn-1][prev]] < a[best_base[mn-1][i]]) {
                best_base[mn][i] = best_base[mn-1][prev];
            } else {
                best_base[mn][i] = best_base[mn-1][i];
            }
        }
        long long tmp = x * mn;
        for (int i = 0; i < N; i++) {
            tmp += a[best_base[mn][i]];
        }
        ret = std::min(ret, tmp);
    }

    std::cout << ret << std::endl;

    return 0;
}



Measured memory_bytes: 16640
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
count = 0
for i in range(n):
    if i + a[i] < n:
        b[i + a[i]] += 1
    if i - a[i] >= 0:
        count += b[i-a[i]]
print(count)

Measured memory_bytes: 92956
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, a, b = sc.nextLong()
    val max = a + (n - 1) * b
    val min = a * (n - 1) + b
    println(math.max(max - min + 1, 0))
  }

}


Measured memory_bytes: 25548
#include<iostream>
#include<stdio.h>



using namespace std;


int main(){



int a,b,n,k=0,i;


cin>>n>>a>>b;




for(i=a;i<=b;i++){


    if(i%n==0){

        k=1;

        cout<<"OK"<<endl;

        break;

    }





}

if(k==0&&i-1==b){


    cout<<"NG"<<endl;


}









return 0;
}


Measured memory_bytes: 3552
N = int(input())
a = list(map(int, input().split()))

t = [0] * 8
over = 0
for x in a:
    if x >= 3200:
        over += 1
    else:
        t[x // 400] = 1
print(*[max(sum(t), 0 if over == 0 else 1), sum(t) + over])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int cnt[13],d[51];
int main(){
    int n;
    cin>>n;
    cnt[0]=1;
    FOR(i,1,n+1){
        cin>>d[i];
        ++cnt[d[i]];
    }
    if(cnt[0]>=2||cnt[12]>=2){
        cout<<0<<endl;
        return 0;
    }
    rep(i,13){
        if(cnt[i]>=3){
            cout<<0<<endl;
            return 0;
        }
    }
    int ans=0;
    rep(i,(1<<11)){
        int mn=12;
        vector<int> v;
        v.pb(0);
        if(cnt[12]==1) v.pb(12);
        FOR(j,1,12){
            if(cnt[j]==2){
                v.pb(j);v.pb(24-j);
            }
            if(cnt[j]==1){
                if(1&(i>>(j-1))){
                    v.pb(24-j);
                }
                else v.pb(j);
            }
        }
        for(auto it1:v)for(auto it2:v){
            if(it1==it2) continue;
            int sub=min(abs(it1-it2),24-abs(it1-it2));
            mn=min(sub,mn);
        }
        ans=max(ans,mn);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX (500000)
#define SENTINEL (2000000000)
int cnt;
int L[MAX/2+2],R[MAX/2+2];

void merge(int A[],int n,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }else{
            A[k]=R[j];
            j++;
        }
    }
}

void mergesort(int A[],int n,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(A,n,left,mid);
        mergesort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int main(void){
    int A[MAX],n,i;
    cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);
    mergesort(A,n,0,n);
    for(i=0;i<n;i++){
        if(i)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 7092
#include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[10];
	int i, j, k;
	int n;
	int ans;
	
	scanf("%d", &n);
	
	while(n){
		
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
			
			tube2[i] = 0;
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				tube1[j + 1] = tubeM[i];
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

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

int main() {
    long long l,r;
    cin>>l>>r;
    long long min=2020;
    for(long long i=l;i<r;i++) {
        for(long long j=r;j>l;j--) {
            int cur=(i*j)%2019;
            if(cur<=min) min=cur;
            if(min==0) {
                cout<<0;
                return 0;
            }
        }
    }
    cout<<min;
    return 0;
}
// [l,r]

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    abc080c()
}

fun abc080c() {
    val n = readLine()!!.toInt()
    val fList = (1..n).map { readLine()!!.split(" ").map { it[0] == '1' }.toBooleanArray() }.toTypedArray()
    val pList = (1..n).map { readLine()!!.split(' ').map { it.toLong() }.toLongArray() }.toTypedArray()

    var answer = Long.MIN_VALUE / 10

    for (i in 1L until (1 shl 10)) {
        val bitSet = BitSet.valueOf(longArrayOf(i))

        val sum = fList.mapIndexed { index, f ->
            val count = f.withIndex().count { it.value && bitSet[it.index] }
            pList[index][count]
        }.sum()

        answer = Math.max(answer, sum)
    }

    println(answer)
}


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

namespace AtCoderBeginnerContest098
{
    class QA
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
        }
    }
}


Measured memory_bytes: 13140
#include "iostream"
#include "vector"
#include "cmath"
#include "map"

using namespace std;
typedef long long ll;

#include <vector>

const int N = 1000100;
vector<bool> isp(N, true);
void sieve()
{
  isp[0] = false;
  isp[1] = false;
  for (auto i = 0; i <= N; i++)
  {
    if (isp[i])
    {
      for (auto j = 2; i * j <= N; j++)
        isp[i * j] = false;
    }
  }
}

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

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

  map<ll, ll> f;

  ll cnt = 0;
  ll nn = n;
  for (auto i = 0; i < N; i++)
  {
    if (!isp[i])
      continue;

    while (nn % i == 0)
    {
      nn /= i;
      f[i]++;
    }
  }

  if (nn != 1)
  {
    f[nn] += 1;
  }

  for (auto x : f)
  {
    ll rest = x.second;
    for (auto i = 1; rest > 0; i++)
    {
      rest -= i;
      if (rest >= 0)
      {
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3348
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a<=b&&b<=c){
cout <<a<<" "<<b<<" "<<c<<endl;
}else if(a<=c&&c<=b)
cout <<a<<" "<<c<<" "<<b<<endl;
else if(b<=a&&a<=c)
cout <<b<<" "<<a<<!" "<<c<<endl;
else if(b<=c&&c<=a)
cout <<b<<" "<<c<<" "<<a<<endl;
else if(c<=a&&a<=b)
cout <<c <<" "<<a<<" "<<b<<endl;
else if(c<=b&&b<=a)
cout <<c<<" "<<b<<" "<<a<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> p(n);
	RBF(pi, p) {
		cin >> pi;
	}

	int pmin = INF, ans = 0;
	RBF(pi, p) {
		if (pi <= pmin) {
			ans++;
		}
		pmin = min(pmin, pi);
	}

	col(ans);
	return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, root=1;
int A[MAXN];
vector<int> G[MAXN];

int dfs(int node, int par){
	if (G[node].size()==1) return A[node];
	int res=2*A[node], mx=0;
	for (int v:G[node]) if (v!=par){
		int tmp=dfs(v, node);
		mx=max(mx, tmp);
		res-=tmp;
		if (res<0){
			cout<<"NO\n";
			exit(0);
		}
	}
	mx=max(mx, res);
	if (mx>A[node]){
		cout<<"NO\n";
		exit(0);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i];
	if (n==2) kill((A[1]==A[2]?"YES":"NO"))
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	while (G[root].size()==1) root++;
	if (dfs(root, 0)) cout<<"NO\n";
	else cout<<"YES\n";
	
	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	int a; string s; cin >> a >> s;
	if(a>=3200) cout << s << endl;
	else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;


int main() {
    int L;
    cin >> L;
    int N = 0;//頂点
    int pow = 1;
    while (pow <= L) pow *= 2, ++N;
    int M = (N-1)*2 + __builtin_popcount(L)-1;
    cout<<N<<" "<<M<<endl;
    REP(i,N-1){
        cout<<i+1<<" "<<i+2<<" "<<0<<endl;
        cout<<i+1<<" "<<i+2<<" "<<(1<<i)<<endl;
    }
    int cur = 1<<(N-1);//N-1からN
    for(int i = N-2;i >= 0;i--){
        if(L&(1<<i)){
            //Lのi bit目が立っているか
            cout<<i+1<<" "<<N<<" "<<cur<<endl;
            cur += (1<<i);
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if (a < b) {
	printf("a < b\n");
	}
	else if (a > b) {
	printf("a > b\n");
	}
	else {
	printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
print(readLine().map { line in 
    let l = line.split(separator: " ").compactMap { Int($0) }
    let (a, b, c, d) = (l[0], l[1], l[2], l[3])
    let left = max(a, c)
    let right = min(b, d)

    return max(0, right - left)
}!)

Measured memory_bytes: 8192
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N):
    B[i] = A[i]-i-1
B.sort()
med = B[N//2]
loss = 0
for i in range(N):
    loss += abs(B[i]-med)
print(loss)


Measured memory_bytes: 26836
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,=I()
l=I()
dp=[0]*(n)
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
	dp[i]=min(dp[i-2]+abs(l[i-2]-l[i]),dp[i-1]+abs(l[i-1]-l[i]))

print(dp[-1])

Measured memory_bytes: 13596
n=int(input())
Ai=list(map(int,input().split()))
Bi=list(map(int,input().split()))

ans=0
for i in range(n):
    b=Bi[i]
    if i<n-1:
        if Ai[i]>=b:
            ans+=b
        else:
            ans+=Ai[i]
            b-=Ai[i]
            if Ai[i+1]>=b:
                ans+=b
                Ai[i+1]-=b
            else:
                ans+=Ai[i+1]
                Ai[i+1]=0
    else:
        ans+=min(Ai[i]+Ai[i+1], b)


print(ans)

Measured memory_bytes: 18476
S = ["","",""]

S[0] = input()  # S_A
S[1] = input()  # S_B
S[2] = input()  # S_C

turn = 0
nextturn = 0

while len(S[turn]) > 0:
    if S[turn][:1] == "a":
        S[turn] = S[turn][1:]
        turn = 0
    elif S[turn][:1] == "b":
        S[turn] = S[turn][1:]
        turn = 1
    else:
        S[turn] = S[turn][1:]
        turn = 2

if turn == 0:
    print("A")
elif turn == 1:
    print("B")
else:
    print("C")


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

int stricmp(char* ch1,char* ch2){
	int ch1_length = 0,ch2_length = 0,div;
	for(int i = 0; ch1[i] != '\0';i++) ch1_length++;
	for(int i = 0; ch2[i] != '\0';i++) ch2_length++;
	if(ch1_length != ch2_length) return -1;
	for(int i = 0; ch2[i] != '\0';i++)
	{
		div = ch1[i] -ch2[i];
		if(div != 0 && div != 32 && div != -32)
			return -1;
	}
	return 0;
}

int main(){
	char W[11],T[1001];
	int count = 0;
	scanf("%s",W);
	while(true){
		scanf("%s",T);
		if(strcmp("END_OF_TEXT",T) == 0) break;
		if(stricmp(T, W) == 0) count++;
	}
	printf("%d\n",count);
	
	return 0;
}



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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int R,G,B;

int main()
{
	cin >> R >> G >> B;
	if((G * 10 + B) % 4 == 0){
		puts("YES");
	}
	else{
		puts("NO");
	}

	return 0;
}


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

const int mx = 1000 * 1000;
int x;
bool ch[1000 * 1000];
vector <int> v;

int main() {
	cin >> x;
	for (int i = 2; i < mx; i++) {
		if(ch[i]) continue;
		for (int j = 2 * i; j < mx; j += i) ch[j] = 1;
		v.push_back(i);
	}
	cout << *lower_bound(v.begin(), v.end(), x);
	return 0;
}


Measured memory_bytes: 1916
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 8 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n;

    cin>>n;

    vi v(n);
    iv(v);
    int counter = 0;
    for(int i=1; i<n-1;++i){
        if(v[i]<v[i+1] and v[i]>v[i-1])
            ++counter;
        else if(v[i]>v[i+1] and v[i]<v[i-1])
            ++counter;
    }
    cout<<counter<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

string s;
long k;

int main()
{
  cin >> s;
  cin >> k;

  int p = 0;
  while (s[p] == '1') p++;
  if (k <= p) printf("1\n");
  else printf("%c\n", s[p]);
  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#define mp(a, b) make_pair(a, b)

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}

ostream & operator << (ostream &out, pii a) {
    cout << a.first << " " << a.second ;
    return out;
}

void smain();

signed main() {

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void out(bool flag) {
    cout << (flag ? "Yes" : "No");
    exit(0);
}

void smain() {

    string s;
    cin >> s;
    map<char, int> cnt;
    for (auto c : s) {
        cnt[c]++;
    }
    if (cnt['N'] && !cnt['S'])
        out(false);
    if (cnt['S'] && !cnt['N'])
        out(false);
    if (cnt['W'] && !cnt['E'])
        out (false);

    if (cnt['E'] && !cnt['W'])
        out (false);
    out(true);
}

Measured memory_bytes: 764
import math
n=int(input())
m=[]
ds=[]

for i in range(n):
    m.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i+1,n):
        ds.append(math.sqrt((m[i][0]-m[j][0])**2+(m[i][1]-m[j][1])**2))
ps=math.factorial(n)
x=(n-1)*math.factorial(n)/len(ds)
print(sum(ds)*(n-1)/len(ds))

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	long long x,y;
	cin >> x >> y;
	
	int ans = 0;
	while (x <= y)
	{
		++ans;
		x *= 2LL;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256