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

using namespace std;

int main()
{
    int n;
    cin>>n;
    float x;
    string y;
     float a=0.0000000;
     float b=380000.0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if(y=="BTC")
            a+=x*b;
        else
            a+=x;
    }
cout<<a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A <= 0 && B >= 0) printf("Zero\n");
	else if (A > 0) printf("Positive\n");
	else if ((A - B) % 2) printf("Positive\n");
	else printf("Negative\n");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define long long long

struct TEdge { int v, id; };

const int N = 1e5 + 2;

int n;
vector<TEdge> g[N];
long s[N], weight[N], remain;

int Dfs(int u, int p)
{
    int sze = 1;
    for (auto e: g[u])
    {
        int v = e.v, id = e.id;
        if (v == p) continue;
        int sub = Dfs(v, u);
        sze += sub;
        if (sub * 2 != n)
        {
            weight[id] = abs(s[u] - s[v]) / abs(n - sub * 2);
            remain -= weight[id] * sub;
        }
        else
            weight[id] = -sub;
    }
    return sze;
}

void Solve()
{
    remain = s[1];
    Dfs(1, 0);
    for (int i = 0; i < n - 1; ++i)
    {
        if (weight[i] < 0) weight[i] = remain / -weight[i];
        printf("%lld\n", weight[i]);
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back({v, i});
        g[v].push_back({u, i});
    }
    for (int i = 1; i <= n; ++i) scanf("%lld", &s[i]);
    Solve();
    return 0;
}


Measured memory_bytes: 15616
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int max = Math.max(Math.max(a, b), c);
    if ((max == a+b || max == b+c || max == c+a)) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

int main() {
    char x, y;
    cin >> x >> y;
    if(x > y) cout << ">" << endl;
    else if(x < y) cout << "<" << endl;
    else cout << "=" << endl;
}

Measured memory_bytes: 256
k = int(input())
L = [1,2,3,4,5,6,7,8,9]
i = 0
while i < k:
    if int(str(L[i])[-1]) == 0:
        n2 = L[i]*10 + L[i]%10
        n3 = L[i]*10 + L[i]%10 +1
        L.append(n2)
        L.append(n3)
    elif 1 <= int(str(L[i])[-1]) <= 8:
        n1 = L[i]*10 + L[i]%10 -1
        n2 = L[i]*10 + L[i]%10
        n3 = L[i]*10 + L[i]%10 +1
        L.append(n1)
        L.append(n2)
        L.append(n3)
    elif int(str(L[i])[-1]) == 9:
        n1 = L[i]*10 + L[i]%10 -1
        n2 = L[i]*10 + L[i]%10
        L.append(n1)
        L.append(n2)
    i +=1

print(L[k-1])


Measured memory_bytes: 15820
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	ll x;
	cin >> x;


	ll sum=0;
	ll minutes = 0;
	while (sum < x) {
		minutes++;
		sum += minutes;
	}

	cout << minutes << endl;

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    long double A,B,H,M;

    cin >> A >> B >> H >> M;

    long double Arad,Brad;

    Arad = ((H*60+M)*0.5);
//    cout << Arad << endl;
    while(1){
        if(Arad-360 < 0) break;
        Arad = Arad - 360;
    }

//    cout << Arad << endl;

    Brad = M*6;

//    cout << Brad << endl;

    long double rad;

    rad = cos(abs(Arad*M_PI/180 - Brad*M_PI/180));
    
//    cout << rad << endl;

    cout << fixed << setprecision(10) << sqrt(A*A+B*B-2*A*B*rad) << endl;

}

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

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

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

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

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


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  
  priority_queue<pll> q1;
  rep(i,n){
    ll a; cin>>a;
    q1.emplace(a,1);
  }
  
  priority_queue<pll> q2;
  rep(i,m){
    ll b,c; cin>>b>>c;
    q2.emplace(c,b);
  }
  
  ll pos=n;
  ll ans=0;
  while(pos>0){
    pll p1=q1.top(), p2;
    if(q2.size()>0) p2=q2.top();
    else p2={0,0};
    
    if(p1.first>=p2.first){
      q1.pop();
      ans+=p1.first*p1.second;
      pos-=p1.second;
    }else{
      q2.pop();
      ans+=p2.first*min(p2.second,pos);
      pos-=p2.second;
    }
  }
  cout<<ans<<endl;
  
}

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


int main(){
    int n;cin>>n;
    set<string>s;
    forn(i,n){
        string x;cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50


LL C[53][53];
int nck(){
    CLR(C);
    REP(i,53)C[i][0]=1;
    FOR(n,1,53){
        FOR(k,1,n+1){
            C[n][k]=C[n-1][k]+C[n-1][k-1];
        }
    }
    return 0;
}
int main(){
    nck();
    int N,A,B;
    cin>>N>>A>>B;
    LL v[52];
    REP(i,N)cin>>v[i];
    sort(v,v+N,greater<LL>());
    if(v[0]==v[A-1]){
        cout<<v[0]<<endl;
        LL cnt=0;
        int num=0;
        REP(i,N)if(v[i]==v[0])num++;
        FOR(i,A,min(B+1,num+1)){
            cnt+=C[num][i];
        }
        cout<<cnt<<endl;
        return 0;
    }
    double res=0;
    int samein=0,sameout=0;
    REP(i,N){
        if(i<A){
            res+=v[i];
            if(v[i]==v[A-1])samein++;
        }else if(v[i]==v[A-1]){
            sameout++;
        }
    }
    cout<<fixed<<setprecision(6)<<res/A<<endl;
    
    cout<<C[samein+sameout][samein]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n;
  cin >> n;
  string s;
  vector<string> t,u;
  rep(i,n){
    cin >> s;
    t.push_back(s);
    u.push_back(s);
  }
  rep(i,n){
    rep(j,n-1){
      if(t.at(j).at(1) > t.at(j+1).at(1)){
        swap(t.at(j),t.at(j+1));
      }
    }
  }
  rep(i,n){
    cout << t.at(i);
    if(i == n-1) break;
    cout << " ";
  }
  cout << endl << "Stable" << endl;
  rep(i,n){
    int mini = u.at(i).at(1);
    int num = i;
    for(int j = i; j < n; j++){
      if(mini > u.at(j).at(1)){
        mini = u.at(j).at(1);
        num = j;
      }
    }
    if(u.at(num).at(1) < u.at(i).at(1)){
      swap(u.at(num), u.at(i));
    }
  }
  rep(i,n){
      cout << u.at(i);
      if(i == n-1) break;
      cout << " ";
  }
  cout << endl;
  if( t == u) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

}


Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        stack = []
        while self.parent_or_size[a] >= 0:
            stack.append(a)
            a = self.parent_or_size[a]
        for i in stack:
            self.parent_or_size[i] = a
        return a

n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


Measured memory_bytes: 75904
#include<cstdio>
#include<cmath>

using namespace std;


int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    long int ans = 0;
    if(k % 2 == 0){

        long int num1 = 0;
        long int num2 = 0;
        for(int i = 1; i <= n; i++){
            if (i % k == 0) {
                num1++;
            }else if (i % k == k / 2){
                num2++;
            }
        }
        ans = pow(num1, 3) + pow(num2, 3);
    }else{
        long int num1 = 0;
        for(int i = 1; i <= n; i++){
            if (i % k == 0) {
                num1++;
            }
        }
        ans = pow(num1, 3);
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 512
d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]

for k, v in sorted(d.items(), key=lambda x: x[0]):
    print(k)
    print(*sorted(v))



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

//復習
const ll MAX = 4000010;
const ll MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
 
 
void COMinit() {
 fac[0] = fac[1] = 1;
 finv[0] = finv[1] = 1;
 inv[1] = 1;
  for (ll i = 2; i < MAX; i++){
  fac[i] = fac[i - 1] * i % MOD;
  inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
        }
      }
 
   long long COM(ll n, ll k){
  if (n < k){ return 0;}
  if (n < 0 || k < 0) {return 0;}
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
     }
 


signed main(void){
  
  int N,A,B,K; cin >> N >> A >> B >> K;
  COMinit();
  
  int ans = 0;
  
  for(int x = 0; x <= N; x++){ 
    int y;
    if( (K-A*x)% B == 0 ){ y = (K-A*x)/B;}
    else{ continue;}
    
    ans += COM(N,x)*COM(N,y);
    
    ans %= MOD;
    
  }

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

Measured memory_bytes: 93952
#include<stdio.h>
int main(void){
	int A,B,ans=0;
	scanf("%d %d",&A,&B);
	if(A%3==0){
		ans=1;
	}else if(B%3==0){
		ans=1;
	}else if((A+B)%3==0){
		ans=1;
	}
	if(ans==0){
		printf("Impossible\n");
	}else if(ans==1){
		printf("Possible\n");
	}
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

int M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if (M1!=M2) {
		ce(1)
	}
	else {
		ce(0)
	}
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  const ll MAXW = 10000;
  vector<ll> dp(MAXW+1, -1); dp[0] = 0;

  ll N, W; cin >> N >> W;
  rep(i, N) {
    ll vi, wi; cin >> vi >> wi;
    for (ll j = 0; j + wi <= W; j++) {
      if (dp[j] != -1) {
        dp[j+wi] = max(dp[j+wi], dp[j] + vi);
      }
    }
  }
  ll ans = 0;
  rep(i, W+1) ans = max(ans, dp[i]);
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int a,b;
    cin>>a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)cout<<"Alice"<<endl;
    if(a==b)cout<<"Draw"<<endl;
    if(a<b)cout<<"Bob"<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
  *  Worg
  */
#include <cstdio>
#include <vector>
#include <algorithm>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

int main() {
  int n, m; scanf("%d%d", &n, &m);
  int other = 100 * (n - m), ans = 0;

  ans = (1900 * m + other) * (1 << m);
  printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
n,x = [],[]

while True:
    a,b = map(int,input().split())
    if a==0 and b==0:
        break
    n.append(a)
    x.append(b)

for i in range(len(n)):
    cnt = 0
    for i2 in range(1,n[i]+1):
        for i3 in range(1,n[i]+1):
            if i2 >= i3:
                continue
            for i4 in range(n[i]+1):
                if i3 >= i4:
                    continue
                y = x[i] - (i2+i3+i4)
                
                if y==0:
                    cnt +=1
                    break

    print(cnt)


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

int main(){
	char a[N][N];
	char s[N];
	int h,w;
	cin >> h >> w;

	for(int i=0;i<h;i++){
		cin >> s;
		for(int j=0;j<w;j++){
			a[i][j] = s[j]; 
		}
	}


	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){

			int bom = 0;
			if(a[i][j] == '.'){
				for(int m=-1;m<2;m++){
					for(int n=-1;n<2;n++){
						if(i+m<0 || i+m > h-1);
						else if(j+n<0 || j+n > w-1);
						else if (a[i+m][j+n] == '#'){
							++bom;
						}

					}
				}
				a[i][j] = '0' + bom; 
			}
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

 //int dp[1001][1001];
 /*
vector < int > tree(400005);

void buildtree (vector < int > v,int node,int start,int fin)
  {
      if(start==fin)
      {
          tree[node]=v[start];
          return;
      }
      int mid=(start+fin)/2;
      buildtree(v,2*node,start,mid);
      buildtree(v,2*node+1,mid+1,fin);
      tree[node]=tree[2*node]+tree[2*node+1];
  }

 int sum (int node,int tl,int tr,int l , int r)
   {
       if(l>r) return 0;
       if(l==tl and r==tr) return tree[node];
       int mid=(tl+tr)/2;
       return sum(2*node,tl,mid,l,min(r,mid))+sum(2*node+1,mid+1,tr,max(l,mid+1),r);
   }

  void update(int node,int tl , int tr,int pos,int val)
    {
        if(tl==tr) {tree[node]=val; return;}
        int mid=(tl+tr)/2;
        if(pos<=mid)
              update(2*node,tl,mid,pos,val);
        else
            update(2*node+1,mid+1,tr,pos,val);
        tree[node]=tree[2*node]+tree[2*node+1];

    }
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}
*/


void solve()
{
    ll int i,j=0,r=200,p,q,k,d,y=0,h,flag=1,n,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l;
   cin>>n;
   vi v(n),vp(n);
   rep(i,0,n-1) cin>>v[i];
   vp[0]=v[0]; y=vp[0];
   rep(i,1,n)
   {
       vp[i]=min(v[i],v[i-1]);
       if(i==n-1) vp[i]=v[n-2];
       y+=vp[i];
   }
   cout<<y;

}


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


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int N,M,S;
vector<pair<int,pair<int,int> > >G[50];
long dist[50][6000];
int C[50],D[50];
main()
{
	cin>>N>>M>>S;
	for(int i=0;i<M;i++)
	{
		int u,v,a,b;cin>>u>>v>>a>>b;
		u--,v--;
		G[u].push_back(make_pair(v,make_pair(a,b)));
		G[v].push_back(make_pair(u,make_pair(a,b)));
	}
	for(int i=0;i<N;i++)cin>>C[i]>>D[i];
	for(int i=0;i<N;i++)for(int j=0;j<6000;j++)dist[i][j]=4e18;
	dist[0][min(S,5999)]=0;
	priority_queue<pair<long,pair<int,int> > >P;
	P.push(make_pair(0,make_pair(0,min(S,5999))));
	while(!P.empty())
	{
		int u=P.top().second.first;
		int rest=P.top().second.second;
		long c=-P.top().first;
		P.pop();
		if(dist[u][rest]<c)continue;
		{
			int nr=min(rest+C[u],5999);
			long nc=c+D[u];
			if(dist[u][nr]>nc)
			{
				dist[u][nr]=nc;
				P.push(make_pair(-nc,make_pair(u,nr)));
			}
		}
		for(pair<int,pair<int,int> >e:G[u])
		{
			int v=e.first;
			int nr=rest-e.second.first;
			long nc=c+e.second.second;
			if(nr<0)continue;
			if(dist[v][nr]>nc)
			{
				dist[v][nr]=nc;
				P.push(make_pair(-nc,make_pair(v,nr)));
			}
		}
	}
	for(int t=1;t<N;t++)
	{
		long ans=4e18;
		for(int i=0;i<6000;i++)ans=min(ans,dist[t][i]);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 9728
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if N == 0:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


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

const int N = 1000000;
bool haming[N + 1];

int main(){
    int m, n;
    fill(haming, haming + N, false);
    for(int i = 1;i <= N;++i){
        int t = i;
        while((t & 1) != 1) t >>= 1;
        while(t % 3 == 0) t /= 3;
        while(t % 5 == 0) t /= 5;
        if(t == 1) haming[i] = true;
    }
    while(cin >> m, m){
        int c = 0;
        cin >> n;
        for(int i = m; i <= n;++i){
            if(haming[i]) ++c;
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 2136
import string
data = {}
while True:
    try:
        in_str = raw_input()
        for c in in_str:
            if c.isalpha() == False or c.lower() < 'a' and 'z' < c.lower():
                continue
            if c.lower() in data:
                data[c.lower()] += 1
            else:
                data[c.lower()] = 1
    except(EOFError):
        break
for c in string.lowercase[:26]:
    if c in data:
        print c + ' : ' + str(data[c])
    else:
        print c + ' : 0'

Measured memory_bytes: 6524
#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;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	int res=0;
	sort(p.rbegin(), p.rend());
	p[0] /= 2;
	rep(i,n){
		res += p[i];
	}
	cout << res << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	int n;cin >> n;
    vector<double> a(n);REP(i,n)cin >> a[i];
    double s=0;
    VSORT(a);

    FOR(i,1,n){
        a[i]=(a[i-1]+a[i])/2;
    }
    cout << a[n-1] << endl;

}


Measured memory_bytes: 256
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    S = str(input())
    return (S,)


def solve(S):
    if len(S) < 4:
        return "No"
    if "".join(S[0:4]) == "YAKI":
        return "Yes"
    else:
        return "No"


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define ff first
#define ss second

void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    freopen((name+".in").c_str(), "r", stdin); // see Input & Output
    freopen((name+".out").c_str(), "w", stdout);
}
// the code that we provide requires everything above this line to compile

int main() {
    //setIO("shuffle");
    int a, b, c;cin>>a>>b>>c;
    int k;cin>>k;
    while(b <= a && k){
    	b*=2;
    	--k;
    }
    if(b <= a){
    	cout<<"No\n";
    	return 0;
    }
    while(c <= b && k){
    	c*=2;
    	--k;
    }
    if(c <= b){
    	cout<<"No\n";
    	return 0;
    }
    cout<<"Yes\n";
    return 0;
}

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

int main()
{
    int n, cl;
    int last = 0;
    cin >> n >> cl;
    int s[100005], t[100005], c[100005];
    int table[30][100005] {0};
    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
        table[c[i]][s[i]] = 1;
        if(table[c[i]][t[i]] == 0) table[c[i]][t[i]] = -1;
        last = max(last, t[i]);
    }

    for(int i = 0; i < cl; i++){
        bool f = false;
        for(int j = 0; j <= last; j++){
            if(table[i][j] == 1){
                f = true;
                table[i][j - 1] = 1;
            }
            if(table[i][j] == -1){
                f = false;
            }
            if(f) table[i][j] = 1;
            else table[i][j] = 0;
        }
    }
    int ans = 0;
    for(int j = 0; j < last; j++){
        int sum = 0;
        for(int i = 0; i < cl; i++){
            sum += table[i][j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	int x;
	cin >> x;
	if(x >= 400 and x <= 599) cout << 8;
	else if(x >= 600 and x <= 799) cout << 7;
	else if(x >= 800 and x <= 999) cout << 6;
	else if(x >= 1000 and x <= 1199) cout <<5;
	else if(x >= 1200 and x <= 1399) cout << 4;
	else if(x >= 1400 and x <= 1599) cout << 3;
	else if(x >= 1600 and x <= 1799) cout << 2;
	else cout << 1;
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main(void) {
	int x1, x2, x3, x4, x5;
	scanf("%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5);
	if (x1 == 0) {
		printf("1\n");
	}
	else if (x2 == 0) {
		printf("2\n");
	}
	else if (x3 == 0) {
		printf("3\n");
	}
	else if (x4 == 0) {
		printf("4\n");
	}
	else if (x5 == 0) {
		printf("5\n");
	}
	return 0;
}

Measured memory_bytes: 1656
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;

ll dp[60];
ll num(int n) {
	if (dp[n])return dp[n];
	if (n == 0) {
		dp[n] = 1;
		return 1;
	}
	dp[n] = 2 * num(n - 1) + 3;
	return dp[n];
}

ll pate[60];
ll get_pate(int n){
	if (pate[n])return pate[n];
	if (n == 0) {
		pate[n] = 1;
		return 1;
	}
	pate[n] = get_pate(n - 1) * 2 + 1;
	return pate[n];
}

ll calc(int n,int x) {
	if (x <= 0) return 0;
	if (n == 0) {
		return 1;
	}
	x--;
	ll res = 0;
	if (x >= num(n-1)) {
		res += get_pate(n - 1);
		x -= num(n - 1);
		if (x > 0) {
			x--;
			res++;
		}
		res += calc(n - 1, x);
		return res;
	}
	else {
		return calc(n - 1, x);
	}
}

void solve() {
	int n, x; cin >> n >> x;
	print(calc(n, x));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	auto N=in(),A=in(),B=in();
	vll V=vecin(N);
	sort(ALL(V),greater<ll>());
	
	map<ll,ll> C;
	REP(i,N){
		C[V[i]]++;
	}

	ll maxS=0,maxN=1;
	vll L;
	FOR(i,A,B+1){
		ll S = accumulate(V.begin(),V.begin()+i,0ll);
		if(i*maxS<S*maxN){
			L.clear();
			maxS = S;
			maxN = i;
			L.push_back(i);
		}
		else if(i*maxS==S*maxN){
			L.push_back(i);
		}
	}

	out(maxS/(double)maxN);

	vvll comb(51,vll(51,0));
	comb[0][0]=1;
	REP(i,50){
		REP(j,50){
			comb[i+1][j]+=comb[i][j];
			comb[i+1][j+1]+=comb[i][j];
		}
	}
	ll S=0;
 	for(auto& x:L){
		ll X=x,index=0;
		while(X){
			if(C[V[index]]>=X){
				S += comb[C[V[index]]][X];
				X=0;
			}
			else{
				X -= C[V[index]];
			}
			index++;
		}
	}
	out(S);
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e5+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int a[N];
int n,k;
bool check(int x)
{
    int res=0;
    for(int i=1;i<=n;++i)
    {
        res+=(a[i]-1)/x;
    }
    return res<=k;
}
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    cin>>n>>k;
    rep1(i,n) cin>>a[i];
    int l=0,r=1e9,ans;
    while(l+1<r)
    {
        int mid=(l+r)/2;
        if(check(mid)) r=mid;
        else l=mid;
    }
    cout<<r<<endl;
    return 0;
}



Measured memory_bytes: 4308
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
point = 0
win = [0 for i in range(len(t))]

for i in range(len(t)):
  if t[i] == 'r':
    if (t[i-k] != 'r') or (win[i-k] != 1):
      point += p
      win[i] = 1

  if t[i] == 's':
    if (t[i-k] != 's') or (win[i-k] != 1):
      point += r
      win[i] = 1
    
  if t[i] == 'p':
    if (t[i-k] != 'p') or (win[i-k] != 1):
      point += s
      win[i] = 1

print(point)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define Int int64_t
using namespace std;
const Int MAXN=(Int)(1e7+5);
vector<Int> spf(MAXN);

void sieve() 
{ 
    spf[1] = 1; 
    for (Int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (Int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (Int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (Int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  

Int getFactorization(Int x) 
{ 
   Int ans=1;Int firsts=x;
    while (x > 1) 
    { 
        Int c=0;
        Int t=x;
        while(x%spf[t]==0){
            x/=spf[x];
            ++c;
        }
        
        ans*=(c+1);
        
    }

    ans*=firsts;
    return ans; 
} 
Int N;

int main()
{
    cin>>N;
    sieve();
    //cout<<getFactorization(4)<<" ";
    Int ans=0;
    
    for(Int i=1;i<=N;++i){
        ans+=getFactorization(i);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 81188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
using namespace std;
const int N=18;
int n,xval[1<<N][2];

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

void apl(int x[2],int v){
	if(x[0]<v) swap(x[0],v);
	if(x[1]<v) swap(x[1],v);
}

int main(){
	n=nxi();
	for(int i=0; i<1<<n; ++i){
		xval[i][0]=nxi();
	}
	for(int i=1; i<1<<n; i<<=1){
		for(int j=0; j<1<<n; j+=i<<1){
			for(int k=0; k<i; ++k){
				apl(xval[j+k+i],xval[j+k][0]);
				apl(xval[j+k+i],xval[j+k][1]);
			}
		}
	}
	int res=0;
	for(int i=1; i<1<<n; ++i){
		apx(res,xval[i][0]+xval[i][1]);
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 5780
import java.util.*;
public class Main{
    public static void main(String[]args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int n, m;
    String[] id;
    String s;
    boolean open; // true なら開いている

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    id = new String[n];
	    open = false;
	    for(int i=0; i<n; i++)
		id[i] = sc.next();
	    m = sc.nextInt();
	    solve();
	}
    }

    void solve(){
	while(m>0){
	    m--;
	    s = sc.next();
	    if(check()){
		if(open){
		    System.out.println("Closed by "+s);
		    open = false;
		}
		else {
		    System.out.println("Opened by "+s);
		    open = true;
		}
	    }
	    else System.out.println("Unknown "+s);
	}
    }

    boolean check(){
	boolean know = false;
	for(int i=0; i<id.length; i++)
	    if(s.equals(id[i])) know = true;
	return know;
    }
}

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

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int d=in.nextInt();
            int[][] points=new int[n][2];
            for(int i=0;i<n;i++){
                for(int j=0;j<2;j++)
                points[i][j]=in.nextInt();
            }
            int count=0;
            for(int i=0;i<n;i++){
                double squaredDistance=Math.pow(points[i][0], 2)+Math.pow(points[i][1], 2);
                double distance=  Math.sqrt(squaredDistance);
                if(distance<=d) count++;
            }
           out.println(count);
        }
    }
}
                
                

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

int main(){
    ll n;
    cin >> n;
    vector <ll> num(62,0);
    vector <ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        rep(j,62){
            if((a[i]>>j)&1==1){
                ++num[j];
            }
        }
    }

    
    unsigned long long ans;
    ans=0;
    ll ni,sa,sb;
    ni=1;
    rep(j,62){
        sa=(num[j]*(n-num[j]))%1000000007;
        
        ans+=ni*sa;
        ans=ans%(1000000007);
        ni=(ni*2)%1000000007;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    int OK=0;
    int OK2=0;
    for(int i=0;i<S.size();i++){
       if(S[i]=='C')
         OK=1;
         if(OK&&S[i]=='F')
            {
                OK2=1;
                break;
            }
    }
    if(OK2)
    cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

odds = 0
devens = 0
for a in A:
    if a % 2 == 1:
        odds += 1
    elif (a // 2) % 2 == 0:
        devens += 1

if devens >= odds:
    print('Yes')
elif devens == odds - 1 and devens + odds == N:
    print('Yes')
else:
    print('No')




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

using namespace std;

//#define MD 100010

int main(){
    vector<int> v(3);
    int cnt_go=0,cnt_na=0;
    for(int i=0;i<3;i++){
        cin>>v[i];
        if(v[i]==5){
            cnt_go++;
        }else if(v[i]==7){
            cnt_na++;
        }            
    }
    
    if(cnt_go==2 && cnt_na==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var l, r int
	fmt.Fscan(read, &l, &r)

	if r-l >= 2019 {
		fmt.Fprintln(write, 0)
	} else {
		ans := 2019
		var val int
		for i := l; i <= r; i++ {
			for j := i + 1; j <= r; j++ {
				val = (i * j) % 2019
				if ans > val {
					ans = val
				}
			}
		}
		fmt.Fprintln(write, ans)
	}

}


Measured memory_bytes: 640