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

int main(void) {
    int num,*mat,ans=0,i,j;
    scanf("%d",&num);
    mat=malloc(sizeof(int)*num);
    for (i=0;i<num;i++) {
        scanf("%d",&mat[i]);
    }
    for (i=0;i<num-1;i++) {
        for (j=i+1;j<num;j++) {
            ans+=mat[i]*mat[j];
        }
    }
    free(mat);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long N,M;
    cin >> N >> M;
    long long ans=0;
    if(2*N<=M){
        ans=N+(M-2*N)/4;
    }else{
        ans=M/2;
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int res = 0;
    REP(i, N) {
        string s = to_string(i + 1);
        if (s.size() % 2 == 1) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


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

fn main() {
    input! {
        x: i64,
        y: i64
    }

    println!("{}", if (x - y).abs() <= 1 {"Brown"} else {"Alice"});
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;

namespace ABC045C{
    public class Program{
        public static void Main(string[] args){
            var S = Console.ReadLine();

            var list = new List<long>{(long)Math.Pow(2, S.Length - 1)};
            var res = 0L;
            for(var i = S.Length - 1; i >= 0; i--){
                var mul = 1;
                for(var j = 0; j < list.Count; j++){
                    res += (S[i] - '0') * list[j] * mul;
                    mul *= 10;
                }
                list[list.Count - 1] /= 2;
                list.Add(list[list.Count - 1]);
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 2904
import numpy as np

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

if len(arr) == 1:
    print(arr[0])
else:
    print(gcd(arr))


Measured memory_bytes: 23056
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<iterator>
#include <stack>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()),((v).end())
#define vec2(n,m) vector<vector<ll>>vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1   priority_queue<int,vector<int>,greater<int>>pq1;
#define format(n) fixed<<setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first 
#define S second
#define mkpr(x,y)  make_pair(x,y)
using namespace std;
void weza()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
	weza();
	ll t, n, m, c,a,d,b;
    cin >> a >> b>>c>>d;
    n = c / b;
    if (c % b != 0)
        n++;
    m = a / d;
    if (a % d != 0)
        m++;
    if (n < m + 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    fenwick_tree<lint> fw(N);
    for_(i,0,N) {
        lint a;
        cin >> a;
        fw.add(i, a);
    }
    
    for_(i,0,Q) {
        int t; lint a, b;
        cin >> t >> a >> b;
        if (t == 0) fw.add(a, b);
        else cout << fw.sum(a, b) << endl;
    }
}

Measured memory_bytes: 8212
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <unordered_map>   
#define waru 1000000000+7

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s;
    unsigned long long int res = 0;
    vector<int> che(n);
    unordered_map<string, int> hash; 
    rep(i,n){
        che[i] = 0;
        string buf;
        cin >> buf;
        sort(all(buf));
        auto itr = hash.find(buf);        // "xyz" が設定されているか？
        if( itr != hash.end() ) {
            res += hash[buf];
             hash[buf]++;

        } else {
            hash[buf] = 1;    
        }
        // s.push_back(buf);
    }

    // rep(i,n){
    //     for(int j = i+1; j < n; j++){
    //         if(s[i] == s[j]){
    //             res++;
    //         }
    //     }
    // }

    cout << res;
   }

Measured memory_bytes: 11044
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N, P;
  std::cin >> N >> P;
  std::vector<std::pair<i64, i64>> v, a;
  for (usize i = 0; i < N; i++) {
    i64 w, b;
    std::cin >> w >> b;
    v.push_back({w, b});
    a.push_back({(100 - P) * w + P * b, i});
  }

  std::sort(a.begin(), a.end(), std::greater<std::pair<i64, i64>>());

  i32 ok = N, ng = 0;
  while (abs(ok - ng) > 1) {
    i32 mid = (ok + ng) / 2;

    auto C = [&](i32 mid) {
      i64 sum = 0;
      for (usize i = 0; i < static_cast<usize>(mid); i++) {
        usize idx = a[i].second;
        sum += (100 - P) * v[idx].first;
      }
      for (usize i = mid; i < N; i++) {
        usize idx = a[i].second;
        sum -= P * v[idx].second;
      }

      if (sum >= 0) {
        return true;
      } else {
        return false;
      }
    };

    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  std::cout << ok << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll a[200000], b[200000], d[200000], c=0, e=1;
int f(ll x){
    if(d[0]>=x)return 0;
    if(d[n-1]<x)return n;
    int l=0, r=n-1;
    while(l+1<r){
        int m=(l+r)/2;
        if(d[m]<x){
            l=m;
        }else{
            r=m;
        }
    }
    return l+1;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<30;i++){
        for(int j=0;j<n;j++){
            d[j]=b[j]%(e*2);
        }
        sort(d, d+n);
        ll t=0;
        for(int j=0;j<n;j++){
            ll x=a[j]%(e*2);
            t+=f(e*4-x)-f(e*3-x)+f(e*2-x)-f(e-x);
        }
        t%=2;
        c+=(t<<i);
        e*=2;
    }
    cout<<c<<endl;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void bad()
{
	cout << "No" << endl;
	exit(0);
}

const int N = 1 << 17;
int n, m;
VI G[N];
set<int> g[N];
char used[N];
int batya[N];
bool kin;

void vydaly(int x, int y)
{
	g[x].erase(y);
	g[y].erase(x);
}

void dfs0(int v, int p)
{
	if (kin)
		return;
		
	batya[v] = p;
	used[v] = 1;
	for(auto i: G[v])
		if (i != p)
		{
			if (!used[i])
				dfs0(i, v);
			else
			{
				if (kin)
					return;
					
				kin = 1;
				VI path;
				while(v != i)
				{
					path.PB(v);
					v = batya[v];
				}
				
				path.PB(v);
				path.PB(path[0]);
				FOR(j, 0, SZ(path) - 1)
					vydaly(path[j], path[j + 1]);
				
				return;
			}
		}
		
}

bool zle()
{
	while(1)
	{
		if (clock() / (double)CLOCKS_PER_SEC >= 1.8)
			break;
			
		FOR(i, 1, n + 1)
			used[i] = 0, g[i].clear();
			
		FOR(i, 1, n + 1)
			for(auto j: G[i])
				g[i].insert(j);
		
		FOR(i, 1, n + 1)
			shuffle(ALL(G[i]), rng);
			
		kin = 0;
		dfs0(1 + (rng() % n), 1);
		bool ok = 0;
		FOR(i, 1, n + 1)
			if (SZ(g[i]) > 2)
				ok = 1;
		
		if (ok)
			return 0;
	}
	
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> m;
	FOR(i, 0, m)
	{
		int u, v;
		cin >> u >> v;
		g[u].insert(v);
		g[v].insert(u);
		G[u].PB(v);
		G[v].PB(u);
	}
	
	if (m < 9)
		bad();
	
	if (m - n < 2)
		bad();
		
	FOR(i, 1, n + 1)
		if (SZ(g[i]) & 1)
			bad();
	
	if (zle())
		bad();
		
	cout << "Yes" << endl;
			
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

ll N, L;
string S;
ll p = 0;

vector<vector<ll>> sl(vector<vector<ll>> &a, ll r) {
  vector<vector<ll>> b(a);
  REP(i, 0, N) b[r][i] = a[r][(i + 1) % N];
  return b;
}

vector<vector<ll>> sr(vector<vector<ll>> &a, ll r) {
  vector<vector<ll>> b(a);
  REP(i, 0, N) b[r][i] = a[r][(i + N - 1) % N];
  return b;
}

vector<vector<ll>> su(vector<vector<ll>> &a, ll c) {
  vector<vector<ll>> b(a);
  REP(i, 0, N) b[i][c] = a[(i + 1) % N][c];
  return b;
}

vector<vector<ll>> sd(vector<vector<ll>> &a, ll c) {
  vector<vector<ll>> b(a);
  REP(i, 0, N) b[i][c] = a[(i + N - 1) % N][c];
  return b;
}

vector<vector<ll>> mg(vector<vector<ll>> &a, vector<vector<ll>> &b) {
  vector<vector<ll>> c(N, vector<ll>(N));
  REP(i, 0, N) REP(j, 0, N) {
    ll y = b[i][j] / N, x = b[i][j] % N;
    c[i][j] = a[y][x];
  }
  return c;
}

vector<vector<ll>> pw(vector<vector<ll>> &a, ll n) {
  if (n == 0) {
    vector<vector<ll>> e(N, vector<ll>(N));
    REP(i, 0, N) REP(j, 0, N) e[i][j] = i * N + j;
    return e;
  }
  if (n % 2 == 0) {
    vector<vector<ll>> b = mg(a, a);
    return pw(b, n / 2);
  } else {
    vector<vector<ll>> b = pw(a, n - 1);
    return mg(a, b);
  }
}

ll number() {
  ll n = 0;
  while (p < L && isdigit(S[p])) {
    n = n * 10 + (S[p++] - '0');
  }
  return n;
}

vector<vector<ll>> sequence() {
  vector<vector<ll>> ret(N, vector<ll>(N));
  REP(i, 0, N) REP(j, 0, N) ret[i][j] = i * N + j;

  while (p < L) {
    char c = S[p++];
    if (c == 'L') {
      ret = sl(ret, number() - 1);
    } else if (c == 'R') {
      ret = sr(ret, number() - 1);
    } else if (c == 'U') {
      ret = su(ret, number() - 1);
    } else if (c == 'D') {
      ret = sd(ret, number() - 1);
    } else if (c == '(') {
      vector<vector<ll>> a = sequence();
      vector<vector<ll>> b = pw(a, number());
      ret = mg(ret, b);
    } else if (c == ')') {
      break;
    }
  }

  return ret;
}

int main(void) {
  cin >> N >> L >> S;

  vector<vector<ll>> s = sequence();
  REP(i, 0, N) {
    REP(j, 0, N) cout << s[i][j] + 1 << (j + 1 != N ? " " : "\n");
  }
}


Measured memory_bytes: 30700
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int k;
    cin >> k;
    int n = 50;

    int ans[n];
    for (int i = 0; i < n; i++) {
        ans[i] = (n - 1) + k / n;
    }

    int remain = k % n;
    for (int i = 0; i < remain; i++) {
        ans[i] += n;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            ans[j]--;
        }
    }

    cout << n << endl;
    for (int i = 0; i < n; i++) {
        cout << ans[i];
        if (i != n - 1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long int ll;

int main (){
    ll m,n,ans=0;
    cin >> m >> n;
    for (ll i=1;i<=m;i++){
        for (ll j=22;j<=n;j++){
            ll j2,j3;
            j2=j%10;
            j3=j/10;
            if (j2<2 || j3<2)continue;
            if (j2*j3==i){
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    int N; cin>>N;
    vector<string> sequence(N);
    for(int i=0;i<N;i++){
        cin>>sequence.at(i);
        sort(sequence.at(i).begin(),sequence.at(i).end());
    }
    sort(sequence.begin(),sequence.end());
  //for(int i=0;i<N;i++)cout<<sequence.at(i)<<endl;
    long count=0;
    long bookmark = 0;
    for(long i=0;i<N;i++){
        if(sequence.at(i)!=sequence.at(bookmark)){
            count = count+(i-bookmark)*(i-bookmark-1)/2;
          //cout<<count<<endl;
            bookmark = i;
        }
      if(i==N-1){
        count = count+(i-bookmark+1)*(i-bookmark)/2;
          //cout<<count<<endl;
            bookmark = i;
      }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 7296
A = list(input().split())
B = []

for i in range(len(A)):
    if A[i]=='+':
        y=B.pop()
        x=B.pop()
        B.append(x+y)
    elif A[i]=='-':
        y=B.pop()
        x=B.pop()
        B.append(x-y)
    elif A[i]=='*':
        y=B.pop()
        x=B.pop()
        B.append(x*y)
    else:
        B.append(int(A[i]))

print(B[0])


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

int main() {
	int n, cntt = 0, cnth = 0;
	string cardt, cardh;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> cardt >> cardh;
		if (cardt > cardh)
			cntt += 3;
		else if (cardt < cardh)
			cnth += 3;
		else {
			cntt++;
			cnth++;
		}
	}

	cout << cntt << " " << cnth << endl;

	return 0;
}

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

int n, a, b, ra, rb;
string s;
int main() {
	cin >> n >> a >> b >> s;
	for(int i=0; i<n; i++) {
		if(s[i]=='c') {
			puts("No");
		} else if(s[i]=='a') {
			if(ra+rb+1 <= a+b) {
				puts("Yes");
				ra++;
			} else puts("No");
		} else {
			if(ra+rb+1 <= a+b && rb+1 <= b) {
				puts("Yes");
				rb++;
			} else puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 896
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> x, std::vector<long long> y){
  vl idx(N);
  iota(ALL(idx), 0LL);
  long double ans = 0.0, cnt = 0.0;

  do{
    cnt += 1.0;
    long double dis = 0.0;
    
    rep(i,N-1) dis += sqrt(double(x[idx[i+1]]-x[idx[i]])*double(x[idx[i+1]]-x[idx[i]])+double(y[idx[i+1]]-y[idx[i]])*double(y[idx[i+1]]-y[idx[i]]));
    dump(dis);
    ans += dis;
  }while(next_permutation(ALL(idx)));
  dump(ans,cnt);
  cout << ans/cnt << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////

int main() {
    
    ll K;
    cin >> K;
    ll ans = 0;
    repn(a, K)repn(b, K)repn(c, K) {
        ans += gcd(a, gcd(b, c));
    }
    cout << ans;
    
    system("PAUSE");
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   
    queue<int> q;
    
    int v,e;
    cin>>v>>e;
    
    vector<int> g[v+1];
    //ans(i):部屋iの道しるべ
    vector<int> ans(v+1,-1);
    
    ans[1]=1;
    //1番目の部屋は必ず１の部屋に行ける
    
    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }//とりあえず、辺の情報を隣接リストに収納
    
   
    for(int u:g[1]){
        if(u==0)break;
        else {
            q.push(u);
            ans[u]=1;//部屋sと接している部屋の道しるべは1
        }
    }//まず、1の部屋から調べて行って、1の部屋と直接つながっているときに道しるべは必ず１
    
   while (!q.empty()) {
   
       //全ての部屋に道しるべができるまで調べる。BFS?
       
        int s=q.front();q.pop();//すでに道しるべが決まっている部屋sを１つずつ調べる。
        
        for(int u:g[s]){
            
                if(ans[u]!=-1)continue;//すでに道しるべあり
                else{
                    q.push(u);
                    ans[u]=s;//部屋sと接しているかつ、まだ道しるべがないところは道しるべがsになる。
                }
            
        }
   }
 //全ての部屋はつながっているので必ず道しるべがある
cout<<"Yes"<<endl;
          for(int i=2;i<v+1;i++){
              cout<<ans[i]<<endl;
          }
 
    return 0;
}

   
    

   


    

   



Measured memory_bytes: 10240
fun main(args: Array<String>) {
    a89(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a89(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val num = args[0].toInt()
    println(num / 3)
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int a[5];
    rep(i, 5) cin >> a[i];
    rep(i,5){
        if(a[i]==0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort(); F.sort(); F=F[::-1]

def test(x):
    return np.maximum(0,A-x//F).sum() <= K

left = -1
right = 10**13
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)



Measured memory_bytes: 27784
#include <iostream>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main()
{
    optimizar_io;
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)==c || (a+c)==b || (b+c)==a){cout<<"Yes\n";}
    else{cout<<"No\n";}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
struct node
{
    int y,next;
};
node e[1100000];
int loc[1100000];
int top=1;

int w[1001][1001];

int ind[1100000];
int level[1100000];
int q[1100000];
int l,r;
int nownum;
int n;

void addedge(int x, int y)
{
    ind[y]++;
    e[top].y = y;
    e[top].next = loc[x];
    loc[x] = top;
    top++;
}

int topsort()
{
    l = 0;
    r = 0;
    int max_level = 1;
    for (int i=1; i<=nownum; ++i)
        if (ind[i] == 0)
        {
            level[i] = 1;
            q[r] = i;
            r++;
        }
    while (l<r)
    {
        int x=q[l]; l++;
        for (int now=loc[x]; now; now=e[now].next)
        {
            ind[e[now].y]--;
            if (ind[e[now].y]==0)
            {
                level[e[now].y] = level[x]+1;
                q[r]=e[now].y; r++;
                max_level = max(max_level, level[e[now].y]);
            }
        }

    }
    if (r!=nownum) return -1;
    return max_level;
    
}

int main()
{
    cin >> n;
    nownum=1;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n; ++j)
        {
            if (i==j) continue;
            if (w[j][i]!=0)
                w[i][j] = w[j][i];
            else
            {
                w[i][j] = nownum;
                nownum++;
            }
        }
    nownum-=1;
    int prenode, y;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n-1; ++j)
        {
            if (j==1) prenode=0;
            scanf("%d",&y);
            if (prenode)
                addedge(prenode, w[i][y]);
            prenode = w[i][y];
        }
    cout << topsort() <<endl;

    return 0;
}



Measured memory_bytes: 27008
n = gets.to_i
a = gets.split.map(&:to_i).group_by(&:itself).transform_values(&:count)
sum = a.sum{|k, v| k * v}
q = gets.to_i
q.times do
  b, c = gets.split.map(&:to_i)
  if a.has_key?(b)
    sum += (c - b) * a[b]
    if a.has_key?(c)
      a[c] += a[b]
    else
      a[c] = a[b]
    end
    a[b] = 0
  end
  p sum
end


Measured memory_bytes: 26344
import sys

def main():
    input = sys.stdin.readline
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    ans = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                if 500 * i + 100 * j + 50 * k == X:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	int A[21], B[21], C[21];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i]--;
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
		ans += B[i];
	}
	for (int i = 0; i < N - 1; ++i) {
		cin >> C[i];
	}
	for (int i = 1; i < N; ++i) {
		if (A[i] == A[i - 1] + 1) {
			ans += C[A[i-1]];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

int main(int argc,char *argv[]){
	int A1,A2,A3;
	std::cin >> A1 >> A2 >> A3;	
	std::cout <<
		+ std::max(A1,std::max(A2,A3))
		- std::min(A1,std::min(A2,A3)) << std::endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,H = MI()
X = []
for i in range(N):
    a,b = MI()
    X.append((a,0))
    X.append((b,1))

X.sort(reverse=True)

i = 0
ans = 0
while H > 0:
    x,y = X[i]
    if y == 1:
        H -= x
        i += 1
        ans += 1
    else:
        ans += (H+x-1)//x
        break

print(ans)


Measured memory_bytes: 86116
#include<stdio.h>

#define Max 200000

int main(){
  int i, j, n, R[Max], minv, maxv;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++) scanf("%d", &R[i]);

  maxv = R[1] - R[0];
  minv = R[0];

  for(j = 1 ; j <= n - 1 ; j++){
    //if(minv > R[j]) minv = R[j];
    if(maxv < R[j] - minv) maxv = R[j] - minv;
    if(minv > R[j]) minv = R[j];
  }

  printf("%d\n", maxv);

  return 0;
}



Measured memory_bytes: 2576
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAXN 1123
 
int H, W;
int grid[MAXN][MAXN];
int vis[MAXN][MAXN];
ll memo[MAXN][MAXN];

ll solve(int h, int w) {
	if( h == H-1 && w == W-1 )
		return 1;

	if( vis[h][w] == 1 )
		return memo[h][w];
	vis[h][w] = 1;

	if( grid[h][w] == 0 )
		return 0;

	return memo[h][w] = ( solve( h+1, w ) + solve( h, w+1 ) ) % MOD;
}

int main() {
  
  	cin>>H>>W;
  	char ch;
  	for( int i=0; i<H; i++ ) {
  		for( int j=0; j<W; j++ ) {
  			cin>>ch;
  			grid[i][j] = (ch == '.');
  		}
  	}

  	ll res = solve( 0, 0 );
  	cout<<res<<endl;

  	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


ll dp[60][205000];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,k;
    cin >> n >> k;
    rep(i, n){
        cin >> dp[0][i];
        dp[0][i]--;
    }
    rep(i, 59){
        rep(j, n){
            dp[i + 1][j] = dp[i][dp[i][j]];
        }
    }
    int v = 0;
    for(int i = 59; i >= 0; --i){
        if(k & (1LL << i)) v = dp[i][v];
    }
    print(v + 1);


}



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

int main()
{
	int N, K,l[50],ans = 0;

	cin >> N >> K;

	for (int i = 0; i < N; i++)
		cin >> l[i];

	sort(l, l + N);
	reverse(l, l + N);

	for (int i = 0; i < K; i++) {
		ans += l[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        String[] arr = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
        int i;
        String s;
        i=0;
        s=scan.next();
        while(! s.equals(arr[i])){
            i+=1;
        }
        if(6-i==0) System.out.println(7);
        else System.out.println(6-i);
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K,S,T; cin >> N >> K >> S >> T;
    vector<int> A;
    for (;N--;){
        int a; cin >> a;
        bool ok=true;
        for (int j=0;j<18;++j){
            if ((S&1<<j)&&!(a&1<<j)) ok=false;
            if (!(T&1<<j)&&(a&1<<j)) ok=false;
        }
        if (ok) A.emplace_back(a);
    }
    vector<int> diff;
    for (int i=0;i<18;++i){
        if ((S&1<<i)&&!(T&1<<i)){
            cout << 0 << '\n';
            return 0;
        }
        if (!(S&1<<i)&&(T&1<<i)) diff.emplace_back(i);
    }
    N=A.size();
    vector<vector<ll>> choose(N+1,vector<ll>(N+1,0));
    for (int i=1;i<=N;++i){
        choose[i][0]=1;
        for (int j=0;j<min(K,i);++j) choose[i][j+1]=choose[i][j]*(i-j)/(j+1);
        for (int j=0;j<N;++j) choose[i][j+1]+=choose[i][j];
    }
    int M=diff.size();
    ll ans=0;
    for (int mask=0;mask<(1<<M);++mask){
        map<int,int> mp;
        for (int i=0;i<N;++i){
            int cnt=0;
            for (int j=0;j<M;++j) if (mask&1<<j){
                cnt|=((A[i]&1<<diff[j])>>diff[j])<<j;
            }
            ++mp[cnt];
        }
        int flag=__builtin_popcount(mask);
        for (auto p:mp){
            if (flag&1) ans-=choose[p.second][min(N,K)]-1;
            else ans+=choose[p.second][min(N,K)]-1;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3644
def z_algorithm(S):
    """
    文字列の各インデックスについて「SとS[i: len(S) - 1]の最良共通接頭辞の長さ」を求め、
    それを記録した配列Aを O(|S|) で作成します。
    """
    A = [-1 for _ in range(len(S))]
    A[0] = len(S)
    i = 1
    j = 0
    while i < len(S):
        while i + j < len(S) and S[j] == S[i + j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < len(S) and k + A[k] < j:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    return A


N = int(input())
S = input()

ans = 0
for i in range(N - 1):
    s = S[i:]
    A = z_algorithm(s)
    A = [min(i, a) for i, a in enumerate(A)]  # 重複する区間の除去
    ans = max(ans, max(A[1:]))
print(ans)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m;
void solve(){
	cin >> n >> m;
	m /= 1000;
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j+i <= n; j++){
			if(m < i*10+j*5) break;
			if(m-(i*10+j*5) == n-i-j){
				cout << i << " " << j << " " << n-i-j << endl;
				return;
			}
		}
	}
	cout << "-1 -1 -1" << endl; 
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] a = new int[N  + 1], b = new int[N + 1], c = new int[N + 1];
        int[][] f = new int[N + 1][3];
        for(int i = 1; i <= N; i ++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        for(int i = 1; i <= N; i ++){
            f[i][0] = Math.max(f[i - 1][1],f[i - 1][2]) + a[i];
            f[i][1] = Math.max(f[i - 1][0],f[i - 1][2]) + b[i];
            f[i][2] = Math.max(f[i - 1][1],f[i - 1][0]) + c[i];
        }

        System.out.println(Math.max(Math.max(f[N][0],f[N][1]),f[N][2]));
    }
}

Measured memory_bytes: 96448
n,k=map(int,input().split())
x=list(map(int,input().split()))
v=1e9
for l in range(n-k+1):
  r=l+k-1
  a=abs(x[l])+abs(x[l]-x[r])
  b=abs(x[r])+abs(x[l]-x[r])
  v=min(v,min(a,b))
print(v)

Measured memory_bytes: 14252
n = int(input())

t = 0
h = 0
for i in range(n):
	card1, card2 = map(str, input().split())
	if card1 > card2:
		t += 3
	elif card1 < card2:
		h += 3
	else:
		t += 1
		h += 1

print(str(t) + ' ' + str(h))



Measured memory_bytes: 5596
abc = gets.split(' ').map(&:to_i)

a = abc[0]
b = abc[1]
c = abc[2]

if c < a && c < b then
    puts "No"
elsif 4*a*b < (c-a-b)*(c-a-b) then
    puts "Yes"
else
    puts "No"
end
    

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=1;
  cin >> n;
  vector<string> S(n);
  for(int i=0;i<n;i++)cin >> S[i];
  sort(S.begin(),S.end());
  for(int i=1;i<n;i++)if(S[i-1]!=S[i])cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 9548
def main():
    S = [list(input()) for _ in range(3)]
    
    f = "a"
    while 1:
        if f == "a":
            if len(S[0]) == 0:
                print("A")
                break
            else:
                f = S[0].pop(0)
        elif f == "b":
            if len(S[1]) == 0:
                print("B")
                break
            else:
                f = S[1].pop(0)
                
        elif f == "c":
            if len(S[2]) == 0:
                print("C")
                break
            else:
                f = S[2].pop(0)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    std::string str;
    std::cin >> str;

    int val;
    std::vector<int> vec;
    for(int i = 1; i < str.size() - 1; ++i){
        vec.push_back(abs(std::stoi(str.substr(i - 1, 3)) - 753));
    }
    
    std::sort(vec.begin(), vec.end());

    std::cout << *vec.begin() << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

typedef double db;
int main()
{
	int n, m, d; scanf("%d%d%d", &n, &m, &d);
	db ans = 2.0 * (n - d) / (1.0 * n * n);
	if (d == 0) ans /= 2.0;
	printf("%.10lf\n", ans * (m - 1));
	return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 'APPROVED'
    for i in range(n):
        if a[i]%2 == 0:
            if a[i]%3 != 0 and a[i]%5 != 0:
                ans = 'DENIED'
                break

    print(ans)

main()

Measured memory_bytes: 38384
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int u = sc.nextInt(), v = sc.nextInt();
		Map<Integer, HashSet<Integer>> edge = new HashMap<>();
		for(int i = 1; i <= N; i++)
		        edge.put(i,  new HashSet<>());
		for (int i = 1; i <= N-1; i++) {
		        int A = sc.nextInt(), B = sc.nextInt();
		        edge.get(A).add(B);
		        edge.get(B).add(A);
		}
		int[] da = new int[N+1];
		Arrays.fill(da, -1);
		da[v] = 0;
		Queue<Integer> qa = new ArrayDeque<>();
		for(int i : edge.get(v)) {
			qa.offer(i);
			da[i] = 1;
		}
		while(qa.size() > 0) {
			int x = qa.poll();
			for(int i : edge.get(x)) {
				if(da[i] == -1) {
					da[i] = da[x] + 1;
					qa.offer(i);
				}
			}
		}
		int[] dt = new int[N+1];
		Arrays.fill(dt, -1);
		dt[u] = 0;
		Queue<Integer> qt = new ArrayDeque<>();
		for(int i : edge.get(u)) {
			qt.offer(i);
			dt[i] = 1;
		}
		while(qt.size() > 0) {
			int x = qt.poll();
			for(int i : edge.get(x)) {
				if(dt[i] == -1) {
					dt[i] = dt[x] + 1;
					qt.offer(i);
				}
			}
		}
		int ans = 0;
		for(int i = 1; i <= N; i++) {
			if(da[i] > dt[i])
				ans = Math.max(ans, da[i]-1);
		}
		System.out.println(ans);

	}

}

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


int main() {
	int N;
	cin >> N;
	int A[N];
	int A_sort[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A_sort[i] = A[i];
	}
	sort(A_sort, A_sort + N);
	for (int i = 0; i < N; i++) {
		int ret;
		if (A[i] == A_sort[N-1]) ret = A_sort[N-2];
		else ret = A_sort[N-1];
		cout << ret << endl;
	}
}


Measured memory_bytes: 3200
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, H, W, a[500][500], x1[250000], y1[250000], x2[250000], y2[250000];
	cin >> H >> W;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
 
	for (i=0; i < H; i++) {
		for (j=0; j < W-1; j++) {
			if (a[i][j] % 2) {
				x1[k] = i; y1[k] = j; x2[k] = i; y2[k++] = j + 1;
				a[i][j]--; a[i][j + 1]++;
			}
		}
		if ((a[i][j] % 2)&&(i<H-1)) {
			x1[k] = i; y1[k] = j; x2[k] = i+1; y2[k++] = j;
			a[i][j]--; a[i + 1][j]++;
		}
	}
 
	cout << k << endl;
	for (i = 0; i < k; i++) {
		cout << x1[i]+1 << " " << y1[i]+1  << " " << x2[i]+1 << " " << y2[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n; cin >>n;
    vector<int>v(n);
    string ans = "APPROVED";
    for(int i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] % 2 == 0) {
            if(v[i] % 3 == 0 || v[i] % 5 == 0){
                ans = "APPROVED";
            }
            else{
                ans = "DENIED";
                break;
            }
        } else{
            continue;
        }
    }
    cout << ans << endl;
   return 0;
}


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

int main() {
    ll A,B;
    while (1) {
        cin >> A >> B;
        if(A == 0 && B == 0) break;
        if (A < B) {
            cout << A << " " << B << endl;
        } else {
            cout << B << " " << A << endl;
        }     
    }
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <math.h>
#define PI 3.14159265

int main(void){
	int a,b,C;
	double S,L,h,s_1,s_2,s_3,rad_1,rad_2,henn,c;

	scanf("%d %d %d",&a,&b,&C);

	rad_1=C*PI/180;
	s_1=sin(rad_1);
	S=(a*b*s_1)/2;
	s_2=cos(rad_1);
	henn=a*a+b*b-2*a*b*s_2;
	c=sqrt(henn);
	L=a+b+c;
	rad_2=(180-C)*PI/180;
	s_3=sin(rad_2);
	h=b*s_3;

	printf("%lf %lf %lf\n",S,L,h);

	return 0;
}

Measured memory_bytes: 660