akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v;
    for(int i = 0; i < N; ++i){
        int num;
        cin >> num;
        if(N+i & 1){
            v.insert(v.begin(), num);
        }else{
            v.push_back(num);
        }
    }

    for(int i = 0; i < N; ++i){
        printf("%d", v[i]);
        if(i == N - 1) printf("\n");
        else printf(" ");
    }
    return 0;
}


Measured memory_bytes: 3060
import itertools
def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    perm = list(itertools.permutations([i+1 for i in range(N)]))
    print(abs(perm.index(P)-perm.index(Q)))

main()


Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a < c && c < b) || (b < c && c < a)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int X, t;
  cin >> X >> t;
  cout << max(0, X - t) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> adj[n];
  int h[n];
  for(int i=0;i<n;++i) cin>>h[i];
  while(k--) {
    int a,b;
    cin>>a>>b;
    a--; b--;
    adj[a].pb(b); adj[b].pb(a);
  }
  int a =0;
  for(int i=0;i<n;++i){
    bool st = 0;
    for(auto j:adj[i]){
      if(h[j]>=h[i]) {st = 1; break;}
    }
    if(!st) a++;
  }
  cout<<a;
}


Measured memory_bytes: 9124
#include <iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include <stdio.h>
using namespace std;
int main()
{
	int e[10];
	int e3=0,e32=0,abc=0;
	cin >> e3;
	e32 = e3;
	for (int i = 0; i < 10; i++) {
		if (e3 > 0) {
			e[i] = e3 % 10;
			e3=e3 / 10;
		}
		else { e[i] = 0; }
	}
	for (int j = 0; j < 10; j++) {
		abc += e[j];
	}
	if (e32%abc == 0) {
		cout << "Yes"<<endl;
	}
	else { cout << "No"<<endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vi X(N);
rep(i,N) cin >> X[i];

int m = INF;

rrep(p,100) {
    int now = 0;
    rep(i,N) {
        now += pow(X[i]-p, 2);
    }
    m = min(m, now);
}

cout << m << endl;


return 0;
}

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

const int maxn = 31;
int a[maxn][maxn];



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    int n,m, k, temp;
    cin>>n>>m;
    for(int i = 1; i<=n; i++){
        cin>>k;
        for(int j = 0; j<k;j++){
            cin>>temp;
            a[i][temp] = 1;
        }
    }
    
    int ans = 0;
    for(int i  = 1; i<=m; i++){
        bool ok = 1;
        for(int j = 1; j <= n; j++){
            if(a[j][i]!=1){
                ok = 0;
                break;
            }
        }
        if(ok)ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		//Scanner scan = new Scanner(System.in);

	String[] str = new String[4];
	str = line.split(" ");
	
	if(str[0].equals(str[1]))
			System.out.println("H");
	else
		System.out.println("D");
				
	
			
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;
#define fi                  first
#define se                  second

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll K;
	vector<ll> A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> K;

	cout << A[K - 1] << endl;
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){

	ll n,m;
	cin >> n >> m;

	ll a[n + 5];
	fill(a,a + n + 5,0);

	ll l,r;
	for(ll i = 0;i < m;i++){
		cin >> l >> r;
		a[l]++;
		a[r + 1]--;
	}

	ll cnt = 0;

	for(ll i = 1;i <= n;i++){
		a[i] += a[i - 1];
		cnt += (a[i] == m);
	}

	cout << cnt << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int value(char x) {
  char c = '0';
  return (int)x - (int)c;
}
int main() {
  char a, b, c;
  cin >> a >> b >> c;
  cout << value(a) + value(b) + value(c) << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( int i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 998244353
#define PI 3.14159265358979323846
const ll N = 100005;

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};



int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin >> n;
        ll a[n];
        REP(i, 0, n) cin >> a[i];
        ll x = a[0] ^ a[1];
        REP(i, 2, n) x ^= a[i];
        REP(i, 0, n)
        {
            ll y = x ^ a[i];
            cout << y << " ";
        }
    }
    return 0;
}



Measured memory_bytes: 5072
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	vl v[M];
	int n,m,S,T,ans,x,y;
	cin>>n>>m;
	rep(i,0,m){
		cin>>x>>y;
		v[x].push_back(y);
	}
	cin>>S>>T;
	int dist[M][3];
	rep(i,0,M)rep(j,0,3)dist[i][j]=inf;
	dist[S][0]=0;
	queue<P> q;
	q.push(make_pair(S,0));
	while(!q.empty()){
		P p=q.front();q.pop();
		int s=p.first,t=p.second,next=(t+1)%3;
		for(auto g:v[s]){
			if(dist[g][next]!=inf)continue;
			else{
				dist[g][next]=dist[s][t]+1;
				q.push(make_pair(g,next));
			}
		}
	}
	ans=dist[T][0];
	if(ans==inf)print(-1);
	else print(ans/3);
}

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        int q = sc.nextInt();
        int f = q / 100, b = q % 100;
        if (1 <= f && f <= 12 && (1 > b || 12 < b)) {
            System.out.println("MMYY");
        } else if (1 <= b && b <= 12 && (1 > f || 12 < f)) {
            System.out.println("YYMM");
        } else if (1 <= f && f <= 12 && 1 <= b && b <= 12) {
            System.out.println("AMBIGUOUS");
        } else {
            System.out.println("NA");
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23508
#include <stdio.h>
int n;
long a[500000];
int main(){
	scanf("%d",&n);
	long long sum=0;
	for (int i=1;i<=n;i++){
		scanf("%li",&a[i]);
		a[i]=a[i]-i;	
	}
	sort(1,n);
	a[0]=a[1];
	for (int i=1;i<=n;i++){
		a[i]=a[i]-a[0];
		sum=sum+a[i];
	}
	long long ans=sum;
	for (int i=2;i<=n;i++){
		sum=sum-(a[i]-a[i-1])*(n-i+1)+(a[i]-a[i-1])*(i-1);
		if (sum<ans)ans=sum;
	}
	printf("%lli",ans);
	return(0);
}
int sort(int x,int y){
	int l=x;
	int r=y;
	long m=a[(x+y)/2];
	while (l<r){
		while (a[l]<m)l++;
		while (a[r]>m)r--;
		if (l<=r){
			long z=a[l];
			a[l]=a[r];	
			a[r]=z;
			l++;
			r--;
		}
	}
	if (l<y)sort(l,y);
	if (r>x)sort(x,r);
}

Measured memory_bytes: 1664
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	while (cin >> n, n) {
		P t[25];
		for (int i = 0;i < n;i++) {
			cin >> t[i].second >> t[i].first;
		}
		sort(t, t + n);
		int w = 0;
		int flg = 1;
		for (int i = 0;i < n;i++) {
			w += t[i].second;
			if (t[i].first < w) {
				flg = 0;
				break;
			}
		}

		if (flg == 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>
#include <cstring> 

using namespace std;

#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;

bool neko[10000010];
vector<int> seica;

void mel() {
	neko[0] = neko[1] = true;
	for (int i = 2; i < 10000010;i++) {
		if (!neko[i]) {
			seica.PB(i);
			for (int j = 2 * i; j < 10000010; j += i) {
				neko[j] = true;
			}
		}
	}
}

int main() {

	ll n; cin >> n;

	mel();
	ll ans = 0;
	REP(i, seica.size()) {
		if (!neko[2 + seica[i]] && seica[i] <= n && 2 <= n)ans++;
	}

	cout << 2*ans << endl;

	return 0;
}



Measured memory_bytes: 16832
def main():
    N, X = map(int, input().split(" "))
    L = list(map(int, input().split(" ")))
    d = 0
    result = 1
    for i in range(0, N):
        d += L[i]
        if d <= X:
            result += 1
        else:
            break
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;

int main() {
	cin >> n;

	int money = 100000;
	for (int i = 0; i < n; i++) {
		money *= 1.05;

		int simo = money % 1000;
		if (simo != 0) money += 1000 - simo;
	}

	cout << money << endl;

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1164
from bisect import bisect_left 
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
#print(l)
k = [[] for i in range(n)]
for j,h in l:
  k[j-1].append(h)
k_so = [[] for i in range(n)]
for i in range(n):
  a = k[i]
  k_so[i] = sorted(a)
#print(k_so)
for j,h in l:
  first = "{:0=6}".format(j)
  t = bisect_left(k_so[j-1], h)
  second = "{:0=6}".format(t+1)
  print(first+second)

Measured memory_bytes: 47692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int t = Integer.parseInt(tmpArray[1]);

		int input[] = new int[n];

		tmpArray = br.readLine().split(" ");

		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}

		if(n == 1){
			System.out.println(t);
			return;
		}
		int start = 0;

		long total = 0;
		for(int i = 1; i < n; i++){
			if(input[i] - input[i - 1] > t){
				total += input[i - 1] + t - input[start];
				start = i;
			}

			if(i == n - 1) {
				if(start == n - 1){
					total += t;
				}
				else {
					total += input[i] + t - input[start];
				}
			}

		}

		System.out.println(total);
	}

}


Measured memory_bytes: 45780
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
#define rigsh(a,b) a>>b 
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()) ;
		bool sortbysec(const pair<int,int> &a, 
		      const pair<int,int> &b) 
		{ 
		    return (a.second < b.second); 
		} 	   
		
		  ll power(ll a,ll n)
		{
		ll ans=1;
		while(n)
		{
		if(n&1) ans=(ans*a)%mod;
		a=(a*a)%mod ;
		n=n>>1;
		 }
		 return ans;
		}
		ll power2(ll a,ll n)
		{
		ll ans =1 ;
		while(n)
		{
			if(n&1) ans =(ans*a) ;
			a = (a*a) ;
			n =n>>1 ;
		  }
		  return ans ;
		}
		ll lcm(ll a, ll b)
		{
		       return a / __gcd(a, b) * b;
		}
#define N 100050
#define M 400060

	     void solve()
		 {
		  ll x,k,d ;cin>>x>>k>>d ;
		  if(abs(x)/d >=k )
		  {
		  	cout<<(abs(x)-(k*d))<<endl ;
		  }
		  else
		  {
		  	k -= abs(x)/d ;
			x = abs(x) ;x -=(x)/d*d ;
			if(k%2) cout<<abs(x-d)<<endl ;
			else cout<<x<<endl ; 
		  }
		 }
		  
			  int main() 
	  	{
	    SPEED
	   ll t =1 ;
	    while(t--) solve() ;
	    
	    }

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll arr[n];
	input(arr,n);
	ll cnt=0;
	for(ll i=0;i<n;i++)
	if(arr[i]<0)
	cnt++;
	cnt%=2;
	ll sum=0,minm=1e9;
	for(ll i=0;i<n;i++)
	{
		sum+=abs(arr[i]);
		minm=min(minm,abs(arr[i]));
	}
//	cout<<sum<<" "<<minm<<endl;
	if(cnt)
	sum-=2*minm;
	cout<<sum;
}
	

Measured memory_bytes: 1024
using System;

namespace ABC132A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s.Substring(0,1) == s.Substring(1,1) && s.Substring(1,1) != s.Substring(2,1) && s.Substring(2,1) == s.Substring(3,1))
                Console.WriteLine("Yes");
            else if (s.Substring(0,1) == s.Substring(2,1) && s.Substring(2,1) != s.Substring(3,1) && (s.Substring(1,1) == s.Substring(3,1)))
                Console.WriteLine("Yes");
            else if (s.Substring(0,1) == s.Substring(3,1) && s.Substring(3,1) != s.Substring(1,1) && s.Substring(1,1) == s.Substring(2,1))
                Console.WriteLine("Yes");

            else Console.WriteLine("No");
            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(){
int n,a[111111],ans=1,mode=0,i,p;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
p=a[0];
for(i=1;i<n;i++){
if(mode==0){
if(a[i]>p)
mode=1;
if(a[i]<p)
mode=-1;
p=a[i];
}
else if(mode==1){
if(a[i]<p){
ans++;
mode=0;
}
p=a[i];
}
else{
if(a[i]>p){
ans++;
mode=0;
}
p=a[i];
}
}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
 
int main(){
    string S; cin >> S;
  	string temp = S;
  	sort(temp.begin(), temp.end());
  	if(S.size() < 26){
      for(int i = 0; i < S.size(); ++i){
        if(temp[i] != 'a' + i){
          S.push_back('a' + i);
          cout << S << endl;
          return 0;
        }
        if(i == S.size()-1 && temp[i] == 'a' + i){
          	S.push_back('a' + (i + 1));
        	cout << S << endl;
          	return 0;
        }
      }
    }
  else{
    int i=S.size()-1;
    while(i>=1 and S[i-1]>S[i]) i--;
    if(i==0){
        cout<<-1<<endl;
        return 0;
    }
    char c='~';
    for(int j=i;j<S.size();j++) if(S[j]>S[i-1]) c=min(c,S[j]);
    S[i-1]=c;
    cout<<S.substr(0,i)<<endl;
  }
  
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

struct DisjointSet
{
	VI parent, rank;
	DisjointSet(int n) : parent(n), rank(n, 1)
	{
		for(int i = 0; i < n; ++i)
			parent[i] = i;
	}
	int find(int u)
	{
		if(parent[u] == u)
			return u;
		return parent[u] = find(parent[u]);
	}

	void merge(int u, int v)
	{
		u = find(u), v = find(v);
		if(u == v) return;

		if(rank[u] > rank[v]) swap(u, v);

		parent[u] = v;
		if(rank[v] == rank[u])
			++rank[v];
	}
};

int n;
VPII X, Y;
LL kruskal(vector<pair<LL, PII>>& edges)
{
	LL ret = 0;
	sort(ALL(edges));

	DisjointSet ds(n);
	for(int i = 0; i < sz(edges); ++i)
	{
		LL cost = edges[i].first;
		int u = edges[i].second.first, v = edges[i].second.second;
		if(ds.find(u) == ds.find(v))
			continue;
		
		ds.merge(u, v);
		ret += cost;
	}
	return ret;
}

LL minCost()
{
	sort(ALL(X));
	sort(ALL(Y));

	vector<pair<LL, PII>> edges;
	for(int i = 1; i < n; ++i)
	{
		LL cost = abs(X[i - 1].first - X[i].first);
		int u = X[i - 1].second, v = X[i].second;
		edges.emplace_back(pair<LL, PII>(cost, PII(u, v)));

		cost = abs(Y[i - 1].first - Y[i].first);
		u = Y[i - 1].second, v = Y[i].second;
		edges.emplace_back(pair<LL, PII>(cost, PII(u, v)));
	}
	
	return kruskal(edges);	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	X = Y = VPII(n);
	for(int i = 0; i < n; ++i)
	{
		X[i].second = Y[i].second = i;
		cin >> X[i].first >> Y[i].first;
	}

	cout << minCost() << endl;
	return 0;
}

Measured memory_bytes: 8048
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    set<ll> s;
    ll a,b,c;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<<s.size()<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    for(int i = 1; i<= n; i++){
      int digit = String.valueOf(i).length();
      if(digit%2 != 0){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 28372
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -d[root(x)];
    }
};

int deg[100005];
vector<int> to[100005];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++deg[a];
        ++deg[b];
        uf.unite(a,b);
    }
    rep(i, k) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, n) {
        int ans = uf.size(i)-1-deg[i];
        for (int u: to[i]) {
            if (uf.same(i,u)) --ans;
        }
        printf("%d%c", ans, i==n-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 9212
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,k,d[10];
ll e[10];
int main(){
	cin >> n >> k;
	REP(i,k) {
		cin >> d[i];
		e[d[i]] = true;
	}
	while(true) {
		ll m = n;
		bool f = false;
		while(m > 0) {
			if(e[m % 10]) {
				f = true;
			}
			m /= 10;
		}
		if(f) {
			n++;
			continue;
		}
		break;
	}
	cout << n << endl;
	return 0;
}


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




int main()
{

int N,M;
cin>>N>>M;
int arr[M];
for(int i=0;i<M;i++)
{
    
    cin>>arr[i];
}
int total=0;
for(int i=0;i<M;i++)
{
   total+=arr[i]; 
    
}

if(total>N)
{
    cout<<-1;
}
else{
    cout<<N-total;
}

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
  
signed main() {
    fast;
    int n;
    cin>>n;
    int arr[n];
    map<int,int>m;
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    int sum=0;
    for (auto x:m)
    {
        
            sum+=x.second*(x.second-1)/2;
        
    }
    //cout<<sum<<endl;
    for (int i=0;i<n;i++)
    {
        int x=m[arr[i]]*(m[arr[i]]-1)/2;
        //cout<<x<<endl;
        int ans=sum-x;
        //cout<<ans<<endl;
        //cout<<m[arr[i]]<<endl;
        ans+=(m[arr[i]]-1)*(m[arr[i]]-2)/2;
        cout<<ans<<endl;
    }
    //cout<<endl;
}


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

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

    vector<vector<string>> ans(n+1);
    ans[1] = {"a"};
    for(int t=1; t<n; t++){
        vector<vector<string>> new_ans(n+1);
        for(int i=1; i<=t; i++){
            for(string a : ans[i]){
                for(int j=1; j<=i; j++) new_ans[i].push_back(a + (char)('a' + j - 1));
                new_ans[i+1].push_back(a + (char)('a' + i));
            }
        }
        ans = new_ans;
    }

    vector<string> canonical;
    for(int i=1; i<=n; i++){
        for(string a : ans[i]){
            canonical.push_back(a);
        }
    }

    sort(canonical.begin(), canonical.end());
    for(string c : canonical){
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 15176
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100;

bool havesnack[N];

int main() {
	int n, k; cin >> n >> k;
	while (k--) {
		int m; cin >> m;
		while (m--) {
			int i; cin >> i, i--;
			havesnack[i] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (!havesnack[i])
			ans++;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3588
from collections import defaultdict

n=int(input())
d=[defaultdict(int) for i in range(n)]

for i in range(n):
    s=input()
    for g in range(len(s)):
        d[i][s[g]]+=1


ans=""
char=[chr(i) for i in range(97, 97+26)]

for c in char:
    MIN=10**10
    for i in range(n):
        MIN=min(d[i][c],MIN)
    ans+=c*MIN
print(ans)


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

using namespace std;

typedef long long ll;

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

	string s[3];
	cin >> s[0] >> s[1] >> s[2];

	int n[3];
	rep(i, 3) n[i] = s[i].size();

	int p[3];
	rep(i, 3) p[i] = 0;

	int now = 0;
	while(true){
		if(p[now] == n[now]){
			cout << ""s + (char) ('A' + now) << endl;
			return 0;
		}

		char c = s[now][p[now]];
		// cout << now << "," << p[now] << "," << c << endl;
		p[now]++;
		now = c - 'a';
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    string N;
    int K;
    cin >> N >> K;
    LLONG digit = N.length();
    vector<LLONG> nums(digit);
    for (int i = 0; i < digit; ++i)
    {
        nums[i] = N[i] - '0';
    }
    LLONG ans = 0;
    if (K == 1)
    {
        // topに数字を入れるときと，top以外に数字を入れるとき
        ans = nums[0] + 9 * (digit - 1);
    }
    else if (K == 2 && digit >= 2)
    {
        // topに数字を入れるとき
        // top未満の数字をtopにおくとき
        ans += (nums[0] - 1LL) * 9LL * (digit - 1LL);
        // topにtopの数字をおくとき，初めてゼロ以外になる場所を探す
        int nonZero = 0;
        for (int i = 1; i < digit; ++i)
        {
            if (nums[i] != 0)
            {
                nonZero = i; break;
            }
        }
        if (nonZero > 0)
        {
            ans += nums[nonZero] + 9LL * (digit - 1LL - nonZero);
        }

        // topに数字をおかないとき
        if (digit > 2)
        {
            ans += 81LL * (digit - 1LL) * (digit - 2LL) / 2LL;
        }
    }
    else if (K == 3 && digit >= 3)
    {
        // topに数字を入れるとき
        // top未満の数字をtopにおくとき
        ans += (nums[0] - 1) * 81LL * (digit - 1LL) * (digit - 2LL) / 2LL;
        // topにtopの数字をおくとき，初めてゼロ以外になる場所を探す
        int nonZero = 0;
        for (int i = 1; i < digit; ++i)
        {
            if (nums[i] != 0)
            {
                nonZero = i; break;
            }
        }
        // noneZeroの位置を含めて２桁以上残っていなければならない
        if (nonZero > 0 && digit - nonZero >= 2)
        {
            // nonZeroの位置に数字をおく場合
            // nonZeroにnonZeroの値をおく場合，次にゼロ以外になる場所を探す
            int nonZero2 = 0;
            for (int i = nonZero + 1; i < digit; ++i)
            {
                if (nums[i] != 0)
                {
                    nonZero2 = i; break;
                }
            }
            if (nonZero2 != 0)
            {
                ans += nums[nonZero2] + 9LL * (digit - nonZero2 - 1LL);
            }

            // nonZeroにnonZero未満の値をおく場合
            ans += (nums[nonZero] - 1LL) * 9LL * (digit - 1LL - nonZero);
            
            // nonZeroの位置より下の桁に数字を置く場合
            if (digit - 1 - nonZero >= 2)
            {
                ans += 81LL * (digit - 1LL - nonZero) * (digit - 2LL - nonZero) / 2LL;
            }
        }

        // topに数字をおかないとき
        if (digit > 3)
        {
            ans += 729LL * (digit - 1LL) * (digit - 2LL) * (digit - 3LL) / 6LL;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int n;
while(cin>>n){
  vector<bool> nature(n,true);
  nature[0]=nature[1]=false;
  for(int i=0;i*i<=n;i++){
if(nature[i]){
  for(int j=2;j<=n/i;j++)
  nature[i*j]=false;
}
  }
int count=0;
for(int i=0;i<=n;i++)
if(nature[i])
count++;
cout<<count<<endl;
}
return 0;
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int S = sc.nextInt();
        int W = sc.nextInt();
        String result = (W >= S) ? "unsafe" : "safe";

        System.out.println(result);
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define mem(a, b) memset(a, b, sizeof(a))

const int MOD = 1000000007;
const int MAX = (int) 1e9;
const double PI = 3.141592653589793238462643383279502884;

template <typename T, typename U>
T max(T x, U y) {
    return x > y ? x : y;
}

template <typename T, typename U>
T min(T x, U y) {
    return x < y ? x : y;
}

template<typename T>
void debug(string msg, T t) {
	cout << msg << ": " << t << "\n";
}

int toDigit(char c) { return c - '0'; }

string s, t;
int ans = MAX, diff;

int main() {

	cin >> s >> t;

	int n = s.length();
	int m = t.length();

	for(int i = 0; i <= n - m; i++) {
		diff = 0;
		for(int j = 0; j < m; j++) {
			if(s[i + j] != t[j]) {
				diff++;
			}
		}

		if(diff < ans) {
			ans = diff;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int x, h;
  while(scanf("%d%d", &x, &h) && (x | h)) {
    double m = sqrt(h*h + x*x/2.0);
    double s = (m*2+x)/2.0;
    double S = sqrt(s*(s-m)*(s-m)*(s-x));
    printf("%.10f\n", 4*S + x*x);
  }
}

Measured memory_bytes: 0
-- A
local a,b,c,d,e,k = io.read("n", "n", "n", "n", "n", "n")
local tbl = {a,b,c,d,e}

for i=1, #tbl - 1 do
    for j=i+1, #tbl do
        local distance = tbl[j] - tbl[i]
        if distance > k then
            print(":(")
            return
        end
    end
end

print("Yay!")

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

int main(void)
{
  int flag = 0;
  
  int n;
  scanf("%d",&n);
  
  int a[n];
  int answer = 0;
  
  for(int i = 0; i < n; i++){
    
    scanf("%d",&a[i]);
    
  }

  while (flag == 0)
  {
    for (int i = 0; i < n; i++){
      if (a[i]%2 == 1) flag = 1;
      a[i] = a[i] / 2;
    }

    if (flag == 1) break;
    answer++;
  }

  printf("%d\n",answer);
  

  return 0;
}


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

long long nCr (const int &n, int r) {
  if (r == 0) return 1;

  long long ret = 1;
  if (r > n-r) r = n-r;

  for (int i = n-r+1; i <= n; i++) ret *= i;
  for (int i = r; i > 0; i--) ret /= i;

  return ret;
}

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

  int cnt[] = {0, 0};

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    cnt[tmp%2]++;
  }

  long long ans = 0;
  for (int i = p; i <= cnt[1]; i += 2) {
    ans += (1LL << cnt[0]) * nCr(cnt[1], i);
  }

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

Measured memory_bytes: 256
using System;
class Program{
  static void Main(){
  string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);
    int V=A-(B*2);
    if(V>0)Console.WriteLine(V);
    else Console.WriteLine(0);
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>

using namespace std;

int main(){

    string top,c;
    cin >> top;
    int cost = 700;
    for(int i=0;i<3;i++){
        c = top[i];
        if(c == "o"){
            cost += 100;
        }
    }
    /*
    stringstream ss;
    ss << top;
    while(ss >> top){
        if(top == "o") cost += 100;
    }
    */

    cout << cost << endl;





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18+5;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
#define fst first
#define snd second
const ll mn=1e5+2;
ll a[mn];
vector<ll> g[mn];
bool final=true;
ll n;
ll f(ll x, ll p) {
	ll ans;
	if (g[x].size()==1) ans=a[x];
	else {
		ll sum=0,hi=0;
		for (auto &y:g[x]) {
			if (y==p) continue;
			ll got=f(y,x);
			sum+=got;
			chkmax(hi,got);
		}
		ll left=sum-hi;
		ll canpair=(hi>left)?left:sum/2;
		ll p=sum-a[x];
		ll u=2*a[x]-sum;
		if (u<0||p<0) final=false;
		//printf("x:%lld p3:%lld u3:%lld a:%lld sum:%lld\n",x,p,u,a[x],sum);
		if (p>canpair) final=false;
		ans=u;
	}
	//printf("x:%lld ans:%lld\n",x,ans);
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	scanf("%lld",&n);
	for (ll x=1;x<=n;x++) {
		scanf("%lld",&a[x]);
	}
	for (ll i=0;i<n-1;i++) {
		ll x,y; scanf("%lld%lld",&x,&y);
		g[x].PB(y); g[y].PB(x);
	}
	if (n==2) {
		if (a[1]==a[2]) printf("YES\n");
		else printf("NO\n");
		return 0;
	}
	ll nonleaf=-1;
	for (ll x=1;x<=n;x++) if(g[x].size()!=1) {nonleaf=x;}
	ll rootup=f(nonleaf,-1);
	if (rootup!=0) final=false;
	if(final) printf("YES\n");
	else printf("NO\n");
}


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

int A[111];

int main() {
    int N; scanf("%d",&N);
    for(int i=1; i<=N; i++) A[i] = 1e9;
    for(int i=1; i<N; i++) {
        int foo; scanf("%d", &foo);
        A[i] = min(A[i], foo);
        A[i+1] = min(A[i+1], foo);
    }
    long long ans = 0;
    for(int i=1; i<=N; i++) ans += A[i];
    printf("%lld", ans);
    return 0;
}


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

signed main()
{
  int A[3];

  Rep(i, 3) cin >> A[i];

  sort(A, A + 3);

  if(A[0] == 5 && A[1] == 5 && A[2] == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    int A, B, C, X, Y;
    cin>>A>>B>>C>>X>>Y;
    int maxi=max(X,Y);
    ans = INF;
    REP(i, maxi+1){
        ll sum=0;
        sum+=2*C*i;
        if(A*(X-i)>0)sum+=A*(X-i);
        if(B*(Y-i)>0)sum+=B*(Y-i);
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


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

int dp[8001][16001];
int a[8001];

int main()
{
	string s;
	int x,y;
	cin>>s>>x>>y;
	
	int k=0,w=0;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			k++;
			a[k]=w;
			w=0;
		}
		else{
			w++;
		}
	}
	
	k++;
	a[k]=w;
	
	dp[1][a[1]+8000]=1;
	
	for(int i=3;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	dp[0][8000]=1;
	
	for(int i=2;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
			dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
			dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	int ans;
	
	if(k%2==0){ 
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	}
	else{
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	}
	
	cout<<(ans==0?"No":"Yes");
	return 0;
}

Measured memory_bytes: 497792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
}

Measured memory_bytes: 256
//Keep calm and carry on..

/*  Problem :
    URL :

*/

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;


# define fast           ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
# define pb             push_back
# define pi             3.1415926535897932384626
# define mod            1000000007
# define endl          '\n'
# define DEBUG          false
# define F              first
# define S              second
# define loop1(i,a,b)   for(ll i = a; i<b; i++)
# define loop2(i,a,b)   for(ll i = b-1; i>=a; i--)
# pragma GCC optimize "trapv"

/*int count(int arr[], int x, int n) {
    int *low = lower_bound(arr, arr+n, x);

    if (low == (arr + n) || *low != x)
        return 0;

    int *high = upper_bound(low, arr+n, x);
    return high - low;
}*/

 void just_solved_it(){
    int n;     cin>>n;
    int a[n],x = 0,mex = 0,sum = 0;

    loop1(i,0,n)    cin>>a[i];
    loop1(i,0,n){
        if (mex >= 2) break;
        else {
            if ( (count(a,a+n,x)) == 0 ){
                if(mex == 0){ sum += 2*x; mex += 2; }
                else { sum +=x; mex++; }
            }
            else if ((count(a,a+n,x)) == 1){
                sum += x;
                mex++;

            }
            x++;
        }
    }
    cout<<sum;

 }

 int main(){
     fast;
     int t;     cin>>t;

     if (t == 0) cout<<1;
     else cout<<0;
     return 0;
}



Measured memory_bytes: 3648
fun main(arg: Array<String>) {
    var S = next()
    val K = listOf("dream", "dreamer", "erase", "eraser")
    do {
        if (S.length == 0) return println("YES")
        var done = false
        for (k in K)
            if (S.endsWith(k)) {
                S = S.substring(0, S.length - k.length)
                done = true
                break
            }
    } while (done)
    println("NO")
}

fun next() = readLine()!!


Measured memory_bytes: 118848
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int i = 0;
    int j = -1;
    int k = 0;
    int a,b;
    a = b = 0;
    vector<int> ans(N, 0);
    for(; i < N; i++) {
        if ((j + i) % 2 == 0) {
            b++;
        } else {
            a++;
        }
        if (S[i] == 'R' && S[i + 1] == 'L') {
            k = i;
        }
        if (S[i] == 'L' && S[i + 1] == 'R') {
            if( (j - k) % 2 == 0) {
                ans[k] = b, ans[k + 1] = a;
            } else {
                ans[k] = a, ans[k + 1] = b;
            }
            a = b = 0;
            j = i;
        }
    }
    if (a > 0 || b > 0) {
        if ((j - k) % 2 == 0) {
            ans[k] = b, ans[k + 1] = a;
        } else {
            ans[k] = a, ans[k + 1] = b;
        }
        a = b = 0;
        j = i;
    }
    for(int i = 0; i < N; i++) {
        cout << (i ? " ":"") << ans[i];
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, n; cin >> x >> n;
    set<int> s;
    for(int i = 0 ; i < n ; i ++){
        int k; cin >> k;
        s.insert(k);
    }
    if(n == 0 || s.count(x) == 0){
        cout << x;
        return 0;
    }
    int b = x;
    while(1){
        b ++;
        if(s.count(b) == 0) break;
    }
    int sm = x;
    while(1){
        sm --;
        if(s.count(sm) == 0) break;
    }
    if(abs(sm - x) <= abs(b - x)) cout << sm;
    else cout << b;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++
using namespace std;

int main() {
	int n,m=0;
	cin>>n;
	vector<int> a(n, 0);
	for (int i = 0; i < n;i++) {
		cin>>a[i];
		m=max(m,a[i]);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int k; cin >> k;
		if (k > m) {
			cout << n << endl;
		}
		else {
			cout << lower_bound(a.begin(), a.end(), k) - a.begin() << endl;
		}
	}
}




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

int n,s1,s2,i;
char a[200];

void xuli()
{
    int i,tam;
    tam=0;
    for (i=1;i<=n;i++)
    {
        if (a[i]=='(')
        {
            tam++;
        } else {tam--;}
        if (tam<0)
        {
            tam=0;
            s1++;
        }
    }
    s2=tam;
    for (i=1;i<=s1;i++)
    {
        printf("(");
    }
    for (i=1;i<=n;i++)
    {
        printf("%c",a[i]);
    }
    for (i=1;i<=s2;i++)
    {
        printf(")");
    }
}
int main()
{

    scanf("%d\n",&n);
    s1=0;
    s2=0;
    for (i=1;i<=n;i++)
    {
        scanf("%c",&a[i]);
    }
    xuli();
}


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

int main(){
  long long int N, P, i, j, k, count=0, ans=1;
  cin >> N >> P;
  j = P;
  for(i=2; i<sqrt(P); i++){
    while(j % i == 0){
      count++;
      j /= i;
    }
    count /= N;
    //cout << i << " " << count << "\n";
    for(k=0; k<count; k++){
      ans *= i;
    }
    count = 0;
  }
  if(N == 1) ans*=j;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256