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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int MAXN=3002;
int n;
double p[MAXN],dp[MAXN][MAXN];


int main(){
//    #ifdef Javier
//        freopen(".in", "r", stdin);
//    #endif // Javier

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }

    dp[0][0]=1.0;


    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1-p[i]);
            else
               dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
        }
    }


    double sol=0;
//    for(int i=0;i<=n;i++)
//       {
//         for(int j=0;j<=n;j++)
//         {
//             cout<<dp[i][j]<<" ";
//         }
//         cout<<endl;
//       }
    for(int i=n/2+1;i<=n;i++)
        sol+=dp[n][i];

    cout<<fixed;
    cout<<setprecision(9)<<sol;


    //cout<<sol;

    return 0;
}



Measured memory_bytes: 68992
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n,m,x;
	cin>>n>>m>>x;
	ll arr[n][m+1];
	for(int a=0;a<n;a++)
	{
		for(int b=0;b<=m;b++)
		cin>>arr[a][b];
	}
	ll y,z,ans=9999999999999999;
	for(int a=0;a<=pow(2,n)-1;a++)
	{
		ll crr[m+1]={0};
		for(int b=n-1;b>=0;b--)
		{
		//	cout<<((1<<b)&a)<<" ";
			y=((1<<b)&a);
			if(y>=1)
			y=1;
			if(y==1)
			{
				for(int c=0;c<=m;c++)
				{
					crr[c]+=arr[b][c];
				}
			}
		}
//		cout<<endl;
		z=1;
		for(int aa=1;aa<=m;aa++)
		{
			if(crr[aa]<x)
			{
				z=0;
				break;
			}
		}
		if(z==1)
		{
			ans=min(ans,crr[0]);
		}
	}
	if(ans==9999999999999999)
	cout<<"-1";
	else
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4088
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k xs

solve :: Int -> Int -> U.Vector Int -> Int
solve n k xs = go 0 sums 40
  where
    sums :: U.Vector Int
    sums = U.concatMap (U.scanl1' (+) . flip U.drop xs) $ U.generate n id

    go !res !acc !i
        | i < 0 = res
        | U.length acc' >= k = go res' acc' (i - 1)
        | otherwise = go res acc (i - 1)
      where
        !res' = setBit res i
        acc' = U.filter (\x -> x .&. res' == res') acc

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

using namespace std;
using ll = long long;

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  bool ans = true;
  if (s[0] != s[1]) ans = false;
  if (s[1] == s[2]) ans = false;
  if (s[2] != s[3]) ans = false;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){
    int n;cin>>n;
    if(n%10==3){
        cout<<"bon"<<endl;
    }
    else if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
	io();
	string s;
	cin>>s;
	ll len=s.size()/2;
	//cout<<s.substr(0,len)<<endl;
	//cout<<s.substr(len+1,len)<<endl;
	if(s.substr(0,len)==s.substr(len+1,len))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  bool ans = true;
  for(char a = 'a'; a <= 'z'; ++a){
    int count = 0;
    rep(i, s.length()){
      if(s[i] == a) count++;
    }
    if(count >= 2)  ans = false;
  }
  if(ans) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b==15)printf("+\n");
	else if(a*b==15)printf("*\n");
	else printf("x\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    Yes((a * b) % 2 != 0);
}



Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Storable as V

main=do
    n<-readLn::IO Int
    as<-V.fromList.sort.map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO(V.Vector Int)
    print $ tsearch (f as) (0,n-1)

-- 三分探索 (最小値)
-- b<-[l..r]において最小のf bを求める
tsearch f (l,r)
    | (r-l)<3  = minimum $ map f [l..r]
    | c1 < c2  = tsearch f (l,b2)
    | c1 == c2 = tsearch f (b1,b2)
    | c1 > c2  = tsearch f (b1,r)
    where
        c1 = f b1
        c2 = f b2
        b1 = l+(r-l)`div`3
        b2 = l+((r-l)`div`3)*2

f as b = V.sum $ V.map (\a->abs $ a-e) as
        where e = as V.! b

Measured memory_bytes: 31100
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n;
	cin >> n;
	int a[n+5];
	rep(i,n){
		cin >> a[i];
	}
	ll ans = 0;
	ll cost = 1000; 
	for(int i = 0; i < (n-1); i++){
		if(a[i+1] > a[i]){
			ll num = cost/a[i];
			cost += (a[i+1] - a[i])*num;
		}
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#if (( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

#define pb push_back
#define mp make_pair
#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const int INF = 0x3f3f3f3f;

const int N = 200010;

int T;
int n;
LL p;

vector<LL> w[4];
LL base, ww;
LL v;

int cnt[4];
int sum[4][111];


int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    while(cin >> n >> p)
    {
        cin >> base >> v;
        for(int i=0; i<4; i++)
        {
            w[i].clear();
        }

        w[0].push_back(v);
        for(int i=2; i<=n; i++)
        {
            cin >> ww >> v;
            w[ww-base].push_back(v);
        }

        for(int i=0; i<4; i++)
        {
            sort(w[i].begin(), w[i].end());
            reverse(w[i].begin(), w[i].end());
            cnt[i] = w[i].size();
        }

        clr(sum, 0);
        for(int i=0; i<4; i++)
        {
            //debug(i, cnt[i]);
            for(int j=1; j<=cnt[i]; j++)
            {
                sum[i][j] = sum[i][j-1] + w[i][j-1];
                //debug(i, j, sum[i][j]);
            }
        }


        LL ans = 0;
        for(int a=0; a<=cnt[0]; a++)
        {
            if(a * base > p) continue;

            for(int b=0; b<=cnt[1]; b++)
            {
                if(a * base + b * (base + 1) > p) continue;

                for(int c=0; c<=cnt[2]; c++)
                {
                    if(a * base + b * (base + 1) + c * (base + 2) > p) continue;

                    for(int d=0; d<=cnt[3]; d++)
                    {
                        if(a * base + b * (base + 1) + c * (base + 2) + d*(base + 3) > p) continue;

                        LL tmp = sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
                        ans = max(ans, tmp);
                    }

                }
            }
        }
        cout << ans << endl;


    }


   return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
int n;
ll f[205][205];
ll ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{f[i][j]=__gcd(i,j);}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	for(int k=1;k<=n;k++)
	{
		ans+=f[f[i][j]][k];
	}
	printf("%lld",ans);
	
	return 0;
} 

Measured memory_bytes: 4152
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def check(vec, init_pos, target_pos):
    base = 8000
    dp = [False] * 16001
    dp[init_pos + base] = True

    for i in range(len(vec)):
        dp, dp_prev = [False] * 16001, dp
        for j in range(16001):
            if (
                j - vec[i] >= 0
                and dp_prev[j - vec[i]]
                or j + vec[i] <= 16000
                and dp_prev[j + vec[i]]
            ):
                dp[j] = True

    return dp[target_pos + base]


def main():
    S = readline().strip()
    x, y = map(int, readline().split())

    idx = len(S)
    for i, c in enumerate(S):
        if c == 'T':
            idx = i
            break

    init_x = idx
    step = [[0] for _ in range(2)]
    i = 0
    for c in S[idx:]:
        if c == 'T':
            i = 1 - i
            step[i].append(0)
        else:
            step[i][-1] += 1

    ok = check(step[0], init_x, x) and check(step[1], 0, y)

    if ok:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 93808
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
ll MOD = 1e9+7;
ll MOD2 = 998244353;
int inf = 1e8;
ll INF = 1e16;
string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll A[N], B[N], C[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A+N), sort(B, B+N), sort(C, C+N);
    ll ans = 0;
    rep(i, N){
        ll a = lower_bound(A, A+N, B[i]) - A;
        ll c = C+N - upper_bound(C, C+N, B[i]);
        ans += a*c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
N = int(input())
A = list(int(i) for i in input().split())
count_m = 0
count_z = 0

for i in A:
  if i < 0:
    count_m += 1
  elif i == 0:
    count_z += 1

A_abs = [abs(i) for i in A]
if count_m%2 == 0 or (count_m+count_z)%2 == 0:
  print(sum(A_abs))
  
else:
  A_min = A_abs.index(min(A_abs))
  A_abs[A_min] = A_abs[A_min]*(-1)
  print(sum(A_abs))

Measured memory_bytes: 14224
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

def main():
	s = input()
	K = INT()

	strings = set()
	for  i in range(1, K+1): #文字列の長さ : K番目で長さがK以上のを考える必要はない。
		for j in range(len(s)-i+1): #スタート地点
			#print(j, i)
			strings.add(s[j:j+i])

	print(sorted(strings)[K-1])

if __name__ == '__main__':
	main()


Measured memory_bytes: 6612
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, Ans = 0;cin >> N;
queue<ll> Q;
vector<ll> V;

Q.push(3);Q.push(5);Q.push(7);

ll q = 0;

while(1){

    q = Q.front();
  
    if(q > N)break;
    
    Q.pop();

    Q.push(10*q + 3);Q.push(10*q + 5);Q.push(10*q + 7);

    V.push_back(q);

}

rep(i, 0, V.size()){

    string s = to_string(V[i]);

    bool C = 0, D = 0, E = 0;

    rep(j, 0, s.size()){

        if(s[j] == '3')C = 1;

        if(s[j] == '5')D = 1;

        if(s[j] == '7')E = 1;

    }

    if(C && D && E)Ans++;

}

cout << Ans;

}

Measured memory_bytes: 4156
from itertools import accumulate

def resolve():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    x = [i if i > 0 else 0 for i in a]
    ans = 0
    acc = [0] + list(accumulate(x))
    aaa = [0] + list(accumulate(a))
    for i in range(n+1-k):
        tmp = acc[i] + acc[-1] - acc[i+k]
        if tmp > ans:
            ans = tmp
        if tmp + aaa[i+k] - aaa[i] > ans:
            ans = tmp + aaa[i+k] - aaa[i]

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 18496
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <cstdlib>


using namespace std;

int main(){
  string s;
  int n=0;
  cin >> s;

  int red, blue;
  red = 0;
  blue = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] == '0') red++;
    else blue++;
  }
  cout << 2*min(red, blue) <<endl;

  return 0;
}


Measured memory_bytes: 512
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,M,Q)=readInts() |> triple

let query=
  let tbl=Array2D.create (N+2) (N+2) 0
  for _ in 1..M do
    let (l,r)=readInts()|>pair
    // imos
    Array2D.modify tbl 1 r inc
    Array2D.modify tbl 1 (N+1) dec
    Array2D.modify tbl (l+1) r dec
    Array2D.modify tbl (l+1) (N+1) inc
  for i in 1..(N+1) do
    for j in 1..(N+1) do
      Array2D.modify tbl i j ((+) tbl.[i-1,j])
  for i in 1..(N+1) do
    for j in 1..(N+1) do
      Array2D.modify tbl i j ((+) tbl.[i,j-1])
  fun p q -> tbl.[p,q]

for _ in 1..Q do
  let (p,q) = readInts() |> pair
  query p q |> printfn "%d"

Measured memory_bytes: 19320
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ou.println(Math.max(Integer.parseInt(sc.next()) * Integer.parseInt(sc.next()) , Integer.parseInt(sc.next()) * Integer.parseInt(sc.next())));
		ou.flush();
    }
}

Measured memory_bytes: 35916
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		// argumentの取得
		Scanner s = new Scanner(System.in);

		
                // String型
	    String x = s.next();
        String y = s.next().substring(0,1);
      
		// 戻り値の返却
		System.out.println("A" + y + "C");
	
	} 
}

Measured memory_bytes: 21716
import collections

A = input()
B = input()

A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()

A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9708
a = [ list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if b in a[j]:
            a[j][a[j].index(b)]=0
if a[0][0]==a[1][1]==a[2][2] or a[0][2]==a[1][1]==a[2][0]:
    print("Yes")
elif a[0][0]==a[0][1]==a[0][2] or a[1][0]==a[1][1]==a[1][2] or a[2][0]==a[2][1]==a[2][2]:
    print("Yes")
elif a[0][0]==a[1][0]==a[2][0] or a[0][1]==a[1][1]==a[2][1] or a[0][2]==a[1][2]==a[2][2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#define LL long long
 
 
using namespace std;
 
int main() {
    int w, a, b;
    cin >> w >> a >> b;
    if (a + w < b)
    {
        cout << b - (a + w) << endl;
    }
    else if (b <= a + w && a + w <= b + w || b <= a && a <= b + w)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << a - (b + w) << endl;
    }
    return 0;
}   

Measured memory_bytes: 256
N,M=map(int,input().split())
if N>=M:
    X=[int(i) for i in input().split()]
    print(0)
else:
    X=[int(i) for i in input().split()]
    a=sorted(X)
    d=[]
    for i in range(M-1):
        d.append(a[i+1]-a[i])
    k=sorted(d)
    print(sum(k[:M-N]))


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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

string z;
int N;

signed main() {
    cin >> N;
    cout << 0 << endl;
    cin >> z;

    int l = 0, r = N-1;
    while ( r-l > 1 ) {
        int mid = (l+r) / 2;
        string s;
        cout << mid << endl;
        cin >> s;
        if ( mid % 2 == 0 ) {
            if ( z == s ) l = mid;
            else r = mid;
        } else {
            if ( z == s ) r = mid;
            else l = mid;
        }
    }

    cout << l << endl;
    cout << r << endl;
}


Measured memory_bytes: 852
from math import ceil

def isOK(length):
  ans = 0
  for a in A:
    ans += ceil(a / length) - 1
  return ans <= k

n, k = map(int, input().split())
A = list(map(int, input().split()))

start, end = 0, 10**9 + 1
while True:
  mid = (start + end) // 2
  if mid == 1:
    print(mid)
    exit()
  prev = mid - 1
  if isOK(mid):
    if isOK(prev):
      end = mid
    else:
      print(mid)
      exit()
  else:
    start = mid


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

int main()
{
  char a[11]={},b[11]={},c[11]={};
  int l_a,l_b,l_c;
  
  scanf("%s %s %s",a,b,c);
  
  l_a=strlen(a);
  l_b=strlen(b);
  
  if(a[l_a-1]==b[0]&&b[l_b-1]==c[0])
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
# E - ∙ (Bullet)
import sys
from collections import defaultdict

readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())

# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。 
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)

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

zeros = 0
for i in range(N):
    A, B = map(int, readline().split())
    # (0, 0)のイワシは他の全てのイワシと仲が悪いため、
    # 1匹のみでしか選ぶことができない。最後にこの数を足す。
    if A == 0 and B == 0:
        zeros += 1
    # (?, 0),(0, ?)のイワシは、?がどのような数字であろうとも
    # この組合せであれば仲が悪い。一律、(1,0)(0,-1)として考える。
    elif A == 0:
        d_S[(1, 0)] += 0
        d_T[(0, -1)] += 1
    elif B == 0:
        d_S[(1, 0)] += 1
        d_T[(0, -1)] += 0
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        # いずれもマイナスの場合、傾きはプラスになる
        if A < 0 and B < 0:
            A *= -1
            B *= -1
        if A * B > 0:
            d_S[(A, B)] += 1
            d_T[(B, -A)] += 0
        # 片方がマイナスの場合、必ずAがマイナスになるよう揃える
        else:
            if A > B:
                A, B = B, A
            d_S[(-A, B)] += 0
            d_T[(B, A)] += 1

ans = 1
for (si, sj), s_cnt in d_S.items():
    t_cnt = d_T[(sj, -1*si)]
    tmp = 0
    tmp += pow(2, s_cnt, MOD) - 1
    tmp += pow(2, t_cnt, MOD) - 1
    tmp += 1
    ans = (ans * tmp)%MOD

ans -= 1
ans += zeros

print(ans%MOD)

Measured memory_bytes: 74144
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll n; cin >> n;
  ll x = 26;
  vector<char> res;
  while(n > 0) {
    ll y = n % 26;
    char c = 'a' + y - 1;
    if(y == 0) c = 'z';
    res.push_back(c);
    n /= 26;
    if(y == 0) n--;
  }

  reverse(res.begin(), res.end());
  for(auto val: res) cout << val;
  cout  << "\n";


  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
using namespace std;

#define N 200000

int n;
int a[N];
long long sa[N+1];

int main()
{
	long long ans = INT64_MAX;

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

	sa[0] = 0;
	for( int i = 0; i < n; i++ ) {
		sa[i+1] = a[i] + sa[i];
	}

	int l = 1;
	int r = 3;

	for( int m = 2; m <= n - 2; m++ ) {
		while(l < m && abs( (sa[l] - sa[0]) - (sa[m] - sa[l]) ) >= abs( (sa[l+1] - sa[0]) - (sa[m] - sa[l+1]) ) ) {
			l++;
		}
		while(r < n && abs((sa[n] - sa[r]) - (sa[r] - sa[m]) ) >= abs( (sa[n] - sa[r+1]) - (sa[r+1] - sa[m]) ) ) {
			r++;
		}

		long long p = abs(sa[l] - sa[0]);
		long long q = abs(sa[m] - sa[l]);
		long long rr = abs(sa[r] - sa[m]);
		long long s = abs(sa[n] - sa[r]);

		long long ma = max(p, max(q, max(rr,s)));
		long long mi = min(p, min(q, min(rr,s)));

		ans = min(ans, ma - mi);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <limits>

using namespace std;

vector<int> enum_common_divisor(int x,int y)
{
	if (x < y)
	{
		swap(x,y);
	}

	vector<int> ret;
	for (int i = 1; i <= x; i++) {
		if (x % i == 0 && y % i == 0)
		{
			ret.push_back(i);
		}
	}
	return ret;
}

int main(void) {
	int A, B, K;
	cin >> A >> B >> K;
	K--;
	vector<int> ans = enum_common_divisor(A,B);
	sort(ans.rbegin(),ans.rend());
	cout << ans[K] << endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c>=22)
    {
        cout << "bust";
    }
    else
    {
        cout << "win";
    }
    return 0;
}


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

#define xx first
#define yy second

const int N = 3001;

double p[N], dp[N][N];

void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i <= n; i++)
        fill(dp[i], dp[i] + n + 1, 0.0);
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++)
        for (int h = 0; h <= i; h++) {
            int t = i - h;
            dp[h + 1][t] += p[i] * dp[h][t];
            dp[h][t + 1] += (1.0 - p[i]) * dp[h][t];
        }
    double ans = 0.0;
    for (int h = 0; h <= n; h++) {
        int t = n - h;
        if (h > t)
            ans += dp[h][t];
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << setprecision(15);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 74172
#include <stdio.h>

int main(void);

int main(void){

  long n, max, min;
  long sum = 0;
  long value[20000];

  long i = 0;

  scanf("%ld", &n);

  do {
    scanf("%ld", &value[i]);
    i++;
  } while(i < n);

  /*合計を計算*/
  for (i = 0; i < n; i++) {
    sum += value[i];
  }

  min = value[0];
  max = value[0];

  for (i = 1; i < n; i++) {

    /*最小値*/
    if(min >= value[i]) {
      min = value[i];
    }

    /*最大値*/
    if(max <= value[i]) {
      max = value[i];
    }
    
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}



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

#define ll long long

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

	int k=1;
	while(a>0 && c>0)
	{
		if(k&1) c-=b;
		else a-=d;

		k++;
	}

	if(a>0) puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
   int a ,b, c,i;

for(int i=1;i<=3000 ;i++){
    cin >> a >> b;
if (a>b)
{
   c=a;
   a=b;
   b=c;
}
   if (a==0 && b==0)
   break ;
   else
  
   cout << a << " " << b<< endl;
}
}


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

int main() {
	int N;
	cin >> N;
	int A[N][3],dp[N][3];
	for(int i = 0; i < N; i++) 
	   cin >> A[i][0] >> A[i][1] >> A[i][2];
	memset(dp, 0, sizeof dp);
	for(int i=0; i<N; i++) {
		 if(i==0) {
		 	  dp[i][0]=A[i][0];
		 	  dp[i][1]=A[i][1];
		 	  dp[i][2]=A[i][2];
		 }
		 else{
		 	 dp[i][0] = max(dp[i-1][1],dp[i-1][2])+A[i][0];
		 	 dp[i][1] =max(dp[i-1][0],dp[i-1][2])+A[i][1];
		 	 dp[i][2] =max(dp[i-1][0],dp[i-1][1])+A[i][2];
		 }	   
	}
	 //for(int i=0; i<N; i++)
	   //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	cout<<max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));       
	return 0;
}



Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <string>

std::string deduplicate(std::string s) {
    std::sort(s.begin(), s.end());
    s.erase(std::unique(s.begin(), s.end()), s.end());
    return s;
}

int main() {
    using std::cin;
    using std::string;

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        string f = deduplicate(s.substr(0UL, i));
        string r = deduplicate(s.substr(i));

        int duplications = 0;
        for (char fc : f) {  // 𝑶(n * n/2 * n/2)
            if (r.find(fc) != string::npos) duplications++;
        }
        ans = std::max(ans, duplications);
    }

    std::cout << ans << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N ;
  
  int A,W,T,R;
  A = 0;
  W = 0;
  T = 0;
  R = 0;
  
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if( S == "AC" ) A++;
    else if( S == "WA" ) W++;
    else if( S == "TLE") T++;
    else R++;
  }
  
  cout << "AC"<< " x " << A << endl;
  cout << "WA"<< " x " << W << endl;
  cout << "TLE"<< " x " << T << endl;
  cout << "RE"<< " x " << R << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////

#define N 8001


int main(){
    string s;cin>>s;
    int len=s.size();
    vector<int>x,y;
    int f=1;
    int pos=0;
    while(pos<=len-1){
        int count=0;
        while(s[pos]=='F'&&pos<=len-1){pos++;count++;}
        if(f)x.push_back(count);
        else y.push_back(count);
        f=1-f;
        pos++;
    }
    int sizex=x.size(),sizey=y.size();
    bool dp[2][2*N];for(int i=0;i<=2*N-1;i++)dp[0][i]=dp[1][i]=false;
    dp[0][N+x[0]]=true;
    for(int i=1;i<sizex;i++){
        for(int j=0;j<=2*N-1;j++){
            if(j-x[i]>=0&&j+x[i]<=2*N-1)dp[i&1][j]=dp[(i+1)&1][j-x[i]]||dp[(i+1)&1][j+x[i]];
            else if(j-x[i]>=0)dp[i&1][j]=dp[(i+1)&1][j-x[i]];
            else if(j+x[i]<=2*N-1)dp[i&1][j]=dp[(i+1)&1][j+x[i]];
        }
    }
    int ansx;cin>>ansx;
    if(!dp[(sizex+1)%2][ansx+N]){
        cout<<"No"<<endl;
        return 0;
    }
    /*for(int i=0;i<=2*N-1;i++){
        if(dp[(sizex-1)%2][i])cout<<i-N<<" ";
    }cout<<endl;*/
    for(int i=0;i<=2*N-1;i++)dp[0][i]=dp[1][i]=false;
    dp[1][N]=true;
    for(int i=0;i<sizey;i++){
        for(int j=0;j<=2*N-1;j++){
            if(j-y[i]>=0&&j+y[i]<=2*N-1)dp[i&1][j]=dp[(i+1)&1][j-y[i]]||dp[(i+1)&1][j+y[i]];
            else if(j-y[i]>=0)dp[i&1][j]=dp[(i+1)&1][j-y[i]];
            else if(j+y[i]<=2*N-1)dp[i&1][j]=dp[(i+1)&1][j+y[i]];
        }
    }
    /*for(int i=0;i<=2*N-1;i++){
        if(dp[(sizey-1)%2][i])cout<<i-N<<" ";
    }cout<<endl;*/
    int ansy;cin>>ansy;
    if(!dp[(sizey+1)%2][ansy+N]){
        cout<<"No";
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

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

    uint16_t m[n];
    uint16_t min = UINT16_MAX;
    for (auto i = 0; i < n; i++) {
        cin >> m[i];
        x -= m[i];
        if (min > m[i]) min = m[i];
    }

    cout << (x / min) + n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
 
int main()
{
 
  int n, s, i;
  double sum, sum2, x;
 
  while(scanf("%d", &n), n)
  {
    sum=0;
    sum2=0;
    
    for(i=0;i<n;i++)
    {
      scanf("%d", &s);

      sum+=s;
      sum2+=s*s;
    }
 
    sum/=n;
    x=sum2/n-sum*sum;
 
    printf("%f\n", sqrt(x));
  }
 
  return 0;
}


Measured memory_bytes: 2052
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
def gcd_l(a):
  tmp=a[0]
  for i in range(len(a)):
    tmp=gcd(tmp,a[i])
  return tmp
tmp=gcd_l(a[1:])
p=set()
for i in range(1,int(a[0]**0.5)+1):
  if a[0]%i==0:
    if i>tmp:
      p.add(i)
    if a[0]//i>tmp:
      p.add(a[0]//i)
if len(p)==0:
  print(tmp)
  exit()
p=sorted(list(p),reverse=True)
for x in p:
  b=[not a[i]%x for i in range(n)]
  if sum(b)==n-1:
    print(x)
    exit()
print(tmp)

Measured memory_bytes: 16116
#include<stdio.h> 
#define INFTY 2000000000
#define MAX 200000


long long merge(int S[], int left, int mid, int right){

	int n1 , n2;
	int i , j , k;
	long long c = 0;
	
	n1 = mid - left;
	n2 = right - mid;
	
	int L[MAX/2+2] , R[MAX/2+2];
	
	for( i = 0; i < n1; i++ ){
		L[i] = S[left + i];
	}
	for( i = 0; i < n2; i++ ){
		R[i] = S[mid + i];
	}
	
	L[n1] = R[n2] = INFTY;
	
	i = 0;
	j = 0;
	
	for ( k = left; k < right; k++ ){
		
		if( L[i] <= R[j] ){
			S[k] = L[i];
			i++;
		}else{
			S[k] = R[j];
			j++;
			c += n1 - i;
		}
	}
	
	return c;
}

long long mergeSort(int S[], int left, int right){
	
	int mid;
	long long v1 , v2 , v3;
	
	if ( left+1 < right ){
		
		mid = (left + right)/2;
		v1 = mergeSort(S, left, mid);
		v2 = mergeSort(S, mid, right);
		v3 = merge(S, left, mid, right);
		return v1 + v2 + v3;
		
	}else{ return 0; }
	
}

int main( void ){
	
	int n;
	int S[MAX];
	int i;
	
	long long ans;
	
	scanf( "%d" , &n );
	
	for( i = 0; i < n; i++ ){
		scanf( "%d" , &S[i] );
	}
	
	ans = mergeSort(S, 0, n);
	printf( "%lld\n" , ans );
	
	return 0;
	
}


Measured memory_bytes: 3416
#include<stdio.h>

int main(){
  char N[4];
  int sum = 0;
  for(int i=0; i<4; i++){
    scanf("%c", &N[i]);
  }
  for(int j=0; j<4; j++){
    if(N[j] == '2')
     sum++;
  }
  printf("%d\n", sum);
  return 0;
}

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

using namespace std;

using ll = long long;

void Solve() {
    string s;
    cin >> s;

    const int n = s.size();
    bool is_sym = true;
    for (int i = 1; i < n; ++i)
        if (s[i - 1] != s[n - i - 1]) is_sym = false;

    if (s[0] == '0' || s.back() == '1' || !is_sym) {
        cout << "-1\n";
        return ;
    }

    int prev = n - 1;
    for (int v = n - 2; 0 <= v; --v) {
        cout << v + 1 << ' ' << prev + 1 << '\n';
        if (s[v] == '1') prev = v;
    }
}

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

    Solve();

    return 0;
}


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

int main(){
    int a;
    cin >> a;
    cout << a+ a *a +a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(v)  v.begin(),v.end()

int main(){
   ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

   int n;
   cin>>n;
   string s;
   cin>>s;
   int q;
   cin>>q;
   set<int> c[26];

   for(int i=0;i<n;i++){
        c[s[i]-'a'].emplace(i);
   }

   while(q--){
      int t;
      cin>>t;
      if(t==1){
         int i;char x;
         cin>>i>>x;
         i--;
         c[s[i]-'a'].erase(i);
         c[x-'a'].emplace(i);
         s[i]=x;
      }
      else{
         int l,r;
         cin>>l>>r;
         l--;r--;
         int count = 0;
         for(int i=0;i<26;i++){
             auto it_lo = c[i].lower_bound(l);
             if(it_lo!=c[i].end() and *(it_lo)<=r){
               count++;
             }
         }
           
             cout<<count<<endl; 
      }
   }

   return 0;
}



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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  vector<int> vec;
  for(int i=1;i<200;i++) {
    if(a%i==0&&b%i==0) vec.push_back(i);
  }
  cout << vec[vec.size()-k] << endl;
}

Measured memory_bytes: 256
import numpy as np
S=input()

if S == "SUN":
  print(7)
if S == "MON":
  print(6)

if S == "TUE":
  print(5)

if S == "WED":
  print(4)

if S == "THU":
  print(3)

if S == "FRI":
  print(2)

if S == "SAT":
  print(1)




Measured memory_bytes: 21764
import java.util.Scanner;

public class Main {

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

        int N = Integer.parseInt(scanner.next());
        int D = Integer.parseInt(scanner.next());
        int X = Integer.parseInt(scanner.next());
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(scanner.next());
        }
        scanner.close();

        int eatenCount = 0;
        for (int i = 1; i <= D; i++) {
            for (int j = 0; j < N; j++) {
                if (A[j] == 1 || i % A[j] == 1) {
                    eatenCount++;
                }
            }
        }

        System.out.println(X + eatenCount);
    }
}


Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

string S;

int main() {
    getline(cin, S);
    for (int i = 0; i < S.length(); ++i) {
        char c = S[i];
        if (islower(c)) {
            printf("%c", toupper(c));
        } else if (isupper(c)) {
            printf("%c", towlower(c));
        } else {
            printf("%c", c);
        }
    }
    cout << "\n";
}



Measured memory_bytes: 3200
import math

a,b = list(map(int,input().split()))

count = 1
while True:
  if math.floor(count*0.08) == a and math.floor(count*0.1) == b:
    print(count)
    break
  if math.floor(count*0.08) > a or math.floor(count*0.1) > b:
    print('-1')
    break
  count += 1

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> A(N, 0);

	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector<long long> D(N - 1, 0);
	for (long long i = 0; i < N - 1; i++) {
		D[i] = A[i + 1] - A[i];
	}
	
	long long ans = 1000;
	long long stock = 0;
	long long dum = 0;
	for (long long i = 0; i < N - 1; i++) {
		if (D[i] > 0) {
			dum = ans / A[i];
			stock += dum;
			ans -= A[i] * dum;
		}
		else if (D[i] < 0) {
			ans += A[i] * stock;
			stock = 0;
		}
	}

	ans += A[N - 1] * stock;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
N,X = map(int,input().split())
xs = list(map(int,input().split()))

cums = [0]
for x in xs:
    cums.append(cums[-1] + x)

ans = float('inf')
for k in range(1,N+1):
    tmp = k*X
    if tmp >= ans:
        break
    if 2*k >= N:
        tmp += 5 * cums[-1]
        ans = min(ans, tmp)
        break
    tmp += 5 * (cums[-1] - cums[-1 - 2*k])
    ri = N - 2*k
    m = 7
    while True:
        if ri <= k:
            tmp += m * cums[ri]
            break
        tmp += m * (cums[ri] - cums[ri - k])
        m += 2
        ri -= k
    ans = min(ans, tmp)

print(ans + N*X)

Measured memory_bytes: 26404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int countc=0,countf=0;
		for(int i=0;i<s.length();i++) {
			if(s.substring(i, i+1).equals("C"))countc++;
			if(countc!=0&&s.substring(i, i+1).equals("F"))countf++;
		}
		if(countc!=0&&countf!=0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 23380
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        int[] b = new int[m];
        int[] c =new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int j = 0; j < m; j++) {
            b[j] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                c[i] += a[i][j] * b[j];
            }
            System.out.println(c[i]);
        }
    }
}
            

                
        


Measured memory_bytes: 40088