akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;
ll n, a, b;
ll h[111111];

int main() {
   cin >> n >> a >> b;
   rep (i, n) cin >> h[i];

   ll c = a - b;
   ll left = 0, right = INF;
   while (left+1 < right) {
      ll mid = (left+right) / 2;
      ll t = 0;
      rep (i, n) {
         ll x = max(h[i] - b * mid, 0LL);
         t += (x + c - 1) / c;
      }
      if (t<=mid) {
         right = mid;
      } else {
         left = mid;
      }
   }
   cout << right << endl;

   return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    private static int C = 1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int n = sc.nextInt(); n != 0; n = sc.nextInt())
            solve(n);
    }

    private static void solve(int n) {
        int[][] ns = new int[n][n];
        int inc = 1;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                for (int j = i; j >= 0; j--) {
                    ns[j][i-j] = inc++;
                }
            } else {
                for (int j = 0; j <= i; j++) {
                    ns[j][i-j] = inc++;
                }
            }
        }

        for (int i = n; i < 2 * (n - 1) + 1; i++) {
            if (i % 2 == 1) {
                for (int j = i - n + 1; j < n; j++) {
                    ns[j][i - j] = inc++;
                }
            } else {
                for (int j = n - 1; j >= i - n + 1 ; j--) {
                    ns[j][i - j] = inc++;
                }
            }
        }

        System.out.printf("Case %d:\n", C++);
        for (int[] as : ns) {
            for (int a : as) {
                System.out.printf("%3d", a);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26520
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
loop do
    ans = 0
    n, x = gets.chomp.split.map(&:to_i)
    break if (n+x).zero?
    (1..n).each do |a|
        (a+1..[n, x-a].min).each do |b|
            c = x-a-b
            ans += b < c && c<=n ? 1 : 0
        end
    end
    puts ans
end


Measured memory_bytes: 6860
//=================================
// Created on: 2018/07/04 15:12:12
//=================================
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (int N;;) {
        cin >> N;
        if (N == 0) { break; }
        vector<int> coeff1(10, 0);
        vector<int> coeff2(10, 0);
        set<int> nz;
        map<char, int> ind;
        for (int i = 0; i < N; i++) {
            string s;
            cin >> s;
            reverse(s.begin(), s.end());
            for (int j = 0, d = 1; j < s.size(); j++, d *= 10) {
                const char c = s[j];
                if (ind.find(c) == ind.end()) {
                    const int s = ind.size();
                    ind[c] = s;
                }
                const int in = ind[c];
                (i < N - 1 ? coeff1 : coeff2).at(in) += d;
                if (j == s.size() - 1 and s.size() > 1) { nz.insert(in); }
            }
        }
        assert(ind.size() <= 10);
        vector<int> num{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        int div = 1;
        for (int i = 0; i < 10 - (int)ind.size(); i++) { div *= (i + 1); }
        int ans = 0;
        do {
            bool ok = true;
            for (const int nzz : nz) {
                if (num[nzz] == 0) {
                    ok = false;
                    break;
                }
            }
            if (not ok) { continue; }
            int left = 0, right = 0;
            for (int i = 0; i < ind.size(); i++) { left += coeff1[i] * num[i], right += coeff2[i] * num[i]; }
            if (left == right) { ans++; }
        } while (next_permutation(num.begin(), num.end()));
        cout << ans / div << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
lf dist(ll x1,ll y1,ll x2,ll y2)
{
    return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n,0);
    for(ll i=0;i<n;i++)
        a[i]=i;
    vi x(n),y(n);
    for(ll i=0;i<n;i++)
        cin>>x[i]>>y[i];
    lf ans=0;
    do
    {
        lf d=0;
        for(ll j=0;j<n-1;j++)
        {
            ll i1=a[j];
            ll i2=a[j+1];
            d+=dist(x[i1],y[i1],x[i2],y[i2]);
        }
        ans+=d;
    }while(next_permutation(a.begin(),a.end()));
    while(n>1)
    {
        ans/=n;
        n--;
    }
    printf("%.8Lf\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int x,y; cin >> x >> y;
    rep(a,101) {
        rep(b,101) {
            if (2*a+4*b == y && a+b == x) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
main()
{
	char s1[10];
	char s2[10];
	char s3[10];
	scanf("%s",&s1);
	scanf("%s",&s2);
	scanf("%s",&s3);
	printf("%c%c%c",s1[0]-32,s2[0]-32,s3[0]-32);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int H,W;
	string S[60];

	cin>>H>>W;
	S[0]=S[W+1]="";
	
	FOR(i,1,H+1){
		cin>>S[i];
		S[i]='.'+S[i]+'.';
	}

	int tem;
	FOR(i,1,H+1){
		FOR(j,1,W+1){
			if(S[i][j]=='#'){
				tem=0;
				REP(r,4) if(S[i+dy[r]][j+dx[r]]=='#') tem++;
				if(tem==0){
					print("No");
					return 0;
				}
			}
		}
	}
	print("Yes");
	return 0;
}


Measured memory_bytes: 256
// abc149_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;
    
    int mx = max(max(a, b), c); 
    int mn = min(min(a, b), c);
 
    int ans = mx - mn;
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
   int n, k;
   cin >> n >> k;
   ll res = 0;
   for( int b = 1; b <= n; b++ ) {
       res += n/b*max(0, b-k);
       res += max(0, n%b-k+1);
   }
   if( k == 0 ) res -= n;
   dump(res);
   return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<ll> plus(0);
    vector<ll> minus(0);
    rep(i,N){
        if (vec[i] >= 0){
            plus.push_back(vec[i]);
        }
        else if (vec[i] < 0){
            minus.push_back(-1 * vec[i]);
        }
    }
    sort(all(plus));
    sort(all(minus));
    ll len_plus = plus.size();
    ll len_minus = minus.size();
    
    ll ans;
    
    if (N == K){
        ans = 1;
        rep(i,N){
            if (vec[i] >= 0) ans = (ans * vec[i]) % 1000000007;
            else ans = (ans * (1000000007 + vec[i])) % 1000000007;
        }
    }
    else if (len_plus == 0 && K % 2 == 1){
        ans = 1;
        rep(i,K){
            ans = (ans * (1000000007 - minus[i])) % 1000000007;
        }
    }
    else{
        ans = 1;
        ll plus_count = len_plus;
        ll minus_count = len_minus;
        while (K > 0){
            if (plus_count == 0){
                ans = (((ans * minus[minus_count - 1]) % 1000000007) * minus[minus_count - 2]) % 1000000007;
                minus_count -= 2;
                K -= 2;
            }
            else if (minus_count <= 1 || K == 1){
                ans = (ans * plus[plus_count - 1]) % 1000000007;
                plus_count -= 1;
                K -= 1;
            }
            else if (plus_count == 1 && minus_count >= 2 && K >= 2){
                ans = (((ans * minus[minus_count - 1]) % 1000000007) * minus[minus_count - 2]) % 1000000007;
                minus_count -= 2;
                K -= 2;
            }
            else{
                if (plus[plus_count - 1] * plus[plus_count - 2] > minus[minus_count - 1] * minus[minus_count - 2]){
                    ans = (ans * plus[plus_count - 1]) % 1000000007;
                    plus_count -= 1;
                    K -= 1;
                }
                else{
                    ans = (((ans * minus[minus_count - 1]) % 1000000007) * minus[minus_count - 2]) % 1000000007;
                    minus_count -= 2;
                    K -= 2;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


/*
* Problem : Tax Increase
* Acknowledgement : None
* Author : deathnaught_
* GitHub : www.github.com/DeathNaughT-GitHub
* Complexity : O(1)
*/

public class Main
{

    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n1 = (int) Math.ceil(A / .08);
        int n2 = (int) Math.ceil(B / .1);
        int d1 = (int) Math.floor(A / .08 + 12.5);
        int d2 = (int) Math.floor(B / .1 + 10);

        if (n1 >= d2 || n2 >= d1) {
            System.out.println("-1");
            return;
        }
        System.out.println(Math.max(n1, n2));
        
    }

    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

		boolean hasNext()
		{
		    return st == null ? false : true;
		}

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }
    } 

}

Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>

int digits(int x) {
  int digit = 1;
  while (9 < x) {
    digit++;
    x /= 10;
  }
  return digit;
}

int main(int ac, char **av) {
  unsigned int a, b = 0;
  while (feof(stdin) ==0 ) {
    fscanf(stdin, "%d %d\n", &a, &b);
    fprintf(stdout, "%d\n", digits(a+b));
  }
  
  return 0;
}

Measured memory_bytes: 612
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var li = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var max = li.Max();
            var sum = li.Sum();
            Console.WriteLine(sum - max > max ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a.at(i)>>b.at(i);
    rep(i,m) cin>>c.at(i)>>d.at(i);
    vector<vector<ll> > dist(n,vector<ll>(m));
    rep(i,n){
        rep(j,m){
            dist.at(i).at(j)=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
        }
    }
    
    rep(i,n){
        int ans;
        ll now=1000000000000000000;
        rep(j,m){
            if(now>dist.at(i).at(j)){
                now=dist.at(i).at(j);
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;

long long n, m;

int main()
{
    long long a[1000];
    for(int i = 0; i < 1000; i++) a[i] = 0;
    cin >> n >> m;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < m; j++){
            a[s[j]]++;
        }
    }
    long long q = 0;
    long long b = 0;
    long long u = 0;
    for(int i = 0; i < 1000; i++){
        q += a[i] / 4 * 4;
        a[i] %= 4;
        b += a[i] / 2 * 2;
        a[i] %= 2;
        u += a[i];
    }
    long long up = ((n % 2) && (m % 2));
    long long bp = (n % 2) * (m / 2 * 2) + (m % 2) * (n / 2 * 2);
    //cout << u << " " << b << " " << q << endl;
    //cout << up << " " << bp << " " << endl;
    if(u != up ||
       b > bp){
        cout << "No";
        return 0;
    }
    else{
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    set<char> a1;
    set<char> a2;
    char al1[15]={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
    char al2[11]={'Y','U','I','O','P','H','J','K','L','N','M'};
    rep(i,15){
        a1.insert(al1[i]);
    }
    rep(i,11){
        a2.insert(al2[i]);
    }

    string s;
    while(true){
        cin>>s;
        if(s.size()==1&&s[0]=='#')break;
        vector<int> v;
        rep(i,s.size()){
            if(a1.find(s[i])!=a1.end()){
                v.push_back(1);
            }else{
                v.push_back(2);
            }
        }

        int ans=0;
        for(int i=0;i<s.size()-1;i++){
           // cout<<v[i]<<endl;
            if(v[i]!=v[i+1])ans++;
        }


        cout<<ans<<endl;



    }


    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

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

	rep(i, 0, n + 1) {
		bool ok = true;
		rep(j, 0, n - i) {
			if (s[i + j] != t[j]) ok = false;
		}
		if (ok) {
			cout << i + n << endl;
			return 0;
		}
	}
	return 0;
}

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

#define tnum long long

#define loop(i,end) for(int i = 0; i < end; i++)

int main(int argc, char *argv[]) {
	int n, m;
	char s[103];
	bool flag = false;
	tnum res;

	scanf("%s", s);
	n = strlen(s);

	int p = n;
	
	loop(i, p / 2) {
		if (s[i] != s[p - 1 - i]) {
			flag = true;
			break;
		}

	}
	if (flag) {
		printf("No");
		return 0;
	}
	flag = false;

	p = n / 2;

	loop(i, p / 2) {
		if (s[i] != s[p - 1 - i]) {
			flag = true;
			break;
		}
	}
	if (flag) {
		printf("No");
		return 0;
	}
	flag = false;

	loop(i, p / 2) {
		if (s[i + n / 2 + 1] != s[n - 1 - i]) {
			flag = true;
			break;
		}
	}
	if (flag) {
		printf("No");
		return 0;
	}
	
	printf("Yes");

	return 0;
}

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        // cout << fixed << setprecision(20);
        // cerr << fixed << setprecision(20);
    }
} iosetup;

template <class Info>
struct edge {
    int from, to;
    Info info;
    edge(int to, Info info) : to(to), info(info) {}
    edge(int from, int to, Info info) : from(from), to(to), info(info) {}
};

struct normal_edge {
    normal_edge() {}
};

template <class Info>
class graph {
   protected:
    using edge_type = edge<Info>;
    ::std::size_t N;
    ::std::vector<::std::vector<edge_type>> edges;

   public:
    graph(::std::size_t N_) : N(N_), edges(N_) {}
    virtual void add_edge(int x, int y, Info info) = 0;
    const ::std::vector<edge_type> &delta(int v) const {
        assert(v < N);
        return edges[v];
    }
    const ::std::vector<edge_type> &operator[](int v) const {
        return this->delta(v);
    }
    ::std::size_t size() const { return N; }
};

template <class Info>
class undirected_graph : public graph<Info> {
   public:
    undirected_graph(::std::size_t N) : graph<Info>(N) {}
    void add_edge(int x, int y, Info info) {
        this->edges[x].push_back(edge<Info>(x, y, info));
        this->edges[y].push_back(edge<Info>(y, x, info));
    }
};

template <class Info>
class directed_graph : public graph<Info> {
   public:
    directed_graph(::std::size_t N) : graph<Info>(N) {}
    void add_edge(int x, int y, Info info) {
        this->edges[x].push_back(edge<Info>(x, y, info));
    }
};

template <class Info>
class bipartite_graph : public undirected_graph<Info> {
    ::std::size_t A;
    ::std::size_t B;

   public:
    bipartite_graph(::std::size_t A_, ::std::size_t B_)
        : A(A_), B(B_), undirected_graph<Info>(A_ + B_) {}
    void add_edge(int x, int y, Info info) {
        undirected_graph<Info>::add_edge(x, y + A, info);
    }
};

template <typename Info>
struct is_bipartite {
    vector<int> color;
    int white_cnt = 0, n;

    bool dfs(graph<Info> &g, int v, int prev, int c) {
        color[v] = c;
        if(c == 1) white_cnt++;
        for(auto nv : g[v]) {
            if(nv.to == prev) continue;

            if(color[nv.to] == -1) {
                if(!dfs(g, nv.to, v, 1 - c)) return false;
            } else if(color[nv.to] != 1 - c) {
                return false;
            }
        }
        return true;
    }

    int operator()(graph<Info> &g) {
        color.assign(g.size(), -1);
        if(!dfs(g, 0, -1, 0)) return -1;
        return white_cnt;
    }
};

int main() {
    int_fast64_t N, M;
    cin >> N >> M;
    undirected_graph<int> g(N);
    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        g.add_edge(A - 1, B - 1, 1);
    }
    int_fast64_t white_cnt = is_bipartite<int>()(g);
    if(white_cnt == -1)
        cout << N * (N - 1) / 2 - M << endl;
    else
        cout << white_cnt * (N - white_cnt) - M << endl;

    return 0;
}

Measured memory_bytes: 7424
#n=int(input())
n,k=map(int,input().split())
l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

if n<=k:
    print(0)
else:
    l.sort(reverse=True)
    print(sum(l[k:n]))


Measured memory_bytes: 26024
N = int(input())

INF = N
dp = [0, 1, 2, 3, 4, 5] + [INF for _ in range(N-5)]

for amount in range(6, N+1):
    dp[amount] = amount

    unit = 6
    while unit <= amount:
        dp[amount] = min(dp[amount], dp[amount-unit]+1)
        unit *= 6

    unit = 9
    while unit <= amount:
        dp[amount] = min(dp[amount], dp[amount-unit]+1)
        unit *= 9

print(dp[N])

Measured memory_bytes: 4632
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <time.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    char a[1000],b[1000];
    cin>>a>>b;
    int flag=0;
    if(strlen(a)>strlen(b))cout<<"GREATER"<<endl;
    else if(strlen(a)<strlen(b))cout<<"LESS"<<endl;
    else
    {
        for(int i=0;i<strlen(a);i++)
        {
            if(a[i]>b[i]){cout<<"GREATER"<<endl;return 0;}
            if(a[i]<b[i]){cout<<"LESS"<<endl;return 0;}
        }
        cout<<"EQUAL"<<endl;
    }
    return 0;
}





















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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

class MyException : public exception {};

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N-1; j++) {
      int x; cin >> x; x--;
      A.at(i).at(j) = x;
    }
  }
  auto enc = [&](int x, int y) {
    if (x > y) swap(x, y);
    return x * N + y;
  };
  vector<vector<int>> succ(N*N);
  auto reg = [&](int x, int y, int z) {
    int e1 = enc(x, y);
    int e2 = enc(x, z);
    succ.at(e1).push_back(e2);
  };
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N-2; j++) {
      reg(i, A.at(i).at(j), A.at(i).at(j+1));
    }
  }
  vector<int> visited(N*N, -1);
  function<int(int,int)> dfs = [&](int e, int p) {
    int r = visited.at(e);
    if (r >= 0) return r;
    if (r == -2) throw MyException();
    visited.at(e) = -2;
    int len = 0;
    for (int c : succ.at(e)) {
      if (c == p) continue;
      int z = dfs(c, e);
      len = max(len, z);
    }
    visited.at(e) = len + 1;
    return (len + 1);
  };
  int ans = 0;
  try {
    for (int i = 0; i < N; i++) {
      int z = dfs(enc(i, A.at(i).at(0)), -1);
      ans = max(ans, z);
    }
  }catch (const MyException& e) {
    ans = -1;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 47360
// Need to git gud and reach 1900+
#include <bits/stdc++.h>
using namespace std;

#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >

const int N = 2e6 + 7;
const int INF = 1e9 + 7;

ll a[N];
int n, m;

main(){ // If you don't know what to do, check the text box at the bottom
    cin >> n >> m;
    priority_queue < ll > pq;
    for (int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        pq.push(a[i]);
    }
    while (m--){
        ll it = pq.top();
        pq.pop();
        pq.push(it / 2);
    }
    ll ans = 0;
    while (!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    printf("%lld", ans);
}

/*
    Totally not inspired by BenQ's template
    Things you should do:
    1. Look for stupid typos in code e.g 1 instead of -1 etc
    2. Check if there is no infinite loops
    3. "Measure twice, cut once"
    4. Stay focused
*/


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

const int inf=1e9+5;

void solve()
{
    ll n,m,x;
    bool flag=false;
    cin>>n>>m>>x;
    vector<pair<ll,vector<ll>>> vp;
    for(ll i=0;i<n;i++)
    {
        pair<ll,vector<ll>> x;
        cin>>x.first;
        for(ll i=0;i<m;i++)
        {
            ll y;
            cin>>y;
            x.second.push_back(y);
        }
        vp.push_back(x);
    }
    ll ans=inf;
    for(ll i=0;i<(1<<n);i++)
    {
        vector<ll> b(m);
        ll sum=0;
        for(ll j=0;j<n;j++)
        {
            if(i & (1<<j))
            {
                sum+=vp[j].first;
                //cout<<vp[j].first<<" ";
                for(ll k=0;k<m;k++)
                    b[k]+=vp[j].second[k];
            }
        }
        //cout<<"\n";
        flag=false;
        for(ll k=0;k<m;k++)
        {
            if(b[k]<x)
            {
                flag=true;
                break;
            }
        }
        if(flag) continue;
        else ans=min(ans,sum);
    }
    if(ans==inf) cout<<"-1\n";
    else cout<<ans<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	std::string S;

	cin >> S;

	for (auto alphabet : S) {
		if (count(S.begin(), S.end(), alphabet) != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int n2 = n;
	map<int, int> ma;
	while (n--) {
		int dishes;
		cin >> dishes;
		while (dishes--) {
			int choice;
			cin >> choice;
			if (ma.count(choice) > 0 )
			{
				ma[choice]++;
			}
			else ma[choice] = 1;
		}
	}
	int ans = 0;
	for (auto item : ma) {
		if (item.second == n2) ans++;
		//cout << item.second << endl;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N = int(input())
    #h = list(map(int, input().split()))
    h = [int(x) for x in input().split()]
    inf = float("inf")
    dp = [inf]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)
    for i in range(1,N):
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if(i>1): #2つ目の足場には二個前の足場がないので．
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

    # #3:dp実行部(配るDP)
    # for i in range(N):
    #     if(i+1<N):
    #         dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
    #     if(i+2<N):
    #         dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))

    #4:出力
    print(dp[N-1])

if __name__ == '__main__':
    main()

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

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

typedef long long ll;

ll gcd(ll m, ll n) {
	if(m<n) return gcd(n, m);
	ll r = m%n;
	return (!r ? n : gcd(n, r));
}

int main() {
	ll a[3], m[3], c[3];
	while(1) {
		rep(i, 3) cin >> a[i] >> m[i];
		if(!a[0] && !m[0] &&!a[1] && !m[1] && !a[2] && !m[2]) break;
		rep(i, 3) {
			ll p = a[i] % m[i]; c[i] = 1;
			while(p != 1) p = (p * a[i]) % m[i], ++c[i];
		}
		ll g01 = gcd(c[0], c[1]), g12 = gcd(c[1], c[2]), g20 = gcd(c[2], c[0]);
		ll g = gcd(c[0], g12);
		cout << ( (c[0]*c[1]/g01) * c[2] / g12 / g20 * g) << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>

int main() {

  double d1,d2,d3,d4;
  int i,j,k,l,n;
  double x[1020] = {0};
  double y[1020] = {0};
  double z[1020] = {0};
  double o,p,q,max;
  max = -1;
  o=0;
  p=0;
  q=0;
  d1 = 0;
  d2 = 0;
  d3 = 0;
  d4 = 0;

  scanf("%d",&n);

  for(i=0; i<n; i++) {
    scanf("%lf",&x[i]);
  }

  for(i=0; i<n; i++) {
    scanf("%lf",&y[i]);
  }

  for(i=0; i<n;i++) {

    o = (x[i] - y[i]) * (x[i] - y[i]);
    p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    p = p*p;
    p = sqrt(p);
  
    d3 = d3 + p;
    d2 = d2+o;
    d1 = d1 + sqrt(o); 

    if(max < sqrt(o)) {
      max = sqrt(o);
    }

   
  }

  d2 = pow(d2,1.0/2);
  d3 = pow(d3,1.0/3);
  d4 = max;

  printf("%.11lf\n%.11lf\n%.11lf\n%.11lf\n" ,d1,d2,d3,d4);

  return 0;

}



Measured memory_bytes: 2112
#include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<string>
     
    typedef long long ll;
    int N,a,b,ans;
    int main(){
        scanf("%d",&N);
        a=(N/15)*200;
        b=N*800;
        ans=b-a;
        printf("%d",ans );
        return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long x;
  long temp = 0;
  long ans = 0;

  scanf("%ld", &x);

  for(long i = 0; ; i++){
    temp += i;
    if(temp >= x) {
      ans = i;
      break;
    }
  }

  printf("%ld", ans);
  return 0;
}

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

int main(){
    int N,K;
    cin>>N;
    cin>>K;
    vector<int> v;
    for(int i=0;i<N;i++){
        int temp;
        cin>>temp;
        v.push_back(temp);
    }
    sort(v.begin(),v.end(),greater<int>());
    int min=0;
    for(int i=0;i<K;i++){
        int temp= v.back();
        v.pop_back();
        min= min +temp;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <cmath>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}

int main()
{
	int n; cin >> n ;
	double x[4],y[4];
	while(n--)
	{
		for(int i=0;i<4;i++) cin >> x[i] >> y[i] ;
		double vx[2],vy[2];
		for(int i=0;i<2;i++) vx[i]=add(x[2*i+1],-x[2*i]), vy[i]=add(y[2*i+1],-y[2*i]);
		if(!add(vx[0]*vy[1],-vy[0]*vx[1])) cout << "YES" << '\n' ;
		else cout << "NO" << '\n' ;
	}
}

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

int n, i, j;
long long ans;

int main()
{
    scanf("%d", &n);
    vector<long long>a(n+1);
    for (i = 1; i <= n; i++) {
        for (j = i; j <= n; j += i) {
            a[j]++;
        }
    }
    for (i = 1; i <= n; i++) {
        ans += i*a[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 81332
class UnionFind:
    __slots__ = ["N", "root"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        """x, yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.root[y] < self.root[x]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.buffer.readline
n, q = map(int, input().split())
uf = UnionFind(n)
res = []
for _ in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.union(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 83576
import sys

N=list(map(int,(input().split())))
if N[0]==0:
    if N[1]>0:
        print(N[1])
        sys.exit()
    print(abs(N[1])+1)
    sys.exit()
if N[1]==0:
    if N[0]<0:
        print(abs(N[0]))
        sys.exit()
    print(abs(N[0])+1)
    sys.exit()
if N[1]==N[0]* -1:
    print(1)
    sys.exit()
if N[1]>N[0]:
    if (N[1]>0 and N[0]>0) or (N[1]<0 and N[0]<0):
        print(N[1]-N[0])
        sys.exit()
    print(abs(N[1]-abs(N[0]))+1)
if N[1]<N[0]:
    if (N[1]>0 and N[0]>0) or (N[1]<0 and N[0]<0):
       print(abs((N[0]-N[1]))+2)
       sys.exit()
    print(abs(N[0]-abs(N[1]))+1)


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

void Even(int n,vi a){
	int ans[2]{};
	REP(i,n)
		ans[i%2]+=a[i];
	if(ans[0]<ans[1])swap(ans[0],ans[1]);
	cout<<ans[0]<<" "<<ans[1]<<endl;
}

void Odd(int n,vi a){
	int ans[2]{};
	REP(i,n)
		ans[i%2]+=a[i];
	int l=0,r=n*1001;
	while(r-l>1){
		const int mid=(l+r)/2;
		int x=0,cur=0;
		bool ok=false;
		REP(i,n){
			if(i%2==0)
				cur+=a[i];
			else
				cur-=a[i];
			if(i%2==0){
				if(cur-x>=mid){
					if(i==n-1)
						ok=true;
					else
						chmin(x,cur-a[i+1]);
				}
			}
		}
		if(ok)l=mid;
		else r=mid;
	}
	cout<<ans[1]+l<<" "<<ans[0]-l<<endl;
}

signed main(){
	int n=read();
	vi a(n);REP(i,n)a[i]=read();
	if(n%2==0)Even(n,a);
	else Odd(n,a);
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;



public class Main {

	
	
	public static void main(String[] args) throws IOException{
    
	int[] mountainList = new int[10];
	
	String line = "";
		
	
	BufferedReader br = null;
			
	try {
		br = new BufferedReader(new InputStreamReader(System.in));
		for(int i = 0;i<10;i++){
			line = br.readLine();
			mountainList[i] = Integer.parseInt(line);
				
		}
		
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	Arrays.sort(mountainList);
	for(int j=0;j>-3;j--){
		System.out.println(mountainList[j+9]);
		
	}
	}

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int x,y;
    cin>>x>>y;
    if(x==0){
        if(y==0){
            cout<<0<<endl;
        }else if(y<0){
            cout<<1+abs(x-y)<<endl;
        }else{
            cout<<abs(x+y)<<endl;
        }
    }else if(x<0){
        if(y==0){
            cout<<abs(x)<<endl;
        }else if(y<0){
            if(x<=y){
                cout<<y-x<<endl;
            }else{
                cout<<2+x-y<<endl;
            }
        }else{
            cout<<1+abs(x+y)<<endl;
        }
    }else{
        if(y==0){
            cout<<1+abs(x)<<endl;
        }else if(y<0){
            cout<<1+abs(x+y)<<endl;
        }else{
            if(x<=y){
                cout<<y-x<<endl;
            }else{
                cout<<2+x-y<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256