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

using namespace std;

int main()
{

    int N;
    cin >> N;

    string S;
    cin >> S;

    int all_W = count(S.begin(), S.end(), 'W');
    int all_R = count(S.begin(), S.end(), 'R');

    int ans = all_R;

    int left_W = 0;
    int left_R = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'W')
            left_W++;
        else
            left_R++;
        int right_R = all_R - left_R;
        ans = min(ans, max(left_W, right_R));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3748
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_084_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 M      PIC 9(2).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT M.

    SUBTRACT M FROM 48 GIVING M.

    DISPLAY M.
    STOP RUN.


Measured memory_bytes: 636
li = list(input())

n = len(li)

ans = [0 for _ in range(n)]

rcnt = 0
lcnt = 0
ridx = 0
lidx = 0

for i in range(1,n):
    if li[i-1]=='R':
        rcnt += 1
        if li[i]=='L':
            ridx = i-1
            lidx = i
            if i==n-1:
                lcnt += 1
                ans[ridx] = (rcnt+1)//2 + lcnt//2
                ans[lidx] = (lcnt+1)//2 + rcnt//2
                rcnt = 0
                lcnt = 0
    if li[i-1]=='L':
        lcnt += 1
        if li[i]=='R' or i==n-1:
            if i==n-1:
                lcnt += 1
            ans[ridx] = (rcnt+1)//2 + lcnt//2
            ans[lidx] = (lcnt+1)//2 + rcnt//2
            rcnt = 0
            lcnt = 0

print(*ans)

Measured memory_bytes: 11476
class Cubic
{
  static void Main()
  {
    int num = Cubic.ReadNum();
    System.Console.WriteLine(CalcCubic(num));
  }

  static int ReadNum()
  {
    string line = System.Console.ReadLine();
    return int.Parse(line);
  }

  static int CalcCubic(int num)
  {
    return num * num * num;
  }
}

Measured memory_bytes: 5604
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cctype>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) {
		if (i != n - 1)cout << a[i] << " ";
		else cout << a[i] << endl;
	}
	rep(i, 1, n) {
		int v = a[i];
		int j = i - 1;

		while (j >= 0 And a[j] > v) {
			a[j+1] = a[j];
			j--;
			a[j+1] = v;
		}
		rep(i, 0, n) {
			if (i != n - 1)cout << a[i] << " ";
			else cout << a[i] << endl;
		}
	}
}

Measured memory_bytes: 1196
import math
a,b,h,m = map(int,input().split())
h %= 12
h *= 60
h = h + m
ma = m * 6
ha = h * 0.5
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(min(ma-ha,ha-ma)))))

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

bool isPalindrome(string x) {
    string y(x.rbegin(), x.rend());
    return x == y;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (isPalindrome(s) && isPalindrome(s.substr(0, (n-1)/2)) && isPalindrome(s.substr((n+1)/2))) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No";
        return 0;
    }
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int y = scan.nextInt();
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n-i; j++) {
				if (10000*i + 5000*j + 1000*(n-i-j) == y) {
					System.out.println(i + " " + j + " " + (n-i-j));
					return;
				}
			}
		}
		System.out.println(-1 + " " + -1 + " " + -1);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n,c=0;
	cin>>n;
	long int a[n];
	for(long int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive"<<endl;             
    else if(b>=0)cout<<"Zero"<<endl;            
    else if((a&1)^(b&1))cout<<"Positive"<<endl; 
    else cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

MOD = 1000000007

def mod_add(a, b):
  return (a+b)%MOD

def mod_sub(a, b):
  return (a+MOD-b)%MOD

def mod_mul(a, b):
  return a*b%MOD

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = (1,0,a)
    w = (0,1,b)
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return (w[0],w[1])

def mod_inv(a):
    x,_ = extgcd(a, MOD)
    return (MOD+x%MOD)%MOD

def mod_div(a, b):
    return a*mod_inv(b)%MOD

def mod_pow(a, b):
    res = 1
    while b > 0:
        if b & 1:
            res = res * a % MOD
        a = a * a % MOD
        b >>= 1
    return res

n, a, b = l_in()

res = mod_pow(2, n)
nCa = 1
for i in range(n, n-a, -1):
    nCa = mod_mul(nCa, i)
for i in range(1, a+1):
    nCa = mod_div(nCa, i)

nCb = 1
for i in range(n, n-b, -1):
    nCb = mod_mul(nCb, i)
for i in range(1, b+1):
    nCb = mod_div(nCb, i)

# print(res, nCa, nCb)

res = mod_sub(res, 1)
res = mod_sub(res, nCa)
res = mod_sub(res, nCb)
print(res)



Measured memory_bytes: 43868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

#define printp(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
//B枚までCに書き換えることができるよ！
int main() {
	ll N,M;
	cin>>N>>M;
	vector<ll> A(N),B(M),C(M);
	priority_queue<ll, vector<ll>, greater<ll>> pq;
	rep(i,N){
		cin>>A[i];
		pq.emplace(A[i]);
	}
	sort(all(A));
	print(A); 
	vector<P> CB;
	rep(i,M){
		cin>>B[i]>>C[i];
		CB.push_back({C[i],B[i]});
	}
	sort(all(CB), greater<P>());
	printp(CB);
	int cnt = 0;
	rep(i,M){
		ll c = CB[i].first, b = CB[i].second;
		rep(j,b){
			ll minn = pq.top();pq.pop();
			pq.emplace(max(minn,c));
			cnt++;
			if(cnt==N)i = M,j = b;
		}
	}
	ll ans = 0;
	while(!pq.empty()){
		ans+=pq.top();pq.pop();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <cmath>

using namespace std;

long long mpow(long long a, long long b);

int main()
{
	int n, p;
	cin >> n >> p;
	int a;
	int t = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) {
			t++;
		}
	}

	int s = n - t;
	long long ans = 1;
	for (int i = 0; i < t; i++) {
		ans *= 2;
	}
	if (n == t) {
		if (p == 1) {
			cout << 0 << endl;
		} else {
			cout << ans << endl;
		}
	} else {
		for (int i = 1; i < s; i++) {
			ans *= 2;
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){

    string s; cin >> s;
    int n = (int)s.size();
    int ans = 0;
    int x = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            x++;
            if(x == 4){
                ans++;
                x = 0;
            }
        }else{
            x--;
            if(x == -4) x = 0;
        }
    }

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


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;


bool is_prime(int a){
  bool flag = true;
  for(int i = 2;i*i <= a;i++){
    if(a % i == 0) flag = false;
  }
  return flag;
}

signed main(){
  int q;
  cin >> q;
  vint ans(50505);
  int count = 0;
  rep1(i,50505){
    if(is_prime(i*2+1) && is_prime((i*2+2)/2)) count++;
    ans[i] = count;
  }
  //rep(i,100) cout << ans[i] << " ";
  rep(i,q){
    int a,b;
    cin >> a >> b;
    if(a != 1)  cout << ans[b/2] - ans[a/2 - 1]  << endl;
    else cout << ans[b/2] << endl;
  }
}

Measured memory_bytes: 1024
N , M   = map( int , input().strip().split(" ") ) ;
L  = list ( map( int , input().strip().split(" ") ) ) ;
L.sort() ;
L.reverse() ;
s = sum( L ) ;

b = "Yes" ;
for x in range ( M ) :
	s1 = L[x] * 4 * M 
	if s1 < s :
		b = "No";
		break ;
print ( b ) ;


Measured memory_bytes: 3060
K,A,B = (int(x) for x in input().split())

if A >= B-1:
    print(1+K)
else:
    if K <= A:
        print(1+K)
    else:
        if (K-A+1)%2==0:
            print(int(A+(B-A)*int((K-A+1)/2)))
        else:
            print(int(1+A+(B-A)*int((K-A)/2)))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		String s = stdin.next();
		int a = 0;
		char[] c;
		c = s.toCharArray();
		for (int i = 0; i < s.length(); i++) {
			a = a + Character.getNumericValue(c[i]);
		}
		int in = Integer.parseInt(s);
		if (in % a == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

void solve(long long A, long long B, long long C, long long K){
    if (K > A + B) cout << A - (K - A - B) << '\n';
    else if (K > A) cout << A << '\n';
    else cout << K << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
const int N = 10005;
int a[N] , n,d,y;
int main()
{
    cin>>n >> d>>y;

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

    int cnt = 0;
    for(int i=1;i<=n;i++){
            cnt++;
        for(int j = 1; ;j++){

            int x = j*a[i] + 1;
            if(x<=d)cnt++;
            else break;



        }
    }
    cout<<(cnt + y)<<"\n";


    return 0;
}

/**

5
30 44
26
18
81
18
6

**/


Measured memory_bytes: 256
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2 * 1000 + 17;

ll a, b, c;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0;
	else
		cout << min(min(a * b, b * c), a * c) << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[3];
  a[0] = (N%10); N /= 10;
  if(a[0]== 7){
    cout << "Yes"; return 0;
  }
  a[1] = (N%10); N /= 10;
  if(a[1]== 7){
    cout << "Yes"; return 0;
  }
  a[2] = (N%10); N /= 10;
  if(a[2]== 7){
    cout << "Yes"; return 0;
  }

cout << "No";
return 0;
}

Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, ans = 0;
string Cand[1000], S;

int main(){
  for (int i = 0; i < 1000; i++){
    int num = i;
    for (int j = 0; j < 3; j++){
      Cand[i] += '0' + num % 10;
      num /= 10;
    }
  }

  cin >> N >> S;
  for (int i = 0; i < 1000; i++){
    int cnt = 0;
    for (int j = 0; j < N; j++){
      if (cnt == 3) break;
      if (S[j] == Cand[i][cnt]) cnt++;
    }
    if (cnt == 3) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


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

int N, K;
vector<int> A;

int main() {
    cin >> N >> K;
    A.resize(N);
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    long long int sum = 0;
    for (int i=0; i<N-K; i++) sum += A[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3936
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>H(N);
	for (int i = 0; i < N; i++)cin >> H[i];
	int maxnum = 0;
	int cnt = 0;
	for (int i = 0; i < N - 1; i++)
	{
		if (H[i] - H[i + 1] >= 0)
		{
			cnt++;
		}
		else
		{
			maxnum = max(maxnum, cnt);
			cnt = 0;
		}
	}
	maxnum = max(maxnum, cnt);
	cout << maxnum;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 101000

int ran[MAX], par[MAX];

int init(int n){
	for(int i = 0; i < n; i++){
		ran[i] = 0;
		par[i] = i;
	}
}

int find(int x){
	return par[x] ==  x ? x : par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	
	if(x == y)return;
	
	if(ran[y] > ran[x]){
		par[x] = y;
	} else {
		par[y] = x;
		if(ran[y] == ran[x]) ran[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}


int main(){
	int n, m, q, s, t;
	
	cin>>n>>m;
	
	init(n);
	
	for(int i = 0; i < m; i++){
		cin>>s>>t;
		unite(s,t);
	}
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>s>>t;
		cout<<(same(s,t)?"yes":"no")<<endl;
	}
	
	
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  int k=0;
  int c=0;
  int ans=0;
  int g,f;
  f=10000000;
  for(int i=97;i<123&&ans==0;i++){
    c=0;
    k=0;
    f=10000000;
    for(int j=0;j<s.size()&&ans==0;j++){
      if(s[j]==i){
        f=min(f,j);
        c++;
        k++;
      }
      else{
        if(c>0){
          c--;
          k++;
        }
        else{
          c=0;
          k=0;
          f=10000000;
        }
      }
      if(c>0&&k>1){
        ans++;
        g=j;
      }
    }
  }
  if(ans)cout<<f+1<<" "<<g+1<<endl;
  else cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
typedef int64_t ll;
const ll INF = 1000000000000000000;


int main() {
	ll N, T, A;
	cin >> N;
	cin >> T >> A;
	vector<ll> H(N);
	for (int i = 0; i < N; ++i) cin >> H[i];

	vector<double> H_abs(N);
	for (int i = 0; i < N; ++i) {
		H_abs[i] = abs((double)A - ((double)T - (double)H[i] * 0.006));
	}

	auto it = min_element(H_abs.begin(), H_abs.end());
	cout << it - H_abs.begin() + 1 << endl;
}

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

int main(){
	// sengen
	int k;
	// nyuryoku
	cin >> k;
	// keisan
	for(int i=0;i<k;i++){
		cout << "ACL";
	}
	// syutsuryoku
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;

  int m = max({A, B, C});
  int ans = A + B + C - m + m * pow(2, K);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  int suma=0; int sumb=0;
  for(int i=0;i<M;i++){cin >> A[i];}
  for(int i=0;i<M;i++){
    if(A[i]<X){suma+=1;}
    if(A[i]>X){sumb+=1;}
  }
  cout << min(suma,sumb) << endl;
}

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

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

  priority_queue<int> Q;

  rep (i, n) {
    int a;  cin >> a;
    Q.push(a);
  }

  rep (i, m) {
    int a = Q.top();  Q.pop();
    Q.push(a/2);
  }

  ll ans = 0;
  rep (i, n) {
    ans += Q.top();  Q.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);

int main() {
	int n, t, e;
	cin >> n >> t >> e;
	VI x(n); rep(i, n)cin >> x[i];

	int ans = -1;
	rep(i, n) {
		int aa = (t + e) / x[i] * x[i];
		if (t - e <= aa) {
			ans = i + 1;
			break;
		}
	}
	Cout(ans);
}


Measured memory_bytes: 3112
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
int n;
stack<pair<int,int> >S;
long long ans=0;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int h;cin>>h;
		int j=i;
		while(!S.empty()&&S.top().first>h)
		{
			ans=max(ans,1LL*S.top().first*(i-S.top().second));
			j=S.top().second;
			S.pop();
		}
		if(S.empty()||S.top().first<h)S.push(make_pair(h,j));
	}
	while(!S.empty())
	{
		ans=max(ans,1LL*S.top().first*(n-S.top().second));
		S.pop();
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3716
l=list(input().split())
s=[]
for c in l:
#    print(c)
    
    if c=='+':
        b=s.pop()
        a=s.pop()
        s.append(a+b)
    elif c=='-':
        b=s.pop()
        a=s.pop()
        s.append(a-b)
    elif c=='*':
        b=s.pop()
        a=s.pop()
        s.append(a*b)
    else:
        s.append(int(c))
    
#    print(s)

print(s.pop())


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	cout<<a-(s==u)<<" "<<b-(t==u)<<endl;
}


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

int main(){
  int N; cin>>N;
  int res=0;
  if(N<10)res+=N;
  else{
    res+=9;
    if(N<100){}
    else if(N<1000)res+=(N-100+1);
    else{
      res+=900;
      if(N<10000){}
      else if(N<100000)res+=(N-10000+1);
      else res+=90000;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
int main(){
    int n, ans=0;  cin >> n;
    if(n>=100000) ans = n-9999+900+9-1;
    else if(n>=10000) ans = n-9999+900+9;
    else if(n>=1000) ans = 909;
    else if(n>=100) ans = n-99+9;
    else if(n>=10) ans = 9;
    else ans = n;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,array[100],i;
    scanf("%d",&num);
    for (i=0; i<num; i++) scanf("%d",&array[i]);
    for (i=0; i<num; i++) {
        if (i) printf(" ");
        printf("%d",array[num-i-1]);
    }
    printf("\n");
    return 0;
}

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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

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

    ll n, k;
    cin >> n >> k;

    map<ll,ll> mp;

    for(int i=0;i<k;i++)
    {
        ll p; 
        cin >> p;

        ll x;
        for(int j=0;j<p;j++)
        {
            cin >> x;
            mp[x]= j+1;
        }
    }

    ll cn=0;
    for(int i=1;i<=n;i++)
    {
        if(!mp[i])
        {
            cn++;
        }
    }

    cout << cn << endl;

    return 0;
}

Measured memory_bytes: 3672
N,K = map(int,input().split())
P = list(map(int,input().split()))

Q = [(P[i]+1)/2 for i in range(N)]

max,tmp = sum(Q[0:K]),sum(Q[0:K])
for i in range(N-K):
    tmp = tmp + Q[K+i] - Q[i]
    if max < tmp:
        max = tmp

print(max)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  int MA = 0;
  int X, sum;
  sum = 0;
  rep(i, N) {
    cin >> X;
    sum += X;
    MA = max(MA, X);
  }
  cout << sum - MA / 2 << endl;
}

Measured memory_bytes: 3584
n,m,l = map(int,input().split())
a = [[]for _ in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(m)]
for i in range(m):
    b[i] = list(map(int, input().split()))

for i in range(n):
  line = []
  for j in range(l):
    c = 0
    for k in range(m):
      c += a[i][k]*b[k][j]
    line.append(str(c))
  print(' '.join(line))



Measured memory_bytes: 6316
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int a[100],b[100];
	for(int i=0;i<k;i++)scanf("%d%d",&a[i],&b[i]);
	int dp[101][3][3],x;
	const int mod=10000;

	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				dp[i][j][k]=0;
			}
		}
	}
	int p=0,q=0;
	for(int i=0;i<k;i++){
		if(a[i]==1)p=b[i];
		if(a[i]==2)q=b[i];
	}
	if(p==0&&q==0)for(int X=0;X<3;X++)for(int Y=0;Y<3;Y++)dp[2][X][Y]=1;
	if(p==0&&q!=0){
		for(int X=0;X<3;X++){
			for(int Y=0;Y<3;Y++){
				if(q-1==Y){
					dp[2][X][Y]=1;
				}
				else dp[2][X][Y]=0;
			}
		}
	}
	if(p!=0&&q==0){
		for(int X=0;X<3;X++){
			for(int Y=0;Y<3;Y++){
				if(p-1==X){
					dp[2][X][Y]=1;
				}
				else dp[2][X][Y]=0;
			}
		}
	}
	if(p!=0&&q!=0){
		for(int X=0;X<3;X++){
			for(int Y=0;Y<3;Y++){
				if(p-1==X&&q-1==Y){
					dp[2][X][Y]=1;
				}
				else dp[2][X][Y]=0;
			}
		}
	}
	for(int i=3;i<=n;i++){
		x=0;
		for(int j=0;j<k;j++){
			if(a[j]==i)x=b[j];
		}
		if(x==0){
			for(int X=0;X<3;X++){
				for(int Y=0;Y<3;Y++){
					if(X==Y){
						for(int Z=0;Z<3;Z++){
							if(X!=Z){
								dp[i][X][Y]+=dp[i-1][Z][X];
								dp[i][X][Y]%=mod;
							}
						}
					}
					else{
						for(int Z=0;Z<3;Z++){
								dp[i][X][Y]+=dp[i-1][Z][X];
								dp[i][X][Y]%=mod;
						}
					}
				}
			}
		}
		else{
			for(int X=0;X<3;X++){
				for(int Y=0;Y<3;Y++){
					if(X!=Y||Y!=x-1){
						dp[i][X][x-1]+=dp[i-1][Y][X];
						dp[i][X][x-1]%=mod;
					}
				}
			}
		}
	}
	/*
	for(int i=2;i<=n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				printf("%d ",dp[i][j][k]);
			}
			printf("\n");
		}
		printf("\n");
	}*/
	int ans=0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			ans+=dp[n][i][j];
		}
	}
	ans%=mod;
	printf("%d\n",ans);
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	if (k > (n - 1) * (n - 2) / 2) {
		std::cout << -1 << std::endl;
		return 0;
	}
	std::vector<std::pair<int, int> > hens;
	for (int i = 1; i < n; i++) hens.push_back({0, i});
	int left = (n - 1) * (n - 2) / 2 - k;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < i; j++) {
			if (!left)break;
			hens.push_back({i, j});
			left--;
		}
		if (!left) break;
	}
	std::cout << hens.size() << std::endl;
	for (auto i : hens) std::cout << i.first+1 << " " << i.second + 1 << std::endl;
	return 0;
}


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

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E)
#define cin scanner
#define cout printer
namespace {
class MaiScanner {
  public:
    template <typename T> void input_integer(T &var) {
        var = 0;
        T sign = 1;
        int cc = getchar_unlocked();
        for (; cc < '0' || '9' < cc; cc = getchar_unlocked())
            if (cc == '-')
                sign = -1;
        for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked())
            var = (var << 3) + (var << 1) + cc - '0';
        var = var * sign;
    }
    inline int c() { return getchar_unlocked(); }
    inline MaiScanner &operator>>(int &var) {
        input_integer<int>(var);
        return *this;
    }
    inline MaiScanner &operator>>(long long &var) {
        input_integer<long long>(var);
        return *this;
    }
    inline MaiScanner &operator>>(string &var) {
        int cc = getchar_unlocked();
        for (; !isvisiblechar(cc); cc = getchar_unlocked())
            ;
        for (; isvisiblechar(cc); cc = getchar_unlocked())
            var.push_back(cc);
        return *this;
    }
    template <typename IT> void in(IT begin, IT end) {
        for (auto it = begin; it != end; ++it)
            *this >> *it;
    }
};
class MaiPrinter {
  public:
    template <typename T> void output_integer(T var) {
        if (var == 0) {
            putchar_unlocked('0');
            return;
        }
        if (var < 0)
            putchar_unlocked('-'), var = -var;
        char stack[32];
        int stack_p = 0;
        while (var)
            stack[stack_p++] = '0' + (var % 10), var /= 10;
        while (stack_p)
            putchar_unlocked(stack[--stack_p]);
    }
    inline MaiPrinter &operator<<(char c) {
        putchar_unlocked(c);
        return *this;
    }
    inline MaiPrinter &operator<<(int var) {
        output_integer<int>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(long long var) {
        output_integer<long long>(var);
        return *this;
    }
    inline MaiPrinter &operator<<(char *str_p) {
        while (*str_p)
            putchar_unlocked(*(str_p++));
        return *this;
    }
    inline MaiPrinter &operator<<(const string &str) {
        const char *p = str.c_str();
        const char *l = p + str.size();
        while (p < l)
            putchar_unlocked(*p++);
        return *this;
    }
    template <typename IT> void join(IT begin, IT end, char sep = ' ') {
        for (bool b = 0; begin != end; ++begin, b = 1)
            b ? *this << sep << *begin : *this << *begin;
    }
};
} // namespace
MaiScanner scanner;
MaiPrinter printer;

int main(void) {
    int N, K;
    cin >> N >> K;
    cout << (N % K == 0 ? 0 : 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var info = Console.ReadLine().Split(' ');
            var vote = Console.ReadLine().Split(' ');
            var nums = new int[int.Parse(info[0])];
            double sum = 0;
            var count = 0;
            for(int i = 0; i < int.Parse(info[0]); i++)
            {
                nums[i] = int.Parse(vote[i]);
            }
            foreach(int num in nums)
            {
                sum += num;
            }
            double check = sum / (4 * int.Parse(info[1]));
            //Console.WriteLine(check);
            foreach (int num in nums)
            {
                if (num >= check)
                {
                    count++;
                }
            }
            if (count >= int.Parse(info[1])) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}



void solution()
{
    ll k,i,j,n,m,w;
    cin>>n;
    ll ans=0;
    for(i=1;i<n;i++)
    {
        k=n/i;
        if(k*i==n)k--;
        ans+=k;
    }
    cout<<ans;
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}


Measured memory_bytes: 3644
#include<stdio.h>
#define N 100
#define SHIRO 0
#define GRAY 1
#define KURO 2

int kazu,M[N][N];
int color[N],d[N],f[N],tt;

void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<kazu;v++){
    if(M[u][v]==0)continue;
    if(color[v]==SHIRO){
      visit(v);
    }
  }
  color[u]=KURO;
  f[u]=++tt;
}
void x(){
  int u;
  for(u=0;u<kazu;u++)color[u]=SHIRO;
  tt=0;
  for(u=0;u<kazu;u++){
    if(color[u]==SHIRO)visit(u);
  }
  for(u=0;u<kazu;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
int main()
{
  int u,v,k,i,j;
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    for(j=0;j<kazu;j++)M[i][j]=0;
  }
  for(i=0;i<kazu;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  x();
  return 0;
}



Measured memory_bytes: 2112
# -*- coding:utf-8 -*-
import itertools, math
N, P = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
odd = [ tmp for tmp in a if tmp%2 != 0]
even = [ tmp for tmp in a if tmp%2 == 0]
d = math.factorial(len(odd))
e = math.factorial(len(even))
if P == 0:
    ans += 1
    b = sum([ (d//math.factorial(len(odd)-tmp))//math.factorial(tmp) for tmp in range(2, len(odd)+1, 2) ])
else:
    b = sum([ (d//math.factorial(len(odd)-tmp))//math.factorial(tmp) for tmp in range(1, len(odd)+1, 2) ])
c = [ (e//math.factorial(len(even)-tmp))//math.factorial(tmp) for tmp in range(1, len(even)+1) ]
for tmp in c:
    ans += tmp*b
else:
    if P == 0:
        ans += b+sum(c)
    else:
        ans += b
print(ans)

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

int main(){
  int A,B;
  int sum=0;
  int a,b,d,e;
  
  cin >> A >> B;
  
  for(int i = A; i < B+1;i++){
    a = i % 10;
    b = (i/10) % 10;
    d = (i/1000) % 10;
    e = (i/10000) % 10;
    
    if((a==e)&&(b==d)){
      sum += 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import heapq
n ,m = map(int, input().split())
a = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(a)
ans = 0

for i in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a, x/2)

for i in range(n):
    ans -= int(a[i])
print(ans)

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

using ll = long long;

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector <vector <int> > adj(N + 1);
  vector <int> dp(N + 1, -1);
  for(int i = 0, a, b; i < M; i++){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dp[1] = 1;
  int cont = 0;
  queue <int> q;
  q.push(1);
  while(!q.empty()){
    int node = q.front();
    cont++;
    q.pop();
    for(int i : adj[node]){
      if(dp[i] == -1){
        q.push(i);
        dp[i] = node;
      }
    }
  }
  if(cont == N){
    cout << "Yes\n";
    for(int i = 2; i <= N; i++){
      cout << dp[i] << '\n';
    }
  }else{
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 10148
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

int main() {
	int a, b, c, d;
	scanf ("%d%d%d%d", &a, &b, &c, &d);
	rep(i, 1, 10000000) {
		c -= b;
		if (c <= 0) return printf ("Yes\n"), 0;
		a -= d;
		if (a <= 0) return printf ("No\n"), 0;
	}
	return 0;
}


Measured memory_bytes: 3692
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n;
    int[] a, b;
    scan(n);
    a = readln.split.to!(int[]);
    b = readln.split.to!(int[]);

    long s;

    foreach (i ; 0 .. n) {
        if (a[i] <= b[i]) {
            s += (b[i] - a[i]) / 2;
        }
        else {
            s -= (a[i] - b[i]);
        }
    }

    writeln(s >= 0 ? "Yes" : "No");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int g[100010];
int main()
{
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	map<char, int> rsp;
	rsp['r'] = p;
	rsp['s'] = r;
	rsp['p'] = s;
	ll ans = 0;
	rep(i, n)
	{
		if(g[i])
			continue;
		if(i+k >= n){
			ans += rsp[t[i]];
			continue;
		}
		if (t[i] == t[i + k])
		{
			int now = i + k;
			int count = 1;
			while (now < n)
			{
				if(t[now]==t[i]){
					g[now] = 1;
					now += k;
					count++;
				}
				else
				{
					break;
				}
			}
			ans += (count + 1) / 2 * rsp[t[i]];
		}else{
			ans += rsp[t[i]];
		}
	}
	cout << ans << endl;
}


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

int main(){ 
  int n;
  cin >> n;
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < n-2; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') res++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
N = int(input())
p = list(map(int,input().split()))
ad = 0
ok = list(range(N+1))

for i in range(N):
    if p[i] == ok[i+1]:
        continue
    else:
        ad += 1

print("YES") if ad == 2 or ad == 0 else print("NO") 

Measured memory_bytes: 3060
a, b, c = map(int, input().split())
k = int(input())

cnt = 0
while True:
    if a >= b:
        b *= 2
        cnt += 1
    if b >= c:
        c *= 2
        cnt += 1
    if a < b and b < c:
        break

if cnt <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int main(){
	//IOS;
	string s,t;
	cin>>s;
	t=s;
	reverse(ALL(t));
	if(s==t)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main()
{int a;
int b;
int c;
int n;
while(scanf("%d %d", &a, &b)!=EOF)
{c=a+b;
n=0;
while(n<200)
{
if((c/pow(10,n))<10)
{printf("%d\n",n+1);
break;
}
else
{n++;
}
}
}
}


Measured memory_bytes: 2020
use std::io::stdin;




fn insertion_sort(array:&mut Vec<i32>){
  //println!("{:?}",array);
  print_array(array.to_vec());
  for i in 1 .. array.len(){
    //①位置決定
    let mut insertpos:usize=114514;
    for j in (0..i).rev(){
        if array[j]<array[i]{
          insertpos=j+1;
          break;
        }
        if j==0{
          insertpos=0;
        }
    }
    //②挿入
    for j in (insertpos..i).rev()
    {
      array.swap(j,j+1);
    }
    print_array(array.to_vec());
  }
  //print_array(array.to_vec());
}

fn bubble_sort(array:&mut Vec<i32>)->i32
{
  let mut swap_times=0;
  let mut swapped=true;
  while swapped{
  swapped=false;
  for j in (1..array.len()).rev(){
    if array[j]<array[j-1]
    {
      array.swap(j,j-1);
      //print_array(array.to_vec());
      swap_times+=1;
      swapped=true;
    }
  }
}
  swap_times
}
fn selection_sort(array:&mut Vec<i32>)->i32{
  let mut swap_cnt=0;
  for i in 0..array.len(){
    let mut current_min=1145141919;
    let mut current_min_pos=array.len()-1;
    for j in i..array.len()
    {
      if current_min>array[j]{
        current_min_pos=j;
        current_min=array[j]
      }
    }
    array.swap(i,current_min_pos);
    swap_cnt+=1;
    //print_array(array.to_vec());
  }
  swap_cnt
}
fn main() {
  //入力を受け取ってi32に変換
  let n:i32 = readline().parse().unwrap();
  //println!("{}",n);
  //let mut array=vec![5,4,3,2,1];
  let mut array=readline_as_vec();
  //insertion_sort(&mut array);
  let swap_occured=bubble_sort(&mut array);
  //let swap_occured=selection_sort(&mut array);
  print_array(array);
  println!("{:?}",swap_occured);
}

fn print_array(array:Vec<i32>){
  let mut array_content=String::new();
  for a in array{
    array_content += &a.to_string();
    array_content += " ";
  }
  println!("{}",array_content.to_string().trim_right());
}
fn readline()->String
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s.trim_right().to_owned()
}

fn readline_as_vec()->Vec<i32>
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s=s.trim_right().to_owned();
  let mut read_vec:Vec<i32>=Vec::new();
  //空白で分割
  for chr in s.split_whitespace(){
    read_vec.push(chr.parse::<i32>().unwrap());
  }
  read_vec
}


Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
char a[100010];
int main()
{
	long long k,x=0;
	int i;
	scanf("%s%lld",a,&k);
	for(i=0; i<strlen(a); i++)
	{
		if(a[i]=='1') x++;
		else break;
	}
	if(k==1) cout<<a[0];
	else if(k<=x) cout<<1;
	else
	{
		cout<<a[x];
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
#define mp make_pair
typedef pair<int,int> P;
int n,d,a;
struct Mon{
  int x,h;
  bool operator < (const Mon &b)const
  {
    return x < b.x;
  }
}m[maxn];
P pre[maxn];// from, cst.
ll f[maxn];
int main(){
  n = getint(), d = getint(), a = getint();
  for(int i = 1;i <= n;i++){
    m[i].x = getint(), m[i].h = getint();
  }
  sort(m + 1,m + n + 1);
  int j = 1;
  for(int i = 1;i <= n;i++){
    int val = (m[i].h + a - 1) / a;
    while(m[i].x - m[j].x > d * 2) j++;
    f[i] = max(f[i - 1],f[j - 1] + val);
  }
  putll(f[n],'\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int u = 10 * (s[0] - '0') + s[1] - '0';
    int d = 10 * (s[2] - '0') + s[3] - '0';

    const bool ucanmm = (u > 0 && u <= 12);
    const bool dcanmm = (d > 0 && d <= 12);

    string a[] = {"YYMM", "MMYY", "AMBIGUOUS", "NA"};
    string ans;

    if (ucanmm && dcanmm)
        ans = a[2];
    else if (ucanmm && !dcanmm)
        ans = a[1];
    else if (!ucanmm && dcanmm)
        ans = a[0];
    else
        ans = a[3];

    cout << ans << endl;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　
// vector<vector<int>> mm(h, vector<int>(w, -1));


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll h, w;
    cin >> h >> w;
    ll ans1, ans2, ans3, ans4;
    ans1 = ans2 = ans3 = ans4 = LINF;


    if(w%3==0){
        ans1 = 0;
    }
    else{
        ans1 = h;
    }

    if(h%3==0){
        ans2 = 0;
    }
    else{
        ans2 = w;
    }

    ll tmp;

    if(h%2==0){
        for(ll i=1;i<=w-1;i++){
            tmp = max(h*i,h/2*(w-i)) - min(h*i,h/2*(w-i));
            ans3 = min(ans3,tmp);
        }
    }
    else{
        for(ll i=1;i<=w-1;i++){
            tmp = max({h*i,h/2*(w-i),(h/2+1)*(w-i)}) - min({h*i,h/2*(w-i),(h/2+1)*(w-i)});
            ans3 = min(ans3,tmp);
        }
    }

    if(w%2==0){
        for(ll i=1;i<=h-1;i++){
            tmp = max(w*i,w/2*(h-i)) - min(w*i,w/2*(h-i));
            ans4 = min(ans4,tmp);
        }
    }
    else{
        for(ll i=1;i<=h-1;i++){
            tmp = max({w*i,w/2*(h-i),(w/2+1)*(h-i)}) - min({w*i,w/2*(h-i),(w/2+1)*(h-i)});
            ans4 = min(ans4,tmp);
        }
    }




    ll ans = min({ans1,ans2,ans3,ans4});

    cout << ans <<endl;

    
    return 0;
}



Measured memory_bytes: 3548