akhauriyash/Code-Regression huggingface dataset:
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    string s;
    cin>>s;

    if (s[0]==s[1]and s[1]==s[2] and s[1]=='R')
        cout<<3<<endl;
    else if (s[0]==s[1] and s[1]==s[2] and s[1]=='S')
        cout<<0;
    else if (s[0]==s[1] and s[1]=='R'||s[1]==s[2] and s[1]=='R')
        cout<<2;
    else
        cout<<1;

return 0;
}

Measured memory_bytes: 3648
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		long n=s.nextLong(),a=s.nextLong(),b=s.nextLong();

		if((a-b)%2==0)
			System.out.println(Math.abs(a-b)/2);
		else
			System.out.println(Math.min(a-1,n-b)+(Math.abs(a-b)+1)/2);
	}
}


Measured memory_bytes: 21844
n, k = gets.chomp.split.map(&:to_i)
a = []
n.times do |i|
  a[i] = gets.to_i
end

a.sort!.reverse!
min = 1e10

(n-k + 1).times do |i|
  min = a[i] - a[k+i-1] if a[i] - a[k+i-1] < min
end
puts min

Measured memory_bytes: 4036
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int N =5;
int main(){
	int A[N];
	int B[N];
	REP(i,N){
		cin >> A[i];
		B[i] = 10-A[i]%10;
		if(B[i] ==10) B[i] = 0; 
	}
	
	
	int index=-1;
	int max = -1;
	REP(i,N){
		if(max < B[i]){
			max = B[i];
			index=i;
		}
	}
	
	int ans = 0;
	
	REP(i,N){
		if(i != index){
			if(B[i] != 0){
				ans += (A[i] /10 +1)*10;
			}else{
				ans += A[i];
			}
		}else{
			ans += A[i];
		}
	}
	
	cout << ans  << endl;
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int ans = 0;
    rep(i, n) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        swap(a[i], a[minj]);
        if (i != minj) ans++;
    }

    rep(i, n) {
        cout << a[i];
        if (i != n-1) cout << ' ';
    }
    cout << endl << ans << endl;
    return 0;
}



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

int main() {
vector<char> S(4);
  for(int i=0;i<4;i++){
   
    cin>>S.at(i) ;
  }
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout<<"Bad"<<endl;
  }
   
  else {
    cout<<"Good"<<endl;
  }
}
    

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

void check(vector<vector<int>> &ma,int now,vector<int> &used){
    used[now]=1;
    for(int i=0;i<ma[now].size();i++){
        if(ma[now][i]==1&&used[i]==0){
            check(ma,i,used);
        }
    }
}

int main(void){
    int n,m;
    int a,b;
    int ans=0;
    cin>>n>>m;
    vector<vector<int>> ma(n,vector<int>(n,0));
    vector<pair<int,int>> hen;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        ma[a-1][b-1]=1;
        ma[b-1][a-1]=1;
        hen.emplace_back(a,b);
    }
    for(int i=0;i<m;i++){
        vector<int> used(n,0);
        ma[hen[i].first-1][hen[i].second-1]=0;
        ma[hen[i].second-1][hen[i].first-1]=0;
        check(ma,hen[i].first-1,used);
        if(find(used.begin(),used.end(),0)!=used.end()){
            ans++;
        }
        ma[hen[i].first-1][hen[i].second-1]=1;
        ma[hen[i].second-1][hen[i].first-1]=1;
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef vector<int> vi;

int N,M; vi A;
void input()
{
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a; cin>>a; A.emplace_back(a);
    }
}

void solve()
{
    int sum=0;
    for(int i=0;i<M;++i){
        sum+=A[i];
        if(sum>N){
            cout<<-1<<endl;
            return;
        }
    }
    cout<<N-sum<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 1; i<=n;i++){
        for(int j =1;j<=n;j++){
            for(int k =1;k<=n;k++){
                 int temp = __gcd(j,k);
                 int res = __gcd(i,temp);
                 sum += res;
            }
        }
    }
    cout << sum ;
}









Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;

const int maxN = 100100;
const int INF = 1000000000;
ll a[maxN];
ll b[maxN];
ll c[maxN];
int n,m;
int main() {

	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		b[i] = b[i-1] + a[i];
		c[i] = b[i] % m;
	}
	sort(c+1,c+1+n);
	c[n+1] = INF + 20;
	int st=1,ed = 1;
	ll ans = 0;
	for(int i=1;i<=n;i++)
	{
		if(c[i+1] != c[i])
		{
			ed = i;
			ll len = ed - st + 1;
			if(c[i] == 0)
				ans += ((len + 1)*len/2);
			else
				ans += (len -1 )*len/2;
			st = i+1;
		}
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+100;
const ll MOD = 1e9+7;
using namespace std;

vector<int> g[MAX_N];
int h[MAX_N];
int n;

void dfs(int v,int p)
{
    for(auto x:g[v])
    {
        if (x==p)
            continue;
        h[x] = h[v]+1;
        dfs(x,v);
    }
}

int main()
{
    cin >> n;
    for(int i = 1;i<n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    int mx = 0,v = 1;
    for(int i = 1;i<=n;++i)
    {
        if (h[i]>mx)
            v = i;
        mx = max(mx,h[i]);
    }
    memset(h , 0 , sizeof h);
    dfs(v,0);
    mx = 0;
    for(int i = 1;i<=n;++i)
        mx = max(mx,h[i]);
    if (mx%3==1)
        cout << "Second";
    else
        cout << "First";
    return 0;
}


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

string s;

string rec(int &pos){
    string res = "";
    while(1){
        // end
        if(pos >= int(s.size()) || s[pos] == ']'){
            return res;
        }
        // begin Cipher
        if(s[pos]=='['){
            pos++;
            string tmp = rec(pos);
            reverse(tmp.begin(), tmp.end());
            res += tmp;
            pos++;
            continue;
        }
        int cnt = 0;
        // count +-
        while(1){
            if(s[pos]=='+') cnt++;
            else if(s[pos]=='-') cnt--;
            else break;
            pos++;
        }
        // Add Letter
        if(s[pos] == '?') res.push_back('A');
        else res.push_back(char('A'+((s[pos]-'A')+cnt%26+26)%26));
        pos++;
    }
}

int main() {
    while(cin >> s, s!="."){
        int i=0;
        cout << rec(i) << endl;
    }
    return 0;
}





Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second

const int MAXN = 2 * 1000 * 100 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;

int fact[MAXN], c[MAXN], w[MAXN], inv[MAXN], invf[MAXN];
vector <int> vec[MAXN];
vector <pii> mini;

void PreWork();

int main() {
	PreWork();
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> w[i];
		vec[c[i]].push_back(w[i]);
	}
	for (int i = 0; i < MAXN; i++)
		sort(vec[i].begin(), vec[i].end());
	int cnt[MAXN];
	for (int i = 0; i < MAXN; i++) {
		cnt[i] = 0;
		for (int j = 0; j < vec[i].size(); j++)
			cnt[i] += (vec[i][j] + vec[i][0] <= x);
		if (vec[i].size())
		   mini.push_back(pii(vec[i][0], i));
	}
	int ans = 1;
	sort(mini.begin(), mini.end());
	if(mini.size() < 2) {
		cout << 1;
		return 0;
	}
	pii good = mini[0];
	pii bad = mini[1];
	int AllForMin = 0;
	for (int i = 0; i < MAXN; i++) {
		if (!vec[i].size())
			continue;
		if (i != good.S) {
			int TheNumber = 0;
			if (vec[i][0] + good.F <= y)
				for (int j = 0; j < vec[i].size(); j++)
					if (vec[i][0] + vec[i][j] <= x || vec[i][j] + good.F <= y)
						AllForMin++, TheNumber++;
			ans = (ll)ans * invf[TheNumber] % MOD;
			//cerr << "bad " << i << ' ' << TheNumber << endl;
		} else {
			int TheNumber = 0;
			for (int j = 1; j < vec[i].size(); j++)
				if (vec[i][j] + vec[i][0] <= x || vec[i][j] + bad.F <= y)
					AllForMin++, TheNumber++;
			AllForMin++;
			TheNumber++;
			ans = (ll)ans * invf[TheNumber] % MOD;
			//cerr << "badd " << TheNumber << endl;
		}
	}
	//cerr << "good " << AllForMin << endl;
	ans = (ll)ans * fact[AllForMin] % MOD;
	cout << ans;
}

void PreWork() {
	fact[0] = fact[1] = inv[0] = inv[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MAXN; i++) {
	   fact[i] = (ll)fact[i - 1] * i % MOD;
	   inv[i] = (ll)inv[MOD % i] * (MOD - MOD / i) % MOD;
	   invf[i] = (ll)invf[i - 1] * inv[i] % MOD;
//	   if (i < 10)
//		   cerr << invf[i] << endl;
	}
}



Measured memory_bytes: 15352
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in range(M)]
for i in range(N):
	if t[2*i]<=M:
		v[t[2*i]-1].append(t[2*i+1])
z=0
q=[]
for i in range(M):
	for j in v[i]:
		heappush(q,-j)
	b=0
	if len(q):
		b=heappop(q)
	z-=b
print(z)


Measured memory_bytes: 24932
let rec solve n x =
  if n = x then x
  else 
    let y = (n - 1) / x in
    2 * x * y + solve x (n - x * y)

let () = Scanf.scanf "%d %d" (fun n x ->
  Printf.printf "%d\n"
    (if 2 * x <= n then n + solve (n - x) x
     else n + solve x (n - x)))


Measured memory_bytes: 384
#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;
	map<string,int> cnt;
	rep(i,n){
		string s;
		cin >> s;
		cnt[s]++;
	}
	cout << cnt.size() << endl;
}

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

#define INF (INT32_MAX/2)
#define MAX 200000

int N, Q;
string s;
int t[MAX];
int d[MAX];

bool check( int i, int lr )
{
	int n = s[i] - 'A';
	for( int j = 0; j < Q; j++ ) {
		if( n != t[j] ) {
			continue;
		}
		if( d[j] ) {
			i++;
		}
		else {
			i--;
		}
		if( i < 0 ) {
			if( lr ) {
				return false;
			}
			else {
				return true;
			}
		}
		if( i >= N ) {
			if( lr ) {
				return true;
			}
			else {
				return false;
			}
		}
		n = s[i] - 'A';

	}
	return false;
}

int main() {
	cin >> N >> Q >> s;
	for( int i = 0; i < Q; i++ ) {
		char ct, cd;
		cin >> ct >> cd;
		t[i] = ct -'A';
		d[i] = 0;
		if( cd == 'R' ) {
			d[i] = 1;
		}
	}

	int l = -1;
	int r = N;
	while( r - l > 1 ) {
		int m = (r + l) / 2;
		if( check( m, 0 ) ) {
			l = m;
		}
		else {
			r = m;
		}
	}
	int cl = l;
	l = -1;
	r = N;
	while( r - l > 1 ) {
		int m = (r + l) / 2;
		if( check( m, 1 ) ) {
			r = m;
		}
		else {
			l = m;
		}
	}
	int cr = r;
	int ans = max( cr - cl - 1, 0 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  sort(s.begin(), s.end());
  cout << (s[0] != s[2] ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"3 4
" => r"6",

r"2 2
" => r"1"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: i32,
        m: i32,
    }

    ((n - 1) * (m - 1)).to_string()
}


Measured memory_bytes: 4352
#include <stdio.h>
int main()
{
  int dice[2][6];
  int vector[3][4]={{0,2,5,3},{0,1,5,4},{1,2,4,3}};
  int i,j,k,l,m,c;
  for(i=0;i<2;i++)
  {
    for(j=0;j<6;j++)
    {
      scanf("%d",&dice[i][j]);
    }
  }
  for(i=0;i<2;i++)
  {
    for(j=0;j<4;j++)
    {
      int temp = dice[1][vector[i][0]];
      for(k=0;k<3;k++)
      {
	dice[1][vector[i][k]] = dice[1][vector[i][k+1]];
      }
      dice[1][vector[i][3]] = temp;
      c = 0;
      for(k=0;k<6;k++)
      {
	if(dice[0][k]==dice[1][k])c++;
      }
      if(c==6)break;
      for(m=0;m<3;m++){
	for(k=0;k<4;k++)
	{
	  int temp = dice[1][vector[m][0]];
	  for(l=0;l<3;l++)
	  {
	    dice[1][vector[m][l]] = dice[1][vector[m][l+1]];
	  }
	  dice[1][vector[m][3]] = temp;
	  c=0;
	  for(l=0;l<6;l++)
	  {
	    if(dice[0][l]==dice[1][l])c++;
	  }
	  if(c==6)break;
	}
	if(c==6)break;
      }
      if(c==6)break;
    }
    if(c==6)break;
  }
  if(c==6)printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;



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

	ll a = x;
	set<ll> s;
	int c = 0;
	
	while (s.find(a) == s.end()) {
		c++;
		s.insert(a);
		a = (a * a) % m;
	}

	if (c >= n) {
		ll ans = 0;
		for (int i = 0; i < n; i++) {
			ans += x;
			x = (x * x) % m;
		}
		cout << ans << endl;
		return 0;
	}

	ll ans = 0;
	ll c_begin = 0;
	
	ll c_sum = 0;
	for (auto it = s.begin(); it != s.end(); it++) {
		c_sum += *it;
	}

	for (int i = 0; i < n; i++) {
		if (x == a) {
			c_begin = i;
			break;
		}
		ans += x;
		
		x = (x * x) % m;
		
	}
	ll c_len = c - c_begin;
	c_sum -= ans;
	n -= c_begin;
	ans += c_sum * (n / c_len);
	n %= c_len;
	for (int i = 0; i < n; i++) {
		ans += x;
		x = (x * x) % m;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;

int main()
{
    int n, i, j, k;
    cin>>n;
    map<int, int>a;
    for(i=1;i<=n;i++)
        a[i]=0;
    for(i=1;i<n;i++)
    {
        cin>>j;
        a[j]++;
    }
    for(i=1;i<=n;i++)
        cout<<a[i]<<endl;
    return 0;
}



Measured memory_bytes: 12988
import java.util.Arrays;
import java.util.Scanner;

// ???????¢??????¨?????? LIS
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            int in = lower_bound(dp, a[i]);
            if (in < n) {
                dp[in] = a[i];
            }
        }
        System.out.println(lower_bound(dp, Integer.MAX_VALUE));
    }

    static int lower_bound(int a[], int border) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (border <= a[mid]) {
                r = mid;
            } else {
                l = mid;
            }
        }
        return r;
    }
}

Measured memory_bytes: 70432
#coding: utf-8

inputN, inputK = map(int, input().split())
inputA = list(map(int, input().split()))
minNumber = inputN
minPos = 0

if inputN == inputK:
    print (1)
elif inputN <= (inputK-1)*100000 + 1:
    for i in range(2, 100001):
        if inputN <= (inputK-1)*i + 1:
            print (i)
            break
else:

    for i in range(len(inputA)):
        if inputA[i] < minNumber:
            minNumber = inputA[i]
            minPos = i

    splitNumber = (inputN + 1) / (inputK - 1)
    print (int(splitNumber))


Measured memory_bytes: 14008
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_c();
}

fn solve_c() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (n, m): (usize, usize) = input!(r, usize, usize);
    let mut shops: Vec<(usize, usize)> = Vec::with_capacity(n);
    for _ in 0..n {
        let (price, inventry) = input!(r, usize, usize);
        shops.push((price, inventry));
    }
    shops.sort_by(|a, b| b.0.cmp(&a.0));
    let mut count_m = 0;
    let mut cost = 0;
    for _ in 0..n {
        let (price, inventry) = shops.pop().unwrap();
        if inventry + count_m > m {
            cost += (m - count_m) * price;
            break;
        } else {
            cost += inventry * price;
            count_m += inventry;
        }
    }
    println!("{}", cost);
}



Measured memory_bytes: 6396
// AOJ 1543 Changing Grids
// 2019.2.27 bal4u

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

#define INF 0x30303030
int H, W, N;
char map[17][22][22];
int T[17];
int mv[4][2] = { {-1,0},{1,0},{0,-1},{0,1} };
int SR, SC, GR, GC;  // start, goal
int visited[22][22];
int ans;

#define QMAX 10000000
typedef struct { char r, c; int t, s; } Q;
Q q[QMAX + 2]; int top, end;

// 幅優先探索
int bfs(int id)
{
	int i, r, c, t, s, rr, cc;
	int tmax;

	top = end = 0;
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
		if (map[id][r][c] == '#') visited[r][c] = INF;
		else if (visited[r][c] < INF) {
			q[end].r = r, q[end].c = c;
			q[end].t = T[id], q[end].s = visited[r][c];
			end++;
		}
	}
	tmax = T[id + 1];

	/*
	printf("id=%d, tmax=%d\n", id, tmax);
	for (r = 0; r < H; r++) {
		for (c = 0; c < W; c++) {
			if (visited[r][c] == INF) printf("-1 ");
			else printf("%2d ", visited[r][c]);
		}
		printf("\n");
	}
	*/

	while (top != end) {
		r = q[top].r, c = q[top].c, t = q[top].t, s = q[top].s;
		if (++top == QMAX) top = 0;
		if (r == GR && c == GC) {
			if (ans < 0 || s < ans) ans = s;
			continue;
		}
//		if (t >= tmax) continue;

		t++, s++;
		// 上下左右に移動
		for (i = 0; i < 4; i++) {
			rr = r + mv[i][0], cc = c + mv[i][1];
			if (rr < 0 || rr >= H || cc < 0 || cc >= W) continue;
			if (map[id][rr][cc] == '.') {
				if (t < tmax && s < visited[rr][cc]) {
					visited[rr][cc] = s;
					q[end].r = rr, q[end].c = cc, q[end].t = t, q[end].s = s;
					if (++end == QMAX) end = 0;
				}
			}
			if (map[id+1][rr][cc] == '.') {
				if (s < visited[rr][cc]) visited[rr][cc] = s;
			}
		}
	}
	return -1;
}

int main()
{
	int i, f, r, c;

	memset(visited, INF, sizeof(visited));  // 初期化

	// 入力処理
	scanf("%d%d", &H, &W);
	for (r = 0; r < H; r++) {
		scanf("%s", map[0][r]);
		for (c = 0; c < W; c++) {
			if (map[0][r][c] == 'S') SR = r, SC = c, map[0][r][c] = '.';
			else if (map[0][r][c] == 'G') GR = r, GC = c, map[0][r][c] = '.';
		}
	}
	scanf("%d", &N);
	T[N+1] = INF;

	for (i = 1; i <= N; i++) {
		scanf("%d", T + i);
		f = 0;    // すべてが'"'か
		for (r = 0; r < H; r++) {
			scanf("%s", map[i][r]);
			if (!f) for (c = 0; c < W; c++) if (map[i][r][c] == '.') f = 1;
		}
		if (!f) { N = i - 1; break; }
	}
	while (N > 0) {
		if (map[N][GR][GC] == '.') break;
		N--;
	}

	ans = -1;
	visited[SR][SC] = 0;
	for (i = 0; ; i++) {
		if (i > N) break;
		bfs(i);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2064
A=[[0 for j in range(3)] for i in range(3)]
B=[[0 for j in range(3)] for i in range(3)]
for i in range(3):
    a=list(map(int,input().split()))
    for j in range(3):
        A[i][j]=a[j]

N=int(input())
for i in range(N):
    b=int(input()) 
    for i in range(3):
        for j in range(3):
            if  A[i][j]==b:
                B[i][j]=1    

for i in range(3):
    count=0
    for j in range(3):
        if  B[i][j]==1:
            count+=1
    if count==3:
        print('Yes')
        exit()
            
            
for j in range(3):
    count=0
    for i in range(3):
        if B[i][j]==1:
            count+=1
        if count==3:
            print('Yes')
            exit()

       
if B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
    print('Yes')
    exit()
elif B[0][2]==1 and B[1][1]==1 and B[2][0]==1: 
    print('Yes')
    exit()
else:
    print('No')
    

Measured memory_bytes: 3064
n = int(input())
def input_def(n_num=2):
    input_val = []
    for i in range(n_num):
        input_val.append([i for i in map(int,input().split())])
    return input_val


para_val = input_def()
diff_val = 0
for i in range(n):
    a = para_val[0][i]-para_val[1][i]
    if a>= 0 :
        diff_val += a


print(diff_val)

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int max = 100000+5;
        PriorityQueue<Integer> pq = new PriorityQueue<>(10,Collections.reverseOrder());
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++) A[i]=sc.nextInt();
        int[] rec = new int[max+1];
        for(int i=0;i<N;i++) rec[A[i]]++;
        for(int i=1;i<=max;i++){
            if(rec[i]>0) pq.add(rec[i]);
        }
        if(pq.size()==1){
            System.out.println(1);
            System.exit(0);
        }
        while(pq.size()>1&&pq.peek()>1){
            int cur = pq.poll();
            if(cur>=3&&cur%2==1) {
                pq.add(1);
                continue;
            }
            if(cur%2==0){
                int next = pq.poll();
                if(next==1) pq.add(1);
                else{
                    pq.add(1);
                    pq.add(next-1);
                }
            }
        }
        System.out.println(pq.size());
    }
}


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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 3980
import java.util.Scanner;

public class Main {

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

	    String word = sc.next();
	    String result = "";
	    if (word.equals("Cloudy")) result = "Rainy";
	    if (word.equals("Rainy")) result = "Sunny";
	    if (word.equals("Sunny")) result = "Cloudy";

		System.out.println(result);

    }
}


Measured memory_bytes: 22608
a = input()

card_list = list(map((int),input().split(' ')))

sum_card = sum(card_list)

score = []
sunuke = 0

for i in range(int(a)-1):
    
    sunuke += card_list[i]
    score.append(abs(sum_card-2*sunuke))

print(min(score))
    
      



Measured memory_bytes: 24828
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

inline constexpr auto distance (size_t x, size_t y) noexcept
{
  return x < y ? y - x : x - y;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  ll n, k;
  cin >> n >> k;
  auto c = n % k;
  auto ans = min (c, abs (c - k));
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
2725 ??´??¨?????? 2_1 A
*/
import java.util.Scanner;

    public class Main{
        public void solve(){
        Scanner sc = new Scanner(System.in);
        int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		if(a<b){
		System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a==b){
			System.out.println("a == b");
		}
        }
    public static void main(String[]args){
    Main obj = new Main();
    obj.solve();
    }
    }

Measured memory_bytes: 17156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1e18;
const ll MOD = 1000000007LL;

void solve(void){
    int N;
    cin >> N;
    vector <ll> ts(N), as(N), hs(N, INF);
    rep(N, i) cin >> ts[i];
    rep(N, i) cin >> as[i];
    if (ts[N-1] != as[0]) {
        cout << 0 << endl;
        return;
    }
    hs[0] = ts[0], hs[N-1] = as[N-1];

    vector <bool> pre(N);
    pre[0] = pre[N-1] = true;

    rep(N-1, i) {
        if (ts[i] != ts[i+1]) {
            hs[i+1] = ts[i+1];
            pre[i+1] = true;
        }
        else hs[i+1] = min(ts[i+1], hs[i+1]);
    }
    reverse(all(as));
    reverse(all(hs));
    reverse(all(pre));
    rep(N-1, i) {
        if (as[i] != as[i+1]) {
            if ((pre[i+1] && as[i+1] != hs[i+1]) || as[i+1] > hs[i+1]) {
                cout << 0 << endl;
                return;
            }
            hs[i+1] = as[i+1];
            pre[i+1] = true;
        }
        else hs[i+1] = min(as[i+1], hs[i+1]);
    }

    ll ans = 1LL;
    rep(N, i) {
        if (!pre[i]) {
            ans *= hs[i];
            ans %= MOD;
        }
    }

    cout << ans << endl;
    /*
    reverse(all(hs));
    reverse(all(pre));
    cout << pre << endl << hs << endl;
    */


}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 2560
n = int(raw_input())


c = 2 * (n / 11)
h = {0:0}
for i in range(1, 6+1):
	h[i] = 1
for i in range(7, 12):
	h[i] = 2
if n in h:
	print h[n]
else:
	print h[n % 11] + c


Measured memory_bytes: 85028
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int N;
  string s;
  cin>>N>>s;
  string t="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i,s.size()){
    rep(j,26){
      if(s.at(i)==t.at(j)){
        if(i!=s.size()-1){cout<<t.at((j+N)%26);}
        else{cout<<t.at((j+N)%26)<<endl;}
      }}}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        ArrayList<String> tlist=new ArrayList<String>();
        for(int i=1;i<=13;i++){
            tlist.add("S "+Integer.toString(i));
        }
        for(int i=1;i<=13;i++){
            tlist.add("H "+Integer.toString(i));
        }
        for(int i=1;i<=13;i++){
            tlist.add("C "+Integer.toString(i));
        }
        for(int i=1;i<=13;i++){
            tlist.add("D "+Integer.toString(i));
        }
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        ArrayList<String> a=new ArrayList<String>();
        String s;
        for(int i=0;i<=num;i++){
            s=sc.nextLine();
            a.add(s);
            tlist.remove(a.get(i));
        }
        for(String str:tlist){
            System.out.println(str);
        }
    }
}


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

using namespace std;

typedef vector<int> vi;
typedef long long ll;
#define all(c) begin(c),end(c)

ll f(ll a, ll b) {
    if(a > b) return f(b,a);
//    if (a <= b) {
        ll rem = b % a;
        ll d = b / a;
        if (rem == 0)
            return 2 * (d-1) * a + a;
        return 2 * d * a + f(a, rem);
//    }
//    else {
//        ll rem = a % b;
//        ll d = a / b;
//        if (rem == 0)
//            return 2 * (d-1) * b + b;
//        return 2 * d * b + f(rem, b);
//    }
}

auto solve() {
    ll N, X;
    cin >> N >> X;

    return N + f(N - X, X);
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List

main = do
    [r, c] <- map read . words <$> getLine
    a <- replicateM r $ map read . words <$> getLine
    let ta = a ++ [map sum . transpose $ a]
    forM_ ta (\s -> putStrLn . unwords . map show $ s ++ [sum s])

Measured memory_bytes: 6000
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a,b = m()

s = input()[:-1]

ans = ["" for i in range(n)]
co = 0
cob = 0
for i in range(n):
    if s[i] == "a":
        if co < a+b:
            co += 1
            ans[i] = "Yes"
        else:
            ans[i] = "No"

    elif s[i] == "b":
        if co < a+b and cob < b:
            co += 1
            cob += 1
            ans[i] = "Yes"
        else:
            ans[i] = "No"
    else:
        ans[i] = "No"
for i in range(n):
    print(ans[i])

Measured memory_bytes: 75872
#include <stdio.h>

int main(){
    int i, j, H, W;
    while(true){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if((j == 0 || j == W-1 || i == 0 || i == H-1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
        printf("\n");
        }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2528
n, k = gets.chomp.split(" ").map{|n|n.to_i}
ary = gets.chomp.split(" ").map{|n|n.to_i}

# plan1. 1伝播
min_index = ary.find_index(1)
left = (min_index)/(k-1)

tmp = min_index%(k-1)
if (tmp!=0)
  left += 1
  min_index += (k-1-tmp)
end

right = (n-min_index-1)/(k-1)
right += 1 if ((n-min_index-1)%(k-1))!=0

puts left+right



Measured memory_bytes: 8716
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int a, b;
	cin >> a >> b;
	cout << max(a, b) + max(max(a, b) - 1, min(a, b));
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

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 vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void go(auto& grid, int dep) {
    if (2 * dep + 1 >= grid.size()) {
        const int H = grid.size();
        const int W = grid[0].size();

        vector<string> unmatched;

        for (int i = 0; i < W; i++) {
            string col(H, 0);
            for (int j = 0; j < H; j++)
                col[j] = grid[j][i];

            string tmp = col;
            reverse(all(tmp));

            bool m = false;
            for (auto it = unmatched.begin(); it != unmatched.end(); it++) {
                if (tmp == *it) {
                    m = true;
                    unmatched.erase(it);
                    break;
                }
            }
            if (!m) unmatched.push_back(col);
        }

        if (!unmatched.size()) {
            cout << "YES\n";
            exit(0);
        } else if (unmatched.size() == 1) {
            string elt = *unmatched.begin();
            string tmp = elt;
            reverse(all(tmp));
            if (elt == tmp) {
                cout << "YES\n";
                exit(0);
            }
        }
    } else {
        const int H = grid.size();
        for (int pr = dep + 1; pr < H - dep; pr++) {
            if ((H&1) && (pr == H/2)) continue;
            swap(grid[pr], grid[H - dep - 1]);
            go(grid, dep + 1);
            swap(grid[pr], grid[H - dep - 1]);
        }
    }
}

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

    int H, W;
    cin >> H >> W;

    vector<string> grid(H);
    for (int i = 0; i < H; i++) {
        cin >> grid[i];
    }

    if (H&1) {
        int m = H / 2;
        for (int i = 0; i < H; i++) {
            swap(grid[i], grid[m]);
            go(grid, 0);
            swap(grid[i], grid[m]);
        }
    } else go(grid, 0);

    cout << "NO\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  bool isIn = x >= r && y >= r && (x + r <= W) && (y + r <= H);

  cout << (isIn ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 3084
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < 5; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		for(int i = 0; i < 5; i++) {
			if(list.get(i) == 0) {
				int ans = i + 1;
				System.out.println(ans);
				return;
			}
		}
	}

}

Measured memory_bytes: 35592
#include <stdio.h>

int main(void)
{
	int d;
	scanf("%d",&d);
	printf("Christmas ");

	switch(d){
	case 22:
			printf("Eve Eve Eve\n");
			break;
	case 23:
		printf("Eve Eve\n");
		break;
	case 24:
		printf("Eve\n");
		break;
	case 25:
		printf("\n");
		break;
	}
	
	return 0;
}
		

Measured memory_bytes: 128
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]
N = rri()
arr = rrm()
def solve(N, prices):
    ans = 1000
    for i in range(1, len(prices)):
        if prices[i]>prices[i-1]:
            ans += (prices[i]-prices[i-1])*(ans//prices[i-1])
    return ans
print(solve(N, arr))
        

Measured memory_bytes: 65012
#include <stdio.h>

int isprimefunc(int);

int main()
{
	int n, i, j,
	    kosu, *isprime;
	isprime = (int *)malloc(1000000 * sizeof(int));
	/* pre-processing */
	for(i = 0; i < 1000000; i++) isprime[i] = isprimefunc(i);

	while(scanf("%d", &n) != EOF) {
		kosu = 0;
		for(i = 2; i <= n; i++) if(isprime[i]) kosu++;
		printf("%d\n", kosu);
	}
	return 0;
}

int isprimefunc(int a)
{
	int i;
	if(a == 1) return 1;
	for(i = 2; i * i <= a + 1; i++) if(a % i == 0) return 0;
	return -1;
}

Measured memory_bytes: 4344
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define p pair<ll,ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;
int main(){
    string s;
    cin >> s;
    vector<char> ans;
    for(int i = 0;i < s.size();i++){
        if(s[i] == '0') ans.pb('0');
        else if(s[i] == '1') ans.pb('1');
        else{
            if(ans.size() > 0) ans.erase(ans.end() - 1);
        }
    }
    rep(i,ans.size()) cout << ans[i];
    cout <<  endl;
    return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0] * (N-1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        dis = min(j-i, abs(i-X) + 1 + abs(j-Y), abs(i-Y) + 1 + abs(j-X))
        ans[dis-1] += 1

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3444
def sec2hms( sec )
	h = sec / (60 * 60)
	m = (sec - h * 60 * 60) / 60
	s = sec - h * 60 * 60 - m * 60  
	return h,m,s
end

def calclefttime( hms )
	
	ans = Array.new

	h = hms[ 0 ]
	m = hms[ 1 ]
	s = hms[ 2 ]

	count = h * 3600 + m * 60 + s
	left1 = 120 * 60 - count
	left2 = left1 * 3 

	hl, ml, sl = sec2hms( left1 );	ans << [ hl,ml,sl]
	hl, ml, sl = sec2hms( left2 );	ans << [ hl,ml,sl]
	return ans
end

answers = Array.new
while line = $stdin.gets
	inputtime = line.chomp.split(/\s/).map{ |i| i.to_i }
	if inputtime[ 0 ] == -1 && inputtime[ 1 ] == -1 && inputtime[ 2 ] == -1
		break
	end
	answers << calclefttime( inputtime )
end
answers.each{ |a|
	a.each{ |b|
		printf( "%02d:%02d:%02d\n", b[ 0 ], b[ 1 ], b[ 2 ] )
	}
}


Measured memory_bytes: 6108
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int N;
string s;
int BA, XA, BX;
void solve(){
    int res = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s;
        if(s.at(0) == 'B' && s.back() == 'A') BA++;
        else if(s.at(0) == 'B') BX++;
        else if(s.back() == 'A') XA++;
        for(int i = 0; i < s.size()-1; i++){
            if(s.at(i) == 'A' && s.at(i+1) == 'B') res++;
        }
    }
    if(BA){
        if(XA == 0 && BX == 0) res += BA-1;
        else if(XA == 0) res += BA;
        else if(BX == 0) res += BA;
        else res += BA+1 + min(XA-1, BX-1);
    }
    else res += min(XA, BX);
    cout << res << endl;
}

int main(void){
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;string S;cin>>S;
  vector<bitset<26>>L(N-1),R(N-1);
  for(int i=0;i<N-1;i++){
    if(i!=0)L[i]=L[i-1];L[i].set((int)S[i]-97);
  }
  for(int i=N-2;i>=0;i--){
    if(i!=N-2)R[i]=R[i+1];R[i].set((int)S[i+1]-97);
  }
  int M=0;
  for(int i=0;i<N-1;i++){
    M=max(M,(int)(R[i]&L[i]).count());
    //cout<<L[i]<<" "<<R[i]<<endl;
  }
  cout<<M;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

B = [0]*N
S = 0
cnt = 0
flag = False
for i in range(N):
    if A[i]>0:
        B[i] = A[i]
        S += B[i]
    elif A[i]<0:
        B[i] = -A[i]
        S += B[i]
        cnt += 1
    else:
        flag = True
if cnt%2==0 or flag:
    print(S)
else:
    print(S-2*min(B[i] for i in range(N)))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

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

using namespace std;

char ch[100010];

int main() {
    int n;
    scanf("%s", ch + 1);
    n = strlen(ch + 1);
    for(int i = 1; i <= n; i++) ch[i] -= '0';
    if(ch[1] == 0 || ch[n] == 1) {
        puts("-1");
        return 0;
    }
    for(int i = 1; i < n - 1; i++)
        if(ch[i] ^ ch[n - i]) {
            puts("-1");
            return 0;
        }
    vector <int> V;
    V.clear();
    for(int i = 1; i <= (n + 1) / 2; i++) if(ch[i] == 1) V.push_back(i);
    V.push_back(n);
    int cnt = 1, nw = 1;
    for(int i = 0; i + 1 < V.size(); i++) {
        printf("%d %d\n", cnt + 1, nw);
        nw = ++cnt;
        for(int j = V[i]; j < V[i + 1] - 1; j++) printf("%d %d\n", nw, ++cnt);
    }
    return 0;
}

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static int[] a;

	static void Main(){
		/* 入力の受取, aのソート */
		n = int.Parse(Console.ReadLine());
		a = new int[n];
		for (int i = 0;i < n;i++) a[i] = int.Parse(Console.ReadLine());
		Array.Sort(a);

		long ans = 0;
		/* \/\/\/... */
		int[] count = new int[n];
		bool f = true; //trueで\,falseで/
		for (int i = 0;i < n - 1;i++){
			if (f){
				count[i]++;
				count[i+1]--;
				goto END;
			}
			count[i]--;
			count[i+1]++;
			END:
			f = !f;
		}
		Array.Sort(count);
		long temp = 0;
		for (int i = 0;i < n;i++)
			temp += count[i] * a[i];
		ans = Max(ans,temp);
		/* /\/\/\/... */
		count = new int[n];
		f = false;
		for (int i = 0;i < n - 1;i++){
			if (f){
				count[i]++;
				count[i+1]--;
				goto END;
			}
			count[i]--;
			count[i+1]++;
			END:
			f = !f;
		}
		Array.Sort(count);
		temp = 0;
		for (int i = 0;i < n;i++)
			temp += count[i] * a[i];
		ans = Max(ans,temp);

		/* 出力 */
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 16220
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int rs = 2;
		int N = scan.nextInt();
		for(int i = 0; i < 7; i++) {
			if(N == 1) break;
			if(N < rs) break; 
			rs = rs * 2;
		}
		if(N == 1) System.out.println(1);
		else System.out.println(rs / 2);
		scan.close();
	}
}

Measured memory_bytes: 21844
import math
class abc_159:
    
    def __init__(self):
        pass
    
    def A(self):
        NM=list(map(int,input().split()))
        print(int((NM[0]*(NM[0]-1))/2 + (NM[1]*(NM[1]-1))/2))
    
    def B(self):
        S=input()
        if S==S[::-1] and S[:int((len(S)-1)/2)]==S[:int((len(S)-1)/2):-1] and S[int((len(S)+3)/2)-1:len(S)]==S[int((len(S)+3)/2)-1:len(S)+1][::-1]:print("Yes")
        else:print("No")
        
    def C(self):
        # a+b+c=L abc=M として M=bc(L-b-c) のときのMの極値問題となるb=xとおくとM(x)=-cx^2-c^2x+Lcxの2次関数となる
        #この2次方程式の最大値を求める、まず微分してM'(x)=0を解きx=(L-c)/2を算出、次にM(x)にこれを代入しM((L-c)/2)=c^3-2Lc^2+L^2cの３次関数を作成
        #cをxと置いてM(x)=x^3-2Lx^2+L^2xの3次関数の極大値の内大きい方が答え
        
        L=int(input())
        A,B,C=0,0,0
        
        ans_list=self.f2_ans(3,-4*L,L*L,L)
        
        C = ans_list[0] if self.f3_sum(ans_list[0],L)>=self.f3_sum(ans_list[1],L) else ans_list[1]
        B = (L-C)/2
        A = L-B-C
        print(A*B*C)
            
    #２次関数解の公式       
    def f2_ans(self,a,b,c,L):
        ans_list=[]
        
        discrimination=b*b-4*a*c
        kai1=(-b+math.sqrt(discrimination))/(2*a)
        kai2=(-b-math.sqrt(discrimination))/(2*a)
        
        ans_list.append(kai1)
        ans_list.append(kai2)
        
        return ans_list
    
    def f3_sum(self,x,L):
        return (x*x*x)+(-2*L*x*x)+(L*L*x)
        
        
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_159()
    obj.C()
    

Measured memory_bytes: 38384