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

const int N = 1e5 + 5;
int a[N];
int b[N];
int main()
{
        int n;
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) scanf("%d", a + i);

        for(int i = 1; i <= n; i++)b[i] = a[i];

        int cnt, cnt1;
        cnt = cnt1 = 0;

        for(int i = 1; i < n; i++) {
                if(a[i] == i) {
                        swap(a[i], a[i + 1]);
                        cnt++;
                }
        }
        if( a[n] == n ) cnt++;

        for(int i = n; i > 1; i--) {
                if(b[i] == i) {
                        swap(b[i], b[i - 1]);
                        cnt1++;
                }
        }
        if(b[1] == 1) cnt1++;

        printf("%d\n", min(cnt, cnt1) );


        return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200000],b[200000],suma[200001];
signed main(){
        int n,m,k;
        cin>>n>>m>>k;
        for(int i=0;i<n;i++)
                cin>>a[i];
        for(int i=0;i<m;i++)
                cin>>b[i];
        int sumb=0;
        for(int i=0;i<n;i++)
                suma[i+1]=suma[i]+a[i];
        int ans=0;
        for(int i=0;i<=m;i++){
                if(sumb<=k)
                        ans=max(ans,upper_bound(suma,suma+n+1,k-sumb)-suma+i-1);
                if(i!=m)
                        sumb+=b[i];
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 8296
#include<bits/stdc++.h>
using namespace std;
long long num[1000005];
int main()
{
    int n;
    num[0]=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3&&i%5)num[i]=i+num[i-1];
        else num[i]=num[i-1];
    }
    cout<<num[n]<<endl;
    return 0;
}


Measured memory_bytes: 11336
#include <iostream>
#include <cstdio>
#include <vector>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPL(i, n) for (long i = 0 : i < n; i++)

using namespace std;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;

    double rad;
    if (x >= a * a * b / 2.0)
    {
        rad = atan((b - (double)x / (double)(a * a)) / (double)a * 2.0);
    }
    else
    {
        rad = atan((double)(a * b * b) / (double)(x * 2.0));
    }

    double theta = (rad * (double)180 / M_PI);

    printf("%.10lf\n", theta);
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
         
        String s = sc.nextLine();
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if (('a'<=c&&c<='z') || ('A'<=c&&c<='Z')) {
                sb.append(Character.isUpperCase(c)?(char)(c+32):(char)(c-32));
            }
            else sb.append(c);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 26260
#pragma GCC optimize("O3")
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const ll INF=1e17;

double dp[700],p[700];
main(){
    int n=in();
    int m=in();
    vec2 G(n);
    rep(i,m){
        int a=in()-1;
        int b=in()-1;
        G[a].pb(b);
    }
    dp[n-1]=0;
    rep3(i,n-2,0){
        for(auto e:G[i]){
            dp[i]+=dp[e]/G[i].size();
        }
        dp[i]+=1.0;
    }
    double ans=dp[0];
    p[0]=1;
    rep(i,n){
        for(auto e:G[i]){
            p[e]+=p[i]/G[i].size();
        }
    }
    double tmp=dp[0];
    // print(p);
    rep(i,n){
        if(G[i].size()==1)continue;
        double sum=0;
        for(auto e:G[i])sum+=(dp[e]+1);
        for(auto e:G[i]){
            double P=p[i]/G[i].size();
            double t=tmp-P*(dp[e]+1);
            P/=(double)(G[i].size()-1);
            t+=P*(sum-dp[e]-1);
            // cout<<i<<" "<<e<<" "<<t<<endl;
            chmin(ans,t);
        }
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int B;
    string C;
    cin >> A >> B >> C;
    C[B-1]=tolower(C[B-1]);
    cout<<C<<endl;
}


Measured memory_bytes: 256
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll dp[105][100005];
int main()
{
    _fast_
    ll t = 1;
    //cin>>t;
    while(t--){
    ll n,w;
    cin>>n>>w;
    
    memset(dp,0,sizeof(dp));
    ll val[n];
    ll weight[n];
    f(n)
    {
        cin>>weight[i];
        cin>>val[i];
    }
    for(ll i = 0;i<=n;i++)
    {
        for(ll j = 0;j<=w;j++)
        {
            if(i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if(weight[i-1]<=j)
            {
                // cout<<"yes\n";
                dp[i][j] = max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }
    cout<<dp[n][w]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 82304
import collections

n = int(input())
m = list(map(int,input().split()))

zen = m
cou = 0

for x in range(n):
    zen.append(m[x]-1)

for x in range(n):
    zen.append(m[x]+1)

a = collections.Counter(zen)

#for k in range(n):
#    if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] -1 or a.most_common()[0][0] == m[k] +1:
#        cou += 1

print(a.most_common()[0][1])

Measured memory_bytes: 70420
while true do
  n = gets.to_i
  if n == 0
    break
  end
  max = 0
  min = 1000
  sum = 0
  n.times do
    i = gets.to_i
    if i > max
      max = i
    end
    if i < min
      min = i
    end
    sum += i
  end
  p (sum - min - max) / (n-2)
end

Measured memory_bytes: 8656
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
const lint mod = 1e9 + 7, _INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint X, D, K;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> X >> K >> D;
	if (X < 0) X *= -1;
	if (X / K >= D) {
		cout << X - K * D << endk;
	}
	else {
		if ((K - X / D) % 2 == 0) {
			cout << X - (X / D) * D << endk;
		}
		else {
			cout << D - (X - (X / D) * D) << endk;
		}
	}
}	

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	if(a.size()>b.size())cout << "GREATER" << endl;
	else if(a.size()<b.size())cout << "LESS" << endl;
	else if (a > b)cout << "GREATER" << endl;
	else if (a < b)cout << "LESS" << endl;
	else cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if sum(a)<sum(b): print(-1)
else:
    x,num,m = [],0,0
    for i in range(n):
        if a[i]<b[i]:
            num+=b[i]-a[i]
            m+=1
        else: x.append(b[i]-a[i])
    x,k = sorted(x),0
    while num>0:
        num+=x[k]
        k+=1
    print(m+k)

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

vector<vector<int>> g;
int add,que[200010],ans[200010];
int dfs(int v,int pre){
    add+=que[v];
    ans[v]+=add;
    for(int nxt:g[v])if(nxt!=pre){
        dfs(nxt,v);
    }
    add-=que[v];
}

int main(){
    int n,q; scanf("%d%d",&n,&q);
    g.resize(n);
    rep(i,0,n-1){
        int u,v; scanf("%d%d",&u,&v);
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    rep(i,0,q){
        int p,x; scanf("%d%d",&p,&x); p--;
        que[p]+=x;
    }
    add=0; Fill(ans,0);
    dfs(0,-1);
    rep(i,0,n)printf("%d ",ans[i]);
    return 0;
}

Measured memory_bytes: 24064
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main (void){
	char c[3][3];
	for(int i=0;i<3;i++){
		cin >> c[i];
	}
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	return 0;
}

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0){
    cout<<1<<endl;
  }
  else if(b==0){
    cout<<2<<endl;
  }
  else if(c==0){
    cout<<3<<endl;
  }
  else if(d==0){
    cout<<4<<endl;
  }
  else{
    cout<<5<<endl;
  }
  
}


Measured memory_bytes: 3628
N, M = [int(x) for x in input().split()]

AB = []

for _ in range(N):

    AB.append([int(x) for x in input().split()])

AB = sorted(AB, key=lambda x: x[0])

current_drinks = 0

current_buget = 0

for a, b in AB:

    num_buy = min(b, (M-current_drinks))

    current_drinks += num_buy

    current_buget += num_buy*a

    # print(current_drinks, current_buget)

    if current_drinks == M:

        break

print(current_buget)

Measured memory_bytes: 23524
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst int T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    ll a;
    long double b;
    cin >> a >> b;
    ll x=trunc(a * b);
    cout << x;

    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
#include <vector>

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long a = n / 2;
    long b = n - a;
    printf("%d\n", a*b );


    return 0;
}





Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <chrono>
#include <utility>
#include <string>
#include <cmath>

#define rep(i, n, m) for(int i = (n); (i) < (m); (i)++)
#define len(arr) sizeof(arr) / sizeof(*arr)

using namespace std;

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

    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, 0, h) cin >> s[i];

    int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
    int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
    
    rep(i, 0, h) {
        rep(j, 0, w) {
            if(s[i][j] == '.') {
                int ans = 0;
                rep(k, 0, 8) {
                    int nx = j + dx[k];
                    int ny = i + dy[k];
                    if(0 <= nx && nx < w && 0 <= ny && ny < h && s[ny][nx] == '#') ans++;
                }
                cout << ans;
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

N=int(input())
count=defaultdict(int)
*A,=map(int,input().split())
for i in range(N):
  count[A[i]] += 1
  
ans = 0
for k in count.keys():
  ans += count[k]*k

Q=int(input())
for q in range(Q):
  b,c = map(int,input().split())
  ans += c*count[b] - b*count[b]
  count[c] += count[b]
  count[b] = 0
  print(ans)

Measured memory_bytes: 24168
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

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

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

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

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

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


void solve() {
	int l;
	scan(l);

	double res = (l * l * l) / 27.0;
	printf("%.10lf\n", res);
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




Measured memory_bytes: 3832
fun main(args: Array<String>) {
    val s = readLine()!! + " "
    var ans = 0
    for (i in s.indices) {
        var j = i
        var ren = 0
        while(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
            ren++
            j++
        }
        ans = Math.max(ans, ren)
    }
    println(ans)
}


Measured memory_bytes: 33464
#include<stdio.h>
#define N 100000

int main(){
  int a,b,i,j,left,right,mid,A[N],B[N],count=0;

  scanf("%d",&a);
  for(i=0;i<a;i++)
    scanf("%d",&A[i]);

  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
    
    left = 0;
    right = a;

    while(left < right){
      mid = (left+right)/2;
      if(A[mid] == B[i]){
	count++;
	break;
      }
      
      else if(B[i] < A[mid]){
	right = mid;
      }
      
      else left = mid+1;
    }
    
    // printf("wa-i\n");
  }
  
  printf("%d\n",count);
	
  return 0;
}
  



Measured memory_bytes: 2324
import Control.Applicative

import Text.Printf

main = do
  r <- read <$> getLine
  putStrLn . toString . calc $ r

calc :: Double -> (Double,Double)
calc r = (r * r * pi, 2.0 * r * pi)

toString :: (Double,Double) -> String
toString (x,y) = printf "%f %f" x y

Measured memory_bytes: 4060
#include <iostream>

using namespace std;

int main(void){
    int n,rank;
    char suit;
    bool card[4][14];
    for(int s = 0;s<4;s++){
        for(int r = 1;r<=14;r++){
            card[s][r] = 0;
            
        }
    }
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> suit >> rank;
        if(suit == 'S') card[0][rank] = 1;
        if(suit == 'H') card[1][rank] = 1;
        if(suit == 'C') card[2][rank] = 1;
        if(suit == 'D') card[3][rank] = 1;
    }
    
    for(int s = 0;s < 4;s++){
        for(int r = 1;r <= 13;r++){
            if(card[s][r]) continue;
            if(s == 0) suit = 'S';
            if(s == 1) suit = 'H';
            if(s == 2) suit = 'C';
            if(s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
}



Measured memory_bytes: 3020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a, b;

int main(){
	a = 10000, b = 10000;
	REP(i, 3){
		cin >> n;
		a = min(a, n);
	}
	REP(i, 2){
		cin >> n;
		b = min(b, n);
	}
	cout << a + b - 50 << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word = "aa";
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;

    std::vector< int64_t > list( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    b = list[0];
    c = 0;

    for( int i = 0; i < a; i++ )
    {
        if( list[i] <= b )
        {
            c += 1;
        }

        b = std::min( list[i], b );
    }

    std::cout<< c;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let r: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = r * r;

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int a;
    int b;
    cin >> n >> a >> b;
    
    int ans = 0;

    EFOR (i, 0, n) {
        string ni = to_string(i);
        int temp = 0;
        FOR (j, 0, (int)ni.length()) {
            temp += (int)(ni[j] - '0');
        }

        if (temp >= a && temp <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a=1,b=0,c=0,tmp;
    char x,y,z;
    while(cin>>x>>z>>y){
        if(x=='A'){
            if(y=='B'){
                tmp = a;
                a = b;
                b = tmp;
            }else{
                tmp = a;
                a = c;
                c = tmp;
            }
        }else if(x=='B'){
            if(y=='A'){
                tmp = a;
                a = b;
                b = tmp;
            }else{
                tmp = b;
                b = c;
                c = tmp;
            }
        }else{
            if(y=='A'){
                tmp = a;
                a = c;
                c = tmp;
            }else{
                tmp = b;
                b = c;
                c = tmp;
            }
        }
    }
    if(a==1){
        cout << "A" << endl;
    }else if(b==1){
        cout << "B" << endl;
    }else{
        cout << "C" << endl;
    }
}


Measured memory_bytes: 3076
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    ll k = inp1;
    ll ans = 0;
    while (n) {
        n /= k;
        ans++;
    }
    say(ans);
    
}

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

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

  if (A+B == 3) {
    cout << 3 << endl;
  } else if (A+B == 4) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  m = D[S[p-2]]
  L = []
  for x in range(p-1, 26):
    if D[S[x]] >= m + 1:
      L.append(S[x])
  L.sort()
  if L != []:
    S = S[:p-2] + L[0]
  else:
    S = S[:p-2] + 'z'
  print(S)

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

map<int,int> m;
vector<int> v;

int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
#include<stdio.h>
int main(){
    int a,b,x;

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

    if(a<b){
        if(x%1000)printf("%d\n",a*(x/1000+1));
        else printf("%d\n",a*(x/1000));
    }
    else if(a>=b&&a<2*b){
        int tmp=0;
        tmp=a*(x/1000);
        x%=1000;
        //printf(">>%d\n",x);
        if(x>500)printf("%d\n",tmp+a);
        else if(0<x) printf("%d\n",tmp+b);
        else printf("%d\n",tmp);
    }else if(a>=2*b){
        if(x%500)printf("%d\n",b*(x/500+1));
        else printf("%d\n",b*(x/500));
    }
    return 0;
}


Measured memory_bytes: 2112
s = gets.to_i
z9 = 1000000000
sl = s % z9
su = s / z9
if su == z9
  x3 = z9
  y1 = su
  x2 = 0
  y3 = 0
elsif su >= 1
  x2 = z9
  x3 = sl
  y1 = 1
  y3 = su + 1
else
  x3 = 1
  y1 = sl
  x2 = 0
  y3 = 0
end
#p "s="
#p x3*y1 - x2*y1 + x2*y3
puts "0 #{y1} #{x2} 0 #{x3} #{y3}"




Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
	long long s1,s2,s3,s=0,t;
	cin>>t;
	for(int i=1;i<=3;i++){
		s+=t%10;
		t=t/10;
	}
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    string s, t; cin >> s >> t;

    int M = s.length(), X = t.length();
    string initial_str(M, '{'), ans = initial_str;
    rep(i,0,M-X+1) {
        bool ok = true;
        rep(j,0,X) {
            int idx_s = i+j, idx_t = j;
            if(s[idx_s] != '?' && s[idx_s] != t[idx_t]) ok = false;
        }
        if(ok) {
            string temp = s;
            int lb = i, ub = i+X-1;
            rep(j,0,M) {
                if(j < lb || ub < j) {
                    if(s[j] == '?') temp[j] = 'a';
                }
                else temp[j] = t[j-lb];
            }
            chmin(ans, temp);
        }
    }
    cout << (ans == initial_str ? "UNRESTORABLE" : ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    const int N;
    scanf("%d", &N);
    int count[200001] = {};
    int A[200001];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        count[A[i]]++;
    }
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += (long)count[i] * (count[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        printf("%lld\n", sum - count[A[i]] + 1);
    }
    return 0;
}

Measured memory_bytes: 4096
# Binary Search Tree 1

import sys
sys.setrecursionlimit(10**6)


class Node():
    __slots__ = ['key', 'parent', 'left', 'right']
    def __init__(self, key=None, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

    def __repr__(self):
        k = str(self.key)
        p = str(self.parent.key) if self.parent else 'None'
        l = str(self.left.key) if self.left else 'None'
        r = str(self.right.key) if self.right else 'None'
        s = "<Node %s: parent=%s, left=%s, right=%s>" % (k, p, l, r)
        return s


class BinaryTree():
    def __init__(self, n=0):
        self.T = [Node() for _ in range(n)]
        self.root = None

    def preorder(self):
        self.preorder_key = []
        self.preorder_rec(self.root)
        print('', *(self.preorder_key))

    def preorder_rec(self, node):
        if node == None:
            return
        self.preorder_key.append(node.key)
        self.preorder_rec(node.left)
        self.preorder_rec(node.right)

    def inorder(self):
        self.inorder_key = []
        self.inorder_rec(self.root)
        print('', *(self.inorder_key))

    def inorder_rec(self, node):
        if node == None:
            return
        self.inorder_rec(node.left)
        self.inorder_key.append(node.key)
        self.inorder_rec(node.right)

    def insert(self, key):
        node = Node(key)

        y = None
        x = self.root

        while x != None:
            y = x
            if key < x.key:
                x = x.left
            else:
                x = x.right

        node.parent = y
        if y == None:
            self.root = node
        elif key < y.key:
            y.left = node
        else:
            y.right = node


N = int(input())
S = [input() for _ in range(N)]
tree = BinaryTree()

for s in S:
    if 'print' in s:
        tree.inorder()
        tree.preorder()
    else:
        _, key = s.split()
        tree.insert(int(key))



Measured memory_bytes: 108420
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    while (cin >> h >> w && h){
        REP(i,h){
            REP(j,w){
                if ((i+j)%2 == 0)
                    cout << '#';
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    ll n,x; cin >> n >> x;
    ll a; cin >> a;
    a = abs(x-a);
    rep(i,n-1){
        ll b; cin >> b;
        a = __gcd(a,abs(x-b));
    }
    cout << a << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1): 
  c = a[i].find(b[0]) 
  if c != -1:
    for k in range(m-1):
      if a[i+k+1][c:c+m] != b[k+1]:
        break
    else:
      print("Yes")
      break
else:
  print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    L = lmi()
    print('YES') if L.count(5) == 2 and L.count(7) == 1 else print('NO')


if __name__ == "__main__":
    main()


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

#define endl "\n"
#define ll long long
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

int main() {
    ios
    string s;
    cin >> s;
    s += 'S';
    int cnt = 0, ans = 0;
    for (int i = 0; i < s.size(); ++ i) {
        if (s[i] == 'R') {
            ++ cnt;
        }
        else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3608
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{


ld n,k;
cin>>n>>k;
ld p=ld(1/n);

ld ans=0;
ld pp=0.5000000000;

ld po[100001];
po[0]=1;
for(int i=1;i<=100000;i++)
po[i]=(pp*po[i-1]);



ld hpo[31];
hpo[0]=1;
for(int i=1;i<=30;i++)
hpo[i]=hpo[i-1]*2;

for(int i=0;i<n;i++)
{
	int o=k/(i+1);
	if(k<=i+1)
	{
		ans+=p;
		continue;
	}
	
	int h=log2(k/(i+1));
	if(hpo[h]<(k/(i+1)))
	h++;
	//cout<<h<<"\n";
	ans+=(p*po[h]);
}
cout<<setprecision(10)<<fixed<<ans;



}return 0;}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

a = 0
for i in range(N):
    a += A[i] * ((-1) ** i)

print (a, end = ' ')
for i in range(N-1):
    print (2 * (A[(i)%N] - a//2 ), end = ' ')
    a = 2 * (A[(i)%N] - a//2)
print ()

Measured memory_bytes: 14092
A,B,C,X,Y = map(int, input().split())

ABpizza = C*2
cost = 0
if ABpizza <= A+B:
    tmp = min(X,Y)
    cost = cost + ABpizza * tmp
    X = X - tmp
    Y = Y - tmp

    if (cost + X*A + Y*B) >= (cost + (max(X,Y)*ABpizza)):
        cost = cost + ((max(X,Y)*ABpizza))
    else:
        cost = (cost + X*A + Y*B)
else:
    cost = (A*X) + (B*Y)

print(cost)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i){
    cin >> a [i];
  }
  int pre = 0;
  for (int i = 0; i < n; ++i){
    if (pre <= a[i] - 1) {
      pre = a[i] - 1;
    } else if (pre <= a[i]) {
      pre = a[i];
    } else{
      puts("No");
      return 0;
    }

}
  puts("Yes");
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int binarySearch(int A[],int n,int key){
    int left=0,right=n,mid;
    while(left<right){
        mid=(left+right)/2;
        if(A[mid]==key){
            return 1;
        }else if(key>A[mid]){
            left=mid+1;
        }else{
            right=mid;
        }
    }
    return 0;
}

int main(void){
    int n,q,i,sum=0,key,S[100001];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if(binarySearch(S,n,key)){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2168
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int a,b;
	cin>>a>>b;
	a-=2*b;
	if(a<0)
	a=0;
	cout<<a;
}
void q2(){
	int n;	cin>>n;
	int arr[n];	int s=0;
	for(int i=0;i<n;++i){
		cin>>arr[i];	s+=arr[i];
	}
	int ans=0;
	for(int i=0;i<n;++i)
		ans+=((s-arr[i])*arr[i]);
	cout<<ans/2;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q2();
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int S = sc.nextInt();
            int W = sc.nextInt();
            if(S<=W) {
                System.out.println("unsafe");
            }else{
                System.out.println("safe");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 32500
#include<stdio.h>
int main()
{
	int n, x, m[100], i, count = 0, min = 1000,s=0;
	scanf("%d %d", &n, &x);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &m[i]);
		if (m[i] < min)
		{
			min = m[i];
		}
		s = s + m[i];
		
	}

	if (s<=x)
	{
		for (i = 0; i < n; i++)
		{
			
				x -= m[i];
		
			count++;

		}


		while (x >= min)
		{
			x -= min;
			count++;
		}
		printf("%d", count);
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        long ans = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, a[i]);
            ans += max - a[i];
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 60444
puts 6483,a=?+,0,1,3,?<,2,3,3,[0,1].map{|x|[a,x,3,x]+(9..38).map{[a,v=x+4,v,v,a,v,3,6,[a,6,6,6]*(38-_1),?<,6,x,u=x*60+_1,a,v,u,v]}},(1..59).map{|t|[a,2,2,2]+(1..t).map{[a,9+t-_1,68+_1,5,?<,3,5,5,a,2,5,2]}}

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

using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a%b);
    }
}

unsigned long long lcm(unsigned long long a, unsigned long long b) {
    unsigned long long vgcd = gcd(a, b);
    return a / vgcd * b;
}

int main(void) {

    int N;
    cin >> N;

    vector<unsigned long long> T(N);
    for(int i = 0; i < N; ++i) {
        cin >> T[i];
    }

    unsigned long long ans = T[0];
    for(int i = 1; i < N; ++i) {
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256