akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, h: int, w: int):
    print ((H-h)*(W-w))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    h = int(next(tokens))  # type: int
    w = int(next(tokens))  # type: int
    solve(H, W, h, w)

if __name__ == '__main__':
    main()


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if(a+b>c+d){
    cout<<"Left"<<endl;
  }
  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }
  if(a+b<c+d){
    cout<<"Right"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(0);  
    cout.tie(0);
    lli n,i,k=0,l=0,c=0;
    cin>>n;
    int a[n+1];
    int b[n];
    for(i=0;i<n+1;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        if(b[i]>=a[i]){
            c=c+a[i];
            b[i]=b[i]-a[i];
            a[i]=0;
            if(b[i]>a[i+1]){
                c=c+a[i+1];
                a[i+1]=0;
            }
            else{
                c=c+b[i];
                a[i+1]=a[i+1]-b[i];
                b[i]=0;
            }
        }
        else{
            c=c+b[i];
        }
    }
    cout<<c;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdbool.h>


int main(){
   int i, j, n;
   char mark;
   char marks[4]={'S', 'H', 'C', 'D'};
   int num;
   bool cards[4][13]={false};


   scanf("%d ", &n);
   for(i=0;i<n;i++){
       scanf("%c %d ", &mark, &num);
       for(j=0;j<4;j++){
           if(mark==marks[j]){
               cards[j][num-1]=true;
               break;
           }
       }
   }
   for(i=0;i<4;i++){
       for(j=0;j<13;j++){
           if(!cards[i][j]){
               printf("%c %d\n", marks[i], j+1);
           }
       }
   }
   return 0;
}


Measured memory_bytes: 2144
#!/bin/ruby

class UnionFindTree
  def initialize(size)
    @array = Array.new(size) { |i| i }
  end

  def union(x, y)
    @array[root(x)] = root(y)
  end

  def print_same(x, y)
    puts same?(x, y) ? 1 : 0
  end

  def same?(x, y)
    root(x) == root(y)
  end

  def root(n)
    @array[n] == n ? n : @array[n] = root(@array[n])
  end
end

n, q = gets.split.map(&:to_i)
tree = UnionFindTree.new(n)
q.times do
  com, x, y = gets.split.map(&:to_i)
  com == 0 ? tree.union(x, y) : tree.print_same(x, y)
end



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

using namespace std;

typedef long long ll;

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

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

	map<string, int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;

	int n;
	cin >> n;

	rep(i, n){
		string s;
		cin >> s;

		mp[s]++;
	}

	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    REP(i, N) { cin >> P[i]; }
    REP(i, N) { cin >> Q[i]; }
    vector<int> Perm{P};
    sort(Perm.begin(), Perm.end());

    int count = 1;
    int P_num = 0, Q_num = 0;
    do {
        if (Perm == P) {
            P_num = count;
        }
        if (Perm == Q) {
            Q_num = count;
        }
        count++;
    } while (next_permutation(Perm.begin(), Perm.end()));
    cout << abs(P_num - Q_num) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
int main(){
    int n;
    cin>>n;
    int K;
    cin>>K;
    vector<int> v;
    for(int i = 0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    vector<int> dp(110000, INT_MAX);
    dp[0] = 0;
    for(int i = 0;i<n;i++){
        for(int j = 1;j<=K && i+j<n;j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(v[i]-v[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
int main()
{
  int N;
  int opponent;
  cin>>N;
  vector<string>hand(N);
  priority_queue<P>q;
  for(int i=0;i<N;i++){
    cin>>hand[i];
    int t=count(hand[i].begin(),hand[i].end(),'o');
    q.push(P(t,i+1));
  }
  for(int i=0;i<1000;i++){
    P me=q.top();
    cout<<me.second<<endl;
    fflush(stdout);
    cin>>opponent;
    q.pop();
    if(hand[me.second-1][opponent-1]=='o')me.first++;
    if(hand[me.second-1][opponent-1]=='x')me.first--;
    q.push(me);
  }
}

Measured memory_bytes: 0
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    s = input()
    n = len(s)
    ans = [0]*(n)
    d = []
    s += '.'
    cnt = 0
    for i in range(n):
        cnt += 1
        if s[i] != s[i+1]:
            d.append((cnt,i))
            cnt = 0
    for i in range(0, len(d),2):
        cnt1, idx1 = d[i]
        cnt2, _ = d[i+1]
        ans[idx1] = cnt1 + cnt2//2 - cnt1//2
        ans[idx1+1] = cnt2 + cnt1//2 - cnt2//2
    print(*ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20976
while True:
	p=list(map(int,input().split()))
	if p[0]==-1 and p[1]==-1 and p[2]==-1:
		break
	else:
		if p[0]==-1 or p[1]==-1:
			print('F')
		elif p[0]+p[1]>=80:
			print('A')
		elif 65<=p[0]+p[1]<80:
			print('B')
		elif 50<=p[0]+p[1]<65:
			print('C')
		elif 30<=p[0]+p[1]<50:
			if p[2]>=50:
				print('C')
			else:
				print('D')
		else:
			print('F')
	


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
using namespace std;


int main(){
    map<string,int> mp;
    long n;
    cin >> n;
    for (int i=0;i<n;i++){
        string s;
        cin >> s;
        auto itr = mp.find(s);
        if(itr!=mp.end()){
            mp[s]++;
        }
        else{
            mp[s]=1;
        }
    }
    int kaisuu=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        int val= itr->second;
        if(val>=kaisuu) kaisuu=val;
    }
    vector<string> vec;
    int yousosuu=0;
    for(auto itr = mp.begin();itr!=mp.end();++itr){
        int val= itr->second;
        if(val==kaisuu) vec.push_back(itr->first);
        yousosuu++;
    }
    sort(vec.begin(),vec.end());
    for(auto itr=vec.begin();itr!=vec.end();++itr){
        cout << *itr << endl;
    }
}



Measured memory_bytes: 26868
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	static int[][] a;
	static int n, start,goal,dan,s;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		label:while(true){
			n = cin.nextInt();
			if(n==0){
				break;
			}
			start = cin.nextInt();
			s = start;
			goal=cin.nextInt();
			dan = cin.nextInt();
			a = new int[dan][n-1];
			for(int i = 0; i < dan;i++){
				String str = cin.next();
				for(int j=0;j<str.length();j++){
					a[i][j]=str.charAt(j)-'0';
				}
			}
			start--;
			for(int i = 0; i < dan;i++){
				//System.out.println(start);
				if(start>0 && a[i][start-1]==1){
					start--;
				}
				else if(start < n-1 && a[i][start]==1){
					start++;
				}
			}
			if(start+1==goal){
				System.out.println(0);
				continue;
			}
			for(int i = 0; i < dan;i++){
				
				for(int j = 0;j < n-1;j++){
					start = s-1;
					if(j==0){
						if(n-1>1&&a[i][j]+a[i][j+1]==0){
							a[i][j]=1;
							if(a(i, j))
								continue label;
							a[i][j]=0;
						}
						else if(n-1==1&&a[i][j]==0){
							a[i][j]=1;
							if(a(i, j))
								continue label;
							a[i][j]=0;
						}
						
					}
					else if(j==n-2){
						if(a[i][j-1]+a[i][j]==0){
							a[i][j]=1;
							if(a(i, j))
								continue label;
							a[i][j]=0;
						}
					}
					else{
						if(a[i][j-1]+a[i][j]+a[i][j+1]==0){
							a[i][j]=1;
							if(a(i, j))
								continue label;
							a[i][j]=0;
						}
					}
					
				}
			}
			System.out.println(1);
		}
		
	}
	static boolean a(int x, int y){
		/*
		for(int i = 0; i < dan;i++){
			for(int j = 0; j < n-1;j++){
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
		*/
		for(int i = 0; i < dan;i++){
			if(start>0 && a[i][start-1]==1){
				start--;
			}
			else if(start < n-1 && a[i][start]==1){
				start++;
			}
		}
		if(start+1==goal){
			System.out.println((x+1) + " " + (y+1));
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC058D {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int H = input[0];
            int W = input[1];
            int A = input[2];
            int B = input[3];
            long ans = 0;
            long[] fact = new long[H + W];
            long[] invfact = new long[H + W];
            fact[0] = 1;
            invfact[0] = 1;
            for (int i = 1; i < H + W; i++) {
                fact[i] = multiply(fact[i - 1], i);
                invfact[i] = divide(1, fact[i]);
            }
            for (int i = 1; i <= H - A; i++) {
                long conbia = multiply(multiply(fact[B - 1 + i - 1], invfact[i - 1]), invfact[B - 1]);
                long conbib = multiply(multiply(fact[W - B - 1 + H - i], invfact[H - i]), invfact[W - B - 1]);
                ans = (ans + multiply(conbia, conbib)) % mod;
            }
            Console.WriteLine(ans);
        }

        //定数です
        const long mod = 1000000007;

        //mod下でのx×yです
        private static long multiply(long x, long y) {
            return (x % mod) * (y % mod) % mod;
        }

        //mod下でのxのy乗です
        private static long power(long x, long y) {
            if (y == 0) {
                return 1;
            } else if (y == 1) {
                return x % mod;
            } else if (y % 2 == 0) {
                long p = power(x, y / 2);
                return p * p % mod;
            } else {
                long p = power(x, y / 2);
                return (p * p) % mod * (x % mod) % mod;
            }
        }

        //mod下でのx÷yです（フェルマーの小定理よりyのmod-2乗をかける）
        private static long divide(long x, long y) {
            return multiply(x, power(y, mod - 2));
        }
    }
}


Measured memory_bytes: 16224
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  string S;
  cin >> N >> S;
  for(unsigned int i=0;i<S.length();i++){
    S[i] = (S[i] - 'A' + N)%26+'A';
  }
  cout << S;
}



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

using namespace std;

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

	int n;
	cin >> n;
	vector<ll> v(n);
	for(ll i=0; i<n; i++)
        cin >> v[i];
    vector<ll> pre(n), suff(n);
    pre[0]=v[0]; suff[n-1]=v[n-1];
    for(ll i=1; i<n; i++)
        pre[i]=(pre[i-1]^v[i]);
    for(ll i=n-2; i>=0; i--)
        suff[i]=(suff[i+1]^v[i]);
    for(ll i=0; i<n; i++){
        ll left=0, right=0;
        if(i>0)
            left=pre[i-1];
        if(i+1<n)
            right=suff[i+1];
        cout << (left^right) << " ";
    }
    cout << endl;

	return 0;
}


Measured memory_bytes: 7932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int NN;
string s1, s2;
int dp[1001][1001];

int run(){
	int N1 = s1.length();
	int N2 = s2.length();

	rep(i1, N1+1)
	rep(i2, N2+1){
		if(i1 == 0 || i2 == 0) dp[i1][i2] = 0;
		else{
			if(s1[i1-1] == s2[i2-1]) dp[i1][i2] = dp[i1-1][i2-1] + 1;
			else dp[i1][i2] = max(dp[i1-1][i2], dp[i1][i2-1]);
		}
	}
	return dp[N1][N2];
}

int main() {
	cin >> NN;
	rep(i, NN){
		cin >> s1;
		cin >> s2;
		cout << run() << endl;
	}
}

Measured memory_bytes: 7064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

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


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

	int x;
	cin >> x;
	cout << 360 * x / gcd(360, x) / x << endl;


	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 88;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

int a[maxN][maxN];
int b[maxN][maxN];
int n,m;
bitset<26000> f[maxN][maxN];
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&b[i][j]);
		}
	}
	f[0][1].set(13000);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int y = abs(a[i][j] - b[i][j]);
			auto tmp = f[i-1][j] | f[i][j-1];
			f[i][j] = ((tmp<<y) | (tmp >> y));
		}
	}
	int ans = inf;
	for(int i=0;i<26000;i++)
	{
		if(f[n][m][i])
		{
			ans = min(abs(i-13000),ans);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 24448
package main

import "fmt"

var N int
var a map[int]int

func main() {
	fmt.Scan(&N)
	a = make(map[int]int)
	var tmp int

	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		if _, ok := a[tmp]; !ok {
			a[tmp] = 0
		}
		a[tmp]++
	}
	result := 0
	for num, count := range a {
		if num > count {
			result += count
		} else {
			result += count - num
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 7936
from collections import defaultdict
from pprint import pprint as pp

rs = lambda: input()
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]

A, B, C = ria()
if A+B >= C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3564
#include<cctype>
#include<cstdio>
#include<cstring>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(char s[128];~scanf("%s",s);){
		int n=strlen(s);

		bool error=false;
		int r1=0,r2=0;
		char r3='+';
		rep(i,n){
			if(isdigit(s[i])){
				r2=10*r2+(s[i]-'0');
				if(r2<0 || 10000<=r2) error=true;
			}
			else{
				if     (r3=='+') r1+=r2, r2=0;
				else if(r3=='-') r1-=r2, r2=0;
				else if(r3=='*') r1*=r2, r2=0;
				if(r1<0 || 10000<=r1) error=true;
				r3=s[i];
			}
		}
		if(error) puts("E"); else printf("%d\n",r1);
	}

	return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define mt                make_tuple
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
#define sz(x)             (int)x.size()
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

const int tam = 1e5 + 10;

bool vis[tam];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ll n, x, m;
    cin >> n >> x >> m;
    if (n <= m) {
        ll res = 0;
        fore(i, 0, n) {
            res += x;
            x = x * x % m;
        }
        cout << res << '\n';
        return 0;
    }
    ll cycleSum = 0, cycleLen = 0;
    ll actX = x;
    //cout << "cola -> ciclo" << endl;
    while (vis[actX] == false) {
        //cout << actX << " -> ";
        vis[actX] = true;
        cycleLen++;
        cycleSum += actX;
        actX = actX * actX % m;
        //cout << actX << endl;
    } 
    ll tail = cycleSum;
    ll tailLen = cycleLen;
    cycleSum = 0;
    cycleLen = 0;
    //cout << "ciclo" << endl;
    while (vis[actX] == true) {
        //cout << actX << " -> ";
        vis[actX] = false;
        cycleLen++;
        cycleSum += actX;
        actX = actX * actX % m;
        //cout << actX << endl;
    }
    tail -= cycleSum;
    tailLen -= cycleLen;
    ll res = tail;
    n -= tailLen;
    ll completeCycles = n/cycleLen;
    ll diff = n - completeCycles*cycleLen;
    res += completeCycles * cycleSum;
    x = actX;
    fore(i, 0, diff) {
        res += x;
        x = x*x % m;
    }
    cout << res << '\n';
    return 0;
}
// Dinosaurs are cool!

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){long long n;
cin>>n;
long long a[n],s=0,i,j;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
        s=s+(a[i]*a[j]);
    }
}cout<<s;

    
    return 0;
}


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


int main() {
  int N=0;
  long long int Okane=1000;
  long long int Kabu=0;
  cin >> N;
  vector<int>Kabuka(N+1);
  Kabuka.at(N)=0;
  for(int i=0;i<N;i++){
    cin >> Kabuka.at(i);
  }
  
  for(int i=0;i<N;i++){
    if(Kabuka.at(i)<Kabuka.at(i+1)){
      Kabu = Kabu + Okane/Kabuka.at(i);
      Okane = Okane - Okane/Kabuka.at(i)*Kabuka.at(i);
    }
    if(Kabuka.at(i)>Kabuka.at(i+1)){
      Okane = Okane + Kabu*Kabuka.at(i);
      Kabu = 0;
    }
  }

  cout << Okane;
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))

ct = 0
flg = False

while True:
  for item in a:
    if(item%2 == 1):
      flg = True

  if(flg == True):
    break
  else:
    a = [int(i/2) for i in a]
    ct += 1
  
print(ct)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec_a(M);
  vector<int> vec_b(M);
  
  for (int i = 0; i < M; i++) {
    cin >> vec_a.at(i);
    cin >> vec_b.at(i);
  }
  
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int k = 0; k < M; k++) {
      if (vec_a.at(k) == j + 1) {
        count++;
      }
      else if (vec_b.at(k) == j + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void){
    int n, prev, curr, minv = 1;
    scanf("%d", &n);
    scanf("%d", &prev);
    for (int i = 1; i < n; i++) {
        scanf("%d", &curr);
        if (curr <= prev) minv++;
        prev = curr;
    }
    printf("%d\n%d\n", minv, n);
    return 0;
}



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

const double PI = 3.14159265359;

double f(double a, double b, double rad) {
	if (b * tan(PI / 2 - rad) <= a) {
		return a * b * b * tan(PI / 2 - rad) / 2.0;
	}
	else {
		return a * a * b - a * a * a * tan(rad) / 2.0;
	}
}

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double left = 0.0, right = 90.0;
	while (right - left >= 0.0000000001) {
		double mid = (left + right) / 2.0;
		double rad = PI / 180.0 * mid;
		if (x < f(a, b, rad)) {
			left = mid;
		}
		else {
			right = mid;
		}
	}
	printf("%.10f\n", right);
	return 0;
}

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

int main(){
  int n,a,b,c,d,i;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--;
  b--;
  c--;
  d--;
  
  int ra,rb;
  i=a;
  while(i<=n-1&&(s.at(i)=='.'||s.at(i+1)=='.')){
    i++;
  }
  ra=i;
  i=b;
  while(i<=n-1&&(s.at(i)=='.'||s.at(i+1)=='.')){
    i++;
  }
  rb=i;
  
  if(c>ra||d>rb){
    cout << "No" << endl;
    return 0;
  }
  
  if(c<d){
    cout << "Yes" << endl;
    return 0;
  }
  
  int judge=0;
  for(i=b;i<=d;i++){
    if(s.at(i-1)=='.'&&s.at(i)=='.'&&s.at(i+1)=='.'){
      judge=1;
    }
  }
  
  if(judge==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3760
package main

import "fmt"

const N = 100005
const INF = 1e9+7
var h [N]int
var cost [N]int

func abs(n int) int {
  if n < 0 {
    return -n
  } else {
    return n
  }
}

func min(a, b int) int {
  if a < b {
    return a
  } else {
    return b
  }
}

func main() {
  var n, k int
  fmt.Scanf("%d %d", &n, &k)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &h[i])
    cost[i] = INF
  }
  cost[0] = 0
  for i := 0; i < n; i++ {
    for j := i+1; j <= i+k && j < n; j++ {
      cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]))
    }
  }
  
  fmt.Println(cost[n-1])
}

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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  cout << (H2 - H1) * 60 + M2 - M1 - K << endl;
  return 0;
}

Measured memory_bytes: 3572
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = []
	B.append(A[0])
	for i in range(1, N - 1):
		if A[i - 1] >= A[i] and A[i] >= A[i + 1]:
			pass
		if A[i - 1] <= A[i] and A[i] <= A[i + 1]:
			pass
		else:
			B.append(A[i])

	B.append(A[-1])
	M = len(B)
	# print(B)
	money = 1000
	kabu = 0
	for i in range(M - 1):
		if B[i] < B[i + 1]:
			kabu += int(money // B[i])
			money %= B[i]
		else:
			money += kabu * B[i]
			kabu = 0

	# print(money, kabu)
	money += kabu * B[-1]
	print(money)


if __name__ == '__main__':
	main()

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

using namespace std;

long long dp[3001];
long long a[3001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    int n;
    cin >> n;
    for (int i = 1; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n - i + 1; ++j) {
            dp[j] = max(a[j]-dp[j+1], a[j+i-1]-dp[j]);
        }
    }
    cout << dp[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1010
#define inf 1000000007
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,p1,p2,p3,p4,s,t;
int head[maxn*2],nxt[maxn*20],to[maxn*20],c[maxn*20],v[maxn*20],tot=1;
void add(int x,int y,int z,int u)
{
    ++tot;
    nxt[tot]=head[x];
    head[x]=tot;
    to[tot]=y;
    c[tot]=z;
    v[tot]=u;
}
void addx(int x,int y,int z,int u)
{
    add(x,y,z,u);
    add(y,x,0,-u);
}
ll ans;
ll dis[maxn*2];
int pre[maxn*2],pre_num[maxn*2],vis[maxn*2];
queue<int>q;
int spfa()
{
    for(int i=1;i<=t;i++)  dis[i]=-1e16;
    q.push(s);dis[s]=0;vis[s]=1;
    while(q.size())
    {
        int now=q.front();q.pop();vis[now]=0;
        for(int i=head[now];i;i=nxt[i])
        {
            if(dis[to[i]]<dis[now]+v[i]&&c[i])
            {
                dis[to[i]]=dis[now]+v[i];
                pre[to[i]]=now;
                pre_num[to[i]]=i;
                if(!vis[to[i]])  q.push(to[i]),vis[to[i]]=1;
            }
        }
    }
    if(dis[t]==-1e16)  return 0;
    int di=inf;
    for(int i=t;i!=s;i=pre[i])  di=min(di,c[pre_num[i]]);
    for(int i=t;i!=s;i=pre[i])  c[pre_num[i]]-=di,c[pre_num[i]^1]+=di;
    ans+=dis[t]*di;
    return di;
}
int main()
{
    n=read();p1=2*n+1;p2=p1+1;p3=p2+1;p4=p3+1;s=p4+1;t=s+1;
    for(int i=1;i<=n;i++)
    {
        int x=read(),y=read(),z=read();
        addx(s,i,z,0);
        addx(i,p1,inf,x+y);
        addx(i,p2,inf,x-y);
        addx(i,p3,inf,-x+y);
        addx(i,p4,inf,-x-y);
    }
    for(int i=1;i<=n;i++)
    {
        int x=read(),y=read(),z=read();
        addx(i+n,t,z,0);
        addx(p1,i+n,inf,-x-y);
        addx(p2,i+n,inf,-x+y);
        addx(p3,i+n,inf,x-y);
        addx(p4,i+n,inf,x+y);
    }
    while(spfa()){};
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n%1000==0){
		cout<<"0"<<endl;
	}
	else
	cout<<1000-(n%1000)<<endl;
	return(0);
}

Measured memory_bytes: 3616
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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



int main() {
	double a, b;
	cin >> a >> b;
	int n = max(ceil(a / 0.08), ceil(b / 0.1));
	for (int i = 1; i <= n; i++) {
		if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100005], b[100005], c[100005], d[100005][3];
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
    for (int i = 1; i <= n; i++) {
        d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i];
        d[i][1] = max(d[i - 1][0], d[i - 1][2]) + b[i];
        d[i][2] = max(d[i - 1][0], d[i - 1][1]) + c[i];
    }
    cout << max({d[n][0], d[n][1], d[n][2]}) << '\n';
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, k;
double p[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for(int i=0; i<n; i++){
		int x; cin >> x;
		p[i] = double(x+1) / 2;
	}
	//max 1d range sum
	for(int i=1; i<n; i++) p[i] += p[i-1];
	double ans = p[k-1];
	for(int l=1; l+k-1<n; l++){
		ans = max(ans, p[l+k-1] - p[l-1]);
	}
	cout << fixed << setprecision(8);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int n;
	long long int s=100000;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		s*=1.05;
		s+=999;
		s/=1000;
		s*=1000;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 2556
// in the name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef long double ld ;

#define f first
#define s second

const ll maxn = 1e5 + 10 ;
const ll INF = 1e18 ;

ll n , dp[maxn][2] , a[maxn] , k ;

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

 cin >> n >> k ;
 for(int i = 1 ; i <= n ; i ++)cin >> a[i] ;

 for(int i = 0 ; i < a[1] ; i ++){
    dp[i][0] = 1;
    dp[i][1] = 0 ;
 }

 for(int i = a[1] ; i <= k ; i ++){
    ll ans0 = 1 , ans1 = 0 ;
    for(int j = 1 ; j <= n ; j ++){
        if(a[j] <= i){
            if(dp[i-a[j]][1] == 0)ans0 = 0 ;
            if(dp[i-a[j]][0] == 1)ans1 = 1 ;
        }
    }
    dp[i][0] = ans0 ;
    dp[i][1] = ans1 ;
 }

 if(dp[k][0] == 0)cout << "First" ;
 else cout << "Second" ;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int dp[4001][4001];
int main(void){
	string s,t;
	int i,j;
	int MAX;
	while(1){
		cin>>s>>t;
		if(cin.eof())	break;
		for(i=0;i<4001;i++){
			for(j=0;j<4001;j++){
				dp[i][j]=0;
			}
		}
		for(i=0;i<s.size();i++){
			for(j=0;j<t.size();j++){
				if(s[i]==t[j])	dp[i+1][j+1]=dp[i][j]+1;
				//else			dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
		}
		MAX=-1;
		for(i=0;i<=s.size();i++){
			for(j=0;j<=t.size();j++){
				MAX=max(MAX,dp[i][j]);
			}
		}
		cout<<MAX<<endl;
	}
	return 0;
}


Measured memory_bytes: 65760
def main():
    X = int(input())
    primes = [2, 3, 5, 7, 9, 11, 13]
    if X <= primes[-1] and X in primes:
        return X
    while True:
        for i in primes:
            if X % i == 0:
                break
        else:
            for i in range(primes[-1] + 2, int(X ** 0.5) + 1, 2):
                if X % i == 0:
                    break
            else:
                return X
        X += 1 

print(main())


Measured memory_bytes: 3060
import sys
s = input()
num = len(s)
l, r = 0, num-1
ans = 0

while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    else:
        ans += 1
        if s[l] == 'x':
            l += 1
        elif s[r] == 'x':
            r -= 1
        else:
            print(-1)
            sys.exit()
print(ans)
    


Measured memory_bytes: 9156
#include<stdio.h>
int main(){
	int f(int,int,int);
	int n,t,h;
	int a[2005];
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
		h=0;
		for(int i=0;i<n-2;i++)
		for(int j=i+1;j<n-1;j++)
		for(int m=j+1;m<n;m++){
		t=f(a[i],a[j],a[m]);
		if(t==1)
		h++;
	}
	printf("%d\n",h);
	}
	return 0;
}
int f(int x,int y,int z)
{
	int k;
	if(x+y>z&&y+z>x&&x+z>y)
	k=1;
	else
	k=0;
	return k;
}

Measured memory_bytes: 888
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans=0
for i in range(n):
        if a[i]>=b[i]:
                ans+=b[i]
        else:
                ans+=a[i]
                b[i]-=a[i]
                if a[i+1]>=b[i]:
                        ans+=b[i]
                        a[i+1]-=b[i]
                else:
                        ans+=a[i+1]
                        a[i+1]=0

print(ans)

Measured memory_bytes: 81892
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int x[]=new int[N];
		int a[]=new int[N];
		for(int i=0;i<N;i++){
			x[i]=in.nextInt();
			a[i]=x[i];
		}
		Arrays.sort(x);
		for(int i=0;i<N;i++) {
			if(a[i]<x[N/2]) {
				System.out.println(x[N/2]);
			}else{
				System.out.println(x[N/2-1]);
			}
		}
	}

}


Measured memory_bytes: 92892
#include <iostream>
using namespace std;
int arr[100005][3];
int dp[100005][3];
int n;

int solve(int i, int prev){
    //cout<<i<<" "<<prev<<"\n";
    if(i == n){
        return 0;
    }

    if(dp[i][prev]!=-1)return dp[i][prev];

    int maxVal=0;
    for(int j=0;j<3;j++){
        if(prev != j){
            int val = arr[i][j] + solve(i+1,j);
            if(maxVal < val)maxVal = val;
        }
    }
    return dp[i][prev] = maxVal;
}

int main() {
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        dp[i][0]=-1;
        dp[i][1]=-1;
        dp[i][2]=-1;
    }
    int ans = max(arr[0][0] + solve(1,0),max(arr[0][1] + solve(1,1),arr[0][2] + solve(1,2)));
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 10368
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int n,k;
bool bad[15];

bool isbad(int x){
	while(x){
		if(bad[x%10])return true;
		x /= 10;
	}
	return false;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n>>k;
    REP(i,1,k){
    	int d;
    	cin>>d;
    	bad[d] = true;
    }

    while(isbad(n)){
    	n++;
    }
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int map[100005];
int main()
{
	int n,sum;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		cin>>map[i];
	}
	sort(map,map+n);
	int a,ssum=1;
	a=map[0];
	for(int i=1; i<n; i++)
	{
		if(a==map[i])
		{
			ssum++;
			if(i==n-1)
				sum+=(ssum%2);
		}
		else
		{
			a=map[i];
			sum+=(ssum%2);
			ssum=1;
			if(i==n-1)
				sum++;
		}

	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;

public class Main {

	ArrayList<Integer>[] g;
	
	boolean[] vis;
	int[] delta;
	
	void submit() {
		int n = nextInt();
		int m = nextInt();
		
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}
		
		while (m-- > 0) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;
			int d = nextInt();
			g[v].add(u);
			g[v].add(d);
			g[u].add(v);
			g[u].add(-d);
		}
		
		vis = new boolean[n];
		delta = new int[n];
		
		for (int i = 0; i < n; i++) {
			if (!vis[i]) {
				if (!dfs(i, 0)) {
					out.println("No");
					return;
				}
			}
		}
		
		out.println("Yes");
	}
	
	boolean dfs(int v, int x) {
		vis[v] = true;
		delta[v] = x;
		
		for (int i = 0; i < g[v].size(); i += 2) {
			int u = g[v].get(i);
			int d = g[v].get(i + 1);
			if (!vis[u]) {
				if (!dfs(u, x + d)) {
					return false;
				}
			} else {
				if (delta[u] != x + d) {
					return false;
				}
			}
		}
		
		return true;
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 83912
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<ll> v(N*3);
    ll ans=0;
    REP(i,N*3) cin >> v[i];
    sort(ALL(v));
    reverse(ALL(v));
    REP(i,N){
        ans+=v[1+(2*i)];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int e;
    
    while (scanf("%d", &e) && e){
        int ct = 1000000;
        for (int i = 0; i * i * i <= e; i++){
            for (int j = 0; j * j <= e - i * i * i; j++){
                ct = min(ct, i + j + e - i * i * i - j * j);
            }
        }
        
        printf("%d\n", ct);
    }
    
    return (0);
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int x1 = max(a,max(b,c));
    int x3 = min(a,min(b,c));
    int x2 = a+b+c-x1-x3;
    cout << 10*x1+x2+x3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i, M) cin >> X[i];
    sort(X.begin(), X.end());
    vector<int> diff(M - 1);
    int len = X[M - 1] - X[0];
    REP(i, M - 1) diff[i] = X[i + 1] - X[i];
    sort(diff.rbegin(), diff.rend());
    REP(i, min(N - 1, (int)diff.size())) len -= diff[i];
    cout << len << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    int N,M;
    std::cin >> N >> M;
    std::vector<int>LS[M];
    int nSwitches;
    int s;
    for(auto &ls : LS){
        std::cin >> nSwitches;
        ls = std::vector<int>(nSwitches);
        for(int i=0; i<nSwitches; ++i){
            std::cin >> s;
            ls.emplace_back(s);
        }
    }
    int P[M];
    for(auto &p : P){
        std::cin >> p;
    }

    int nOnLight = 0;
    int nOnSwitch = 0;
    int nAllOnLight = 0;
    for(int i=0; i<(1<<N); ++i){
        nOnLight = 0;
        for(int j=0; j<M; ++j){
            nOnSwitch = 0;
            for(const auto &s : LS[j]){
                nOnSwitch += (i>>(s-1))&1;
            }
            if((nOnSwitch&1)==P[j]){
                ++nOnLight;
            }
        }
        if(nOnLight==M){
            ++nAllOnLight;
        }
    }
    std::cout << nAllOnLight << std::endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll N, A;
    cin >> N >> A;
    ll rem = N % 500;
    cout << (rem <= A ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

vector<vector<int>> to;
vector<int> ans;

void dfs(int v, int p = -1) {
	for (int b : to[v]) {
		if (b == p)continue;
		ans[b] += ans[v];
		dfs(b, v);
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	to.resize(n);
	ans.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 23552
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;

int main() {
    int N;
    cin >> N;
    int V[N];
    int C[N];
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        if(V[i] > C[i]){
            sum += V[i] - C[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int a[3],b[3],ans = 0;
    int sum[30]={};
    FOR(i,3){
        cin >> a[i] >> b[i];
        sum[a[i]]++;
        sum[b[i]]++;
    }
    FOR(i,5){
        ans=max(ans,sum[i]);
    }
    cout  <<(ans>=3 ? "NO" : "YES" ) fin;

  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, i, a[200001], msa, l, sa;
	
	scanf("%d", &n);
	
	scanf("%d%d", &a[0], &a[1]);
	
	l=a[0]>a[1]?a[1]:a[0];
	msa=a[1]-a[0];
	
	for(i=2;i<n;i++){
		scanf("%d", &a[i]);
		sa=a[i]-l;
		if(sa>msa)
		msa=sa;
		if(l>a[i])
		l=a[i];
	}
	
	printf("%d\n", msa);
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>> v.at(i);
	sort(v.begin(),v.end());
	cout<<v.at(n/2)-v.at(n/2-1)<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

int n, d = 0, maxelement = 0;
vector<pair<int, int>> input;
vector<vector<int>> edge;
vector<int> deg;
map<pair<int, int>, int> mp;

void dfs(int now, int s){
    int cnt = 1;
    vector<bool> used(d, false);
    if(now != 0){
        used[s - 1] = true;
    }
    for(auto&& i : edge[now]){
        for(int j = 1; j <= d; j++){
            if(used[j - 1]) continue;
            used[j - 1] = true;
            mp[make_pair(now, i)] = j;
            maxelement = max(maxelement, j);
            dfs(i, j);
            break;
        }
    }
}

int main(){
    cin >> n;
    edge.resize(n);
    deg.resize(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        input.push_back(make_pair(a - 1, b - 1));
        edge[a - 1].push_back(b - 1);
        deg[a - 1]++;
        deg[b - 1]++;
    }
    for(auto&& i : deg){
        d = max(d, i);
    }
    dfs(0, 0);
    cout << maxelement << "\n";
    for(auto&& i : input){
        cout << mp[i] << "\n";
    }
}


Measured memory_bytes: 17016