akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

bool ok(vector<ll> v, ll t, ll a, ll b)
{
    cerr << t << "," << a << "," << b << endl;
    rep(i, v.size())
    {
        v[i] -= b * t;
    }

    sort(ALL(v), greater<ll>());
    ll ind = 0;
    ll diff = a - b;
    while (t > 0 && ind < v.size())
    {
        if (v[ind] <= 0)
        {
            ind++;
            continue;
        }
        ll cost = min(t, (v[ind] + diff - 1) / diff);
        v[ind] -= cost * diff;
        t -= cost;
    }
    sort(ALL(v), greater<ll>());

    return (v[0] <= 0);
}

int main(int argc, char const *argv[])
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h;
    rep(i, n)
    {
        ll t;
        cin >> t;
        h.push_back(t);
    }
    ll r = 2000000001ll;
    ll l = -1;
    while (l + 1 != r)
    {
        cerr << r << "," << l << endl;
        ll med = (r + l) / 2;
        if (ok(h, med, a, b))
        {
            cerr << "ok" << endl;
            r = med;
        }
        else
        {
            cerr << "ng" << endl;

            l = med;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1908
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n); std::cin>>a;

  std::vector<int> odd, even;
  rep(i,0,n) {
    (i%2==0 ? even : odd).emplace_back(i);
  }
  std::vector<int> ord;
  ord.insert(ord.end(), even.rbegin(), even.rend());
  ord.insert(ord.end(), odd.begin(), odd.end());
  if (ord.front() != n-1) {
    std::reverse(all(ord));
  }

  std::vector<int> ans(n);
  rep(i,0,n) {
    ans.at(i) = a.at(ord.at(i));
  }
  rep(i,0,n) {
    std::cout<<(0 < i ? " " : "") << ans.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 5612
#include <iostream>
#include <string>
using namespace std;
int S(int A, int B) { return A*B; }
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (S(A,B) <= S(C,D)) { cout << S(C,D); }
	else { cout << S(A,B); }
	return 0;
}

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

using namespace std;

int main(){
  const int M=1000000007;
  int N,W;
  cin>>N>>W;
  vector<int> v(N);
  for(auto &e:v){
    cin>>e;
  }
  sort(v.rbegin(),v.rend());
  vector<int> r(N);
  r.back()=v.back();
  for(int i=N-2;i>=0;i--){
    r[i]=r[i+1]+v[i];
  }
  int dp[10001]={1};
  for(int j=0;j<N;j++){
    for(int i=W;i-v[j]>=0;i--){
      dp[i]=(dp[i]+dp[i-v[j]])%M;
      if(i-v[j]+r[j]<=W){
	dp[i-v[j]]=0;
      }
    }
  }
  int s=0;
  for(auto e:dp){
    s=(s+e)%M;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1248
#include <cstdio>
#include <cmath>

int main()
{
	int n, a;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a);
		ans += (int)std::log2(a & (-a));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
int n,k,h[100005],f[100005];
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int abs(int x){return x>0?x:-x;}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);if(i>1)f[i]=f[i-1]+abs(h[i]-h[i-1]);
		for(int j=max(1,i-k);j<i;j++)
		 f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
	}printf("%d\n",f[n]);
}

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

#define int long long

int n,a[100005],b[100005],ans=0;

signed main()
{
	cin>>n;
	for(int i=1;i<=n+1;cin>>a[i++]);
	for(int i=1;i<=n;cin>>b[i++]);
	for(int i=1;i<=n;i++)
	{
		if(b[i]>=a[i])
		{
			ans += min(b[i],a[i]+a[i+1]);
			a[i+1] = max(a[0],a[i+1]-b[i]+a[i]);
		}
		else
			ans += b[i];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[n],s=0;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        while(a[i]%2==0)
            s++,a[i]/=2;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
/*  
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define rrep(i, j, n) for(int i = j; i >= n; i--)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';

void solve(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n){
    cin >> a[i];
  }
  int ans = 1e18;
  int low = 1, high = 1e9 + 10;
  while(low < high){
    int mid = (low + high) / 2;
    int cal = 0;
    rep(i, 0, n){
      cal += (a[i] - 1) / mid;
    }
    if(cal > k){
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  cout << high << " ";
}

int32_t main(){
  
  ios_base::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int tst = 1;
  // cin >> tst;
  while(tst--){
    solve();
  }
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    reverse(A.begin(),A.end());
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<A[i];
        }else{
            cout<<A[i]<<" ";
        }
    }
    cout<<endl;
}


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

ll P[100010],h[100010];
int X[100010],n,s,tt;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();s=rd();
	for (int i=1;i<=n;i++) X[i]=rd(),P[i]=rd();
	int id=0;
	for (int i=1;i<=n;i++) if (X[i]<s) id=i;
	int l=1,r=n;
	while (l<=id||r>id)
	{
		if (l>id) h[++tt]=X[r--];
		else if (r<=id) h[++tt]=X[l++];
		else if (P[l]>=P[r]) P[l]+=P[r],h[++tt]=X[r--];
		else P[r]+=P[l],h[++tt]=X[l++];
	}
	h[++tt]=s;
	ll ans=0;
	for (int i=1;i<tt;i++) ans+=abs(h[i+1]-h[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include <math.h>
#define N 100
int main(){
	double a[N]={0},b[N]={0},c[N]={0},d[N]={0},e[N]={0},f[N]={0};
	int tmp;
	for(tmp=0;scanf("%lf %lf %lf %lf %lf %lf",&a[tmp],&b[tmp],&c[tmp],&d[tmp],&e[tmp],&f[tmp])!=EOF;tmp++);
	
	int i,divisor=0;
	double x=0,y=0;
	for(i=0;i<tmp;i++){
		divisor=a[i]*e[i]-b[i]*d[i];
		x=(c[i]*e[i]-b[i]*f[i])/divisor;
		y=(a[i]*f[i]-c[i]*d[i])/divisor;
		if(fabs(x)==0){
			printf("%.3f %.3f\n",0.0,y);
		}else if(fabs(y)==0){
			printf("%.3f %.3f\n",x,0.0);
		}else{
			printf("%.3f %.3f\n",x,y);
		}
	}
	return 0;
}

Measured memory_bytes: 656
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strconv"
)

func main() {
	N := getStdinInt()
	X := getStdin()

	var cnt int64 = 0
	for i := 0; i < len(X); i++ {
		if X[i] == '1' {
			cnt++
		}
	}

	if cnt == 0 {
		for i := 0; i < N; i++ {
			fmt.Printf("%d\n", 1)
		}
		return
	} else if cnt == 1 {
		for i := 0; i < N; i++ {
			if X[i] == '0' {
				if i == N-1 || X[N-1] == '1' {
					// num % 2 なので下1桁が1の場合にはf(num)→f(1)→0
					fmt.Printf("%d\n", 2)
				} else {
					fmt.Printf("%d\n", 1)
				}
			} else {
				fmt.Printf("%d\n", 0)
			}
		}
		return
	}

	val0 := make(map[int]int64) // cnt - 1
	var sum0 int64 = 0          // cnt - 1
	val1 := make(map[int]int64) // cnt + 1
	var sum1 int64 = 0          // cnt + 1

	// 合計を先に求める
	for i := N - 1; i >= 0; i-- {
		if i == N-1 {
			val0[i] = 1
		} else {
			val0[i] = (2 * val0[i+1]) % (cnt - 1)
		}
		if X[i] == '1' {
			sum0 = modadd(sum0, val0[i], cnt-1)
		}
	}
	for i := N - 1; i >= 0; i-- {
		if i == N-1 {
			val1[i] = 1
		} else {
			val1[i] = 2 * val1[i+1] % (cnt + 1)
		}
		if X[i] == '1' {
			sum1 = modadd(sum1, val1[i], cnt+1)
		}
	}

	for i := 0; i < N; i++ {
		if X[i] == '0' {
			// X(i)分足す
			sum := modadd(sum1, val1[i], cnt+1)
			fmt.Printf("%d\n", pops(sum, cnt+1))
		} else {
			// X(i)分引く
			sum := modadd(sum0, -val0[i], cnt-1)
			fmt.Printf("%d\n", pops(sum, cnt-1))
		}
	}
}

// マイナスのmodに注意
func modadd(a, b, mod int64) int64 {
	var rtn int64 = 0
	if a+b < 0 {
		rtn = (a + b + mod) % mod
	} else {
		rtn = (a + b) % mod
	}
	return rtn
}

// f(num1)→f(num2)→...→0とする
func pops(num, mod int64) int64 {
	if mod == 1 {
		return 1
	}

	var ans int64 = 1
	for num != 0 {
		var cnt int64 = 0
		for i := 0; (1 << i) <= num; i++ {
			if num&(1<<i) != 0 {
				cnt++
			}
		}
		if cnt != 0 {
			num %= cnt
		}
		ans++
		if cnt == 0 {
			break
		}
	}
	return ans
}

func popcount(n uint64) int {
	return bits.OnesCount64(n)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 23336
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		char []c = sc.next().toCharArray();
		ArrayList <Integer> List = new ArrayList <Integer>();
		
		int cnt = 0;
		char now = '1';
		
		for(int i = 0 ; i < n ;i++) {
			if(now == c[i]) {
				cnt++;
			}
			else {
				List.add(cnt);
				now = (char)((now - '0' + 1) % 2 + '0');
				cnt = 1;
			}
		}
		
		List.add(cnt);
		
		if(List.size() % 2 == 0) {
			List.add(0);
		}
		int m = List.size();
	
		int [] sum = new int [m+1];
		
		for(int i = 0 ; i < m ; i++) {
			sum[i+1] = sum[i] + List.get(i);
		}
		
		
		int max = 0;
		int K = 2 * k + 1;
		
		for(int i = 0 ; i <= m ; i+=2) {
			int j = Math.min(i + K , m);
			//System.out.println(i+" "+j+" "+(sum[j] - sum[i]));
			max = Math.max(max, sum[j] - sum[i]);
		}
		
		System.out.println(max);
	}		
}




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

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

    int count = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if ((500*i)+(100*j)+(50*k) == X) count++;
            }
        }
    }
    cout << count << endl;
}

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

bool cmp(pair<pii,int> lhs, pair<pii,int> rhs) {
	return lhs.first.second < rhs.first.second;
}

struct ft {
	int n;
	vector<int> t;
	ft(int sz) {
		n = sz;
		t.resize(n+1);
	}
	void upd(int pos, int val) {
		++pos;
		while (pos<=n) {
			t[pos] += val;
			pos += pos&(-pos);
		}
	}
	int qry(int pos) {
		int ans = 0;
		while (pos) {
			ans += t[pos];
			pos -= pos&(-pos);
		}
		return ans;
	}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n, q;
	cin >> n >> q;
	int a[n];
	for (int i=0; i<n; i++) cin >> a[i];
	pair<pii,int> qry[q];
	for (int i=0; i<q; i++) {
		cin >> qry[i].first.first >> qry[i].first.second;
		--qry[i].first.first; --qry[i].first.second;
		qry[i].second = i;
	}
	sort(qry, qry+q, cmp);
//	for (auto x : qry) cout << x.first.first << ' ' << x.first.second << '\n';
	int last[n+1];
	memset(last, -1, sizeof(last));
	int idx = 0;
	ft fa(n);
	int ans[q];
	for (int i=0; i<n && idx<q; i++) {
		if (last[a[i]] != -1) fa.upd(last[a[i]], -1);
		last[a[i]] = i;
		fa.upd(i, 1);
		while (idx<q && qry[idx].first.second == i) {
			ans[qry[idx].second] = fa.qry(i+1) - fa.qry(qry[idx].first.first);
			idx++;
		}
	}
	for (int x : ans) cout << x << '\n';
}

Measured memory_bytes: 17396
#include <stdio.h>

int main() {
    int n, i, x;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        x = i;
        if (x % 3 == 0) {
            printf(" %d", i);
            continue;
        }
        do {
            if (x % 10 == 3) {
                printf(" %d", i);
                break;
            }
        } while (x /= 10);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100001] = {};
ll s[100001] = {};
ll t[100001] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] += s[i - 1] + a[i];
		t[i] = s[i];
	}

	ll total_p = 0;
	ll total_m = 0;

	ll cnt_o = 0;
	// odd positive
	repe(i, 1, n) {
		s[i] += total_p - total_m;

		if (!(i & 1)) {
			if (s[i] >= 0) {
				ll diff = s[i] + 1;
				total_m += diff;
				s[i] -= diff;
				cnt_o += diff;
			}
		}
		else {
			if (s[i] <= 0) {
				ll diff = 1 - s[i];
				total_p += diff;
				s[i] += diff;
				cnt_o += diff;
			}
		}
	}
	ll cnt_e = 0;
	total_p = 0;
	total_m = 0;
	// even positive
	repe(i, 1, n) {
		t[i] += total_p - total_m;

		if ((i & 1)) {
			if (t[i] >= 0) {
				ll diff = t[i] + 1;
				total_m += diff;
				t[i] -= diff;
				cnt_e += diff;
			}
		}
		else {
			if (t[i] <= 0) {
				ll diff = 1 - t[i];
				total_p += diff;
				t[i] += diff;
				cnt_e += diff;
			}
		}
	}
	cout << min(cnt_o, cnt_e) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> e(A.back()+1, 1);
    for (int i = 0; i < N; i++) {
        int a = A[i];
        
        if (e[a] == 0) continue;
        if (A[i+1] == a) e[a] = 0;
        
        int j = 2;
        while (j * a <= A.back()) {
            e[j*a] = 0;
            j += 1;
        }
    }
    
    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (e[A[i]] == 1) ret += 1;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 7524
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}
 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
 
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
const long long INF = 1LL<<60;
 
int N, K;
vector<long long> V;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> K) {
        V.resize(N);
        for (int i = 0; i < N; ++i) cin >> V[i];
 
        long long res = 0;
        for (int p = 0; p <= min(K, N); ++p) {
            for (int q = 0; p + q <= min(K, N); ++q) {
                vector<long long> v;
                long long cur = 0;
                for (int i = 0; i < p; ++i) v.push_back(V[i]), cur += V[i];
                for (int i = 0; i < q; ++i) v.push_back(V[N-1-i]), cur += V[N-1-i];
 
               
                sort(v.begin(), v.end());
 
                //cout << p << ", " << q << ": " << v << endl;
                for (int i = 0; i < min(K - p - q, (int)v.size()); ++i) {
                    if (v[i] < 0) cur -= v[i];
                }
                chmax(res, cur);
            }
        }
        cout << res << endl;
                
    }
}
 
 
 
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    
    int flag = 0;
    
    for(int i = 0; i < s.size()-1; i++){
        if(i < s.size()-2){
            if(s[i] == s[i+1]){
                cout << i+1 << " " << i+2 << endl;
                flag = 1;
                break;
            }else if(s[i] == s[i+2]){
                cout << i+1 << " " << i+3 << endl;
                flag = 1;
                break;
            }
        }else{
            if(s[i] == s[i+1]){
                flag = 1;
                cout << i+1 << " " << i+2 << endl;
                break;
            }
        }
    }
    
    if(!flag){
        cout << -1 << " " << -1 << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

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

    for (;;) {
        string s, t;
        cin >> s;
        if (s == ".") break;
        cin >> t;
        stringstream ss(s);
        string tmp;
        vector<string> vs, vt;
        stringstream st(t);
        while (getline(ss, tmp, '"')) vs.push_back(tmp);
        while (getline(st, tmp, '"')) vt.push_back(tmp);

        if (vs.size() != vt.size()) {
            cout << "DIFFERENT" << endl;
            continue;
        }

        int diffcnt = 0;
        string ans;
        REP(i, vs.size()) {
            if (vs[i] != vt[i]) {
                if (i & 1) {
                    if (++diffcnt > 1) {
                        ans = "DIFFERENT";
                    }
                } else {
                    ans = "DIFFERENT";
                }
            }
        }
        if (ans.size()) cout << ans << endl;
        else cout << (diffcnt ? "CLOSE" : "IDENTICAL") << endl;
    }

    return 0;

}



Measured memory_bytes: 3244
#include<stdio.h>
#include<string.h>

int main(void){
    int a,b,i;
    char op1[5],op2[]="?";
    for(i=0;i<100000;i++){
        scanf("%d %s %d",&a,op1,&b);
        if(strcmp(op1,op2)==0)  break;;
        switch(op1[0]){
            case '+': printf("%d\n",a + b); break;
            case '-': printf("%d\n",a - b); break;
            case '*': printf("%d\n",a * b); break;
            case '/': printf("%d\n",a / b); break;
            default: break;
        }
    }
    return 0;
}


Measured memory_bytes: 2132
import java.util.*;

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

	List<Integer> list = new ArrayList<Integer>();
	while(sc.hasNext()){
	    list.add(sc.nextInt());
	}

	for(int i=0; i<list.size(); i++){
	    if(list.get(i)==0){
		System.out.println(list.get(i-1));
		list.remove(i);
		list.remove(i-1);
		i = i-2;
	    }
	}
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n+1];
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    bool ans = true;
    for(int i = 2; i <= n; i++){
        if(h[i] > h[i-1]){
            h[i]--;
        } else if(h[i] == h[i-1]){
            continue;
        } else {
            ans = false;
            break;
        }
    }

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

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

int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	bool ans = true;
	cin>>n;
	int nums[200];
	for (int i = 0; i < n; i++) {
		cin>>nums[i];
		if (nums[i]%2 == 0 && (nums[i] % 5 != 0 && nums[i] % 3 != 0)) {
			ans = false;
		}
	}
	cout<<(ans?"APPROVED":"DENIED")<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    cout << max(max(A+B, A-B), A*B) << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from collections import deque
directions = ((-1, 0), (1, 0), (0, -1), (0, 1))


def main():
    H, W = map(int, readline().rstrip().split())
    mat = [list(readline().rstrip()) for _ in range(H)]

    start = []
    for h in range(H):
        for w in range(W):
            if mat[h][w] == '#':
                start.append((h, w))
    
    res = 0
    que = deque(start)
    while que:
        flg = False
        next_que = deque()
        while que:
            h, w = que.popleft()
            for dh, dw in directions:
                if not (0 <= h+dh < H and 0 <= w+dw < W):
                    continue
                if mat[h+dh][w+dw] == '#':
                    continue
                flg = True
                mat[h+dh][w+dw] = '#'
                next_que.append((h+dh, w+dw))

        if flg:
            res += 1
        que = next_que

    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 134224
import math
from collections import Counter
N, P = map(int, input().split())
if P == 1:
    print(1)
elif N == 1:
    print(P)
else:
    Eratosthenes = [p for p in range(2, math.ceil(P ** 0.5))]
    number = Eratosthenes[0]
    sosuu = []
    while number < P ** 0.25:
        sosuu.append(number)
        n_Eratosthenes = []
        for n in Eratosthenes:
            if n % number == 0:
                pass
            else:
                n_Eratosthenes.append(n)
        if len(n_Eratosthenes) == 0:
            break
        number = n_Eratosthenes[0]
        Eratosthenes = n_Eratosthenes
    numbers=sosuu+Eratosthenes
    suuji=0
    answers=[]
    while P>1 and suuji<len(numbers):
        number=numbers[suuji]
        if P%number==0:
            answers.append(number)
            P=P//number
        else:
            suuji+=1
    kotae=Counter(answers)
    answer=1
    for key,value in kotae.items():
        kazu=value//N
        if kazu==0:
            continue
        else:
            answer*=(key**kazu)
    print(answer)


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  auto g = vector<vector<int>>(n + 1, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        g[i][j] = 0;
      } else {
        g[i][j] = 1e9;
      }
    }
  }
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    g[a[i]][b[i]] = c[i];
    g[b[i]][a[i]] = c[i];
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    bool used = false;
    for (int j = 1; j <= n; j++) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) {
        used = true;
      }
    }
    if (!used) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct SegmentTree{
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;  while(n < sz) n *= 2;
        node.resize(2*n-1, 0);

        for(int i=0; i<sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = gcd(node[2*i+1], node[2*i+2]);
        }
    }

    void update(int k, int val){
        k += n - 1;
        node[k] = val;
        while(k > 0){
            k = (k - 1)/2;
            node[k] = gcd(node[2*k+1], node[2*k+2]);
        }
    }

    int query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        return gcd(vl, vr);
    }

    int gcd(int a, int b){
        if(b==0) return a;
        else return gcd(b, a%b);
    }

    private:
        int n;
        vector<int> node;
};



int main(){
    int N;  cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    SegmentTree seg(a);

    int ans = max(seg.query(1,N), seg.query(0,N-1));
    for(int i=1; i<N-1; i++){
        ans = max(ans, seg.gcd(seg.query(0, i), seg.query(i+1, N)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2048
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n;
    cin >> n;

    vvec<string> strs(9);
    strs[0].push_back("7");
    strs[0].push_back("5");
    strs[0].push_back("3");

    vec<string> str753{"7"s, "5"s, "3"s};

    for (int i = 0; i < strs.size() - 1; ++i)
    {
        for (auto s : strs[i])
        {
            for (auto s753 : str753)
            {
                strs[i + 1].push_back(s + s753);
            }
        }
    }

    int ans{};

    auto check = [](string s) {
        bool c3{}, c5{}, c7{};
        for (auto c : s)
        {
            switch (c)
            {
            case '3':
                c3 = true;
                break;
            case '5':
                c5 = true;
                break;
            case '7':
                c7 = true;
                break;
            default:
                break;
            }
        }
        return c3 && c5 && c7;
    };

    for (const auto &v : strs)
    {
        for (const auto s : v)
        {
            if (check(s) && stoi(s) <= n)
                ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

int n;


int main() {
    cin >> n;
    vector<int> a(n * 3);
    for(auto&& i : a) scanf("%d", &i);

    vector<ll> L(3 * n), R(3 * n);
    ll sum = 0;
    
    priority_queue<int, vector<int>, greater<int>> pq1;
    rep(i, 3 * n) {
        pq1.push(a[i]);
        sum += a[i];
        if(SZ(pq1) > n) {
            sum -= pq1.top();
            pq1.pop();
        }
        L[i] = sum;
    }

    priority_queue<int> pq2;
    sum = 0;
    for(int i = 3 * n - 1; i >= 0; i--) {
        pq2.push(a[i]);
        sum += a[i];
        if(SZ(pq2) > n) {
            sum -= pq2.top();
            pq2.pop();
        }
        R[i] = sum;
    }

    ll ans = -1145141919512810;
    FOR(i, n - 1, 2 * n) {
        ans = max(ans, L[i] - R[i + 1]);
    }

    OUT(ans);


    return 0;
}

Measured memory_bytes: 7288
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
	int  A,B,C;

//入力
     scanf("%d",&B);
     scanf("%d",&C);
     scanf("%d",&A);

     printf("%d %d %d",A,B,C);

     return 0;
}



Measured memory_bytes: 128
'use strict'

const main = (input) => {
    input = input.split(' ').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const X = input[2]
    const t = X - A
    if(t === 0 || 0 < t && t <= B){
        console.log('YES')
    }else{
        console.log('NO')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int ans = 0, n = s.size();
  rep(i,0,n){
    if (s[i] == '0')
      ans--;
    else
      ans++;
  }
  cout << n - abs(ans) << endl;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

char a[2][3];

int main()
{
    _upgrade
    for(int i = 0; i < 2; i++)
        for(int j = 0; j < 3; j++)
            cin >> a[i][j];
    bool ok = 1;
    for(int j = 0; j < 3; j++)
        if(a[0][j] != a[1][2 - j]) ok = 0;
    cout << (ok ? "YES" : "NO") << "\n";
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
s = stdin.readline().rstrip()
n = len(s)
dic = {}
dic[0] = 1
now = 0
mul = 1
for i in range(n-1,-1,-1):
    now = (now+(10*mul)*int(s[i]))%2019
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
    mul *= 10
    mul %= 2019
print(sum(dic[i]*(dic[i]-1)//2 for i in dic))

Measured memory_bytes: 9296
#include <iostream>
#include <string>
#include <vector>

using namespace std;

template<unsigned mod>
struct RollingHash {
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const {
        unsigned long long x = (unsigned long long) a * b;
        unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
        asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
        return m;
    }

    RollingHash(const string &s, unsigned base = 114547) {
        int sz = (int) s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; i++) {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
        }
    }

    unsigned get(int l, int r) const {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod) ret -= mod;
        return ret;
    }

    unsigned connect(unsigned h1, int h2, int h2len) const {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod) ret -= mod;
        return ret;
    }

    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return (low);
    }
};

using RH = RollingHash<1000000007>;

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

    RH rh(s);
    int ret = 0;
    for (int i = 0; i < n; i++) {
        int ok = 0;
        int ng = (n - i) / 2 + 1;

        while (ng - ok > 1) {
            int mid = ok + (ng - ok) / 2;

            int comp = rh.get(i, i + mid);
            bool found = false;
            for (int j = i + mid; j + mid <= n; j++) {
                if (rh.get(j, j + mid) == comp)found = true;
            }

            if (found)ok = mid;
            else ng = mid;
        }

        ret = max(ret, ok);
    }

    cout << ret << endl;
    return 0;
}

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

int q1,b,c1,c2,q2;

// ????´\?¶???????????????????x??¨??????
bool C(int x){
    if(x*c1 > b || x > q2)
        return false;

    return x + (b-x*c1)/c2 >= q1;
}

int main(){
    while(1){
        cin>>q1;
        if(!q1)break;
        cin>>b>>c1>>c2>>q2;

        int lb = 0, ub = 1e+9;
        for(int i=0;i<100;i++){
            int mid = (lb + ub) / 2;
            if(C(mid)) lb = mid;
            else ub = mid;
        }

        if(lb == 0)
            cout<<"NA"<<endl;
        else
            cout<<lb<<" "<<(b-lb*c1)/c2<<endl;
    }
    return 0;
}

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


double ans;

int main(){
	ll N;
	cin >> N;
	if(N%2==0){
		ans = (double)1/2;
	}else{
		ans = (double)((ll)(N/2)+1) / N;
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    char a[4];
    cin >> a;
    if(count(a,a+4,'a')==1 && count(a,a+4,'b')==1 && count(a,a+4,'c')==1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  double h,w,x,y;
  scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  if(x == w/2 && y == h/2){
    printf("%lf %d",w*h/2,1);
  }else{
    printf("%lf %d",w*h/2,0);
  }
}

Measured memory_bytes: 1716
#include <stdio.h>

int main(void) {

    int i = 0, ans = 0;
    int a, b, c;

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

    for (i = a; i <= b; i++) {
        if (c % i == 0) {
            ans++;
        }
    }

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

    return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define hell2        1000000009
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define sz(x)       (int)x.size()
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const ll INF=(1LL<<60)-1;
//v.resize(distance(v.begin(),unique(v.begin(),v.end())));
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){ 
		     int n; cin>>n;
		     if(n<1000 && n>=1) cout<<"ABC";
		     else cout<<"ABD";
	    cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int[] str;
	while(sc.hasNext()){
	    str = new int[10];

	    for(int i = 0; i < 10; i++)
		str[i] = sc.nextInt();

	    Arrays.sort(str);
	    for(int i = 1, l = str.length; i <= 3; i++)
		System.out.println(Integer.toString(str[l-i]));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 0
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include <math.h>
#include <iomanip>

using namespace std;
typedef long long llong;

static int fact(int n) {
  if (n == 1)
    return 1;
  return n * fact(n - 1);
}

void CAverageLength(std::istream& in, std::ostream& out) {
  int n;
  in >> n;

  vector<int> x, y;
  for (int i = 0; i < n; ++i) {
    int xx, yy;
    in >> xx >> yy;
    x.push_back(xx);
    y.push_back(yy);
  }

  double sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int dist_sq = (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
      sum += sqrt(dist_sq);
    }
  }
  out << setprecision(14) << 2 * sum / n << endl;
}

int main(int argc, char** argv) { CAverageLength(cin, cout); return 0; }


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 2e5 + 100;
ll A[N], F[N];
ll n, k;
template <typename _tp>
inline void read(_tp& x) {
    char ch = getchar(), sgn = 0;
    x = 0;
    while (ch ^ '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') ch = getchar(), sgn = 1;
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    if (sgn) x = -x;
}
bool cheak(ll x) {
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (x / F[i] < A[n - i + 1]) {
            cnt += A[n - i + 1] - (x / F[i]);
        }
        if(cnt>k)return false;
    }
    return cnt <= k;
}

int main() {
    read(n),read(k);
    for (int i = 1; i <= n; i++) {
        read(A[i]);
    }
    sort(A + 1, A + n + 1);
    ll maxx = -1;
    for (int i = 1; i <= n; i++) {
        read(F[i]);
        maxx = max(maxx, F[i] * A[n - i + 1]);
    }
    sort(F + 1, F + n + 1);
    ll l = 0, r = maxx;
    ll ans = 0;
    while (l <= r) {
        ll mid = l + r >> 1;
        if (cheak(mid))ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int Digits_Sum(int num) {
  if (num < 10) return num;
  return Digits_Sum(num / 10) + num % 10;
}

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

  int ans = 1000000;
  for (int A = 1; A < N; A++) {
    int B = N - A;
    ans = min(ans, Digits_Sum(A) + Digits_Sum(B));
  }

  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n ; ++i) {
        F[i] = F[i-1] + F[i-2];
    }
    
    cout << F[n] << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll a,b; cin >> a >> b;
    ll res;
    (a%(2*b+1)) ? res = a/(2*b+1) + 1 : res = a/(2*b+1);
    cout << res << endl; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int[] l = new int[n];
    for(int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }
    int ans = Integer.MAX_VALUE;
    for(int i = 0; i < (int)Math.pow(4, n); i++) {
      int ta = 0;
      int tb = 0;
      int tc = 0;
      int na = 0;
      int nb = 0;
      int nc = 0;
      int s = i;
      for(int j = 0; j < n; j++) {
        int d = s % 4;
        s /= 4;
        if(d == 1) {
          ta += l[j];
          na++;
        }
        if(d == 2) {
          tb += l[j];
          nb++;
        }
        if(d == 3) {
          tc += l[j];
          nc++;
        }
      }
      if((ta > 0) && (tb > 0) && (tc > 0)) {
        int t = Math.abs(a - ta) + Math.abs(b - tb) + Math.abs(c - tc) + 10 * (na - 1) + 10 * (nb - 1) + 10 * (nc - 1);
        ans = Math.min(ans, t);
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

#define ll long long

using namespace std;


vector<ll> operation(vector<ll> x){
    ll a=x[0];
    ll b=x[1];
    if (a%2 == 1){
        a -=1;
    }
    ll give = a/2;
    a -= give;
    b += give;
    vector<ll> re;
    re.push_back(a);
    re.push_back(b);
    return re;
}

vector<ll> operation2(vector<ll> x){
    ll a=x[0];
    ll b=x[1];
    if (b%2 == 1){
        b -=1;
    }
    ll give = b/2;
    b -= give;
    a += give;
    vector<ll> re;
    re.push_back(a);
    re.push_back(b);
    return re;
}


int main(int argc, char* argv[]){
  ll a,b,k;
  cin >> a>>b>>k;
  vector<ll> result;
  result.push_back(a);
  result.push_back(b);
  for(ll i=0;i<k;i++){
      if (i%2==0){
          result=operation(result);
      }else{
          result=operation2(result);
      }
  }
  cout << result[0]<<" " << result[1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        
        String a = "ABC";
        String b = "ARC";
        
        if (str.equals(a)){
            System.out.println(b);
        } else {
            System.out.println(a);
        }

   }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


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

using namespace std;

const auto INF = (int) 1e9;

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

    int f[101] = {};
    for (unsigned int i = 0; i < n; ++i) {
        for (unsigned int j = 0; j < 10; ++j) {
            int x;
            cin >> x;
            f[i] += (1U << j) * x;
        }
    }

    int p[101][11];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> p[i][j];
        }
    }

    int ans = -INF;
    for (unsigned int sched = 1; sched < (1U << 10); ++sched) {//営業予定ごと
        int sum = 0;
        for (int shop = 0; shop < n; ++shop) {//お店ごと
            int cnt = __builtin_popcount(sched & f[shop]);
            sum += p[shop][cnt];
        }
        ans = max(ans, sum);
    }

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

Measured memory_bytes: 256