akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<pair<int, int> > v(n + 1);
  v[0] = make_pair(0, 0);
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'W') v[i] = make_pair(v[i - 1].first, v[i - 1].second + 1);
    else v[i] = make_pair(v[i - 1].first + 1, v[i - 1].second);
  }
  int ans = INF;
  for (int i = 1; i <= n; i++) {
    // cout << "E: " << v[i].first << " / W: " << v[i].second << endl;
    ans = min(ans, v[i - 1].second + (v[n].first - v[i].first));
  }
  P(ans);


  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, res = 0; cin >> N;
  string S; cin >> S;
  vector<ll> R(N+1), G(N+1), B(N+1);

  R[0] = 0;
  G[0] = 0;
  B[0] = 0;
  REP(i, N) {
    R[i+1] = R[i] + (S[i] == 'R');
    G[i+1] = G[i] + (S[i] == 'G');
    B[i+1] = B[i] + (S[i] == 'B');
  }

  REP(i, N-2)
    RNG(j, i+1, N-1) {
      if (S[i] != S[j]) {
        if (S[i] != 'R' && S[j] != 'R') {
          res += (R[N] - R[j+1]);
          res -= (j+j-i < N) && S[j+j-i] == 'R';
        }
        if (S[i] != 'G' && S[j] != 'G') {
          res += (G[N] - G[j+1]);
          res -= (j+j-i < N) && S[j+j-i] == 'G';
        }
        if (S[i] != 'B' && S[j] != 'B') {
          res += (B[N] - B[j+1]);
          res -= (j+j-i < N) && S[j+j-i] == 'B';
        }
      }
    }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <sys/time.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 5000005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }

double getTime(){
   timeval tv; 
   gettimeofday(&tv, 0); 
   return tv.tv_sec + tv.tv_usec * 1e-6;
}

LL n, l[MAXX];
vector<int> vv;

int main(){
	ios_base::sync_with_stdio(false);
	
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin >> n;
	n = 2*n;int ans = 0;
	for(int i = 0;i < n;i++){
		cin >> l[i];
	}
	sort(l, l + n);
	for(int i = 0;i < n;i+=2) ans += l[i];
	cout << ans << endl;
	//fclose(stdin);
	//fclose(stdout);
return 0;	
}

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

int main() {
    int a[3], k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a + 3);
    for (int i = 1; i <= k; i++) a[2] *= 2;
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define ll long long
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n,s;
  cin >> n >> s;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<ll>> d(n+1,vector<ll>(5000,0));
  rep(i,n){
    d[i][0]=i+1;
  }
  ll ans=0;
  rep(i,n){
    rep(j,s){
      if (j!=0) d[i+1][j]=(d[i+1][j]+d[i][j])%MOD;
      if (j+a[i]==s){
        ans=(ans+d[i][j]*(n-i))%MOD;
      }
      if (j+a[i]<s){
        d[i+1][j+a[i]]=(d[i+1][j+a[i]]+d[i][j])%MOD;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 117632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
/*ll gcd(ll a,ll b){
	if(a>b)swap(a,b);
	if(a==0)return b;
	return gcd(b%a,a);
}*/

signed main(){
	ll n,m; cin>>n>>m;
	string s,t; cin>>s>>t;
	ll L=n*m/gcd(n,m);
	ll a=L/n;
	ll b=L/m;
	swap(a,b);
	ll i=0,j=0;
	bool ok=true;
	while(i<n && j<m){
		if(s[i]!=t[j]){
			ok=false;
			break;
		}
		i+=a; j+=b;
	}
	cout<<(ok ? (ll)L:-1)<<endl;
	return 0;
}

Measured memory_bytes: 3732
n, a = int(input()), list(map(int, input().split()))
b, c = [0] * n, [0] * 10001

for j in range(n):
    c[a[j]] += 1

prev = -1
for i in range(10001):
    c[i] = prev = c[i] + prev

for j in range(n - 1, -1, -1):
    aj = a[j]
    b[c[aj]] = aj
    c[aj] -= 1

print(*b)

Measured memory_bytes: 226464
word = input()
if word == 'SUN':
    print(7)
elif word == 'MON':
    print(6)
elif word == 'TUE':
    print(5)
elif word == 'WED':
    print(4)
elif word == 'THU':
    print(3)
elif word == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 61860
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	REP(i,s.size()){
		if(i == s.size()-1){
			k %= 26;
			char lk;
			if(s[s.size()-1] + k - 'z' > 0){
				lk = 'a' + k - (26 - (s[s.size()-1] - 'a')); 
				s = s.substr(0,s.size()-1) + lk;
			}else{
				lk = s[s.size()-1] + k;
				s = s.substr(0,s.size()-1) + lk;
			}
		}
		else if(s[i] != 'a' && 'z' - s[i] +1 <= k){
			k -= 'z' - s[i] + 1;
			s = s.substr(0,i) + 'a' + s.substr(i+1,s.size() - i - 1);
		}
	}
	cout << s << endl;
  return 0;
}


Measured memory_bytes: 876
s=input()
k=int(input())
s1=[]
num1=1
str1=s[0]
for i in range(1,len(s)):
    if str1==s[i]:
        num1+=1
    else:
        s1.append([str1,num1])
        num1=1
        str1=s[i]
s1.append([str1,num1])
if len(s1)>1:
    if s1[0][0]!=s1[-1][0]:
        num2=0
        for i in range(len(s1)):
            num2+=s1[i][1]//2
        print(k*num2)
    else:
        num2=0
        num3=s1[0][1]//2
        num4=s1[-1][1]//2
        num5=(s1[0][1]+s1[-1][1])//2
        for i in range(1,len(s1)-1):
            num2+=s1[i][1]//2
        print((num2*k)+(num5*(k-1))+num3+num4)
else:
    print((len(s)*k)//2)


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

pair<int, int> f(int x) {
  int a = x % 10;
  int b = 0;
  while(x) {
    b = x;
    x /= 10;
  }
  pair<int, int> P;
  P = make_pair(a, b);
  return P;
}

int main() {
  int n;
  cin >> n;
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= n; i++){
    pair<int, int> p = f(i);
    mp[p]++;
  }
  ll ans = 0;
  for(int i=1; i<=n; i++){
    pair<int, int> p = f(i);
    pair<int, int> q(p.second, p.first);
    ans += mp[q];
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 998244353
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}
ll f[210000];
void cominit() {
    f[0] = 1;
    REP(i, 200000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll nCr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll nPr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}

ll nHr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return nCr(n + r - 1, r);
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    cominit();
    ll ans = 0;
    REP(i, k + 1){
        ll res = nCr(n - 1, i);
        res *= m * powmod(m - 1, n - i - 1) % MOD;
        res %= MOD;
        ans = (ans + res) % MOD;
    }
    cout << ans << endl;
}


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

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++) {
    if (ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0) {
      int j = S1.top();
      S1.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }

  reverse(ans.begin(), ans.end());

  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " " << ans[i];
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define N 31
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;
int w,h;
string mp[N];
 
void rotN(vector<char> &dice){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);  
   
}
 
void rotS(vector<char> &dice){rotN(dice),rotN(dice),rotN(dice);}
 
void rotE(vector<char> &dice){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}
 
void rotW(vector<char> &dice){rotE(dice),rotE(dice),rotE(dice);}
 
void rotCW(vector<char> &dice){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}
 
typedef pair<int,int> P;
typedef pair<vector<char>,P> PP;
 
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
string ord;
 
P getStart(char ch){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]==ch){
    mp[i][j]='w';
    return P(j,i);
      }
}
 
int C[1<<8];
 
int bfs(int sx,int sy,int gx,int gy,vector<char> dice,int dep){
  char gch = ord[dep];
   
  int D[10][10][31][31];
  memset(D,-1,sizeof(D));
   
  D[C[dice[TOP]]][C[dice[FRONT]]][sx][sy] = 0;
  queue<PP> Q;
  Q.push(PP(dice,P(sx,sy)));
   
  int res = 1e9;
  while(!Q.empty()){
    PP t = Q.front();Q.pop();
    dice = t.first;
    int x = t.second.first;
    int y = t.second.second;
    int cost = D[C[dice[TOP]]][C[dice[FRONT]]][x][y];
         
    if(x==gx&&y==gy){
      if(dice[TOP]!=gch)continue;
      if(dep+1==(int)ord.size()) return cost;
      P st = getStart(ord[dep+1]);
      mp[gy][gx] = 'k';
      res =min(res,cost+bfs(gx,gy,st.first,st.second,dice,dep+1));
      mp[st.second][st.first] = ord[dep+1];
      mp[gy][gx] = 'w';
      continue;
    }
     
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      vector<char> ndice = dice;
      if(i==0)rotS(ndice);
      if(i==1)rotN(ndice);
      if(i==2)rotE(ndice);
      if(i==3)rotW(ndice);
      PP sta = PP(ndice,P(nx,ny));
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!='w')continue;
      if(D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]!=-1) continue;
      Q.push(sta);
      D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]=cost+1;
    }
  }
  return res;
}
 
int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[i];
    cin>>ord;
    vector<char> dice(6);
    dice[TOP]   ='r';
    dice[BOTTOM]='c';
    dice[BACK]  ='g';
    dice[FRONT] ='m';
    dice[RIGHT] ='b';
    dice[LEFT]  ='y';
    C['r'] = 0;
    C['c'] = 1;
    C['g'] = 2;
    C['m'] = 3;
    C['b'] = 4;
    C['y'] = 5;
     
    P s = getStart('#');
    P g = getStart(ord[0]);
    int ans = bfs(s.first,s.second,g.first,g.second,dice,0);
     
    if(ans<1e9) cout<<ans<<endl;
    else cout<<"unreachable"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5484
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

#define vi vector<int>
#define vii vector<vector<int>>

void testcase(){
    int n,l;
    cin>>n>>l;
    string ans,s;
    vector<string> v;
    while(n--){
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(string x:v){
        ans+=x;
    }
    cout << ans << "\n";
}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    testcase();
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N,A;
	bool flag=true;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A;
		flag&=(A%2==1||A%2==0&&(A%3==0||A%5==0));
	}
	if(flag)cout<<"APPROVED";
	else cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }

    let mut a = a;
    let mut c = c;

    loop {
        c -= b;
        if c <= 0 {
            println!("Yes");
            break;
        }

        a -= d;
        if a <= 0 {
            println!("No");
            break;
        }
    }
}

Measured memory_bytes: 2200
# include <algorithm>
# include <iostream>
# include <cmath>
# include <string>
# include <vector>

using namespace std;

int main() {
    int n,k;
    string S;
    cin >> n;
    cin >> S;
    cin >> k;
    char c = S[k-1];
    string sout="";
    for(int i=0; i<S.length(); i++){
        if (S[i]!=c){
            sout += '*';
        }else{
            sout += S[i];
        }
    }

    cout << sout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.util.Arrays;
// import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

    static int WIN = 1;
    static int LOSE = 2;

    private static int[] arr;

    private static int[][] memo;

    private static boolean dfs(int K, int isTaro) { // easier to cache, isTaro == 1 if taro
        if (K == 0) {
            return false;
        }
        if (K < 0) {
            return true; // the opponent tried to remove more stones than were in the pile
        }

        if (memo[K][isTaro] > 0) {
            return memo[K][isTaro] == WIN;
        }

        boolean res = false;
        for (int x_stones : arr) {
            if (!dfs(K - x_stones, isTaro ^ 1)) {
                // guaranteed win
                res = true;
                break;
            }
        }


        memo[K][isTaro] = res ? WIN : LOSE;

        return res;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(f.readLine());

        int N = Integer.valueOf(st.nextToken());
        int K = Integer.valueOf(st.nextToken());


        st = new StringTokenizer(f.readLine());

        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = Integer.valueOf(st.nextToken());
        }

        // instantiate the memo table:
        memo = new int[K+1][2]; // we need to cache (K, isTaro) combo, hard to hash pair
        // 0: uninitialized, 1: win, 2: lose

        if (dfs(K, 1)){
            System.out.println("First");
        } else {
            System.out.println("Second");
        }


    }
}

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


void solve(long long A, long long B){
    for(long long i = 1; i <=3; ++i){
        if(i != A && i != B) cout << i << endl;
    }
    return;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(){
  int a,b,c,k;  cin >> a >> b >> c >> k;
  int ans=0;
  if(k==0){
    cout << 0;
  }
  if(k!=0){
    while(k>0&&a>0){
        ans ++;
        a-=1;
        k -=1;
    }
    while(k>0&&b>0){
        b-=1;
        k -=1;
    }
    while(k>0&&c>0){
        c-=1;
        ans--;
        k -=1;
    }
    cout << ans;
  }
}

Measured memory_bytes: 3636
inf = 1145141919810364364
start = 10**15
import heapq

def di(s,fl):
    d = [inf] * n
    used = [1] * n
    d[s] = 0
    used[s] = 0
    lis = []
    
    for a,b in edge[fl][s]:
        heapq.heappush(lis,a*(10**6)+b)
        
    while lis:
        minedge = heapq.heappop(lis)
        
        if used[minedge%(10**6)] == 0:
            continue

        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = 0

        for q in edge[fl][v]:
            if used[q[1]] == 1:
                heapq.heappush(lis,(q[0]+d[v])*(10**6)+q[1])
    return d

n,m,s,t = map(int,input().split())
#0は円、1はスヌーク
edge = [[[] for i in range(n)] for _ in range(2)]

for i in range(m):
    u,v,a,b = map(int,input().split())
    edge[0][u-1].append([a,v-1])
    edge[0][v-1].append([a,u-1])
    edge[1][u-1].append([b,v-1])
    edge[1][v-1].append([b,u-1])
    
a = di(s-1,0)
b = di(t-1,1)
k = start - a[n-1] - b[n-1]
ans = [0] * n

for i in range(n):
    k = max(k , start - (a[n-1-i] + b[n-1-i]))
    ans[n-1-i] = k
    
for i in range(n):
    print(ans[i])

Measured memory_bytes: 127972
#include <iostream>
#include <cmath>
using namespace std;
int main() {
 int n; cin >> n;
 int tot = 0;
 for (int i = 1; i <= n; i++) {
  int d = 0;
  int j = i;
   while (j > 0) {
    d++;
    j /= 10;
   }
   tot += d % 2;
 }
  cout << tot << endl;
  return 0;
}

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


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

class APluralForm {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >>s;
        if(s.back()=='s'){
            out << s << "es" << endl;
        }else{
            out << s << "s" << endl;
        }
	}
};


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


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int cnt[200005]={0};
int main(){
	int i,n,num;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d",&num);
		cnt[num]++;
	}
	for(i=1;i<=n;i++)
		printf("%d\n",cnt[i]);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int A1, A2, A3; cin >> A1 >> A2 >> A3;
  string result = (A1+A2+A3>=22) ? "bust" : "win";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <numeric>

using namespace std;
typedef long long ll;

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

    vector<ll> count(500001, 0);
    for(int i=0; i<n; i++) count[a[i]]++;

    vector<ll> comb(500001, 0);
    ll sum = 0;
    for(int i=0; i<count.size(); i++){
        comb[i] = (count[i] * (count[i]-1)) / 2;
    }
    sum = accumulate(comb.begin(), comb.end(), 0LL);

    for(int k=0; k<n; k++){
        ll ans = sum - comb[a[k]];
        ans += ((count[a[k]] - 1) * (count[a[k]] - 2)) / 2;
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 11136
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = BigInt(next())
    let min = BigInt('1000000000000000')
    let a = []
    while(hasNext()){
        a.push(BigInt(next()))
    }
    for(let i = 0;i<a.length; i++){
        if(min > a[i]){
            min = a[i]
        }  
    }
    let times
    if(N % min == 0) times = N / min - 1n
    else times = N / min
    console.log(String(times+5n))
    
}
Main()


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

using namespace std;

void Main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M, 0);
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
    }
    auto it = lower_bound(A.begin(), A.end(), X);
    int toN = distance(it, A.end());
    int to0 = distance(A.begin(), it);
    cout << min(to0, toN) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    int cnt = 0;
    
    for(int i=1; i <= n; i++){
      int a = sc.nextInt();
      if(i%2 == 0)
        continue;
      if(a%2 == 0)
        continue;
      cnt++;
    }
    
    System.out.println(cnt);
  }
}

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

struct node{
	int num;
	node *parent,*left,*right;
};
node *root,*NIL;


node *nextnode(node *x){
	node *z=x->right;
	while(z->left!=NIL){
		z=z->left;
	}
	return z;
}

void denode(node *z){
	node *x,*y;
	if(z->left==NIL||z->right==NIL) y=z;
	else y=nextnode(z);
	if(y->left!=NIL) x=y->left;
	else x=y->right;
	if(x!=NIL) x->parent=y->parent;
	if(y->parent==NIL) root=x;
	else{
		if(y==y->parent->left) y->parent->left=x;
		else y->parent->right=x;
	}
	if(y!=z) z->num=y->num;
	delete y;
	return ;
}

node *find(int a){
	node *x=root;
	while(x!=NIL){
		if(x->num<a) x=x->right;
		else if(x->num>a) x=x->left;
		else return x;
	}
	return NIL;
}

void print_inorder(node *x){
	if(x==NIL) return ;
	print_inorder(x->left);
	printf(" %d",x->num);
	print_inorder(x->right);
	return ;
}

void print_preorder(node *x){
	if(x==NIL) return ;
	printf(" %d",x->num);
	print_preorder(x->left);
	print_preorder(x->right);
	return ;
}

void insert(int a){
	node *x=root,*y=NIL;
	node *z=new node();
	z->num=a;z->left=NIL;z->right=NIL;
	while(x!=NIL){
		y=x;
		if(z->num < x->num) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else {
		if(z->num < y->num) y->left=z;
		else y->right=z;
	}
	return ;
}

int main(){
	int n;
	cin>>n;
	string s;
	node *f;
	int a;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='i') cin>>a,insert(a);
		else if(s[0]=='p'){
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
		else if(s[0]=='f'){
			cin>>a;
			f=find(a);
			if(f==NIL) printf("no\n");
			else printf("yes\n");
		}
		else{
			cin>>a;
			denode(find(a));
		}
	}
	return 0;
}


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

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

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

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

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

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

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

struct Edge
{
	int from, to;
	ll cost;
};

const int MAX_N = 2577;
const int MAX_M = 5777;

Edge edges[MAX_M];
ll d[MAX_N];
int n, m;

void solve()
{
	ll p;
	cin >> n >> m >> p;

	for(int i = 0; i < m; ++i)
	{
		int v, u;
		ll cost;
		cin >> v >> u >> cost;
		--v, --u;

		edges[i] = {v, u, cost - p};
	}

	for(int v = 0; v < MAX_N; ++v)
		d[v] = -LL_INF;

	d[0] = 0;

	for(int phase = 0; phase < n + 27; ++phase)
	{
		for(int ed = 0; ed < m; ++ed)
		{
			int v = edges[ed].from, u = edges[ed].to;
			ll c = edges[ed].cost;

			if(d[v] <= -LL_INF)
				continue;

			if(d[u] < d[v] + c)
				d[u] = d[v] + c;
		}
	}

	ll old = d[n - 1];

	for(int phase = 0; phase < n + 27; ++phase)
	{
		for(int ed = 0; ed < m; ++ed)
		{
			int v = edges[ed].from, u = edges[ed].to;
			ll c = edges[ed].cost;

			if(d[v] <= -LL_INF)
				continue;

			if(d[u] < d[v] + c)
				d[u] = d[v] + c;
		}
	}
	
	cout << (d[n - 1] > old ? NIL : max(d[n - 1], 0LL)) << endl;
}

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

	return 0;
}


Measured memory_bytes: 384
a,b,c,x,y=map(int,input().split())
if x==y:
    ans=min(a+b,2*c)*x
else:
    if x>y:
        ans=min(a+b,2*c)*y
        ans+=min(a,2*c)*(x-y)
    else:
        ans=min(a+b,2*c)*x
        ans+=min(b,2*c)*(y-x)
print(ans)
    

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	private void run() throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Set<String> set = new HashSet<String>();
		for (int i = 0; i < n; i++) {
			set.add(reader.readLine());
		}
		
		Arrays.asList("S", "H", "C", "D").stream().forEach(suit -> {
			IntStream.range(1, 14).forEach(rank -> {
				String card = suit + " " + rank;
				if (!set.contains(card)) {
					System.out.println(card);
				}
			});
		});
	}
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  ll ans = -a;
  ll ged = a+b;
  ll poi = c;
  if(ged < poi){
    ans += 2*ged+1;
  }else{
    ans += ged+poi;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

ans = 0
tmp = 0
for i in range(N):
    if S[i] in {'A','C','G','T'}:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
else:
    ans = max(ans, tmp)
print(ans)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k;
	cin>>k;
	queue<int64_t>q;
	for(int i=1;i<=9;++i)q.push(i);
	int64_t ans;
	for(int i=1;i<=k;++i){
		ans=q.front();
		q.pop();
		if(ans%10!=0)q.push(ans*10+ans%10-1);
		q.push(ans*10+ans%10);
		if(ans%10!=9)q.push(ans*10+ans%10+1);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
#define OK          pf("Yes\n")
#define _OK         pf("No\n")
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k;
    cin>>n;
    string st,ans;
    cin>>st;
    ll ln=st.size();
    ll ar[ln+1];
    for(i=0;i<ln;i++){
        ar[i]=st[i]-'A';
        ar[i]=ar[i]+n;
        ar[i]=ar[i]%26;
    }
    for(i=0;i<ln;i++){
        pf("%c",'A'+ar[i]);
    }
    return 0;
}
//https://github.com/me-shaon/bangla-programming-resources


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1)
    {
        cout<<"Brown\n";
    }
    else
    {
        cout<<"Alice\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi d(N);
  rep(i,N) {
    cin >> d[i];
  }
  sort(rng(d));
  int a = d[N/2 - 1];
  int b = d[N/2];
  cout <<  b - a << endl;
  return 0;
}

Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}
const H = 19;
const W = 15;
const INF = int.max / 2;

void main() {
    auto F = new string[19];
    foreach (ref L; F) L = readln.chomp;
    int sy, sx;
    void find_init_pos() {
        foreach (i; 0 .. H) {
            foreach (j; 0 .. W) {
                if (F[i][j] == 'O') {
                    sy = i;
                    sx = j;
                    return;
                }
            }
        }
    }
    find_init_pos();

    if (! (F[H - 2].any!((c) => c == 'X') || F[H - 1].any!((c) => c == 'X'))) {
        writeln(-1);
        return;
    }

    bool[W][H] used;
    bool dfs(int cy, int cx, int d) {
        if (d == 0) return false;
        //log([cy, cx, t, d]);
        for (int dy = -1; dy <= 1; dy++) {
            for (int dx = -1; dx <= 1; dx++) {
                if (dy == 0 && dx == 0) continue;
                int y = cy + dy, x = cx + dx;
                if (! (0 <= y && y < H && 0 <= x && x < W && F[y][x] == 'X' && !used[y][x])) continue;
                while (0 <= y && y < H && 0 <= x && x < W && F[y][x] == 'X' && !used[y][x]) {
                    y += dy;
                    x += dx;
                }
                if (y == H - 1 && 0 <= x && x < W) return true;
                if (y >= H) return true;
                if (x < 0 || x >= W) continue;
                y = cy + dy, x = cx + dx;
                while (0 <= y && y < H && 0 <= x && x < W && F[y][x] == 'X' && !used[y][x]) {
                    used[y][x] = true;
                    y += dy;
                    x += dx;
                }
                if (dfs(y, x, d - 1)) return true;
                y -= dy, x -= dx;
                while (y != cy || x != cx) {
                    used[y][x] = false;
                    y -= dy;
                    x -= dx;
                }
            }
        }
        return false;
    }

    for (int d = 1; d <= 20; d++) {
        if (dfs(sy, sx, d)) {
            writeln(d);
            return;
        }
    }
    writeln(-1);

}

Measured memory_bytes: 2480
S = input()
N = len(S)
for i in range(N):
    if i < N-1:
        if len(set(S[i:i+2])) == 1:
            print(i+1, i+2)
            exit()

    if i < N-2:
        if len(set(S[i:i+3])) <= 2:
            print(i+1, i+3)
            exit()

print(-1,-1)

Measured memory_bytes: 3188
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100, MAXI = 5000, D = 9;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	int n = rand()%N + 1;
//     	int k = rand()%MAXI + 1;

//     	cout << n << " " << k << "\n";

//     	for(int i=0;i<n;i++)
//     	{
//     		for(int j=0;j<n;j++)
//     		{
//     			cout << rand()%2 << " ";
//     		}
//     		cout << "\n";
//     	}
    	
//     	cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
//#define ll long long
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 22

int n, a[N]={0};
int mask;

int dp[1<<N];

int MEM(int mask_j)
{
	if(mask_j>mask)
		return 0;
	
	if(mask_j==mask)
		return 1;

	//int ans;

	int &ans = dp[mask_j];

	if(ans!=-1)
		return ans;

	ans = 0;

	int ind = __builtin_popcount(mask_j);

	for(int j=0;j<n;j++)
	{
		
		if(!((1<<j)&mask_j) and ((1<<j)&a[ind]))
		{

			ans += MEM(mask_j | (1<<j));

			if(ans>=mod)
				ans %= mod;
		}
		
	}

	return ans;
}

// Driver code to test above functions
int32_t main()
{
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	cout.tie(NULL);

	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int y;
			cin >> y;
			if(y==1)
				a[i] |= (1<<j);
		}
	}

	mask = (1<<n)-1;

	memset(dp, -1, sizeof dp);

	cout << MEM(0);

    return 0;
 
} 


Measured memory_bytes: 33024
function main(lines) {
  const phrases = na();
  
  let cnt5 = cnt7 = 0;
  phrases.forEach(n => {
    if (n == 5) cnt5++;
    if (n == 7) cnt7++;
  })
  const ans = cnt5 == 2 && cnt7 == 1 ? 'YES' : 'NO';
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 29496
import math

N = int(input())
alphas = 'abcdefghijklmnopqrstuvwxyz'
alphabets = [str(alphas[i]) for i in range(26)]
ans = ''

while (N>=1):
  ans = alphabets[int((N%26)-1)]+ans
  if N%26==0:
    N = int(N/26-0.1)
  else:
    N = int(N/26)

print(ans)

Measured memory_bytes: 62112
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007
typedef long long ll;
ll fact[100005], inv[100005], dp[25][100005]; 
int arr[25]; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
inline ll C(int n, int m)
{
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
int main()
{
	// freopen("ARC093-F.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
		scanf("%d", arr + i); 
	fact[0] = inv[0] = 1; 
	for (int i = 1; i <= 1 << n; i++)
	{
		fact[i] = fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	dp[m][0] = 1;
	for (int i = m; i; i--)
	{
		for (int x = 0; x < 1 << n; x++)
		{
			int rem = (1 << n) - arr[i - 1] - x; 
			(dp[i - 1][x] += dp[i][x]) %= MOD; 
			for (int j = n - 1; j >= 0; j--)
			{
				if (!(x & (1 << j)) && (1 << j) - 1 <= rem)
					(dp[i - 1][x | (1 << j)] += (MOD - C(rem, (1 << j) - 1)) * dp[i][x]) %= MOD; 
			}
		}
	}
	ll ans = 0; 
	for (int i = 0; i < 1 << n; i++)
	{
		ll x = dp[0][i]; 
		for (int j = 0; j < n; j++)
		{
			if (!(i & (1 << j)))
				x = x * inv[1 << j] % MOD; 
		}
		int rem = (1 << n) - i - 1; 
		x = x * fact[rem] % MOD; 
		(ans += x) %= MOD; 
	}
	for (int i = 0; i < n; i++)
		ans = ans * fact[1 << i] % MOD; 
	printf("%lld\n", ans * (1 << n) % MOD);
	return 0; 
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ld n;
 cin>>n;
 cout<<fixed<<setprecision(12)<<(n/3)*(n/3)*(n/3)<<endl;
 return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int a = S.find('A');
    int z = S.rfind('Z');
    cout << z - a + 1 << endl;

    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    rep(i, N){
        ll a; cin >> a;
        q.push(a);
    }
    ll cnt = 0, tmp = 0;
    while(q.size() > 1){
        ll a = q.top(); q.pop();
        ll b = q.top(); q.pop();
        tmp++;
        if(a*2 < b) cnt = tmp;
        q.push(a+b);
    }
    cout << N-cnt << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5496
n,m=map(int,input().split())
c=[]
d=[]
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    c.append(b)
  elif b==n:
    d.append(a)
if len(set(c)&set(d))!=0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

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

using namespace std;

typedef long long swl;

int main(void) {
  swl n; cin >> n;
  swl rt_n = sqrt((double)n);
  
  for (int i = rt_n; i > 0; i--) {
    if (n % i == 0) {
      cout << i + n/i - 2 << endl;
      return 0;
    }
  } 

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
count1,count2,count3 = 0,0,0
for i in range(N):
  if P[i] <= A:
    count1 += 1
  if P[i] >= B+1:
    count3 += 1
    continue
  if P[i] >= A+1:
    count2 += 1
print(min(count1,count2,count3))

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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


int main( void )
{
	ll h, w, k;
	cin >> h >> w >> k;

	char	c[6][6];
	rep ( y, h ) {
		rep ( x, w ) {
			cin >> c[y][x];
		}
	}

	ll cnt = 0;
	rep ( maskH, (1 << h) ) {
		rep ( maskW, (1 << w) ) {
			ll black = 0;
			rep ( y, h ) {
				rep ( x, w ) {
					if ( !(maskH & (1 << y)) && !(maskW & (1 << x)) && (c[y][x] == '#') ) {
						black++;
					}
				}
			}
			if ( black == k ) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
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); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n;
  cin >> n;
  vector<int>v(n * 3);
  rep(i,n * 3)cin >> v[i];
  sort(all(v));
  reverse(all(v));
  ll ans = 0;
  for(int i = 1,cnt = 0;cnt < n; i += 2,cnt++)ans += v[i];
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 1408