akhauriyash/Code-Regression huggingface dataset:
#include <math.h>

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
    // int n;
    // cin >> n;
    // int a[n];
    // sort(a, a + n);
    // int len = 0;
    // for (int i = 0; i < n; i++) cin >> a[i];
    // for (int i = 0; i < n; i++) {
    //     for (int j = i + 1; j < n; j++) {
    //         for (int k = j + 1; k < n; k++) {
    //             if (a[i] + a[j] > a[k]) len = max(len, a[i] + a[j] + a[k]);
    //         }
    //     }
    // }
    // cout << len << endl;

    // int n;
    // cin >> n;
    // int x[n], y[n];
    // double dist = 0.0;
    // for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    // for (int i = 0; i < n; i++) {
    //     for (int j = i + 1; j < n; j++) {
    //         dist = max(dist, sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j],
    //         2)));
    //     }
    // }
    // cout << dist << endl;

    // int k, s;
    // cin >> k >> s;
    // int count = 0;
    // for (int x = 0; x <= k; x++) {
    //     for (int y = 0; y <= k; y++) {
    //         int z = s - x - y;
    //         if (z >= 0 && z <= k) count++;
    //     }
    // }
    // cout << count << endl;

    int n, y;
    cin >> n >> y;
    bool trueth = false;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                cout << i << " " << j << " " << (n - i - j) << endl;
                trueth = true;
                break;
            }
        }
        if (trueth) break;
    }
    if (!trueth) cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    int x = n % 10;
    if(x == 3){
        cout << "bon\n";
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8){
        cout << "pon\n";
    }
    else{
        cout << "hon\n";
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int x, y, aa, bb, cc;
	cin >> x >> y >> aa >> bb >> cc;
	int a[aa], b[bb], c[cc];
	for (int i = 0; i < aa; cin >> a[i++]);
	for (int i = 0; i < bb; cin >> b[i++]);
	for (int i = 0; i < cc; cin >> c[i++]);
	sort(a, a + aa), sort(b, b + bb), sort(c, c + cc);
	reverse(a, a + aa), reverse(b, b + bb), reverse(c, c + cc);
	ll ans = 0;
	int p1 = x - 1, p2 = y - 1, p3 = 0;
	while(p1 >= 0 || p2 >= 0)
	{
		if (p1 >= 0 && p2 >= 0)
		{
			if (p3 == cc || c[p3] < min(a[p1], b[p2]))
				ans += a[p1] + b[p2], p1--, p2--;
			else
			{
				ans += c[p3], p3++;
				a[p1] < b[p2] ? p1-- : p2--;
			}
		}
		else if (p1 >= 0)
		{
			if (p3 == cc || c[p3] < a[p1])
				ans += a[p1], p1--;
			else
				ans += c[p3], p1--, p3++;
		}
		else if (p2 >= 0)
		{
			if (p3 == cc || c[p3] < b[p2])
				ans += b[p2], p2--;
			else
				ans += c[p3], p2--, p3++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

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



int main(){
	string S; cin >> S;
	int ans = 0;
	if(S.size()!=4) ans++;
	vector<char> L;
	L.push_back(S[0]);
	reps(i,3){
		bool flg = false;
		rep(j, L.size()){
			if(S[i]==L[j]) flg = true;
		}
		if(!flg) L.push_back(S[i]);
	}
	if(L.size()!=2) ans++;

	if(ans==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


	return 0;
}


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

#define M 1000005
#define MOD 1000000007
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

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

	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
		
	int n;
	cin>>n;

	int rem = n%10;

	if(rem == 3)
		cout<<"bon\n";
	else if(rem == 0 || rem==1 || rem==6 || rem==8)
			cout<<"pon\n";
	else
		cout<<"hon\n";
	
}

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

int main(){
    int n;
    cin>>n;
    int a[n+5];
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if((i+1)%2==1 && a[i]%2==1) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
n = input().strip()
k = int(input())
l = len(n)

dp = [[[0] * (k+1) for _ in range(2)] for _ in range(l+1)]
dp[0][1][0] = 1
for i, s in enumerate(n, start=1):
    s = int(s)
    for j in range(10):
        if j == 0:
            if j < s:
                for x in range(k+1):
                    dp[i][0][x] += dp[i-1][0][x] + dp[i-1][1][x]
            elif j == s:
                for x in range(k+1):
                    for y in range(2):
                        dp[i][y][x] += dp[i-1][y][x]
        elif j < s:
            for x in range(k):
                dp[i][0][x+1] += dp[i-1][0][x] + dp[i-1][1][x]
        elif j == s:
            for x in range(k):
                for y in range(2):
                    dp[i][y][x+1] += dp[i-1][y][x]
        else:
            for x in range(k):
                dp[i][0][x+1] += dp[i-1][0][x]
print(dp[-1][0][k] + dp[-1][1][k])

Measured memory_bytes: 3064
import math


k = int(input())


g = [[0] * (k + 1)for _ in range(k + 1)]
for i in range(1, k + 1):
    for j in range(1, k + 1):
        g[i][j] = math.gcd(i, j)

summ = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            summ += g[g[a][b]][c]

print(summ)

Measured memory_bytes: 9392
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
if all([not i for i in a]):
    print("Yes")
else:
    for i in a[1:]:
      d[i] += 1
    now1,now2 = a[0],0
    ans = [now1]
    for i in a[1:]:
      xor = now1^i
      d[i] -= 1
      d[xor] -= 1
      if d[xor] >= 0:
        now1, now2 = i, xor
        ans.append(now1)
        ans.append(now2)
        break
      d[i] += 1
      d[xor] += 1        
    else:
      print("No")
      exit()
    for i in range(n-3):
      xor = now1^now2
      d[xor] -= 1
      if d[xor] >= 0:
        now1, now2 = now2, xor
        ans.append(now2)
        continue
      else:
        print("No")
        exit()
    else:
      if now1^now2 == a[0]:
        print("Yes")
      else:
        print("No")
      exit()


Measured memory_bytes: 17312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int s = 0;

			int temp = n;
			while (temp > 0) {
				s += (temp % 10);
				temp /= 10;
			}
			if (n % s == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b < 10){
        cout << a + b << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    string S;
    int Q;
    cin >> S ;
    cin >> Q;
    string f = "", b = "";
    int up = 1;
    for(int i=0; i<Q; i++){
        int t;
        cin >> t;
        if(t == 1){
            up *= -1;
        }
        else{
            int F; string c;
            cin >> F >> c;
            if(F == 1){
                if(up == 1) f += c;
                else b += c;
            }
            else{
                if(up == 1) b += c;
                else f += c;
            }
        }
    }
    if(up == 1) {
        reverse(f.begin(), f.end());
        cout << f + S + b << endl;
    }
    else{
        reverse(b.begin(), b.end());
        reverse(S.begin(), S.end()) ;
        cout << b + S + f << endl;
    } 
    return 0;
}

Measured memory_bytes: 1348
// ABC141-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=s.size();
    int ans=0;
    for(int i=0;i<=l-2;i++){ //i文字目から始まる文字列と、後ろの文字列の共通部分を探す。
        // z-algorithm
        vector<int> z(l-i,0);
        z[0]=l-i;
        int from=-1,end=-1;
        for(int j=i+1;j<=l-1;j++){
            int &same=z[j-i];
            if(from!=-1){
                same=min(z[(j-i)-(from-i)],end-(j-1));
                same=max(0,same);
            }
            while(j+same<=l-1 && s[i+same]==s[j+same]) same++;
            // 1つ目の末尾と2つ目の先頭が重ならないmax(共通部分)
            int cur=0;
            if(same!=0){
                if((i-1)+same<j) cur=same;
                else cur=j-i;
            }
            
            ans=max(ans,cur);
            if(end<j+same-1){
                from=j;
                end=j+same-1;
            }
        }
        //cout<<z<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    string input;
    cin >> input;
    ll dp[100002][2] = {};
    dp[0][0] = 1;
    dp[0][1] = 2;
    int len = input.length();

    for(int i=1;i<len;++i)
    {
        char c = input[i];
        dp[i][0] += dp[i-1][0] * 3;
        dp[i][0] %= MOD;
        if (c == '1'){
            dp[i][0] += dp[i-1][1]; 
            dp[i][0] %= MOD;
            dp[i][1] += dp[i-1][1] * 2;
        }else{
            dp[i][1] += dp[i-1][1];
        }
        dp[i][1] %= MOD;
    }

    cout << (dp[len-1][0] + dp[len-1][1])  % MOD << endl;
}

Measured memory_bytes: 2000
card_lst = []
card_type = ['S', 'H', 'C', 'D']
#make table
for tp in card_type:
    for i in range(13):
        card_lst.append(tp + ' ' + str(i + 1))

#remove
cnt = int(input())
for i in range(cnt):
   card_lst.remove(input())

[print(c) for c in card_lst]


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define cono cout << "No" << endl; continue;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;//s.size()==n
    int counta=0,countb=0;
    rep(i,n){
        if(s[i] == 'a'){
            if(counta + countb == a + b){cono}
            counta++;
            cout << "Yes" << endl;
        }
        else if(s[i] == 'b'){
            if(counta + countb == a + b){cono}
            if(countb == b){cono}
            countb++;
            cout << "Yes" << endl;
        }
        else{cono}
    }
}

Measured memory_bytes: 896
A=["AKIHABARA","KIHBR", "AKIHBR", "KIHABR", "KIHBAR", "KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"]
S=input()
if S in A:
  print("YES")
else:
  print("NO")



Measured memory_bytes: 2940
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn is_squared(x: i64) -> bool {
    let mut r = 0;
    while r * r < x {
        r += 1;
    }
    r * r == x
}

fn good(u: usize, v: usize, D: usize, X: &[Vec<i64>]) -> bool {
    let mut sum = 0;
    for t in 0..D {
        let d = X[v][t] - X[u][t];
        sum += d * d;
    }
    is_squared(sum)
}

fn main() {
    let (N, D) = read!(usize, usize);
    let X = read![[i64]; N];

    let mut count = 0;
    for u in 0..N {
        for v in u + 1..N {
            if good(u, v, D, &X) {
                count += 1;
            }
        }
    }

    println!("{}", count)
}


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

long long n, d, x, y, ans;

int main(){
    scanf("%lld%lld", &n, &d);
    for (int i = 0; i < n; ++i){
        scanf("%lld%lld", &x, &y);
        long double sqrt = pow(x * x + y * y, 0.5);
        //cout<<sqrt<<"\n";
        if (sqrt <= d) ++ans;
    }
    printf("%d", ans);
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

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

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

  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int ans = 0;
  int cnt = 1;
  rep(i, N-1){
    if(a[i] != a[i+1]){
      ans += cnt/2;
      cnt = 1;
    }else{
      cnt++;
    }
  }
  ans += cnt/2;

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = []
count =0
count2 = 0
count3 = 0
X=int(N**0.5)
for i in range(X+1):
	if i ==0 or i == 1:
		pass
	elif N % i == 0:

		while N % i==0:
			N /= i
			count2 += 1
		j =1
		count3 = 0
		while count2 - j >=0:
			count2 -= j
			j = j+1
			count3 += 1 
		count += count3 		
		count2 = 0            
if  N >1:
	count +=1
print(count)


Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n],i;
    for(i=0; i<n; i++)
        cin>>a[i];
    int m=k-1,s=n-m;
    int b[s],j=0;
    sort(a,a+n);
    for(i=m; i<n; i++)
    {
        b[j]=a[i]-a[i-m];
        j++;
    }
    sort(b,b+s);
    cout<<b[0]<<endl;
    return 0;
}



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

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


Measured memory_bytes: 256
function main(input) {
    let N = 0 | input.split("\n");
    return  N >= 30 ? "Yes": "No";
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 30492
import bisect
N=int(input())

rllist=[]
for _ in range(N):
  X,L=map(int,input().split())
  rllist.append((X+L,X-L))
rllist.sort()
#print(rllist)

dp=[0]*N
dp[0]=1
for i in range(1,N):
  r,l=rllist[i]
  
  pos=bisect.bisect(rllist,(l,float("inf")))
  #print(i,pos)
  if pos==0:
    dp[i]=dp[i-1]
  else:
    dp[i]=max(dp[i-1],dp[pos-1]+1)
  
#print(dp)
print(dp[-1])

Measured memory_bytes: 26220
#include <iostream>                                            
using namespace std;                                           
                                                               
int main() {                                                   
  int N, M;                                                    
  cin >> N >> M;                                               
  int a[M];                                                    
  for (int i=0; i<M; i++) {                                    
    cin >> a[i];                                               
  }                                                            
  int ans = N-M-1;                                             
  cout << ans << endl;                                         
  return 0;                                                    
}                 

Measured memory_bytes: 3120
from collections import deque

n = int(input())
d = list(map(int, input().split()))
d.append(0)
d.sort()

deq = deque()

for i in range(n + 1):
    if i & 1:
        deq.append(d[i])
    else:
        deq.appendleft(-d[i])

ans = abs(deq[0] + 24 - deq[n])
for i in range(n):
    ans = min(ans, deq[i + 1] - deq[i])

print(ans)

Measured memory_bytes: 9416
#include<iostream>
using namespace std;
typedef long long ll;

int H, W, A, B, S;
ll M = 1000000007;
ll FACT[200001], FACT_INV[200001];

ll mod_pow(ll a,ll n){
    ll x = 1;
    
    while(n>0){
        if(n&1) x = x * a % M;

        a = a * a % M;
        n >>= 1;
    }
    return x;
}

ll combination(int n, int r){
    if(n==0 && r==0) return 1;
    else if(n<r || n<0) return 0;

    ll res = FACT[n] * FACT_INV[r] % M;
    return res * FACT_INV[n-r] % M;
}

int main(){
    cin>> H >> W >> A >> B;
    S = H + W - 2;

    FACT[0] = FACT_INV[0] = 1;
    for(int i=1;i<S+1;i++) FACT[i] = FACT[i-1] * i % M;

    FACT_INV[S] = mod_pow(FACT[S], M-2);
    for(int i=S-1;0<=i;i--) FACT_INV[i] = FACT_INV[i+1] * (i+1) % M;

    ll com = combination(S, H-1), bef = 0;
    for(int i=0;i<B;i++){
        ll c1 = combination(H-A+i, H-A), c2 = combination(S-H+A-i, A-1);
        ll tmp = (c1-bef) * c2 % M;
        bef += c1 - bef;
        com -= tmp;
        if(com<0) com += M;
    }

    cout << com % M << endl;

    return 0;
}


Measured memory_bytes: 3328
#144_E
n, k = map(int, input().split())
a = sorted(list(map(int,input().split())))
f = sorted(list(map(int,input().split())))[::-1]

l, r = -1, 10 ** 12
while r - l > 1:
    x = (r + l) // 2
    
    res = 0
    for i in range(n):
        res += max(0, a[i] - x // f[i])
    
    if res > k:
        l = x
    else:
        r = x
print(r)

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

int main(void) {
  int n, m, x, y;
  cin >> n >> m >> x >> y;

  int l=x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    l = max(l,a);
  }

  int r=y;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    r = min(r,a);
  }

  if(l<r){
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
h, w = (int(i) for i in input().split())
s = [input() for i in range(h)]

result = []
for j in range(h):
    r = ""
    for i in range(w):
        if s[j][i] == "#":
            r += "#"
            continue

        si = 0 if i == 0 else i-1
        sj = 0 if j == 0 else j-1
        ei = w if i == w-1 else i+2
        ej = h if j == h-1 else j+2
        count = 0
        for j_ in range(sj,ej):
            for i_ in range(si,ei):
                if s[j_][i_] == "#":
                    count += 1
        r += str(count)
    result.append(r)

for j in range(h):
    print(result[j])



Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] a = new int[3 * N];
        for (int i = 0; i < 3 * N; ++i) {
            a[i] = sc.nextInt();
        }

        Queue<Integer> q1 = new PriorityQueue<>();
        long[] sum1 = new long[N + 1];
        for (int i = 0; i < N; ++i) {
            q1.offer(a[i]);
            sum1[0] += a[i];
        }
        Queue<Integer> q2 = new PriorityQueue<>(Collections.reverseOrder());
        long[] sum2 = new long[N + 1];
        for (int i = 2 * N; i < 3 * N; ++i) {
            q2.offer(a[i]);
            sum2[0] += a[i];
        }

        for (int k = N; k < 2 * N; ++k) {
            q1.offer(a[k]);
            int t1 = q1.poll();
            sum1[k - N + 1] = sum1[k - N] + a[k] - t1;

            q2.offer(a[3 * N - k - 1]);
            int t2 = q2.poll();
            sum2[k - N + 1] = sum2[k - N] + a[3 * N - k - 1] - t2;
        }

        long max = Long.MIN_VALUE;
        for (int i = 0; i <= N; ++i) {
            max = Math.max(max, sum1[i] - sum2[N - i]);
        }
        _out.println(max);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<ll> dp(n, 1LL << 60);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            // if(i + j < n){
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            // }
        }
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
n,a,b,c=map(int,input().split())
a=min(3,a)
b=min(3,b)
S=[input() for i in range(n)]
X=a+b+c
idx=0
log=[0]*n#0,1のいずれか,
plog=[(a,b)]*(n+1)

flag=False

while idx!=n:

    if idx==0 and log[0]==2:
        flag=True
        break

    a,b=plog[idx]
    dx,dy=0,0
    if S[idx]=='AB':
        dx,dy=1,-1
    elif S[idx]=='BC':
        dx,dy=0,1
    else:#AC
        dx,dy=1,0

    if log[idx]==0:
        a+=dx
        b+=dy
    elif log[idx]==1:
        a-=dx
        b-=dy
    else:
        log[idx]=0
        idx-=1
        log[idx]+=1
        continue
    
    if a<0 or b<0 or X-(a+b)<0:
        log[idx]+=1
        continue
    else:
        idx+=1
        plog[idx]=(a,b)

if flag:
    print('No')
else:
    print('Yes')
    for i,s in zip(log,S):
        print(s[i])

Measured memory_bytes: 89340
#include<iostream>
#include<numeric>
using namespace std;
#define ll long long
ll f(ll x,int c,int d);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
ll a,b;
int c,d;
cin>>a>>b>>c>>d;
ll s = f(b,c,d) - f(a-1,c,d);
cout<<s;
return 0;
}


ll f(ll x,int c,int d){
  ll sum=x;
  sum-=x/c;
  sum-=x/d;
  sum+=x/lcm(c,d);
  return sum;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func switchTile(r rune) rune {
	if r == '0' {
		return '1'
	}
	return '0'
}

func changeColor(s string) int {
	if len(s) == 1 {
		return 0
	}
	if len(s) == 2 {
		changeNum := 0
		switch s {
		case "00", "11":
			changeNum = 1
		}
		return changeNum
	}

	// 最終結果は2通りなので、
	// その文字列との差を求めればいいだけな気がするが
	// 変換後の文字列も確認したいため
	runes := []rune(s)
	l := len(runes)
	changeNum := 0
	for i := 0; i+3 <= l; i++ {
		readed := string(runes[i : i+3])
		if readed == "010" || readed == "101" {
			continue
		}
		changeNum++
		switch readed {
		case "000", "111":
			runes[i+1] = switchTile(runes[i+1])
		case "100", "011":
			runes[i+2] = switchTile(runes[i+2])
		// case "010", "101":
		case "001", "110":
			runes[i] = switchTile(runes[i])
		}
	}
	return changeNum
}

func countDiff(s, origin string) int {
	diffNum := 0

	or := []rune(origin)
	sr := []rune(s)

	for i := 0; i < len(s); i++ {
		if sr[i] != or[i] {
			diffNum++
		}
	}
	return diffNum
}

func changeColorWithGenStr(s string) int {
	l := len(s)
	s0 := strings.Repeat("10", l/2)
	s1 := strings.Repeat("01", l/2)
	if l%2 == 1 {
		s0 += "1"
		s1 += "0"
	}

	s0n := countDiff(s0, s)
	s1n := countDiff(s1, s)
	if s0n < s1n {
		return s0n
	}
	return s1n
}
func main() {
	s := nextString()
	r := changeColorWithGenStr(s)
	fmt.Println(r)
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s, t;
    cin >> s >> t;
    if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main() {
  std::size_t n, m;
  std::cin >> n >> m;

  std::vector<std::size_t> a(n);
  std::vector<std::size_t> b(n);
  std::vector<std::size_t> id(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> a[i] >> b[i];
  std::iota(id.begin(), id.end(), (std::size_t)0);
 
  std::sort(id.begin(), id.end(), [&a,&b](auto i, auto j) { return a[i] < a[j]; });

  std::size_t cost = 0;
  std::size_t num = 0;
  for (auto&& i : id) {
    if (num + b[i] < m) {
      cost += a[i]*b[i];
      num += b[i];
    } else {
      cost += (m - num)*a[i];
      num = m;
      break;
    }
  }
  std::cout << cost << std::endl;
}

Measured memory_bytes: 2560
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main(int argc, char* argv[]) {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];

  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int k = i + 1; k < n; k++) {
      double sum = 0;
      for (int j = 0; j < d; j++) {
        sum += pow(x[i][j] - x[k][j], 2);
      }
      sum = sqrt(sum);
      if (ceil(sum) == floor(sum)) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 888
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0);def f(i)r=0;H[i].map{|e|f e}.sort.map{|e|r=[r,e].max+1};r end;H=Hash.new{|h,k|h[k]=[]};2.upto(gets.to_i){|i|H[gets.to_i]<<i};p f 1

Measured memory_bytes: 224596
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	s := nextString()
	ans := make([]string, (len(s)+1)/2)
	for i := 0; i < len(s); i += 2 {
		ans[i/2] = string(s[i])
	}
	fmt.Println(strings.Join(ans, ""))
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;

using namespace std;
struct UnionFind {
  
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

std::array<bool, 1000001> primes;
std::set<int> prime_list;
void init_primes(){
  for(int i=0; i<1000001; i++){
    primes[i] = true;
  }
  primes[0] = false;
  primes[1] = false;

  for(int i=2; i<1000001; i++){
    if(primes[i] == false) continue;

    prime_list.insert(i);
    int tmp = i;
    while(tmp+i < 1000001){
      tmp += i;
      primes[tmp] = false;
    }
  }
}

std::unordered_set<int> prime_decomposition(const int num){
  int tmp = num;
  std::unordered_set<int> ret;
  //std::cout << prime_list.size() << std::endl;
  for(const auto& elem: prime_list){
    while(tmp % elem == 0){
      tmp /= elem;
      ret.insert(elem);
    }
    if(tmp == 1) break;
    if(prime_list.find(tmp) != prime_list.end()){
      ret.insert(tmp);
      //tmp == 1;
      break;
    }
  }
  return ret;
}

bool is_pairwise_coprime(const std::vector<int> &A){
  std::unordered_set<int> ret;
  for(int i=0; i<A.size(); i++){
    std::unordered_set<int> decomposed = prime_decomposition(A[i]);
    int cnt_ret = ret.size(), decomp_ret = decomposed.size();
    ret.insert(decomposed.begin(), decomposed.end());
    if(cnt_ret + decomp_ret > ret.size()) return false;
  }

  return true;
}
bool is_setwise_coprime(const std::vector<int> &A){
  int val = A[0];
  for(const auto& elem: A){
    val = std::gcd(val, elem);
  }
  return val == 1;
}

void solve(void){

  int n;
  std::cin >> n;
  std::vector<int> A(n);
  for(int i=0; i<n; i++){
    std::cin >> A[i];
  }

  if(is_pairwise_coprime(A))     std::cout << "pairwise coprime" << std::endl;
  else if(is_setwise_coprime(A)) std::cout << "setwise coprime"  << std::endl;
  else                           std::cout << "not coprime"      << std::endl;
  return;
}
int main(void){
  init_primes();
  solve();
  return 0;
}





Measured memory_bytes: 11900
#include <iostream>
#include <vector>

using namespace std;

int prime(int x, vector<int>& p){
    bool flag;
    p.push_back(2);
    for(int i=3;i<=x;i+=2){
        flag = true;
        for(int j=2;j*j<=i;j++){
            if(i % j == 0){
                flag = false;
                break;
            }
        }
        if(flag) p.push_back(i);
    }
}

int main()
{
    int x;
    cin >> x;
    vector<int> prim;
    prime(1000005, prim);
    for(int p : prim){
        if(x <= p){
            cout << p << endl;
            break;
        }
    }
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int k,t;
  cin >> k >> t;
  vi data(t);
  rep(i,t) cin >> data[i];
  int ans = 0;
  rep(i,t) {
    int a = data[i] - (k - data[i]);
    if(a >= 2) ans += (a - 1);
  }
  cout << ans;
  hinata;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    int h = 0;
    for(int i = 0; i < N-1; i++) {
        if(S[i] == S[i+1]) h++;
    }

    cout << min(N-1, h+2*K);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
double a, b, x, ans=0; cin >> a >> b >> x;
if(a*a*b/2<=x){ ans=(180/M_PI)*atan((2*(a*a*b-x))/(a*a*a)); }
else{ ans=(180/M_PI)*atan((a*b*b)/(2*x)); }  
cout << setprecision(12) << ans << "\n";
}

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

void getCD(int array[],int N){
  int cnt1=0,mini=100000000;
  for(int i=0;i<N;i++){
    mini=min(mini,array[i]);
  }
  for(int j=1;j<=mini;j++){
    for(int i=0;i<N;i++){
      if(array[i]%j==0) cnt1++;
    }
    if(cnt1==N){
      cout<<j<<endl;
    }
    cnt1=0;
  }
}

int main(){

  int N;
  cin>>N;
  int array[N];
  for(int i=0;i<N;i++)
    cin>>array[i];
  getCD(array,N);
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, p;
llong a[55];
llong b[55];
llong acnt[2];
llong bcnt[2];

void dfs1(llong i, llong sum) {
    if (i >= n / 2) {
        acnt[sum % 2]++;
        return;
    }

    dfs1(i + 1, sum + a[i]);
    dfs1(i + 1, sum);
}

void dfs2(llong i, llong sum) {
    if (i >= n) {
        bcnt[sum % 2]++;
        return;
    }

    dfs2(i + 1, sum + a[i]);
    dfs2(i + 1, sum);
}

int main() {
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    dfs1(0, 0);
    dfs2(n / 2, 0);

    if (p == 0) {
        cout << acnt[0] * bcnt[0] + acnt[1] * bcnt[1] << endl;
    }
    else {
        cout << acnt[0] * bcnt[1] + acnt[1] * bcnt[0] << endl;
    }

    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int temp1,temp2;
    rep(i,m){
        cin >> temp1 >> temp2;
        road[temp1-1].push_back(temp2-1);
        road[temp2-1].push_back(temp1-1);
    }
    rep(i,n)cout << road[i].size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cmath>
#include<list>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 8;
#define MOD 1046527
int n;
char H[maxn][15];

int getChar(char ch)
{
    return ch-'A' + 1;
}
int getValue(char s[])
{
    int sum = 0;
    int p = 1;
    int len = strlen(s);
    for(int i = 0;i < len; ++i){
        sum += p * getChar(s[i]);
        p *= 6;
    }
    return sum;
}
int h1(int k)
{
    return k % MOD;
}
int h2(int k)
{
    return 1 + k % (MOD-1);
}

int is_insert(char s[])
{
    int key = getValue(s);
    int i = 0;
    while(true)
    {
        int h = (h1(key) + i * h2(key)) % MOD;
        if(strcmp(H[h],s) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h],s);
            return 0;
        }
        i++;
    }
}
int is_find(char s[])
{
    int key = getValue(s);
    int i = 0;
    while(true)
    {
        int h = (h1(key) + i * h2(key)) % MOD;
        if(strcmp(H[h],s) == 0) return 1;
        else if(strlen(H[h]) == 0){
            return 0;
        }
        i++;
    }
}
int main()
{
    char a[15],b[15];
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%s%s",a,b);
        if(a[0] == 'i'){
            is_insert(b);
        }else{
            if(is_find(b)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}

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

int main() {
	
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int ans = 0;
	rep(l, k + 1){
		rep(r, k - l + 1){
			if(l + r > n) break;
			int d = k - l -r;
			int now = 0;
			vector<int> s;
			rep(i, l){
				now += v[i];
				s.push_back(v[i]);
			}
			for(int i = n - r; i < n; i++){
				now += v[i];
				s.push_back(v[i]);
			}
			sort(s.begin(), s.end());
			rep(i, d){
				if(i >= s.size()) break;
				if(s[i] > 0) break;
				now -= s[i];
			}
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define jloop(n) for(int j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
const ll N = 2e5+9;
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
#define endl '\n'
ll po(ll,ll);















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, s;
  cin >> n >> k >> s;
  if(s==1e9){
    loop(k) cout << s << " ";
    loop(n-k) cout << "1 ";
  }
  else{
    loop(k) cout << s << " ";
    loop(n-k) cout << s+1 << " ";
  }
  R 0;
}
/*

*/



































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 1280
/*
 * Author:heroming
 * File:heroming.cpp
 * Time:2017/01/15 08:26:30
 */
#include <vector>
#include <list>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;

#define px first
#define py second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define clr(v, e) memset(v, e, sizeof(v))
#define rep(it, v) for (auto it : v)
#define forn(i, n) for (int i = 0; i < (n); ++ i)
#define rforn(i, n) for (int i = (n) - 1; i >= 0; -- i)
#define form(i, a, b) for (int i = (a); i <= (b); ++ i)
#define rform(i, a, b) for (int i = (b); i >= (a); -- i)
#define forv(i, v) for (int i = 0; i < sz(v); ++ i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++ it)

typedef long long lint;
typedef vector<int> vint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef vector<lint> vlint;
typedef vector<pint> vpint;

const int maxn = 100010;

int n, a, b;
int x[maxn];

int main() {
    while (scanf("%d%d%d", &n, &a, &b) != EOF) {
        forn (i, n) scanf("%d", &x[i]);
        lint ans = 0;
        for (int i = 1; i < n; ++ i) {
            lint d = x[i] - x[i - 1];
            if (d * a <= b) {
                ans += d * a;
            } else {
                ans += b;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
s = gets.chomp
t = gets.chomp

def ary_df(a,b)
  df = 0
  a.chars.each_with_index do |x, i|
    break unless b[i]
    if x != b[i]
      df += 1
    end
  end
  df
end

min = t.size
count = s.size-t.size
count = 1 if count.zero?

count.times do |i|
  min_t = ary_df(s[i..-1], t)
  min = min_t if min_t < min
end

puts min


Measured memory_bytes: 14616
N = int(input())
s = [0] * N
t = [0] * N
for i in range(N):
    s[i], t[i] = map(str, input().split())
for i in range(N):
    t[i] = int(t[i])
X = input()

not_listened = False
ans = 0
for i in range(N):
    if not_listened:
        ans += t[i]
    if s[i] == X:
        not_listened = True
print(ans)


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

int main(){
 int N,W;cin>>N>>W;
 vector<pair<int,int>> v;
 v.push_back(make_pair(0,0));
 for(int i=0;i<N;i++){
     int a,b;
     cin>>a>>b;
     v.push_back(make_pair(a,b));
 }
 long long dp[N+1][W+1];
for(int i=0;i<=N;i++)dp[i][0]=0;
for(int j=0;j<=W;j++)dp[0][j]=0;

for(int i=1;i<=N;i++){
 for(int j=1;j<=W;j++){
     if(v[i].first > j){
        dp[i][j]=dp[i-1][j];
     }else{
        dp[i][j]=max(dp[i-1][j-v[i].first]+v[i].second , dp[i-1][j]);
     }
   }
}
 cout<<dp[N][W];
 return 0;
}

Measured memory_bytes: 79104
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int A[N];
    int max1 = 0, max2 = 0;
    REP(i, N){
        cin >> A[i];
        if (A[i] > max2){
            max2 = A[i];
        }
        if (A[i] > max1){
            max2 = max1;
            max1 = A[i];
        }
    }

    REP(i, N){
        if(A[i] == max1){
            cout << max2 << endl;
        }
        else cout << max1 << endl;
    }
}

Measured memory_bytes: 4356
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

fn main() {
  input! {
    n: i128,
  };

  let mut res = vec![];
  for i in 1..=n {
    if i * i > 2 * n { break; }
    
    if (2 * n) % i == 0 {
      let j = (2 * n) / i;
      if let Some((k, _)) = chinese_rem(0, i, j - 1, j) {
        if k > 0 {
          res.push(k);
        }
      }
      if let Some((k, _)) = chinese_rem(0, j, i - 1, i) {
        if k > 0 {
          res.push(k);
        }
      }
    }
  }
  
  println!("{}", res.iter().min().unwrap());
}

fn ext_gcd(a: i128, b: i128, x: &mut i128, y: &mut i128) -> i128 {
  if b == 0 {
    *x = 1;
    *y = 0;
    a 
  } else {
    let d = ext_gcd(b, a % b, y, x);
    *y -= (a / b) * (*x);
    d
  }
}

fn chinese_rem(b1: i128, m1: i128, b2: i128, m2: i128) -> Option<(i128, i128)> {
  let mut x = 1i128;
  let mut y = 0i128;
  let d = ext_gcd(m1, m2, &mut x, &mut y);

  if (b2 - b1) % d != 0 {
    None
  } else {
    let m = m1 * (m2 / d);
    let t = ((b2 - b1) / d * x) % (m2 / d);
    let r = ((b1 + m1 * t) + m) % m;
    Some((r, m))
  }
}


Measured memory_bytes: 2232