akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, k;
	cin >> n >> k;

	double ans = 0;
	rep_lr(i, 1, n + 1) {
		double p = 1.0 / n;

		int m = 0;
		ll ii = i;
		while (ii < k) {
			m++;
			ii *= 2;
		}

		p *= pow(0.5, m);
		ans += p;
	}

	cout << fixed << setprecision(12);
	cout << ans << endl;

}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
vector<long long> pre(405,0);
vector<vector<long long>> dp(405, vector<long long>(405, -1));

/*long long solve(int L, int R)
{
    if(L>=R)
        return 0;
    if(dp[L][R]!=-1)
        return dp[L][R];
    dp[L][R] = LLONG_MAX;
    long long s = L>0? pre[R] - pre[L-1]: pre[R];
    dp[L][R] = min(dp[L][R], solve(L,L+1) + solve(L+2,R) + s);

    return dp[L][R];
}*/
int main()
{
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    //pre.resize(n+1);
    pre[0] = a[0];
    for(int i=1; i<n; i++)
        pre[i] = pre[i-1]+a[i];
   for(int L=n-1 ; L>=0; L--)
        for(int R=L; R < n; R++)
    {
        if(L==R)
        dp[L][R]=0;
        else
        {
            dp[L][R]=LLONG_MAX;
            long long s = L>0? pre[R] - pre[L-1]: pre[R];
            //cout<<s<<" ";
            for(int i=L; i<R; i++)
            dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
        }

    }

    cout<<dp[0][n-1];
    return 0;
}


Measured memory_bytes: 1536
import java.io.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        int x, ans;
     
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(br.readLine());
         
        ans = x*x*x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 24204
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 100010
int sosu(int a)
{
  for(int j=2;j <= a-1 ;j++){
    if(a%j == 0) return 0;
  }
  return 1;
}
int main(void)
{
  int ss[N+1],tmp[N+1],tmp1[N+1];
  tmp[0]=tmp[1]=tmp[2]=0;
  tmp1[0]=tmp1[1]=tmp1[2]=0;
  ss[0]=ss[1]=0;
  ss[2]=1;
  for(int i=3;i<=N;i++){
    //2n
    if(i%2 == 0){
      ss[i]=0;
      tmp1[i]=0;
    //2n+1
    }else{
      ss[i]=sosu(i);
      if((ss[i]==1)&&(ss[(i+1)/2]==1)){
        tmp1[i]=1;
      }else tmp1[i]=0;
    }
    tmp[i]=tmp[i-1]+tmp1[i];
  }
  int q;
  scanf("%d",&q);
  int l[q],r[q],ans[q];
  for(int i=0;i<q;i++){
    scanf("%d%d",&l[i],&r[i]);
    ans[i]=tmp[r[i]]-tmp[l[i]-1];
  }
  //printf("%d\n",tmp[99291]);
  for(int i=0;i<q;i++) printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 2560
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let mut av: Vec<usize> = sc.next_vec(n);
    let mut ans = 0;
    loop {
        let s: usize = av.iter().map(|x| x/n).sum();
        for i in 0..av.len() {
            av[i] = av[i] % n + s - av[i] / n;
        }
        ans += s;
        if av.iter().all(|&x| x < n) {
            break;
        }
    }
    println!("{}",ans);
}

pub mod io {
    use std;
    use std::str::FromStr;

    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: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

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

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include"stdio.h"
#include<string.h>

int main() {
	char com[8];
	char input[10];
	int a;
	scanf("%s",input);
	//printf("%c",input[0]);
	a = input[0];
		int i;
	for (i = 0; i < 3; i++) {
		if (a != input[i]) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 
char f[55][55];

int main(){
	
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w) cin>>f[i][j];
	
	rep(i,h)
	{
		rep(j,w)
		{
			if(f[i][j] == '#')
			{
				cout <<'#';
				continue;
			}
			
			int cnt = 0;
			rep(loop1,3)rep(loop2,3)
			{
				int dh= loop1-1,dw=loop2-1;
				int nh = i+dh, nw = j+dw;
				if(dh==0 and dw==0) continue;
				if(nh<0 or nw < 0 or nh > h-1 or nw > w) continue;
				if(f[nh][nw]=='#')cnt++;
			}
			cout << cnt;
			
			
		}
		cout << endl;
	}
	
	
}

//cout << ans << endl;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    rep(i,H){
        rep(j,W){
            if(i<B && j<A)cout<<0;
            else if(i>=B && j>=A)cout<<0;
            else cout<<1;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3640
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse = True)
if M > 1:
    for i in range(M):
        if A[i] >= sum(A)*(1/(4*M)):
            del[i]
        else:
            print('No')
            exit()
    print('Yes')
elif M == 1:
    if A[1] >= sum(A)*(1/(4*M)):
        print('Yes')
    else:
        print('No')


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   while(n)
   {
      if(n%10==7)
         return cout<<"Yes"<<endl,0;
      n/=10;
   }
   cout<<"No"<<endl;
   return 0;

}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

vector<int> stepx, stepy;
bool dpx[2][20005], dpy[2][20005];
int origin = 10000;

int main() {
	string s; cin >> s;
	int x, y; cin >> x >> y;
	int cnt = 0, g = 0;
	s += 'T';
	for (int i = 0; i < (int)s.length(); ++i) {
		if (s[i] == 'T') {
			if (g == 0) stepx.push_back(cnt);
			else stepy.push_back(cnt);
			g = 1 - g;
			cnt = 0;
		}
		else {
			++cnt;
		}
	}
	dpx[1][origin] = true;
	int gx = 1;
	if (stepx.size() > 0) {
		dpx[0][origin + stepx[0]] = true;
		gx = 0;
	}
	for (int i = 1; i < (int)stepx.size(); ++i) {
		gx = i % 2;
		for (int j = 0; j <= 2*origin; ++j) {
			dpx[gx][j] = false;
			if (j + stepx[i] <= 2*origin) dpx[gx][j] |= dpx[1 - gx][j + stepx[i]];
			if (j - stepx[i] >= 0) dpx[gx][j] |= dpx[1 - gx][j - stepx[i]];
		}
	}

	dpy[1][origin] = true;
	int gy = 1;
	for (int i = 0; i < (int)stepy.size(); ++i) {
		gy = i % 2;
		for (int j = 0; j <= 2*origin; ++j) {
			dpy[gy][j] = false;
			if (j + stepy[i] <= 2*origin) dpy[gy][j] |= dpy[1 - gy][j + stepy[i]];
			if (j - stepy[i] >= 0) dpy[gy][j] |= dpy[1 - gy][j - stepy[i]];
		}
	}
	if (origin + x < 0 || origin + y < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (dpx[gx][origin + x] && dpy[gy][origin + y]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(void)
{
	int S;
	
	std::cin >> S;
	std::cout << S / 60 / 60 << ":" << ( S / 60 ) % 60 << ":" << S % 60 % 60 << std::endl;
	
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include <stdio.h>
#include <math.h>
#include <map>
#include <queue>
#include <string.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ll;
const ll maxn = 1e18;
ll n;
ll i,j;
ll c = 1;
ll a[100];
ll sumn = 0;
ll m,o;

int main()
{
    cin >> n;
    m = n;
    for(i = 2; i*i <= m; i++)
    {
        if(n%i == 0)
        {
            while (n%i == 0)
            {
                n = n/i;
                a[c] ++;
            }
            c++;
        }
    }
    if(n > 1) a[c]++,c++;
    for(i = 1; i < c; i++)
    {
        o = 1;
        while (1)
        {
            if(a[i] >= o)
            {
                sumn ++;
                a[i] -= o;
            }
            else break;
            o++;
        }
    }
    cout << sumn;
}

Measured memory_bytes: 3156
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        String S = in.next();
        StringBuilder ans = new StringBuilder();
        for(char c: S.toCharArray()){
            char ch = (char) (((int) c - 65 + N) % 26 + 65);
            ans.append(ch);
        }
        println(ans.toString());
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

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

struct Mod {
  static constexpr lli M = 1000000007;
  lli n;
  Mod(): n(0) {}
  Mod(lli m): n(m) {
    if (m > M)
      n = m % M;
    else if (m < 0)
      n = (m % M + M) % M;
  }
  explicit operator lli() const { return n; }

  Mod& operator+=(const Mod& a) {
    n = (n + a.n) % M;
    return *this;
  }
  Mod& operator-=(const Mod& a) {
    n = (n + M - a.n) % M;
    return *this;
  }
  Mod& operator*=(const Mod& a) {
    n = (n * a.n) % M;
    return *this;
  }
  Mod operator+(const Mod& a) const {
    Mod res = *this;
    return res += a;
  }
  Mod operator-(const Mod& a) const {
    Mod res = *this;
    return res -= a;
  }
  Mod operator*(const Mod& a) const {
    Mod res = *this;
    return res *= a;
  }
};

Mod  dp[668][2001]{};

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

  dp[1][3] = 1;
  for (int k = 1; k <= 666; k++) {
    for (int s = 4; s <= 2000; s++) {
      dp[k][s] = dp[k][s-1] + dp[k-1][s-3];
    }
  }


  Mod res;
  for (int k = 1; k <= 666; k++) { res += dp[k][S]; }
  cout << res.n << endl;

  return 0;
}


Measured memory_bytes: 14020
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        var d = new long[100001];
        int N = cin.Nextint;
        var K = cin.Nextlong;
        for (long i = 0; i < N; i++)
        {
            long a = cin.Nextlong;
            long b = cin.Nextlong;
            d[a] += b;
        }
        

        long cnt = 0;
        for (int i = 1; i < d.Length; i++)
        {
            if (cnt + d[i] >= K)
            {
                WriteLine(i);
                return;
            }
            cnt += d[i];
        }
    
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 15956
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int m;
    	int f;
    	int r;
    	int total;
    	int Absent = -1;
    	
    	for(;;){
    		m = scan.nextInt();
    		f = scan.nextInt();
    		r = scan.nextInt();
    		
    		if(m == Absent && f == Absent && r == Absent){
    			break;
    		}
    		
    		if(m == -1 || f == -1){
    			System.out.println("F");
    		}else{
	    		total = m + f;
	    		if(total >= 80){
	    			System.out.println("A");
	    		}else if(total < 80 && total >= 65){
	    			System.out.println("B");
	    		}else if(total < 65 && total >= 50 || r >= 50){
	    			System.out.println("C");
	    		}else if(total < 50 && total >= 30){
	    			System.out.println("D");
	    		}else{
	    			System.out.println("F");
	    		}
    		}
    	}
    }
}

Measured memory_bytes: 26020
object Main extends App{
    var card=Array(0)
    for{i<-1 to 30}{
        card = card :+ 0
    }

    var num=io.StdIn.readLine().toInt
    while(num>0){
        rec(0,num,num)
        num=io.StdIn.readLine().toInt
    }
    
    def rec(row:Int,left:Int,now:Int):Unit={
        var now2=now
        if (left==0){
            for{i<-0 to row-2}{
                print(card(i))
                print(" ")
            }
            println(card(row-1))
            return
        }
        if (left<now){
            now2=left
        }
        var i=now2
        while(i>0){
            card(row)=i
            rec(row+1,left-i,i)
            i -= 1
        }
    }
}



Measured memory_bytes: 67052
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int mod = 1e9 + 7;

// O(N * K^2)

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> dp(k + 1);
    // dp[i] - the number of ways such that we used i candies so far
    dp[0] = 1;
    for(int child = 0; child < n; ++child) {
        int up_to;
        scanf("%d", &up_to);
        vector<int> fake(k + 1);
        for(int used = k; used >= 0; --used) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if(L <= R) {
                add_self(fake[L], tmp);
                if(R + 1 <= k) {
                    sub_self(fake[R+1], tmp);
                }
            }
            //~ for(int i = L; i <= R; ++i) {
                //~ add_self(dp[i], tmp);
            //~ }
        }
        int prefix_sum = 0;
        for(int i = 0; i <= k; ++i) {
            add_self(prefix_sum, fake[i]);
            add_self(dp[i], prefix_sum);
        }
    }
    printf("%d\n", dp[k]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  set<int> st{};
  int N,d;
  cin>>N;
  for(int i=0;i<N;++i){
    cin>>d;
    st.insert(d);
  }
  cout<<st.size()<<"\n";
return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
confort_index = 1
now_confort_count = 2
ans = A[0]
for i in range(2,N):
  ans += A[confort_index]
  now_confort_count -= 1
  if now_confort_count == 0:
    confort_index += 1
    now_confort_count = 2

print(ans)


Measured memory_bytes: 31680
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

const int N = 300005;

int n, a, b, now, x, tot;
int ans[N];

int main()
{
	n = read();
	a = read();
	b = read();
	if (a + b > n + 1)
	{
		puts("-1");
		return 0;
	}
	if (1ll * a * b < 1ll * n)
	{
		puts("-1");
		return 0;
	}
	if (a + b == n + 1)
	{
		rep(i, 1, a - 1) printf("%d ", i);
		printf("%d ", n);
		rep(i, a + 1, n) printf("%d ", n - i + a);
		return 0;
	}
	rep(i, 1, a) ans[i] = n - a + i;
	b --;
	tot = a;
	x = n - a;
	while (b)
	{
		now = min(n - tot - b + 1, a);
		rep(i, 1, now) ans[tot + i] = x - now + i;
		tot += now;
		b --;
		x -= now;
	}
	if (tot != n)
	{
		puts("-1");
		return 0;
	}
	rep(i, 1, n) printf("%d ", ans[i]);
	return 0;
}


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

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    vector<vector<int>> m(H,vector<int>(W));
    char c;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>c;
            if(c=='#'){
                m[i][j]=1;
            }else{
                m[i][j]=0;
            }
        }
    }
    /*
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<m[i][j]<<" ";
        }
        cout<<endl;
    }
    //*/

    vector<vector<int>> v(H,vector<int>(W));

    int ans=0;
    for(int b=0;b<(1<<(H+W));b++){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                v[i][j]=m[i][j];
            }
        }
        for(int i=0;i<H;i++){
            if(b&(1<<i)){
                for(int j=0;j<W;j++){
                    v[i][j]=0;
                }
            }
        }
        for(int i=0;i<W;i++){
            if(b&(1<<(H+i))){
                for(int j=0;j<H;j++){
                    v[j][i]=0;
                }
            }
        }
        int cnt=0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cnt+=v[i][j];
            }
        }
        if(cnt==K){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := n; i <= 999; i++ {
		if strconv.Itoa(i)[0] == strconv.Itoa(i)[1] &&
			strconv.Itoa(i)[0] == strconv.Itoa(i)[2] {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 512
class Arrow
  attr_reader :source, :sink, :label
   
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end
 
class Result
  attr_reader :target, :spell
 
  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end
 
def advance(table, n, goes, arrows)
  next_table = [nil] * n
  (0...n).each do |node|
    best = table[node]
    goes[node].each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end
 
def has_cycle(table, result, n)
  used = [false] * n
  loop do
    node = result.target
    return false unless node
    return true if used[node]
    used[node] = true
    result = table[node]
  end
end
 
def work(n, arrows, start, goal)
  goes = (0...n).map{[]}
  arrows.each do |arrow|
    goes[arrow.source] << arrow
  end
  table = [nil] * n
  table[goal] = Result.new(nil, '')
  n.times do
    table = advance(table, n, goes, arrows)
  end
  return nil unless table[start]
  (n*5).times do
    table = advance(table, n, goes, arrows)
  end
  result = table[start]
  has_cycle(table, result, n) ? nil : result.spell
end
 
loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0
 
  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(x, y, lab)
  end
 
  start = s
  goal = g
 
  puts work(n, arrows, start, goal) || 'NO'
end

Measured memory_bytes: 23620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int N, K;
	string S;
	vector<int> cntSum, cumuSum, maxSum;

	cin >> N >> K;
	cin >> S;

	int now = 1;
	int cnt = 0;
	if(S[0] == '0'){
		cntSum.push_back(0);
		now = 0;
	}
	for(int i = 0; i < N; ++i){
		cnt++;

		if(S[i+1] != now + '0'){
			cntSum.push_back(cnt);
			cnt = 0;
			now ^= 1;
		}
	}
	if(now == 1) cntSum.push_back(0); // 1が0個あると仮定して追加

	// 累積和作成
	cumuSum.push_back(0);
	for(int i = 0; i < cntSum.size(); ++i){
		cumuSum.push_back(cntSum[i] + cumuSum[i]);
	}

	K = min((int)cntSum.size()/2, K);
	for(int i = 2*K+1; i < cumuSum.size(); i+=2){
		maxSum.push_back(cumuSum[i] - cumuSum[i-(2*K+1)]);
	}

	int a = *max_element(maxSum.begin(), maxSum.end());
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
int N,A,B,C,l[8];

int dfs(int i,int a,int b,int c,int p){
  if (i==N && a!=0 && b!=0 && c!=0) {
    int sum= p+abs(a-A)+abs(b-B)+abs(c-C);
    return sum;
  } else if (i==N ){
    return 1e9;
  }
  int mini(1e9);
  mini = min(dfs(i+1,a+l[i],b,c,p+10),mini);
  mini = min(dfs(i+1,a,b+l[i],c,p+10),mini);
  mini = min(dfs(i+1,a,b,c+l[i],p+10),mini);
  mini = min(dfs(i+1,a,b,c,p),mini);
  return mini;
}

int main(){
  cin>>N>>A>>B>>C;
  for (int i(0);i<N;i++) cin>>l[i];
  cout << dfs(0,0,0,0,-30) << endl;
}


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

#define debi(var) "[" << (#var) << " : " << var <<"]" << " "
#define debv(v) "[" << (#v) << " : {";for(int i = 0; i < v.size() - 1; ++i)\
					cout << v[i] <<", ";cout << v.back() << "}] "
#define deba(a,n) "[" << (#a) << " : {";for(int i = 0; i < n - 1; ++i)\
					cout << a[i] << ", ";cout << a[n - 1] << "}] "
#define debp(p) "[" << (#p) << " : {" << p.first << ", " << p.second << "}] "
#define debs(s) "[" << (#s) << " : {";auto _itr = s.begin();\
					for(int k = s.size(); k > 1; --k) {cout << *_itr << ", "; ++_itr;} cout << *_itr << "}] "

typedef long long ll;
/*LETS BEGIN WITH THE NAME OF LORD MAHADEV*/
int main(){
	ll A;
	float B;
	cin >> A >> B;
	ll ans = (A * (B * 100)) / 100;
	cout << ans;	
	return 0;	
}

Measured memory_bytes: 3700
#include<vector>
#include<list>
#include<set>
#include<iostream>
using namespace std;
#define df 0
void show_list(int i,list<int> const& que){
  printf("%d:[ ",i);
  for(const int& k: que){
    printf("%d ",k);
  }
  printf("]\n");
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >> n;
  vector<list<int>> mat(n);
  for(int i=0;i<n;i++){
    list<int>& q=mat.at(i);
    for(int j=0;j<n-1;j++){
      int a; cin >> a;  a--;
      q.push_back(a);
    }
  }

  if(df){
    for(int i=0;i<n;i++)show_list(i,mat.at(i));
  }
  int cnt=0;
  set<int> buf;
  for(int i=0;i<n;i++){
    if(mat.at(i).empty())continue;
    int a=mat.at(i).front();
    if(mat.at(a).front()==i){
      buf.insert(i);
      buf.insert(a);
    }
  }
  if(df){
    for(const int& i: buf){
      printf("%d ",i);
    }
    printf(":buf\n");
  }
  while(not buf.empty()){
    for(const int& i: buf){
      mat.at(i).pop_front();
      if(df)show_list(i,mat.at(i));
    }
    cnt++;
    set<int> temp;
    for(const int& i: buf){
      if(mat.at(i).empty())continue;
      int a=mat.at(i).front();
      if(mat.at(a).front()==i){
	temp.insert(i);
	temp.insert(a);
      }
    }
    buf.swap(temp);
    if(df){
      for(const int& i: buf){
	printf("%d ",i);
      }
      printf(":buf\n");
    }
  }
  bool flag=true;
  for(int i=0;i<n;i++){
    if(not mat.at(i).empty()){
      flag=false;
      if(df)show_list(i,mat.at(i));
    }
  }
  printf("%d\n",flag?cnt:-1);
}

/// confirm df==0 ///


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n>>k;
    ll a[n] = {0}, dp[n];
    for(i=0;i<n;i++){
    	cin>>a[i];	
    	dp[i] = inf;
    }
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(i=2;i<n;i++){
		// cout<<i<<"-->";
		x = max(0ll, i - k);
		for(j=x;j<i;j++){
			// cout<<a[j]<<" ";
			dp[i] = min(dp[j] + abs(a[i] - a[j]),dp[i]);
		}
		// cout<<"\n";
		
	}
	// for(i=0;i<n;i++){
	// 	cout<<dp[i]<<" ";
	// }
	cout<<dp[n-1];
}    
	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 30
#define M 200000
using namespace std;
int n,A[N];
double calc(double a,double b){return abs(a-b)/a;}


double DP(){
  vector<vector<double> > dp(N,vector<double>(M,1e9));
  dp[0][1] = 0;
  for(int i=0;i<n;i++){
    for(int num=1;num<M;num++)
      for(int j=num;j<M;j+=num)
	dp[i+1][j] = min(dp[i+1][j],max(calc(A[i],j),dp[i][num]));
  }
  
  double res=1e9;
  for(int i=0;i<M;i++) res=min(res,dp[n][i]);
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  printf("%.10f\n",DP());
  return 0;
}

Measured memory_bytes: 51452
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
 	int n;
 	int a; 
 	int ans=0;
 	cin>>n;
 	for(int i=0;i<n;i++)
 	{
 		cin>>a;
 		if(a%2==0)
 		{
 			while(a%2==0)
 			{
 				ans++;
				 a/=2;	
			}
		}
	}
	cout<<ans<<endl;
 	return 0;
  } 

Measured memory_bytes: 256
//============================================================================
// Problem     : AOJ0042
// Title       : A Thief
// Author      : mizo0203
// Copyright   : Your copyright free
// Description : 動的計画法(DP)によるナップサック問題 + 重さの総和
//============================================================================

#include <stdio.h>
#include <algorithm>
using namespace std;

#define MAX_N 1000  // お宝の総数の最大値
#define MAX_W 10000 // お宝の重さの最大値
using namespace std;

int W; // 風呂敷の耐えられる重さ
int N; // お宝の数

int w[MAX_N]; // お宝の重さ
int v[MAX_N]; // お宝の価値

// DP テーブル
// long int 型だと Memory Limit Exceeded になる
short int dp[MAX_N + 1][MAX_W + 1];

// 入力
bool input() {
  scanf("%d", &W);
  if(!W) return false;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    // コンマで区切られた入力には，以下の scanf 関数を書く
    scanf("%d,%d", &v[i], &w[i]);
  }
  return true;
}

// 動的計画法(DP)
// 『プログラミングコンテストチャレンジブック』を参考
void solve() {

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = (short)max((int)dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }

}

int main() {

  int cnt = 0;

  while (input()) {
    solve(); // 動的計画法(DP)

    // 重さの総和を探索
    int i;
    for (i = W; i >= 0; i--) {
      if (dp[N][W] != dp[N][i]) break;
    }

    // 出力
    printf("Case %d:\n", ++cnt);
    printf("%d\n", dp[N][W]); // お宝の価値総和
    printf("%d\n", i + 1);    // お宝の重さの総和
  }

  return 0;
}

Measured memory_bytes: 18376
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	int h[n];
	rep(i,0,n-1)cin>>h[i];
	vector<bool> check(n,true);
	for(int i = 0; i < m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		if(h[a] > h[b]){
			check[b] = false;
		}
		else if ( h[b] > h[a]){
			check[a] = false;
		}
		else{
			check[a] = check[b] = 0;
		}
	}
	int cnt=0;
	for(int i = 0; i < n; i++){
		if(check[i]){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}



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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	deque<ll> d;
	rep(i,n){
		int p = lower_bound(d.begin(),d.end(),a[i]) - d.begin();
		if(p == 0){
			d.push_front(a[i]);
		}else{
			d[p-1] = a[i];	
		}
	}
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
    s[i] = 'x';
  }
  cout << s << '\n';
  return 0;   
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5/2;

int main()
{
	long long n,k,a,b,sum;
	long long ans;
	while(~scanf("%lld %lld",&n,&k))
	{
		ans = 0;
		if(k==0) ans = n*n;
		else
		{
		/*	for(int i = k;i <= n;i++)
			{
				ans = ans + n - i;
				sum = i-i/2;
				if(sum > k) ans += sum-k;
				sum = i/2-i/3;
				for(int j = k+1;j <= i/2;j++)
				{
					if(i%j>=k)
					{
						ans++;
					}
				}
			}*/
			for(int i = k+1;i <= n;i++)
			{
				ans += n/i*(i-k);
				sum = n%i-k+1;
				if(sum > 0) ans += sum;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 500000

typedef struct Node_tbl{
	int k;
	int p;
	int l;
	int r;
} Node;

const int nil = -1;
Node t[N];
int root;
int room;
int ix;

int tmin(int u){

  while (t[u].l != nil)
		u = t[u].l;

	return u;
}

int find(int u, int k){
	while (u != nil && k != t[u].k){
		if (k < t[u].k)
			u = t[u].l;
		else
			u = t[u].r;
	}

	return u;
}

int trees(int u){
	if (t[u].r != nil){
		return tmin(t[u].r);
  }

	int y = t[u].p;
	while (y != nil && u == t[y].r){
		u = y;
		y = t[y].p;
	}

	return y;
}

void delete(int z){
	int y;
	int x;

	if (t[z].l == nil || t[z].r == nil){
		y = z;
  }
	else{
		y = trees(z);
  }

	if (t[y].l != nil)	x = t[y].l;
	else{
		x = t[y].r;
  }

	if (x != nil) t[x].p = t[y].p;

	if (t[y].p == nil) root = x;
	else{
		if (y == t[t[y].p].l){
			t[t[y].p].l = x;
    }
		else{
			t[t[y].p].r = x;
    }
	}

	if (y != z)
		t[z].k = t[y].k;

	t[y].r = room;
	room = y;
}

void insert(int k){
	int z;
	int y = nil;
	int x = root;

	if (room == nil) z = ix++;
	else{
		z = room;
		room = t[room].r;
	}

	t[z].k = k;
	t[z].l = nil;
	t[z].r = nil;

	while (x != nil){
		y = x;
		if (t[z].k < t[x].k)
			x = t[x].l;
		else
			x = t[x].r;
	}

	t[z].p = y;
	if (y == nil)
		root = z;

	else{
		if (t[z].k < t[y].k)
			t[y].l = z;
		else
			t[y].r = z;
	}
}

void
inorder(int u)
{
	if (u == nil)
		return;

	inorder(t[u].l);
	printf(" %d", t[u].k);
	inorder(t[u].r);
}

void preorder(int u){
	if (u == nil) return;

	printf(" %d", t[u].k);

	preorder(t[u].l);
	preorder(t[u].r);
}

int main(int argc, char** argv){
	char com[8];
	int n;
	int x;
	int i;

	root = nil;
	room = -1;
	ix = 0;

	scanf("%d", &n);

	for (i = 0; i < n; ++i){
		scanf("%s", com);

		switch (com[0]){
		case 'd':
			scanf("%d", &x);
			delete(find(root, x));
			break;

		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'p':
		default:
			inorder(root);
			printf("\n");

			preorder(root);
			printf("\n");
			break;
		}
	}

  return 0;
}



Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
#ifdef DEBUG
  template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	  return out << '(' << p.first << ", " << p.second << ')';
  }
  template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	  out << '{';
	  for(auto it = x.begin(); it != x.end(); ++it)
		  out << *it << (it == --x.end() ? "" : ", ");
	  return out << '}';
  }
  void dump() {}
  template<class T, class... Args> void dump(T &&x, Args... args) {
	  cerr << x << ";  ";
	  dump(args...);
  }
  const int seed = 1;
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (#x != "" ? #x ":  " : ""), dump(x), Nl(), cerr
#else
  const int seed = chrono::system_clock::now().time_since_epoch().count();
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(seed);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
template<class T> int size(T a) { return a.size(); }

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

	int n;
	multiset<LL> s;
	LL d = 0, u = 0;

	auto update = [&](LL val, int type)
	{
		if(val < 0) u += type;
		else d += type;
	};

	cin >> n;
	REP(i, n)
	{
		LL x;
		cin >> x;
		s.emplace(x);
		update(x, +1);
	}

	vector<pair<LL, LL>> ans;
	REP(i, n - 1)
	{
		LL x = *s.begin();
		LL y = *s.rbegin();
		s.erase(s.begin());
		s.erase(prev(s.end()));
		update(x, -1);
		update(y, -1);

		LL a = max(x, y);
		LL b = min(x, y);
		if(d != 0) swap(a, b);
		ans.emplace_back(a, b);
		s.emplace(a - b);
		update(a - b, +1);
	}

	cout << *s.begin() << "\n";
	for(auto &p : ans)
		cout << p.first << " " << p.second << "\n";
}


Measured memory_bytes: 8188
#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++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

  const ll mod = 1e9 + 7;

  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i = k; i <= n+1; i++) {
    ll mn, mx;
    mn = (0 + i-1) * i / 2;
    mx = ((n-i+1) + n) * i / 2;
    ans += (mx - mn) + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

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

int main(){
    ll n, y; cin >> n >> y;

    rep(i, n+1)rep(j, n+1){
        ll k = n - i - j;
        if(0 <= k && k <= n){
            if(i*10000+j*5000+k*1000 == y){
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
X_dis = []
for m in range(M-1):
    X_dis.append(X[m+1]-X[m])
X_dis.sort()
ans = 0
if N < M:
    for i in range(M-N):
        ans += X_dis[i]
print(ans)


Measured memory_bytes: 13968
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 600300;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	ll N, A, B, K;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	if (K == 0) {
		printf("1\n");
		return 0;
	}

	ll GCD = __gcd(A, B);
	if (K % GCD) {
		printf("0\n");
		return 0;
	}

	A /= GCD;
	B /= GCD;
	K /= GCD;

	if (A < B) swap(A, B);

	if (A == 1) {
		ll k = min(K, 2 * N - K);
		if (k < 0) {
			printf("0\n");
			return 0;
		}
		ll kari = 1ll * f.fac[2 * N] % mod * f.ifac[k] % mod * f.ifac[2 * N - k] % mod;
		printf("%lld\n", kari);
		return 0;
	}

	ll hajime = max(0ll, (K - N * B + A - 1) / A);
	ll owari = min(N, K / A);
	const int b = B;
	ll kotae = 0;
	K -= hajime * A;
	if (b != 1) {
		for (int i = hajime; i <= owari; i++) {
			if (K % b == 0) {
				int j = K / b;
				while (i <= owari) {
					kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - j] % mod * f.ifac[j] % mod;
					i += B;
					j -= A;
				}
			}
			K -= A;
		}
	}
	else {
		for (int i = hajime; i <= owari; i++) {
			kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - K] % mod * f.ifac[K] % mod;
			K -= A;
		}
	}

	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 128
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(n)]
    b = [list(str(input().rstrip('\n'))) for _ in range(m)]
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            b_y = True
            for k in range(i, i + m):
                for l in range(j, j + m):
                    if a[k][l] != b[k-i][l-j]:
                        b_y = False
                        break
            if b_y:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    ll cnt = 0;
    REP(i, N) {
        if (a[i] < b[i]) {
            ll c = (b[i] - a[i] + 1) / 2;
            a[i] += c * 2;
            cnt += c;
        }
        if (a[i] > b[i]) {
            cnt -= a[i] - b[i];
        }
    }
    cout << (cnt >= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];
        for(int i=0; i<M; i++){
            int ai= scanner.nextInt();
            int bi= scanner.nextInt();
            a[i] = ai;
            b[i] = bi;
            for(int j=0; j<bi; j++){
                c[i] = c[i] | (1<<(scanner.nextInt()-1));
            }
        }
        int[] dp = new int[1<<N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i=0; i<(1<<N); i++){
            if(dp[i] != Integer.MAX_VALUE){
                for(int j=0; j<M; j++){
                    dp[i|c[j]] = Math.min(dp[i|c[j]], dp[i] + a[j]);
                }
            }
        }
        if(dp[(1<<N) - 1]==Integer.MAX_VALUE){
            System.out.println(-1);
        }else{
            System.out.println(dp[(1<<N) -1]);
        }
    }
}

Measured memory_bytes: 33440
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int n, k, s;
  while (cin >> n >> k >> s &&n  + k + s  > 0){

    int count = 0;
    REP(mask, 1 << n){
      if (__builtin_popcount(mask) == k){
        int sum = 0;
        REP(k, n){
          if ((mask >> k) & 1) sum += k + 1;
        }
        if (sum == s) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1192