akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  double N;
  cin>>N;
  print(N*PI*2);
  return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int A[200005];
int B[200005];
int c[200005];
int n,a,b,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>A[i]>>B[i];
	}
	for(int i=0;i<m;i++){
		if(A[i]==1) c[B[i]]=1;
	}
	bool ans=0;
	for(int i=0;i<m;i++){
		if(B[i]==n&&c[A[i]]==1) ans=1;
		if(ans) break;
	}
	if(!ans) cout<<"IM";
	cout<<"POSSIBLE";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int n;
    while (true)
    {
        cin >> n;
        if (n == 0)
            break;

        vector<int> a;
        rep(i, 26) a.push_back(0);
        vector<char> kuso;
        rep(i, n)
        {
            char hoge;
            cin >> hoge;
            kuso.push_back(hoge);
        }
        bool flag = false;
        //cout << "n is " << n << endl;
        int nokori = n;
        rep(i, n)
        {
            nokori--;
            a[(int)(kuso[i] - 'A')]++;
            int ichiban = 0, niban = 0;
            char ichibannoyatu = 'A';
            rep(j, 26)
            {
                if (ichiban < a[j])
                {
                    ichibannoyatu = 'A' + j;
                    ichiban = a[j];
                }
            }
            rep(j, 26)
            {
                if (j != ichibannoyatu - 'A' && a[j] > niban)
                {
                    niban = a[j];
                }
            }
            if (ichiban > niban + nokori)
            {

                cout << ichibannoyatu << " " << i + 1 << endl;
                flag = true;
                break;
            }
        }
        if (flag != true)
            cout << "TIE" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>
int main(void){
        int hum[4][3][10] = {};
        int i,j,k,n;
        int b,f,r,v;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d %d %d %d",&b,&f,&r,&v);
                hum[b-1][f-1][r-1] += v;
        }

        for(i=0;i<4;i++){
                for(j=0;j<3;j++){
                        for(k=0;k<10;k++)
                                printf(" %d",hum[i][j][k]);
                        puts("");
                }
                if(i<3)
                        puts("####################");
        }

        return 0;

}


Measured memory_bytes: 2080
n=input()
list=list(map(int,input().split()))

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)


Measured memory_bytes: 21580
#include<iostream>
using namespace std;
int n,i,j,a[26],c[26];
string s;
int main(){
	cin>>n;
	for(i=0;i<26;i++)a[i]=50;
	for(i=0;i<n;i++){
		cin>>s;
		for(auto x:s)c[x-'a']++;
		for(j=0;j<26;c[j++]=0)a[j]=min(a[j],c[j]);
	}
	for(i=0;i<26;i++)while(a[i]--)cout<<(char)('a'+i);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define v vector
#define vi vector< int >
#define vpi vector< pair< int,int > >
#define forl(a) for(int i = 0;i < a;i ++)
using namespace std;
ll modF=1e7;

void solve(){
	string s;
	string t;
	cin>>s>>t;
	int l=s.length();
	int ans=0;
	forl(l){
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<"\n";
}

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

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, M, ans;
    scanf("%d %d", &N, &M);
    vector<int> s(M), c(M);
    REP(int,i,0,M){
        scanf("%d %d", &s.at(i), &c.at(i));
    }
    int MaxNum = pow(10,N);
    int MinNum = pow(10,N-1);
    if ( N == 1 ) MinNum = 0;
    ans = -1;
    REP(int,i,MinNum,MaxNum){
        string NumChar = to_string(i);
        bool fg = true;
        REP(int,j,0,M){
            if ( NumChar.at(s.at(j)-1) - '0' != c.at(j) ){
                fg = false;
            }
        }
        if ( fg ){
                cout << i << endl; return 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
x,a,b = list(map(int,input().split(" ")))
#string = input()

if a >= b:
  print("delicious")
elif x >= b - a:
  print("safe")
else:
  print("dangerous")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    int ans = 0;
    for(int i = 0; i < 5; i++){
        int n;
        cin >> n;
        if(n == 0){
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int A,B;
  cin >> A >> B;

  int count=0;
  for (int i = A; i < B+1; i++) {
    string X,Y;
    X=to_string(i);
    Y=to_string(i);
    reverse(Y.begin(), Y.end());
    if (X==Y) count+=1;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
template <class T>
using vector = std::vector<T>;
template <class T, u64 N>
using array = std::array<T, N>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    std::string s;
    cin >> s;
    bool flag = true;
    for (u32 i = 0; i < s.size(); i++)
    {
        if (i % 2 != 0)
        {
            if (s[i] == 'R') { flag = false; }
        }
        if (i % 2 == 0)
        {
            if (s[i] == 'L') { flag = false; }
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){


	lli r;
	cin>>r;

	cout<<3*r*r<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll num=0;
	while(true){
		if(a%2==1||b%2==1||c%2==1){
			cout<<num;return 0;
		}
		if(a==b&&b==c){
			cout<<-1;return 0;
		}
		++num;
		ll x,y,z;
		x=(b/2+c/2);y=(a/2+c/2);z=(a/2+b/2);
		a=x;b=y;c=z;
	}
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  long long int N1,N2,i,a[100000],cnt2=0,cnt4=0,ans=0,other=0;
  char y[]="Yes",n[]="No";
  scanf("%lld",&N1);
  for(i=0;i<N1;i++){
    scanf("%lld",&a[i]);
  }
  N2=N1;
  for(i=0;i<N1;i++){
    if(a[i]%4==0){
      cnt4++;
      //N2-=3;
      }else if(a[i]%2==0){
      cnt2++;
        }else other++;
    }
  ans = cnt4 * 2;
  if(cnt2!=0)other++;
  if(cnt4+1>=other){
    printf("%s\n",y);
  }else{
    printf("%s\n",n);
    }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
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);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"YES":"NO");
}
int main() {
  string a,b;cin>>a>>b;
  reverse(all(b));
  cout << btos(a==b)<<endl;
  return 0;
}


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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 200000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int types[MAXN+5];
vector<int> adj[MAXN+5];
int degrees[MAXN+5][2];
bool valid[MAXN+5], visited[MAXN+5];



int32_t main()
{
    #ifdef DEBUG
    //freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n,m;
    cin >> n >> m;
    string s; 
    cin >> s;
    for0(i,n) 
        types[i] = s[i] == 'A';
    ms(degrees,0);
    
    for0(i,m) {
        int u,v;
        read(u); read(v);
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
        degrees[u][types[v]]++;
        degrees[v][types[u]]++;
    }
    
    ms(valid,true);
    ms(visited,false);
    queue<int> q;
    for (int i=0; i<n; i++) {
        if (not visited[i] and valid[i] and (degrees[i][0] == 0 or degrees[i][1] == 0)) {
            visited[i] = true;
            valid[i] = false;
            q.push(i);     
            
            while (not q.empty()) {
                int top = q.front();
                q.pop();
                for (int x : adj[top]) {
                    if (not visited[x] and valid[x]) {
                        degrees[x][types[top]]--;
                        if (degrees[x][types[top]] == 0) {
                            visited[x] = true;
                            valid[x] = false;
                            q.push(x);
                        }
                    }
                }
            }
        }
    }
    printa(valid,n);
    
    for0(i,n) {
        if (valid[i]) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 16772
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int work[n][3];
    for(int i =0; i< n; i++){
        for(int j =0; j < 3; j++){
            cin >> work[i][j];
        }
    }
    int dp[n+1][3];
    for(int i=0; i < 3; i++){
        dp[0][i] = work[0][i];
    }
    for(int i =1 ; i < n; i++){
        int x, y;
        for(int j =0; j < 3; j++){
            if(j == 0){
                x = 1;
                y = 2;
            }
            else if(j == 1){
                x = 0;
                y = 2;
            }
            else{
                x = 0;
                y = 1;
            }
            dp[i][j] = work[i][j] + max(dp[i-1][x], dp[i-1][y]);
        }
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<"\n";
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(llong P){
    int i=0;
    for(int j=0;j<k;j++){
        llong s=0;
        while(s+T[i]<=P){
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left=0, right=100000*10000, mid;
    while(right-left>1){
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    return right;
}

main(){
 cin>>n>>k;
 for(int i=0;i<n;i++) cin>>T[i];
 llong ans=solve();
 cout<<ans<<endl;
}


Measured memory_bytes: 3880
#include <stdio.h>
#include <stdlib.h>

int n;
int A[200000];

inline void swap(int *a, int *b){
  int z;
  z = *a;
  *a = *b;
  *b = z;
}

int kth(int *A, int n, int k){
  int ll, rr;
  ll = 0;
  rr = n;
  while(1){
    int i, l, r, pivot;
/*
    if(A[n/2] > A[0])    swap(A+n/2, A);
    if(A[n/2] > A[n-1])  swap(A+n/2, A+n-1);
    if(A[0] > A[n-1])    swap(A, A+n-1);
*/
    swap(A+ll, A+(ll+rr)/2);
    pivot = A[ll];
    l = ll;
    r = rr;
    i = ll+1;
    while(i < r){
      if(A[i] < pivot) swap(A+l++, A+i++);
      else if(A[i] > pivot) swap(A+--r, A+i);
      else i++;
    } 
    if(k < l) rr = l;
    else if(k >= r) ll = r;
    else return pivot;
  }
}

int main(){
  int i, m;
  long long int r;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", A+i);
    A[i] -= i+1;
  }
  m = kth(A, n, n/2);
  r = 0;
  for(i=0;i<n;i++) r += abs(A[i] - m);
  printf("%lld\n", r);
  return 0;
}


Measured memory_bytes: 896
// 2020 0404 161 A
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;

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

    cout << Z << " " << X << " " << Y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, mx, a[105];

void f(ll p) {
	ll i, s, b[105];
	if(p==n+1) {
		s = 0;
		for(i=1; i<=n; i++) s += a[i];
		mx = max(mx, s);
		return;
	}
	if(a[p]<0) {
		for(i=1; i<=n; i++) b[i] = a[i];
		for(i=p; i<=n; i+=p) a[i] = 0;
		f(p+1);
		for(i=1; i<=n; i++) a[i] = b[i];
	}
	f(p+1);
}

int main() {
	ll i, j, s;
	cin>>n;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=n; i>n/3; i--) {
		s = 0;
		for(j=i; j<=n; j+=i) s += a[j];
		if(s<0) for(j=i; j<=n; j+=i) a[j] = 0;
	}
	f(1);
	cout<<mx;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
char s[N];
int n;
void input()
{
	scanf("%s",s+1);
	n=strlen(s+1);
}
ll ans;
void work()
{
	int num=0;
	For(i,1,n)
	{
		if(s[i]=='B')num++;
		else ans+=num;
	}
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int N,C[86400*2];

int main()
{
	scanf ("%d",&N);
	int t = 0; while (N--){
		int a,b; scanf ("%d %d",&a,&b);
		t = (t + a) % 86400;
		C[t]++;
		t = (t + b) % 86400;
	}

	for (int i=0;i<86400;i++) C[i+86400] = C[i];
	for (int j=1;j<86400*2;j++) C[j] += C[j-1];

	int ans = 0;
	for (int j=10800+1;j<86400*2;j++){
		int now = C[j] - C[j-10800-1];
		if (ans < now)
			ans = now;
	}
	printf ("%d\n",ans);

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#define FAST_IO                  \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<vl> vvl;


int main()
{

    FAST_IO

    ll n;
    cin >> n;
    vl v(n + 1, 0), dp(n, 0);
    for (ll i = 0; i < n; i++)
        cin >> v[i];

    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    dp[2] = abs(v[2] - v[0]);
    for (ll i = 2; i < n; i++)
    {
        dp[i] = min(abs(v[i] - v[i - 1]) + dp[i - 1], abs(v[i] - v[i - 2]) + dp[i - 2]);
        // cost += v[i + 1];
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

void printArray(int A[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
}

void insertionSort(int A[], int N) {
    int i, j, v;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        printArray(A, N);
    }
}

int main(void) {
    int i;
    int N; // 入力数
    int A[100]; // ソートする配列
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", A + i);
    printArray(A, N);
    insertionSort(A, N);
    return 0;
}



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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int ns = (int)s.size();
  int nt = (int)t.size();
  vector<char> sc(ns), tc(nt);
  for (int i = 0; i < ns; i++) {
    sc[i] = s[i];
  }
  for (int i = 0; i < nt; i++) {
    tc[i] = t[i];
  }
  sort(sc.begin(), sc.end());
  sort(tc.begin(), tc.end(), greater<int>());
  string u, v;
  for (int i = 0; i < ns; i++) {
    u += sc[i];
  }
  for (int i = 0; i < nt; i++) {
    v += tc[i];
  }
  if (u < v) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3628
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline T read(T &a){
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    return a = x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 

const int maxn = 2e5 + 20;
int n;
int a[maxn];
int tong[1000001];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++) {
		if (a[i] == a[i - 1] && i != 1) {
			tong[a[i]] ++; continue;
		}
		int res = a[i];
		while (res <= 1e6) {
			tong[res]++;
			res += a[i];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (tong[a[i]] == 1) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8320
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main(void){
	int n = 0;
	char str1[100] = { 0 };
	char str2[100] = { 0 };
	int point1 = 0;
	int point2 = 0;
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", str1);
		scanf("%s", str2);
		if (strcmp(str1, str2) > 0) {
			point1 += 3;
		}
		else if(strcmp(str1, str2) < 0){
			point2 += 3;
		}
		else{
			point1++;
			point2++;
		}
		memset(str1, '\0', 100);
		memset(str2, '\0', 100);
	}

	printf("%d %d\n", point1, point2);

	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int ans=1e7;
    for(int i=0;i<n;i++) cin >> w[i];
    for(int t=0;t<n;t++){
        int s1=0,s2=0;
        for(int i=0;i<n;i++){
            if(i<=t) s1+=w[i];
            else s2+=w[i];
        }
        ans=min(ans,abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main(){
    let N: usize = getvec()[0];
    let mut ans = (0, 0, 0);
    for h in 1..3501 {
        for n in 1..3501 {
            let numerator = N * h * n;
            let denominator = (4*h*n) as i64 - (N*h) as i64 - (N*n) as i64;
            if denominator > 0 && numerator % denominator  as usize== 0 {
                ans = (n, h, numerator / denominator as usize);
                break;
            }
        }
    }
    println!("{} {} {}", ans.0, ans.1, ans.2);
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec<T: std::str::FromStr>() -> Vec<T>{
    let line = getline();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;

    int maxmatch = -1;
    for(int i=0; i<=s.length() - t.length(); i++)
    {
        int match = 0;
        for(int j=0; j< t.length(); j++)
            if(s[i+j] == t[j])
                match++;
        if(match > maxmatch)
            maxmatch= match;
    }

    cout<<t.length() - maxmatch<<endl;
    return 0;
}

Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
a.sort()
wro = 0
if n % 2 == 0:
    for i in range(n):
        if a[i] != 2*((i//2)+1)-1:
            wro += 1
            break
else:
    for i in range(n):
        if a[i] != 2*((i+1)//2):
            wro += 1
            break
if wro == 1:
    print(0)
else:
    print(2**(n//2)%(10**9+7))

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x) cerr << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cerr << a << " "; cerr << endl;
#define debug3(x) rep(i, sizeof(x)) cerr << x[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

struct output {
    int a1, a2, a3, a4;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<bool> odd[h];
    vector<pii> turn;

    rep(i, h) {
        vector<pii> turn_sub;

        rep(j, w) {
            turn_sub.push_back(MP(i, j));
            int a;
            cin >> a;
            odd[i].push_back(a % 2 == 1);
        }
        if (i % 2 == 1) reverse(all(turn_sub));
        turn.insert(turn.end(), all(turn_sub));
    }

    bool have_coin = false;
    vector<output> ans;
    int cnt = 0;

    rep(t, turn.size()) {
        int i = turn[t].first, j = turn[t].second;
        int bi, bj;
        if (t != 0) bi = turn[t - 1].first, bj = turn[t - 1].second;
        if (have_coin) {
            ans.push_back({bi + 1, bj + 1, i + 1, j + 1});
            cnt++;

        }
        if (odd[i][j]) have_coin ^= 1;
    }
    cout << cnt << endl;
    for (auto p : ans) {
        printf("%d %d %d %d\n", p.a1, p.a2, p.a3, p.a4);
    }

    return 0;
}



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

int main() {

string S;
cin >>S;
bool a=true;
for(int i=0;i<S.size();i++){
if((i+1)%2==0){
if(S.at(i)=='L'||S.at(i)=='U'||S.at(i)=='D'){
a=true;}else{a=false;break;}
}else if((i+1)%2==1){
if(S.at(i)=='R'||S.at(i)=='U'||S.at(i)=='D'){
a=true;
}else{a=false;break;
}
}}

if(a){cout << "Yes" <<endl;}
else if(!a){cout<<"No"<<endl;}


}


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

int main(void)
{
    ll n,ans=0;
    cin >> n;

    rep1(i,n){
        ll y=n/i;
        ans+=y*(y+1)*i/2;
    }

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


Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long L = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        DPfunction D = new DPfunction(L,N,int.Parse(str[0]));
        for(int i=1;i<N;i++){
            sb.Append(D.Get()/L+"\n");
            str = Console.ReadLine().Split(' ');
            D.Set(int.Parse(str[0]),int.Parse(str[1]));
        }
        sb.Append(D.Get()/L+"\n");
    }
    class DPfunction{
        double L;
        double TS;
        double VS;
        int p,q;
        double[] T;
        double[] V;
        public DPfunction(long L0,int N,long t){
            L = L0;
            TS = 0;
            VS = 0;
            T = new double[N+1];
            V = new double[N+1];
            p = N-1;
            q = N;
            T[N] = t*L;
            V[N] = L;
        }
        public double Get(){
            return T[q]+TS;
        }
        public void Set(long t,long v){
            while(V[q-1] + VS + v > L){
                q--;
            }
            T[q] = ((V[q] - L + VS + v)*T[q-1] + (L - VS - v - V[q-1])*T[q])/(V[q] - V[q-1]);
            V[q] = L - VS - v;
            TS += t*v;
            VS += v;
            p--;
            while(p+1 < q){
                if(((V[p+2] - V[p+1])*(-TS) + (V[p+1] + VS)*(T[p+2]))/(V[p+2] + VS) > T[p+1]){
                    p++;
                }
                else{
                    break;
                }
            }
            T[p] = -TS;
            V[p] = -VS;
        }
    }
}

Measured memory_bytes: 64648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int a;cin>>a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3624
import sys

s = sys.stdin.readline().strip()

q = int(sys.stdin.readline().strip())

class Node:
    def __init__(self, c):
        self.prev = None
        self.next = None
        self.c = c
s = list(s)

head = Node(s[0])
tail = None
prev = head
for i in range(1, len(s)):
    crt = Node(s[i])
    prev.next = crt
    crt.prev = prev
    prev = crt
tail = prev

order = 0
for _ in range(q):
    l = sys.stdin.readline().strip()
    if l[0] == "1":
        order = (order + 1) %2
    else:
        t, f, c = l.split()
        n = Node(c)
        if (f == "1" and order == 0) or ( f== "2" and order==1):
            # add to head
            n.next = head
            head.prev = n
            head = n
        else:
            # add to tail
            tail.next = n
            n.prev = tail
            tail = n
if order == 0:
    crt = head
    while crt != None:
        print(crt.c, end="")
        crt = crt.next
else:
    crt = tail
    while crt != None:
        print(crt.c, end="")
        crt = crt.prev
print("")

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

int main() {
  int n;
  cin >> n;
  set<string> st;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    st.insert(s);
  }

  int cnt = st.size();
  if (cnt == 3) {
    puts("Three");
  } else {
    puts("Four");
  }

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>

using namespace std;

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

	int cnt = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1)
			cnt++;
	}

	if (cnt >= k) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
heightToTemp :: Double -> Double -> Double
heightToTemp t h = t - h * 0.006

makeValueList :: Double -> Double -> [Double] -> [Double]
makeValueList a t xs = map (abs . ((-) a) . (heightToTemp t)) xs

minIndex :: Integer -> [Double] -> (Integer, Double)
minIndex i (x:[]) = (i, x)
minIndex i (x:xs)
  | x < minval = (i, x)
  | otherwise = (mini, minval)
  where
    (mini, minval) = minIndex (i + 1) xs

main :: IO()
main = do
   _ <- getLine
   [t, a] <- map read . words <$> getLine
   heights <- map read . words <$> getLine
   let values = makeValueList a t heights
   putStrLn . show . fst $ (minIndex 1 values)


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
const int maxn = 100010;
int N, K;
int A[maxn];

template <unsigned Mod> struct Modular {
  using M = Modular;
  unsigned v;
  Modular(long long a = 0) : v((a %= Mod) < 0 ? a + Mod : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod) v -= Mod; return *this; }
  M& operator-=(M r) { if ((v += Mod - r.v) >= Mod) v -= Mod; return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod; return *this; }
  M& operator/=(M r) { return *this *= mdpow(r, Mod - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend M mdpow(M b, unsigned exp) {
    Modular res(1);
    while(exp) {
      if (exp & 1) {
        res *= b;
        if ((res.v += Mod) >= Mod) res.v -= Mod;
      }
      b *= b;
      exp >>= 1;
    }
    return res;
  }
};

constexpr long long mod = 1e9 + 7;
using Mint = Modular<mod>;

vector<Mint> fact, inv_fact, minv;
void prep(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = 1 / fact[n];
  // cout << inv_fact[n].v << endl;
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}

Mint binom(int n, int k) {
  if (k < 0 || k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}

int main() {
  fastio;
  cin >> N >> K;
  prep(N);
  // rep(i, N) cout << inv_fact[i].v << endl;
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  sort(A, A + N);
  Mint res(0);
  Mint choose;

  for (int i = 0; i < N; i++) {
    choose = binom(i, K-1);
    Mint val(A[i]);
    res += (val * choose);
  }

  for (int i = 0; i < N; i++) {
    Mint val(A[i]);
    choose = binom(N - i - 1, K-1);
    res -= (val * choose);
  }
  cout << res.v << endl;
}


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

long long Ans;
long long K,A,B;

int main() {

	cin>>K>>A>>B;
	if(A>=B) cout<<1+K<<endl;
	else {
	  Ans=1+K;
	  K-=(A-1);
	  cout<<max(Ans,A+(B-A)*(K>>1)+(K&1))<<endl;
	}	  
	return 0;
}

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

int main() {
int H,J,D,U,T=0;
  cin >> H >> J >> D >> U;
  for (int i=0; i<H; i++){
  if (i<J){
  T += D;}
  else{
    T+=U;}
  }
  cout << T << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;

int main(int argc,char const* argv[])
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int tmp=0;
  int ans=1000000;
  ans=min(ans,abs(a[0]-a[1])+abs(a[1]-a[2]));
  ans=min(ans,abs(a[0]-a[2])+abs(a[2]-a[1]));
  ans=min(ans,abs(a[1]-a[0])+abs(a[0]-a[2]));
  ans=min(ans,abs(a[1]-a[2])+abs(a[2]-a[0]));
  ans=min(ans,abs(a[2]-a[0])+abs(a[0]-a[1]));
  ans=min(ans,abs(a[2]-a[1])+abs(a[1]-a[0]));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

template<typename T>
T extgcd(T a, T b, T &x ,T &y){
    for (T u = y = 1, v = x = 0; a; ) {
        ll q = b/a;
        swap(x -= q*u, u);
        swap(y -= q*v, v);
        swap(b -= q*a, a);
    }
    return b;
}

template<typename T>
T mod_inv(T x, T m){
    T s, t;
    extgcd(x, m, s, t);
    return (m+s)% m;
}

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

int main() {
    int n; string s;
    cin >> n >> s;
    int k = s.size();
    auto dp = make_v(n+1, n+1, 0LL);
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= n; ++j) {
            (dp[i+1][max(j-1, 0)] += dp[i][j]) %= MOD;
            (dp[i+1][j+1] += dp[i][j]*2) %= MOD;
        }
    }
    cout << (dp[n][k]*mod_inv(pow_(2, k, MOD), MOD)) % MOD << "\n";
    return 0;
}


Measured memory_bytes: 195840
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  s=a+(b-a)/3;u,t=s+(s-a)*(1+3**.5*1j)/2,b-(b-a)/3
  p+=[a,s,u,t]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5924
#include <bits/stdc++.h> 
using namespace std; 
//#define endl "\n";
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double d,s,t;
    cin>>d>>t>>s;
    double ans=(d/s);
    //cout<<ans<<endl;
    if(ans<=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
  // input
  int A, B;  cin >> A >> B;
  
  // grid
  int h, ha, hb;
  ha = (A - 1) / 50 + 1;
  hb = (B - 1) / 50 + 1;
  h = ha + hb;
  vector<char> grid(h * 100, '.');
  for (int i = 0; i < ha * 100; i++) {
    grid.at(i) = '#';
  }
  
  // paint
  for (int i = 0; i < (A - 1) * 2; i += 2) {
    grid.at(i) = '.';
  }
  for (int i = h * 100 - 1; i > h * 100 - (B - 1) * 2 - 1; i -= 2) {
    grid.at(i) = '#';
  }
  
  // output
  cout << h * 2 << " " << 100 << endl;
  for (int i = 0; i < h * 100; i++) {
    if (i != 0 && i <= ha * 100 && i % 100 == 0) {
      for (int j = 0; j < 100; j++) cout << "#";
      cout << endl;
    }
    if (i >= ha * 100 && i % 100 == 0) {
      for (int j = 0; j < 100; j++) cout << ".";
      cout << endl;
    }
    cout << grid.at(i);
    if ((i + 1) % 100 == 0) {
      cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=5e5+5;
int n,p[N],d[N],f[N];
int main()
{
	n=read(),p[0]=read();
	fo(i,1,n) d[i]=read(),p[i]=min(p[i-1],abs(p[i-1]-d[i]));
	fd(i,n,1)
	{
		f[i]=f[i+1];
		if(d[i]<=2*f[i+1]+1) f[i]=max(f[i],f[i+1]+d[i]);
	}
	for(int q=read();q;q--)
	{
		int x=read();
		puts(p[x-1]>f[x+1]?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 7680
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 1000000007;

int n,a[100005];

int main(){
	cin >> n; rep(i,n) cin >> a[i];
	sort(a,a+n);
	cout << a[n/2]-a[n/2-1] << endl;
}

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

int main() {
   int n;
   cin >> n;
   int ans = n % 1000;
   if (ans == 0){
       cout << 0 << endl;
   } else {
       cout << 1000 - ans << endl;
   }
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int K;
    cin >> K;
    if (K % 2 == 1)
    {
        cout << (K / 2) * (1 + (K / 2));
    }
    else
    {
        cout << (K / 2) * (K / 2);
    }
    return 0;
}


Measured memory_bytes: 256
//from PKU1125
#define M 1001
double dist[M][M],d;
next[M][M],x[M],y[M];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.1?d:999;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>998)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

Measured memory_bytes: 5112
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

A,B,C,D,E,F = map(int, input().split())

water = []
for a in range(30):
    for b in range(30):
        w = 100*A*a + 100*B*b
        if w == 0: continue
        if w <= F: water.append(w)
        else: break

sugar = []
for c in range(3000):
    for d in range(3000):
        s = c*C + d*D
        if s <= F: sugar.append(s)
        else: break

d = 0
anss = 0
answ = 100*A
for w in water:
    for s in sugar:
        if w+s > F or w*E < 100*s:
            continue
        tmpd = (100*s)/(w+s)
        if tmpd > d:
            d = tmpd
            anss = s
            answ = w

print(anss+answ, anss)

Measured memory_bytes: 21808
S = input()

easy = True

for i in range(0, len(S)):
    if (i + 1) % 2 == 0:
        if S[i] == "R":
            easy = False
            break
    else:
        if S[i] == "L":
            easy = False
            break

if easy:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//abc163_d.cpp
//Sun Apr 19 20:58:07 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	ll n,k;
	cin >> n >> k;

	ll ans = 0;
	for (ll i=k;i<=n+1;i++){
		ll min = ((i-1)*i/2)%MOD;
		ll max = (2*n-i+1)*i/2%MOD;

//		cout << i << " " << min << " "<< max << endl;
		ll tmp = (max-min+1+MOD)%MOD;
		ans = (ans + tmp)%MOD;
	}




	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3632
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val lArray = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var ans = 0
    for (i in 0 until lArray.size - 2){
        for(j in i + 1 until lArray.size - 1){
            val array = lArray.subList(j + 1, lArray.size)
            val min = lArray[j] - lArray[i]
            val max = lArray[j] + lArray[i]
            ans += lowerBound(array, max) - lowerBound(array, min)
        }
    }
    println(ans)
}

fun lowerBound(list: List<Int>, value: Int): Int{
    var low = 0
    var high = list.size
    while(low < high){
        val mid = (low + high) / 2
        if(value <= list[mid]){
            high = mid
        }else{
            low = mid + 1
        }
    }
    return low
}

Measured memory_bytes: 40684