akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( auto itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

pair<pair<int,pii>,pair<int,pii> > ak[N];  
int n;
set<pair<int,pii> > mkd,umkd;
int d,fl;
pair<int,pii> opp(pair<int,pii> a){
  int id = a.Y.X;
  if(ak[id].X==a) return ak[id].Y;
  else return ak[id].X;
}
int check(pair<int,pii> a){
  set<pair<int,pii> > :: iterator it=mkd.lower_bound(a),it1;
  it1=it;
  it++;
  if(it!=mkd.end()){
    if((*it).X-a.X<d) return 0;
  }
  if(it1!=mkd.begin()){
    it1--;
    if(a.X-(*it1).X<d) return 0;
  }
  return 1;
}
void mark(pair<int,pii> a){
  //printf("%d %d %d\n",a.X,a.Y.X,a.Y.Y);
  umkd.erase(a); umkd.erase(opp(a));
  mkd.insert(a);
  if(!check(a)) {
    fl=0; return;
  }

  while(1){
    set<pair<int,pii> > :: iterator it=umkd.lower_bound(a);
    if(it!=umkd.end()){
      
      if((*it).X-a.X<d){
        mark(opp(*it));
      }else break;
    }else break;
    if(fl==0||!check(a)) return ;
  }
  while(1){
    set<pair<int,pii> > :: iterator it=umkd.lower_bound(a);
    if(it!=umkd.begin()){
      it--;
      if(a.X-(*it).X<d){
        mark(opp(*it));
      }else break;
    }else break;
    if(fl==0||!check(a)) return ;
  }
}
void restore(){
  foreach(mkd,it){
    umkd.insert(*it);
    umkd.insert(opp(*it));
  }
  mkd.clear();
}
int calc(int _d){
  d=_d;
  umkd.clear(); mkd.clear();
  REP(i,n) umkd.insert(ak[i].X),umkd.insert(ak[i].Y);
  while(umkd.size()){
    fl=1;
   // printf("%d\n",d);
    mkd.clear();
    int id = (*umkd.begin()).Y.X;
    mark(ak[id].X);
    if(fl==0) restore();
    else continue;
    fl=1;
    mark(ak[id].Y);
    if(fl==0)  return 0;
  }
  return 1;
}
int main(){
  srand(time(NULL));  
  scanf("%d",&n);
  REP(i,n){
    int x,y;scanf("%d%d",&x,&y);
    if(x>y) swap(x,y);
    ak[i].X=mp(x,mp(i,0));
    ak[i].Y=mp(y,mp(i,1));
  }
  int l=0,r=mod;
  while(l<r){
    int m=((l+r)>>1)+1;
   // m=4;
    if(calc(m)) l = m ; else r=m-1;
  //  break;
  }
  printf("%d\n",l); 
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define     FAST            ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    string s1,s2;

    cin>>s1>>s2;

    int mx=-1,ans=0;;

    for(int i=0;i<s1.size();i++)
    {
        string x;
        ans=0;
        if(s2.size()+i>s1.size()){break;}
        for(int j=i;j<s2.size()+i;j++)
        {
            x+=s1[j];
        }


        //cout<<x<<endl;
        //cout<<s2<<endl;


        for(int k=0;k<s2.size();k++)
        {
            if(s2[k]==x[k])
            {
                ans++;
            }
        }

        //cout<<ans<<endl;

        mx=max(ans,mx);
        x.clear();
    }

    cout<<s2.size()-mx<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> b,c;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i%2==0){
      b[a[i]]++;
    }else{
      c[a[i]]++;
    }
  }
  vector<pair<int,int>> d,e;
  for(auto au:b){
    d.push_back(make_pair(au.second,au.first));
  }
  for(auto au:c){
    e.push_back(make_pair(au.second,au.first));
  }
  sort(d.begin(),d.end(),greater<pair<int,int>>());
  sort(e.begin(),e.end(),greater<pair<int,int>>());
  if(d[0].second!=e[0].second){
    cout<<n/2-d[0].first+n/2-e[0].first;
  }else{
    if(d.size()==1&&e.size()==1){
      cout<<n/2;
    }else if(d.size()==1){
      cout<<n/2-e[1].first;
    }else if(e.size()==1){
      cout<<n/2-d[1].first;
    }else{
      if(d[1].first>e[1].first){
        cout<<n/2-e[0].first+n/2-d[1].first;
      }else{
        cout<<n/2-d[0].first+n/2-e[1].first;
      }
    }
  }
}

Measured memory_bytes: 6520
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D = sorted(D)
T = sorted(T)

from collections import deque
D = deque(D)
T = deque(T)

if N < M:
    print('NO')
else:
    t = T.popleft()
    for d in D:
#        print(t, d)
        if d == t:
#            print('hit')
            if len(T) == 0:
                print('YES')
                break
            else:
                t = T.popleft()
    else:
        print('NO')

Measured memory_bytes: 127572
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int main() {
  int N, Y;
  cin >> N >> Y;
  string ans="No";
  int fin=0;
  for (int i=0; i<=Y/10000; i++) {
    for (int j=0; j<=(Y-10000*i)/5000; j++) {
      if (Y-10000*i-5000*j==(N-i-j)*1000) {
        cout << i << " " << j << " " << N-i-j << endl;
        fin =1;
        break;
      }
    }
    if (fin==1) {break;}
  }
  if (fin==0) {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}
 

Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

string sub(string a, int x, int y) {
  string ans;
  for (int i = x; i <= y; i++) ans += a[i];
  return ans;
}

bool ispal(string s) {
  string a = s;
  string b = s;
  reverse(b.begin(), b.end());
  return (a == b);
}

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


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

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

  bool good = true;
  char c_old = 'a';
  for (char c : S) {
    if (c == c_old)
      good = false;
    c_old = c;
  }

  cout << (good ? "Good" : "Bad") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

    int a, b, d, r;
    double f;

    scanf("%d%d", &a, &b);

    d = a / b;
    r = a % b;
    f = (double)a / b;

    printf("%d %d %f\n", d, r, f);

    return 0;

}

Measured memory_bytes: 636
#include<stdio.h>

int main(){
    int n, x;
    int a, b, c, d;
    
    while(1){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0){
            break;
        }d = 0;
        for(a = 1; a <= n; a++){
            for(b = a + 1; b <= n; b++){
                c = x - b - a;
                if((c > b) && (c <= n)){
                    d++;
                }
            }
        }printf("%d\n", d);
    }
}


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

signed main() {
	int n, m;
	cin >> n >> m;
	int a = 0;
	int b = 0;
	rep(i, n) {
		int w;
		cin >> w;
		a += w;
	}
	rep(i, m) {
		int w;
		cin >> w;
		b += w;
	}
	cout << a * b << endl;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

//#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define endl "\n"
#define f first
#define s second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    string s;
    cin >> s;
    ll n = s.size();
    reverse(all(s));
    vi arr(n+1, 0);
    ll p = 1;
    ll m = 2019;
    map<ll, ll> mp;
    mp[0] = 1;
    REP(i, 1, n+1) {
        arr[i] = (arr[i-1] + (p * (s[i-1] - '0')) % m) % m;
        p = (p*10) % m;
        mp[arr[i]]++;
    }
    //print(arr);
    ll ans = 0;
    for (auto i: mp)
        ans += (i.s * (i.s - 1))/2;
    cout << ans << endl;
}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int cards[2*n] = {};
    for (int i = 0; i < 2*n; i++) cards[i] = i + 1;
    int k, t[2*n] = {};
    while (m--) {
        cin >> k;
        if (k > 0) {
            for (int i = k, j = 0; i < 2*n; i++, j++) {
                t[j] = cards[i];
            }
            for (int i = 2*n-k, j = 0; i < 2*n; i++, j++) {
                t[i] = cards[j];
            }
            for (int i = 0; i < 2*n; i++) cards[i] = t[i];
        } else {
            for (int i = 0, j = 0; j < 2*n; i++, j += 2) {
                t[j] = cards[i], t[j+1] = cards[n+i];
            }
            for (int i = 0; i < 2*n; i++) cards[i] = t[i];
        }
    }
    for (int i = 0; i < 2*n; i++) cout << cards[i] << endl;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int p[N];
  for(int i(0);i<N;i++){
    cin>>p[i];
  }
  int max(p[0]);
  for(int i(1);i<N;i++){
    if(max<p[i])max=p[i];
  }
  int s(0);
  for(int i(0);i<N;i++){
    s+=p[i];
  }
  s-=max;
  s+=max/2;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))

ind = range(1, max(X)+1)
K = [0]*(len(ind)+1)

for p in ind:
    K[p] = sum(map(lambda x: (x - p)**2, X))
#    print(K)
print(min(K[1:]))

Measured memory_bytes: 38640
#include <stdio.h>
#include <stdlib.h>

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

	scanf ("%d %d %d %d", &a, &b, &c, &d);

	if (abs(a-c) <= d) {
		printf ("Yes\n");
		return 0;
	}
	if (abs(a-b) <= d && abs(b-c) <= d) {
		printf ("Yes\n");
		return 0;
	}

	printf ("No\n");
	return 0;
}


Measured memory_bytes: 128
n = int(input())
b = input().split()

result = 0
for i in range(n):
    if i == 0:
        result += int(b[i])
    elif i == n-1:
        result += int(b[n-2])
    else:
        result += min(int(b[i-1]),int(b[i]))
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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


///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

// initalisation of the binominal coefficient
void COMBinit(std::vector<long long>& fac, std::vector<long long>& finv, std::vector<long long>& inv, int n, int MOD) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < n; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// binominal coefficient: nCk
// http://drken1215.hatenablog.com/entry/2018/06/08/210000
long long COMB(int n, int k, int MOD) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    std::vector<long long> fac(n + 1), finv(n + 1), inv(n + 1);
    COMBinit(fac, finv, inv, n + 1, MOD);
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    ll S; cin >> S;
    if (S < 3) {
        cout << 0 << endl;
        return;
    }
    
    // combination: O(N^2)
    // for each number of elements, count the possible configurations of extra elements
    //ll maxN = S / 3;
    //ll cnt = 1;
    //for (ll i = 2; i <= maxN; ++i) {
    //    ll slot = S - 3 * i;
    //    cnt = (cnt + COMB(slot + i - 1, i - 1, MOD)) % MOD;
    //}
    //cout << cnt << endl;

    //// dp : O(N^2)
    //// https://www.youtube.com/watch?v=yLkJZXkB6D0&feature=youtu.be
    //vector<ll> dp(S+1, 0);
    //dp[0] = 1;
    //for (ll i = 3; i <= S; ++i) {
    //    for (ll j = 0; j <= i - 3; ++j) {
    //        //dp[i] += dp[j];
    //        //dp[i] %= MOD;
    //        dp[i] = (dp[i] + dp[j]) % MOD;
    //    }
    //}
    //cout << dp[S] << endl;

    // dp : O(N)
    // https://www.youtube.com/watch?v=yLkJZXkB6D0&feature=youtu.be
    vector<ll> dp(S + 1, 0);
    vector<ll> cum(S + 1, 0);
    dp[0] = cum[0] = 1;
    for (ll i = 1; i <= S; ++i) {
        if (i >= 3) {
            dp[i] = cum[i - 3];
        }
        cum[i] = (cum[i - 1] + dp[i]) % MOD;
    }
    cout << dp[S] << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr, arr+3);

  arr[0] -= arr[2];
  arr[1] -= arr[2];
  arr[2] = 0;
  int ans = -arr[1];

  ans += (arr[1] - arr[0]) / 2;
  if ((arr[1] - arr[0]) % 2 == 1)
    ans += 2;
  OUT(ans);

  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] r = "::Man:Oku:Cho:Kei:Gai:Jo:Jou:Ko:Kan:Sei:Sai:Gok:Ggs:Asg:Nyt:Fks:Mts".split(":");
        for (;;) {
            int n = sc.nextInt(), m = sc.nextInt();
            if ((n | m) == 0) {
                break;
            }
            String b = new BigInteger(n + "").pow(m).toString();
            if (b.length() % 4 > 0) {
                int s = 4 - b.length() % 4;
                while (s-- > 0) {
                    b = "0" + b;
                }
            }
            int l = b.length() / 4;
            for (int i = 0; i < b.length(); i += 4) {
                int a = Integer.parseInt(b.substring(i, i + 4));
                System.out.print(a > 0 ? a + r[l--] : "");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 26944
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (a, b) = read!(usize, usize);
    let ab = a * b;
    if ab % 2 == 1 {
        println!("Yes");
    } else if (ab * 3) % 2 == 1 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split();
            var n = int.Parse(r[0]);
            var m = int.Parse(r[1]);

            var d = new Dictionary<int ,string>();
            var e = new Dictionary<int ,int>();
            for(var i = 0; i < m; i++){
                var t = Console.ReadLine().Split();
                var p = int.Parse(t[0]);
                var s = t[1];

                if(d.ContainsKey(p)){
                    if(d[p].Equals("AC")){
                        continue;
                    }else{
                        d[p] = s;
                        if(s.Equals("WA")){
                            e[p] += 1;
                        }
                    }
                }else{
                    d.Add(p, s);
                    e.Add(p, 0);
                    if(s.Equals("WA")){
                        e[p] += 1;
                    }                    
                }
            }

            var ac = d.Count(x => x.Value == "AC");
            var wa = e.Where(x => d[x.Key].Equals("AC")).Sum(x => x.Value);
            Console.WriteLine(string.Format("{0} {1}",ac,wa));
        }
    }
}


Measured memory_bytes: 32724
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N - 1), B(N - 1), C(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> A[i] >> B[i]; A[i]--, B[i]--;
    }
    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < N - 1; i++) {
        G[A[i]].emplace_back(B[i], i);
        G[B[i]].emplace_back(A[i], i);
    }
    stack<pair<int, int>> S;
    for (int i = 0; i < N; i++) {
        if (G[i].size() == 1) { S.emplace(i, -1); break; }
    }
    int K = 0;
    while (!S.empty()) {
        int node, color; tie(node, color) = S.top(); S.pop();
        int c = 1;
        for (int i = 0; i < G[node].size(); i++) {
            int next, idx; tie(next, idx) = G[node][i];
            if (C[idx] != 0) continue;
            if (c == color) c++;
            C[idx] = c;
            S.emplace(next, c);
            K = max(c, K);
            c++;
        }
    }
    cout << K << '\n';
    for (auto c : C) cout << c << '\n';
    return 0;
}

Measured memory_bytes: 7680
import numpy as np

N = int(input())
WIDTH = 2
hight_arr = np.array(list(map(int, input().split())))
cost_arr = np.zeros(N,dtype=int)

for i in range(1,N):
    start = max(i-WIDTH,0)
    cost_arr[i] = np.min(np.abs(hight_arr[i] - hight_arr[start:i]) + cost_arr[start:i])
print(cost_arr[-1])

Measured memory_bytes: 22724
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		//今いる階段までどんだけかかったかを記憶
		int dp[]=new int[31];
		dp[0]=0;dp[1]=1;dp[2]=2;dp[3]=4;
		for(int i=4;i<31;i++)
			dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			int ans=dp[n]/3650+1;
			System.out.println(ans);
		}
	}		
}

Measured memory_bytes: 17180
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in); 
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int h = scanner.nextInt();
    
    System.out.println((a + b) * h / 2);
  }
}  

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

int main() {
    int h, n, sum = 0;
    cin >> h >> n;
    for (int i = 0; i < n; i++)
    {
        int a;cin >> a;
        sum += a;
    }
    string ans = "No";
    if(sum >= h)ans ="Yes";
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

  VAR(int, N);
  map< int, int > memo;
  function< int (int)> solve = [&](int n) {
    if (memo[n] > 0) return memo[n];
    if (n == 0) return memo[0] = 1;
    if (n == 1) return memo[1] = 2;
    return memo[n] = (solve(n >> 1) + solve((n - 1) >> 1) + solve((n - 2) >> 1)) % MOD;
  };

  int ans = solve(N);
  OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
// Will this ordering work? 
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		StringBuilder s = new StringBuilder(sc.next().replaceAll("eraser","")
			.replaceAll("erase","").replaceAll("dreamer","").replaceAll("dream",""));
		System.out.println(s.length()==0 ? "YES" : "NO");
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 41724
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>


using namespace std;
#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REP_(i,n,m) for( long long int i = (n); i <= (m); i++ )
#define CNT(i,n) for( long long int i = (n); i > 0; i-- )
#define CNT_(i,n) for( long long int i = (n); i >= 0; i-- )
#define SKIP(i,n,m) for( long long int i = (n); i < (m) ; i+=2 )
#define ll long long
#define ld long double
#define ft first
#define sd second
#define ALL(a) (a).begin(), (a).end()
#define srt(v) sort( v.begin(), v.end() );
#define sz(v) ( int ) v.size()
#define erase( v, i ) v.erase( v.begin() + i)
#define last(v) v[sz(v)-1]
#define swap( v, i, j ) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define out(a) printf( " %.16f¥n ", a );
#define vi vector<int>
#define vd vector<double>
#define vl vector<long long>
#define pa pair<int, int>
#define mulM( a, b, c ) a = a * b % c;
#define mp make_pair
#define pb push_back
#define iin(a) int a; cin >> a;
#define lin(a) long long int a; cin >> a;
#define sin(a) string a; cin >> a;
#define ios() ios_base::sync_with_stdio(0); cin.tie(0);
#define EPS (1e-10)
#define PI 3.14159265358979323846

int cnt=0;
int MOD=1000000007;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


void dfs( string s, int n ){
  if( s != "" ){
    if( stoll(s) > n ){
      return;
    }
    if( s.find("7") != string::npos && s.find("5") != string::npos && s.find("3") != string::npos){
      cnt++;
    }
  }
  dfs( s + "7",n );
  dfs( s + "5",n );
  dfs( s + "3",n );
}
void solve(){
  lin(n)
  dfs( "", n );

  cout << cnt << endl;

}

signed main() {
    ios()
    solve();
    return 0;
}


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

#define int long long

const int mod = 1e9 + 7;

int n,k;
int dp[2050][2050];

int fac[4000050],inv[4000050];
int ksm(int x,int y){
    int z = 1;
    while(y){
        if(y & 1) z = z * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return z;
}
int C(int n,int m){
    if(n < m || m < 0) return 0;
    if(n == m || m == 0) return 1;
    return (fac[n] * inv[m] % mod) * inv[n - m] % mod;
}

signed main(){
    scanf("%lld%lld",&n,&k);
    
    fac[0] = 1;
    for(int i = 1; i <= 4000000; ++ i) fac[i] = fac[i - 1] * i % mod;
    inv[4000000] = ksm(fac[4000000],mod - 2);
    for(int i = 3999999; i >= 0; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;
    
    if(k == 1) { puts("1"); return 0; } 
    
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++ i){
        dp[i][0] = 1;
        for(int j = 1; j <= i; ++ j){
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % mod * (n - j + 1) % mod ) % mod; 
        }
    }
    
    printf("%lld\n",dp[n][n]);
    return 0;
}

Measured memory_bytes: 89008
//https://atcoder.jp/contests/abc079/tasks/abc079_a
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	// string op;
	cin >> n;

	// cout << n[0] << " " << n[1] << " " << n[2] << endl;
	if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int n ;
int arr[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	if(n >= 30)
		cout<<"Yes\n" ;
	else
		cout<<"No\n" ;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
using namespace std;
int n;
int a[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=n;i>=1;i--){
		if(a[i]<a[i-1]){
			a[i-1]-=1;
			if(a[i]<a[i-1]){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		String N=reader.next();
		if (N.charAt(0)=='9' || N.charAt(1)=='9') {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
 	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    // init
    vector<vector<ll>> dp(N+1, vector<ll>(N+1));
    for (int i = 0; i < N; i++) dp[i][i] = 0;

    // DP
    for (int len = 1; len <= N; len++) {  // 間の配列の長さ
        for (int i = 0; i + len <= N; i++) {  // start
            int j = i + len;  // end
            // 先攻
            if ((N - len) % 2 == 0)
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            // 後攻
            else
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
        }
    }
    cout << dp[0][N] << '\n';
}


Measured memory_bytes: 73692
N=int(input())
MAX = 55555*5 + 10
def makePrimeChecker(n):
    """
    エラトステネスの篩.
    nまでの自然数が素数かどうかを表すリストを返す.
    O(nloglog(n))
    """
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i*i, n+1, i): #i 毎に大きくする
                isPrime[j] = False
    return isPrime

is_prime = makePrimeChecker(MAX)
nums = []
for num in range(2, 55555+1):
    if is_prime[num]:
        if num % 5 == 1:
            nums.append(num)
ans = nums[:N]
print(*ans)

Measured memory_bytes: 67456
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N,K;
    cin >> N >> K;
    ll cnt = 0;
    ll num;
    for(int i = 1; i <= K && i <= N; i++){
        if((2 * i) % K != 0) continue;
        num = 0;
        while((num+1)*K + i <= N){
           num++; 
        } 
        num++;
        cnt += num*num*num;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
int k;
int main(){
	scanf("%d",&k);
	if (k<=10){
		printf("%d\n",k);
		For(i,1,k){
			For(j,1,k) printf("%d ",i);
			puts("");
		}
	}
	else{
		int n=(k+3)/4*2;
		printf("%d\n",n);
		For(i,1,n){
			For(j,1,n){
				int x=(i+j)%n+(i&1?n:0);
				printf("%d ",x-(x>=k?n:0)+1);
			}
			puts("");
		}
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#define MAX 101

int A[MAX];

void print(int n) {
    for (int i = 0 ; i < n; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int n) {
    for (int i = 1; i < n; i++) {
        int j = i-1;
        int v = A[i];
        while ( j >= 0 && A[j] > v ) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print(n);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        A[i] = tmp;
    }
    
    print(n);
    insertionSort(n);
    
    return 0;
}

Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main()
{
	int h,w;
	cin >> h >> w;
	char c;
	int s[h][w];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> c;
			if(c=='#'){
				s[i][j]=1;
			}else{
				s[i][j]=0;
			}
		}
	}

	int ans=1;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			int cnt=0;
			if(s[i][j]==0){
				continue;
			}else{
				for(int k=0; k<4; k++){
					int ni=i+dx[k];
					int nj=j+dy[k];
					if(ni<0 || ni>=h || nj<0 || nj>=w){

					}else{
						cnt+=s[ni][nj];
					}
				}
				if(cnt==0){
					ans=0;
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;
int w,h;
int dp[101][101][2][2][3];
int solve(int x,int y,int x_f,int y_f,int prev){
  //1:true 0:false
  //prev 1: x , 2: y
  if(dp[y][x][x_f][y_f][prev] != -1)
    return dp[y][x][x_f][y_f][prev];
  if(x==w&&y==h){
    //ans++;
    return 1;
  }
  if(x>w || y>h)return 0;
  int ret = 0;
  if(x_f==1&&y_f==1){
    // cout<<"ff:"<<x<<"\t"<<y<<endl;
    if(prev == 1){
      ret = solve(x+1,y,1,1,1) + solve(x,y+1,0,1,2);
    }else if(prev == 2){
      ret = solve(x,y+1,1,1,2) + solve(x+1,y,1,0,1);
    }else{
      ret = solve(x,y+1,1,1,2) + solve(x+1,y,1,1,1);
    }
  }else if(x_f==0&&y_f==1){
    // cout<<"ft"<<x<<"\t"<<y<<endl;
    ret = solve(x,y+1,1,1,2);
  }else if(x_f==1&&y_f==0){
    //cout<<"tf"<<x<<"\t"<<y<<endl;
    ret = solve(x+1,y,1,1,1);
  }

  return dp[y][x][x_f][y_f][prev] = ret % 100000;

}


int main(){

  while(cin>>w>>h){
    if(w==0&&h==0)
      break;
    w--;h--;
    memset(dp,-1,sizeof(dp));
    cout<< solve(0,0,1,1,0) % 100000<<endl;
  }
  

  return 0;
}

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

int main()
{
    long long N;
    cin >> N;
    long long ans = N + 1 - 2;
    for (long long a = 1; a * a <= N; a++)
    {
        if (N % a == 0)
        {
            long long b = N / a;
            ans = min(ans, a + b - 2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdlib>  //abs()で絶対値を取得する（整数）
#include <cmath>    //abs()かfabs()で絶対値を取得する（少数）
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    ll n;
    ll a;
    ll b;
    ll x = 0;
    ll y = 0;
    ll ans = 0;
    cin >> n >> a >> b;
    x = n % (a+b);
    y = n / (a+b);
    if (x > a){
        ans = y * a + a;
    }
    if (x <= a){
        ans = y * a + x;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


int N;
int A[100010];

int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half;
	}
	else {

		return a * modpow(a, p - 1);
	}
}

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

	cin >> N;


	if (N == 0) {
		int a; cin >> a;
		if (a == 1)cout << 1 << endl;
		else cout << -1 << endl;
		return 0;
	}

	REP(i, N + 1)cin >> A[i];
	if (A[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	int sum[100010] = { 0 };
	for (int i = N; i >= 0; i--) {
		sum[i] = sum[i + 1] + A[i];
	}
	int ans = 1;
	int pa = 1;
	eFOR(i, 1, N) {
		int tmp = min(pa * 2, sum[i]);
		ans += tmp;
		if (tmp - A[i] < 0) {
			cout << -1 << endl;
			return 0;
		}
		pa = min(pa * 2, tmp - A[i]);
	}



	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for (int i = min(a, b); i >= 1; --i) {
        if (a % i == 0 && b % i == 0) {
            ++cnt;
            if (cnt == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, M, Q; cin >> N >> M >> Q;
    vector<vector<int>> a(N+5, vector<int>(N+5, 0)), cum(N+5, vector<int>(N+5, 0));
    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        a[l][r]++;
    }

    for(int l=1; l<=N; l++){
        for(int r=l; r<=N; r++) cum[l][r] = cum[l][r-1]+a[l][r];
    }

    vector<pair<int, int>> q(Q);
    for(int i=0; i<Q; i++) cin >> q[i].first >> q[i].second;
    
    for(int i=0; i<Q; i++){
        int l = q[i].first;
        int r = q[i].second;

        int sum = 0;
        for(int i=l; i<=r; i++) sum += cum[i][r];
        cout << sum << endl;
    }



}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    string sa[n];
    string sb[m];
    rep(i,n)
    {
        cin >> sa[i];
    }
    rep(i,m) cin >> sb[i];
    bool ansflag = false;
    rep(i,n-m+1) rep(j, n-m+1)
    {
        bool flag = true;
        rep(k,m) rep(l,m)
        {
            if (sa[i+k][j+l] != sb[k][l])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            // cout << i << " " << j << endl;
            ansflag = true;
            break;
        }
    }
    if (ansflag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N, A, B;
    cin >> N >> A >> B;

    if (A > B){
        cout << 0 << endl;
    }
    else if (N == 1 && A != B){
        cout << 0 << endl;
    }
    else if (N == 1 && A == B){
        cout << 1 << endl;
    }
    else {
    long long min = B + A * (N - 1);
    long long max = B * (N - 1) + A;

    cout << max - min + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	char c[200005];
	scanf("%s", c);
	int cntr = 0;
	for (i = 0; i < n; i++)
		if (c[i] == 'R')
			cntr++;
	int l, r;
	int ans = 0;
	l = 0;
	r = n - 1;
	while (l < cntr && r >= cntr)
	{
		if (c[l] == 'R')
		{
			l++;
			continue;
		}
		if (c[r] == 'W')
		{
			r--;
			continue;
		}
		ans++;
		l++;
		r--;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1928
arr = []

for _ in range(3):
    arr += list(map(int, input().split()))

a = [0] * 3
b = [0] * 3
a[0] = 0
b[0] = arr[0]
b[1] = arr[1]
b[2] = arr[2]
a[1] = arr[4] - b[1]
a[2] = arr[8] - b[2]

tmp = [a[i] + b[j] for i in range(3) for j in range(3)]

print('Yes' if arr == tmp else 'No')

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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;



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

  priority_queue<ll> q;
  //priority_queue< ll, vector<ll>, greater<ll> > q;
  //vector<ll> v;

  ll tmp = 0;
  ll a,b;
   // vector<ll> a(n);
   // vector<ll> b(n);
  rep(i, n) {
    cin >> a >> b;
    tmp = max(tmp, a);
    if (b>tmp) q.push(b);
  }

  int flag = 1;
  int u;
  // while(flag){
  //   u = q.top();
  //   if (u<tmp) q.pop();
  //   else flag = 0;
  // }

  int cnt=0;
  ll ans =0;
  while(flag){
    if (q.size()==0) break;
    u = q.top();
    if (u>tmp) {
      cnt += u;
      q.pop();
      ans++;
    }
    else flag=0;
    
    if (cnt>=h) flag=0;
  }

  if (cnt<h) ans += (h-cnt+tmp-1) / tmp;
  
 
  
  
  cout << ans << endl;  
  
}


Measured memory_bytes: 1400
n = int(input())
one_one = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
one_two = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
one_three = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
two_one = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
two_two = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
two_three = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
three_one = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
three_two = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
three_three = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
four_one = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
four_two = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
four_three = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(n):
    b, f, r, v = map(int, input().split())    
    if b == 1:
        if f == 1:
            one_one[r-1] += v
        elif f == 2:
            one_two[r-1] += v
        elif f == 3:
            one_three[r-1] += v
    if b == 2:
        if f == 1:
            two_one[r-1] += v
        elif f == 2:
            two_two[r-1] += v
        elif f == 3:
            two_three[r-1] += v
    if b == 3:
        if f == 1:
            three_one[r-1] += v
        elif f == 2:
            three_two[r-1] += v
        elif f == 3:
            three_three[r-1] += v
    if b == 4:
        if f == 1:
            four_one[r-1] += v
        elif f == 2:
            four_two[r-1] += v
        elif f == 3:
            four_three[r-1] += v
print(" ",end="")
print(" ".join(map(str, one_one)))
print(" ",end="")
print(" ".join(map(str, one_two)))
print(" ",end="")
print(" ".join(map(str, one_three)))
print("####################")
print(" ",end="")
print(" ".join(map(str, two_one)))
print(" ",end="")
print(" ".join(map(str, two_two)))
print(" ",end="")
print(" ".join(map(str, two_three)))
print("####################")
print(" ",end="")
print(" ".join(map(str, three_one)))
print(" ",end="")
print(" ".join(map(str, three_two)))
print(" ",end="")
print(" ".join(map(str, three_three)))
print("####################")
print(" ",end="")
print(" ".join(map(str, four_one)))
print(" ",end="")
print(" ".join(map(str, four_two)))
print(" ",end="")
print(" ".join(map(str, four_three)))


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

using namespace std;

const int INF = 1e+9;

int cnt;

void dfs(int n, int s, int now)
{
    if(now > 9)
    {
        if(n == 0 && s == 0) cnt++;
        return;
    }
    
    dfs(n - 1, s - now, now +1);
    dfs(n, s, now + 1);
    
    return;
}

int main()
{
    while (true)
    {
        int n, s;
        cin >> n >> s;
        cnt = 0;
        if(n == 0 && s == 0) return 0;
        
        dfs(n, s, 0);
        
        cout << cnt << endl;
    }
}

Measured memory_bytes: 2988
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  list<int> lst;
  string str;
  int n;
  int x;
  list<int>::iterator itr;

  cin >> n;
  for( int i = 0; i < n; ++i){
    cin >> str;
    if( str == "insert" ){
      cin >> x;
      lst.push_front(x);
    }else if( str == "delete"){
      cin >> x;
      for( itr = lst.begin(); itr != lst.end();++itr){
        if( *itr == x ){
          lst.erase(itr);
          break;
        }
      }
    }else if( str == "deleteFirst"){
      lst.pop_front();
    }else{
      lst.pop_back();
    }
  }

  auto itr2 = lst.end();
  itr2--;

  for( itr = lst.begin(); itr != itr2;++itr){
    cout << *itr << " ";
  }
  cout << lst.back() << endl;
}

Measured memory_bytes: 34384
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int  i=0;i<n;i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i< n-1;i++) {
            if (p[i-1] < p[i] && p[i] < p[i+1]) count++;
            if (p[i-1] > p[i] && p[i] > p[i+1]) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23636
from operator import mul
from itertools import starmap

n, m, l = map(int, input().split())
a, b = ([tuple(map(int, input().split())) for _ in range(k)] for k in (n, m))
for line in ([sum(starmap(mul, zip(ai, bj))) for bj in zip(*b)] for ai in a):
    print(*line)

Measured memory_bytes: 8684
#include <bits/stdc++.h> 
#define kk long long
using namespace std; 
 
int main() 
{ 
	
	  double i,j,n,m,a;
	 cin>>n>>m;
	 a=ceil(n/m);
	 cout<<a<<endl;
	 
	return 0; 
} 

// This is code is contributed by rathbhupendra 


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            // かず
            long[] N = Console.ReadLine().Split(' ').ToArray().Select(long.Parse).ToArray();

            if (N[0] == 1 || N[1] == 1)
            {
                Console.WriteLine("1");
            }
            else if (N[1] * N[0] % 2 == 0)
            {
                Console.WriteLine(String.Format("{0}", N[1] * N[0] / 2));
            }
            else
            {
                Console.WriteLine(String.Format("{0}",(N[1] * N[0] / 2 ) + 1));
            }
        }
    }
}


Measured memory_bytes: 28284
n = int(input())
s = input()

if n < 2:
    print(0)
    exit(0)

cum_r = [0] * (n + 1)
cum_g = [0] * (n + 1)
cum_b = [0] * (n + 1)

for i in range(n):
    cum_r[i + 1] = cum_r[i]
    cum_g[i + 1] = cum_g[i]
    cum_b[i + 1] = cum_b[i]
    if s[i] == "R":
        cum_r[i + 1] += 1
    elif s[i] == "G":
        cum_g[i + 1] += 1
    else:  # s[i] == "b":
        cum_b[i + 1] += 1

sum = 0
for i in range(n - 2):
    for k in range(n - 1, i + 1, -1):
        if s[i] == s[k]:
            continue

        # check "b"
        if (s[i] == "R" and s[k] == "G") or (s[i] == "G" and s[k] == "R"):
            sum += cum_b[k] - cum_b[i + 1]
            if (k + i) % 2 == 0 and s[(k + i) // 2] == "B":
                sum -= 1
        elif (s[i] == "R" and s[k] == "B") or (s[i] == "B" and s[k] == "R"):
            sum += cum_g[k] - cum_g[i + 1]
            if (k + i) % 2 == 0 and s[(k + i) // 2] == "G":
                sum -= 1
        else:
            sum += cum_r[k] - cum_r[i + 1]
            if (k + i) % 2 == 0 and s[(k + i) // 2] == "R":
                sum -= 1

print(sum)


Measured memory_bytes: 68396
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i =0; i < s.size()/2; i++) {
        if(s[i] != s[s.size()-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(x => long.Parse(x) * 2).ToArray();
        var half = a.Sum() / 2;
        long sum = 0;
        var halfa = a.TakeWhile(x => (sum += x) <= half).ToArray();
        var halfb = a.Skip(halfa.Length).ToArray();

        var fir = Abs(halfb.Sum() - halfa.Sum());
        var sec = Abs(a.Take(halfa.Length + 1).Sum() - a.Skip(halfa.Length + 1).Sum());

        Console.WriteLine(Min(fir, sec) / 2);
    }
}


Measured memory_bytes: 39296
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int n;
vector<ll> a;

ll memo[3050][3050];
ll rec(int i, int j){
	if(memo[i][j] != -1)return memo[i][j];
	if(j - i < 0)return 0; 

	bool flg = (i + j) % 2 == (n - 1) % 2; 
	if(flg)return memo[i][j] = max(rec(i + 1, j) + a[i], rec(i, j - 1) + a[j]);
	else return memo[i][j] = min(rec(i + 1, j), rec(i, j - 1));
}

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

  ll sum = accumulate(a.begin(), a.end(), 0LL);
  fill((ll*)memo, (ll*)memo + sizeof(memo) / sizeof(ll), -1);

  cout << 2 * rec(0, n - 1) - sum << endl;

  return 0;
}


Measured memory_bytes: 73088