akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

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

  cout << A * B << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define reg register
#define maxn 200001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int nt[maxn], fi[maxn], go[maxn], cnt;
int ans, n, k, p[maxn], dp[maxn];
void add(int x, int y){
    nt[++cnt] = fi[x]; fi[x] = cnt; go[cnt] = y;
}
void dfs(int u){
    for(int i = fi[u]; i; i = nt[i]){
        dfs(go[i]);
        if(dp[go[i]] + 1 == k && u != 1) 
        dp[go[i]] = -1, ans++;
        dp[u] = max(dp[u], dp[go[i]] + 1);
       } 
}
int main(){
    n = read(); k = read();
    for(int i = 1; i <= n; i++) {
        int x = read();
        if(i == 1 && x != 1) ans++;
        if(i != 1) add(x, i);
    }
    dfs(1); cout << ans << endl;
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String[] abc = new String[3];
		abc[0] = sc.next();
		abc[1] = sc.next();
		abc[2] = sc.next();

		int t = 0;
		while (true) {
			if (abc[t].length() == 0) {
				pr.println((char)('A' + t));

				return;
			}

			char next = abc[t].charAt(0);
			abc[t] = abc[t].substring(1, abc[t].length());
			if (next == 'a') {
				t = 0;
			} else if (next == 'b') {
				t = 1;
			} else if (next == 'c') {
				t = 2;
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int inf = 10000000;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
  Edge(int src, int dst) :
    src(src), dst(dst) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int hungarian(const Matrix &a) {
  int n = a.size(), p, q;
  Array fx(n, inf), fy(n, 0);
  vector<int> x(n, -1), y(n, -1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      fx[i] = max(fx[i], a[i][j]);
  for (int i = 0; i < n; ) {
    vector<int> t(n, -1), s(n+1, i);
    for (p = q = 0; p <= q && x[i] < 0; ++p)
      for (int k = s[p], j = 0; j < n && x[i] < 0; ++j)
        if (fx[k] + fy[j] == a[k][j] && t[j] < 0) {
          s[++q] = y[j], t[j] = k;
          if (s[q] < 0)
            for (p = j; p >= 0; j = p)
              y[j] = k = t[j], p = x[k], x[k] = j;
        }
    if (x[i] < 0) {
      int d = inf;
      for (int k = 0; k <= q; ++k)
        for (int j = 0; j < n; ++j)
          if (t[j] < 0) d = min(d, fx[s[k]] + fy[j] - a[s[k]][j]);
      for (int j = 0; j < n; ++j) fy[j] += (t[j] < 0 ? 0 : d);
      for (int k = 0; k <= q; ++k) fx[s[k]] -= d;
    } else ++i;
  }
  int ret = 0;
  for (int i = 0; i < n; ++i){
 
	ret += a[i][x[i]];
  }
  return ret;
}


int main(){
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	map<char,int> dic1,dic2;
	for( auto c : s ) dic1[c]++;
	for( auto c : t ) dic2[c]++;
	

	Matrix mat(26,Array(26));
	for(int i = 0 ; i < 26 ; i++){
		for(int j = 0 ; j < 26 ; j++){
			mat[i][j] = min(dic1['a'+i],dic2['a'+j]);
		}
	}
	cout << n-hungarian(mat) << endl;
	
	
}

Measured memory_bytes: 1524
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int L;
	cin >> L;
	
	printf("%.12f\n", (double)(L * L * L) / 27.0);
	
	return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll MODP = 998244353;

ll gen(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x%MODP;
  if(y%2 == 1){
    return ((x%MODP)*(gen(x,y-1))%MODP)%MODP;
  }else{
    ll t = gen(x,y/2);
    return ((t%MODP)*(t%MODP))%MODP;
  }
}

ll comb(ll x,ll y){
  if(y == 0)return 1;
  ll res = 1;
  rep(i,y){
    res = ((res%MODP)*((x-i)%MODP))%MODP;
  }
  for(ll i = 1;i <= y;i++){
    res = ((res%MODP)*gen(i,MODP-2))%MODP;
  }
  return res%MODP;
}

int main(){
  ll N , M , K;
  cin >> N >> M >> K;

  vector<ll> com(N,1);
  com[0] = 1;
  com[1] = N-1;
  for(ll i = 2;i <= N-1;i++){
    com[i] = ((com[i-1]%MODP)*(((N-i)%MODP)*(gen(i,MODP-2))%MODP))%MODP;
  }

  ll ans = 0;
  for(ll i = 0;i <= K;i++){
    ll add = M;
    add = (add*com[i])%MODP;
      add = ((add%MODP)*(gen(M-1,N-i-1)%MODP))%MODP;
    ans = (ans%MODP+add%MODP)%MODP;
  }
  if(ans < 0)cout << ans+MODP << endl;
  else  cout << ans%MODP << endl;

  return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;
long double dp[3000][3000];//dp[i][j]でi枚投げたときj枚表
int main() {
	int N;
	cin >> N;
	vector<double> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	dp[0][0] = 1.0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i + 1][j + 1] = dp[i + 1][j + 1] + dp[i][j] * p[i];
			dp[i + 1][j] = dp[i + 1][j] + dp[i][j] * (1.0 - p[i]);
		}
	}
	long double ans = 0.0;
	for (int i = (N + 1)/2; i <= N; i++) {
		ans = ans + dp[N][i];
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 139008
using System.Text;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var d = new Dictionary<long, int>();
        var asum = 0L;
        for (int i = 0; i < n; i++)
        {
            if (d.ContainsKey(a[i])) d[a[i]]++;
            else d[a[i]] = 1;
            asum += a[i];
        }
        getAns(d, asum);
    }
    static void getAns(Dictionary<long, int> d, long asum)
    {
        var sb = new StringBuilder();
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var b = long.Parse(line[0]);
            var c = long.Parse(line[1]);
            if (d.ContainsKey(b))
            {
                asum += (c - b) * d[b];
                if (d.ContainsKey(c)) d[c] += d[b];
                else d[c] = d[b];
                d[b] = 0;
            }
            sb.Append(asum.ToString() + "\n");
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 54600
#include<bits/stdc++.h>
using namespace std;
char a[110];
int main()
{
	gets(a); 
	int ans=0,s; 
	for(int i=0;i<sizeof(a);++i)
	{
		if(a[i]=='C') 
		{ 
			for(int j=i;j<sizeof(a);++j)
			if(a[j]=='F')
			ans++;
		}
	}
	if(ans!=0)
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        writer.println(180 * (n - 2));
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

int main() {
    int X;
    cin >> X;
    
    int A = 0;
    int B = 0;
    
    bool end = 0;
    
    while (end == 0) {
        if (A*A*A*A*A - B*B*B*B*B == X) {
            cout << A << " "<< B << endl;
            end = 1;
        }else if (A*A*A*A*A - B*B*B*B*B > X) {
            while (A*A*A*A*A - B*B*B*B*B >= X) {
                if (A*A*A*A*A - B*B*B*B*B == X) {
                    cout << A << " " << B << endl;
                    end = 1;
                }
                B++;
            }
            A++;
        }else if (A*A*A*A*A - B*B*B*B*B < X) {
            while (A*A*A*A*A - B*B*B*B*B <= X) {
                if (A*A*A*A*A - B*B*B*B*B == X) {
                    cout << A << " " << B << endl;
                    end = 1;
                }
                B--;
            }
            A++;
        }
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
const ll mod=1e9+7;

int n,m,a[13];
vector<int>v[12];

bool ok(int x)
{

    int vis[12]={0},d[13]={0};
    int p=0;
    while(x)
    {
        ++p;
        if(x&1)
            d[p]=1;
        x>>=1;
    }

    for(int i=1;i<=10;i++)
    {
        if(d[i])
            for(int j=0;j<v[i].size();j++)
                vis[v[i][j]]++;
    }
    for(int i=1;i<=m;i++)
        if(vis[i]%2!=a[i])
            return false;
    return true;
}
int main()
{
    cin>>n>>m;
    for(int k,x,i=1;i<=m;i++)
    {
        scanf("%d",&k);
        for(int j=1;j<=k;j++)
            scanf("%d",&x),v[x].push_back(i);
    }
    for(int i=1;i<=m;i++)scanf("%d",&a[i]);

    int cnt=0;
    for(int i=0;i<(1<<n);i++)
    {
        if(ok(i))cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

vector<int> to[2505]; //辺があるか判定
vector<int> revto[2505];	//Nにたどり着けるか判定
bool reachableFrom1[2505]; //1から到達できるか判定
bool reachableToN[2505];	//Nまで到達できるか判定
bool ok[2505];

void dfs(int v){
	if (reachableFrom1[v]) return;
	reachableFrom1[v] = true; //到達出来たらtrue
	for (int u : to[v]) {
		dfs(u);
	}
}
//0から出発できる頂点を列挙

void rdfs(int v){
	if (reachableToN[v]) return;
	reachableToN[v] = true;
	for (int u : revto[v]) {
		rdfs(u);
	}
}
//Nに到達できる頂点を判定

int main(){
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;	//3つの値をまとめる
	repp(i, 0, m){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b; //1-indexなので0始まりにする
		c -= p;	//各辺costからp引いておく
		c = -c;	//符号を逆転
		edges.emplace_back(a, b, c); //push_back的な
		to[a].push_back(b);
		revto[b].push_back(a);
	}
	dfs(0); //0からdfs
	rdfs(n-1); //Nからrdfs
	repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i];
	//okがtrueになっている頂点だけ考慮する

	{ //bellman ford
		vector<int> d(n, INF);
		d[0] = 0;
		bool update = true; //更新されたか
		int step = 0;
		while(update) { //更新が行われたら更新し続ける
			update = false; 
			repp(i, 0, m) {
				int a, b, c;
				tie(a, b, c) = edges[i];
				if (!ok[a]) continue;
				if (!ok[b]) continue; //okじゃない頂点は除く
				int newD = d[a] + c;
				if (newD < d[b]) {
					update = true; //更新が行われたらtrueにする
					d[b] = newD; //updateする
				}
			}
			step++;
			if (step > n) { //最大N回目まではstep数がカウントされる.超えたら負閉路なのでアウト
				puts("-1");
				return 0;
			}
		}
		int ans = -d[n-1]; //無事通り抜けたら、符号を反転
		ans = max(0, ans); //マイナスの場合もあるのでmax通しておく
		cout << ans << endl;
		return 0;
	}	
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 1e9;
const int MB = 30;
const int MOD = 1e9 + 7;
const double PI = atan2(0, -1);


void solve() {
    double r;
    cin >> r;
    cout << 2 * PI * r;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    cout.precision(12);
    cout << fixed;
    while (t--) solve();
}


Measured memory_bytes: 3804
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        _n: usize,
        s: chars
    }

    let mut ret = 1u64;
    let s_count = count(&s);
    for &v in s_count.values() {
        ret *= v as u64 + 1;
        ret %= M;
    }
    if ret == 0 {
        ret = M - 1;
    } else {
        ret -= 1;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 4352
N,H=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
# 切るのはmax(a)だけでいい
# 投げるのはbi> max(a)となるb
am=max(A)
b2=sorted(B,reverse=True)
ct=0
for bb in b2:
    if bb>=am:
        H-=bb
        ct+=1
        if H<=0:
            break
    else:
        break
print(ct+(((H//am)+int(H%am!=0)) if H>0 else 0))

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

int dfs(int a, int n, int b1, int b2, int bb){
    int b=0,sum=0;
    if(a >= 1 && b1 == 0)   return 1;
    if(a>1 && n>0){
    for(int i=bb; i<=a; i++) {
        b=b1*i-b2;
           sum+=dfs(a/i, n-1, b, b2*i, i);
        }
    }
    return sum;
}

int main(void){
    int p, q, a, n;
    while(cin >> p >> q >> a >> n){
        if(p==0 && q==0 && a==0 && n==0)    break;
        cout << dfs(a, n, p, q, 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAX_N 150

struct rect{
	int h, w;
};

vector<rect> Rect;

bool operator<(const rect r1, const rect r2){
	double diagonal1 = (double)r1.h*(double)r1.h + (double)r1.w*(double)r1.w;
	double diagonal2 = (double)r2.h*(double)r2.h + (double)r2.w*(double)r2.w;
	return (diagonal1 == diagonal2) ? (r1.h < r2.h) : (diagonal1 < diagonal2);
}

void calcRect(){
	for(int i = 1; i <= MAX_N; i++){
		for(int j = i+1; j <= MAX_N; j++){
			rect r;
			r.h = i;
			r.w = j;
			Rect.push_back(r);
		}
	}
}

int main(){
	int h, w;
	calcRect();
	sort(Rect.begin(), Rect.end());
	while( cin >> h >> w, h || w ){
		for(int i = 0; i < Rect.size(); i++){
			if( Rect[i].h == h && Rect[i].w == w ){
				cout << Rect[i+1].h << " " << Rect[i+1].w << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1348
n = int(input())
count = 0
count1 = 0
lih = list(map(int,input().split()))
lih.append(10**9+1)
li = ""
for i in range(n):
    if lih[i] >= lih[i+1]:
        li += "1"
    else:
        li += "0"
print(len(max(li.split("0"))))

Measured memory_bytes: 14252
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

bool isACGT(char  c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {
    string S;
    cin >> S;
    int max  = 0;
    for (int i = 0; i < S.length(); i++) {
        if (!isACGT(S[i])) {
            continue;
        }
        int count = 1;
        for (int j = i + 1; j < S.length(); j++) {
            if (isACGT(S[j])) {
                count++;
            } else {
                break;
            }
        }
        if (max < count) {
            max = count;
        }
    }
    cout << max << endl;
    return 0;
}



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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayLong();
            var Asum = new long[N + 1];
            for (int i = 0; i < N; i++)
            {
                Asum[i + 1] = Asum[i] + A[i];
            }
            var dif = long.MaxValue;
            for (int i = 1; i < N; i++)
            {
                var yen = Math.Abs(Asum[N] - Asum[i] * 2);
                dif = yen < dif ? yen : dif;
            }

            Console.WriteLine(dif);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 40784
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void att(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
void sirra(){
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
}
void solve();
int main(){
	att();sirra();
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	int n,k,p(0);cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<k;i++)
		p+=arr[i];
	cout<<p;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n, a[MAX];
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", &a[i]);

  int f = 0, t = 0;
  rep(i, 0, n) {
    if ( a[i] % 4 == 0 ) f++;
    else if ( a[i] % 2 == 0 ) t++;
  }
  int ans;
  if ( t == 0 ) ans = f * 2 + 1;
  else ans = f * 2 + t;
  printf( ans >= n ? "Yes\n" : "No\n");
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        if(a != i+1){
            cnt++;
        }
    }
    YES(cnt <= 2);
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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




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

	lint s[1000] = {};
	lint n; cin >> n;
	lint j;
	lint cur;
	rep(i, n) {
		cur = n;
		j = 2;
		while(cur!=1) {
			if (!(cur%j)) {
				cur /= j;
				s[j]++;
			}
			else j++;
		}
		n--;
	}
	lint ans = 1;
	rep(i, 1000) {
		if (s[i]) {
			ans *= (s[i] + 1);
			ans %= 1000000007;
		}
	}
	co(ans);
	gc();
}

Measured memory_bytes: 256
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(3):
  for j in b:
    if a[i].count(j) > 0:
      a[i][a[i].index(j)] = -1

if (sum(a[0]) == -3) or (sum(a[1]) == -3) or (sum(a[2]) == -3) or (a[0][0] + a[1][0] + a[2][0] == -3) or (a[0][1] + a[1][1] + a[2][1] == -3) or (a[0][2] + a[1][2] + a[2][2] == -3) or (a[0][0] + a[1][1] + a[2][2] == -3) or (a[0][2] + a[1][1] + a[2][0] == -3):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int n, m;
	m = max(a, b);
	m = max(m, c);
	n = min(a, b);
	n = min(n, c);
	cout << m - n << endl;
}

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

int func(int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }

    return s;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int s = 0;
    for (int i = 1; i <= n; i++) {
        int j = func(i);
        if (j >= a && j <= b) {
            s += i;
        }
    }

    cout << s << endl;
}

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

int main() {
  string s,p;
  int memo = 0;
  
  cin >> s >> p;
  s = s + s;
  rep(i,sz(s)) {
    if(p[0] == s[i]) {
      bool flag = true;
      rep(j,sz(p)) {
        if(p[j] != s[i+j]) flag = false;
      }
      if(flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int main()
{
  int x1,y1,x2,y2,a1,b1,a2,b2;
  cin>>x1>>y1>>x2>>y2;
  a1=x2-x1;
  b1=y2-y1;
  a2=-1*b1;
  b2=a1;
  int x3=x2+a2, y3=y2+b2, x4=x1+a2, y4=y1+b2;
  cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4;
  return 0;
}

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

using namespace std;

const int INF = 1e9+5;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	vector<int> h(n,0);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-k;j<i;j++){
			if(j<0){
				continue;
			}
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
			//printf("%d %d\n",h[i],h[j]);
		}
	}
	//for(int i=0;i<n;i++){
	//	printf("%d ",dp[i]);
	//}
	//printf("\n");
	printf("%d\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> c(H, std::vector<char>(W));
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      std::cin >> c[i][j];

  int res = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (c[i][j] == '.')
        continue;
      for (int k = 0; k < H; ++k) {
        for (int l = 0; l < W; ++l) {
          if (c[k][l] == '.')
            continue;
          int d = std::abs(k - i) + std::abs(l - j);
          chmax(res, d);
        }
      }
    }
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),cnt(111111,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans=0, b=0;
  for(int i=1;i<=100000;i++){
    if(cnt[i]>2){
      cnt[i]=2-cnt[i]%2;
    }
    if(cnt[i]==2)b++;
    if(cnt[i])ans++;
  }
  if(b%2)ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

vector<long long> A;

int search_pos(long long C, int start){
    int min_pos = start - 1;
    int max_pos = A.size();

    if(A[start] >= C){
        return start - 1;
    }

    if(start == max_pos){
        return start;
    }

    while(max_pos - min_pos > 1){
        int mid = (max_pos + min_pos) / 2;

        if(A[mid] >= C){
            max_pos = mid;
        }
        else{
            min_pos = mid;
        }
    }

    return min_pos;
}


struct info{
    info(){

    }
    long long B;
    long long C;
};


int main(){
    long long N, M;
    cin >> N >> M;

    A.resize(N);
    vector<info> BC(M);
    long long B, C;
    long long sum = 0;
    vector<long long> sum_table(N + 1, 0);

    for(int i = 0; i < N; ++i){
        cin >> A.at(i);
        sum += A[i];
    }

    for(int i = 0; i < M; ++i){
        cin >> B >> C;
        BC[i].B = B;
        BC[i].C = C;
    }

    std::sort(A.begin(), A.end());
    std::sort(BC.begin(), BC.end(), [](const info& l, const info& r){return l.C > r.C;});

    for(int i = 0; i < N; ++i){
        sum_table[i + 1] = sum_table[i] + A[i];
    }


    int start_pos = 0;

    for(int j = 0; j < M; ++j){
        int pos = search_pos(BC[j].C, start_pos);

        if(pos < start_pos){
            break;
        }

        int end_pos = std::min<int>(pos, start_pos + BC[j].B - 1);
        end_pos = std::min<int>(end_pos, N - 1);
        long long del_sum = sum_table[end_pos + 1] - sum_table[start_pos];

        sum -= del_sum;
        sum += BC[j].C * (end_pos - start_pos + 1);

        if(end_pos == N - 1){
            break;
        }

        start_pos = end_pos + 1;
    }

    cout << sum;

}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

string S;
int main(){
    cin>>S;
    int N=S.size();
    int flg=1;
//
    //N=3の時
    if(N==3&&S[0]==S[2]){flg*=1;}
    else if(N==3){flg*=0;}
    //N>3の時
    else{
        //S判別
        string S_rev=S;
        reverse(S_rev.begin(),S_rev.end());
        if(S==S_rev)flg*=1;
        else flg*=0;
        //front, back判別
        int num=(N-1)/2;
        string front=S.substr(0,num);
        string back =S.substr(num+1,num);
        string front_rev=front, back_rev=back;
        reverse(front_rev.begin(),front_rev.end());
        reverse(back_rev.begin(),back_rev.end());
        if(front==back&&front==front_rev&&back==back_rev)flg*=1;
        else flg*=0;
    }
//
    if(flg==1)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int D = scanner.nextInt();
        int area = 2 * D + 1;
        if (area > N) {
            System.out.println("1");
        } else if (N % area == 0){
            System.out.println(N / area);
        } else {
            System.out.println(N / area + 1);
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

constexpr ll mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
struct comb {
    vector<mint> fact, ifact;
    comb(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
template< typename T > T mod_pow(T x, T n, const T& p) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}
int main() {
	init();

	ll N, M, K; cin >> N >> M >> K;
    mint ans = 0;
    comb nCr(N - 1);
    rep(i, 0, K + 1) {
        ans += nCr(N - 1, i) * M * mod_pow(M - 1, N - 1 - i, mod);
    }
    cout << ans.x << "\n";

	return 0;
}

Measured memory_bytes: 6348
num=int(input())
info=[list(map(int,input().split(" ")))for i in range(num)]
control=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in info:
    control[i[0]-1][i[1]-1][i[2]-1]+=i[3]

for i in range(4):
    for j in range(3):
        print(" "+" ".join(list(map(str,control[i][j]))))
    if i !=3:
        print("#"*20)


Measured memory_bytes: 5604
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
using namespace std;

int main(){
	string a;
	int nagasa;
	int num[8];
	int ans=1000;
	cin>>a;
	nagasa=a.size();

	for(int i=0;i<8;i++){
		num[i]=0;
	}
	for(int i=0;i<(nagasa-2);i++){
		num[i]=stoi(a.substr(i,3));
	}
	for(int i=0;i<(nagasa-2);i++){
		if(ans>abs(num[i]-753)){
			ans=abs(num[i]-753);
		}
	}
	cout<<ans<<endl;
}
	


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

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){

    int N;
    cin>>N;
  
    if(N<1200) cout<<"ABC\n";
    else if(N>=1200 && N<2800) cout<<"ARC\n";
    else cout<<"AGC\n";
}

Measured memory_bytes: 764
#coding:utf-8

def up(nums):
    if len(nums) == nums.count(9):
        nums = [1] + [0] * len(nums)
        return nums
    
    for i in list(reversed(range(len(nums)))):
        if nums[i] > nums[i-1] or nums[i] == 9:
            continue
        else:
            nums[i] += 1
            for j in range(i+1, len(nums)):
                nums[j] = max(nums[j-1]-1, 0)
            return nums
          
  
def main():
    k = int(input())
    nums = [0]
    for _ in range(k):
        nums = up(nums)
        
    print(''.join([str(num) for num in nums]))
        
    
        
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        a,b=map(int, input().split())
        for i in range(13,1250):
            if (i*8)//100==a and (i*10)//100==b:
                return i
        return -1
    print(main())
resolve()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b && a!=c){
        cout<<a<<endl;
    }else if(b!=a && b!=c){
        cout<<b<<endl;
    }else{
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n, s;
int a[100005];
int dp[100005][18];
int dp2[100005][18];
int m;

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    cin >> s;
    int l = n;
    for (int i = n; i > 0; --i) {
        while (l > i && a[l] - a[i] > s) --l;
        dp[i][0] = l;
        for (int j = 1; j <= 17; ++j)
            dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
    l = 1;
    for (int i = 1; i <= n; ++i) {
        while (l < i && a[i] - a[l] > s) ++l;
        dp2[i][0] = l;
        for (int j = 1; j <= 17; ++j)
            dp2[i][j] = dp2[dp2[i][j - 1]][j - 1];
    }
    cin >> m;
    while (m--) {
        int l, r;
        cin >> l >> r;
        if (l == r) {
            cout << 0 << '\n';
            continue;
        }
        if (l < r) {
            int res = 0;
            for (int i = 17; i >= 0; --i)
                if (dp[l][i] && dp[l][i] < r) {
                    res += (1 << i);
                    l = dp[l][i];
                }
            ++res;
            cout << res << '\n';
        } else {
            int res = 0;
            for (int i = 17; i >= 0; --i)
                if (dp2[l][i] && dp2[l][i] > r) {
                    res += (1 << i);
                    l = dp2[l][i];
                }
            ++res;
            cout << res << '\n';
        }
    }
    return 0;
}



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

#define LEN 100000

void swap(int *a, int *b)
{
	int temp;
	
	temp = *a;
	*a = *b;
	*b = temp;
}

int Partition(int arr[], int p, int r)
{
	int x = arr[r];
	int i = p-1;
	
	for (int j = p; j < r; j++) {
		if (arr[j] <= x) {
			i++;
			swap(&arr[i], &arr[j]);
		}
	}
	swap(&arr[i+1], &arr[r]);
	
	return i+1;
}

int main(void)
{
	int n;
	int arr[LEN];
	int q;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	q = Partition(arr, 0, n-1);
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		if (i == q) {
			cout << "[" << arr[i] << "]";
		}
		else {
			cout << arr[i];
		}
	}
	cout << endl;
	
	
	return 0;
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, D, X = 0;
  cin >> N >> D;
  if (N % (D * 2 + 1) == 0) {cout << N / (D * 2 + 1) << endl;}
  else {cout << N / (D * 2 + 1) + 1 << endl;}
}

Measured memory_bytes: 3640
using System;

namespace AtCoder.ABC096
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var a = int.Parse(spl[0]);
            var b = int.Parse(spl[1]);
            Console.WriteLine(a <= b ? a : a - 1);
        }
    }
}


Measured memory_bytes: 11092
fun main(arr:Array<String>) {
    val (x,y) = readLine()!!.split(" ").map { it.toLong() }
    val present = mutableListOf(x)
    while (present.last() < y) {
        if(present.last() * 2 <= y) {
            present.add(present.last()*2)
        } else {
            break
        }
    }
    println(present.size)
}


Measured memory_bytes: 37612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll N,K; cin >> N >> K;
	V<ll> A(N); rep(i,N) cin >> A[i];
	auto can = [&](ll X){
		ll cut = 0;
		for(ll a: A) cut += (a-1)/X;
		return cut <= K;
	};
	ll lb = 0, ub = TEN(9);
	while(ub-lb>1){
		ll m = (lb+ub)/2;
		if(can(m)) ub = m;
		else lb = m;
	}
	cout << ub << endl;
}


Measured memory_bytes: 4724
a,b=(int(x)for x in input().split())

print(
    round(
        (a//b)
        ),end=' '
        
    )


print(
    round(
        a%b
        ),end=' '
        
    )


print(
    format(
    a/b,'.5f'
        )
    )
    
    
    


Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll sum=b-a+1;
  ll e=lcm(c,d);
  //cout<<e<<endl;
  ll x=b/c+b/d-b/e;
  a--;
  ll y=a/c+a/d-a/e;
  cout<<sum-(x-y);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

using namespace std;


using ll = long long int;
int N,K;
const int MAXN=2e5+7;
const ll MOD=998244353 ;

int L[14],R[14];

struct Node{
    int lbound,rbound;
    ll diff;
    Node *left,*right;
};

Node segtree[MAXN*2];
Node* next_pos=segtree;
int n,q;

Node* build(int left,int right){
    auto* cur=next_pos;
    next_pos++;
    cur->lbound=left;
    cur->rbound=right;
    cur->diff=0;
    int mid=(left+right)/2;
    if (right-left==1) return cur;
    cur->left=build(left,mid);
    cur->right=build(mid,right);
    return cur;
}

void update(Node& self,int l,int r,ll u){
    int mid=(self.lbound+self.rbound)/2;
    if (l==self.lbound&&r==self.rbound){
        self.diff=(self.diff+u)%MOD;
    }else if (l>=mid){
        update(*self.right,l,r,u);
    }else if (r<=mid){
        update(*self.left,l,r,u);
    }else{
        update(*self.left,l,mid,u);
        update(*self.right,mid,r,u);
    }
}

ll query(Node& self,int i){
    // puts("q");
    if (self.rbound-self.lbound==1&&self.lbound==i) return self.diff;
    int mid=(self.lbound+self.rbound)/2;
    if (i>=mid) return (query(*self.right,i)+self.diff)%MOD;
    else return (query(*self.left,i)+self.diff)%MOD;
}

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

    for(int i=0;i<K;i++)
        scanf("%d%d",L+i,R+i);
    
    build(1,N+1);

    update(segtree[0],1,2,1ll);

    for(int i=1;i<N;i++){
        ll cur=query(segtree[0],i);
        for(int k=0;k<K;k++){
            int x=i+L[k],y=i+R[k]+1;
            if (x>N) continue;
            update(segtree[0],x,min(y,N+1),cur);
        }
    }

    printf("%lld\n",query(segtree[0],N));
    return 0;
}

Measured memory_bytes: 14232
N = int(input())
src = list(map(int, input().split()))

s = [0]
for i in range(N):
    s.append(s[-1] + src[i])

ans = float('inf')
for i in range(N-1):
    a = s[i+1]
    b = s[-1] - s[i+1]
    df = abs(a-b)
    ans = min(ans, df)
print(ans)


Measured memory_bytes: 24812
N = int(input())
dic = {}
for i in range(1, N+1):
  n = i 
  cnt = 0
  while i % 2 == 0:
    cnt += 1
    i = i // 2
  dic[n] = cnt

a = 0
b = 0
for k, v in dic.items():
  if a < v:
    b = k
    a = v

if b == 0:
  print(1)
else:
  print(b)


Measured memory_bytes: 61788