akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int k = scanner.nextInt() - 1;

        int[] f = new int[Math.max(w + 2, 4)];
        f[0] = 1;
        f[1] = 1;
        for (int i = 2; i <= w; i++) {
            f[i] = f[i - 2] + f[i - 1];
        }

        long[][] dp = new long[h + 1][w];
        dp[0][0] = 1;
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j <= i && j < w; j++) {
                if (j > 0) {
                    dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] * f[w - j - 1] % 1000000007 * f[j - 1] % 1000000007) % 1000000007;
                }
                if (j < w - 1) {
                    dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * f[w - j - 2] % 1000000007 * f[j] % 1000000007) % 1000000007;
                }
                dp[i][j] = (dp[i][j] + dp[i - 1][j] * f[w - j - 1] % 1000000007 * f[j] % 1000000007) % 1000000007;
            }
        }
        System.out.println(dp[h][k]);
    }
}

Measured memory_bytes: 23764
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let vars: Vec<i32> = read_line();
    // let n = vars[0];
    let m = vars[1];
    let a: Vec<i32> = read_line();

    let sum_a_i: f32 = a.iter().fold(0., |acc, &x| acc + x as f32);

    let mut cnt = 0;
    for a_i in a.iter() {
        if *a_i as f32 >= sum_a_i / (4. * m as f32) {
            cnt += 1;
        }
        if cnt >= m {
            break;
        }
    }

    if cnt >= m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(int) A(N);
    READVEC(A);
    sort(ALL(A));

    VEC(Pii) ops(M);
    FOR(i, 0, M) {
        cin >> ops[i].second >> ops[i].first;
    }

    sort(ALL(ops));
    reverse(ALL(ops));

    int op = 0, card = 0;
    lint ret = 0;
    while (card < N) {
        if (op >= M) {
            ret += A[card++];
            continue;
        } else if (ops[op].second == 0) {
            op++;
            continue;
        } else {
            if (A[card] >= ops[op].first) {
                ret += A[card++];
            } else {
                ret += ops[op].first;
                ops[op].second--;
                card++;
            }
        }
    }

    cout << ret << endl;
    return 0;
};


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

int main() {
  int N;
  cin >> N;
  
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int max = 0;
  
  for (int i = 0; i < N; i++) {
    int score = 1;
    
    for (int j = i + 1; j < N; j++) {
      if (s.at(i) == s.at(j)) score++;
      // cout << s.at(i) << " " << s.at(j) << endl;
    }
    
    for (int j = 0; j < M; j++) {
      if (s.at(i) == t.at(j)) score--;
      // cout << s.at(i) << " " << t.at(j) << endl;
    }
    
    if (score > max) max = score;
  }
  
  cout << max << endl;
}

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

import math
max_n = sum([a for a in range(N-2+1)])


import sys

sys.setrecursionlimit(20000)

if N == 2 and K != 0:
    print(-1)
elif max_n >= K:
    non_edges = []
    for a in range(2, N+1):
        for b in range(a+1, N+1):
            if len(non_edges) == K:
                break
            non_edges.append((a, b))
    
    edges = []
    for a in range(1, N+1):
        for b in range(a+1, N+1):
            if (a, b) in non_edges:
                pass
            else:
                edges.append((a, b))
    
    print(len(edges))
    for a, b in edges:
        print(a, b)
else:
    print(-1)

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

typedef pair <int, int> ii;

const int Maxn = 200005;
const int mod = 998244353;

int n;
ii xd[Maxn];
vector <int> S;
int nxt[Maxn];
int dp[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &xd[i].first, &xd[i].second);
    sort(xd, xd + n);
    for (int i = n - 1; i >= 0; i--) {
        int my = i + 1;
        while (!S.empty() && xd[i].first + xd[i].second > xd[S.back()].first) {
            my = max(my, nxt[S.back()]);
            S.pop_back();
        }
        nxt[i] = my;
        S.push_back(i);
    }
    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--)
        dp[i] = (dp[i + 1] + dp[nxt[i]]) % mod;
    printf("%d\n", dp[0]);
    return 0;
}


Measured memory_bytes: 3832
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int A1 = sc.nextInt();
      	int A2 = sc.nextInt();
      	int A3 = sc.nextInt();
		if((A1 + A2 + A3) <= 21) {
        	System.out.print("win");
        }else{
        	System.out.print("bust");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	cin >> n;
	vector<ll> a(n);
	ll p = 1;
	ll cnt = 0;
	ll flg = false;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (a[i] == p) {
			p++;
			cnt++;
			flg = true;
		}
	}
	if (!flg) {
		cout << -1 << endl;
	}
	else {
		cout << n - cnt << endl;
	}
}


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

const double PI=4.0*atan(1.0);

int main(){
  int A,B,H,M;
  cin>>A>>B>>H>>M;

  double angle_h=PI/6.0*((double)H+(double)M/60.0);
  double angle_m=PI/30.0*M;
  double angle=abs(angle_h-angle_m);
  double x=sqrt((double)A*(double)A+(double)B*(double)B-2.0*(double)A*(double)B*cos(angle));
  printf("%.12lf\n",x);
}


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


int main()
{
    lli q=1;
    //cin>>q;
    
    while(q--)
    {
        string a,b;
        cin>>a>>b;
        cout<<b<<a<<endl;
    }
    return 0;

}

Measured memory_bytes: 256
program main
  implicit none
  integer :: h, n, i
  integer, allocatable :: a(:)
  read (*, *) h, n
  allocate (a(n))
  read (*, *) a(:)
  if (sum(a) < h) then
    write (*, "(a)") "No"
  else
    write (*, "(a)") "Yes"
  end if
end program main


Measured memory_bytes: 1152
package main

import "fmt"

func main() {
	// Code for C - 1D Reversi
	var S string
	fmt.Scanf("%s", &S)

	var count int
	for i := 0; i < len(S)-1; i++ {
		if S[i] != S[i+1] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 2572
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	int W, N;
	vector<int> vec(40, 0);
	REP(i, 40) {
		vec[i] = i;
	}

	cin >> W >> N;
	REP(i, N) {
		int A, B;
		char C;
		cin >> A >> C >> B;
		swap(vec[A], vec[B]);
	}

	REP2(i, 1, W + 1) {
		cout << vec[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll powmod(ll a, ll b, ll m = mod) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % m;
            --b;
        } else {
            a = (a * a) % m;
            b >>= 1;
        }
    }
    return res % m;
}
 
long long rev(long long a, long long m=mod) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<int> primes(1000001, 0);
    ll ans = 0;
    for (auto &i:a) {
        cin >> i;
        ans += rev(i);
        for (int j = 2; j * j <= i; ++j) {
            if (i % j == 0) {
                int pow = 0;
                while (i % j == 0) {
                    i /= j, pow++;
                }
                primes[j] = max(primes[j], pow);
            }
        }
        if (i != 1) {
            primes[i] = max(primes[i], 1);
        }
    }
    for (int i = 2; i <= 1000000; ++i) {
        if (primes[i] != 0) {
            (ans *= powmod(i, primes[i])) %= mod;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4224
import numpy as np
n = int(input())
a = list(map(int, input().split()))
n = len(a)
Mean1 = np.floor(sum(a) / n)
Mean2 = -(-sum(a) // n)
sum1 = sum([(x-Mean1)**2 for x in a])
sum2 = sum([(x-Mean2)**2 for x in a])
print(int(min(sum1, sum2)))


Measured memory_bytes: 12440
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

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

    int A,B,C;
    cin >> A >> B >> C;
    if(A <= C && C <= B){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*
  A - Two Rectangles
  Contest 052
  Rakesh Kumar --> 04/08/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0, c = 0, d = 0;
    std::cin >> a >> b >> c >> d;
    std::cout << std::max(a * b, c * d) << std::endl;

    return 0;
}


Measured memory_bytes: 3652
#pragma region Template

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <bitset>
#include<map>
#include<cmath>
#include <set>
#include<limits.h>
#include<fstream>

#define lli long long int
#define l long
#define us unsigned short
#define mod 1000000007
#define INF 1e9+5

#define vi vector<int>
#define vus vector<unsigned short>
#define vlli vector<long long int>
#define vs vector<string>
#define mii map<int,int>

#define w(t) int t; cin>>t;while(t--)

using namespace std;

#pragma endregion

int main()
{
	lli n,k;
	vlli v(100006);
	vlli dp(100006,INF);

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

	dp[0]=dp[1]=0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i + j <= n)
			{
				dp[i + j] = min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
			}
		}
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//#define int long long
vector<bool>sieve_bool(100001, true);
int cnt[100001];
vector<int> sieve(int n) {
	vector<int> prime;
	vector<bool> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	sieve_bool[0] =sieve_bool[1]= false;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
				sieve_bool[j] = false;
			}
		}
	}
	return prime;
}
signed main() {
	vector<int>primes = sieve(100000);
	for (int i = 3; i <= 100000; i += 2) {
		if (sieve_bool[i] && sieve_bool[(i + 1) / 2]) {
			cnt[i]++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		cnt[i] += cnt[i - 1];
	}
	int Q;
	scanf("%d", &Q);
	int l, r;
	while (Q--) {
		scanf("%d %d", &l, &r);
		printf("%d\n", cnt[r] - cnt[l - 1]);
	}

}

Measured memory_bytes: 1152
import sys
data = [t.rstrip() for t in sys.stdin.readlines()]

r = [i.split() for i in data]
n = [int(i) for i in r[1]]

ans = 0

#print(n)

for i in n:
    ii = i
    while ii % 2 == 0:
        ii /= 2
        ans += 1

print(ans)

Measured memory_bytes: 4212
#!/usr/bin/env python3

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

mod = 10**9+7

ans = 0
for k_ in range(k, n+2):
    low_lim = (0+(k_-1))*k_//2
    up_lim = ((n-k_+1)+n)*k_//2
    # print(up_lim-low_lim + 1)
    ans += up_lim - low_lim + 1

# low_lim = (((1+k) % mod) * (k % mod)) % mod // 2
# up_lim = (((1+n) % mod)*(n % mod) % mod)//2


# print(num % mod)
print(ans % mod)


Measured memory_bytes: 9144
#include<stdio.h>


int main(){

	int x;
	int total;
	scanf("%d",&x);
	
	if(x%1000 != 0){
		x = x % 1000;
		total = 1000-x;
		printf("%d",total);
	}
	else{
		printf("0");
	}


    return 0;
}


Measured memory_bytes: 1708
#include<iostream>
using namespace std;
typedef long long ll;
ll ans1[100005]={0},ans2[100005]={0},ans3[100005]={0};
int main(){
  ll n,k;
  cin>>n>>k;
  ll last=k+3*n-1;
  ll st=n*(2*n-k)+n*(n-1)/2;
  if(st<n*(n*2-1)){
    cout<<-1<<endl;
    return 0;
  }
  if(n%2==0){
    int pos=0;
    ll p2=0;
    for(int i=1;i<=n/2;i++){
      ans1[pos]=n-i;
      ans2[pos]=n/2-i+1;
      ans3[pos]=last-p2;
      pos++;
      p2+=2;
    }
    p2=1;
    for(int i=1;i<n/2;i++){
      ans1[pos]=n/2-i;
      ans2[pos]=n-i;
      ans3[pos]=last-p2;
      pos++;
      p2+=2;
    }
    ans1[pos]=0;
    ans2[pos]=0;
    ans3[pos]=last-p2;
  }
  else{
    ll pos=0;
    ll p2=0;
    for(int i=1;i<=(n+1)/2;i++){
      ans1[pos]=n-i;
      ans2[pos]=n/2-i+1;
      ans3[pos]=last-p2;
      pos++;
      p2+=2;
    }
    p2=1;
    for(int i=1;i<=n/2;i++){
      ans1[pos]=n/2-i;
      ans2[pos]=n-i;
      ans3[pos]=last-p2;
      pos++;
      p2+=2;
    }
  }
  for(int i=0;i<n;i++){
    cout<<ans1[i]+k<<" "<<ans2[i]+n+k<<" "<<ans3[i]<<endl;
  }
}


Measured memory_bytes: 4608
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define loopi(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) loopi(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl "\n"
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/10;

int popcount(unsigned long long x){
    static int dp[66000];
    if(dp[65536] != 16) for(int i = 0; i < 65536; i++) dp[i] = (i&1) + dp[i>>1];
    int res = 0;
    while(x) res += dp[x&65535], x >>= 16;
    return res;
}

int solve(ll s, ll d){
    //if(s <= 0 && d >= 0) return __builtin_popcount(-s) + __builtin_popcount(d);
    if(s <= 0 && d >= 0) return popcount(-s) + popcount(d);
    else if(s >= 0 && d >= 0){
        int j = 0;
        int ans = 0;
        while(s < d){
            if((s>>j&1) && (d>>j&1)){
                s += 1LL<<j;
                d -= 1LL<<j;
                ans += 2;
            } else if((s>>j&1) ^ (d>>j&1)){
                s += 1LL<<j;
                ans ++;
            }
            j++;
        }
        return ans;
    } else return solve(-d,-s);
}

signed main(){
    fastios();
    int N;
    cin >> N;
    rep(i,N){
        ll s,d;
        cin >> s >> d;
        cout << solve(s,d) << endl;
    }
}

Measured memory_bytes: 1456
N = gets
a = gets.split.map(&:to_i)
n1 = a.select { |i| i < 3200 }.group_by { |i| i / 400 }.size
n2 = a.select { |i| i >= 3200 }.size
puts [
  [n1, 1].max,
  n1 + n2
].join(" ")


Measured memory_bytes: 3836
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int N = (int)(b-a);
        int h = wa(N-1);
        System.out.println(h-a);
    }
    
    public static int wa(int x) {
        if(x == 1) {
            return 1;
        }else {
            return x + wa(x-1);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    string ans;
    rep(i, max(a, b)) {
        ans += to_string(min(a, b));
    }
    co(ans);
    return 0;
}

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

using namespace std;


typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k%2) cout << b-a << endl;
  else cout << a-b << endl;
  return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for (ll &e : A) cin >> e;
    sort(ALLR(A));
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (K) {
            K--;
        } else {
            ans += A[i];
        }
    }

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


Measured memory_bytes: 1792
n = int(input())
b = list(map(int, input().split()))
res=0
a = [0]*n
for i in range(1,n-1):
  a[i]=min(b[i],b[i-1])
a[n-1]=b[n-2]
a[0]=max(a[1],b[0])
for i in range(n):
  res+=a[i]
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<=a.length();i++)
	{
		if(a[i]=='C')
		{
			if(a[i-1]=='A')
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
C = [list(map(int, input().split())) for _ in range(3)]
ans = 'Yes'

for i in range(2):
    if C[i][0] - C[i+1][0] != C[i][1] - C[i+1][1] or \
        C[i][0] - C[i+1][0] != C[i][2] - C[i+1][2]:
        ans = 'No'

        
for j in range(2):
    if C[0][j] - C[0][j+1] != C[1][j] - C[1][j+1] or \
        C[0][j] - C[0][j+1] != C[2][j] - C[2][j+1]:
        ans = 'No'

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;

int main(){
  ll N;
  cin>> N;
  ll step = N;
  ll point = 0;
  int dir = 1;
  string prev = "start";
  for(int i=0;i<20;++i){
    
    cout<<point<<endl;
    string res;
    cin >> res;
    if(res == "Vacant"){
      cerr<<"fin";
      return 0;
    }
    cerr<<prev<<","<<res<<endl;
    if( (res == prev && step%2 ==0) || (res!=prev && step%2 == 1) ){
      cerr<<"novac"<<endl;
    }else{
      cerr<<"vac"<<endl;
      dir = dir*-1;
    }
    step = step /2 + step%2;
    if(step==0){step = 1;}

    point += N + dir * step;
    point = point%N;
    prev = res;
  }
  
  return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

bool check(ll k, ll d, const vector<ll>& as){
    vector<ll> rs(as.size());
    for(int i = 0; i < as.size(); ++i){
        rs.at(i) = as.at(i) % d;
    }
    sort(rs.begin(), rs.end());

    vector<ll> cs(rs.size(), 0);
    cs.at(0) = rs.at(0);
    for(int i = 1; i < rs.size(); ++i){
        cs.at(i) = cs.at(i - 1) + rs.at(i);
    }

    vector<ll> rcs(rs.size(), 0);
    rcs.at(rs.size() - 1) = d - rs.back();
    for(int i = rs.size() - 2; i >= 0; --i){
        rcs.at(i) = d - rs.at(i) + rcs.at(i + 1);
    }

    for(int i = 0; i < rs.size() - 1; ++i){
        if(cs.at(i) == rcs.at(i + 1) && cs.at(i) <= k){
            return true;
        }
    }
    if(cs.back() == 0){ return true; }
    return false;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);
    ll suma = 0;
    for(int i = 0; i < n; ++i){
        cin >> as.at(i);
        suma += as.at(i);
    }

    ll ans = 1;
    for(ll d = 1; d * d <= suma; ++d){
        if(suma % d != 0){ continue; }
        if(check(k, d, as)){
            ans = max(ans, d);
        }
        if(check(k, suma / d, as)){
            ans = max(ans, suma / d);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int h = in.nextInt();
        int x = in.nextInt();
        out.println((int)Math.ceil(h/(x*1.0)));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int main(void) {
  int a, b;
  char op;
  while(true){
  cin >> a >> op >> b;
  if ( op == '+'){
      cout << (a+b) << endl;
  }
  else if ( op == '-'){
      cout << (a-b) << endl;
  } 
  else if ( op == '*' ){
      cout << (a*b) << endl;
  }
  else if ( op == '/' ){
      cout << (a/b) << endl;
      
} else if ( op == '?' ){
    break;
}
}
}


Measured memory_bytes: 3076
#include <stdio.h>

// min
int main(void){
  char s[4];
  int ans = 0;

  scanf("%s", s);

  if(s[0] == '1'){
    ans++;
  }
  if(s[1] == '1'){
    ans++;
  }
  if(s[2] == '1'){
    ans++;
  }

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

}


Measured memory_bytes: 128
object Main extends App {
	val n = scala.io.StdIn.readInt
	val Array(t, a) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val h = scala.io.StdIn.readLine.split(" ").map(_.toDouble).map{z => math.abs(t - z*0.006 - a)}
 
	println(h.indexOf(h.min) + 1)
}

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

int main(){
 int E, Y;
 cin >> E >> Y;

 switch(E){
  case 0:
   if(1868<=Y&&Y<=1911) cout << 'M' << Y-1867 << endl;
   if(1912<=Y&&Y<=1925) cout << 'T' << Y-1911 << endl;
   if(1926<=Y&&Y<=1988) cout << 'S' << Y-1925 << endl;
   if(1989<=Y&&Y<=2016) cout << 'H' << Y-1988 << endl;
   break;
  case 1:
   cout << 1867 + Y << endl;
   break;
  case 2:
   cout << 1911 + Y << endl;
   break;
  case 3:
   cout << 1925 + Y << endl;
   break;
  case 4:
   cout << 1988 + Y << endl;
   break;
 }

 return 0;
}
                                  

Measured memory_bytes: 3076
function Main(input){

  var inp = input.split(' ');
  var A = parseInt(inp[0]); // 水の量
  var B = parseInt(inp[1]); // 水の量
  var C = parseInt(inp[2]); // 砂糖の量
  var D = parseInt(inp[3]); // 砂糖の量
  var E = parseInt(inp[4]); // 水100gあたりの溶ける砂糖の量
  var F = parseInt(inp[5]); // 砂糖水の総量
  
  var waterTotal = []; // とりうる水の量
  var sugarTotal = []; // とりうる砂糖の量
  
  var sugarWater = []; // とりうる砂糖水の量
  var sugarWeight = []; // とりうる砂糖の量
  
  // とりうる水と砂糖の量を列挙
  for(var i = 0; i <= F; i++){
    for(var j = 0; j <= F; j++){
      var water = ((A * i) + (B * j)) * 100; // 水の量
      if(water <= F ) waterTotal.push(water); 
  
      var sugar = (C * i + D * j); // 砂糖の量
      if(sugar <= F) sugarTotal.push(sugar);
    }
  }  
  
  // とりうる砂糖水と砂糖の量を列挙
  for(var i = 0; i <= F; i++){
    for(var j = 0; j <= F; j++){
      var sw = waterTotal[i] + sugarTotal[j]; // 砂糖水の量
      var meltSugar = 100 * sugarTotal[j] / waterTotal[i]; // 水に溶ける砂糖の量
      if( sw <= F && meltSugar <= E){
        sugarWater.push(sw); 
        sugarWeight.push(sugarTotal[j]);
      }
    }
  }
  
  // 各砂糖水と砂糖の量から、濃度を求める
  var noudo = 0;
  var noudoIndex = 0;
  for(var i = 0; i < sugarWater.length; i++){
    var noudoTmp = (100 * sugarWeight[i]) / sugarWater[i]; // 砂糖水の濃度
    if(noudoTmp > noudo){
      noudo = noudoTmp;
      noudoIndex = i;
    }
  }
  
  console.log(sugarWater[noudoIndex] + ' ' + sugarWeight[noudoIndex]);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

public class Main {

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

		while (in.hasNext()) {
			int N = in.nextInt();
			int[] L = new int[N];

			for (int i = 0; i < L.length; ++i) {
				L[i] = in.nextInt();
			}

			Arrays.sort(L);

			int count = 0;
			for (int i = 0; i < L.length; ++i) {
				for (int j = i + 1; j < L.length; ++j) {
					int sum = L[i] + L[j];

					int k = lowerBound(L, 0, L.length, sum);
					k = Math.max(k, -(k + 1));
					
				    count += Math.max(0, k - j - 1);
					
					//System.err.println(k);
				}
			}

			System.out.println(count);
		}
	}

	private static int lowerBound(int[] a, int fromIdx, int toIdx, int key) {
		while (fromIdx < toIdx) {
			int mid = fromIdx + (toIdx - fromIdx) / 2;

			if (a[mid] < key) {
				fromIdx = mid + 1;
			} else { // key <= a[mid]
				toIdx = mid;
			}
		}

		if ( 0 <= fromIdx && fromIdx < a.length && a[fromIdx] == key) {
			return fromIdx;
		} else {
			return -fromIdx - 1;
		}
	}

}


Measured memory_bytes: 26496
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int n, m;
int main() {
    string s;
    cin >> s;
    if(s == "ARC") {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
	int inputA, inputB, inputC;

	scanf("%d %d %d", &inputA, &inputB, &inputC);
	
	// Checks if all numbers have the same value
	if (inputA == inputB && inputB == inputC)
	{
		printf("No \n");
        return 0;
	}

	// Checks if inputed numbers are 'poor'
	if (inputA == inputB || inputA == inputC || inputB == inputC)
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  while (op != '?') {
    if (op == '+') {
      cout << a + b << endl;
      cin >> a >> op >> b;
    } else if (op == '-') {
      cout << a - b << endl;
      cin >> a >> op >> b;
    } else if (op == '*') {
      cout << a * b << endl;
      cin >> a >> op >> b;
    } else if (op == '/') {
      cout << a / b << endl;
      cin >> a >> op >> b;
    }
  }
}


Measured memory_bytes: 3108
while True:
    try:
        a = raw_input()
        if a[::4] == "ooo" or a[2:8:2] == "ooo":
            print "o"
        elif a[::4] == "xxx" or a[2:8:2] == "xxx":
            print "x"
        else:
            for i in range(3):
                if a[3*i:3*(i+1)] == "ooo" or a[i::3] == "ooo":
                    print "o"
                    break
                elif a[3*i:3*(i+1)] == "xxx" or a[i::3] == "xxx":
                    print "x"
                    break
                elif i == 2:
                    print "d"
    except:
        break
            

Measured memory_bytes: 4220
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);

    int h[N];
    REP(i, N) {
        scanf("%d", &h[i]);
    }

    sort(h, h + N, greater<int>());

    long ng = 0;
    long ok = 1e9;
    while (abs(ok - ng) > 1) {
        long mid = (ng + ok) / 2;

        long count = 0;
        REP(i, N) {
            long hi = h[i] - (B * mid);
            if (hi > 0) {
                count += (hi + (A - B) - 1) / (A - B);
            }
        }

        // printf("count = %ld, mid = %ld, ok = %d, ng = %d\n", count, mid, ok, ng);
        if (count <= mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    printf("%ld\n", ok);

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int k,s; cin >> k >> s;
  int res = 0;
  rep(i,k+1) {
    rep(j,k+1) {
      if(0 <= s - i - j && s - i - j <= k) res++;
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3528
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    ans = 0
    n = int(input())
    for j in range(1,n+1):
        ans += j*(n//j)*(n//j + 1)//2
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 66252
import java.util.Scanner;
import java.util.Random;
import java.math.*;

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

        int b=(int)(Math.pow(a,2)+Math.pow(a,3)+a);
            System.out.println(b);
    }
}

Measured memory_bytes: 35796
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>


using namespace std;

using ll = long long int;
using lln = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
const long MOD = pow(10, 9) + 7;

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(double num) {
	return log10(num) + 1;
}

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}

	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};



template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

int parmitation(ll N) {
	ll ans = 1;
	for (ll i = 1; i <= N; i++) {
		ans *= i;
	}

	return ans;
}

int SemiCommonMultiple(ll A, ll ANum, ll B, ll BNum, ll diff,ll max) {
	ll calc;
	calc = diff + B * BNum - A * ANum;

	if (diff + B * BNum > max) {
		return 0;
	}
	else {
		if (calc < 0) {
			SemiCommonMultiple(A, ANum, B, ++BNum, diff, max);
		}
		else if (calc > 0) {
			SemiCommonMultiple(A, ++ANum, B, BNum, diff, max);
		}
		else {
			return A * (ANum + 0.5);
		}
	}
}

inline void Main() {
	ll X, Y, N, M;
	vector<ll> A;
	ll M1 = 1, D1 = 0, M2 = 1, D2 = 0;
	ll ans,temp;
	ll sum = 0, count = 0, a = 0;
	string S;
	string T;
	string Ans = "";
	bool b[8];
	bool flag = false;


	cin >> S;
	


	cout << (char)(S[0]+1);
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5,mod=998244353;
typedef long long ll;
ll f[N],invf[N],sum[N];
int n;
ll C(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    f[0]=f[1]=invf[0]=invf[1]=1;
    for(int i=2;i<N;i++)
    {
        f[i]=f[i-1]*i%mod;
        invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    }
    for(int i=2;i<N;i++) invf[i]=invf[i]*invf[i-1]%mod;
    for(int i=1;i<N;i++) sum[i]=(sum[i-1]+C(n,i))%mod;
    int n;scanf("%d",&n);
    ll ans=qpow(3,n);
    for(int i=n/2+1;i<=n;i++)
        ans=(ans-C(n,i)*qpow(2,n-i)%mod*2)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 234624
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(true){
			String str=s.nextLine();
			if(str.equals("END OF INPUT"))System.exit(0);
			String []table=str.split(" ");
			for(int i=0;i<table.length;i++){
				System.out.print(table[i].length());
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const ll inf = 99900100100;
const int MOD = 998244353;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int dp[10100] = {};
    int n,W;
    cin >> n >> W;
    int v[110],w[110];
    rep(i,n) cin >> v[i] >> w[i];
    rep(i,n){
      rrep(j,W-w[i]+1){
        dp[j+w[i]] = max(dp[j+w[i]],dp[j] + v[i]);
      }
    }
    cout << dp[W] << endl;
    return 0;
}



Measured memory_bytes: 3228
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    ll max_height = -1;
    ll cnt = 0;
    REP(i, n) {
        ll h = in();
        if (max_height <= h) {
            max_height = h;
            ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n + 2];
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 1; i <= n + 1; i++) {
			sum += Math.abs(a[i] - a[i - 1]);
		}
		int ans = 0;
		for (int i = 1; i < n + 1; i++) {
			ans = sum + Math.abs(a[i + 1] - a[i - 1])
					- (Math.abs(a[i - 1] - a[i]) + Math.abs(a[i] - a[i + 1]));
			sb.append(ans + "\n");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 61940
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  long long int h,w;
  cin>>h>>w;
  vector<vector<long long int> > c(10,vector<long long int>(10));
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>c[i][j];
    }
  }
 
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
 
  long long int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      cin>>a;
      if(a!=-1){
        ans+=c[a][1];
      }
    }
  }
 
  cout<<ans<<endl;
 
  return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    int R, G;
    cin >> R >> G;
    cout << G * 2 - R << endl;

    return 0;
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

int n;
int w;
vector<pair<int, int>> val;
#define INF 1e18L + 5

void solve()
{
    cin >> n >> w;
    val.clear();
    val.resize(n);
    int sum_value = 0;
    forn(i, n)
    {
        cin >> val[i].first >> val[i].second;
        sum_value += val[i].ss;
    }

    vector<ll> dp(sum_value + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        vector<ll> new_dp(sum_value + 1, INF);
        for(int j = 0; j <= sum_value; j++){
            if(j - val[i].ss >= 0){
                new_dp[j] = dp[j - val[i].ss] + val[i].ff;
            }

            new_dp[j] = min(dp[j], new_dp[j]);
        }
        dp = new_dp;
    }

    ll max1 = 0;
    for(int i = 0; i <= sum_value; i++){
        if(dp[i] <= w){
            max1 = i;
        }
    }

    cout << max1 << endl;
}

int main()
{
    zoom;
    ll t = 1;
    // cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 4756
#include<cstdio>
typedef long long ll;
const int N=2e5+10;
int a[N],n;
ll x[N],y[N],ans=1e18;
ll mi(ll a,ll b){return a<b?a:b;}
ll ab(ll x){return x<0?-x:x;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		x[i]=x[i-1]+a[i];
	for(int i=n;i;i--)
		y[i]=y[i+1]+a[i];
	for(int i=1;i<n;i++)
		ans=mi(ab(x[i]-y[i+1]),ans);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3116