akhauriyash/Code-Regression huggingface dataset:
chomp($n=<>);
chomp($h=<>);
@h=split/ /,$h;

$sum=$h[0];
for($i=0;$i<$n;$i++){
	if($h[$i+1]-$h[$i]>0){
    	$sum+=$h[$i+1]-$h[$i];
    }
}
print $sum;

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int n, m;
    n = s.size();
    m = t.size();

    vector< vector<int> > dp(n+1, vector<int>(m+1, 0));

    s = " "+s;
    t = " "+t;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    // for (auto i : dp) {
    //     for (auto j : i) 
    //         cout << j << " ";
    //     cout << endl;
    // }
    
    string ans = "";
    while (dp[n][m] != 0) {
        if (s[n] == t[m]) {
            ans = s[n] + ans;
            n--;
            m--;
        }
        else if (dp[n-1][m] < dp[n][m-1])
            m--;
        else
            n--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 2e5 +5;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    int n;
    cin>>n;
    if(n>=30)
    {
        printf("Yes\n");
        return;
    }
    printf("No\n");

}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}


template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os,set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3644
import java.util.Scanner;

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

		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			int sum=0,maxi=0,mini=1000;
			for(int i=0;i<n;i++){
				int a=sc.nextInt();
				sum+=a;
				maxi=Math.max(maxi,a);
				mini=Math.min(mini,a);
			}
			System.out.println((sum-maxi-mini)/(n-2));
		}

		return;
	}
}


Measured memory_bytes: 28544
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();

        int[] arr = new int[n + 1];
        Arrays.fill(arr, 0);
        for (int i = 0; i < n; ++i) {
            if (i + 1 < n && s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i + 1] = arr[i] + 1;
            else
                arr[i + 1] = arr[i];
        }

        for (int i = 0; i < q; ++i) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(arr[r] - arr[l]);
        }
    }
}

Measured memory_bytes: 67508
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int c[100000][11][11];
int main(){
	CLR(c);
	int cnt=0;
	vector<int>res;
	while(1){
		int N;
		cin>>N;
		if(N==0)break;
		res.PB(N);
		int sumr=0;
		REP(i,N){
			REP(j,N){
				cin>>c[cnt][i][j];
				c[cnt][i][N]+=c[cnt][i][j];
				c[cnt][N][j]+=c[cnt][i][j];
			}
			c[cnt][N][N]+=c[cnt][i][N];
		}
		cnt++;
	}
	REP(i,cnt){
		REP(j,res[i]+1){
			REP(k,res[i]+1){
				cout<<setw(5)<<right<<c[i][j][k];
			}
			cout<<endl;
		}
	}
	return 0;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char b;
map<char,char> pair_dict;
pair_dict['A']='T';
pair_dict['T']='A';
pair_dict['G']='C';
pair_dict['C']='G';
cin>>b;
cout<<pair_dict[b]<<endl;

system("pause");
return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll N=ii();
    vector<ll> A;
    REP(i,0,N){
        A.push_back(ii());
    }
    ll ret=0;
    REP(i,0,N){
        REP(j,i+1,N){
            REP(k,j+1,N){
                ll a=A[i], b=A[j], c=A[k];
                if(a!=b&&b!=c&&c!=a){
                    if(a+b>c&&b+c>a&&c+a>b){
                        ret++;
                    }
                }
            }
        }
    }
    oie(ret);
    return 0;
}


Measured memory_bytes: 3632
a,b,c=map(int,input().split())
k=int(input())
count1=0
while a>=b:
    b=2*b
    count1+=1
count2=0
while b>=c:
    c=2*c
    count2+=1
if count1+count2<=k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9112
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut rate = vec![0; 9];

    for i in 0..n {
      if 1 <= a[i] && a[i] <= 399 {
        rate[0] += 1;
      }
      else if 400 <= a[i] && a[i] <= 799 {
        rate[1] += 1;
      }
      else if 800 <=  a[i] && a[i] <= 1199 {
        rate[2] += 1;
      }
      else if 1200 <= a[i] && a[i] <= 1599 {
        rate[3] += 1;
      }
      else if 1600  <= a[i] && a[i] <= 1999 {
        rate[4] += 1;
      }
      else if 2000 <= a[i] && a[i] <= 2399 {
        rate[5] += 1;
      }
      else if 2400 <= a[i] && a[i] <= 2799 {
        rate[6] += 1;
      }
      else if 2800 <= a[i] && a[i] <= 3199 {
        rate[7] += 1;
      } else {
        rate[8] += 1;
      }
    }

    let mut count = 0;
    for i in 0..8 {
      if rate[i] > 0 {
        count += 1;
      }
    }

    let m
     = if count > 0 {
       count
     } else {
       1
     };

    println!("{} {}", m, count + rate[8]);
}


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

pll norm(ll x,ll y)
{
  ll g=__gcd(abs(x),abs(y));
  x/=g;
  y/=g;
  if(x<0)return mp(-x,-y);
  else return mp(x,y);
}


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


ll n,ans=0;cin>>n;
map<ll,ll>m;
vl a(n);
rep(i,0,n)
{
cin>>a[i];
m[a[i]]++;
}

for(auto x:m)
{
  if(x.ss>=x.ff)ans+=x.ss-x.ff;
  else 
  ans+=x.ss;

}
cout<<ans<<"\n";


return 0;

}


Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> ans(n + 1);	
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int v = x * x + y * y + z * z + x * y + y * z + z * x;
				if (v <= n) {
					ans[v]++;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 3676
N = int(input())

A = [0]+list(map(int,input().split()))+[0]

B = []
for i in range(N+1):
    B.append(abs(A[i+1]-A[i]))
S = sum(B)

for i in range(1,N+1):
    print(S + abs(A[i+1]-A[i-1]) - B[i-1] - B[i])

Measured memory_bytes: 14040
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using ll = long long;

using namespace std;

ll pow_mod(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

ll factorial_mod(ll a, ll p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

ll sum_digit(ll N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

ll gcd(ll a,ll b) {
	if (!b)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int xa,xb,ya,yb;

int main(){
	scanf("%d %d %d %d", &xa,&ya,&xb,&yb);
	printf("%d ", xb + ya - yb);
	printf("%d ", yb+xb-xa);
	printf("%d ", xa + ya - yb);
	printf("%d", ya + xb - xa);
	return 0;
}

Measured memory_bytes: 256
'use strict';
(function(input){
  input=input.trim().split(/\n/);
  var firstLine=input[0].split(/\s+/).map(x=>x-0);
  const H=firstLine[0],W=firstLine[1];
  const K=Math.pow(10,9)+7;
  input.shift();
  const dp=new Array(H+1).fill(0).map(x=>new Array(W+1).fill(0));
  dp[0][1]=1;
  for(let i=1;i<=H;i++){
    for(let j=1;j<=W;j++){
      let p=(input[i-1][j-1]==='.');
      dp[i][j]=p?((dp[i-1][j]+dp[i][j-1])%K):0;
    }
  }
  console.log(dp[H][W]);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 28848
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]) {
	vector<int> v;
	int in;
	while(scanf("%d", &in) == 1) {
		v.push_back(in);
		//cout << in;
	}
	sort(v.begin(), v.end(), greater<int>());
	for(int i = 0; i < 3; ++i)
		printf("%d\n", v[i]);
}

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

int main(){
  
  int n;
  cin>>n;
  double sum = 0.0;
  
  for(int i=0; i<n; i++){
    int b;
    cin>>b;
    sum+=(double)1.0/b;
  }
  
  cout<<1.0/sum<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a;
  int b;
  char buf1[20];
  fgets(buf1, 20, stdin);
  sscanf(buf1, "%d" "%d", &a, &b);
  
  int d;
  d = a + b;
  if(d < 10){
  printf("%d \n", d);
  }
  else{
  printf("error \n");
  }
  
  return 0;
}

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

long long gcd(long long a, long long b) {
    if (a == 0 || b == 0) return 1ll;
    while (b) swap(a = a % b, b);
    return a;
}

struct Ratio {
    long long d, n;
    Ratio(long long d_ = 0, long long n_ = 1) : d(d_), n(n_) {}
    Ratio& operator+=(Ratio other) { return *this = reduct(Ratio(d * other.n + other.d * n, n * other.n)); }
    Ratio& operator-=(Ratio other) { return *this = reduct(Ratio(d * other.n - other.d * n, n * other.n)); }
    friend Ratio operator+(const Ratio& lhs, const Ratio& rhs) { Ratio t(lhs); return t += rhs; }
    friend Ratio operator-(const Ratio& lhs, const Ratio& rhs) { Ratio t(lhs); return t -= rhs; }
    friend Ratio reduct(Ratio r) {
        long long g = gcd(r.d, r.n);
        Ratio t(r.d / g, r.n / g);
        if (t.n < 0) t.d = -t.d, t.n = -t.n;
        return t;
    }
    friend ostream& operator<<(ostream& os, const Ratio& r) {
        if (r.n == 1) return os << r.d; return os << r.d << '/' << r.n;
    }
};

inline bool endswith(const string& s, const string& t) {
    return s.size() < t.size() ? false : s.compare(s.size() - t.size(), t.size(), t) == 0;
}

Ratio solve(const string& dir) {
    Ratio a(0);
    for (int l = int(dir.size()), n = 0; l > 0; ++n) {
        if (endswith(dir.substr(0, l), "west")) a += Ratio(90, 1 << n), l -= 4;
        else a -= n ? Ratio(90, 1 << n) : 0, l -= 5;
    }
    return a;
}

int main() {
    for (string dir; cin >> dir, dir != "#";) cout << solve(dir) << endl;
}

Measured memory_bytes: 3000
#include<iostream>
#include<algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N=110000;
PII a[N];
bool st[N];
int ans;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i].first>>a[i].second;
    sort(a+1,a+1+n);
    //reverse(a+1, a+1+n);
    int cnt=1;
    int ans=0;
    priority_queue<int>q;
    for(int i=1;i<=m;i++){
        while(a[cnt].first<=i&&cnt<=n){
            q.push(a[cnt].second);
            cnt++;
        }
        if(q.empty())continue;
        ans+=q.top();
        q.pop();
    }
  
    
    cout<<ans<<endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

int main(){
    int N;
    ll K;
    cin >> N >> K;
    string S;
    cin >> S;

    vi diffs(3*N, 0);
    int offset = 0;

    for(int i=0;i<N;i++) {
        if (S[i] != "BA"[(N+i)%2]) {
            diffs[i] = 1;
        }
    }

    while (K > 0 && offset < N) {
        if (diffs[offset] != N%2) {
            diffs[offset] = diffs[offset] ^ 1;
        } else {
            offset++;
        }
        K--;
    }

    if (N%2 == 1 && K > 0) {
        if (K%2 == 1) diffs[offset] ^= 1;
    }

    for (int i=0;i<N;i++) cout << "BA"[(N+i+diffs[offset+i])%2];
    cout << endl;


    return 0;
}


Measured memory_bytes: 3076
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n=gif
a=gi

puts (a.max - a.min).abs


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int Nr[MAX_N], N;
bool isCan(int k) {
	int minAbs = MAX_N * 10, val = -1;
	for(int i=1; i<2*N-1; i++) {
		int nowAbs = min(abs(N-1-i), abs(N-1-i+1));
		if((Nr[i] >= k) == (Nr[i-1] >= k) && minAbs > nowAbs) minAbs = nowAbs, val = (Nr[i] >= k);
	}
	if(val == -1) val = (Nr[0] >= k);
//	printf("%d -> %d\n", k, val);
	return val;
}
int main() {
	cin >> N;
	for(int i=0; i<2*N-1; i++) scanf("%d", &Nr[i]);
	int ans = -1;
	for(int l=1, r=2*N-1; l<=r; ) {
		int m = (l+r) >> 1;
		if(isCan(m)) ans = m, l = m+1;
		else r = m-1;
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 1152
function max(a, b) {
  if (a < b) return b
  return a
}

const main = (input) => {
  const [a, b, k] = input.trim().split(' ').map(n => Number(n))
  let taka = a;
  let aoki = b;
  if (a <= k) {
    taka = 0
    aoki = max(b-(k-a), 0)
  } else {
    taka = a - k
  }
  console.log(taka + ' ' + aoki)
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<cstdio>
#include<iostream>
using namespace std;
int a[5],b[5]={0,1,0,-1};
int n=3,k,ans;
int main()
{
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	scanf("%d",&k);
	for(int i=1;i<=n;++i)
	{
		if(k>=a[i])k-=a[i],ans+=a[i]*b[i];
		else
		{
			ans+=k*b[i];
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3748
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())

ans = 0

for i in range(1<<len(s)):
    ttl = []
    memo = s[0]
    for j in range(1,len(s)):
        if (i>>j)&1:
            memo += s[j]
        else:
            ttl.append(int(memo))
            memo = s[j]
    ttl.append(int(memo))
    
    ans += sum(ttl)
    ttl = []

print(ans//2)




Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
using namespace std;
int sx[25];
int cai[25];
int jf[25];

int main()
{
	int n;
	int sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&sx[i]);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&cai[i]);
		sum+=cai[i];
	}
	
	for(int i=0;i<n-1;i++)
	{
		scanf("%d",&jf[i]);
	}
	for(int i=1;i<n;i++)
	{
		if(sx[i]-1==sx[i-1])
		{
		//	printf("test%d %d %d i=%d\n",sx[i],sx[i-1],jf[i-2],i);
			sum+=jf[sx[i]-2];
		}
	}
	printf("%d",sum);
	
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define DEBUG(x) cout << #x"=" << x << endl

#define INFTY INT_MAX/3

#define MAX_N

int main(void) {

	int a, b;

	cin >> a >> b;

	if (a > 0 && b > 0) cout << "Positive" << endl;
	else if ((b == 0 && a <= 0) || (a == 0 && b >= 0) || (a == 0 && b == 0) || (a < 0 && b > 0)) cout << "Zero" << endl;
	else if (a < 0 && b < 0) {
		if ((b - a + 1) % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>


long long lcd(long long p, long long q) {
	long long upper,lower,r;

	if (p >= q) upper = p, lower = q;
	else upper = q, lower = p;
	r = upper % lower;
	if (r)return lcd(lower, r);
	else return lower;
}

int main(void) {
	long long a, b;
	long long c, flag;
	long long ans = 0;

	scanf("%lld %lld", &a, &b);
	c = lcd(a, b);
	for (long long i = 2; i <= sqrt(c); i++) {
		flag = 0;
		while (c%i==0) {
			c /= i;
			flag = 1;
		}
		if (flag) ans++;
	}
	if (c > sqrt(c))ans++;
	printf("%lld", ans + 1);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,x,y,z,i=0,h=0,j=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(x==2) j++;
    
    else if(x%2==0) h++;
    else if(x < 2 ) h++;   
    else if(x > 2){
    for(y=3;y*y<=x;y+=2){
	z=x%y;
	if(z==0)break;
        
      }
    if(z!=0) j++;
    }
    }
  
  
  printf("%d\n",j);

  return 0;
}

Measured memory_bytes: 596
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var d = new int[m, 2];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            d[i, 0] = int.Parse(line[0]) - 1;
            d[i, 1] = int.Parse(line[1]);
        }
        getAns(n, m, d);
    }
    static void getAns(int n, int m, int[,] d)
    {
        int istart, iend;
        if (n == 1) { istart = 0; iend = 9; }
        else if (n == 2) { istart = 10; iend = 99; }
        else { istart = 100; iend = 999; }
        for (int i = istart; i <= iend; i++)
        {
            var t = i.ToString();
            var ok = true;
            for (int j = 0; j < m; j++)
                if (t[d[j, 0]] - '0' != d[j, 1]) { ok = false; break; }
            if (ok) { Console.WriteLine(i); return; }
        }
        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 13140
/*#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop(void);

int top, S[1000];

int main(){
  int x,y,top = 0;
  char s[100];

  while(scanf("%s", s) != EOF){
    // if(scanf("%s", s) != EOF) break;
    if ( s[0] == '+' ){
      y = pop();
      y += pop();
      push(y);

    } else if ( s[0] == '-' ){
      y = pop();
      y -= pop();
      push(y);

    } else if ( s[0] == '*' ){
      y = pop();
      y *= pop();
      push(y);


    } else {
      x = atoi(s);
      push(x);

    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int a){
  S[++top] = a;
}

int pop(){
  top--;
  return S[top+1];
  }*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//int S[100],top = 0;

int main(){
  int x,y;
  char s[100];
  int S[100],top = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      y = S[top--];
      y += S[top--];
      S[++top] = y;

    } else if ( s[0] == '-' ){
      y = S[top--];
      y = -1*y + S[top--];
      S[++top] = y;

    } else if ( s[0] == '*' ){
      y = S[top--];
      y *= S[top--];
      S[++top] = y;

    } else {
      x = atoi(s);
      S[++top] = x;

    }
  }
  //x = atoi(S[top--]);
    x = S[top];

  printf("%d\n",x);

  return 0;
}



Measured memory_bytes: 2044
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if (N.contains("7")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
			
		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 35716
def prime_factor(x):
    
    prime_factor=[]
    
    for i in range(2,int(x**0.5)+1):
        if x==1: break

        count = 0
        while x%i == 0:
            x //= i
            count += 1
        if count>0:
            prime_factor.append((i,count))
    
    if x>1: prime_factor.append((x,1))
    
    return prime_factor

def count(x):
    ret = 1
    for i in range(1,x):
        if i*(i+1)//2 <= x:
            ret = i
        else:
            break
    return ret

n = int(input())
ans = 0
for p,esum in prime_factor(n):
    ans += count(esum)
print(ans)

Measured memory_bytes: 9476
#include <iostream>
#include <array>

using namespace std;

bool IsEasyToTap(string dance) {
    enum eStep {
        Step_Odd = 0,
        Step_Even,
        Step_Num,
    };

    array<char, Step_Num> difficult_poistion = {};
    difficult_poistion.at(Step_Odd)     = 'L';
    difficult_poistion.at(Step_Even)    = 'R';

    for(int i = 0; i < static_cast<int>(dance.length()); ++i) {
        if((i + 1) % 2 == 0) {
            if(dance.at(i) == difficult_poistion.at(Step_Even)) {
                return false;
            }
        } else {
            if(dance.at(i) == difficult_poistion.at(Step_Odd)) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    string dance;
    cin >> dance;

    string result_str = (IsEasyToTap(dance)) ? "Yes" : "No";
    cout << result_str;

    return 0;
}

Measured memory_bytes: 256
#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 n; cin >> n;
    n %= 10;
    if( n == 3){
        cout << "bon" << endl;
    }else if(
        n == 0
        || n == 1
        || n == 6
        || n == 8
    ){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;

}

Measured memory_bytes: 3620
n = int(input())
d = []
for i in range(n):
    D = list(map(int,input().split()))
    d.append(D)
num = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        num += 1
    else:
    	num = 0
    if num == 3:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 9228
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
mozi = input()
a_list = []
for i in range(n):
    if mozi[i] == 'W':
        a_list.append(0)
    else:
        a_list.append(1)

r_count = sum(a_list)
w_count = n - r_count
start = r_count
count = 0
for i in range(r_count):
    if a_list[i] == 0:
        count += 1
        while True:
            if a_list[start] == 1:
                start += 1
                break
            else:
                start += 1
print(count)


Measured memory_bytes: 10920
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    cout << N * (N - 1) / 2 << endl;

    return 0;
}


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

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

if __name__ == '__main__':

    n = int(input())
    A = [int(a) for a in input().split()]

    q = partition(A, 0, n-1)

    A[q] = "[" + str(A[q]) + "]"
    print(" ".join(map(str, A)))



Measured memory_bytes: 16376
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
inline int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
ll a[maxn],b[maxn],c[maxn<<1],sum[maxn],n;
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),b[i]=read();
	ll ans=0,tmp=0;
	for(int i=1;i<=n;i++)ans+=a[i];
	for(int i=1;i<=n;i++)tmp+=b[i];
	ans=min(ans,tmp);
	for(int i=1;i<=n;i++)c[2*i]=a[i],c[2*i-1]=b[i];
	sort(c+1,c+2*n+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+c[i];
	for(int i=1;i<=n;i++){
		tmp=0;int now=n;
		if(a[i]>=c[now])tmp+=a[i],now--;
		if(b[i]>=c[now])tmp+=b[i],now--;
		ans=min(ans,tmp+sum[now]);
	}printf("%lld\n",ans);return 0;
}

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

int main(){
    string input;
    int cnt = 0;
    while(cin >>input){
        bool okflag = true;
        for(int i = 0; i < input.size() / 2; i++){
            if(input[i] != input[input.size() - 1 - i]){
                okflag = false;
                break;
            }
        }
        if(okflag) cnt++;
    }
    cout <<cnt <<endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second 
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ans;
  map<int,int> d;
  cin>>n;
  for(int i=1;i<=sqrt(n);i++){
    for(int j=1;j<=sqrt(n);j++){
      for(int k=1;k<=sqrt(n);k++){
	d[pow(i,2)+pow(j,2)+pow(k,2)+(i*j)+(i*k)+(j*k)]++;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<d[i]<<"\n";
  }
}


Measured memory_bytes: 6068
#include <iostream>
#include <vector>
using namespace std;
struct edge{
    int a;
    int b;
    edge(int x, int y){
        a = x;
        b = y;
    }
};
int w[100000];
vector<edge> v[100000];
void f(int x, int y, int z){
    w[x] = z;
    for(int i=0;i<v[x].size();i++){
        if(v[x][i].a != y){
            f(v[x][i].a, x, (z+v[x][i].b)%2);
        }
    }
}
int main(void){
    int n, a, b, c;
    cin >> n;
    for(int i=0;i<n-1;i++){
        cin >> a >> b >> c;
        a--;
        b--;
        v[a].push_back(edge(b, c));
        v[b].push_back(edge(a, c));
    }
    f(0, -1, 0);
    for(int i=0;i<n;i++){
        cout << w[i] << endl;
    }
}


Measured memory_bytes: 9088
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean lock = true;
		int n = sc.nextInt();
		String[] u = new String[n];
		for (int i = 0; i < n; i++)
			u[i] = sc.next();
		int m = sc.nextInt();
		String[] t = new String[m];
		for (int i = 0; i < m; i++)
			t[i] = sc.next();
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (t[i].equals(u[j]) && lock) {
					System.out.println("Opened by " + t[i]);
					lock = false;
					break;
				} else if (t[i].equals(u[j]) && !lock) {
					System.out.println("Closed by " + t[i]);
					lock = true;
					break;
				} else if (j == n - 1)
					System.out.println("Unknown " + t[i]);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 21640
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n;
inline bool qu(int i)
{
    cout<<'?';
    for(int j=0;j++<n;)
        cout<<' '<<i+j;
    cout<<endl;
    string s;
    cin>>s;
    return s[0]=='B';
}
inline bool qu(vector<int>&v)
{
    cout<<'?';
    for(int&t:v)
        cout<<' '<<t;
    cout<<endl;
    string s;
    cin>>s;
    return s[0]=='B';
}
int i,j;
int x[1010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    int f=qu(0);
    int s=1;
    int e=n;
    while(s<e)
    {
        int m=s+e>>1;
        if(qu(m)!=f)
            e=m;
        else
            s=m+1;
    }
    for(i=0;i++<n*2;)
        x[i]=-1;
    x[s]=f;
    x[s+n]=!f;
    for(i=0;i++<n*2;)
    {
        if(x[i]!=-1)
            continue;
        if(s<=i&&i<=s+n)
        {
            vector<int>v;
            for(j=s;j<=s+n;j++)
                if(j!=i)
                    v.eb(j);
            int q=qu(v);
            x[i]=!q;
        }
        else
        {
            vector<int>v;
            for(j=s+1;j<s+n;j++)
                v.eb(j);
            v.eb(i);
            int q=qu(v);
            x[i]=q;
        }
    }
    cout<<"! ";
    for(i=0;i++<2*n;)
        cout<<(x[i]==1?'B':'R');
    cout<<endl;
    return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    long long N, K;
    cin >> N >> K;

    long long ans = (N - 2) / (K - 1) + 1;
    // a/b の切り上げは (a-1)/b+1 で求まる
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*Flow..................*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#include <cctype>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",(long long)x)
#define pc(x) printf("%c",(char)x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%0.10lf\n",x);
#define pll(x) printf("%lld\n",(long long)x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,y,z,w) {cerr<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;}
#define ts(x,u,y,z,w) {cerr<<x<<" "<<#u<<"="<<u<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;}
#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
#define trace3(x, y, z) {cerr << #x << "=" << x << " " << #y << "=" << y << " " << #z << "=" << z << endl;}
using namespace std;
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const multiset<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

int main()
{
   int i,j;
   ll q,h,s,d;
   sll(q),sll(h),sll(s),sll(d);
   ll n;
   sll(n);
   h=min(h,2*q);
   s=min(s,min(2*h,4*q));
   d=min(min(d,2*s),min(4*h,8*q));
   ll x=(n/2)*d+(n%2)*s;
   pll(x);
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

int n;
string s;
int dp[30010][10];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  
  cin>>n;
  cin>>s;
  rep(i,n+2){
    rep(j,10) dp[i][j]=inf;
  }

  rrep(i,n){
    rep(j,10){
      dp[i][j]=dp[i+1][j];
    }
    dp[i][s[i]-'0']=i+1;
  }

  int ans=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        int it=dp[0][i];
        if(it==inf) continue;
        it=dp[it][j];
        if(it==inf) continue;
        it=dp[it][k];
        //cout<<i<<' '<<j<<' '<<k<<endl;
        if(it==inf) continue;
        //cout<<i<<' '<<j<<' '<<k<<endl;
        ans++;
      }
    }
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	vector<int> exist(9, 0);

	rep(i, n) {
		if (a[i] >= 3200) {
			exist[8]++;
			continue;
		}
		rep(j, 8) {
			if (a[i] >= 400 * j && a[i] < 400 * (j + 1))
				exist[j]++;
		}
	}

	int colorSum = 0;
	rep(i, 8) {
		if (exist[i] >= 1) colorSum++;
	}

	cout << max(colorSum, 1) << " " << colorSum + exist[8] << endl;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())

def divisor_two_power(N):
    for i in range(64):
        if N % (2 ** i) != 0:
            return i - 1
    return -1

if A == B and B == C:
    if A % 2 == 0:
        print(-1)
    else:
        print(0)
else:
    print(min(min(map(divisor_two_power, [A, B, C])) + 1,
              min(map(divisor_two_power, [A + B, B + C, A + C]))))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;


signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int count=0;
		for(int j=0;j<i;j++)
		{
			if(arr[j]<arr[i])
			{
				count++;
			}
		}
		int count1=0;
		for(int j=i+1;j<n;j++)
		{
			if(arr[j]<arr[i])
			{
				count1++;
			}
		}
		int res=(k+1)*(k);
		res/=2;
		res%=MOD;
		ans+=((count1*res)%MOD);
		ans%=MOD;
		res=(k-1)*(k);
		res/=2;
		res%=MOD;
		ans+=((count*res)%MOD);
		ans%=MOD;

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

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

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = 0;

	while (l==0) {
		c -= b;
		if (c <=0) {
			cout << "Yes";
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3612
# coding: utf-8
# Your code here!
N = int(input())
def div(n):
    cnt = 0
    N = n
    for i in range(1,N+1):
        if n % i == 0:
            cnt += 1
    if cnt == 8:
        return True
    else:
        return False

ans = 0
for i in range(1,N+1):
    if i % 2 == 1:
        if div(i):
            ans += 1

print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int N, M;
  ll ans = 0;
  cin >> N >> M;
  if (N == 1 && M == 1)
    ans = 1;
  else if (N == 1)
    ans = M - 2;
  else if (M == 1)
    ans = N - 2;
  else
    ans = 1ll * (N - 2) * (M - 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
	int n, k; cin >> n >> k;
	int l[n], sum = 0;
	int i;
	for (i = 0; i < n; i++) {
		cin >> l[i];
	}

	sort(l, l + n);

	for (i = n - 1; i >= n - k; i--) {
		sum += l[i];
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (X, Y) = listOfLong()
    val ans = if (Math.abs(X - Y) <= 1) "Brown" else "Alice"
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 37796
def cont(a, K):
    contL = []
    j = 1
    while j < W: 
        cnt = 1
        while a[j] == a[j-1] and a[j] != None:
            cnt += 1
            j += 1
        if cnt >= K:
            contL.append((j-cnt, j, a[j-1]))
        j += 1
    return contL

def fall(d):
    for j in range(W):
        for k in range(H):
            if d[k][j] == None:
                for i in range(k, 0, -1):
                    d[i][j] = d[i-1][j]
                d[0][j] = None
    return d


import copy 

H, W, K = map(int, input().split())
c = [list(map(int, list(input().strip()))) + [0] for _ in range(H)] #; print2(c)

candL = [(i, j) for i in range(H) for j in range(W)]

ans = 0
for i_push, j_push in candL:   
    d = copy.deepcopy(c)    #; print2(d); print()
    d[i_push][j_push] = None
    d = fall(d)             #; print2(d)
    n = -1
    ans0 = 0
    while True:
        flag = False
        n += 1
        for i in range(i_push, -1, -1):
            cL = cont(d[i], K)       #;print(cL)
            for j0, j1, val in cL:
                d[i][j0:j1] = [None]*(j1-j0)                
                ans0 += val *(j1-j0) * 2**(n)  #;print(val, val *(j1-j0) * 2**(n))
                flag = True
        if not flag: break
        #print2(d); print()
        d = fall(d)          #;print('i_push, j_push', i_push, j_push, ans0) ; print2(d);print() 
    ans = max(ans, ans0)    
print(ans)    

Measured memory_bytes: 9352
#include <stdio.h>

int main()
{
	int n;
	int l, r;
	int ans = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++ ) {
		scanf("%d %d", &l, &r);

		ans = ans + (r - l + 1);
	}

	printf("%d\n", ans);

	return 0;
}


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

using namespace std;
using ll = long long;

ll powll(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base; base = base * base; exp >>= 1; } return res;}
ll mod_pow(ll base,ll exp, ll mod) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base % mod; base = base * base % mod; exp >>= 1; } return res % mod;}


int main()
{
    ll n;
    cin >> n;
    vector<ll> in;
    map<tuple<ll,ll,ll>,ll> fl;


    for(ll i = 0; i < n; i++){
        string s; cin >> s;
        if(!count(s.begin(), s.end(), '.')) {
            in.push_back(stol(s));
        } else {

            while(s.back() == '0')s.pop_back();
            if(s.back() == '.') {
                s.pop_back();
                in.push_back(stol(s));
            } else {
                
                auto itr = find(s.begin(), s.end(), '.');
                ll dig = s.end() - itr  -1;
                s.erase(itr);
                ll num = stol(s);

                ll tw = 0, fi = 0;
                while(num % 2 == 0) {
                    tw++; num /= 2;
                }
                while(num % 5 == 0) {
                    fi++; num /= 5;
                }
                fl[{tw,fi,dig}]++;
            }
        }
    }

    for(auto dig : in) {
        ll tw = 0, fi = 0;
        while(dig % 2 == 0) {
            tw++; dig /= 2;
        }
        while(dig % 5 == 0) {
            fi++; dig /= 5;
        }
        fl[{tw,fi,0}]++;
    }


    ll sum = 0;
    ll sum2 = 0;
    for(auto i : fl) {
        ll a, b , c;
        tie(a, b, c) = i.first;
        for(auto j : fl) {
            ll a2, b2, c2;
            tie(a2, b2, c2) = j.first;
            if(c + c2 <= min(a + a2, b + b2)) {
                if(i == j)sum += (i.second) * (j.second - 1) / 2;
                else sum2 += (i.second) * j.second;
            }
        }
    }

    cout << sum + sum2 / 2 << endl;
}

Measured memory_bytes: 5368