akhauriyash/Code-Regression huggingface dataset:
//16
#include<iostream>
#include<deque>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    char l[1025];
    cin>>l;
    deque<char> deq;
    deq.push_back(l[0]);
    int idx=0;
    for(int i=1;l[i];i+=3){
      if(l[i]=='-'){
	idx++;
	if(idx>=deq.size()){
	  deq.push_back(l[i+2]);
	}
      }else{
	idx--;
	if(idx<0){
	  deq.push_front(l[i+2]);
	  idx=0;
	}
      }
    }
    for(int i=0;i<deq.size();i++){
      cout<<deq[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char[] ary = sc.next().toCharArray();
		int ans=0;
		Set<Character> set = null;
		for(int i=0; i<n;i++) {
			set = new HashSet<>();
			for(int j=0; j<=i;j++) {
				for(int k=i+1; k<n;k++) {
					if(ary[j]==ary[k]) set.add(ary[j]);
				}
			}
			if(ans < set.size()) ans = set.size();
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin>>n;
  string ans;
  while(n){
    n--;
    ans+='a'+n%26;
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s_a = sum(a)
s_b = sum(b)
if s_b > s_a:
    print(-1)
    exit()
dist_s = s_a - s_b
dist_list = []
for i in range(n):
    if a[i] >= b[i]:
        dist_list.append(a[i]-b[i])
dist_list.sort()
m = len(dist_list)
count = 0
ans = n
while dist_s > 0 and count < m:
    dist_s -= dist_list[count]
    ans -= 1
    count += 1
    if dist_s < 0:
        ans += 1
print(ans)

Measured memory_bytes: 97900
def main():
    a, b, c, d = map(int, input().split())
    ans = b - a + 1
    ans -= b // c - (a - 1) // c
    ans -= b // d - (a - 1) // d
    lcmcd = lcm(c, d)
    ans += b // lcmcd - (a - 1) // lcmcd
    print(ans)

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    long double a, b, c;
    cin >> a >> b >> c;

    if (a+b+2*sqrt(a*b)<c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

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


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

struct UnionFind
{
    vector<int> par;
    vector<int> sizes;
    UnionFind(int n) : par(n), sizes(n, 1)
    {
        rep(i, n) par[i] = i;
    }
    int find(int x)
    {
        if (x == par[x])
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
        {
            return;
        }
        if (sizes[x] < sizes[y])
        {
            swap(x, y);
        }
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    int size(int x)
    {
        return sizes[find(x)];
    }
};

struct Edge
{
    int a, b, cost;
    bool operator<(const Edge &o) const
    {
        return cost < o.cost;
    }
};
struct Graph
{
    int n;
    vector<Edge> es;
    int kruskal()
    {
        sort(es.begin(), es.end());
        UnionFind uf(n);
        int min_cost = 0;
        rep(ei, es.size())
        {
            Edge &e = es[ei];
            if (!uf.same(e.a, e.b))
            {
                min_cost += e.cost;
                uf.unite(e.a, e.b);
            }
        }
        return min_cost;
    }
};

int main()
{
    Graph g;
    //    int n;
    cin >> g.n;
    vector<pair<pair<int, int>, int>> a(g.n);
    vector<pair<pair<int, int>, int>> b(g.n);

    rep(i, g.n)
    {
        int x, y;
        cin >> x >> y;
        a[i] = {{x, y}, i};
        b[i] = {{y, x}, i};
    }
    sort(all(a));
    sort(all(b));
    rep(i, g.n - 1)
    {
        g.es.push_back({a[i].second, a[i + 1].second, abs(a[i].first.first - a[i + 1].first.first)});
        g.es.push_back({b[i].second, b[i + 1].second, abs(b[i].first.first - b[i + 1].first.first)});
    }
    cout << g.kruskal() << endl;
    return 0;
}

Measured memory_bytes: 7284
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {

            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];

            var ok = new bool[N + 1];
            for (int i = 0; i < K; i++)
            {
                var d = long.Parse(Console.ReadLine());
                var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for (int j = 0; j < d; j++)
                {
                    ok[A[j]] = true;
                }
            }

            var ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if (!ok[i])
                {
                    ans++;
                }
            }
                Console.WriteLine(ans);
            
        }
    }

}


Measured memory_bytes: 19284
(let* ((n (read))
       (m (read))
       (cs (loop repeat m
                 collect (cons (read) (read))))
       (dig (make-array n :initial-element -1))
       (valid t)
       (result))
  (loop for (s . c) in cs
        do (progn
             (when (and (<= 0 (aref dig (- s 1)))
                        (/= c (aref dig (- s 1))))
               (setf valid nil)
               (loop-finish))
             (setf (aref dig (- s 1)) c)))
  (loop for i from 0 below n
        for d = (aref dig i)
        do (push (cond
                   ((<= 0 d) d)
                   ((zerop i) 1)
                   (t 0))
                 result))
  (setf result (nreverse result))
  (when (and (zerop (car result))
             (> n 1))
    (setf valid nil))
  (when (and (zerop m) (= n 1))
    (setf result '(0)))
  (if valid
      (format t "~{~a~}~%" result)
      (format t "-1~%")))


Measured memory_bytes: 19300
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,k;cin>>n>>k;
  vl h(n);
  rep(i,n)cin>>h[i];
  ll dp[100010];
  dp[0]=0;
  for(ll i=1;i<n;i++){
    dp[i]=INF;
    for(ll j=0;j<min(k,i);j++){
      dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
    }
  }
  cout<<dp[n-1]<<endl;
}

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

int main(void){
  char X,Y;
  cin>>X>>Y;
  if(X=='A'||Y=='A'){
    if(X==Y)cout<<"=";
    else cout<<(X=='A'?"<":">");
  }
  else if(X=='B'||Y=='B'){
    if(X==Y)cout<<"=";
    else cout<<(X=='B'?"<":">");
  }
  else if(X=='C'||Y=='C'){
    if(X==Y)cout<<"=";
    else cout<<(X=='C'?"<":">");
  }
  else if(X=='D'||Y=='D'){
    if(X==Y)cout<<"=";
    else cout<<(X=='D'?"<":">");
  }
  else if(X=='E'||Y=='E'){
    if(X==Y)cout<<"=";
    else cout<<(X=='E'?"<":">");
  }
  else cout<<"=";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,R; cin >> N >> R;
    if(N >= 10){
        cout << R << endl;
    }else{
        cout << R + 100*(10-N) << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, a ,b, c;
    for ( i=1; i<=3000; i++)
     {  
         cin >> a >> b;
        if(a == 0&&b == 0)
        break;
      
        //Swap a & b
        if(a>b)
        { 
            
            c=b;
            b=a;
            a=c;
        }
       
        
        cout << a << " " << b << endl;
     }
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  string ans = n == m ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	string s;
	cin >> s;
	int digSum = 0;
	F0R(i, sz(s)) {
		digSum += s[i] - '0';
	}
	cout << (digSum % 9 == 0 ? "Yes" : "No") << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3728
/*input
2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vi v1,v2,v3;
	v1.resize(a),v2.resize(b),v3.resize(c);
	for(auto &i:v1){
		cin >> i;
	} 
	for(auto &i:v2){
		cin >> i;
	} 
	for(auto &i:v3){
		cin >> i;
	}
	sort(all(v1)),sort(all(v2)),sort(all(v3));
	reverse(all(v1)),reverse(all(v2)),reverse(all(v3));
	while(v1.size()>x){
		v1.pop_back();
	}
	while(v2.size()>y){
		v2.pop_back();
	}
	reverse(all(v1)),reverse(all(v2));
	lld i=0,j=0;
	lld k=0;
	lld ans=0;
	while(i<x && j<y && k<c){
		if(v1[i]<v2[j]){
			if(v3[k]>v1[i]){
				ans+=v3[k];
				k++;
				i++;
			}
			else{
				ans+=v1[i];
				i++;
			}
		}
		else{
			if(v3[k]>v2[j]){
				ans+=v3[k];
				k++,j++;
			}
			else{
				ans+=v2[j];
				j++;
			}
		}
	}
	while(i<x && k<c){
		if(v3[k]>v1[i]){
			ans+=v3[k];
			k++,i++;
		}
		else{
			ans+=v1[i];
			i++;
		}
	}
	while(i<x){
		ans+=v1[i];
		i++;
	}
	while(j<y && k<c){
		if(v3[k]>v2[j]){
			ans+=v3[k];
			k++,j++;
		}
		else{
			ans+=v2[j];
			j++;
		}
	}
	while(j<y){
		ans+=v2[j];
		j++;
	}
	cout << ans << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

int main() {
  int n,mae,maemae;
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  mae = max(vec.at(1),vec.at(0))-min(vec.at(1),vec.at(0));
  maemae = 0;
  for(int i=2;i<vec.size();i++){
    int a,b;
    a = maemae + max(vec.at(i),vec.at(i-2))-min(vec.at(i),vec.at(i-2));
    b = mae + max(vec.at(i),vec.at(i-1))-min(vec.at(i),vec.at(i-1));
    maemae = mae;
    mae = min(a,b);
  }
  cout << mae << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


int main(){
    ll a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

    return 0;
}


Measured memory_bytes: 3620
unittest
{
	assert( [ "4", "2 5 4 6" ].parse.expand.solve == 5 );
	assert( [ "9", "0 0 0 0 0 0 0 0 0" ].parse.expand.solve == 45 );
	assert( [ "19", "885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1" ].parse.expand.solve == 37 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto l = 0L;
	auto r = 0L;
	auto x = 0L;
	auto t = 0L;
	while( r < as.length )
	{
		if( ( x ^ as[ r ] ) == ( t + as[ r ] ) )
		{
			x ^= as[ r ];
			t += as[ r ];
			r++;
			ans += r - l;
		}
		else
		{
			x ^= as[ l ];
			t -= as[ l ];
			l++;
		}
	}
	return ans;
}


Measured memory_bytes: 11440
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    print(n ** 3)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """8"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5620
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int H, W, K;
    cin >> H >> W >> K;

    vector<string> M(H);
    for (int i = 0; i < H; ++i) {
        cin >> M[i];
    }

    vector<vector<int>> res(H, vector<int>(W, 0));

    int idx = 0;
    for (int i = 0; i < H; ++i) {
        vector<int> P;
        for (int j = 0; j < W; ++j) {
            if (M[i][j] == '#') {
                P.push_back(j);
            }
        }
        if (P.empty()) {
            for (int j = 0; j < W; ++j) {
                if (i - 1 >= 0) {
                    res[i][j] = res[i - 1][j];
                }
            }
        } else {
            int L = -1;
            bool isFirst = idx == 0;
            for (auto x : P) {
                ++idx;
                for (int j = L + 1; j <= x; ++j) {
                    res[i][j] = idx;
                }
                L = x;
            }
            for (int j = P.back() + 1; j < W; ++j) {
                res[i][j] = idx;
            }
            if (isFirst) {
                for (int k = i - 1; k >= 0; --k) {
                    res[k] = res[k + 1];
                }
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << res[i][j] << (j == W - 1 ? '\n' : ' ');
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

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

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

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

    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;
    int ab = A * B;
    if((ab * 1) % 2 == 1 || (ab * 2) % 2 == 1 || (ab * 3) % 2 == 1) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=200005;
const int MOD=1000000007;

int n,a[N],b[N],jc[8005],ny[8005];
LL f[4005][4005];

int read()
{
	int 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*10+ch-'0';ch=getchar();}
	return x*f;
}

int ksm(int x,int y)
{
	int ans=1;
	while (y)
	{
		if (y&1) ans=(LL)ans*x%MOD;
		x=(LL)x*x%MOD;y>>=1;
	}
	return ans;
}

int main()
{
	n=read();int mx=0;
	for (int i=1;i<=n;i++) a[i]=read(),b[i]=read(),mx=max(mx,max(a[i],b[i]));
	for (int i=1;i<=n;i++) f[a[i]+mx][b[i]+mx]++;
	jc[0]=ny[0]=1;
	for (int i=1;i<=mx*4;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=ksm(jc[i],MOD-2);
	LL ans=0;
	for (int i=mx*2;i>=0;i--)
		for (int j=mx*2;j>=0;j--)
			(f[i][j]+=f[i+1][j]+f[i][j+1])%=MOD;
	for (int i=1;i<=n;i++) (ans+=f[mx-a[i]][mx-b[i]])%=MOD;
	for (int i=1;i<=n;i++) (ans-=(LL)jc[a[i]*2+b[i]*2]*ny[a[i]*2]%MOD*ny[b[i]*2])%=MOD;
	ans=ans*ksm(2,MOD-2)%MOD;
	printf("%lld",(ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 127104
#include "cstdio"

int main()
{
    char O[52],E[52];
    while (scanf ("%s%s",O,E)!= EOF)
    {
        int i=0;
        while (E[i] != '\0')
        {
            printf ("%c%c",O[i],E[i]);
            i++;
        }
        if (O[i] != '\0')
        {
            printf ("%c",O[i]);
        }
        putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }



ll x[110000];
vector<ll> p;
int main(){
    ll n,ans=0;
    cin>>n;
    ll a;
    rep(i,0,n){cin>>a;x[a]++;ans+=a;}
    ll q;
    cin>>q;

    rep(i,0,q){
        ll b,c;
        cin>>b>>c;
        ll t1=x[b];
        ans+=c*(t1)-b*t1;
        p.pb(ans);
        x[c]+=t1;
        x[b]=0;
    }
    rep(i,0,p.size())cout<<p[i]<<endl;
}



Measured memory_bytes: 5036
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


long res[30];
long from[30],to[30];

int main(){
	li w,n;
	cin>>w>>n;
	
	rep(i,w)res[i]=i;
	
	rin{
		scanf("%ld,%ld", &from[i], &to[i]);
	}
	
	rin{
		swap(res[from[i]-1],res[to[i]-1]);
	}
	
	rep(i,w)cout<<res[i]+1<<endl;
	
	return 0;
}

Measured memory_bytes: 1240
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = new Integer(sc.nextLine());
        String[] str = sc.nextLine().split(" ");
        StringBuilder sb = new StringBuilder();
        
        for(int i=n-1;i>=0;i--){
            sb.append(str[i]);
            if(i!=0) sb.append(" ");
        }
        System.out.println(sb);
    }
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<long> c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i];
    sort(c.rbegin(), c.rend());

    const long MOD = 1000000007;

    long p4 = 1;
    for (int i = 0; i < n - 1; i++) {
        p4 *= 4;
        p4 %= MOD;
    }

    long res = 0;
    for (int i = 0; i < n; i++) {
//        res += c[i] * (i + 2) * (4 ** (n - 1))
        long z = (c[i] * (i + 2)) % MOD;
        z *= p4;
        z %= MOD;
        res += z;
        res %= MOD;
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int menu[5];
  int time = 0;
  int i,j;
  int gosa; // 10の倍数からどのくらい離れているか
  int gg = 11;
  int gn = 0;
  int check[5];

  for(i = 0; i < 0; i++){
    check[i] = 0;
  }

  scanf("%d%d%d%d%d",&menu[0],&menu[1],&menu[2],&menu[3],&menu[4]);

  for(i = 0; i < 5; i++){
    gg =11;
    for(j = 0; j < 5; j++){
      if(check[j] == 1)continue;
      gosa = 10-menu[j]%10;
      if(gosa == 10) gosa = 0;
      if(gg > gosa) {
        gg = gosa;
        gn = j;
      }
    }
    //printf("%d\n",gn);
    time += menu[gn]+gg;
    check[gn] = 1;
  }
  time -= gg;

  printf("%d",time);
}


Measured memory_bytes: 128
# coding: utf-8

n = int(raw_input())
scores = [0,0]
for i in range(n):
    tarou, hanako = raw_input().split()
    if tarou > hanako:
        scores[0] += 3
    elif tarou < hanako:
        scores[1] += 3
    else:
        scores[0] += 1
        scores[1] += 1

print scores[0], scores[1]

Measured memory_bytes: 6460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int h, w, n, md;
bool g[51][51] = {};

void answer() {
    ll res = 0;
    ll base = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) res = (res+base) % md;
            base = 2*base % md;
        }
    }
    cout << "! " << res << endl;
}

using T = tuple<int, int, int, int>;
map<T, int> buf;
int que(int ax, int ay, int bx, int by) {
    bx--; by--;
    if (buf.count(T(ax, ay, bx, by))) return buf[T(ax, ay, bx, by)];
    cout << "? " << ay << " " << ax << " " << by << " " << bx << endl;
    int p;
    cin >> p;
    return buf[T(ax, ay, bx, by)] = p;
}

int dfs(int y, int l, int r, int nm = -1) {
    if (nm == -1) {
        nm = que(l, y, r, y+1);
    }
    if (nm == 0) return 0;
    if (l+1 == r) {
        g[y][l] = true;
        return 1;
    }
    int md = (l+r)/2;
    int buf = dfs(y, l, md);
    if (nm != buf) dfs(y, md, r, nm-buf);
    return nm;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> h >> w >> n >> md;
    for (int i = 0; i < h; i++) {
/*        for (int j = 0; j < w; j++) {
            g[i][j] = (que(j, i, j+1, i+1) != 0);
        }*/
        dfs(i, 0, w);
    }
    answer();
    return 0;
}



Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n;
  cin>>n;
  long long h[100010],dp[100010];
  for(int i=0;i<n;i++){
      cin >> h[i];
  }
  for(int i=0;i<n;i++){
      dp[i] = INFINITY;
      dp[0]=0;
  }
  for(int i=1;i<n;i++){
      chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
      if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1]<<endl;
  }

Measured memory_bytes: 1792
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int a, b = 0;
			int di = 1;
			a = sc.nextInt();
			b = sc.nextInt();
			a = a+b;
			while(a/10 != 0){
				a /= 10;
				di++;
			}
			System.out.println(di);
		}
	}
}

Measured memory_bytes: 20388
n = input()
nums = input().split()
check = 1
for num in nums:
  a = int(num)
  if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
    check = 0

if check == 1:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct r{
	string na;
	int s,a;
};
r x[10000];
bool cmp(r x,r y){
	string a=x.na,b=y.na;
	if(b.size()>a.size())a=b;
	for(int i=0;i<a.size();i++){
		if(x.na[i]!=y.na[i])return x.na<y.na;
	}
	return x.s>y.s;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i].na>>x[i].s;
		x[i].a=i+1;
	}
	sort(x,x+n,cmp);
	for(int i=0;i<n;i++)cout<<x[i].a<<endl;
} 

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int i,j;
  int K=0;
  int memo[30]={};
  for(i=0; i<N; i++){
    scanf("%d",&K);
    for(j=0; j<K; j++){
      int num=0;
      scanf("%d",&num);
      memo[num-1]++;
    }
  }
  int count=0;
  for(i=0; i<M; i++){
    if(memo[i]==N)
      count++;
  }
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ld long double
using namespace std;

#define ld long double
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007
#define pii pair<int,int>
#define TT int t;cin>>t;while(t--)
#define ina for(i=0;i<n;i++){cin>>a[i];}

signed main()
{
    int i,j,n,m;
    cin>>n>>m;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int x,y;
    pii d[m];
    for(i=m-1;i>=0;i--)
    {
        cin>>d[i].so>>d[i].fi;
    }
    sort(d,d+m);
    j=m-1,i=0;
    while(a[i]<d[j].fi && j>=0 && i<n)
    {
        if(d[j].so==0) {j--;continue;}
        a[i]=d[j].fi;
        i++;
        d[j].so--;
    }
    int sum=0;
    for(i=0;i<n;i++) sum+=a[i];
    cout<<sum;
}


Measured memory_bytes: 2560
//    ____       ____                 _           
//   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___  
//   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
//   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
//   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/ 
//                                                

 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 2e3+7;

int ans[N];

int main()
{
	
	int n,x,y;
	scanf("%d %d %d",&n,&x,&y);
	
	repA(i,1,n) repA(j,i+1,n)
	{
		int res = j-i;
		res = min(res,abs(i-x)+1+abs(y-j));
		ans[res]++;
	}
	
	repA(i,1,n-1) printf("%d\n",ans[i]);
	
    return 0;
}



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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;
	inline void flush(){fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<typename T >inline T Read() {
		T _ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __=getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		return _ *= ___;
	}
	template<typename T>inline void write(T _, char __ = '\n') {
		if(!_) *nowps ++ = '0';
		if(_ < 0) *nowps ++ = '-', _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; *nowps ++ = sta[tp --] ^ 48); 
		(*nowps ++) = __;
	}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;
char S[N];
bool exs[N];
vector <int> E;
int n,now;
bool check() {
	if(S[1] == '0' || S[n] == '1' || S[n - 1] == '0') return 0;
	for(int i = 1;i <= n - 1;++i) 
		if(S[i] != S[n - i]) return 0;
	return 1;
}
int main() {
	scanf("%s",S + 1);
	n = strlen(S + 1),now = 1;
	if(!check()) {puts("-1");return 0;}
	for(int i = 1;i <= n;++i) if(S[i] == '1') exs[i] = 1,E.push_back(i);
	for(int i = 1;i < E.size();++i) {
		printf("%d %d\n",E[i - 1],E[i]);
		for(int j = 1;j <= E[i] - E[i - 1] - 1;++j) {
			while(exs[now]) now ++;
			printf("%d %d\n",E[i],now ++);
		}
	}
	for(int i = now;i <= n;++i) if(!exs[i])printf("%d %d\n",i,n - 1);
	return flush(), 0;
}


Measured memory_bytes: 2040
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

    ll n,a[200005],i,j,k,l,dp[405][405]={0};

int main()
{
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-2)dp[i][1]=a[i]+a[i+1];
    rep(i,0,n-1)dp[i][0]=0;
    rep(l,2,n-1)
    {
        rep(i,0,n-l-1)
        {
            ll x=inf,y=0;
            rep(j,i+1,i+l-1)
            {
                x=min(x,min(dp[i][j-i]+dp[j+1][i+l-j-1],dp[i][j-i-1]+dp[j][i+l-j]));
            }
            rep(j,i,i+l)y+=a[j];
            dp[i][l]=y+x;
        }
    }
    //rep(i,0,n-1){rep(j,0,n-1)cout<<dp[i][j]<<" ";cout<<en;}
    cout<<dp[0][n-1];
    return 0;       
}


Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
"""
Network Flow - Maximum Flow
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

"""
import sys
from sys import stdin
from collections import namedtuple, deque
input = stdin.readline

edge = namedtuple('edge', ['to', 'cap', 'rev'])


def add_edge(G, f, t, c):
    G[f].append(edge(t, c, len(G[t])))
    G[t].append(edge(f, 0, len(G[f]) - 1))


def bfs(G, level, s):
    for i in range(len(level)):
        level[i] = -1
    que = deque()
    level[s] = 0
    que.append(s)
    while que:
        v = que.popleft()
        for e in G[v]:
            if e.cap > 0 and level[e.to] < 0:
                level[e.to] = level[v] + 1
                que.append(e.to)


def dfs(G, iter, level, v, t, f):
    if v == t:
        return f
    for i in range(iter[v], len(G[v])):
        e = G[v][i]
        if e.cap > 0 and level[v] < level[e.to]:
            d = dfs(G, iter, level, e.to, t, min(f, e.cap))
            if d > 0:
                G[v][i] = edge(e.to, e.cap - d, e.rev)
                G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev)
                return d
    return 0

def max_flow(G, V, s, t):
    level = [0] * V
    flow = 0
    while True:
        bfs(G, level, s)
        if level[t] < 0:
            return flow
        iter = [0] * V
        while True:
            f = dfs(G, iter, level, s, t, float('inf'))
            if f > 0:
                flow += f
            else:
                break


def main(args):
    V, E = map(int, input().split())

    G = [[] for _ in range(V)]
    for _ in range(E):
        u, v, c = map(int, input().split())
        add_edge(G, u, v, c)

    ans = max_flow(G, V, 0, V - 1)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



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

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

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

using namespace std;

string s;
bool a[10];

int main() {

    cin >> s;


    for (int i = 0; i < s.size(); ++i){
        if (s[i] == 'N') a[1] = 1;
        else if (s[i] == 'W') a[2] = 1;
        else if (s[i] == 'S') a[3] = 1;
        else a[4] = 1;
    }

    if (a[1] - a[3] == 0 && a[2] - a[4] == 0) cout << "Yes";
    else cout << "No";



    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
int main() {
	int W, H, N; cin >> W >> H >> N;
	int left = 0, right = W, up = H, down = 0;
	for (int i = 0; i < N; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) left = max(left, x);
		else if (a == 2) right = min(right, x);
		else if (a == 3) down = max(down, y);
		else up = min(up, y);
	}
	int width = right - left;
	int height = up - down;
	int res = width * height;
	if (width<0 || height<0) cout << 0 << endl;
	else cout << res << endl;
	//system("pause");
	return 0;
}


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


int main(){
	int n,m;
	cin >> n >> m;
	vector<int> b(m);
	vector<int> a(m);
	vector<vector<int> > key(m);
	for(int i=0;i<m;++i){
		cin >> a[i] >> b[i];
		for(int j=0;j<b[i];++j){
			int c;
			cin >> c;
			c--;
			key[i].push_back(c);
		}
	}
	const int INF = 10000000;
	int nn = 1;
	for(int i=0;i<n;++i) nn*=2;
	vector<int> dp(nn,INF);
	dp[0] = 0;
	
	for(int i=0;i<m;++i){
		int current = 0;
		
		for(int j=0;j<key[i].size();++j){
			current |= (1 << key[i][j]);
		}
//		cout<<i<<" "<< current << endl;
//		cout << dp[4095] <<endl;
		for(int bits = 0 ; bits < nn;bits++){
			//cout <<( bits | current) <<dp[bits|current]  <<endl;
			dp[bits|current] = min(dp[bits|current],dp[bits]+a[i]);
		}
		
//		cout << "--"<<endl;
	}
	/*
	for(int i=0;i<nn;++i){
		cout <<dp[i] << " ";
	}cout <<endl;
	*/
	if(dp[nn-1] == INF) cout << -1 <<endl;
	else cout << dp[nn-1] <<endl;
	
	
	
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define pi 3.141592653589 
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int>adj[100001];
vector<bool>vis(100001);
vector<int>p(100001);
vector<int>dis(100001);
queue<int> q;
void bfs(int s)
{
    q.push(s);
    vis[s]=true;
    p[s]=-1;
    while(!q.empty())
    {
        int v=q.front();q.pop();
        for(int u:adj[v])
        {   
            if(!vis[u])
            {
                vis[u]=true;
                q.push(u);
                dis[u]=dis[v]+1;
                p[u]=v;
            }
            
        }
    }
}
void shortestpath(int u)
{
    if (!vis[u]) {
    cout << "No path!";
} else {
    vector<int> path;
    for (int v = u; v != -1; v = p[v])
        path.push_back(v);
    reverse(path.begin(), path.end());
    cout << "Path: ";
    for (int v : path)
        cout << v << " ";
}
}
 

int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {   cin>>u>>v;
        adj[u].push_back(v);adj[v].PB(u);
    }
    bfs(1);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cout<<"No";return 0 ;
        }
    }
    cout<<"Yes"<<"\n";
    for(int i=2;i<=n;i++)
    {
        cout<<p[i]<<"\n";
    }
return 0;
   
}

Measured memory_bytes: 10572
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();
		    long a[] = new long[n];
		    long max = 0;
		    long chk = 0;
		    long min = 1000000000;
		    for(int i=0;i<n;i++){
		        a[i] = sc.nextLong();
		    }
		    
		    for(int i=0;i<n;i++){
		        max = Math.max(max,a[i]);
		        chk += max - a[i];
		    }
		    System.out.println(chk);
	        
    
	}
}


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int count_1 = 0;
    int count_0 = 0;
    for (int i=0; i<S.size(); i++) {
        if (S.at(i) == '1') {
            count_1++;
        } else {
            count_0++;
        }
    }
    ans = min(count_1, count_0) * 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

const int MAXN = 3000 + 5;

using namespace std;

long double dp[MAXN][MAXN],probability[MAXN];
///i chestii , j capuri

int main()
{
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>probability[i];
    dp[1][0] = 1 - probability[1];
    dp[1][1] = probability[1];
    for(int i = 2; i <= n; i++){
        for(int j = 0; j <= i; j++){
            dp[i][j] += dp[i - 1][j] * (1 - probability[i]);
            dp[i][j + 1] += dp[i - 1][j] * probability[i];
        }
    }
    long double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    cout<<setprecision(10)<<fixed<<ans;
    return 0;
}


Measured memory_bytes: 139392
#include<iostream>
using namespace std;
int main(){
	int H=0,M=0,S=0,h=0,m=0,s=0;
	cin>>S;
	h=S/3600;
	if(h==0){
		h=0;
		}
	H=S%3600;
	m=H/60;
	if(m==0){
		m=0;
		}
	M=H%60;
	
	
	cout<<h<<":"<<m<<":"<<M<<endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if(a <= k){
	ans += a;
	k -= a;
    }else{
	P(k);
	ret 0;
    }

    if(b <= k){
	k -= b;
    }else{
	P(ans);
	ret 0;
    }

    P(ans - k);
    return  0;
}


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

int main() {
  int r,g,b;
  cin>>r>>g>>b;
  if((10*g+b)%4==0) {
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import Foundation

let x = Int(readLine()!)!
var ans = 0
for i in 2...31 {
  for j in 2...9 {
    let p = pow(Double(i), Double(j))
    if Int(p) <= x { ans = max(Int(p), ans) }
  }
}
print(x < 4 ? 1 : ans)

Measured memory_bytes: 13500