akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll pos;
  ll depth;
} data;
//
// struct Node{
//
// }



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }





int main() {

  string s,t;
  cin >>s>>t;

  ll sn = s.size();
  ll tn = t.size();

  vvint dp(sn+1, vint(tn+1, 0));

  string ans = "";

  rep(i, sn){
    rep(j, tn){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
        // ans += s[i];
      }else{
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
  }


  ll i = sn-1;
  ll j = tn-1;

  while(i>=0 && j>=0){
    if(dp[i+1][j+1]>dp[i+1][j] && dp[i+1][j+1]>dp[i][j+1]){
      ans = s[i] + ans;
      i--;j--;
    }else if(dp[i][j+1]>dp[i+1][j]){
      i--;
    }else{
      j--;
    }
  }

  // repr(i, sn){
  //   repr(j, tn){
  //     if(dp[i+1][j+1]>dp[i+1][j] && dp[i+1][j+1]>dp[i][j+1]){
  //       ans = s[i] + ans;
  //     }else if(dp[i][j+1]>dp[i+1][j]){
  //
  //     }
  //   }
  // }


  cout << ans << endl;

}

















//


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

int main(){

    while(1){
        int n;
        int M = 0;
        int s[1000]={0};
        double a,m,t;
        double T = 0;

        cin >> n;
        if(n == 0){
            break;
        }
        for(int i=0 ; i<n ; i++){
            cin >> s[i];
            M += s[i];
        }
        m = (double)M / n;

        for(int i = 0 ; i<n ; i++){
            //tは得点ー平均の2乗,Tはそれの合計
            t = (s[i] - m) * (s[i] - m);
            T += t;
            t = 0;
        }
        a = sqrt(T / n);
        cout << fixed << setprecision(8) << a << endl;

    }
}


Measured memory_bytes: 3228
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	ll n=s.size();
	if(n&1)
	{
		cout<<"No";
		return 0;
	}
	for(ll i=0;i<n;i+=2)
	{
		if(s[i]!='h' || s[i+1]!='i')
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
    return 0;
}


//252908XL

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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}
int sum(vector<int> arr){int cnt = 0;rep(i,0,arr.size()){cnt += arr[i];}return cnt;}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}

//main------------------------------------------------------------------------------------------



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

    
    int n = input();

    vector<int> arr;
    while(n > 0){
        arr.push_back(n%10);
        n /= 10;
    }
    reverse(arr.begin(), arr.end());
    int t = arr[0];
    
    rep(i,1,arr.size()){
        if(arr[i] > t){
            t++;
            break;
        }else if(arr[i] < t) break;
    }

    rep(i,0,arr.size()){
        cout << t;
    }
    cout << endl;
    





    




}

Measured memory_bytes: 256
n,k = map(int,input().split())

a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])
su = 0
for i in range(n-1):
    if b[i] >= k:
        su += k
    else:
        su += b[i]
print(su+k)

Measured memory_bytes: 98896
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    vec(b,n);
    b[0] = 0;
    int tmp = a[0];
    FOR(i,1,n){
        b[i] = tmp * 2;
        tmp = a[i] - tmp;
    }
    int sa = a[n-1]-(b[n-1]/2);
    REP(i,n){
        if(i%2==0){
            cout << b[i]+sa << " ";
        }
        else{
            cout << b[i]-sa << " ";
        }
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

ll n;
ll en = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {

		int u, v;
		cin >> u >> v;
		if (v < u)
			swap(u, v);
		en += (ll) u * (n - v + 1);
	}

	cout << n * (n * n + 3 * n + 2) / 6 - en << endl;

}


Measured memory_bytes: 3612
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t x,y,z;
  int32_t N;
  cin >> N;
  vector<int32_t> cnt(N,0);
  for (x = 1; x * x < N; x++) {
    if (x * x + x + 4 > N) continue;
    for (y = 1; y * y < N; y++) {
      if (x * x + y * y + x + y + x * y + 1 >  N) continue;
      for (z = 1; z * z < N; z++) {
        int32_t sum = x*x + y*y + z*z + x*y + y*z + z*x;
        if (sum > N) continue;
        cnt[sum-1]++;
      }
    }
  }
  for (auto c : cnt) {
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,j,k,l,t,a,b,c,d;
    scanf("%lld %lld %lld",&n,&i,&j);
    k=abs(i-j);
    t=k/2;
    l=k%2;
    if(l==0)
        printf("%lld\n",t);
    else{
    a=max(i-1,j-1);
    b=max(n-i,n-j);
    c=min(a,b);
    a=n-j;
    a+=t+1;
    b=i-1;
    b+=t+1;
    b=min(b,a);
    d=min(c,b);
    printf("%lld",d);
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]D = new int[N];
		string[]str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			D[i] = int.Parse(str2[i]);
		}
		long ans = 0;
		for(var i=-1;i<N;i++){
			for(var j=i+1;j<=N;j++){
				int ct = i+1+N-j;
				if(ct>K){
					continue;
				}
				var list = new List<int>();
				long a = 0;
				for(var k=0;k<=i;k++){
					list.Add(D[k]);
					a += D[k];
				}
				for(var k=N-1;k>=j;k--){
					list.Add(D[k]);
					a += D[k];
				}
				list.Sort();
              	int ct2 = ct;
				if(ct<K){
					for(var k=ct;k<Math.Min(K,ct2*2);k++){
						if(list[k-ct]>=0){
							break;
						}
						a -= list[k-ct];
					}
				}
				ans = Math.Max(a,ans);
			}
		}
      Console.WriteLine(ans);
	}
}

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

using namespace std;
int dizi[100005];
int main(){
	int a;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>dizi[i];
	}
	for(int i=a-1;i>=1;i--){
		if(dizi[i]<dizi[i-1]){
			dizi[i-1]--;
		}
		if(dizi[i]<dizi[i-1]){
			cout<<"No";
			return 0;
		}
		
	}
	cout<<"Yes";
	
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    string s;
    string one;
    string zero;
    int zero_one = 0;
    int one_zero = 0;

    cin >> s;
    int n = s.size();

    for(int i = 0; i < n; i ++) {
        if((i%2) != 0) {/*odd*/ 
            if(s[i] == '1')  { zero_one++; }
            if(s[i] == '0')  { one_zero++; }         

        } else {/*even*/
            if(s[i] == '0')  { zero_one++; }
            if(s[i] == '1')   { one_zero++; }         
        }
    }
    cout << n - max(zero_one, one_zero) << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    set<string>s;
    string a;
    while(n--)
    {
        cin >> a;
        
        s.insert(a);
    }
    
    cout << s.size();
    
    
    
}

Measured memory_bytes: 19116
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

set <string> opa;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int n = (int) s.length();

    for (int i = 0; i < n; i++)
    {
        string str = "";
        for (int j = i; j < min(n, i + k); j++)
        {
            str += s[j];
            opa.insert(str);
            if ((int) opa.size() > k) opa.erase(*opa.rbegin());
        }
    }
    cout << *opa.rbegin();
    return 0;
}


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

int n, m;
map<int, vector<int>> mp;
vector<int> min_dist;

int bfs(int start) {
  queue<pair<int, int>> que;

  vector<bool> reached(n + 1);
  min_dist[start] = 0;
  if (mp[start].size() == 0) return -1;
  else {
    que.push(make_pair(start, 0));
    reached[start] = true;
    min_dist[start] = 0;
  }

  while(!que.empty()) {
    pair<int, int> curr = que.front();
    que.pop();
    int pos = curr.first;
    int dist = curr.second;

    if (mp[pos].size() == 0) continue;

    for (int i = 0; i < mp[pos].size(); i++) {
      if (reached[mp[pos][i]]) continue;

      que.push(make_pair(mp[pos][i], dist+1));
      reached[mp[pos][i]] = true;
      min_dist[mp[pos][i]] = dist+1;
    }
  }

  return 0;
}

void solver() {
  cin >> n >> m;
  min_dist = vector<int>(n+1, -1);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    mp[a].push_back(b);
    mp[b].push_back(a);
  }

  bfs(1);
  bool imps = false;
  for (int i = 1; i <= n; i++) {
    if (min_dist[i] == -1) {
      imps = true;
      break;
    }
  }

  if (imps) {
    cout << "No" << "\n";
  } else {
    cout << "Yes\n";
    for (int i = 2; i <= n; i++) {
      int min_dist_ = 10000000;
      int min_next = -1;
      for (int j = 0; j < mp[i].size(); j++) {
        if (min_dist[i] == min_dist[mp[i][j]] + 1) {
          min_dist_ = min_dist[mp[i][j]];
          min_next = mp[i][j];
          break;
        }
      }
      cout << min_next << "\n";
    }
  }
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 16112
#pragma GCC optimize("O3")

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

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

int main(){
  ios; cfs(15);
  int cnt = 0;
  INT(n);
  rep(i,n) {
    int a;
    cin>>a;
    if((i+1)&1 && (a&1)) ++cnt;
  }
  cout<<cnt<<endl;
  ret;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

int main() {

   int N;
   scanf("%d", &N);
   int ans = 0;
   while (ans < N) {
      ans += 1000;
   }
   ans -= N;
   printf("%d\n", ans);

   return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int e;
  while(cin >> e, e) {
    int res = (int)1e9;
    for(int z = 0; z * z * z <= e; z++) {
      for(int y = 0; z * z * z + y * y <= e; y++) {
        int x = e - (z * z * z + y * y);
        res = min(res, z + y + x);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

string s;
int i;
bool f[256];

bool imp(bool x, bool y){
	if ( x &&  y)return true;
	if ( x && !y)return false;
	if (!x &&  y)return true;
	if (!x && !y)return true;
}

bool form(){
	
	if (s[i] == 'T'){ i++; return true; }
	if (s[i] == 'F'){ i++; return false; }

	if (s[i] >= 'a' && s[i] <= 'k'){
		bool r = f[s[i]]; i++;return r;
	}else
	if (s[i] == '-'){
		i++; return !form();
	}else
	if (s[i] == '('){
		i++; bool c = form();

		if (s[i] == '*'){
			i++;  bool tc = form(); i++; return tc && c;
		}
		if (s[i] == '+'){
			i++;  bool tc = form(); i++; return tc || c;
		}
		if(s[i] == '-' && s[i+1] == '>')
		{
			i+=2; bool tc = form(); i++; return imp(c,tc);
		}
	}
}

bool equation(){
	i = 0;
	bool t = form();i++;
	return t == form();
}

bool dfs(int n){

	if (n == 'k' + 1){
		return equation();
	}
	f[n] = true;
	bool ret = dfs(n+1);
	f[n] = false;
	return ret && dfs(n + 1);
}


int main()
{

	while (cin >> s && s != "#"){
		memset(f,0,256*sizeof(bool));
		s += " ";
		if (dfs('a'))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    lint a, b, n; cin >> a >> b >> n;
    if(b == 1){
        out(0); return 0;
    }
    out(a*min(b-1,n)/b);
}

Measured memory_bytes: 3592
n=int(input())
XY=[list(map(int,input().split())) for _ in range(n)]
fact1,fact2=1,1
for i in range(1,n+1):
    fact1*=i
for i in range(1,n):
    fact2*=i
dist=0
for i in range(n):
    for j in range(i+1,n):
        dist+=((XY[i][0]-XY[j][0])**2+(XY[i][1]-XY[j][1])**2)**0.5
dist*=2*fact2
dist/=fact1
print(dist)

Measured memory_bytes: 38472
import scala.collection.mutable
import scala.io.Source.stdin

object Main extends App {

  val lines = stdin.getLines()
  val xs = {
    val nums = ('a' to 'z').map { (_, 0) }

    val m = mutable.Map(nums: _*)
    for {
      line <- lines
      c    <- line.map { _.toLower }
      if c.isLetter && c <= 'z'
    } {
      m(c) += 1
    }
    m.toSeq.sorted
  }

  for ((k, v) <- xs) {
    println(s"$k : $v")
  }
}



Measured memory_bytes: 44708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
 
  ll ans = K;
  if (N >= 2) {
    for (int i = 0; i < (N - 1); i++) {
      ans = ans * (K - 1);
    }
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 3640
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Feb  5 11:09:44 2019
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	a1 := make([]int, N)
	for i := range a1 {
		fmt.Scan(&a1[i])
	}

	a2 := make([]int, N)
	for i := range a2 {
		fmt.Scan(&a2[i])
	}

	for i := range a1 {
		if i+1 < len(a1) {
			a1[i+1] += a1[i]
			a2[i+1] += a2[i]
		}
	}

	ans := 0
	for i := 0; i < len(a1); i++ {
		var n int
		if i == 0 {
			n = a1[0] + a2[len(a2)-1]
		} else {
			n = a1[i] + a2[len(a2)-1] - a2[i-1]
		}
		if ans < n {
			ans = n
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var ks = IO.ReadSplitInt;
            int cnt = 0;
            for (int i = 0; i <= ks[0]; i++)
            {
                for (int j = 0; j <= ks[0]; j++)
                {
                    if (ks[1] - i - j >= 0 && ks[1] - i - j <= ks[0])
                        cnt++;
                }
            }
            WriteLine(cnt);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static int GCD(int x, int y)
        {
            if (x < y) Swap(ref x, ref y);
            if (y == 0) return x;
            else return GCD(x % y, y);
        }

        public static void Swap(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 11348
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a, b, c = L[i], L[j], L[k]
            if a!=b and b!=c and c!=a and a+b>c and b+c>a and c+a>b:
                ans += 1
print(ans)


Measured memory_bytes: 9128
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int sx = sc.nextInt();
	int sy = sc.nextInt();
	int tx = sc.nextInt();
	int ty = sc.nextInt();
	StringBuilder sb = new StringBuilder();
	int w = Math.abs(sx-tx);
	int h = Math.abs(sy-ty);
	for ( int i = 0; i < h; i++ ) {
	    sb.append("U");
	}
	for ( int i = 0; i < w+1; i++ ) {
	    sb.append("R");
	}
	for ( int i = 0; i < h+1; i++ ) {
	    sb.append("D");
	}
	for ( int i = 0; i < w+1; i++ ) {
	    sb.append("L");
	}
	sb.append("U");

	//2
	sb.append("L");
	for ( int i = 0; i < h+1; i++ ) {
	    sb.append("U");
	}
	for ( int i = 0; i < w+1; i++ ) {
	    sb.append("R");
	}
	for ( int i = 0; i < h+1; i++ ) {
	    sb.append("D");
	}
	for ( int i = 0; i < w; i++ ) {
	    sb.append("L");
	}
	String str = sb.toString();
	System.out.println(str);
    }
}


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

#define llint long long int

using namespace std;

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

    cin >> A >> B >> C >> K;

    int k = 0;

    for (; k <= K; k++)
    {
        if (B > A)
        {
            for (; k <= K; k++)
            {
                if (C > B)
                {
                    cout << "Yes" << endl;

                    return 0;
                }
                C *= 2;
            }
        }
        B *= 2;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
a[100],c[100],p,v,i,j,n,m;main(k){for(;~scanf("%d%d",n?(i<n?a:c-n)+i++:&n,m?(i<n?a:c-n)+i+50:&m););for(;j<n;printf("%d\n",p,j++))for(v=1e9,i=0;i<m;v>k?p=i,v=k:0)k=abs(a[j]-c[i])+abs(a[j+50]-c[50+i++]);}

Measured memory_bytes: 128
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, s, C = input().split()

    print(A[0] + s[0] + C[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 10292
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ll N=2e5+5;
ll n,q;
vector<vi>v(N);
ll val[N];

void dfs(ll a,ll b){
    val[a]+=val[b];
    for(auto x:v[a]){
        if(x!=b)dfs(x,a);
    }
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q;
    mset(val);
    for(int i=0;i<n-1;i++){
        ll a,b;cin>>a>>b;
        v[a].pb(b);v[b].pb(a);
    }
    for(int i=0;i<q;i++){
        ll a,b;cin>>a>>b;
        val[a]+=b;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)cout<<val[i]<<" ";
}


Measured memory_bytes: 24320
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;



int main(){

  int n,k,q; cin >> n >> k >> q;
  vector<int> a(q);
  for (int i=0; i<q; i++){cin >> a[i];}
  vector<int> AC(n,0);

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

  for (int i=0; i<n; i++){
    if (k-q+AC[i]>0){cout << "Yes" << endl;}
    else {cout << "No" << endl;}
  }


  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vi DIJ(int s){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int n;

int main(){
	cin>>n;
	Graph g(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g.add_edge(u-1,v-1,1);
	}
	vi d=g.DIJ(0);
	int M=-1,v;
	for(int i=0;i<n;i++) if(d[i]>M) M=d[i],v=i;
	d=g.DIJ(v);
	M=-1;
	for(auto i:d) M=max(M,i);
	cout<<(M%3==1?"Second":"First")<<endl;
}

Measured memory_bytes: 17876
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;

  double ans = (double)(W)*H / 2;

  cout << fixed << setprecision(10) << ans << " ";
  if (2 * x == W && 2 * y == H) {
    cout << 1;
  } else {
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e6+100;
const int MAXM = 1e5;
int a[MAXN];
int main(){
	int n,A,b;
	cin>>n>>A>>b;
	for(int i=1;i<=n;i++) cin>>a[i];
	int n1,n2,n3;
	n1=n2=n3=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=A) n1++;
		else if(a[i]>A&&a[i]<=b) n2++;
		else n3++;
	}
//	cout<<n1<<" "<<n2<<" "<<n3<<endl;
	cout<<min(n1,min(n2,n3))<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
    int n,b,i,j,x;
    cin >> n;
    int cards[4][13]={0};
    char a;
    for (x=0;x<n;x++){
        cin >> a >> b;
        switch(a){
            case 'S':
                cards[0][b-1]=1;
                break;
            case 'H':
                cards[1][b-1]=1;
                break;
            case 'C':
                cards[2][b-1]=1;
                break;
            case 'D':
                cards[3][b-1]=1;
                break;
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(cards[i][j]==0){
                switch(i){
                    case 0:
                        cout << "S " << j+1 << endl;
                        break;
                    case 1:
                        cout << "H " << j+1 << endl;
                        break;
                    case 2:
                        cout << "C " << j+1 << endl;
                        break;
                    case 3:
                        cout << "D " << j+1 << endl;
                        break;
                }
            }
        }
    }
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int q;
  cin >> s >> q;
  
  vector<char> x, y;
  int count = 0;
  for (int i = 0; i < q; i++) {
    int z;
    cin >> z;
    if (z == 1) {
      count++;
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if ((f + count) % 2 == 1) {
        x.push_back(c);
      }
      else {
        y.push_back(c);
      }
    }
  }
  
  if (count % 2 == 0) {
    for (int i = x.size() - 1; i >= 0; i--) {
      cout << x.at(i);
    }
    cout << s;
    for (int i = 0; i < y.size(); i++) {
      cout << y.at(i);
    }
    cout << '\n';
  }
  else {
    reverse(s.begin(), s.end());
    for (int i = y.size() - 1; i >= 0; i--) {
      cout << y.at(i);
    }
    cout << s;
    for (int i = 0; i < x.size(); i++) {
      cout << x.at(i);
    }
    cout << '\n';
  }
}

Measured memory_bytes: 976
def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n+1)]
    hl = [[] for i in range(n+1)] 
    h = [0]
    h.extend(list(map(int, input().split())))
    for i in range(m):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)
    g[0].append(0)
    for i, gi in enumerate(g):
        for j, gj in enumerate(gi):
            if gj is None:
                continue
            hl[i].append(h[gj])
    max_hl = list()
    for i in hl:
        if i == []:
            max_hl.append(0)
        else:
            max_hl.append(max(i))
    res = len([x - y for (x, y) in zip(h, max_hl) if x - y > 0 ])
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 43344
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; }
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    int a = v[n/2-1];
    int b = v[n/2];
    cout << b - a << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);

    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll total = 0;
    int cnt = 0;
    rep(i, N)
    {
        if (i == 0)
        {
            cnt = min(A[0], B[0]);
            total += cnt;
        }
        else
        {
            cnt = min(A[i] - cnt, B[i]);
            total += cnt;
        }

        cnt = max(min(A[i + 1], B[i] - cnt), 0);
        total += cnt;
    }
    cout << total << endl;

 //   system("pause");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

int main() {
	int n, *st;
	double dev, avr, var;
	std::cin >> n;
	while (n) {
		dev = avr = var = 0.0;
		st = new int[n];
		for (int i=0; i<n; i++) {
			std::cin >> st[i];
			avr += st[i] / (double)n;
		}
		for (int i=0; i<n; i++) {
			var += (avr - st[i]) * (avr - st[i]) / n;
		}
		dev = sqrt(var);
		std::cout << dev << std::endl;
		delete[] st;
		std::cin >> n;
	}
}

Measured memory_bytes: 1268
#include <iostream>
#include <stdio.h>

using namespace std;

typedef struct Card{
    char mark;
    int number;
    int flag;
} C;

int main(){
    C cards[52];
    int n;
    char str;
    int x;
    
    for(int i = 0; i < 52; i++){
        if(i < 13){
            cards[i].mark = 'S';
            cards[i].number = i + 1;
            cards[i].flag = 0;
        }
        else if(i > 12 and i < 26){
            cards[i].mark = 'H';
            cards[i].number = i - 12;
            cards[i].flag = 0;
        }
        else if(i > 25 and i < 39){
            cards[i].mark = 'C';
            cards[i].number = i - 25;
            cards[i].flag = 0;
        }
        else{
            cards[i].mark = 'D';
            cards[i].number = i - 38;
            cards[i].flag = 0;
        }
    }
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> str >> x;
        for(int j = 0; j < 52; j++){
            if(cards[j].mark == str and cards[j].number == x){
                cards[j].flag = 1;
            }
        }
    }

    for(int i = 0; i < 52; i++){
        if(cards[i].flag  == 0){
            printf("%c %d\n", cards[i].mark, cards[i].number);
        }
    }

    return 0;
}




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

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

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

char s[2100][2100];
int sm[2100][2100];
int smv[2100][2100];
int smh[2100][2100];
int n, m, q;

int gh(int x, int y) {
	if (y == m - 1)
		return 0;
	if (s[x][y] == '1' && s[x][y + 1] == '1')
		return 1;
	return 0;
}

int gv(int x, int y) {
	if (x == n - 1)
		return 0;
	if (s[x][y] == '1' && s[x + 1][y] == '1')
		return 1;
	return 0;
}

int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < n; ++i) {
		scanf(" %s", s[i]);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j)
			sm[i + 1][j + 1] = sm[i + 1][j] + sm[i][j + 1] - sm[i][j] + (s[i][j] - '0');
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j)
			smh[i + 1][j + 1] = smh[i + 1][j] + smh[i][j + 1] - smh[i][j] + gh(i, j);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j)
			smv[i + 1][j + 1] = smv[i + 1][j] + smv[i][j + 1] - smv[i][j] + gv(i, j);
	}
	for (int i = 0; i < q; ++i) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		--x1, --y1;
		int ans = 0;
		ans += sm[x2][y2] - sm[x1][y2] - sm[x2][y1] + sm[x1][y1];
		ans -= smh[x2][y2 - 1] - smh[x1][y2 - 1] - smh[x2][y1] + smh[x1][y1];
		ans -= smv[x2 - 1][y2] - smv[x1][y2] - smv[x2 - 1][y1] + smv[x1][y1];
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 57600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

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

    cout << 3.141592 * 2 * R << endl;
    return 0;
}


Measured memory_bytes: 3784
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Splitting Pile
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

typedef long long ll;
const ll LINF = 1LL << 60;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &as[i]);
    sum += as[i];
  }

  ll mind = LINF;
  ll x = 0, y = sum;
  for (int i = 0; i < n - 1; i++) {
    x += as[i], y -= as[i];
    ll d = abs(x - y);
    if (mind > d) mind = d;
  }

  printf("%lld\n", mind);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int tmp1=0,tmp2=0;
    int counter=0;
    int maxi=0;
    for(int i=0;i<N;i++){
        cin >> tmp1;
        if(tmp1<=tmp2){
            counter++;
            if(counter>=maxi)maxi=counter;
        }else{
            counter=0;
        }
        tmp2=tmp1;
    }
    cout << maxi <<endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;

  ll su = 1;
  ll i = 1;
  while(1) {
    if(su >= n) {
      while(n > 0) {
        if(i <= n) {
          cout << i << endl;
          n -= i;
        }
        i--;
      }
      break;
    } else {
      i++;
      su += i;
    }
  }
}


Measured memory_bytes: 256
N = int(input())
h = [0] + list(map(int,input().split()))

dp = [0] * (N+1)
dp[2] = abs(h[2]-h[1])

for i in range(3,N+1):
    jump1 = dp[i-1] + abs(h[i]-h[i-1])
    jump2 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(jump1,jump2)
    
print(dp[N])

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

int main(){
	int x; scanf("%d", &x); printf("%d\n", x ^ 1);
	return 0;
}


Measured memory_bytes: 3780
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    vok();
    int n,m;
    IN n>>m;
    vector<int> v(n,-1);
    if(n==1 && m==0)
    {
        OUT 0<<endl
        return 0;
    }
    loop(i,0,m)
    {
        int temp;
        IN temp;
        temp--;
        int num;
        IN num;
        if(v[temp]!=-1 && num!=v[temp])
        {
            OUT -1<<endl
            return 0;
        }
        v[temp]=num;
    }
    if(v[0]==0)
    {
        if(n==1)
        {
            OUT 0<<endl
        }
        else
        {
            OUT -1<<endl
        }
    }
    else
    {
        loop(i,0,n)
        {
            if(v[i]==-1)
            {
                if(i==0)
                {
                    OUT 1;
                }
                else
                {
                    OUT 0;
                }
            }
            else
            {
                OUT v[i];
            }
        }
        OUT endl
    }
    //OUT endl
    return 0;
}


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

int main(){
  int n,m,a;
  cin >> n;
  vector<int> v(n);
  r(i,n){
    cin >> v.at(i);
  }
  cin >> m;
  while(m--){
    cin >> a;
    cout << lower_bound(v.begin(),v.end(),a)-v.begin()<<endl;
  }
  
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>-
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define clr(a,x) memset(a,x,sizeof(a))
#define input(x) freopen(x".in","r",stdin)
#define output(x) freopen(x".in"",w",stdout)
#define file(x) input(x),output(x)
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int n,k,last,x;
ll ans=0;

int main(){
	scanf("%d%d",&n,&k);
	ans=(ll)n*k;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(i>1) ans-=max(0,k-x+last);
		last=x;
	}
	printf("%d\n",(int)ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(-a==b){
		printf("0\n");
	}
	if(-a>b){
		printf("-1\n");
	}
	if(-a<b){
		printf("1\n");
	}
	return 0;
}


Measured memory_bytes: 2616