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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static int inf = 0x7ffffff;

    public static void main(String[]$) throws Exception {
        int n = scanner.nextInt();
        int[] l = scanner.nextIntArray(n);
        Arrays.sort(l);
        long count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int b = lowerBound(l, l[j] + l[i]);
                count += b - j - 1;
            }
        }
        System.out.println(count);
    }

    static int lowerBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            if (array[mid] < value) {
                left = mid;
            } else {
                right = mid;
            }
        }
        return right;
    }

    static class System {
        static PrintWriter out = new PrintWriter(java.lang.System.out);

        static {
            Runtime.getRuntime().addShutdownHook(new Thread(System.out::flush));
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        char[][] nextCharArray(int n, int m) {
            char[][] a = new char[n][m];
            for (int i = 0; i < n; i++) {
                a[i] = next().toCharArray();
            }
            return a;
        }

        int[] nextIntArray(int n, java.util.function.IntUnaryOperator op) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsInt(nextInt());
            }
            return a;
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        long[] nextLongArray(int n, java.util.function.LongUnaryOperator op) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsLong(nextLong());
            }
            return a;
        }
    }
}


Measured memory_bytes: 28756
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>

using namespace std;

void SolveA()
{
	int a, b;
	scanf("%d %d", &a, &b);

	int x = ceil((a + b) / 2.0);
	printf("%d\n", x);
}

int main()
{
	SolveA();
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	n=int(input())
	s=set()
	
	for i in range(1,10):
		for j in range(1,10):
			s.add(i*j)
	if n in s:
		print("Yes")
	else:
		print("No")
	
	
	
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
N,A,B=[int(i) for i in input().split(" ")]
sum = 0
for n in range(N+1):
    t,v = n,0
    for i in reversed(range(5)):
        v+=int(t/pow(10,i))
        t-=int(t/pow(10,i)) * pow(10,i)
    if A <= v <= B:
        sum+=n
print (sum)

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

int main(){
    string S;
    int K;
    cin >> K >> S;
    int len = S.size();
    if(len <= K){
        cout << S;
    }else {
        for(int i = 0; i < K; i++){
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int a[15];
string b,c; 
int main(){
	int n;
	cin>>n;
	while(n--){
		for(int i=0;i<10;i++){
			cin>>a[i];	
		}
		for(int i=0;i<=1024;i++){
			if(i==1024){
				cout<<"NO"<<endl;
				break;
			}
			c.clear();b.clear();
			for(int j=0;j<10;j++){
				if((i>>j)&1){//进c 
					c+=('0'+a[j]);
				}
				else{//进b 
					b+=('0'+a[j]);
				}
			}
			int ok=1;
			for(int j=0;j<b.size()-1;j++){
				if(b[j]>b[j+1]){
					ok=0;
					break;
				}
			}
			for(int j=0;j<c.size()-1;j++){
				if(c[j]>c[j+1]){
					ok=0;
					break;
				}
			}
			if(ok){
				cout<<"YES"<<endl;break;
			}
		}
	}	
	return 0;
}


Measured memory_bytes: 3020
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut sc = io::Scanner::new(&buf);

    let n: usize = sc.next();
    let a: Vec<usize> = sc.vec(n);

    let mut ans = 0;
    let mut i = 0;
    while i < n {
        if i + 1 < n && a[i] == a[i+1] {
            ans += 1;
            i += 2;
        } else {
            i += 1;
        }
    }

    println!("{}", ans);
}

pub mod io {
    pub struct Scanner<'a> {
        iter: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: ::std::str::FromStr>(&mut self) -> T {
            if let Ok(v) = self.iter.next().unwrap().parse() {
                v
            } else {
                panic!("parsing failed")
            }
        }

        pub fn vec<T: ::std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }
}



Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;



int main(void){
    ll r; cin >> r;
    cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int x, n;
    cin >> x >> n;
    vi v(n);
    cin >> v;
    set<int> s(all(v));
    rep(i,0,n+1)
    {
        if(!s.count(x-i))
            ret(x-i);
        if(!s.count(x+i))
            ret(x+i);
    }
}


Measured memory_bytes: 3180
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp::{max, min};

fn main() {

  let s: String = read();
  let t: String = read();
  let s_char: Vec<char> = s.chars().collect();
  let mut cnt = 0;
  for (i, v) in t.chars().enumerate() {
    if v == s_char[i] {
      cnt += 1;
    }
  }
  println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <stdio.h>



int main()
{
	
	int A,B,X;
	scanf("%d %d %d", &A, &B, &X);
	
	if(X < A || X > (A+B)){
		printf("NO");
	}
	else{
		printf("YES");
	}

	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define pb push_back()
double r;
int main()
{
	scanf("%lf",&r);
	printf("%.10f\n",2.0*acos(-1)*r);
return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int count = 0;
  
  while (A >= B) {
    B *= 2;
    count++;
  }
  
  while (B >= C) {
    C *= 2;
    count++;
  }
  
  if (count <= K) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;


int main(){
  double l;
  cin >> l;
  cout <<fixed<<setprecision(6)<< (l*l*l)/27;

}


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

map< pair<long long, long long>, int> lft;

const long long p = 99999999999999997LL;

char str[45];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s", str);
    long long ans = 0;
    for(int i=0;i<(1 << n);i++){
        long long red = 0, blue = 0;
        for(int j=0;j<n;j++){
            if(i & (1 << j)){
                red = (red * 27 + (str[j] - 'a') + 1) % p;
            }
        }
        for(int j=n-1;j>=0;j--){
            if((i & (1 << j)) == 0){
                blue = (blue * 27 + (str[j] - 'a') + 1) % p;
            }
        }
        //printf("%lld %lld\n", red, blue);
        lft[{red, blue}]++;
    }
    for(int i=0;i<(1 << n);i++){
        long long red = 0, blue = 0;
        for(int j=0;j<n;j++){
            if(i & (1 << j)){
                blue = (blue * 27 + (str[n+j] - 'a') + 1) % p;
            }
        }
        for(int j=n-1;j>=0;j--){
            if((i & (1 << j)) == 0){
                red = (red * 27 + (str[n+j] - 'a') + 1) % p;
            }
        }
        ans += lft[{red, blue}];
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 33024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	double L;
	cin >> L;

	cout << fixed << setprecision(10) <<  L * L * L / 27 << "\n";

	return 0;
}

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

int main() {
  int score[6];
  for (int i = 0; i < 6; i++) {
    cin >> score[i];
  }

  int sum = 0;
  for (int i = 0; i < 6; i++) {
    sum += score[i];
  }
  
  int mini;
  mini = score[0];
  for (int i = 0; i <= 3; i++) {
    if (score[i] < mini) mini = score[i];
  }
  sum -= mini;

  if (score[4] < score[5]) mini = score[4];
  else mini = score[5];
  sum -= mini;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3096
package main
 
import "fmt"
 
func main() {
  var a,b,k int
  
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&k)
  
  var l = 1
  
  if a<b {
    l = a 
  } else {
    l = b
  }
  
  for i:=l; i>0; i-- {
    if a%i == 0 && b%i == 0 {
      k--
    }
    if k == 0 {
      fmt.Println(i)
      return
    }
  }

}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  ll n;cin>>n;
  vvll g(n,vll(0));
  rep(i,0,n){
    ll m,k;cin>>m>>k;
    m--;
    rep(j,0,k){
      ll v;cin>>v;
      v--;
      g[m].push_back(v);
     
    }
  }
  vb seen(n,false);vll ans(n,-1);
  queue<ll> q;
  q.push(0);
  ll cnt=0;
  ans[0]=0;
  while(!q.empty()){
    ll tmp=q.front();
    q.pop();
    seen[tmp]=true;
    for(ll u:g[tmp]){
      if(seen[u])continue;
      q.push(u);
      if(ans[u]==-1)ans[u]=ans[tmp]+1;
    }
  }
  rep(i,0,n){
    cout<<i+1<<' '<<ans[i]<<endl;
  }
}



Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n, k;
vi vv;

void init()
{
	cin >> n >> k;
	vv.resize(n);
	REP(i, n) cin >> vv[i];
}

int main()
{
	init();

	vi tmp1;
	int ans = 0;

	for (int left = 0; left <= k && left <= n; left++)
	{
		if (left)
			tmp1.PB(vv[left - 1]);

		for (int right = 0; right <= (k - left) && right + left <= n; right++)
		{
			vi tmp2(tmp1);
			for (int i = n - 1; i >= (n - right); --i)
				tmp2.PB(vv[i]);

			//cout << "left = " << left << ", right = " << right << " vec = [ ";
			//REP(i, SZ(tmp2))
			//	cout << tmp2[i] << " ";
			//cout << " ]" << endl;

			int s = accumulate(ALL(tmp2), 0);
			sort(ALL(tmp2));

			int rm = 0;
			while (rm < (k - left - right) && rm < (left + right))
			{
				if (tmp2[rm] < 0)
					s -= tmp2[rm++];
				else
					break;
			}
			chmax(ans, s);
		}
	}

	cout << ans << endl;

}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N;
int a[25][25];
int lg2[100005];
LL group[100005];
LL dp[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            scanf("%d", &a[i][j]);

    for(int i = 2; i < (1 << N); i++)   lg2[i] = lg2[i >> 1] + 1;

    for(int msk = 1; msk < (1 << N); msk++)
    {
        int msk2 = msk ^ (msk & (-msk));
        int i = lg2[msk & (-msk)];
        group[msk] = group[msk2];
        for(int j = 0; j < N; j++)
            if((msk2 >> j) & 1)
                group[msk] += a[i][j];
    }

    for(int msk = 1; msk < (1 << N); msk++)
    {
        for(int msk2 = (msk - 1) & msk; msk2 > 0; msk2 = (msk2 - 1) & msk)
            dp[msk] = max(dp[msk], dp[msk2] + dp[msk2 ^ msk]);
        dp[msk] = max(dp[msk], group[msk]);
    }

    cout << dp[(1 << N) - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,flag=0;
  string s;
  cin>>a>>b>>s;
  rep(i,a+b+1){
    if (i!=a) {
      if (s.at(i)=='-') {
        flag+=1;
        break;
      }
    }
    else if (i==a) {
      if (s.at(i)!='-') {
        flag+=1;
        break;
      }
    }
  }
  if (flag==0) {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
max = 10 ** 18

if a.any?(&:zero?)
  puts 0
else
  anser = 0
  a.each_with_index do |v, i|
    if i.zero?
      anser = v
    else
      anser *= v
    end
    if anser > max
      anser = -1
      break
    end
  end
  puts anser
end

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

int		main(void)
{
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	cout << a.at(0) + a.at(1) + a.at(2) * 10 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



ll n, a[100005], b[100005], ans;

int main() {

	cin >> n;
	rep(i, n + 1) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}

	rep(i, n) {
		if (a[i] >= b[i]) {
			ans += b[i];
		}
		else {
			ans += a[i];
			b[i] -= a[i];
			if (a[i + 1] >= b[i]) {
				ans += b[i];
				a[i + 1] -= b[i];
			}
			else {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define      ll     long long int

const int N = 100005;
int A[N];
int B[N];
int C[N];

int main()
{
    ll n, i, j, k, l;
    ll s = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A + n);
    for (i = 0; i < n; i++) {
        cin >> B[i];
    }
    sort(B, B + n);
    for (i = 0; i < n; i++) {
        cin >> C[i];
    }
    sort(C, C + n);
    for (i = 0; i < n; i++) {
        j = B[i];
        k = (int) (lower_bound(A, A + n, j) - A);
        l = (int) (upper_bound(C, C + n, j) - C);
        l = n - l;
        //cout << j << ' ' << k << ' ' << l << '\n';
        s += (k * l);
    }
    cout << s << '\n';
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string ans = "";
    for(int i = 0; i < N; i++){
        ans += S[i];
        ans += T[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using PZL = vector<vector<int>>;

#define bsize 4

int potential(PZL p) {
    int res = 0;
    rep(i, bsize) {
        rep(j, bsize) {
            int x = (p[i][j] - 1) % bsize;
            int y = (p[i][j] - 1) / bsize;
            if (p[i][j] == 0) continue;
            res += abs(j - x) + abs(i - y);
        }
    }
    return res;
}

ll encode(PZL p) {
    ll res = 0;
    ll base = 1;
    rep(i, bsize) {
        rep(j, bsize) {
            if (i == 0 && j == 0) continue;
            res += p[i][j] * base;
            base *= bsize * bsize;
        }
    }
    return res;
}

PZL decode(ll hash) {
    PZL p(bsize, vector<int>(bsize));
    vector<bool> num(bsize * bsize, false);
    rep(i, bsize) {
        rep(j, bsize) {
            if (i == 0 && j == 0) continue;
            p[i][j] = hash % (bsize * bsize);
            num[p[i][j]] = true;
            hash /= bsize * bsize;
        }
    }
    rep(i, bsize * bsize) {
        if (!num[i]) p[0][0] = i;
    }
    return p;
}

P findZero(ll hash) {
    rep(i, bsize) {
        rep(j, bsize) {
            if (i == 0 && j == 0) continue;
            if (hash % (bsize * bsize) == 0) return P(i, j);
            hash /= bsize * bsize;
        }
    }
    return P(0, 0);
}

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

    PZL puzzle(bsize, vector<int>(bsize)); 
    PZL ans(bsize, vector<int>(bsize));
    rep(i, bsize) {
        rep(j, bsize) {
            cin>>puzzle[i][j];
            ans[i][j] = i * bsize + j + 1;
        }
    }
    ans[bsize - 1][bsize - 1] = 0;
    ll ahash = encode(ans);

    vector<P> direc {P(1, 0), P(-1, 0), P(0, 1), P(0, -1)};
    priority_queue<pair<P, ll>, vector<pair<P, ll>>, greater<pair<P, ll>>> q;
    set<ll> visited;
    q.push(pair<P, ll>(P(potential(puzzle), 0), encode(puzzle)));

    int res = 0;
    while (!q.empty()) {
        pair<P, ll> p = q.top(); q.pop();
        ll hash = p.second;
        int w = p.first.second;
        
        if (hash == ahash) {
            res = w;
            break;
        }

        if (visited.find(hash) != visited.end()) continue;
        visited.insert(hash);

        if (p.first.first > 45) continue;
        PZL pzl = decode(hash);
        P z;
        rep(i, bsize) {
            rep(j, bsize) {
                if (pzl[i][j] == 0) z = P(i, j);
            }
        }
        for (auto d : direc) {
            int ni = z.first + d.first;
            int nj = z.second + d.second;
            if (ni < 0 || ni >= bsize || nj < 0 || nj >= bsize) continue;
            swap(pzl[z.first][z.second], pzl[ni][nj]);
            q.push(pair<P, ll>(P(w + 1 + potential(pzl), w + 1), encode(pzl)));
            swap(pzl[z.first][z.second], pzl[ni][nj]);
        }
    }
    cout<<res<<endl;
}



Measured memory_bytes: 96012
s=input()
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

# C=Counter(s)
n=len(s)
ans=n+1
for c in range(ord("a"),ord("z")+1):
    c=chr(c)
    now=[]
    for v,cc in enumerate(s):
        if cc==c:
            now.append(v)
    if len(now)==0: continue
    #print(n,c,now)
    d=[now[0]]
    d+=[ (now[i+1]-now[i]-1) for i in range(len(now)-1) ]+[n-1-now[-1]]
    ans=min( max(d),  ans )
print(ans)

Measured memory_bytes: 10316
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner Sc=new Scanner(System.in);
    int n=Sc.nextInt();
    int m=Sc.nextInt();
    int c=Sc.nextInt();
    int a[]=new int[m];
    int b[][]=new int[n][m];
    for(int i=0;i<m;i++)
      a[i]=Sc.nextInt();
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
      {
        b[i][j]=Sc.nextInt();
      }
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
      int sum=0;
      for(int j=0;j<m;j++)
      {
        sum=sum+(a[j]*b[i][j]);
      }
      sum=sum+c;
      if(sum>0)
        count++;
    }
    System.out.println(count);
  }
}

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

using namespace std;

typedef long long ll;

const int mod= 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n;
    cin>>n;
    ll ans = 1;
    for(int i=1;i<=n;++i){
        ans = (ans*i)%mod;
    }    
    cout<<ans;
}

Measured memory_bytes: 3620
// 相手の動けるマスを減らすのが最適そう？
// 二人とも相手の方に近づいて、
// 動いて、相手と隣り合った時、動いた人が勝ちそう
// 引き分けになる場合がわからない、、、
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    bool turn = true;
    while (abs(A - B) > 1) {
        if (turn) {
            if (A < B)
                ++A;
            else
                --A;
        } else {
            if (A < B)
                --B;
            else
                ++B;
        }
        turn = !turn;
    }

    turn = !turn;  // 直前に動いた人が誰か調べる。
    if (turn)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int r, c, i, j, a[101][101];
	cin >> r >> c;
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			a[i][j] = 0;
		}
	}
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			cin >> a[i][j];
			a[r][j] += a[i][j];
			a[i][c] += a[i][j];
			a[r][c] += a[i][j];
		}
	}
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			cout << a[i][j] ;
			if (j == c)
				cout << endl;
			else
				cout << " ";
		}
	}
	return 0;
}

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

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M,0);
  for(int i=0;i<M;i++) cin>>B[i];
  
  int ans=0;
  for(int i=0;i<N;i++){
    int sum=C;
  	for(int i=0;i<M;i++){
      int t; cin>>t;
      sum += t*B[i];
    }
    if(sum>0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
[m-solutions2019] A - Sum of Interior Angles
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N;

ll solve() { return 180 * (N - 2); }

int main() {
    cin >> N;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1000010];

int main(){
    int n;
    cin>>n;
        
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0)
            a[i]=0;
        else
            a[i]=i;
    }
    
    long long sum=0;
    
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,n) {
        cin >> A[i];
    }
    sort(all(A), greater<int>());
    int cnt = 0;
    rep(i,n) {
        if (i%2==0) cnt += A[i];
        else cnt -= A[i];
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include<iostream>

#include<cstdio>

using namespace std;

int main(){

  int a,b,c,d,r;

  double f;

    cin>> a >> b;

    d=a/b;

    r=a%b;

      f=1.00000000*a/b;
    
      printf("%d %d %.8lf\n",d,r,f); 

  


  return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>
#include <limits.h>
#define N 101

main(){
  int i, j, k, n, l, q;
  int p[N], m[N][N];

  scanf("%d", &n);

  for( i = 1; i <= n; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }

  for( i = 1; i <= n; i++){
    m[i][i] = 0;
  }

  for( l = 2; l <= n; l++){
    for( i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INT_MAX;
      for( k = i; k <= j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	if( m[i][j] > q ){
	  m[i][j] = q;
	}
	else m[i][j] = m[i][j];
      }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;

}

Measured memory_bytes: 636
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		int INF = Integer.MAX_VALUE/2;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		int[] B = new int[N];
		Arrays.setAll(B, i -> sc.nextInt());
		int ans = INF;
		int[][] dp = new int[1<<N][51];
		for(int i = 0; i < 1<<N; i++)
			Arrays.fill(dp[i], INF);
		dp[0][0] = 0;
		for(int S = 0; S < 1<<N; S++) {
			int j = Integer.bitCount(S);
			int c = 0;
			for(int i = 0; i < N; i++) {
				if((S & 1<<i) == 0) {
					int k = (i - j) % 2 == 0 ? A[i] : B[i];
					for(int l = 0; l <= k; l++)
						dp[S|1<<i][k] = Math.min(dp[S|1<<i][k], dp[S][l]+c);
					c++;
				}
			}
		}
		for(int i : dp[(1<<N)-1])
			ans = Math.min(ans, i);
		System.out.println(ans == INF ? -1 : ans);
	}

}


Measured memory_bytes: 103412
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdlib>

using namespace std;
typedef long long int ll;

bool debug = false;
#define show(x) if (debug) {cout << "" # x << " = " << x << endl;}
#define rep(x, a, b) for (int x = a; x < b; x++)

int main()
{
  int n;

  cin >> n;

  vector<int> t(n), a(n);

  rep (i, 0, n) cin >> t[i];
  rep (i, 0, n) cin >> a[i];

  vector<bool> u(n), b(n);

  u[0] = true;
  rep(i, 1, n) u[i] = (t[i] != t[i - 1]);

  b[n - 1] = true;
  rep(i, 1, n) b[n - i - 1] = (a[n - i - 1] != a[n - i]);

  ll ans = 1, mod = 1000000007;
  bool okay = true;

  rep (i, 0, n) {
    if ((b[i] && u[i] && a[i] == t[i]) ||
        (b[i] && !u[i] && a[i] <= t[i]) ||
        (!b[i] && u[i] && a[i] >= t[i])) {
      continue;
    } else if (!b[i] && !u[i]) {
      ans = (ans * (ll)min(a[i], t[i])) % mod;
    } else {
      okay = false;
    }
  }

  cout << (okay?ans:0) << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int k, x;
  cin >> k >> x;

  int low = max(-1000000, x - (k - 1));
  int high = min(1000000, x + (k - 1));
  for (int i = low; i <= high; i++) {
    cout << i << endl;
  }
}

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = input()

if S[0] != 'A' or 'C' not in S[2:-1]:
    print('WA')
else:
    i = S[2:-1].find('C')
    S = S[1:2 + i] + S[2 + i + 1:]
    if not S.islower():
        print('WA')
    else:
        print('AC')


Measured memory_bytes: 2940
NUM_EAT = 3
_ = gets.to_i
a = gets.chomp.split.map(&:to_i)
h = Hash.new(0)
a.each{ h[_1] += 1 }
single = h.select { |_k, v| v == 1 }
dx = h.select { |_k, v| v > 1 }
loop do
  break if dx.size.zero?

  target = []
  dx.each do |k, v|
    rest = NUM_EAT - target.size
    if v <= rest
      [v, rest].min.times { target << k }
      dx.delete(k)
    else
      rest.times { target << k }
      dx[k] -= rest
      if dx[k] == 1
        single[k] = 1
        dx.delete(k)
      end
    end
    break if target.size == NUM_EAT
  end

  unless target.size == NUM_EAT
    single.each do |k, _v|
      target << k
      single.delete(k)
      break if target.size == NUM_EAT
    end
  end
  target.sort!
  add_k = target[1]
  if dx.key?(add_k)
    dx[add_k] += 1
  elsif single.key?(add_k)
    single.delete(add_k)
    dx[add_k] = 2
  else
    single[add_k] = 1
  end
end
puts single.size


Measured memory_bytes: 30112
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> p(N+1);
	for(int i=1; i<=N; i++) cin >> p[i];

	int ans=0;
	for (int i = 1; i <= N; i++) {
		if (p[i] == i) {
			swap(p[i],p[i+1]);
			ans++;
		}
	}

	cout << ans << endl;
}


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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            {
                var N = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int ret = -1;
                if (9 >= N[0] && N[0] >= 1 && 9 >= N[1] && N[1] >= 1)
                {
                    ret = N[0] * N[1];
                }
                Console.WriteLine($"{ret}");
            }
        }
    }
}


Measured memory_bytes: 13396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Coer
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskM solver = new TaskM();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskM {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int mod = 1000000007;
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
            }
            int[][] dp = new int[n + 1][k + 1];
            dp[0][0] = 1;
            for (int i = 1; i <= n; i++) {
                dp[i][0] = 1;
                for (int j = 1; j <= k; j++) {
                    dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
                    if (j - 1 - a[i] >= 0) {
                        dp[i][j] -= dp[i - 1][j - 1 - a[i]];
                    }
                    dp[i][j] = (dp[i][j] % mod + mod) % mod;
                }
            }
            out.println(dp[n][k]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 81748
#include<cstdio>
int main() {
	int n;
	while (scanf("%d", &n) && n != 0) {
		int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
		int tmp;
		for (int i=0; i<n; i++) {
			scanf("%d", &tmp);
			if (tmp < 10) a++;
			else if (tmp < 20) b++;
			else if (tmp < 30) c++;
			else if (tmp < 40) d++;
			else if (tmp < 50) e++;
			else if (tmp < 60) f++;
			else g++;
		}
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n", a, b, c, d, e, f, g);
	}
}

Measured memory_bytes: 756
#include <bits/stdc++.h>
#define ll long long
#include <math.h>
using namespace std;

int main()
{
    ll n;
    cin >> n;
    unordered_map<ll, ll> map;
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        sum = sum + a;
        if (map.count(a) == 0)
        {
            map[a] = 1;
        }
        else
        {
            map[a]++;
        }
    }

    ll q;
    cin >> q;

    for (ll i = 0; i < q; i++)
    {
        ll b;
        ll c;
        cin >> b >> c;
        if (map.count(b) == 1)
        {
            ll total = map[b];
            sum = sum - b * map[b];
            map.erase(b);
            if (map.count(c) == 0)
            {
                map[c] = total;
            }
            else
            {
                map[c] += total;
            }

            sum = sum + c * total;
            cout << sum << endl;
        }
        else
        {
            cout << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6564
# AGC031A - Colorful Subsequence
def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in set(S):
        ans *= S.count(i) + 1
        ans %= MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[102], t[102];
	scanf("%s%s", s, t);
	int i;
	for (i = 0; i < n; i++)
		printf("%c%c", s[i], t[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

c = Counter()
N = int(input())
for _ in range(N):
    s = input()
    c[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    c[s] -= 1
print(max(list(c.values()) + [0]))



Measured memory_bytes: 6476
#include<iostream>
    #include<string>
    #include<math.h>
    #include<algorithm>
    using namespace std;

    #define sqr(x) ((x)*(x))

    int main(){
        int i, n;
        long long find, find2 = 1000000000;
        int a[100];
        cin >> n;
        for(i=0; i<n; i++){
            /*if((n <= -100) or (n >= 100)){
                continue;
            }*/
            cin >> a[i];
            /*if(a[i-1] == a[i]){
                cnt++; //중복 값 검증
            }*/
        }
        /*if((cnt == n) and (cnt != 0)){
            cout << 0 << endl; // 중복 값 검증_2
            return 0;
        }*/
        sort(a, (a + n));
        for(int i=-101; i<101; i++){
            find = 0;
            for(int j = 0; j < n; j++){
                find += sqr(i - a[j]);
            }
            find2 = min(find2, find);
        }
        cout << find2;

    }

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (int &i: h) cin >> i;
    sort(h.begin(), h.end());
    int ans = 1e9+1;
    for (int i=0; i<n-k+1; ++i) {
        int m = h[i], M = h[i+k-1];
        ans = min(ans, M-m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    ll ans = 0;
    int prev = 0;
    for(int i = 0; i < n; i++){
        if(prev > as[i]){
            ans += prev - as[i];
        }
        prev = max(prev, as[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
string s,t,kq,tmp;
int dp[3010][3010];
void xuly(int i,int j){
    if(tmp.size()>kq.size())kq=tmp;
    if(i>=s.size()||j>=t.size())return ;
    for(int i1=i;i1<s.size();i1++)
        for(int j1=j;j1<t.size();j1++){
            if(s[i1]==t[j1]){tmp+=s[i1],xuly(i1+1,j1+1);tmp.erase(tmp.size()-1,1);}
        }
}
void solve(){
    cin>>s>>t;
    s="*"+s;t="#"+t;
    //xuly(0,0);
    for(int i=1;i<s.size();i++)
        for(int j=1;j<t.size();j++)
            if(s[i]==t[j])dp[i][j]=max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1]));
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    int i=s.size()-1,j=t.size()-1;
    vector<char>kq;
    while(i>=1&&j>=1){
        if(s[i]==t[j]){kq.push_back(s[i]);i--;j--;}
        else if(dp[i-1][j]>dp[i][j-1])i--;
        else j--;
    }
    for(int i=kq.size()-1;i>=0;i--)cout<<kq[i];
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("FORM MAU.inp","r",stdin);
    //freopen("FORM MAU.out","w",stdout);

    //srand(time(0));

    //int t;cin>>t;while(t--)
    //cout << setprecision(2) <<fixed;
    solve();
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<algorithm>
#include<stdlib.h>
using namespace std;
 
string Hen(int N)
{
  string S;
  char s;
  while(N!=0){
    s='0'-N%10;
    S.insert(S.begin(),s);
    N/=10;
  }
  return S;
}
int main()
{
  string S,T[40];
  int L,N,M,j,len,flag;
  while(1){
    cin>>S>>L;
    if(S[0]=='0'&&L==0)break;
    len=S.length();flag=0;
    if(S.length()<L){
      for(int i=0;i<L-len;i++){
	S.insert(S.begin(),'0');
      }
    }
    T[0]=S;
    for(int i=1;i<21;i++){
      sort(S.begin(),S.end());
      N=atoi(S.c_str());
      reverse(S.begin(),S.end());
      M=atoi(S.c_str());
      S=Hen(N-M);
      len=S.length();
      if(S.length()<L){
	for(int j=0;j<L-len;j++){
	  S.insert(S.begin(),'0');
	}
      }
      T[i]=S;
    }
     for(int i=1;i<21;i++){
       for(int j=0;j<i;j++){
	 if(T[i]==T[j]){
	   cout<<j<<" "<<atoi(T[i].c_str())<<" "<<i-j<<endl;
	   flag=1;
	   break;
	 }
       }
       if(flag==1)break;
     }
  }
  return 0;
}

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

const int INF = 1001001001;

int main() {
    int n, q;
    cin >> n >> q;
    vector<tuple<int, int, int>> A(n);
    rep(i, n) {
        int s, t, x;
        cin >> s >> t >> x;
        s -= x; t -= x;
        A[i] = make_tuple(x, s, t);
    }
    sort(A.begin(), A.end());
    set<P> D;
    rep(i, q) {
        int d;
        cin >> d;
        D.insert(P(d, i));
    }
    vector<int> ans(q, INF);
    rep(i, n) {
        int x, s, t;
        tie(x, s, t) = A[i];
        auto it_l = D.lower_bound(P(s, -1));
        auto it_r = D.lower_bound(P(t, -1));
        while (it_l != it_r) {
            ans[it_l->second] = x;
            it_l = D.erase(it_l);
        }
    }
    rep(i, q) {
        if (ans[i] == INF) cout << -1 << endl;
        else cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>

main(){
  int A[100];
  int n, flag, j, x, count;

  scanf("%d\n", &n);

  for( j = 0; j < n; j++){
    scanf("%d", &A[j]);
  }

  count = 0;
  flag = 1;

  while( flag ){
    flag = 0;

    for( j = n-1; 1 <= j; j--){
      
      if( A[j] < A[j-1] ){
	
	x = A[j];
	A[j] = A[j-1];
	A[j-1] = x;
	
	count++;
	
	flag = 1;
      
      }

    }

  }

  for( j = 0; j < n; j++){
    if( j == n-1 ) printf("%d\n", A[j]);
    else printf("%d ", A[j]);
  }

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

  return 0;

}

Measured memory_bytes: 600
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin >> a >> b;
	if(b*2 >= a) println(0);
	else println(a-2*b);
}


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

using namespace std;

int main(){
	int r,g,b;
	scanf("%d %d %d",&r,&g,&b);
	if((10*g+b) %4 == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
using namespace std;

int main(){
  double a, b, x, y;
  cin >> a >> b >> x >> y;
  double ans = a*b / 2;
  int fl = 0;
  if(a == 2*x && b == 2*y) fl = 1;
  cout << ans << " " << fl << endl;
}

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

vector<int> temp(10e7, 0);

int main() {
    int x, ans;
    cin >> x;
    for(int i = 2; i < x; i++) {
        if(temp.at(i) == 1) continue;
        int j = 0;
        while(i * j < 10e7) {
            temp.at(i * j) = 1;
            j++;
        }
    }
    ans = x;
    while(temp.at(x) != 0) {
        x++;
        ans = x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 390912