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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  rep(i,0,n)cin>>x[i]>>y[i];
  vector<ll>v(n);
  iota(ALL(v),0);
  ld ret=0;
  do{
    ld now=0;
    rep(i,0,n-1){
      ld da=abs(x[v[i]]-x[v[i+1]]);
      ld db=abs(y[v[i]]-y[v[i+1]]);
      now+=sqrt(da*da+db*db);
    }
    ret+=now;
  }while(next_permutation(ALL(v)));
  rep(i,1,n+1)ret/=i;
  lfs<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define endl "\n"
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define pi pair<int,int>
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	v h(n);in(h,n);
	sort(all(h));
	if(k>=n)
	{
		cout<<0<<endl;
	}
	else
	{
		int sum=0;
		for(int i=0;i<n-k;i++)
			sum+=h[i];
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

const int maxn = 1e5 + 10;

int A, B, M;
int a[maxn], b[maxn];
int x[maxn], y[maxn], c[maxn];

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>A>>B>>M;
    int mnA = 1e9;
    for(int i = 0; i < A; i++) {
    	cin>>a[i];
    	checkmin(mnA, a[i]);
	}
	int mnB = 1e9;
	for(int i = 0; i < B; i++) {
		cin>>b[i];
		checkmin(mnB, b[i]);
	}
	int ans = mnA + mnB; 
	for(int i = 0; i < M; i++) {
		cin>>x[i]>>y[i]>>c[i];
		checkmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
	}
	cout<<ans<<endl;
    /* end code */
	return 0;
}

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

#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

ll mod=1e9+7;

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll n;
      cin>>n;
      ll arr[n];
      loop(i,0,n){cin>>arr[i];}

      ll sum=0;
      for(int i=0,cnt=0; i<n; i++){
           sum=(sum+((cnt*arr[i])%mod))%mod;
           cnt=(cnt+arr[i])%mod;
      }

      cout<<sum<<endl;


      bye;
}


Measured memory_bytes: 5216
#include<iostream>
#include<map>
#include<string.h>
#include<cmath>
#include<vector>
#include<fstream> 
#include<string>
#include<algorithm>
using namespace std;
const double PI = acos(-1.0);


int main() 
{
	//freopen("ttt.txt","r",stdin);
	string a,b,c;
	cin>>a>>b>>c;
	printf((a[a.length()-1]==b[0]&&b[b.length()-1]==c[0])?"YES\n":"NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
const int MOD = 1e9+7;

int n;
int dp[1000010][2][2]; // [N][0を含むかどうか][9を含むかどうか]

ll modpow(ll x, ll y) {
  ll v = 1;
  REP(i,y) { v *= x; v %= MOD; }
  return v;
}

// 包除原理解法
void solve1() {
  ll p1 = modpow(10, n);
  ll p2 = (modpow(9, n) * 2) % MOD;
  ll p3 = modpow(8, n);
  ll ans = p1 - (p2 - p3);
  ans %= MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
}

// DP解法
void solve2() {
  dp[0][0][0] = 1;
  REP(i,n) {
    REP(j,2) {
      REP(k,2) {
        REP(x,10) {
          int nj = j || x == 0;
          int nk = k || x == 9;
          dp[i+1][nj][nk] += dp[i][j][k];
          dp[i+1][nj][nk] %= MOD;
        }
      }
    }
  }
  cout << dp[n][1][1] << endl;
}

int main() {
  cin >> n;
  // solve1();
  solve2();
  return 0;
}

Measured memory_bytes: 19040
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <math.h>

const long long MOD = 1000000007;

using namespace std;



int main(void) {

    long long i, j;
    long long n, k;
    long long sum = 0;
    long long temp;
    long long min, max;
    long long a, b, c, d;
    string s;

    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    }else {
        cout << "ABC" << endl;
    }





    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int X, Y;
    cin >> X;
    cout << ( X == 3 || X == 5 || X == 7 ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long N, M;
    long long A[100000];
    long long B[100000];

    cin >> N >> M;
    for (int i=0; i<N; i++) cin >> A[i] >> B[i];

    int idx[100000];
    for (int i=0; i<N; i++) idx[i] = i;
    sort(idx, idx+N, [&](int x, int y){return A[x] < A[y];});

    long long money = 0;
    int store = 0;
    while (M>0) {
        int store_num = idx[store];
        if (M < B[store_num]) {
            money += M * A[store_num];
            break;
        }
        money += A[store_num] * B[store_num];
        store++;
        M -= B[store_num];
    }
    cout << money << endl;
    return 0;
}



Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(15) << sqrt(pow((x2-x1),2) + pow((y2-y1),2)) << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,i,j,d,c=0;
 	cin>>n;
 	int a[n];
 	for(i=0;i<n;i++)
 		cin>>a[i];
 		for(i=1;i<n-1;i++)
 		{
 			if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
 				c++;
		 }
 	cout<<c<<endl;	
 }

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

int main()
{
	int n;
	string s,r;
	vector<string> S1, S2;
	S1.reserve(50);
	S2.reserve(50);
	while (cin >> n, n) {
		S1.clear();
		for (int i = 0; i < n; i++) {
			cin >> s;
			r = s[0];
			for (int j = 1; j < s.size(); j++)
				if (s[j - 1] == 'a' || s[j - 1] == 'i' || s[j - 1] == 'u' || s[j - 1] == 'e' || s[j - 1] == 'o')
					r += s[j];

			S1.push_back(r);
		}
		bool flag = false;
		int k;
		for (k = 1; k <= 50; k++) {
			S2.clear();
			for (int j = 0; j < S1.size(); j++) {
				S2.push_back(S1[j].substr(0, min((int)S1[j].size(), k)));
			}
			sort(S2.begin(),S2.end());
			S2.erase(unique(S2.begin(),S2.end()),S2.end());
			if (S2.size() == n) {
				flag = true;
				break;
			}
		}
		if (flag) {
			cout << k << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int d = 0;
  int i;
  rep(i, m){
    cin >> a[i];
  	d += a[i]; 
  }
  int p;
  p = n - d;
  if(p >= 0)
    cout << p << endl;
  else
    cout << "-1" << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
	int p, q, r;
	cin >> p >> q >> r;
	cout << min(min(p + q, p + r), q + r);
    
    return 0;
}

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

int main(){
  int n;
  int s=100;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    int v=0;
    cin>>a;
    while(a%2==0){
      a /= 2;
      v++;
    }
    s=min(v,s);
  }
  cout<<s<<endl;
  return 0;
}
  
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  int y,x;
  cin >> y >> x;
  y--;
  x--;
  string S,T;
  cin >> S >> T;
  int temp_x=x;
  for(int i=0; i<N; i++){
    if(S[i] == 'R'){
      temp_x++;
    }
    if(temp_x>=W){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i] == 'L' and temp_x>0){
      temp_x--;
    }
  }
  temp_x = x;
  for(int i=0; i<N; i++){
    if(S[i] == 'L'){
      temp_x--;
    }
    if(temp_x<0){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i] == 'R' and temp_x<W-1){
      temp_x++;
    }
  }
  int temp_y=y;
  for(int i=0; i<N; i++){
    if(S[i] == 'D'){
      temp_y++;
    }
    if(temp_y>=H){
      cout << "NO" << endl;
      return 0;
    } 
    if(T[i] == 'U' and temp_y>0){
      temp_y--;
    }
  }
  temp_y = y;
  for(int i=0; i<N; i++){
    if(S[i] == 'U'){
      temp_y--;
    }
    if(temp_y<0){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i] == 'D' and temp_y<H-1){
      temp_y++;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;




int main(){
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    
    if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }else{
        if(abs(a-b)>d || abs(c-b)>d){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
        
    }
    return 0;
}




Measured memory_bytes: 256
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

N,K = map(int,input().split())
A = list(map(int,input().split()))

GCD = A[0]
for i in range(1,N):
    GCD = gcd(GCD,A[i])
    
MAX = max(A)

if MAX >= K and (MAX-K)%GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14252
while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    for i in range(a):
        for j in range(b):
            if (i + j) % 2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


Measured memory_bytes: 7004
num_s, *D,  = [list(map(int, s.split())) for s in open(0)] 
flag = 0
x, y = D[0], D[1]

max_x, min_y = max(x), min(y)

if max_x > min_y:
    flag += 1
else:
    for i in range(max_x  + 1, min_y + 1):
        if i > num_s[2] and i <= num_s[3]:
            break 
    else:
        flag += 1
if flag:
    print("War")
else:
    print("No War")

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int d; cin >> d;
	vi c(26); rep(i, 26) cin >> c[i];
	vector<vi> s(d, vi(26));
	rep(i, d) rep(j, 26) cin >> s[i][j];

	for(auto t : s){
		cout << (max_element(all(t))-t.begin())+1 << endl;;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdbool.h>

int main(void) {
    long A, B, C;
    long K;
    long S = 0;

    scanf("%ld %ld %ld %ld", &A, &B, &C, &K);

    if(K <= A) {
        S += (K * 1);
        printf("%ld\n", S);
        return 0;
    }
    S += (A * 1);
    K -= A;

    if(K <= B) {
        S += (K * 0);
        printf("%ld\n", S);
        return 0;
    }
    S += (B * 0);
    K -= B;

    S += (K * -1);
    printf("%ld\n", S);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      sum = sum + T.at(i) * T.at(j);
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int ans=c;
  int ansa=a;
  int cnt=0;
  int cnta=0;
  while(ans>0){
    ans=ans-b;
    cnt++;
  }
  while(ansa>0){
    ansa=ansa-d;
    cnta++;
  }
  if(cnt<=cnta) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>k>>n;
	int a[n];
	for(int i =0;i<n; i++)
		cin>>a[i];
	vector<int>v;
	for(int i =1; i<n; i++)
		v.push_back(a[i]-a[i-1]);
	v.push_back(k-a[n-1]+a[0]);
	cout<<accumulate(v.begin(),v.end(),0)-*max_element(v.begin(),v.end())<<endl;
	return 0;
}

Measured memory_bytes: 2168
from bisect import bisect_left
from collections import deque


def solve():
	N, *A = map(int, open(0).read().split())

	top = deque([A[0]])
	for a in A[1:]:
		if top[0] >= a:
			top.appendleft(a)
		else:
			index = bisect_left(top, a)
			top[index-1] = a
	
	print(len(top))


if __name__ == '__main__':
	solve()

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n, x, t;
  int ans;
  
  cin >> n >> x >> t;
  
  ans = n / x;
  if(n%x != 0) ans++;
  ans *= t;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll ans = 0,n;
    vector<ll>cnt(5,0);
    string s;
    cin>>n;
    rep(i,n){
        cin>>s;
        if(s[0]=='M')cnt[0]++;
        else if(s[0]=='A')cnt[1]++;
        else if(s[0]=='R')cnt[2]++;
        else if(s[0]=='C')cnt[3]++;
        else if(s[0]=='H')cnt[4]++;
    }
    rep(i,5){
        repi(j,i+1,5){
            repi(k,j+1,5){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define all(x) begin(x), end(x)

using namespace std;

template <typename T> T gcd(T a, T b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

void input(vector<int> &v) {
  for (int i = 0; i < v.size(); ++i) {
      cin >> v[i];
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  input(s);
  int q;
  cin >> q;
  vector<int> t(q);
  input(t);

  int res = 0;
  for (int i = 0; i < t.size(); ++i) {
      int ele = t[i];
      int low = 0;
      int high = s.size();
      bool found = false;
      while (low <= high) {
          int mid = (low + high) / 2;
          int can = s[mid];
          if (can < ele) {
            low = mid + 1;
          } else if (can > ele) {
            high = mid - 1;
          } else {
              found = true;
              break;
          }
      }
      if (found) {
          res++;
      }
  }
  cout << res << endl;
}



Measured memory_bytes: 3348
import sys
from copy import deepcopy

N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]
B = deepcopy(A)
for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j or j == k or k == i:
                continue
            if A[i][k] + A[k][j] < A[i][j]:
                print(-1)
                sys.exit()
            elif A[i][k] + A[k][j] == A[i][j]:
                B[i][j] = 0

ans = sum(sum(B[i][j] for j in range(N)) for i in range(N)) // 2
print(ans)

Measured memory_bytes: 76876
<?php
  fscanf(STDIN,"%d %d", $a, $b);
  for ($i=1; $i<1010; $i++){
    if( (int)($i*0.08) == $a && (int)($i*0.1) == $b){
      echo $i."\n";
      exit;
    }
  }
  echo "-1\n";


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    s = 'x' + s + 'x';

    vector<pair<int,int>> dp(n+2), bp(n+2);
    dp[0] = make_pair(0, -inf);
    bp[n+1] = make_pair(0, inf);

    REP(i, n+1){
        dp[i+1] = dp[i];
        if(i+1 - dp[i+1].second > c && s[i+1] == 'o') {
            dp[i+1].first++;
            dp[i+1].second = i+1;
        }
    }

    RREP(i, n+1) {
        bp[i] = bp[i+1];
        if(bp[i].second - i > c && s[i] == 'o') {
            bp[i].first++;
            bp[i].second = i;
        }
    }

    vector<int> ans;

    FOR(i, 1, n+1) {
        int cnt = dp[i-1].first;
        int a = dp[i-1].second + c;
        if(a <= i) a = i+1;
        cnt += bp[a].first;
        if(cnt < k) ans.push_back(i);
    }

    for(auto i : ans) cout << i << '\n';

    return 0;
}


Measured memory_bytes: 5816
#include<stdio.h>
#define N 40

int n,pos;
int a[N],b[N];

void solve(int, int);

void solve(int l,int r){
  int x,i;

  x = a[pos];
  if( l > r ) return;
  if( l == r ){
    if( b[l] == a[0] ) printf("%d", b[l]);
    else printf("%d ", b[l]);
    pos++;

    return;
  }
  pos++;

  for( i = l ; i <= r ; i++){
    if( b[i] == x ) break;
  }
  solve( l, i-1);
  solve( i+1, r);

  if( x == a[0]) printf("%d", x);
  else printf("%d ", x);
}


int main(){
  int i;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
  }
  for( i = 0 ; i < n ; i++){
    scanf("%d", &b[i]);
  }
  pos = 0;
  solve( 0, n-1);
  printf("\n");

  return 0;
}



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

int d[100005];

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0;i < n;i++)
	{
		int l, r; scanf("%d%d", &l, &r);
		d[1]++; d[r-l+2]--;
		d[l]++; d[r+1]--;
		if (l <= r-l+1) { d[l]--; d[r-l+2]++; }
		int at = r-l+2;
		while (at < l)
		{
			int fact = (l+at-1)/at;
			int hi = r/fact;
			if (hi >= at)
			{
				d[at]++;
				if (hi+1 < 100005) d[hi+1]--;
			}
			fact = r/(max(at, hi)+1);
			if (fact == 0) break;
			at = (l+fact-1)/fact;
		}
	}
	for (int i = 1;i <= m;i++)
	{
		d[i] += d[i-1];
		printf("%d\n", d[i]);
	}
	return 0;
}


Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), [](int a, int b){return b < a;});
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) sum1 += A[i]; else sum2 += A[i];
    }
    cout << sum1 - sum2 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]

    P.sort()

    ans = 0
    for i in range(K):
        ans += P[i]

    print(ans)
    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9232
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n;
int dis[305][305];
bool ok[305][305],flag;
int main(){
    read(n);
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) read(dis[i][j]);
    for (int k=1;k<=n;k++){
        for (int i=1;i<=n;i++){
            for (int j=1;j<=n;j++)if (i!=j && i!=k && j!=k){
                if (dis[i][k]+dis[k][j]<dis[i][j]) flag=true;
                if (dis[i][k]+dis[k][j]==dis[i][j]) ok[i][j]=true;
            }
            if (flag) break;
        }
        if (flag) break;
    }
    if (flag) puts("-1");
    else{
        ll ans=0;
        for (int i=1;i<=n;i++){
            for (int j=i;j<=n;j++){
                ans+=1LL*(ok[i][j]?0:dis[i][j]);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;
const ll INF=1e18;
int N;
ll D[MAX_N];

map<ll,int> dmp;
int par[MAX_N],chl[MAX_N];
vector<int> G[MAX_N];
ll dist[MAX_N];
int main(){
	cin>>N;
	REP(i,N)cin>>D[i];
	REP(i,N){
		dmp[D[i]]=i;
	}
	REP(i,N){
		par[i]=-1;
		chl[i]=1;
	}
	bool flg=true;
	{
		auto ite=dmp.end();
		ite--;
		for(;;ite--){
			if (ite==dmp.begin()){
					break;
				}
//			cout<<ite->second<<endl;
			ll pd=ite->first-N+chl[ite->second]*2;
			if (pd>=ite->first || dmp.find(pd)==dmp.end()){
				flg=false;
				break;
			}
			int pr=dmp[pd];
			par[ite->second]=pr;
			chl[pr]+=chl[ite->second];
		}
	}
	if (flg){
//		cout<<"debug"<<endl;
		int rot;
		REP(i,N){
			if (par[i]==-1){
				rot=i;
			}else{
				G[i].push_back(par[i]);
				G[par[i]].push_back(i);
			}
		}
		queue<int > que;
		REP(i,N){
			dist[i]=INF;
		}
		que.push(rot);
		dist[rot]=0;
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(auto e:G[v]){
				if (dist[e]==INF){
					dist[e]=dist[v]+1;
					que.push(e);
				}
			}
		}
		ll sm=0;
		REP(i,N)sm+=dist[i];
		if (sm!=D[rot]){
			flg=false;
		}
	}
	if (flg){
		REP(i,N){
			if (par[i]!=-1){
				cout<<i+1<<" "<<par[i]+1<<endl;
			}
		}
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 15488
import java.util.Scanner;

public class Main {
    final static int nmax = 8;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] graph = new boolean[nmax][nmax];

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
        }
        boolean[] visited = new boolean[nmax];
        for (int i = 0; i < n; i++) {
            visited[i] = false;
        }
        visited[0] = true;
        System.out.println(dfs(0, n, visited, graph));
    }

    private static int dfs(int v, int n, boolean visited[], boolean graph[][]) {
        boolean all_visited = true;
        for (int i = 0; i < n; i++) {
            if (visited[i] == false) {
                all_visited = false;
            }
        }

        if (all_visited) {
            return 1;
        }

        int ret = 0;

        for (int i = 0; i < n; i++) {
            if (graph[v][i] == false) {
                continue;
            }
            if (visited[i]) {
                continue;
            }
            visited[i] = true;
            ret += dfs(i, n, visited, graph);
            visited[i] = false;

        }
        return ret;
    }

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; bool can = false;
    for(int i=1;i<=3500;i++){
        for(int j=1;j<=3500;j++){
            double W=(double)N*i*j/(4*i*j-N*(j+i));
            if(W>=1&&ceil(W)==floor(W)&&W<=3500){
                can = true;
                cout << W <<" "<< i <<" "<< j << endl;;
                break;
            }
        }
        if(can) break;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll ttol(string time) {
  ll res=0;
  res+=(int(time[0]-'0')*10+int(time[1]-'0'))*60*60;
  res+=(int(time[3]-'0')*10+int(time[4]-'0'))*60;
  res+=(int(time[6]-'0')*10+int(time[7]-'0'));
  return res;
}

int main() {
  while(1) {
    ll n;
    cin >> n;
    if(n==0) {
      break;
    }
    priority_queue<ll,vector<ll>,greater<ll>> s;
    priority_queue<ll,vector<ll>,greater<ll>> e;
    for(ll i=0;i<n;i++) {
      string temps,tempe;
      cin >> temps >> tempe;
      s.push(ttol(temps));
      e.push(ttol(tempe));
    }
    ll ready=0;
    ll ans=0;
    for(ll i=0;i<24*60*60;i++) {
      while(e.size()&&e.top()==i) {
        ready++;
        e.pop();
      }
      while(s.size()&&s.top()==i) {
        if(ready>0) {
          ready--;
        }
        else {
          ans++;
        }
        s.pop();
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3372
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

///
/// # Examples
///
/// # integers
/// input! { n: usize, m: usize, ... }
///
/// # array
/// input! { n: usize, v: [i32; n], }
///
/// # matrix
/// input! { n: usize, m: usize, mat: [[]] }
///
/// # string
/// input! { s: chars }

// https://practice.contest.atcoder.jp/tasks/practice_1
//
fn gcd(a: i32, b: i32) -> i32 {
    if b == 0 { a }
    else { gcd(b, a % b) }
}

fn main() {
    input!{
        n: usize, x: i32,
        xs: [i32; n],
    }
    let mut ans = 0;
    for x_i in xs {
        ans = gcd(ans, (x_i-x).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
 
void main()
{
   string n = chomp(readln());
   int a = to!int(n);
   if(a/100%10 == a/10%10 && (a/100%10 == a/1000 || a/100%10 == a%10)){
       writeln("Yes");
   } else {
       writeln("No");
   }
}

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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int blocks = 0;
    char last = -1;
    int ans = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] != last)
        {
            blocks++;
            last = s[i];
        }
        if(i > 0 && s[i] == 'L' && s[i - 1] == 'L') ans++;
        if(i < n - 1 && s[i] == 'R' && s[i + 1] == 'R') ans++;
    }

    int half = (blocks - 1) / 2;
    if(k > half) ans = n - 1;
        else ans += k * 2;
    cout << ans;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int a[3],min,i,j,x;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  for(j=0;j<2;j++){
    min=a[j];
    x=j;
    for(i=j;i<3;i++){
      if(min>a[i]){
	min=a[i];
	x=i;
      }
    }
     a[x]=a[j];
     a[j]=min;
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}


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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D)	cout << "Left" << endl;
  else if (A + B < C + D)	cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  const int INF = 1 << 30;
  int n, dis[110][110];
  cin >> n;
  fill((int*)dis, (int*)(dis + 110), INF);
  for (int i = 1; i <= n; i++) {
    dis[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int r, k;
    cin >> r >> k;
    for (int j = 0; j < k; j++) {
      int t;
      cin >> t;
      dis[r][t] = 1;
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (dis[i][k] == INF || dis[k][j] == INF) continue;
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int p;
  cin >> p;
  for (int i = 0; i < p; i++) {
    int s, d, v;
    cin >> s >> d >> v;
    if (dis[s][d] + 1 <= v) cout << dis[s][d] + 1 << endl;
    else cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();
let [N, K] = reader.readInts();
let V: number[] = reader.readInts();

let answer = 0;

for(let a=0; a<=Math.min(N, K); a++) {
	for(let b=0; b<=Math.min(N-a, K-a); b++) {
		let inHand: number[] = [];
		for(let i=0; i<a; i++) {
			inHand.push(V[i]);
		}
		for(let i=0; i<b; i++) {
			inHand.push(V[N-i-1]);
		}
		let S: number = inHand.reduce((prev, current) => prev+current, 0);
		answer = Math.max(answer, S);
		inHand.sort((a, b) => a-b);
		let leftOps = K-a-b;
		for(let i=0; i<inHand.length && inHand[i]<0 && i<leftOps; i++) {
			S -= inHand[i];
			answer = Math.max(answer, S);
		}
	}
}

console.log(answer);


Measured memory_bytes: 33776
from math import sqrt 

n = int(input())

x = int(sqrt(n))
if n == 2:
    print(0)
    exit()
ans = n-1
for i in range(2, x+1):
    y = dt = n//i
    while n//dt == n//y and n%y <= n//y:
        if n//y == n%y:
            ans += y
            break
        y -= 1
        if y == 1:
            break
        # print x,y,ans
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s , t;
  cin>>s;
  for(int i=0;i<s.length();i++)
     cout<<"x";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol a,b,c=0,d=0;
  lol ans=INF;
  string s;
  cin >>s;
  if(s=="SUN") cout <<7<<'\n';
  else{
    if(s=="MON") cout <<6<<'\n';
    else{
      if(s=="TUE") cout <<5<<'\n';
      else{
	if(s=="WED") cout <<4<<'\n';
	else{
	  if(s=="THU") cout <<3<<'\n';
	  else{
	    if(s=="FRI") cout <<2<<'\n';
	    else cout <<1<<'\n';
	  }
	}
      }
    }
  }
  return 0;
}


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


void solve()
{
    string a,b;
    cin>>a>>b;
    ll j=0,i,na=a.size(),nb=b.size();
    if(na+1==nb)
    {
        for(i=0;i<na;i++)
        {
            if(a[i]!=b[i])
            {
                cout<<"No";
                j=1;
                break;
            }
        }
        if(j==0)
            cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    //cin>>t;
    t=1;

    while(t--)
    {
        solve();
    }
    return 0;
}


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

struct intint{
    int fir;
    int sec;
};


int main(){
    stack<int> S1;
    stack<intint> S2;
    char gr;
    int a,b,tot=0;
    intint pair;
    
    for(int i=0;cin>>gr;i++){
        if(gr=='\\')S1.push(i);
        else if(gr=='/'){
            if(S1.size()>0){
                a=S1.top();
                S1.pop();
                tot+=i-a;
                b=i-a;
                while(S2.size()>0 && S2.top().fir>a){
                    b+=S2.top().sec;
                    S2.pop();
                }
                pair.fir=a;pair.sec=b;
            S2.push(pair);
            }
        }
        
    }
    cout<<tot<<endl;
    
    vector<int> pond;
    while(S2.size()>0){
        pond.push_back(S2.top().sec);
        S2.pop();
    }
    reverse(pond.begin(),pond.end());
    cout << pond.size();
    for(int i=0;i<pond.size();i++){
        cout<<" "<<pond.at(i);
    }
    cout<<endl;
}






Measured memory_bytes: 3196
// https://beta.atcoder.jp/contests/abc069

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

void print_yes_no(bool cond, string yes = "Yes", string no = "No") { cout << (cond ? yes : no) << endl; }

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(6
2 7 1 8 2 8
)");
#endif
    int mul4 = 0, mul2 = 0, mul1 = 0;
    int n;
    stream >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        stream >> a;
        if (a % 4 == 0) mul4++;
        else if(a % 2 == 0) mul2++;
        else mul1++;
    }

    mul1 += mul2 % 2;
    print_yes_no(mul1 <= mul4 + 1);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    N = int(input())

    case = []

    for i in range(1, 10):
        for j in range(1, 10):
            case.append(i * j)

    if N in case:
        ans = 'Yes'

    else:
        ans = 'No'

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  int n,a[10000],sum=0;
  cin>>n;
  for(int i=0;i<n*2;i++){
    cin>>a[i];
  }
  sort(a,a+n*2);
  for(int i=0;i<n*2;i+=2){
    sum+=a[i];
  }
  cout<<sum<<"\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define M 1000000007
#define pb push_back
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



int dp[101][100001];
int n,w;
int val[10001],wt[10001];

int solve(int i,int V)
{
    //cout << i << " " << V  << endl;
    if(V==0)
        return 0;
    if(V<0 || i==n)
        return 999999999999;
    if(dp[i][V]!=-1)
        return dp[i][V];
    int x=solve(i+1,V);
    int y=wt[i]+solve(i+1,V-val[i]);
    dp[i][V]=min(x,y);
    return dp[i][V];

}
signed main()
{
    boost
   // #ifndef ONLINE_JUDGE 
   // NAYAN
   // #endif
   
    //int n;
    cin >> n >> w;
  //  cout << n << endl;
    int i,j;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=100000;j++)
        {
            dp[i][j]=-1;
        }
    }
   
    
    for(i=0;i<n;i++)
    {
        cin >> wt[i] >> val[i];
    }
    int ans;
    for(i=100000;i>=0;i--)
    {
        
        ans=solve(0,i);
      //  cout << ans << " " << w << endl;
        if(ans<=w)
            break;
    }
    cout << i << endl;
    


}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
vector<int> vec[35];
int main(){
	int n;
	cin >> n;
	int cnt = 0;
	int sm = 0, i;
	vector<int> v;
	if(n == 3){
		cout << 2 << " " << 3 << " " << 25 << endl; return 0;
	}
	int g = 0;
	for(i = 1; cnt + 2 < n; i++){
		if(i % 2 == 0 || i % 3 == 0 || i % 5 == 0) cout << i << " ", sm = (sm + i) % 30, cnt++, g = __gcd(g, i);
	}
	// for(; cnt+1 < n; i++){
	// 	if()
	// }
	for(; i <= 30000; i++){
		if((i % 2 == 0 || i % 3 == 0 || i % 5 == 0)){vec[i % 30].push_back(i);}
	}
	for(int i = 0; i < 30; i++){
		for(int j = i + 1; j < 30; j++){
			if(!vec[i].empty() && !vec[j].empty() && (i + j + sm) % 30 == 0){
				cout << vec[i][0] << " " << vec[j][0] << endl;
				g = __gcd(g, __gcd(vec[i][0], vec[j][0]));
				assert(g == 1);
				return 0;
			}
		}
		if((2 * i + sm) % 30 == 0 && vec[i].size() >= 2){
			cout << vec[i][0] << " " << vec[i][1] << endl;
			g = __gcd(g, __gcd(vec[i][0], vec[i][1]));
			assert(g == 1);
			return 0;
		}
	}
	assert(0);
}

Measured memory_bytes: 384
import math
n,a,b = map(int,input().split())
li = list(map(int,input().split()))
sakai = math.ceil(b/a)
ans = 0
for i,l in enumerate(li):
    if i == 0:
        continue
    #print(ans,i,l-li[i-1],sakai)
    if l-li[i-1]>=sakai:
        ans += b
    else:
        ans += a*(l-li[i-1])
print(ans)

Measured memory_bytes: 62704