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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i<N; ++i) cin >> h.at(i);
  
  vector<int> dp(N,1001001000);
  
  dp.at(0) = 0;
  
  for(int i = 0; i<N; ++i){
    if(i>0){
      dp.at(i) = min(dp.at(i),
                       dp.at(i-1)+abs(h.at(i-1)-h.at(i))
                      );
    }
    if(i>1){
      dp.at(i) = min(dp.at(i),
                     dp.at(i-2)+abs(h.at(i-2)-h.at(i))
                    );
    }
  }
  
  cout << dp.at(N-1) << endl;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vc=vector<char>;

const double pi = acos(-1);

int io(int x){
  int a=1;
  for(int i=0;i<x;i++){
    a*=10;
  }
  return a;
}

int main(){
  int i,N;
  cin>>N;
  if(N>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;
int G[10][10];

int dfs(int p, int t, int checked)
{
	if (t == N)
	{
		return 1;
	}

	int res = 0;
	rep(i, 0, N)
	{
		if (G[p][i] == 1 && (checked&(1 << i)) == 0)
		{
			res+=dfs(i, t + 1, checked | (1 << i));
		}
	}

	return res;
}

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

	cin >> N >> M;
	int x, y;
	rep(i, 0, M)
	{
		cin >> x >> y;
		x--;
		y--;
		G[x][y] = 1;
		G[y][x] = 1;
	}

	cout << dfs(0, 1, 1) << endl;

	return 0;
}

Measured memory_bytes: 256
N=gets.to_i
s=gets.chomp
Q=gets.to_i

SIZE = 1 << (N-1).bit_length

@tree=Array.new(SIZE*2+1,0)

A_ORD = 'a'.ord

def update(c,i)
  i = SIZE+i-1
  @tree[i] = 1 << (c.ord - A_ORD)
  while 0 < i
    i = (i-1) / 2
    @tree[i] = @tree[i*2+1] | @tree[i*2+2]
  end
end

def query(a,b,k,l,r)
  return 0 if r <= a || b <= l
  return @tree[k] if a <= l && r <= b
  vl = query(a,b,k*2+1,l,(l+r)/2)
  vr = query(a,b,k*2+2,(l+r)/2,r)
  vl | vr
end

s.each_char.with_index do |c,i|
  @tree[SIZE+i-1] = 1 << (c.ord - A_ORD)
end
(SIZE-2).downto(0) do |i|
  @tree[i] = @tree[i*2+1] | @tree[i*2+2]
end

$<.read.split.each_slice(3).each do |a,b,c|
  if a == '1'
    update(c,b.to_i-1)
  else
    p query(b.to_i-1,c.to_i,0,0,SIZE).to_s(2).count('1')
  end
end



Measured memory_bytes: 16288
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  priority_queue<int> nega;
  priority_queue<int> posi;
  vector<int> c;
  rep(i, n){
    if(a[i]>=0){
      posi.push(a[i]);
    } else {
      nega.push(-a[i]);
      c.push_back(-a[i]);
    }
  }
  ll ans=1;
  if(n==k){
    rep(i, n){
      ans*=a[i];
      ans%=mod;
    }
    ans+=mod;
    ans%=mod;
    cout << ans << endl;
    return 0;
  }
  if(posi.empty()){
    if(k%2==0){
      rep(i, k){
        ans*=nega.top();nega.pop();
        ans%=mod;
      }
    } else {
      sort(c.begin(), c.end());
      rep(i, k){
        ans*=c[i];
        ans%=mod;
      }
      ans*=-1;
      ans+=mod;
      ans%=mod;
    }
  } else {
    int k2=k;
    if(k%2==1){
      ans*=posi.top();
      posi.pop();
      ans%=mod;
      k2--;
    }
    while(k2>0){
      if(posi.size()<=1){
        ll nega1=nega.top();nega.pop();
        ll nega2=nega.top();nega.pop();
        ans*=(nega1*nega2)%mod;
        ans%=mod;
        k2-=2;
        continue;
      } else if(nega.size()<=1){
        ll posi1=posi.top();posi.pop();
        ll posi2=posi.top();posi.pop();
        ans*=(posi1*posi2)%mod;
        ans%=mod;
        k2-=2;
        continue;
      }
      ll posi1=posi.top();posi.pop();
      ll posi2=posi.top();posi.pop();
      ll nega1=nega.top();nega.pop();
      ll nega2=nega.top();nega.pop();
      if(posi1*posi2>=nega1*nega2){
        ans*=(posi1*posi2)%mod;
        ans%=mod;
        nega.push(nega1);
        nega.push(nega2);
      } else {
        ans*=(nega1*nega2)%mod;
        ans%=mod;
        posi.push(posi1);
        posi.push(posi2);
      }
      k2-=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5892
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = a[0]
for i in range(1, n):
    b[i] = a[i] + b[i - 1]
c = 10 ** 15
for i in range(n - 1):
    if abs(b[n - 1] - 2 * b[i]) < c:
        c = abs(b[n - 1] - 2 * b[i])
print(c)

Measured memory_bytes: 24632
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string s, t;

void solve(){
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    solve();
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), X = sc.nextInt();
    //There has to be at least A cats
    //There can be at most A+B cats
    //If X is between A and A+B, then it is possible
    if(X >= A && X <= A+B){
      System.out.println("YES"); 
    }
    else{
      System.out.println("NO"); 
    }
  }
}

/*

pre[i] = arr[1] + arr[2] + arr[3] + arr[4] + ... + arr[i]
The question for some l and r
arr[l] + arr[l+1] + arr[l+2] + ... + arr[r]
= 
pre[r] - pre[l-1]

pre[r]   = arr[1] + arr[2] + ... + arr[l-1] + arr[l] + arr[l+1] + ... + arr[r]
-
pre[l-1] = arr[1] + arr[2] + ... + arr[l-1]

*/


Measured memory_bytes: 35724
class UnionFind():

    def __init__(self, s):
        self.nodes = [-1 for _ in range(s)]
        self.rank = [0 for _ in range(s)]
        self.weight = [0 for _ in range(s)]

    def find(self, x):
        if self.nodes[x] < 0:
            return x
        else:
            root = self.find(self.nodes[x])
            self.weight[x] += self.weight[self.nodes[x]]
            self.nodes[x] = root
            return root

    def union(self, x, y, z):
        s_1 = self.find(x)
        s_2 = self.find(y)
        if s_1 == s_2:
            return False
        if self.rank[s_1] < self.rank[s_2]:
            self.nodes[s_1] = s_2
            self.weight[s_1] = z - self.weight[x] + self.weight[y]
        elif self.rank[s_1] > self.rank[s_2]:
            self.nodes[s_2] = s_1
            self.weight[s_2] = self.weight[x] - self.weight[y] - z
        else:
            self.nodes[s_2] = s_1
            self.weight[s_2] = self.weight[x] - self.weight[y] - z
            self.rank[s_1] += 1
        return True

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


if __name__ == "__main__":
    n, q = map(int, input().split())
    sets = UnionFind(n)
    for i in range(q):
        inputs = [int(i) for i in input().split()]
        if inputs[0] == 0:
            sets.union(inputs[1], inputs[2], inputs[3])
        else:
            if sets.is_same(inputs[1], inputs[2]):
                print(sets.diff(inputs[1], inputs[2]))
            else:
                print("?")



Measured memory_bytes: 11148
#!/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

N, T = map(int, input().split())

prev = None
ans = 0
for t in map(int, input().split()):
    if prev is not None:
        if t - prev < T:
            ans += t - prev
        else:
            ans += T
    prev = t
ans += T
print(ans)


Measured memory_bytes: 21748
#include <iostream>
#include <cstring>
#include <string>
#include <set>
using namespace std;
typedef long long ll;

ll cnt[26];

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

	string s;
	cin >> s;
	int n = s.size();
	ll ans = 1;
	for(int i = 0; i < n; i++) {
		ans += i;
		ans -= cnt[s[i] - 'a'];
		cnt[s[i] - 'a']++;
	}
	cout << ans << endl;
	return 0;
	set<string> set;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			string ss;
			for(int k = 0; k < n; k++) {
				if(i <= k && k <= j) {
					ss += s[i + j - k];
				}
				else {
					ss += s[k];
				}
			}
			if(set.count(ss)) cout << "*";
			set.insert(ss);

			cerr << "i : " << i << ", j : " << j << ", ss : " << ss << endl;
		}
	}
	cout << set.size() << endl;
}


Measured memory_bytes: 720
#include <stdio.h>
 
int main(){
        char a[100];
        char b[100];
        char c[100];
        char turn = 'a';
        char result = 0;
        char ca = 0;
        char cb = 0;
        char cc = 0;
 
        scanf("%s", a);
        scanf("%s", b);
        scanf("%s", c);
 
        while(result == 0){
                switch(turn){
                        case 'a':
                                if(a[ca] == '\0'){
                                        result = 'A';
                                        break;
                                }
                                turn = a[ca++];
                                break;
                        case 'b':
                                if(b[cb] == '\0'){
                                        result = 'B';
                                        break;
                                }
                                turn = b[cb++];
                                break;
                        case 'c':
                                if(c[cc] == '\0'){
                                        result = 'C';
                                        break;
                                }
                                turn = c[cc++];
                                break;
                        default:
                                return 1;
                }
        }
        printf("%c\n", result);
        return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    
    return 0;
}



Measured memory_bytes: 3600
n,k,s = map(int,input().split())
ans = ""
for i in range(n):
    if i > 0:
        print (" ",end="")
    if i < k:
        print (str(s),end="")
    else:
        if s < 1000000:
            print(str(s+1),end="")
        else:
            print(str(s-1),end="")

print ("")

Measured memory_bytes: 4592
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!(
        "{}",
        (a..b + 1)
            .filter(|x| palindrome_number(&x.to_string()))
            .count()
    );
}

fn palindrome_number(s: &String) -> bool {
    for (c1, c2) in s.chars().zip(s.chars().rev()) {
        if c1 != c2 {
            return false;
        }
    }
    true
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  while ( true )
  {
    int n;

    if ( !( cin >> n ) )  break;
    cout << ( 1 + n * ( n + 1 ) / 2 ) << endl;
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    long long a,b;
    cin >> a >> b;
    vector<long long> z(a);
    for (ll i = 0; i < a; i++) {
        cin >> z.at(i);
    }
    ll s = 1;
    vector<long long> bik(a+4);
    for (ll i = 0; i < a+3; i++) {
        s *= i + 1;
        s %= 1000000007;
        bik.at(i + 1) = s;
    }
    bik.at(0) = 1;
    sort(z.begin(), z.end());
    ll mn = 0;
    ll zr = 0;
    for (ll i = 0; i < a; i++) {
        long long fl = (bik.at(a - i - 1) * modinv(bik.at(b-1), 1000000007)) % 1000000007;
            fl *= modinv(bik.at(max(zr,a - i - b)), 1000000007);
            fl %= 1000000007;
            fl *= z.at(i);
            fl %= 1000000007;
            fl += 1000000007;
            fl %= 1000000007;
            if(a-i-b>=0)mn += fl;
            mn %= 1000000007;
    }
    reverse(z.begin(), z.end());
    ll mnx = 0;
    for (ll i = 0; i < a; i++) {
        long long fl = (bik.at(a - i-1) * modinv(bik.at(b-1), 1000000007)) % 1000000007;
        fl *= modinv(bik.at(max(zr, a - i - b)), 1000000007);
        fl %= 1000000007;
        fl *= z.at(i);
        fl %= 1000000007;
        fl += 1000000007;
        fl %= 1000000007;
        if (a - i - b >= 0)mnx += fl;
        mnx %= 1000000007;
    }
    cout << (mnx - mn + 1000000007) % 1000000007 << endl;
}

Measured memory_bytes: 1792
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

e=min(a)+min(b)

for _ in range(M):
    x,y,c=map(int,input().split())
    f=a[x-1]+b[y-1]-c
    e=min(e,f)

print(e)


Measured memory_bytes: 18612
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n;
    scan(n);
    auto a = readArr!(int)();

    a = a.uniq.array;
    n = a.length.to!int;

    int ans;

    for (int i = 0; i < n; i++) {
        ans++;
        if (i == n - 1) break;
        if (a[i] < a[i + 1]) {
            while (i + 1 < n && a[i] < a[i + 1]) i++;
        }
        else {
            while (i + 1 < n && a[i] > a[i + 1]) i++;
        }
    }

    writeln(ans);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

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

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4520
#include <iostream>
using namespace std;
int main() {
	string N;
	cin >> N;
	for(int i = 0; i < 3; i++) {
		if(N.at(i) == '7') {
			cout << "Yes" << endl;
			break;
		}
		else if(i == 2) {
			cout << "No" << endl;
		}
	}

}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	ll a,b;
	cin>>a>>b;
	if(a>12)
	cout<<b;
	else if(a>5)
	cout<<b/2;
	else
	cout<<"0";
    return 0;
}























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

using namespace std;

const int MAXN = 2000000 + 1000;
const int MOD = 1000000000 + 7;

int n, m, a, b;
int fac[MAXN], ifac[MAXN];

int fpow(int x, int p)
{
	int ret = 1;
	for(; p; p >>= 1, x = (long long)x * x % MOD)
		if(p & 1)
			ret = (long long)ret * x % MOD;
	return ret;
}

int inv(int x)
{
	return fpow(x, MOD - 2);
}

void init()
{
	fac[0] = 1;
	for(int i = 1; i < MAXN; i++)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	ifac[MAXN - 1] = inv(fac[MAXN - 1]);
	for(int i = MAXN - 2; i >= 0; i--)
		ifac[i] = (long long)ifac[i + 1] * (i + 1) % MOD;
}

int get_c(int n, int m)
{
	if(n < 0 || m < 0 || n < m)
		return 0;
	return (long long)fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int ways(int n, int m)
{
	return get_c(n + m - 2, n - 1);
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	init();
	cin >> n >> m >> a >> b;
	int ans = ways(n, m);
	for(int i = 1; i <= b; i++)
		ans = (ans - (long long)ways(n - a, i) * ways(a, m - i + 1) % MOD + MOD) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
#define Num 100000
#define LAST -1

struct Node {
    int parent;
    int left;
    int right;
};
struct Node Tree[Num];

void Pre_Order(int a){

    if(a == LAST)
        return;
    printf(" %d" , a);
    Pre_Order(Tree[a].left);
    Pre_Order(Tree[a].right);
}


void In_Order(int b) {

    if(b == LAST)
        return;
    In_Order(Tree[b].left);
    printf(" %d" , b);
    In_Order(Tree[b].right);
}


void Post_Order(int c) {
    if(c == LAST)
        return;
    Post_Order(Tree[c].left);
    Post_Order(Tree[c].right);
    printf(" %d" , c);
}

int main(void)
{
    int n , i;
    int vertex , left , right;
    int root;
    
    scanf("%d" , &n);
    

    for(i = 0 ; i < n ; i++)
        Tree[i].parent = LAST;

    for(i = 0 ; i < n ; i++) {
        scanf("%d %d %d" , &vertex , &left , &right);
        Tree[vertex].left  = left;
        Tree[vertex].right = right;
        /*親を設定*/
        if(left != LAST)
            Tree[left].parent  = vertex;
        if(right != LAST)
            Tree[right].parent = vertex;
    }
    /*親はLASTにされている*/
    for(i = 0 ; i < n ; i++)
        if(Tree[i].parent == LAST)
            root = i;
    
    puts("Preorder");
    Pre_Order(root);
    printf("\n");
    
    puts("Inorder");
    In_Order(root);
    printf("\n");
    
    puts("Postorder");
    Post_Order(root);
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2136
import math


def main():

    v = list(map(int, input().split()))
    n = v[0]
    a = v[1]
    b = v[2]

    answer = 0
    if n < a:
        answer = n
    elif n < a+b:
        answer = a
    elif a == 0 and b == 0:
        answer = 0
    else:
        answer += math.floor(n / (a+b)) * a
        rest = n % (a+b)
        if rest <= a:
            answer += rest
        else:
            answer += a
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 80268
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	int n, a[100010], cnt = 0, now = 1;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	while (cnt != n) {
		if (now == 2) {
			cout << cnt << endl;
			return 0;
		}
		now = a[now];
		cnt++;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    cin>>N>>T;
    vector<int>c(N),t(N);
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
    }
    vector<int>answer;
    for(int i=0;i<N;i++){
        if(t[i]<=T){
            answer.push_back(c[i]);
        }
    }
      
    if(answer.size()==0){
        cout<<"TLE"<<endl;
    }
    else{
         cout<<*min_element(answer.begin(),answer.end())<<endl;
    }
    }

Measured memory_bytes: 256
n,k=gets.split;a=[*0..9]-gets.split.map(&:to_i)
(puts n;exit)if !i1=(0...n.size).find{|i|!a.find{|e|e==n[i].to_i}}
i2=i1.downto(0).find{|i|k=a.find{|e|e>n[i].to_i}}||-1
puts"#{i2<0?a[0]>0?a[0]:a[1]:n[0...i2]+k.to_s}"+a[0].to_s*(n.size-i2-1)

Measured memory_bytes: 1788
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int x;
int main(){
	scanf("%d",&x);
	if(x>=1200)puts("ARC");
	else puts("ABC");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
 
int main(){
 char a;
 scanf("%c",&a);

    
    if(a=='A'){
        printf("T");
    }
    
    else if(a=='T'){
        printf("A");
    }
    
    else if(a=='C'){
        printf("G");
    }
    
    else if(a=='G'){
        printf("C");
    }


    return 0;
    }

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int w,h,x,y,r;
  scanf("%d %d %d %d %d",&w, &h, &x, &y, &r);

  if(w-x>=r && x>=r && h-y>=r && y>=r){
    printf("Yes\n");
  }
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
S=set(input())
Al=["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"]
ans=0
for i in Al:
    if i not in S:
        print(i)
        exit()
print('None')

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> high(10);
  for(int i=0; i<10; i++) cin >>high[i];
  sort(high.begin(), high.end());
  for(int i=9; i>=7; i--) cout <<high[i]<<endl;
  return 0;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

void chmin(int *x, int y){
  if(*x > y) *x = y;
}

#define inf 1000000000

  int n,A,B,C,ans = 0;
  int l[8];

int dfs(int cur, int a, int b, int c){

  if(cur == n){
    if(!a||!b||!c) return inf;
    return abs(a-A) + abs(b-B) + abs(c-C);
  }

  int len = dfs(cur+1, a, b, c);

  chmin(&len,dfs(cur+1, a + l[cur], b, c) + (a ? 10 : 0));
  chmin(&len,dfs(cur+1, a, b + l[cur], c) + (b ? 10 : 0));
  chmin(&len,dfs(cur+1, a, b, c + l[cur]) + (c ? 10 : 0));

  return len;

}

int main(){

  scanf("%d%d%d%d",&n,&A,&B,&C);
  for(int i = 0; i < n; ++i){
    scanf("%d",l+i);
  }

  ans = dfs(0,0,0,0);
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1736
a, b = map(int, input().split())

base = 2
ans = ''
if a == 0 and b == 0:
  print(0)
else:
  while base // 2 <= b:
    nb = (b // base) * (base // 2)
    na = (a // base) * (base // 2)
    if b % base != 0:
      nb += max(0, b % base - (base // 2) + 1)
    if a % base != 0:
      na += max(0, (a - 1) % base - (base // 2) + 1)
    if (nb - na) % 2 == 1:
      ans += '1'
    else:
      ans += '0'
    base *= 2
  print(int(ans[::-1], 2))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define Left second
#define Right first
class SEGMENTS{
private:
    
    map<int,int> dat;
    
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<=it->Left)break;
            
            int li = it->Left;
            int ri = it->Right;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                int tl = li, tr = ri;
                dat.erase(it);
                if( isInclude(l,r,li,ri) ){
                    if(li!=l) dat[l] = li;
                    if(r!=ri) dat[ri] = r;
                }else{
                    if(li<=l&&l<ri) tr = l;
                    if(l<=li&&li<r) tl = r;
                    if(tl!=tr) dat[tr] = tl;
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<it->Left)break;
            
            if( isInclude(it->Left,it->Right,l,r) ) dat.erase(it);
            else{
                l = min(l,it->Left);
                r = max(r,it->Right);
            }
        }
        
        auto it = dat.lower_bound(l);
        if( it!=dat.end() && it->Right == l ){
            l = it->Left;
            dat.erase(it);
        }
        if(l!=r)dat[r]=l;
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.Left<<" "<<e.Right<<endl;cout<<endl; }
};

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    SEGMENTS st;
    
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
        
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 4172
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

void count(vector<int> v,vector<int>& ans){
    sort1(v);
    int n=v.size();
  int k=1;
  int i=1;
  bool bl=true;
    while(true){
    while(bl){
        if(v[i-1]==v[i]){
        k++;    
      }else{
          bl=false;
      }
      i++;
      }
      ans.push_back(k);
      if(i>=(n-1))break;
      k=1;
      bl=true;
    }
    }




int main() {

  int n;
  ll ans,a;
  ll max =1e18;
  ans=1;
  cin >> n;
  vector<ll> b(n+2);
  for(int i=0;i<n;i++){
    cin >>b[i];
    if(b[i]==0){cout <<0;return 0;}
  }
  for(int i=0;i<n;i++){
   if(ans>max/b[i]){cout << -1;return 0;}
    ans=ans*b[i];

  }

cout << ans;

}
    

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int k,n;
		scanf("%d %d",&n,&k);
		std::vector<long long> a,b;
		static long long int x[55],y[55];
		for(int i=0;i<n;i++){
			scanf("%lld %lld",&x[i],&y[i]);
			a.push_back(x[i]);
			b.push_back(y[i]);
		}	
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		long long ans = LLONG_MAX;
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				for(int i1=0;i1<n;i1++){
					for(int j1=i1;j1<n;j1++){

						ll int r1 = a[i];
						ll int r2 = a[j];
						ll int c1 = b[i1];
						ll int c2 = b[j1];
						int count =0 ;
						for(int p=0;p<n;p++){
							if(r1 <= x[p] && x[p] <= r2 && c1 <= y[p] && y[p] <= c2){
								count++;
							}
						}
						if(count >= k){
							long long area = (c2 - c1) * (r2 - r1);
							ans = min(ans,area);
						}
					}
				}
			}
		}
		printf("%lld\n",ans);	
	}
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct ArticulationPoints{
  vector<vector<int> > G;
  vector<int> used,pre,par,low;
  int V,timer;
  set<int> ap;
  ArticulationPoints(){}
  ArticulationPoints(int V):V(V){init();}
  void init(){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    used.clear();
    pre.clear();
    par.clear();
    low.clear();
    ap.clear();
    
    G.resize(V);
    used.resize(V);
    pre.resize(V);
    par.resize(V);
    low.resize(V);
  }
  
  void add_edge(int from,int to){
    G[from].push_back(to);
    G[to].push_back(from);
  }
  
  void dfs(int v,int p){
    pre[v]=low[v]=timer;
    timer++;
    used[v]=1;
    for(int u:G[v]){
      if(!used[u]){
	par[u]=v;
	dfs(u,v);
	low[v]=min(low[v],low[u]);
      }else if(u!=p){
	low[v]=min(low[v],pre[u]);
      }
    }
  }
  
  void build(){
    fill(used.begin(),used.end(),0);
    timer=1;
    dfs(0,-1);
    ap.clear();
    int np=0;
    for(int i=1;i<V;i++){
      int p=par[i];
      if(p==0) np++;
      else if(pre[p]<=low[i]) ap.insert(p);
    }
    if(np>1) ap.insert(0);
  }
};
signed main(){
  int v,e;
  cin>>v>>e;
  ArticulationPoints ap(v);
  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    ap.add_edge(s,t);
  }
  ap.build();
  for(int i:ap.ap) cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  int n = S.back() - '0';
  if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) std::cout << "hon" << std::endl;
  else if ( n == 3 ) std::cout << "bon" << std::endl;
  else std::cout << "pon" << std::endl;  
  return 0;
}



Measured memory_bytes: 3656
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    a = list(map(int,input().split()))
    a = [0] + a
    
    for i in range(n,0,-1):
        x = 0
        for j in range(1,(n//i) +1):
            x += a[i*j]
        a[i] = x % 2
    
    m = a.count(1)

    print(m)
    for i in range(1,n+1):
        if a[i] == 1:
            print(i)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 122476
from itertools import accumulate
import sys


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


N, M = LI()
X = LI()
if M <= N:
    print(0)
    sys.exit()
sa = []
X.sort()
for i in range(M-1):
    sa.append(X[i+1]-X[i])
sa.sort(reverse=True)
sa = list(accumulate(sa))
if N == 1:
    print(sa[M-2])
else:
    print(sa[M-2]-sa[N-2])


Measured memory_bytes: 20344
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let uf = UnionFind.make (n + m) in
  for i = 0 to n - 1 do
    Scanf.scanf "%d " @@ fun k ->
      for j = 0 to k - 1 do
        Scanf.scanf "%d " @@ fun l ->
          UnionFind.unite uf
            (UnionFind.find uf i)
            (UnionFind.find uf (n + l - 1))
      done
  done;
  print_endline @@
  if
    Array.fold_left ( && ) true @@
    Array.init n @@ fun i ->
      UnionFind.Class.compare
        (UnionFind.find uf 0)
        (UnionFind.find uf i) = 0
  then "YES"
  else "NO"


Measured memory_bytes: 6144
import sys

def merge(A, left, mid, right, num_compare):
	n1 = mid - left
	n2 = right - mid

	L = A[left:mid] + [SENTINEL]
	R = A[mid:right] + [SENTINEL]
	
	i = 0
	j = 0

	num_compare += right - left
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	return num_compare

def merge_sort(A, left, right, num_compare):
	if left + 1 < right:
		mid = (left + right) // 2
		num_compare = merge_sort(A, left, mid, num_compare)
		num_compare = merge_sort(A, mid, right, num_compare)
		num_compare = merge(A, left, mid, right, num_compare)

	return num_compare


#fin = open("test.txt", "r")
fin = sys.stdin

SENTINEL = float("inf")

n = int(fin.readline())
S = list(map(int, fin.readline().split()))

num_compare = 0
num_compare = merge_sort(S, 0, n, num_compare)

print(S[0], end = "")
for s in S[1:]:
	print(" " + str(s), end = "")
print("") 
print(num_compare)

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



void solve(string N, long long K){
	vector<vector<vector<int>>> dp(N.size()+1, vector<vector<int>>(2, vector<int>(4, -1)));
	function<int(int, int, int)> f = [&](int i, int tight, int sum) -> int{
		if(sum > 3)return 0;

		if(i == N.size())return sum == K;

		if(dp[i][tight][sum] != -1)return dp[i][tight][sum];
		dp[i][tight][sum] = 0;
		int num = N[i] - '0';

		int ma;
		if(tight){
			ma = num;
		}else{
			ma = 9;
		}
		for(int j = 0;j <= ma;j++){
			dp[i][tight][sum] += f(i + 1, tight && j == ma, sum + (j == 0 ? 0 : 1));
		}
		return dp[i][tight][sum];
	};
	cout<<f(0, 1, 0)<<endl;
}

int main(){
    string N;
    cin >> N;
    long long K;
    scanf("%lld",&K);

    solve(N, K);
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

const int INF = 1001001001;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(200005, INF);
	int count = 0;
	rep(i, n) {
		int b;
		cin >> b;
		if (a[b] == INF) {
			a[b] = 1;
			count++;
		} else {
			a[b]++;
		}
	}
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, count - k) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    vector<pair<ll,ll> > mx(n);
    for(int i=0;i<n;i++)
    {
        ll mx1=a[i];
        int j=i;
        for( j=i+1;j<n;j++)
        {
            if(a[j]>=a[j-1])
            {
                mx1=max(mx1,a[j]);
            }
            else
            {
                break;
            }
            
        }
        mx[i].first=mx1;
        mx[i].second=j;
    }
    
     ll cur=1000;
    for(int i=0;i<n;)
    {
        if(mx[i].second!=i+1)
        {
            ll no=cur/a[i];
            cur+=(mx[i].first-a[i])*1LL*no;
             i=mx[i].second;

        }
        else
        {
            i++;
        }
        
    }
    cout<<cur<<endl;

}

Measured memory_bytes: 3624
N, M = gets.split.map(&:to_i)
list = []

M.times do |i|
  s, c = gets.split.map(&:to_i)

  list[s] ||= c
  (puts -1; exit) if list[s] != c
end

if N == 1
  list[1] ||= 0
else
  (puts -1; exit) if list[1] == 0
  list[1] ||= 1
  list[2] ||= 0
  list[3] ||= 0
end


puts 1.upto(N).inject(0) {|sum, i| sum + list[i] * 10 ** (N - i) }

Measured memory_bytes: 1916
#include <stdio.h>
#include <string.h>
int main()
{
  int n,i,j=0,minj=0,flag=0;
  char c[37][3],k[3],c2[37][3];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",c[i]);
   for(i=0;i<n;i++)strcpy(c2[i],c[i]);
  for(i=0;i<=n-1;i++)
    {
      for(j=n-1;j>=i+1;j--)
	{
	  if(c[j][1]<c[j-1][1])
	    {
	      strcpy(k,c[j]);
	      strcpy(c[j],c[j-1]);
	      strcpy(c[j-1],k);
	    }
	}
    }
  for(i=0;i<n-1;i++)printf("%s ",c[i]);
  printf("%s\n",c[i]);
  printf("Stable\n");

  for(i=0;i<n-1;i++)
    {
      minj = i;
      for(j=i;j<=n-1;j++)
	{
	  if(c2[j][1] < c2[minj][1])minj=j;
	}
      if(c2[i][1]>c2[minj][1])
	{
	  strcpy(k,c2[i]);
	  strcpy(c2[i],c2[minj]);
	  strcpy(c2[minj],k);
	}
    }
  for(i=0;i<n-1;i++)printf("%s ",c2[i]);
  printf("%s\n",c2[i]);

  for(i=0;i<n;i++)
    {
      flag = strcmp(c[i],c2[i]);
      if(flag != 0)
	{
	  printf("Not stable\n");
	  break;
	}
    }
  if(flag == 0)printf("Stable\n");
  return 0;
}




Measured memory_bytes: 2040
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
	int fib[45];
	int n;

	cin >>n;

	fib[0] = 1;
	fib[1] = 1;

	if(n == 0)
		cout <<fib[0] <<endl;
	else if(n == 1)
		cout <<fib[1] <<endl;
	else{
		for(int i=2;i<=n;i++){
			fib[i] = fib[i-1] + fib[i-2];
		}
		cout <<fib[n] <<endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

vector<int> check;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int, int> > V;
    int x, y;
    rep(i, n) {
    	cin >> x >> y;
    	V.push_back(make_pair(x, y));
    }

    sort(all(V));

    int cnt = 0;
    long double sum = 0, res;
    do {
    	res = 0;
    	for (int i = 0; i < n - 1; ++i) {
    		res += sqrt(pow(V[i].first - V[i + 1].first, 2) + pow(V[i].second - V[i + 1].second, 2));
    	}
    	sum += res;
    	++cnt;
    } while (next_permutation(all(V)));

    cout << setprecision(15) << sum / cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=[int(j)for j in input().split()]
l=[[]for i in range(n+1)]
for i in range(m):
    a,b=[int(j)for j in input().split()]
    l[a].append(b)
    l[b].append(a)
ans=[0]*(n+1)
from collections import deque
q=deque([1])
s=set([1])
while q:
    i=q.popleft()
    for k in l[i]:
        if k not in s:
            ans[k]=i
            q.append(k)
            s.add(k)

if 0 not in ans[2:]:
    print("Yes")
    print('\n'.join(map(str,ans[2:])))
else:
    print("No")

Measured memory_bytes: 113168
#include<stdio.h>

int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n],c=0,d=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    c+=a[i];
  }
   for(int i=0;i<n;i++){
    if((double)c/(4*m)<=a[i]){
      d++;
    }
   }
  if(d>=m){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

bool ok(vector<int> &a, double x, int k) {
	int k0;
	for (int d : a) {
		k0 = ceil(d / (x )) - 1;
		if (round(d / (k0 + 1)) > x) {
			k0++;
		}
		k -= k0;
	}

	return k >= 0;
}

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int l = 0;
    int r = 1000000001;
    int m;
    while (l < r - 1) {
    	m = l + (r - l) / 2;
    	if (ok(a, m, k)) {
    		r = m;
    	} else {
    		l = m;
    	}
    }
    cout << r << endl;
}


Measured memory_bytes: 4724