akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, M;
    cin >> N >> M;
    struct Cond {
        ll s;
        ll c;
    };
    vector<Cond> conds(M);
    rep(i,0,M) {
        cin >> conds[i].s >> conds[i].c;
        conds[i].s--;
    }
    rep(n,0,1000) {
        string str = to_string(n);
        if (str.size() != N) {
            continue;
        }
        bool bad = false;
        rep(i,0,M) {
            if (str[conds[i].s] != '0' + conds[i].c) {
                bad = true;
                break;
            }
        }
        if (bad) {
            continue;
        }
        cout << n << endl;
        return 0;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 888
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.trim.split(" ").map(_.toInt)).toSeq.init
    for (Array(h, m, s) <- in) {
        val x = 7200-h*3600-m*60-s
        println("%02d:%02d:%02d".format(x/3600, x/60%60, x%60))
        println("%02d:%02d:%02d".format(x/1200, x/20%60, x*3%60))
    }
}

Measured memory_bytes: 44456
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) dunk("hon");
    if(n == 0 || n == 1 || n == 6 || n == 8) dunk("pon");
    if(n == 3) dunk("bon");
    return 0;
}

Measured memory_bytes: 3592
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int a,b;
  cin >> a >> b;
  cout << ((b%a==0) ? a+b : b-a) << endl;
  return 0;
}


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

int main(){
    ll ans = 0, n;
    cin >> n;
    rep(i, 0, n){
        ll t; cin >> t;
        while(t > 1){
            if(t%2 == 0){
                ans++;
                t /= 2;
            }else{
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

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

  vvi a (2,vi(n));
  for (int i=0; i<2; i++){
    for (int j=0; j<n; j++){
      cin >> a.at(i).at(j);
    }
  }

  int max=0;
  for (int i=0; i<n; i++){
    int sum=0;
    for (int j=0; j<n; j++){
      if (j<i){
        sum += a.at(0).at(j);
      }
      else {
        sum += a.at(1).at(j);
      }
    }
    sum += a.at(0).at(i);
    if (sum>max){
      max = sum;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
def attack(h, k, arr):
    arr.sort()
    if h - k > 0:
        return sum(arr[0:h-k])
    else:
        return 0

if __name__ == "__main__":
    h, k = map(int, input().split())
    arr = list(map(int,input().split()))
    print(attack(h, k, arr))

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

int N;
ll A[100005];
ll dp[100005][2];
ll ans=0;

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

  fill(dp[0],dp[100005],-1);
  
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      if(dp[i][j]<0)continue;

      if(A[i+1]>0&&A[i]-j>0){
        dp[i+1][1]=max(dp[i+1][1],dp[i][j]+1+(A[i]-j-1)/2LL);
      }
      dp[i+1][0]=max(dp[i+1][0],dp[i][j]+(A[i]-j)/2LL);
    }
  }

  cout<< max(dp[N][0],dp[N][1]) <<endl;
  return 0;
}


Measured memory_bytes: 2560
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

int main() {
  int S;
  cin >> S;
  if (S/100 > 12 || S/100 == 0)
    if (S%100 > 12 || S%100 == 0)
      cout << "NA" << endl;
    else 
      cout << "YYMM" << endl;
  else if (S%100 > 12 || S%100 == 0)
      cout << "MMYY" << endl;
       else
      cout << "AMBIGUOUS" << endl;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    if (b <= a + 1)
        cout << k + 1 << endl;
    else
    {
        int cnt = a;
        k -= (a - 1);
        // cout << "k:" << k << " a-1:" << a - 1 << endl;
        cnt = cnt + (b - a) * (k / 2);
        k %= 2;
        cnt += k;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

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

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"5 3 2"# => "NO",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }

    let c = s.into_iter().filter(|&x| x == 'o').count();
    (700 + c * 100).to_string()
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, K);

  vector< ll > x(N);
  vector< ll > y(N);
  REP(i, N) {
    cin >> x[i] >> y[i];
  }

  vector< ll > sortX(x);
  vector< ll > sortY(y);
  sort(ALL(sortX));
  sort(ALL(sortY));

  ll ans = (sortX.back() - sortX[0]) * (sortY.back() - sortY[0]);

  REP(xi, N) {
    REP(yi, N) {
      FOR(xj, xi, N) {
	FOR(yj, yi, N) {

	  ll minX = sortX[xi];
	  ll minY = sortY[yi];
	  ll maxX = sortX[xj];
	  ll maxY = sortY[yj];

	  int cnt = 0;
	  // ここから範囲内全探索
	  REP(i, N) {
	    if (minX <= x[i] && x[i] <= maxX &&
		minY <= y[i] && y[i] <= maxY) {
	      cnt++;
	    }
	  }

	  if (cnt >= K) {
	    ans = min(ans, (maxX - minX) * (maxY - minY));
	  }
	  
	}
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N = 4;
    int E = 3;

    vector<int> deg(N);
    vector< pair<int, int> > edges;
    for(int i=0; i<E; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        edges.emplace_back(a, b);
    }
    sort(edges.begin(), edges.end());

    vector<int> cnt(5);
    for(int i=0; i<N; i++) cnt[ deg[i] ]++;

    if(deg[1] == 2 and deg[2] == 2) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    /*
    do {
        vector<int> visited(N);

        int pre = -1;
        bool ok = true;
        for(int i=0; i<E; i++) {
            int a, b; tie(a, b) = edges[i];
            if(pre >= 0 and pre != a and pre != b) ok = false;
            if(pre == b) swap(a, b);
            visited[a] = visited[b] = true;
            pre = b;
        }

        for(int i=0; i<N; i++) {
            ok &= (visited[i]);
        }

        if(ok) {
            cout << "YES" << endl;
            return 0;
        }
    }while(next_permutation(edges.begin(), edges.end()));
    cout << "NO" << endl;
    */
    return 0;
}


Measured memory_bytes: 256
import itertools

N, K = [int(i) for i in input().split()]
a = [0] * K
c = [0] * (K - 1)
b = len(list(itertools.combinations(a,1)))

e = len(list(itertools.combinations(a,1)))

for i in range(N - 1):
    e *= len(list(itertools.combinations(c,1)))
    
print(e)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    map<Int, Int> mp;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    if (mp[0] > 0) {
        if ((Int)mp.size() == 1) {
            dump("Yes");
            return 0;
        }
        else if (n % 3 == 0 && (Int)mp.size() == 2 && mp[0] == n / 3) {
            dump("Yes");
            return 0;
        }
        else {
            dump("No");
            return 0;
        }
    }
    Int cnt = 0;
    for (auto i : mp) {
        if (i.se > 0) cnt++;
    }
    if (cnt != 3 || n % 3 != 0) {
        //cout << mp.size() << " " << n % 3 << endl;
        dump("No");
        return 0;
    }
    bool check = true;
    vector<Int> x;
    for (auto i : mp) {
        if (i.se == 0) continue;
        if (i.se != n / 3) check = false;
        x.emplace_back(i.fi);
    }
    if (!check) {
        dump("No");
        return 0;
    }
    //cout << x[0] << " " << x[1] << " " << x[2] << endl;
    dump((x[0] ^ x[1]) == x[2] ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn= new Scanner(System.in);
        int[] cookie=new int[3];
        for(int i=0;i<3;i++){
            cookie[i]=scn.nextInt();
        }
        if(cookie[0]+cookie[1]>=cookie[2]-1){
            System.out.println(cookie[1]+cookie[2]);
        }else{
            System.out.println(cookie[1]+cookie[1]+cookie[0]+1);
        }
    }
}

Measured memory_bytes: 23124
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, M;
	std::vector<int> A;
	std::cin >> N >> M;
	A.resize(M);
	for (auto& a : A)
		std::cin >> a;
	
	long total = 0;
	for (auto a : A)
		total += a;
	
	if (total <= N)
		std::cout << (N - total) << "\n";
	else
		std::cout << "-1\n";
}


Measured memory_bytes: 3640
#include<iostream>

int a, b, c, d;

int main(){
	std::cin >> a >> b >> c;
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	if (b > c){
		d = b;
		b = c;
		c = d;
	}
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	std::cout << a << ' ' << b << ' ' << c << "\n";
}


Measured memory_bytes: 3108
def main():
    n = int(input())
    a = list(map(int, input().split()))
    div = [0]*n
    ans = format(a[0], 'b')[::-1].find('1')
    for i, aa in enumerate(a):
        tmp = format(aa, 'b')[::-1].find('1')
        if tmp < ans:
            ans = tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import math

import numpy as np


def get_choices(n, p):
    choices = set()
    for i in range(1, n):
        powered = int(math.pow(p, i))
        if powered <= n:
            choices.add(powered)
        else:
            break
    return choices


def main(n):
    choices = {1}
    choices |= get_choices(n, 6)
    choices |= get_choices(n, 9)

    dp = np.full(shape=n + 1, fill_value=n, dtype=int)
    dp[0] = 0
    dp[1] = 1

    for i in range(1, n + 1):
        if i in choices:
            dp[i] = 1
        else:
            for choice in choices:
                pre_index = i - choice
                if pre_index > 0:
                    if dp[i] > dp[pre_index] + 1:
                        dp[i] = dp[pre_index] + 1
                else:
                    break

    return dp[-1]


if __name__ == '__main__':
    N = int(input())
    print(main(N))


Measured memory_bytes: 14548
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
const int N=2e5+5;
const int M=1e9+7;



void solve(){
	ll x;
	sfl(x)

	for(ll a=0;a*a*a*a*a<llinf;a++){
		ll temp=(a*a*a*a*a-x);

		//cout<<temp<<endl;
		ll temp1=temp;
		temp=abs(temp);



		int f=0;

		ll num=1;

		for(ll i=2;i*i<=temp;i++){
			if(temp%i==0){
				int cnt=0;
				while(temp%i==0){
					temp/=i;
					cnt++;
				}
				if(cnt%5!=0){
					f=1;
					break;
				}
				else{
					num=num*pow(i,cnt/5);
				}
			}
		}

		if(temp!=1 || f==1){
			continue;
		}
		else{
			if(temp1<0){
				num=num*-1ll;
			}
			cout<<a<<" "<<num;
			return;
		}
	}
}



int main(){	
	
	solve();
	return 0;	
}

Measured memory_bytes: 4164
import math
n=int(input())
x0 = n * 100 / 108
x1 = (n+1) * 100 / 108

if x0.is_integer():
    print(math.floor(x0))
elif x1.is_integer():
    print(':(')
elif math.floor(x0) != math.floor(x1):
    print(math.floor(x1))
else:
    print(':(')


Measured memory_bytes: 3060
import itertools

n, d = map(int, input().split())

x = [list(map(int, input().split())) for i in range(n)]

cnt = 0
for c in itertools.combinations(range(n), 2):
    sum = 0
    for i in range(d):
        sum += (x[c[0]][i] - x[c[1]][i])**2
    dist = sum**0.5

    if dist.is_integer():
        cnt += 1

print(cnt)

Measured memory_bytes: 9344
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 610000
ll n,m,k;
ll dp[N];
ll a[N];
ll b[N];
int main(){
    n=in();
    int w=in();
    rep(i,n){
        a[i]=in();b[i]=in();
    }
    fill(dp,dp+200000,LLINF);
    dp[0]=0;
    ll ans=0;
    rep(i,n){
        rep3(j,100000,b[i]){
            dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
            if(dp[j]<=w)ans=max(ans,(ll)j);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), y(m), ball(n, 1);
  bool poss[n];

  for(int i=0;i<n;i++) poss[i] = false;
  poss[0] = true;

  for(int i=0;i<m;i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    if(poss[x[i]] && ball[x[i]] > 1) {
      poss[y[i]] = true;
      //ball[x[i]]--;
      //ball[y[i]]++;
    }
    else if(poss[x[i]]) {
      poss[y[i]] = true;
      poss[x[i]] = false;
    }
    ball[x[i]]--;
    ball[y[i]]++;
  }
  int ans = 0;
  for(int i=0;i<n;i++)
    if(poss[i]) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 1000000
//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char cube[SIZE];
    char under_cube;
    int i,count = 0,answer = 0;
    scanf("%s",cube);
    //最初のノードの指す先
    node *first = NULL;
    /* 文字の数だけループ */
    for ( i = 0; i < strlen(cube); i++)
    {
        if (count == 0)
        {
            /* stackがからの場合、挿入 */
            push(&first,cube[i]);
            count += 1;
        }
        else
        {
            /* stackに要素がある場合、取り出す */
            under_cube = pop(&first);
            if (under_cube == cube[i])
            {
                /* 1か0が連続している場合、stackに追加 */
                push(&first,under_cube);
                push(&first,cube[i]);
                count += 1;
            }
            else
            {
                /* 連続していない場合は、追加せず */
                answer += 2;
                count -= 1;
            }
            
        }
        
    }
    printf("%d\n",answer);
    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
#include<set>
#define MAXA 100000
#define MAX 2000000000?
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int A[200001] = {0}, B[2000001] = {0};

bool cmp(int a, int b){
	return a > b;
}
int main(){
	int i, n, m, k, j, a, b, Count1 = 0, Count2 = 0;
	set<int> s;
	cin >> n >> m;
	rer(i,0,m){
		cin >> a >> b;
		if(a==1){
			A[Count1++] = b;
			s.insert(s.begin(),b);
		}
		if(b==n){
			B[Count2++] = a;
			s.insert(s.begin(),a);
		}
	}
	int is = 0;
	if(Count1==0||Count2==0){
		cout << "IMPOSSIBLE" << endl;
	}else{
		if(s.size()==(Count1+Count2)){
			cout << "IMPOSSIBLE"  << endl;
		}else{
			cout << "POSSIBLE" << endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 12032
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long CD=lcm(C, D);
		
		long BC=B/C;
		long BD=B/D;
		long AC=A/C;
		long AD=A/D;
		long BCD=B/CD;
		long ACD=A/CD;
		
		int dis=0;
		if(A%C==0) {
			dis++;
		}
		if(A%D==0) {
			dis++;
		}
		if(A%CD==0) {
			dis--;
		}
		
		
		System.out.println(B-A+1-((BC-AC)+(BD-AD)-(BCD-ACD))-dis);
		
	}
	
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c/b);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n],b[n],t[(3*n)+1];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        t[i]=a[i]^a[(i+1)%n];
    t[n]=-1;
    for(int i=0;i<n;i++)
        t[n+1+i]=b[i]^b[(i+1)%n];
    for(int i=(2*n)+1;i<(3*n)+1;i++)
        t[i]=t[i-n];
    ll x=n;
    n = (3*n)+1;
    ve<ll> pi(n);
    for (int i = 1; i < n; i++) 
    {
        int j = pi[i-1];
        while (j > 0 && t[i] != t[j])
            j = pi[j-1];
        if (t[i] == t[j])
            j++;
        pi[i] = j;
    }
    for(int i=0;i<n-1;i++)
        if(pi[i]==x)
            cout<<i-x-x<<' '<<(a[0]^b[i-x-x])<<'\n';
    subt;
    return 0;
}

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

using namespace std;

int n,m,x;
int book[15][15];

int rekurzija(int i,int zbr[],int cost){
    bool t=true;
    for(int j=0;j<m;j++)
        if(zbr[j]<x)
            t=false;
    if(t)
        return cost;
    if(i>n)
        return INT_MAX;
    int new_zbr[m];
    for(int j=0;j<m;j++)
        new_zbr[j]=zbr[j]+book[i][j+1];
    return min(rekurzija(i+1,zbr,cost),rekurzija(i+1,new_zbr,cost+book[i][0]));
}

int main(){
    cin>>n>>m>>x;
    for(int i=0;i<n;i++)
        for(int j=0;j<=m;j++)
            cin>>book[i][j];
    int zbr[m];
    memset(zbr,0,sizeof(zbr));
    int rj=rekurzija(0,zbr,0);
    if(rj==INT_MAX)
        cout << -1<<endl;
    else
        cout <<rj<<endl;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll n, k;
	cin >> n >> k;
	// ウニでn+1が行ける
	int now = ((n - 1) * (n - 2) )/ 2;
	if(k > now){
		cout << -1 << endl;
		return 0;
	}
	vector<P> ans(0);
	rep(i,n-1){
		ans.push_back({1,i+2});
	}
	bool end = false;
	For(i,2,n+1){
		For(j,i+1,n+1){
			if(now == k) {
				end = 1;
				break;
			} else {
				ans.push_back({i,j});
				now--;
			}
		}
		if(end)break;
	}
	cout << ans.size() << endl;
	for(auto x:ans){
		cout << x.first << " " << x.second << endl;
	}
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int sn = s.size(), tn = t.size();
    if(sn<tn){
        cout << "UNRESTORABLE"<<endl;
        return 0;
    }
    vector<string> ans(sn-tn+1);
    for(int i=0; i<sn-tn+1; i++){
        string ss = s;
        for(int j=0; j<tn; j++){
            if(s[j+i] == t[j] || s[j+i] == '?'){
                ss[j+i] = t[j];
            }else{
                ss = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
                break;
            }
        }
        for(int j=0; j<sn; j++){
            if(ss[j]=='?') ss[j]='a';
        }
        ans[i] = ss;
    }

    sort(ans.begin(), ans.end());
    if(ans[0] == "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"){
        cout << "UNRESTORABLE"<<endl;
    }else{
        cout << ans[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

ans = ""
if N == 1:
    print("1") 
elif N == 0:
    print("0")  
elif N == -1:
    print("10")
else:
    while True:
        r = N % 2
        N = (N-r) /-2
        ans = str(int(r)) + ans
        if N == 0 or N == 1:
            ans = str(int(N)) + ans
            break

    print(ans)

Measured memory_bytes: 9072
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    
    def set(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
    
    def kaiten(self,m):
        for i in range(6):
            self.work[i] = self.number[i]
        if m == 'E':
            self.set(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif m == 'N':
            self.set(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif m == 'S':
            self.set(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif m == 'W':
            self.set(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def top(self):
        return self.number[0]
    
a = Dice()
table = list(map(int,input().split()))
a.set(table[0], table[1], table[2], table[3], table[4], table[5])

m = str(input())
for i in m:
    a.kaiten(i)
    
print("%d"%(a.top()))


Measured memory_bytes: 5616
#include<stdio.h>
  
typedef struct{
  
  int parent;
    
  int left;

  int right;

}Node;

Node N[30];

void output1(int x);
void output2(int x);
void output3(int x);

int main(){
  
  int i, n, a;

  scanf("%d", &n);
 
  for(i = 0; i < n; i++){ 
   
    N[i].parent = -1;

  }
 
  for(i = 0; i < n; i++){
    
    scanf("%d", &a);

    scanf("%d %d", &N[a].left, &N[a].right);

    if(N[a].left != -1) 
      N[N[a].left].parent = a;

    if(N[a].right != -1) 
      N[N[a].right].parent = a;

  }
 
  int root;

  for(i = 0; i < n; i++){
    if(N[i].parent == -1){

      root = i;

      break;

    }
  }

  printf("Preorder\n");

  output1(root);
   
  printf("\nInorder\n");

  output2(root);

  printf("\nPostorder\n");

  output3(root);

  printf("\n");

  return 0;
}

void output1(int x){

  if(x == -1)
    return;

  printf(" %d", x);
  
  output1(N[x].left);

  output1(N[x].right);

}
 
void output2(int x){

  if(x == -1)
    return;

  output2(N[x].left);

  printf(" %d", x);

  output2(N[x].right);

}
 
void output3(int x){

  if(x == -1)
    return;

  output3(N[x].left);

  output3(N[x].right);

  printf(" %d", x);

}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int a,b,c;
    cin >> a >> b >> c;

    cout<<a+b+c-max(a,max(b,c))<<endl;

 return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	l := []string{"dream", "dreamer", "erase", "eraser"}
	change := true
	for change && len(S) > 0 {
		change = false
		for _, v := range l {
			if len(v) <= len(S) && S[len(S) - len(v):] == v {
				S = S[:len(S) - len(v)]
				change = true
				break
			}
		}
	}
	if len(S) > 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1280
import math
a,b,x=map(int,input().split())
theta=0

if x<=a**2*b/2:
	theta=math.degrees(math.atan(a*b**2/(2*x)))
else:
	theta=math.degrees(math.atan(2*(a**2*b-x)/a**3))

print(theta)

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

int main() {
    int N, D;
    cin >> N >> D;
    int DD = 2*D + 1;
    int ans = N / DD;
    if (N%DD != 0) {
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
ll n,i,sum=0;
cin>>n;
ll a[n];
for(i=0;i<n;i++)cin>>a[i];
for(i=0;i<n-1;i++)
{
    if(a[i]>a[i+1])
    {
        sum+=(a[i]-a[i+1]);
        a[i+1]=a[i];
    }
}
cout<<sum;
return 0;
}


Measured memory_bytes: 5164
def main():
    N = int(input())
    digits = []

    while N != 0:
        digits.append(N % 26)
        if digits[-1] == 0:
            digits[-1] = 26
            N //= 26
            N -= 1
        else:
            N //= 26
    digits.reverse()
    for d in digits:
        print(chr(96 + d), end='')
    print()  # 改行


if __name__ == '__main__':
    main()


Measured memory_bytes: 8948
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  cin >>A>>B>>C>>D;
  
  if(C>A){
    cout << "1" << endl;
  }
  else cout << "0" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k, a[200010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	int mi = 0, ma = 1000000000;
	while (ma - mi > 1) {
		int md = (mi + ma) / 2;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % md == 0)cnt += a[i] / md - 1;
			else cnt += a[i] / md;
		}
		if (cnt <= k)ma = md;
		else mi = md;
	}
	cout << ma << endl;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, ans, tmp;
  cin >> n >> a >> b >> c;
  int l[n] = {};
  vector<int> x(3, 0) ;
  int y[3] = {};
  int i[8] = {};
  for(int k = 0; k < n; k++){
    cin >> l[k];
  }

  for(i[0] = 0; i[0] < 4; i[0]++){
    for(i[1] = 0; i[1] < 4; i[1]++){
      for(i[2] = 0; i[2] < 4; i[2]++){
        for(i[3] = 0; i[3] < 4; i[3]++){
          for(i[4] = 0; i[4] < 4; i[4]++){
            for(i[5] = 0; i[5] < 4; i[5]++){
              for(i[6] = 0; i[6] < 4; i[6]++){
                for(i[7] = 0; i[7] < 4; i[7]++){
                  tmp = 0;
                  x[0] = 0;
                  x[1] = 0;
                  x[2] = 0;
                  y[0] = 0;
                  y[1] = 0;
                  y[2] = 0;
                  for(int j = 0; j < n; j++){
                    if(i[j] == 1){
                      x[0] += l[j];
                      y[0]++;
                      if(y[0]>1){
                        tmp += 10;
                      }
                    }
                    if(i[j] == 2){
                      x[1] += l[j];
                      y[1]++;
                      if(y[1]>1){
                        tmp += 10;
                      }
                    }
                    if(i[j] == 3){
                      x[2] += l[j];
                      y[2]++;
                      if(y[2]>1){
                        tmp += 10;
                      }
                    }
                  }
                  sort(x.begin(), x.end());
                  if(x[0]*x[1]*x[2] != 0){
                    tmp += abs(x[0] - c) + abs(x[1] - b) + abs(x[2] - a);
                    if(ans > tmp){
                      ans = tmp;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.siz = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                self.siz[y] += self.siz[x]
            else:
                self.par[y] = x
                self.siz[x] += self.siz[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

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

    def size(self, x):
        return self.siz[self.find(x)]

    def print_tree(self):
        print(self.rank)
        print(self.par)

n,m,k = map(int, input().split())

uf = UnionFind(n)
ng = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    uf.union(a, b)

    ng[a].append(b)
    ng[b].append(a)

for i in range(k):
    c, d = map(int, input().split())
    c-=1
    d-=1
    if uf.is_same(c, d):
        ng[c].append(d)
        ng[d].append(c)

ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - len(ng[i]) - 1

print(*ans)


Measured memory_bytes: 38336
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func main() {
	scanner.Split(bufio.ScanWords)
	query := strings.ToLower(nextString())
	nHitted := 0
	for {
		w := nextString()
		if w == "END_OF_TEXT" {
			break
		}
		if strings.ToLower(w) == query {
			nHitted++
			// fmt.Println(nHitted, w)
		} else {
			// fmt.Println(w)
		}
	}
	fmt.Println(nHitted)
}



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

using namespace std;

int
main(void){
    int n; cin >> n;
	vector<int> vec = {399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4800};
	vector<int> mp(9, 0);
	int a; 
	int add = 0;
	for(int i = 0; i < n; i++){
		cin >> a;
		for(int i = 0; i < 9; i++){
			if(i == 8){
				add++;
				break;
			}
			if(a <= vec[i]){
				mp[i] = 1;
				break;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 8; i++) ans += mp[i];
	cout << max(ans, 1) << " " << ans + add;
	
}

Measured memory_bytes: 256
a, b, c, x, y = [int(x) for x in input().split()]

if a + b < c*2:
    res = a*x + b*y
else:
    min_c = min(x, y)
    ab_cost = min_c * 2 * c
    rem = max(x-min_c, y-min_c)
    if x > y:
        rem_cost = min(rem * a, rem*2*c)
    else:
        rem_cost = min(rem*b, rem*2*c)
    res = ab_cost + rem_cost
print(res)

Measured memory_bytes: 3064
import java.util.Scanner;

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

			for (int i = 0; i < n; i++) {
				String x = in.next();
				String y = in.next();

				System.out.printf("%d\n", lcs(x, y));
			}
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}

	private static int lcs(final String x, final String y) {
		int n = x.length();
		int m = y.length();

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

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);

				if (x.charAt(i-1) == y.charAt(j-1))
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1]+1);
			}
		}

		return dp[n][m];
	}
}

Measured memory_bytes: 65064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() { 
  ll n; cin >> n;
  ll p[100010];
  Rep(i, 1, n) cin >> p[i];
  ll cnt = 0;
  Rep(i, 1, n){
    if(p[i] == i){
      if(i != n) if(p[i+1] == i+1){
        swap(p[i], p[i+1]);
      }
      cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  vector<long> data(N);
  long sum = 0;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    sum += data.at(i);
  }
  long count = 0;
  for(int i = 0; i < N; i++){
    if(4 * M * data.at(i) >= sum)count++;
  }
  cout << (count >= M? "Yes": "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  vector<string> v(n);
  rep(i, n) cin >> v[i];
  sort(All(v));
  string ans = "";
  rep(i, n) ans += v[i];
  cout << ans << endl;
  system("pause");
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int64_t a = ri(), b = ri(), c = ri();
	a *= 4;
	b *= 4;
	c *= 4;
	int64_t left = c - a - b;
	left /= 2;
	if (left < 0) {
		puts("No");
		return 0;
	}
	left = left * left;
	puts((int64_t) a * b < left ? "Yes" : "No");
	return 0;
}




Measured memory_bytes: 256