akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
ans = 0
if n % 2 == 0:
  b = []
  for i in range(n//2):
    ans += a[2*i]
    b.append(a[2*i+1] - a[2*i])
  #print(b)
  for i in range(1,n//2)[::-1]:
    b[i-1] += b[i]
  #print(b)
  b.append(0)
  print(ans + max(b))
else:
  b = []
  c = []
  for i in range(n//2):
    ans += a[2*i]
    b.append(a[2*i+1] - a[2*i])
    c.append(a[2*i+2] - a[2*i+1])
  for i in range(1,n//2)[::-1]:
    b[i-1] += b[i]
    c[i-1] += c[i]
  #print(b)
  #print(c)
  d = c[:]
  d[-1] = max(d[-1],0)
  for i in range(1,n//2)[::-1]:
    d[i-1] = max(d[i-1],d[i],0)
  #print(d)
  e = []
  for i in range(n//2):
    e.append(b[i]+d[i])
  #print(ans)
  e.append(0)
  print(ans + max(e))

Measured memory_bytes: 105600
// Problem : C - Many Requirements
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 vi a,b,c;
 vl d;
int N,M,Q;
vi v;
ll mx=-1;
void calc(int lv,int level)
{
	if(level==N)
	{
		ll ans=0;
		F0R(x,Q)
		{
			if(v[b[x]]-v[a[x]]==c[x])
				ans+=d[x];
			// if(v[0]==1 && v[1]==3 && v[2]==4)
			// {
				// bug(v[a[x]]-v[b[x]]);
				// bug(c[x]);
			// }
		}
		ckmax(mx,ans);
		return;
	}
	FOR(x,lv,M+1)
	{
		v[level]=x;
		calc(x,level+1);
	}
}
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>N>>M>>Q;
	F0R(x,Q)
	{
		int n1,n2,n3,n4;
		cin>>n1>>n2>>n3>>n4;
		a.pb(n1-1),b.pb(n2-1),c.pb(n3),d.pb(n4),v.pb(0);
	}
	calc(1,0);
	cout<<mx;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3668
n,m = map(int, input().split())
a = [int(input()) for i in range(m)]
p = (10**9)+ 7
a.append(n+1)
memo = [0,1,1]
for i in range(2,n+10):
    memo.append((memo[i-1]+memo[i])%p)

ans = 1
clist = []
for i in range(len(a)):
    if i == 0:
        cnt = a[0]+1
        clist.append(cnt)
    else:
        cnt = a[i]-a[i-1]
        clist.append(cnt)
    if cnt == 1:
        ans = ans * 0
        break
    
    ans = (ans * memo[cnt-1]) % p
print(ans)

Measured memory_bytes: 11048
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n; scanf("%d", &n); std::vector<int> p(n), q(n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);
	for(int i = 0; i < n; i++) scanf("%d", &q[i]);

	std::vector<int> vec;
	int X = -1, Y = -1, now = 1;
	auto cnt = [&](auto&& cnt, int sz) -> void {
		if(sz == n) {
			if(vec == p) X = now;
			if(vec == q) Y = now;
			now++;
			return;
		}

		std::vector<bool> used(10, 0);
		for(int i = 0; i < sz; i++) used[vec[i]] = true;
		for(int i = 1; i <= n; i++) {
			if(used[i]) continue;

			vec.push_back(i);
			cnt(cnt, sz + 1);
			vec.pop_back();
		}
	};
	cnt(cnt, 0);

	printf("%d\n", std::abs(X - Y));
	return 0;
}


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);

int main() {
    fastio;

    const ll maxV = 1000000000000000000;
    int n;
    cin >> n;

    ll x;
    cin >> x;
    bool isZ = false;
    FOR(i, 1, n) {
        ll y;
        cin >> y;
        if (y == 0) {
            isZ = true;
            break;
        }
        if (y <= maxV/x) {
            x *= y;
        } else {
            x = -1;
        }
    }
    if (isZ) {
        cout << 0 << "\n";
    } else {
        if (x >= 0) {
            cout << x << "\n";
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
	int a = 0;
	int b = 0;
        int i;
	for(i=0; i<7; i++)
	{
		scanf("%d", &a);
		scanf("%d", &b);

		if(a > b) {
			printf("%d\n", a-b);

		} else {
			printf("%d\n", b-a);
		}

	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int d[10][10];
int E, V;
void warshall_floyd(int n) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}


int main() {
	int n = 10;
	int H, W;
	cin >> H >> W;
	int A[200][200];
	for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 10; j++) {
			cin >> d[i][j];
		}
	}
	warshall_floyd(10);
	int ans = 0;
	for(int i = 0; i < W; i++) {
		for(int j = 0; j < H; j++) {
			int tmp;
			cin >> tmp;
			if(abs(tmp) != 1) {
				ans += d[tmp][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >>b;
    vector<int> kud(a);
    for(int i=0;i<a;i++){
        cin >> kud.at(i);
    }
    sort(kud.begin(),kud.end());
    c = 0;
    for(int i=0;i<b;i++){
        c += kud.at(i);
    }
    cout << c;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
  vector<int> time(5);
  int diff_max = 0, sum = 0, max_index, add_value;
  for (int i = 0; i < 5; ++i)
  {
    cin >> time[i];

    int a = 10;
    while (a < time[i]) a += 10;

    if (diff_max <= a - time[i])
    {
      diff_max = a - time[i];
      max_index = i;
      add_value = a;
    }
    sum += a;
  }
  sum += time[max_index] - add_value;
  cout << sum << endl;
}

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

int main() {
  int n, m;
  long long a[1000 + 1];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];

  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }

  int match = 0;
  for (int i = 0; i < n; i++) {
    //if (a[i] >= t) match++;
    if (a[i] * 4 * m >= sum) match++;
  }

  cout << (match >= m ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    long N,border;
    double probability=1,allP=0;
    scanf("%ld %ld",&N,&border);
    long i,j;
    //printf("N:%ld\n",N);
    double a=N;
    //printf("a:%f\n",a);
    for(i=1;i<=N;i++){
        if(border<=i){
            allP+=(1.0/a)*(N+1-i);
            break;
        }
        j=i;
        probability=1.0/a;
        //printf("(%lf)",probability);
        while(j<border){
            j=j<<1;
            //printf("%ld:",j);
            probability/=2;
        }
        //printf("(%lf)",probability);
        allP+=probability;
        //printf("\n");
    }
    printf("%.12lf",allP);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((b - a) == (c - b))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a, b;
    int s = 1; 
    for (int i=0; i<n; i++) {
        a = s * 2;
        b = s + k;
        if (a > b) {
            s = b;
        } else {
            s = a;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int flg[1000000];
int main(void)
{
	int k,n,cnt,f,i;
	scanf("%d",&k);
	for(i=0;i<k;i++)	flg[i]=0;
	n=0;
	cnt=0;
	f=0;
	while(1)	{
		n=n*10+7;
		cnt++;
		if(n%k==0)	{
			f=1;
			break;
		}
		n=n%k;
		if(flg[n]==1)	break;
		flg[n]=1;
	}
	if(f==1)	printf("%d\n",cnt);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  sort(A.begin(), A.end());

  vector <ll> sum(N);
  for (int i = 0; i < N; i++){
    if (i == 0) sum[i] = A[i];
    else sum[i] = A[i] + sum[i - 1];
  }

  int stop = 0;
  for (int i = 0; i < N - 1; i++){
    if (sum[i] * 2 < A[i + 1]){
      stop = i + 1;
    }
  }
  
  cout << N - stop << endl;
  
  

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct UnionFind{
    vector<long long> par;
    vector<long long> siz;
    //Constractor
    UnionFind(long long sz_) : par(sz_),siz(sz_,1LL){
        for(long long i = 0;i < sz_;i++)par[i] = i;
    }
    void init(long long sz_){
        par.resize(sz_);
        siz.resize(sz_);
        for(long long i = 0;i < sz_;i++)par[i] = i;
    }
    //MemberFunc
    long long find(long long x){
        while(par[x] != x)x = par[x] = par[par[x]];
        return x;
    }
    void unite(long long x, long long y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(siz[x] < siz[y])swap(x,y);
        siz[x] += siz[y];
        par[y] = x;
    }
    bool same(long long x, long long y){
        return find(x) == find(y);
    }
    long long size(long long x){
        return siz[find(x)];
    }
};

//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;

    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        uf.unite(a - 1, b - 1);
    }
    set<ll> st;
    ll mi = n;
    ll ma = 0;
    rep(i, n) {
        if(st.find(uf.find(i)) == st.end()){
            st.insert(uf.find(i));
            mi = min(mi, uf.size(i));
            ma = max(ma, uf.size(i));
        }
    }
    cout << ma << "\n";
    return 0;
}

Measured memory_bytes: 15536
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;

void warshall_floyd(vector<vector<int>>& G, ll n){
  for (int k = 0; k < n; ++k){      //経由する頂点
    for (int i = 0; i < n; ++i){    //始点
      for (int j = 0; j < n; ++j){  //終点
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}
bool is_minus_cycle(vector<vector<int>>& G, ll n){
  for (int k = 0; k < n; ++k){
    for (int i = 0; i < n; ++i){
      for (int j = 0; j < n; ++j){
        if (G[i][j] > G[i][k] + G[k][j]) return true;
      }
    }
  }
  return false;
}

int main(){
  int H, W; cin >> H >> W;

  vector<vector<int>> G(10, vector<int>(10, INF));
  rep(i, 10) G[i][i] = 0;
  for (int i = 0; i < 10; ++i){
    for (int j = 0; j < 10; ++j){
      int cost; cin >> cost;
      G[i][j] = min(G[i][j], cost);
    }
  }

  warshall_floyd(G, 10);

  map<int, int> num;
  rep(i, 10) num[i] = 0;
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      int n; cin >> n;
      num[n] += 1;
    }
  }

  int res = 0;
  for (int i = 0; i < 10; ++i){
    res += G[i][1] * num[i];
  }
  cout << res << endl;
}


Measured memory_bytes: 256
s = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
for i in range(len(s)):
    if i%2 == 0:
        if s[i] in odd:
            continue
        else:
            print("No")
            break
    elif i%2 == 1:
        if s[i] in even:
            continue
        else:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int a,b;
int main(){
	a=read(),b=read();
	printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 3724
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int mod = 1000000007;
    int[] idx = new int[200000];
    Arrays.fill(idx,-1);
    int before = -1;
    long[] dp = new long[n+1];
    dp[0]=1;
    for(int i=0;i<n;i++){
      int c = sc.nextInt()-1;
      if(idx[c]==-1)dp[i+1]=dp[i];
      else{
        if(before!=c)dp[i+1]=(dp[i]+dp[idx[c]])%mod;
        else dp[i+1]=dp[i];
      }
      before=c;
      idx[c]=i+1;
    }
    System.out.println(dp[n]);
  }
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=1e5+5;
const int INF=1e9;
const int MOD=1e9+5;

int n,k;
int cost[M],h[M];

int dp(int x){
  if (x == 1) return 0;
  if (x < 1) return INF;
  if (cost[x] != -1) return cost[x];
  cost[x] = 1e9;
  fp(i,1,k+1)
    if (x-i > 0) cost[x] = min(cost[x] , dp(x-i) + abs(h[x] - h[x-i]));
  return cost[x];
}

int main(){

	fastio;
  cin >> n >> k;
  fp(i,1,n+1) cin >> h[i];
  fp(i,0,n+1) cost[i] = -1;
  dp(n);
  cout << cost[n] << "\n";

	return 0;
}


Measured memory_bytes: 10628
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n, q, time, i;
		queue que = new queue();
		
		n = sc.nextInt();
		q = sc.nextInt();
		
		for(i = 0; i < n; i++){
			String name = new String(sc.next());
			time = sc.nextInt();
			
			que.enqueue(name, time);
		}
		
		que.simulate(q);
	}
}

class data{
	String name;
	int time;
	
	data(String name, int time){
		this.name = name;
		this.time = time;
	}
}

class queue{
	ArrayList<data> Q;
	int head, tail;
	
	queue(){
		Q = new ArrayList<data>();
		head = tail = 0;
	}
	
	void enqueue(String name, int time){
		data process = new data(name, time);
		
		Q.add(process);
		tail ++;
	}
	
	data dequeue(){
		data process = Q.get(head);
		
		head ++;
		
		return process;
	}
	
	boolean isEmpty(){
		if(head == tail){
			return true;
		}
		else{
			return false;
		}
	}
	
	void simulate(int q){
		int sum = 0, cnt = 0, t;
		ArrayList<data> finish = new ArrayList<data>();
		
		while(!isEmpty()){
			data temp = dequeue();
			if(temp.time <= q){
				sum += temp.time;
				temp.time = sum;
				finish.add(temp);
				
				cnt ++;
			}
			else{
				sum += q;
				enqueue(temp.name, temp.time - q);
			}
		}
		
		for(int i = 0; i < cnt; i++){
			System.out.println(finish.get(i).name.toString() + " " + finish.get(i).time);
		}
	}
}

Measured memory_bytes: 88736
using System;
class Program
{
	static void Main(string[] args)
	{
		string t = Console.ReadLine();
		int N = int.Parse(t);
		string S = Console.ReadLine();
		string A = "EW";
		int [] B = new int[2];
		int [] C = new int[2];
		for(var i=0;i<S.Length;i++){
			B[A.IndexOf(S.Substring(i,1))] += 1;
		}
		int countmin = N;
		for(var i=0;i<S.Length;i++){
			B[A.IndexOf(S.Substring(i,1))] -= 1;
			if(i > 0){
				C[A.IndexOf(S.Substring(i-1,1))] += 1;
			}
			int count = B[0] + C[1];
			countmin = Math.Min(countmin,count);
		}
		Console.WriteLine(countmin);
	}
}

Measured memory_bytes: 18652
H, W, A, B = map(int, input().split())
ans = [[0] * W for i in range(H)]
for i in range(A):
	for j in range(B):
		ans[j][i] = 1
i = A
while i < W:
	j = B
	while j < H:
		ans[j][i] = 1
		j += 1
	i += 1
for i in ans:
	for j in i:
		print(j, end='')
	print()

Measured memory_bytes: 13300
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T;
    cin >> S;
    cin >> T;

    int ans = 0;

    for (int s = 0; s + T.size() <= S.size(); s++) {
        int count = 0;
        FOR(t, T.size()) {
            if (S[s + t] == T[t]) {
                count++;
            }
        }

        if (ans < count) {
            ans = count;
        }
    }

    cout << T.size() - ans << endl;

    return 0;
}


Measured memory_bytes: 3616
// Example program
#include <iostream>
using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    while(H > 0 && W > 0){
        for ( int i = 1; i <= H; i++){
            for ( int j = 1; j <= W; j++){
                if(i == 1 || i == H || j == 1 || j == W){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            
            cout << endl;
        }
        cout << endl;
        cin >> H >> W ;
    }    
    
    
    
    
    
    return 0;		 
}



Measured memory_bytes: 3056
import java.util.Scanner;

/**
 * Created by kazuki on 2014/07/04.
 */
public class Main{
   static Scanner s = new Scanner(System.in);

    public static void main(String[] args) {
        int e,x,y,z;
        int tmp,min;

        while(true){
            e = s.nextInt();
            min=e;

            if(e==0) break;

            for(z=0;z*z*z<=e;z++){
                tmp=e-z*z*z;
                for (y=0;y*y<=tmp;y++){
                    x=tmp-y*y;
                    if(min>x+y+z) min=x+y+z;
                }
            }

            System.out.println(min);
        }


    }
}

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

using namespace std;



void solver() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for(int &x : a) cin >> x;
    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i < k; ++i) sum += a[i];
    cout << sum << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

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

int main(){
  	string s1,s2;
  	cin >> s1 >> s2;
  
  	rep(i,0,s1.size()){
      cout << s1[i];
      if(i < s2.size()){
		cout << s2[i];
      }
    }
  	cout << endl;
  	return 0;
}

Measured memory_bytes: 256
import math

n,l = list(map(int, input().split()))

apple = [l+i for i in range(n)]

if(n+l-1<0):
    print(sum(apple)-apple[-1])
elif(l<=0 and n+l-1>=0):
    print(sum(apple))
else:
    print(sum(apple)-apple[0])

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;


int graph[10][10] = {};

int main() {

	int h, w;
	cin >> h >> w;
	
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> graph[i][j];

	for (int i = 0; i < 10; i++) {//中間点
		for (int j = 0; j < 10; j++) {//出発点
			for (int k = 0; k < 10; k++) {//終点
				if (graph[j][i] + graph[i][k] < graph[j][k]) {
					graph[j][k] = graph[j][i] + graph[i][k];
				}
			}
		}
	}

	int answer = 0;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int t;
			cin >> t;
			if (t != -1)
				answer += graph[t][1];
		}
	}

	cout << answer << endl;

	return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    int A,B;
    string S;
    cin >> A >> B;
    cin >> S;
    
    bool flg = true;
    REP(i,A+B+1){
        if ( i == A ){
            if ( S[i] != '-' ) flg = false;
        } else {
            int x = S[i] - '0';
            if ( x < 0 or x > 9 ) flg = false;
        }
    }
    
    if ( flg ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a;i<=b;++i)
#define UF(i,a,b) for(register int i=a;i>=b;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
typedef unsigned long long ull;
inline int r(int &x)
{
    int f=1;x=0;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
    return x*=f;
}
inline ll r(ll &x)
{
    ll f=1ll;x=0ll;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1ll;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ll)(c-'0');
    return x*=f;
}
inline ull r(ull &x)
{
    x=0ull;
    char c=getchar();
    for(;!isdigit(c);c=getchar());
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ull)(c-'0');
    return x;
}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define mp(a,b) make_pair(a,b)
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int prime_have[10];
int prime_num[10];
int primes=0;
ll ni[100020];
int nownum=0;
const ll mod=1000000007ll;
ll qp(ll a,ll b)
{
	if(b==1ll) return a;
	ll w=qp(a,b/2);
	if(b&1) return ((w*w)%mod)*a%mod;
	else return (w*w)%mod;
}
ll _ni(ll a){return qp(a,mod-2);}
void prework()
{
	ni[0]=1;
	ll a=1;
	F(i,1,100010)
	{
		a=a*i%mod;
		ni[i]=_ni(a);
	}
	return;
}
int m,n;
void solve()
{
	F(i,2,100000)
	{
		nownum=0;
		while(m%i==0) {m/=i;++nownum;}
		if(nownum!=0) {prime_have[++primes]=i;prime_num[primes]=nownum;}
	}
	if(m!=1) {prime_have[++primes]=m;prime_num[primes]=1;}
	//F(i,1,primes) printf("%d,%d\n",prime_have[i],prime_num[i]);
	ll ans=1;
	F(i,1,primes)
	{
		F(j,1,n-1) ans=ans*(prime_num[i]+j)%mod;
		ans=ans*ni[n-1]%mod;
	}
	printf("%lld\n",ans);
	return;
}
int main()
{
	prework();
	r(n),r(m);
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int a[N], num[N], win[N], n;
vector<int> gr[N], v;
void getAns() {
	for (int i = 0; i < v.size(); i++) {
		int u = v[i], z = 0;
		for (auto x : gr[u]) {
			if (a[x] != a[u] && win[x] == -1)
				z = 1;
		}
		if (z == 1)
			win[u] = 1;
		else
			win[u] = -1;
	}
	for (int i = 0; i < v.size(); i++) {
		int u = v[i];
		if (win[u] == -1) {
			for (auto x : gr[u]) {
				if (a[x] != a[u])
					win[x] = 1;
			}
		}
	}
	return;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
			cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	iota(num, num + n, 0);
	sort(num, num + n, [] (int x, int y) { return a[x] < a[y]; });
	v.push_back(num[0]);
	for (int i = 1; i < n; i++) {
		if (a[num[i]] != a[num[i - 1]]) {
			getAns();
			v.clear();
		}
		v.push_back(num[i]);
	}
	getAns();
	for (int i = 0; i < n; i++) {
		if (win[i] == 1)
			cout << i + 1 << " ";
	}
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;++i) cin >> a[i];
    if (N==2){cout << -1 << '\n'; return 0;}
    vector<int> deg(N,0),used(N,0),ans(N,-1);
    for (int i=0;i<N;++i) ++deg[--a[i]];
    set<pair<int,int>> s;
    priority_queue<int,vector<int>,greater<int>> skipped;
    for (int i=0;i<N;++i) s.emplace(-deg[i],i);
    for (int i=0,now=0;i<N-3;++i){
        auto p=*s.begin();
        if (-p.first==N-1-i){
            ans[i]=p.second;
        } else if (!i){
            ans[i]=0;
        } else {
            if (!skipped.empty()){
                int x=skipped.top(); skipped.pop();
                if (a[ans[i-1]]!=x) ans[i]=x;
                else if (!skipped.empty()){
                    ans[i]=skipped.top();
                    skipped.pop(); skipped.emplace(x);
                } else skipped.emplace(x);
            }
            if (ans[i]<0){
                while(used[now]) ++now;
                if (a[ans[i-1]]==now) skipped.emplace(now++);
                while(used[now]) ++now;
                ans[i]=now;
            }
        }
        used[ans[i]]=1;
        s.erase({-deg[ans[i]],ans[i]});
        int nxt=a[ans[i]];
        if (used[nxt]) continue;
        s.erase({-deg[nxt],nxt});
        --deg[nxt];
        s.emplace(-deg[nxt],nxt);
    }
    vector<int> unused,res(3,N);
    for (int i=0;i<N;++i) if (!used[i]) unused.emplace_back(i);
    vector<int> perm(3);
    iota(perm.begin(),perm.end(),0);
    do {
        vector<int> cnt(3);
        for (int i=0;i<3;++i) cnt[i]=unused[perm[i]];
        if (N>3&&a[ans[N-4]]==cnt[0]) continue;
        if (a[cnt[0]]==cnt[1]) continue;
        if (a[cnt[1]]==cnt[2]) continue;
        res=min(res,cnt);
    } while(next_permutation(perm.begin(),perm.end()));
    for (int i=0;i<3;++i) ans[N-3+i]=res[i];
    for (int i=0;i<N;++i) cout << ans[i]+1 << (i+1==N?'\n':' ');
}

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

int main(void){
  int n;
  cin>>n;
  int ans=0;
  rep(i, n) {
    int a;
    cin>>a;
    ans+=(a-1);
  }
  cout<<ans<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
int main()
{
    double a,b,c;
    scanf("%lf%lf%lf",&a,&b,&c);
    double d=c/(a*a);

    if(b==d)
    {
        printf("%.9lf\n",0.0);
        return 0;
    }

    double y=b-d;

    double z=(a+d)-y;

    if(z>a) b-=(z-a);

    else
    {
        a*=d;
        a+=a;
        a/=b;
    }

    c=sqrt((a*a)+(b*b));

    double w=b*b;
    w/=(c*b);

    double xx=90.0;

    printf("%.9lf\n",xx-((acos(w)*180.0)/pi));

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    fenwick_tree<ll> bit(n);
    for(int i=0; i<n; i++){
        ll a; scanf("%lld", &a);
        bit.add(i, a);
    }
    while(q--){
        int t;
        scanf("%d", &t);
        if(t==0){
            int p; ll x;
            scanf("%d %lld", &p, &x);
            bit.add(p, x);
        }else{
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", bit.sum(l, r));
        }
    }
    return 0;
}

Measured memory_bytes: 8232
from functools import lru_cache

@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

n,p = map(int,input().split())
even = 0
odd = 0
ans = 0
for i in map(int,input().split()):
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
if p == 0:
    eveng = 0
    for j in range(0,odd+1,2):
        if j > odd:
            break
        eveng += kaijou(odd)/kaijou(odd-j)/kaijou(j)
    ans = int((2**even)*eveng)
else:
    oddg = 0
    #print(odd)
    for j in range(1,odd+1,2):
        if j > odd:
            break
        oddg += kaijou(odd)/kaijou(odd-j)/kaijou(j)
    ans = int((2**even)*oddg)
print(ans)

Measured memory_bytes: 3572
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <pii> Ve;
vector <int> conn[100050];
int deg[100050];
char col[100050];
bool chk[100050];

bool dchk[100050];
int dis[100050];
void DFS(int n) {
	dchk[n] = true;
	dis[n] += (int)(col[n] == 'W') * 2;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		dis[it] = dis[n];
		DFS(it);
	}
}
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		Ve.emplace_back(t1, t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
		deg[t1]++;
		deg[t2]++;
	}
	scanf("%s", col + 1);
	if (N == 1) {
		if (col[1] == 'B') printf("0\n");
		if (col[1] == 'W') printf("1\n");
		return 0;
	}

	vector <int> Vu;
	for (i = 1; i <= N; i++) if (col[i] == 'B' && deg[i] == 1) Vu.push_back(i);
	for (i = 0; i < Vu.size(); i++) {
		int t = Vu[i];
		chk[t] = true;
		for (auto it : conn[t]) {
			deg[it]--;
			if (col[it] == 'B' && deg[it] == 1) Vu.push_back(it);
		}
	}
	if (Vu.size() == N) return !printf("0\n");
	if (Vu.size() + 1 == N) return !printf("1\n");

	for (i = 1; i <= N; i++) conn[i].clear();
	Vu.clear();

	int ans = 0;
	for (auto it : Ve) {
		int t1 = it.first, t2 = it.second;
		if (chk[t1] || chk[t2]) continue;
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
		ans += 2;
	}

	for (i = 1; i <= N; i++) {
		if (chk[i]) continue;
		if (conn[i].size() % 2) col[i] ^= 'B' ^ 'W';
		if (col[i] == 'W') ans++;
	}

	for (i = 1; i <= N; i++) if (!chk[i]) break;
	int r = i;
	DFS(r);
	for (i = 1; i <= N; i++) if (!chk[i] && dis[i] > dis[r]) r = i;
	memset(dis, 0, sizeof(dis));
	memset(dchk, 0, sizeof(dchk));
	DFS(r);
	for (i = 1; i <= N; i++) if (!chk[i] && dis[i] > dis[r]) r = i;

	return !printf("%d\n", ans - dis[r]);
}

Measured memory_bytes: 10612
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

def waru(N):
    ans = 0
    while(True):
        if N % 2 == 0:
            ans += 1
            N = N // 2
        else:

            return ans

n = getN()
nums = getList()

ans = 2000000000
for num in nums:
    d = waru(num)
    if d < ans:
        ans = d

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++) // ex)REP(i,10) i=0~i=9
#define REPR(i, n) for(int i = n;i >= 0;i--) // ex)REPR(i,10) i=10~i=0
#define FOR(i, m, n) for(int i = m;i < n;i++) //ex)FOR(i,3,10) i=3~i=9
#define FORR(i, m, n) for(int i = m;i >= n;i--) 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end()); //
#define llong long long //64bitに拡張
#define pb(a) push_back(a)　
#define INF 999999999 //大きな値
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//座標上を探索
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
llong N;
llong A[100000];
llong B[100000];
llong count[100000] = {0};
llong sum = 0;
llong tmp = 0; 
cin >> N;
REP(i,N){
	cin >> A[i] >> B[i];
}
REPR(j,N-1){
	A[j] = sum + A[j]; 
if( A[j] % B[j] == 0){ 
	count[j] = 0;
}else{
count[j] = B[j] - (A[j] % B[j]) ;
sum = sum + count[j];
}
}
cout << sum << endl;
return 0;
}


Measured memory_bytes: 1920
cnt = 0
def InsertionSort(A, n, g):
    global cnt

    for i in range(g, n):
        v = A[i]
        j = i - g

        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        
        A[j + g] = v

def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G

def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

    print(len(G))
    print(*G)
    print(cnt)
    print("\n".join(map(str, A)))

Main()


Measured memory_bytes: 125976
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
#define ll 		 long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 	 1000000007
#define MOD      998244353
#define mp       make_pair
#define pb       push_back
#define F        first
#define S        second
#define t()      ll test;cin>>test;while(test--)
#define ii       pair<int,int>
#define endl     "\n"
#define que_max  priority_queue <int>
#define IOS      ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef tree < int ,  null_type ,  greater <int> ,  rb_tree_tag ,  tree_order_statistics_node_update > pbds;

int pw(int b, int p) { int r = 1; while (p > 0) { if (p & 1) r = r * b;
        p = p >> 1; b = b * b; } return r; }


ll n;
vector <ll> arr(1e5);
vector <ll> dp(1e5 , -1);

ll solve(ll id)
{
	if(id == n-1)
		return 0;

	if(dp[id]!=-1)
	{
		return dp[id];
	}
	ll ans = abs(arr[id+1]-arr[id]) + solve(id+1);

	if(id+2<n)
	{
		ans = min(ans , abs(arr[id+2]-arr[id]) + solve(id+2));
	}
		return dp[id] = ans;
}
int main()
{
	cin>>n;

	arr.resize(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<solve(0)<<endl;
}


Measured memory_bytes: 7964
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var list = nextCharArray();
	var N = list.length;
	var output = new Array(N).fill(0);
	var count = 0;
	for(var i = 0; i < N - 1; i++){
		if(list[i] == "R"){
			count++;
			if(list[i + 1] == "L"){
				output[i] = count;
				count = 0;
			}
		}
	}
	count = 0;
	for(var i = N - 1; i > 0; i--){
		if(list[i] == "L"){
			count++;
			if(list[i - 1] == "R"){
				output[i] = count;
				count = 0;
			}
		}
	}
	myerr(output);
	for(var i = 0; i < N - 1; i++){
		if(list[i] == "R" && list[i + 1] == "L"){
			if(output[i] % 2 == (output[i + 1]) % 2){
				var avg = (output[i] + output[i + 1]) / 2;
				output[i] = avg;
				output[i + 1] = avg;
			}else{
				var avg = Math.floor((output[i] + output[i + 1]) / 2);
				if(output[i] % 2 == 1){
					output[i] = avg + 1;
					output[i + 1] = avg;
				}else{
					output[i] = avg;
					output[i + 1] = avg + 1;
				}
			}
		}
	}
	myout(myconv(output,8));
}

Measured memory_bytes: 35312
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple {
    private int a, b, c;
    void Solve() {
        //input
        a = io.Int;
        b = io.Int;
        c = io.Int;
        //cal
        var ans = new int[] {a, b, c}.OrderBy(a => a).Take(2).Sum();
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 13652
#include <iostream>
#include <cstdlib>

using namespace std;

typedef long long LL;
const LL MOD = 1e9+7;
const int maxn = 111111;
LL f[maxn];

int main()
{
	f[0] = f[1] = 1;
	for(int i=2;i<maxn;i++)f[i] = (f[i-1] * i) % MOD;
	int a, b;
	cin>>a>>b;
	if(abs(a-b)>1){cout<<0;return 0;}
	if(abs(a-b)==1)
	{
		cout<<(f[a]*f[b]) % MOD;
	}
	else
	{
		cout<<(2ll * f[a] * f[b]) % MOD;
	}
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARC072
{
    public class D
    {
        private const string Alice = "Alice";
        private const string Brown = "Brown";

        private const int TestMax = 100;
        private bool?[,] winMemo = new bool?[TestMax, TestMax];

        private bool Win(long X, long Y)
        {
            var max = Math.Max(X, Y);
            var min = Math.Min(X, Y);

#if true
            if (max <= 1) { return false; }

            return max - min > 1 ? true : false;
#else
            if (max <= 1) { return (winMemo[max, min] = false).Value; }

            if (winMemo[max, min].HasValue) { return winMemo[max, min].Value; }

            bool winAny = false;
            for (int i = 2; i <= max; i += 2)
            {
                winAny |= !Win(max - i, min + i / 2);
            }
            for (int i = 2; i <= min; i += 2)
            {
                winAny |= !Win(max + i / 2, min - i);
            }
            winMemo[max, min] = winAny;
            return winAny;
#endif
        }

        private void Run()
        {
            for (int i = 0; i < TestMax / 2; ++i)
            {
                for (int j = 0; j < TestMax / 2; ++j)
                {
                    Win(i, j);
                }
            }

            var input = Console.ReadLine().Trim().Split();
            var X = long.Parse(input[0]);
            var Y = long.Parse(input[1]);
            Console.WriteLine(Win(X, Y) ? Alice : Brown);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new D().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 11064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = double.Parse(Console.ReadLine());
            var A = L / 3.0;
            var ans = A * A * A;
            Console.WriteLine(ans.ToString("0.000000000000"));
        }
    }
}


Measured memory_bytes: 11220
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const N = input - 0

    let ans = 0

    for (let i = 1; i <= N; i++) {
        n = Math.floor(N / i)
        ans += (n * n + n) / 2 * i
    }

    console.log(ans)
 
})(input)


Measured memory_bytes: 33236
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=(1<<20)+10;
ll dp[maxn];
int mst[22],val[22];
int n,m,k;
inline void add(ll &a,ll b)
{
	a+=b;
	if(a>=MOD)a-=MOD;
}
int trans[maxn][22];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	n--;
	for(int i=0;i<k;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--,b--;
		mst[a]|=(1<<b);
		val[a]|=(c<<b);
	}
	
	for(int msk=0;msk<(1<<n);msk++)
	{
		int nxtone=0;
		for(int i=0;i<n;i++)
		{
			if(msk>>i&1)continue;
			if(nxtone<=i)nxtone=i+1;
			while(nxtone<n&&!(msk>>nxtone&1))nxtone++;
			trans[msk][i]=msk^(1<<i);
			if(nxtone<n)trans[msk][i]^=(1<<nxtone);
		}
	}
	
	dp[0]=1;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int msk=0;msk<(1<<n);msk++)
			{
				if(msk>>j&1)continue;
			//	cout<<msk<<" "<<j<<" "<<trans[msk][j]<<endl;
				add(dp[trans[msk][j]],dp[msk]);
			}
		}
		for(int msk=0;msk<(1<<n);msk++)
		{
			if((msk&mst[i])!=val[i])
			{
				dp[msk]=0;
			}
		}
	}
	ll ans=0;
	for(int msk=0;msk<(1<<n);msk++)
	{
		add(ans,dp[msk]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 53504
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;

int main(){
	string s;
	int n;
	int b;
	int k;
	cin >> s;
	cin >> k;
	n = s.length();
	
	for(int i=0;i<n;i++){
		if(s[i]!='a'){
			b = 'z'-s[i]+1;
			if(b<=k){
				s[i] = 'a';
				k=k-b;
			}
		}
	}
	if(k>0)
		s[n-1]=s[n-1]+(k%26);
	cout << s << endl;
	return 0;
};

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<string> S(N);
    int res = 0;
    int front = 0, back = 0, front_back = 0;
    REP(i, N) {
        cin >> S[i];
        REP(j, S[i].size() - 1) {
            res += S[i].substr(j, 2) == "AB";
        }
        if (S[i].front() == 'B') {
            if (S[i].back() == 'A') {
                ++front_back;
            } else {
                ++front;
            }
        } else if (S[i].back() == 'A') {
            ++back;
        }
    }
    if (front_back > 0) {
        if (front + back == 0) {
            res += front_back - 1;
        } else {
            res += front_back + min(front, back);
        }
    } else {
        res += min(front, back);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3704