akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 1e5 + 5;
vector <int> adj[MAX], w[MAX];
int mark[MAX], counter[MAX];
bool vis[MAX];

vector <int> v;
void dfs(int x)
{
	vis[x] = true;
	v.pb(x);
	for(auto v : adj[x]) {
		if(!vis[v])
		dfs(v);
	}
}
int main()
{
	boost;
	int n, m, k, a, b, i;
	cin >> n >> m >> k;
	fo(i, 0, m) {
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	fo(i, 0, k) {
		cin >> a >> b;
		w[a].pb(b);
		w[b].pb(a);
	}
	int cnt = 0;
	foe(i, 1, n) {
		if(!vis[i]) {
			dfs(i);
			for(auto x : v)
			mark[x] = cnt;
			++cnt;
			int sz = (int)v.size();
			for(auto x : v)
			counter[x] = sz - 1;
			v.clear();
		}
	}
	vector <int> ans;
	foe(i, 1, n) {
		int curr = counter[i];
		for(auto x : adj[i])
		curr--;
		
		for(auto x : w[i]) {
			if(mark[x] == mark[i])
			--curr;
		}
		ans.pb(curr);
	}
	for(auto x : ans)
	cout << x << ' ';
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

set<pair<ll, ll> > s;

ll tur[600005];
ll a[200005];
ll off = 1;

void update1(ll node, ll val) { 
	tur[node] = val;
}

void update(ll x, ll y, ll l, ll r, ll node, ll val) {
	if (l >= x and r <= y) {
		tur[node] -= val;
		return ;
	}
	if (r < x or l > y) return ;
	update(x, y, l, (l+r)/2LL, node*2LL, val);
	update(x, y, (l+r)/2LL+1LL, r, node*2LL+1LL, val);
}

ll query(ll node, ll l, ll r, ll pos) {
	if (l == node and r == node) return tur[pos];
	if (l>node or r<node) return 0LL;
	tur[pos*2LL] += tur[pos];
	tur[pos*2LL+1LL] += tur[pos];
	tur[pos] = 0LL;
	return query(node, l, (l+r)/2LL, pos*2LL) + query(node, (l+r)/2LL+1LL, r, pos*2LL+1LL);
}

int main() {
	ll n, d, dem;
	scanf("%lld%lld%lld", &n, &d, &dem);
	for (ll i=0 ; i<n ; i++) {
		ll x, h;
		scanf("%lld%lld", &x, &h);
		s.insert(mp(x, i));
		a[i] = h;
	}
	while (off <= n) off*=2LL;
	ll ind = 0LL;
	set <pair<ll, ll> > s2;
	for (set<pair<ll, ll> > :: iterator it = s.begin() ; it!=s.end() ; it++) {
		update1(off+ind, a[it->second]);
		s2.insert(mp(it->first, ind));
		ind++;
	}
	s = s2;
	ll sol = 0LL;
	while (s.size()) {
		set <pair<ll, ll> > :: iterator it = s.end();
		it--;
		while (query(it -> second, 0LL, off-1LL, 1LL) <= 0LL) {
			//cout <<"..."<<it->first<<" "<<it->second<<endl;
			//cout <<"kveri: "<<query(it -> second, 0, off-1, 1)<<endl;
			s.erase(it);
			if (s.size() == 0LL) break;
			it = s.end();
			it--;
		}
		if (s.size() == 0) break;
		ll cnt = (query(it -> second, 0LL, off-1LL, 1LL) + dem-1LL) / dem;
		//cout <<"cnt = "<<cnt<<endl;
		sol += cnt;
		int l = s.lower_bound(mp(it->first - 2LL*d, 0LL)) -> second;
		update(l, it->second, 0LL, off-1LL, 1LL, cnt*dem);
	}
	printf("%lld\n", sol);
	return 0;
}

Measured memory_bytes: 31360
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    int a=0,b=0,c=0;
    char next_turn;
    while(a<=s1.size() && b<=s2.size() && c<=s3.size()){
        if(a==0&&b==0&&c==0){
            next_turn = s1[a];
            a++;
            continue;
        }
        if(next_turn == 'a'){
            next_turn = s1[a];
            a++;
            continue;
        }
        if(next_turn == 'b'){
            next_turn = s2[b];
            b++;
            continue;
        }
        if(next_turn == 'c'){
            next_turn = s3[c];
            c++;
            continue;
        }
    }
    if(a>s1.size()) cout<<"A"<<endl;
    else if(b>s2.size()) cout<<"B"<<endl;
    else cout<<"C"<<endl;
}

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

using namespace std;

int main()
{
	int N, T;
  	cin >> N >> T;
  	vector<int> c(N), t(N);
  	for(int i = 0; i < N; i++){
      cin >> c.at(i) >> t.at(i);
    }
  	int ans = c.at(0), x = 0;
  	for(int i = 0; i < N; i++){
      if(t.at(i) <= T){
        x++;
        if(c.at(i) <= ans){
          ans = c.at(i);
        }
      }
    }
  	if(x == 0){
      cout << "TLE";
    }else{
      cout << ans;
    }
  	return 0;
}

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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int A,B;
    cin >> A >> B;
    if ((A+B)%2==0){
        cout<< (A+B)/2 <<endl;
    }
    else 
    {
        cout<< "IMPOSSIBLE" <<endl;
    }
}

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

int s[31] = {} ;
int ans[31] = {} ;

void cal(){
	s[1] = 1 ;
	s[2] = 2 ;
	s[3] = 4 ;
	
	for( int i=4 ; i<=30 ; i++ ){
		s[i] = s[i-1] + s[i-2] + s[i-3] ;
	}
	
	for( int i=1 ; i<=30 ; i++ ){
		ans[i] = s[i] / 3650 ;
		if( s[i] % 3650 > 0 ) ans[i]++ ;
	}
}

int main(){
	
	cal() ;
	
	int n ;
	
	while( cin >> n , n ){
		cout << ans[n] << endl ;
	}
	
return 0 ;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){

int S; cin >> S;
int s1 = S - (S/100)*100;//しも二桁
int s2 = S/100;//上二桁
    if(1 <= s1 && s1 <= 12){
     //YYMMである可能性。
     //YYは何でもいいので。MMYYの可能性を排除
        if(1 <= s2 && s2 <= 12){
            //MMYYでもあったわ…
            cout << "AMBIGUOUS" << endl;
         } else{
             //MMYYではないですね
             cout << "YYMM" << endl;
         }
    } else {
         //YYMMでは絶対ない
        //MMYYの吟味，上の２桁が０１から１２の中か？

        if(1 <= s2 && s2 <= 12){
            cout << "MMYY" << endl;
            //MMYYで決定。
             }else{//MMYYですらない
            cout << "NA" << endl;
                 }
   
        }

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;

using pint = pair<ll,ll>;

int main(){
	int n,q; cin >> n >> q;
	string s; cin >> s;
	int l[100006],r[100006];
	rep(i,q) cin >> l[i] >> r[i];
	vector<int> vec(n+1,0);//1_indexed
	rep(i,n){
		int cal = 0;
		if(s[i-1] == 'A' && s[i] == 'C' && i != 0) cal++;
		//cout << cal << endl;
		vec[i+1] = vec[i] + cal;
	}
	//vec[n] = vec[n-1];
	rep(i,q){
		cout << vec[r[i]] - vec[l[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
S = input()
T = input()

alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

S_counter = []
T_counter = []
for i in alph:
    S_counter.append(S.count(i))
    T_counter.append(T.count(i))

S_counter.sort()
T_counter.sort()

if S_counter == T_counter:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main(){
  int A,B,C,D;
  int ans=0;
  cin >> A >> B >> C >> D;
  if(A<=C){
    if(B>=C){
      ans = B-C;
      if(D<=B){
        ans = D-C;
      }
    }
  }else{
    if(A<=D){
      ans = D-A;
      if(B<=D){
        ans = B-A;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    unsigned long long a;
    double b;
    cin >> a >> b;
    unsigned long long t = b * 100. + 0.1;
    unsigned long long result = a * t / 100;
    cout << result << endl;
    return EXIT_SUCCESS;
}

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


int main()
{
    ll n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    map<ll, ll> mp;
    for (size_t i = 2; i <= n; i++)
    {
        ll j = 2;
        ll tmp = i;
        while (tmp >= j * j) {
            if (tmp % j == 0) {
                mp[j]++;
                tmp /= j;
            } else {
                j++;
            }
        }
        mp[tmp]++;
    }

    ll num = 1;
    for (auto elem : mp) {
        num = ((num % (ll)(1e9+7)) * (elem.second + 1) % (ll)(1e9+7));
    }
    cout << num << endl;

    return 0;
}

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

int main(){
 ll n ;
  cin >>n;
  vector<ll> a(3*n);
  rep(i,3*n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
 ll sum=0;
  rep(i,n){
    sum+=a.at(2*i+1);
  }
  
  cout <<setprecision(0) <<  sum << endl;
}
  

Measured memory_bytes: 2560
H,W=map(int,input().split(' '))
S=[input().split(' ') for i in range(H)]
row = -1
for i in range(H):
    if 'snuke' in S[i]: row=i+1
col='ABCDEFGHIJKLMNOPQRSTUVWXYZ'[S[row-1].index('snuke')]
print(str(col)+str(row))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void);

int main(void)
{
    int a, b, c, x;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if (a >= b){
        x = a;
        a = b;
        b = x;
    }
    if (b >= c){
        x = c;
        c = b;
        b = x;
    }
    if (a >= b){
        x = a;
        a = b;
        b = x;
    }
    printf("%d %d %d\n", a, b, c);
    return(0);
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  char c;
  string s, t="";
  cin >> s;
  forll(i, 0, s.size()){
	c = s[i];
	if (t.size() != 0 && c=='B')
	  t.pop_back();
	else if(c=='1' || c=='0')
	  t.push_back(c);
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
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<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
string s;

int main(){
	cin>>n>>s;
	int M=0,x=0;
	for(int i=0;i<n;i++){
		x+=s[i]=='I'?1:-1;
		M=max(M,x);
	}
	cout<<M<<endl;
}

Measured memory_bytes: 384
const fs = require("fs")
const input = fs.readFileSync("/dev/stdin", "utf-8")
const arr = input.split("\n")[0].split(" ")
const N = parseInt(arr[0])
const M = parseInt(arr[1])
const A = input.split("\n")[1].split(" ").map(function(i) {
  return parseInt(i)
})

function homework(a) {
  let result = 0
  a.forEach(function(i) {
    result += i
  })
  return result
}

function fun(n, a) {
  let result = n - homework(a)
  if (result < 0) {
    return -1
  }
  return result
}
console.log(fun(N, A))


Measured memory_bytes: 30788
import sys
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0)
already = set()
for line in sys.stdin:
    p, s = line.strip().split()
    p = int(p)
    if p in already:
        continue
    if s == 'AC':
        ac += 1
        already.add(p)
    else:
        wa[p] += 1

print(ac, sum(wa[i] for i in already))


Measured memory_bytes: 22888
#include <stdio.h>

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

int main(void) {
	int n,k,i,a,b,x;
	scanf("%d%d",&n,&k);
	for(i = 1;i <= k;i++){
		scanf("%d%d",&a,&b);
		x = min(min(a,b),min(n-a+1,n-b+1));
		x%=3;
		if(x){printf("%d\n",x);}else{printf("3\n");}
	}
	return 0;
}

Measured memory_bytes: 608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (a, b) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = a - (b < a ? 1 : 0);

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28244
let a = ref 0;;
let b = ref 0;;
Scanf.scanf "%d %d" (fun x y -> a := x; b := y);;

let p =
  if !a >= 13 then !b
  else if !a >= 6 then !b / 2
  else 0 in
  print_endline(string_of_int p)
;;

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for (int i=0;i<H;++i) cin >> S[i];
    vector<vector<int>> dp(H,vector<int>(W,INF));
    for (int i=0;i<H;++i){
        for (int j=0;j<W;++j){
            if (i==0&&j==0) dp[i][j]=(S[i][j]=='#');
            if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]+(S[i][j-1]=='.'&&S[i][j]=='#'));
            if (i) dp[i][j]=min(dp[i][j],dp[i-1][j]+(S[i-1][j]=='.'&&S[i][j]=='#'));
        }
    }
    cout << dp[H-1][W-1] << '\n';
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const int MOD = 1000000007;
int main()
{
	string a;
	string b;
	string c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    for(int d = 0; d < N; ++d) {
        int cnt = 0;
        for(int i = 0; i < N - d; ++i) {
            if(S[i] == S[i+d]) {
                ++cnt;
            } else {
                cnt = 0;
            }
            ans = max(ans, min(d, cnt));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int N;cin >> N ;
    int s[N];
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        sum+=s[i];
    }
    
    int dif=abs(sum-2*s[0]);
    for(int i=1;i<N-1;i++){
        int sum1=0;
        for(int j=0;j<=i;j++){
            sum1+=s[j];
        }
        dif=min(dif,abs(sum-2*sum1));
    }
    cout << dif;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		long takahashi = scanner.nextLong();
		long nakahashi = scanner.nextLong();
		long hikuhashi = scanner.nextLong();

		long k = scanner.nextLong();

		System.out.println((k%2==1)?nakahashi-takahashi:takahashi-nakahashi);
		scanner.close();
	}

}


Measured memory_bytes: 21844
var main = function main(input) {
  var args = input.split(' ')
  var threedigit = args[0] * 100 + args[1] * 10 + +args[2]
  if (threedigit % 4 === 0) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

//#define _USE_MATH_DEFINES
//#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return (p1.first - p1.second > p2.first - p2.second);
    }
};

struct pair_hash
{
    std::size_t operator()(const pair<i64, i64>& k) const
    {
        return static_cast<size_t>(k.first ^ k.second);
    }
};


#include <random>

const i64 mod = 1000000007ll;
const i64 inf = 10000000000000007ll;

const double eps = 0.00000001;

i64 n;

i64 solve(i64 a) {
    i64 r = 0;
    while (a) {
        r += a % 10;
        a /= 10;
    }
    return r;
}

int main() {
    cin >> n;

    i64 R = inf;

    for (i64 a = 1; a < n; a++) {
        i64 b = n - a;

        R = min(R, solve(a) + solve(b));
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Monad.State
import Control.Arrow
import Data.List

getInts = map read . words <$> getLine :: IO [Int]

data Coins = Coins {_a::Int,_b::Int,_c::Int}

sumStr = map (\x -> read [x]) >>> foldr1 (+)

main = do
    arr <- getLine >> getInts
    putStrLn . show $ game (sort >>> reverse $ arr) 0
    where 
        game [] a  =  a
        game (x:[]) a = a + x
        game (x:y:arr_) a = game arr_ (a + x - y)

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
const int N = 5007;
int n, m, a, b;
int ans[N][N];
int main()
{
    cin >> n >> m >> a >> b;

    for(int i = 1; i <= n; ++ i)
        for(int j = 1; j <= m; ++ j)
            ans[i][j] = 0 + ((i <= b && j <= a) || (i > b && j > a));
    for(int i = 1; i <= n; ++ i)
    {
        for(int j = 1; j <= m; ++ j)
        printf("%d", ans[i][j]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 11068
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    int n,ans;
    cin >> n;
    vector<int> vec(n+1);
    REP(i,1,n+1){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int left,right;
    left=vec[n/2];
    right=vec[(n/2)+1];
    if(left==right){
        ans=0;
    }else{
        ans=right-left;
    }
    p(ans);
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int x = int.Parse(Console.ReadLine());
            if (x == 3 || x == 5 || x == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

using namespace std;

int num(char x) {
  if (0 <= x - '0' && x - '0' <= 9) {
    return true;
  }
  return false;
}

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;

  bool ok = true;
  for (int i = 0; i < (A + B + 1); i++) {
    if (i < A && !num(S[i])) {
      ok = false;
      break;
    }
    if (A < i && !num(S[i])) {
      ok = false;
      break;
    }
    if (S[A] != '-') {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m,v,p=map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
reva = [a[0] - x for x in a]
ub = a[0]
lb = a[-1]

from bisect import *

def ok(val):
    i = bisect_left(reva,a[0]-val)
    val = a[i]
    if v-(min(n-i,v)) < p and a[p-1] <= a[i] + m:
        return True
    l = v - (p-1) - (n - i)
    if a[i]+m < a[p-1]:
        return False
    if sum(list(map(lambda x:min(a[i]+m-x,m),a[p-1:i]))) >= l*m:
        return True
    return False

while ub > lb:
    mid = (ub+lb)//2
    if ok(mid):
        ub=mid
    else:
        lb=mid+1

print(len(list(filter(lambda x:x >= lb,a))))

Measured memory_bytes: 15744
from sys import stdin
import numpy as np
# import math
import fractions as math
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
A = np.array(A)
abs_A = abs(A)
posi = sum(A<0)
if posi%2==0:
  print(sum(abs_A))
else:
  minA = min(abs_A)
  print(sum(abs_A)-2*minA)

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b == c)cout << "Yes" << endl;
    else if(a + c == b)cout << "Yes" << endl;
    else if(b + c == a)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

l = S.count('(')
r = S.count(')')
d = r - l

if d > 0:
    S = '(' * d + S
if d < 0:
    S = S + ')' * (-d)

l, r, d = 0, 0, 0
for s in S:
    if s == '(':
        l += 1
    if s == ')':
        r += 1
    d = max(d, r - l)

if d > 0:
    S = '(' * d + S + ')' * d

print(S)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ans = 0;
        rep(i, n){
            cin >> a;
            ans += a - 1;
        }
        print(ans);
    }
}


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

int main()
{
    int x;
    cin>>x;
    if((x>=0) || (x<=0))
    {
        if(x==1)
        {
            cout<<"0";
        }
        else{
            if(x==0)
            {
                cout<<"1";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

map<pair<int, int>, int> weight;
int color[100005];
vector<int> tree[100005];
vector<bool> used(100005);

void dfs(int now, bool _color) {
  color[now] = _color;
  // //cerr << now << ": "; for(auto t : tree[now]) cerr << t << " ";cerr << endl;
  for(int t : tree[now]) {
    if(used[t]) continue;
    used[now] = true;
    if(weight[make_pair(now, t)] % 2 == 0) dfs(t, _color);
    else if(weight[make_pair(now, t)] % 2 == 1) dfs(t, !_color);
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> u(N), v(N), w(N);
  for(int i = 0; i < N - 1; i++) {
    cin >> u[i] >> v[i] >> w[i];
    tree[u[i]].push_back(v[i]);
    tree[v[i]].push_back(u[i]);
    weight[make_pair(u[i], v[i])] = w[i];
    weight[make_pair(v[i], u[i])] = w[i];
  }
  dfs(u[0], false);
  for(int i = 1; i <= N; i++) cout << color[i] << endl;
  return 0;
}

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

int  main() {

   char c;
   cin >> c ;

   string ans;
   ans = "consonant";

  if  (c == 'a' || c ==  'i' ||  c ==  'u' ||  c ==  'e' ||  c ==  'o' ) {
  ans = "vowel";
  }

 cout <<  ans  << endl;

}
   

Measured memory_bytes: 256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 15:25:25

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
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;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a[10], k;
	for(int i = 1; i <= 5; ++i)	cin >> a[i];
	cin >> k;
	bool flag = 1;
	for(int i = 1; i <= 5; ++i){
		for(int j = 1; j <= 5; ++j){
			if(abs(a[i]-a[j]) > k)	flag = 0;
		}
	}		
	if(flag)	cout << "Yay!" << endl;
	else	cout << ":(" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	ll N,M; cin>>N>>M;
  	string S,T; cin>>S>>T;
  	ll n=lcm(N,M)/M,m=lcm(N,M)/N;
  
  if(lcm(N,M)==1){
  	if(S[0]==T[0]) printf("%lld",lcm(N,M));
    else printf("-1");
  }else{
   	 ll lim=min((N-1)/n,(M-1)/m);
    	for(int i=0;i<=lim;i++){
        	if(S[n*i]==T[m*i]) continue;
          	printf("-1");
          	return 0;
        }
    	printf("%lld",lcm(N,M));
  }
	
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define PI 3.14159265358979

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int N;
const int MAX_N = 15;
const int N_STATE = 1<<15;
int n[MAX_N], d[MAX_N], s[MAX_N];

const double INF = 1.0e10; 
bitset<MAX_N> visited;
int dp[N_STATE][MAX_N];
vi  path[N_STATE][MAX_N];

void dfs(int k, vi& p, double t, int w) {
	int state = visited.to_ulong();
	if(dp[state][k] >= 0 && dp[state][k] <= t) return;
	dp[state][k] = t;
	path[state][k] = p;

	if(visited.count() == N) return;

	rep(i,N) {
		if(!visited[i]) {
			double e = abs(d[i] - d[k]) / (2000.0 / (70.0 + w));
			visited.set(i);
			p.push_back(i);
			dfs(i, p, t+e, w+s[i]*20);
			p.pop_back();
			visited.reset(i);
		}
	}
}

void solve() {
	memset(dp, -1, sizeof(dp));

	int last = (1<<N) - 1;
	double minval = INF;
	vi p, ans;
	rep(i,N) {
		visited.set(i);
		p.push_back(i);
		dfs(i, p, 0, s[i]*20);
		p.pop_back();
		visited.reset(i);

		rep(j,N) {
			if(dp[last][j] >= 0 && minval > dp[last][j]) {
				minval = dp[last][j];
				ans = path[last][j];
			}
		}
	}

	if(ans.size() == N) {
		rep(i,N) {
			printf("%d", n[ans[i]]);
			if(i != N-1) printf(" ");
		}
		printf("\n");
	}
}

int main() {
	cin>>N;
	rep(i,N) {
		cin>>n[i]>>d[i]>>s[i];
	}
	solve();
}

Measured memory_bytes: 25696
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    for(int i = 0; i < 3; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(10 * a[2] + a[1] + a[0]);
  }
}


Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#define neko 200010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
int n,nows,nowt,ans;
char s[neko];
int cmin(int a,int b){return a<b?a:b;}
int main()
{
	scanf("%s",s+1);
	ans=n=strlen(s+1);
	f(i,1,n)
	{
		if(s[i]=='S')++nows;
		else ++nowt;
		if(nows<nowt)ans-=nows*2,nows=nowt=0;
	}
	return printf("%d\n",ans-nowt*2),0;
}

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

using namespace std;

#define int unsigned long long

signed main()
{
	cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	//freopen("output", "w", stdout);

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = c * d / __gcd(c, d);
	int helpa = (a - 1) / c + (a - 1) / d - (a - 1) / l;
	int helpb = b / c + b / d - b / l;
	int ans = helpb - helpa;
	if (c == d)
		ans = b / c - (a - 1) / c;
	cout << b - a - ans + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define ll long long

using namespace std;

int n, p;
int a[51];
ll dp[50][2];

int main() {
    cin >> n >> p;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (a[i] % 2 == 0) {
            dp[i][0] = dp[i - 1][0] * 2;
            dp[i][1] = dp[i - 1][1] * 2;
        } else {
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
        }
    }

    cout << dp[n][p] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,a, b;
  cin >> x >> a >> b;
  if (abs(x-a)<abs(x-b))
  cout << "A"<< endl;
  else
  cout << "B" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int MAX = 1000000;

long long gcd(long long a, long long b) {return b?gcd(b, a%b):a;}

ll ans;

int main(void) {
    int N;
    cin >> N;
    vector<ll> A(N, 0);
    rep(i, 0, N) cin >> A[i];

    ll g = A[0];
    rep(i, 0, N) g = gcd(g, A[i]);

    if (g!=1) {
        puts("not coprime");
        return 0;
    }

    vector<bool> x(MAX+5, false);
    rep(i, 0, N) x[A[i]] = true;

    rep(i, 2, MAX+1) {
        int cnt = 0;
        for (int j=i; j<=MAX; j+=i) {
            if (x[j]) cnt++;
        }
        if (cnt>1) {
            puts("setwise coprime");
            return 0;
        }
    }

    puts("pairwise coprime");
    return 0;
}





Measured memory_bytes: 11200
#include <bits/stdc++.h>
using namespace std;
const long long p=1e9+7;
long long n;
int main(){
	cin>>n;
	long long x=1,y=1;
	for(int i=0;i<n;i++){
		x*=10;
		x%=p;
	}
	long long yy=1;
	for(int i=0;i<n;i++){
		yy*=8;
		yy%=p;
	}
	for(int i=0;i<n;i++){
		y*=9;
		y%=p;
	}
	y-=yy;
	y*=2;
	y%=p;
	y+=yy;
	y%=p;
	if(x>=y){
		cout<<x-y<<endl;
	}
	else cout<<(x+p-y)%p<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> price(N);
    for (int i = 0; i < N; ++i) {
        cin >> price[i];
    }
    sort(price.begin(), price.end(), greater<>());
    int answer = 0;
    answer += price[0] / 2;
    for (int i = 1; i < N; ++i) {
        answer += price[i];
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n, a, b;
	cin>>n>>a>>b;
	vll x(n);
	for(int i = 0; i < n; i++) cin>>x[i];
	ll ans = 0;
	for(int i = 0; i < n-1; i++)
	{
		if((x[i+1]-x[i])*a>=b)
			ans+=b;
		else ans+=(x[i+1]-x[i])*a;
	}
	p(ans);
	return 0;
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main(){
    int n,temp;
    ll rta=0;
    cin >> n;
    vector<int> datos;
    deque<int> process;
    for(int i=0;i<n;i++){
        cin >> temp;
        datos.pb(temp);
    }
    sort(datos.begin(),datos.end());
    process.pb(datos.back());
    datos.pob;
    for(int i=1;i<n;i++){
        rta+=process.front();
        process.pof;
        temp=datos.back();
        datos.pob;
        process.pb(temp);
        process.pb(temp);
    }
    cout << rta << endl;
}

Measured memory_bytes: 4840
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main() {

	IOS;

    int t;
    cin >> t;

	cout <<1-t;
	
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin >> c;
    if(c <= 'Z' && c >= 'A'){
        cout << 'A';
    }
    else cout << 'a';
    return 0;
}

Measured memory_bytes: 3608
using System;

namespace AtCoder.ABC._131
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = long.Parse(spl[0]) - 1;
            var B = long.Parse(spl[1]);
            var C = long.Parse(spl[2]);
            var D = long.Parse(spl[3]);
            var CD = C * D / gcd(C, D);
            var cnt = B - A;
            var divCnt = B / C - A / C + B / D - A / D - (B / CD - A / CD);
            Console.WriteLine(cnt - divCnt);
        }

        static long gcd(long i, long j)
        {
            if(i < j)
            {
                return gcd(j, i);
            }
            while(j != 0)
            {
                var t = i % j;
                i = j;
                j = t;
            }
            return i;
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;



int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);


	int h, a;
	cin >> h >> a;
	h += a - 1;

	cout << h / a << endl;





	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int arr[n];
	fill(arr, arr + n, 0);
	
	for (int i = 1; i < n; i++) {
		cin >> arr[i];
		arr[i]--;
	}
	
	int ret[n];
	fill(ret, ret + n, 0);
	
	for (int i = 1; i < n; i++) ret[arr[i]]++;
	
	for (int x : ret) cout << x << '\n';
	
	
	return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int n,m;
	int lim = 7368793;
	bool find = false;
	cin >> m >> n;
	while ( n != 0 || m != 0 ) {
		std::vector<bool> blo(lim,false);
		int piv;
		for (int i = 0; i < n; i++) {
			if ( i == 0 ) {
				blo[m] = true;
				for (int j = 2; m*j < lim; j++) {
					blo[m*j] = true;
				}
				piv = m;
			}
			else {
				find = false;
				for (int k = piv+1; k < lim && !find; k++) {
					if ( !blo[k] ) {
						blo[k] = true;
						for (int j = 2; k*j < lim+2; j++) {
							blo[k*j] = true;
						}
						find = true;
						piv = k;
					}
				}
			}
		}

		find = false;
		int ret = 0;
		for (int i = piv+1; i < lim && !find; i++) {
			if ( !blo[i] ) {
				ret = i;
				find = true;
			}
		}
		cout << ret << endl;
		cin >> m >> n;
	}
	return 0;
}

Measured memory_bytes: 3948
from sys import exit, stdin
sx, sy, tx, ty = [int(_) for _ in stdin.readline().rstrip().split()]
dx, dy = tx-sx, ty-sy
print(dy*'U'+dx*'R'+dy*'D'+dx*'L'+'L'+'U'+dy*'U'+dx*'R'+'R'+'D'+'R'+dy*'D'+'D'+'L'+dx*'L'+'U')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int main(){
  string data="abcdefghijklmnopqrstuvwxyz",input;
  cin>>input;
  char flag='.';
  for(int i=0;i<data.size();i++){
    if(input.find(data[i])==string::npos){
      flag=data[i];
      break;
    }
  }
  if(flag!='.'){
    cout<<flag<<endl;
  }
  else{
    cout<<"None"<<endl;
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n, m;
    while (cin >> n && n) {
        cin >> m;
        vector<pii> v(n);
        rep(i, n) {
            cin >> v[i].F >> v[i].S;
            v[i].S *= -1;
        }
        sort(all(v));
        //rep(i, SZ(v)) cout << v[i].F << " " << v[i].S << endl;
        //rep3(i, 1, n) {  // 事故る
        rep3(i, 1, SZ(v)) {
            if (v[i].F == v[i - 1].F) {
                v.erase(v.begin() + i);
                i--;
            }
        }
        int sum = 0;
        rep(i, SZ(v)) {
            sum += v[i].S;
        }
        out(-sum);
    }
}



Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <stdlib.h>
#include <iostream>

int main(int argc, char** argv) {
    int n;
    std::cin >> n;
    int spent = n * 800;
    int discountFactor = n / 15;
    
    std::cout << spent - 200*discountFactor << std::endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);


            if (a == b && b == c)
                Console.WriteLine(1);
            else if (a != b && a != c && b != c)
                Console.WriteLine(3);
            else
                Console.WriteLine(2);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int mark[200004],cnt[200004];
vector<int>adj[200004];
void solve(int u,int p, int d)
{
    d+=mark[u];
    cnt[u]=d;
    for(int v: adj[u])if(v!=p)solve(v,u,d);
}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        mark[x]+=y;
    }
    solve(1,-1,0);
    for(int i=1;i<=n;i++)cout<<cnt[i]<<" ";
    cout<<endl;
    return 0;

}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    a += b;
    a %= 24;
    cout << a << "\n";
    return 0;
}


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


int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    char a, b;
    a = s.front();
    b = s.back();
    if (a == b){
        cout << ((s.size() & 1) ? "Second" : "First") << endl;
    }else{
        cout << ((s.size() & 1) ? "First" : "Second") << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n;i++) {
		cin >> a.at(i);
	}
	int ma=-1000000000;
	int mi = a.at(0);
	for (int i = 1; i < n;i++) {
		ma = max(a.at(i) - mi, ma);
		mi = min(mi, a.at(i));
	}
	cout << ma << endl;
}



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

ans=0
right=0
left=0
for i in range(n):
    left=min(a[i],b[i])
    ans+=left
    a[i]-=left
    b[i]-=left
    
    right=min(a[i+1],b[i])
    ans+=right
    a[i+1]-=right
    b[i]-=right
print(ans)

Measured memory_bytes: 19156
#include<bits/stdc++.h>
using namespace std;
long long qzh[200003],a,n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		qzh[i]=a+qzh[i-1];
	}
	sort(qzh,qzh+(n+1));
	long long ans=0,x=1;
	for(int i=1;i<=n;i++)
		if(qzh[i]!=qzh[i-1])
			ans=ans+x*(x-1)/2,
			x=1;
		else
			x++;
	cout<<ans+x*(x-1)/2;
}

Measured memory_bytes: 1792