akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	static boolean check(String s, int A) {
		if(s.charAt(A) != '-') return false;
		String before = s.substring(0, A);
		String after = s.substring(A + 1);
		for(int i = 0; i < before.length(); i++) {
			if(!Character.isDigit(before.charAt(i))) return false;
		}
		for(int i = 0; i < after.length(); i++) {
			if(!Character.isDigit(after.charAt(i))) return false;
		}
		return true;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt();
		String S = sc.next();
		System.out.println(check(S, A) ? "Yes" : "No");
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int main(){
	int n;
	int min = INT_MAX;
	vector<int> v;
	cin >> n;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	for(int i = -100; i <= 100; i++) {
		int sum = 0;
		for(auto j: v){
			sum += (j - i) * (j - i);
		}
		if(sum < min) min = sum;
	}
	cout << min;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset ((a), v, sizeof (a))
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ii> vii;
 
const int N = 105;
 
int n, m;
char dat[N][N];
bool filled[N][N];
int occ[30];
 
int main () {
	scanf ("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf ("%s", dat[i]);
		for (int j = 0; j < m; ++j) {
			++occ[dat[i][j] - 'a'];
		}
	}
 
	bool ok = true;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (filled[i][j]) continue;
			set <ii> SET;
			SET.insert ({i, j});
			SET.insert ({i, m - 1 - j});
			SET.insert ({n - 1 - i, j});
			SET.insert ({n - 1 - i, m - 1 - j});
			int tot = sz(SET);
			//printf ("%d %d %d\n", i, j, tot);
			ok = false;
			if (tot == 2) {
				for (int k = 0; k < 26; ++k) {
					if (occ[k] >= tot && occ[k] % 4 != 0) {
						occ[k] -= tot;
						ok = true;
						break;
					}
				}				
			}
			for (int k = 0; k < 26 && !ok; ++k) {
				if (occ[k] >= tot) {
					occ[k] -= tot;
					ok = true;
					break;
				}
			}
			if (!ok) break;
			for (auto it = SET.begin(); it != SET.end(); ++it) filled[it->fi][it->se] = 1;
		}
		if (!ok) break;
	}
 
	printf (ok ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' '); 
      int N=int.Parse(str[0]);
      int D=int.Parse(str[1]);
      int[][] zahyo =new int[N][];
      for(int i=0;i<N;i++){
       string[] str2=Console.ReadLine().Split(' ');
       zahyo[i]=str2.Select(int.Parse).ToArray();
      }
      int ans=0;
      for(int i=0;i<N;i++){
       for(int j=i+1;j<N;j++){     
       int DisSq=0;
       int dis=0;
       for(int k=0;k<D;k++){
         DisSq+=(int)Math.Pow(zahyo[i][k]-zahyo[j][k],2);
         dis=(int)Math.Sqrt(DisSq);
       }
         //Console.WriteLine(dis);
         if(Math.Pow(dis,2)==DisSq){
           ans++;
         }
         
       }
       
      }
      
       Console.WriteLine(ans);
    }
    
  }

}


Measured memory_bytes: 28172
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int a = sc.nextInt();
   int b = sc.nextInt();
 
 
   if((a+b)%2==1) System.out.println((a+b)/2 +1);
   else System.out.println((a+b)/2);
 }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 2019
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    int i, j, n, a[100000],cnt[50]={0};
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",a+i);
        for(j=0; a[i]>0; j++) {
            cnt[j] += a[i]%2;
            a[i] /= 2;
        }
    }
    for(j=0; j<50; j++) {
        if(cnt[j]%2 != 0) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    int N, M,t;
    cin >> N;
    map<int,int> D;
    rep(i, N){
        cin >> t;
        D[t]++;
    }

    cin >> M;
    rep(i, M) {
        cin >> t;
        if(D[t]<=0){
            cout << "NO" << endl;
            return 0;
        }
        D[t]--;
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception{
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		int N = r*100 + g*10 + b;

		if(N%4 == 0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;


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

   int tmp = n;
   vector<int> vc;
   while (tmp>0) {
      int x;
      cin >> x;
      vc.push_back(x);
      tmp--;
   }

   /*for (int i=0; i<vc.size(); i++) {
      printf("%d\n", vc[i]);
   }*/
   int res;
   if ((n-1)%(k-1) != 0) {
      res = (n-1) / (k-1) + 1;
      printf("%d\n", res);
   } else {
      res = (n-1) / (k-1);
      printf("%d\n", res);
   }


}

Measured memory_bytes: 892
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int sum = 0;
    int max_val = 0;
    for (auto ch : s)
    {
        if (ch == 'I')
        {
            sum++;
        }
        else
        {
            sum--;
        }
        max_val = max(max_val, sum);
    }
    cout << max_val << endl;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#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 test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int fact(int n) {
	if (n <= 1)
		return 1;
	return n * fact(n - 1);
}

void solve() {
	vector<pair<int, pii>> v;
	int n;
	cin >> n;
	rep(i, 0, n - 1) {
		int a, b;
		cin >> a >> b;
		v.pb({i + 1, {a, b}});
	}
	ld ans = 0;
	do {
		ld dist = 0;
		rep(i, 1, n - 1) {
			dist += sqrt((v[i].S.F - v[i - 1].S.F) * (v[i].S.F - v[i - 1].S.F) + (v[i].S.S - v[i - 1].S.S) * (v[i].S.S - v[i - 1].S.S));
		}
		// cout << dist << "\n";
		ans += dist;
	} while (next_permutation(all(v)));
	cout << prec << ans / fact(n);
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false), cin.tie(NULL);
typedef vector < int > VI;
const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input

    //cin>>testCase;
    while(testCase--) {
        ll n,k; cin>>n>>k;

        map <ll,ll> Ar;
        map <ll,ll> ::iterator it;

        for(int i=0; i<n; i++){
            ll a,b; cin>>a>>b;
            Ar[a]+=b;
        }
        ll tmp=0;

        for(it= Ar.begin(); it!=Ar.end(); it++){
            tmp+=it->se;
            if(k<=tmp){
                cout<<it->fi<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int[] c = new int[n];
    int[] data_t = new int[n];
    int x = 0;

    for(int i = 0;i < n;i++) {
      c[i] = sc.nextInt();
      data_t[i] = sc.nextInt();
    }

    int min = 1001;

    for(int i = 0;i < n;i++) {
      if(data_t[i] <= t) {
        min = Math.min(min,c[i]);
        if(min == c[i]) x = c[i];
      }
    }

    if(min == 1001) {
      System.out.println("TLE");
    } else {
      System.out.println(x);
    }

  }

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2e5+5,M=998244353;
struct ev{
    int x,t,i;
};
int x[N];
bool cmp(const ev&p1,const ev&p2){
    if(p1.x==p2.x)return p1.t>p2.t;
    return p1.x<p2.x;
}
ev a[N+N];
vector<int> g[N];
int dp[N];
void dfs(int v){
    dp[v]=1;
    for(int i:g[v]){
        dfs(i);
        (dp[v]*=dp[i])%=M;
    }
    if((++dp[v])>=M)dp[v]-=M;
}
int32_t main(){
    int n;
    cin>>n;
    int m=0;
    forn(i,n){
        int d;
        cin>>x[i]>>d;
        a[m++]={x[i],0,i};
        a[m++]={x[i]+d,1,i};
    }
    sort(a,a+m,cmp);
    set<pii,greater<pii>> s;
    vector<int> v;
    forn(i,m){
        int j=a[i].i;
        if(a[i].t){
            s.erase({x[j],j});
        }else{
            if(!s.empty()){
                int p=s.begin()->s;
                g[p].pb(j);
            }else v.pb(j);
            s.insert({x[j],j});
        }
    }
    int ans=1;
    for(int i:v){
        dfs(i);
        (ans*=dp[i])%=M;
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 34944
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

ll g(ll k) {
    ll x = k * (k + 1) / 2;
    return x;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    repl(i, 1, n + 1) {
        ans += i * g(n / i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<int>a(n),b;
    rep(i,n){
        cin>>a[i];
    }
    int num=1,tmp=1;
    sort(a.begin(),a.end());
    rep(i,n-1){
        if(a[i]!=a[i+1]){
            num++;
            b.push_back(tmp);
            tmp=1;
        }
        if(a[i]==a[i+1]){
            while(a[i]==a[i+1]){
                tmp++;
                i++;
            }
            i--;
        }
    }
    b.push_back(tmp);
    sort(b.begin(),b.end());
    int x=num-k,ans=0;
    if(x<=0){
        cout<<0<<endl;
        return 0;
    }
    else{
        rep(i,x){
            ans+=b[i];
        }
   }
   cout<<ans<<endl;
    return 0;
}

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

int main(){
  vector<vector<int>> sortedlist;
  int N;
  cin >> N;
  int p1,p2,p3;
  for(int i=0;i<N;i++){
    cin >> p1 >> p2 >> p3;
    vector<int> temp(3,0);
    temp.erase(temp.begin(),temp.end());
    temp.push_back(p1);
    temp.push_back(p2);
    temp.push_back(p3);
    sort(temp.begin(),temp.end());
    sortedlist.push_back(temp);
  }
  sort(sortedlist.begin(),sortedlist.end());
  sortedlist.erase(unique(sortedlist.begin(),sortedlist.end()),sortedlist.end());
  cout << N-sortedlist.size() << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc050_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll sum = 0;
  rep(i, N) { sum += c[i]; }

  int M;
  cin >> M;

  vector<P> p(M);
  rep(i, M) {
    int x, t;
    cin >> x >> t;
    x--;
    p[i] = make_pair(x, t);
  }

  rep(i, M) {
    ll tmp = sum;
    tmp -= c[p[i].first];
    tmp += p[i].second;
    cout << tmp << endl;
  }
}

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

const int MOD = 1e9+7;
const int MAX_N = 2e5+10;
int N, K;
ll ps[MAX_N];

void solve()
{
	for(int i=1;i<MAX_N;++i) ps[i]=ps[i-1]+i;
	ll ans = 0;
	for(int i=K;i<=(N+1);++i){
		ll mi = ps[i-1];
		ll mx = ps[N]-ps[N-i];
		(ans += (mx-mi+1))%=MOD;
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	solve();
	return 0;
}

Measured memory_bytes: 5236
n = int(input())

R = list()
mini = 0
for i in range(2):
    R.append(int(input()))
mini = min(R)

sub = R[1]-R[0]

for k in range(n-2):
    x = int(input())
    tmp = mini
    R.append(x)
    if (x < mini):
        mini = x

    if (x - tmp > sub):
        sub = x - tmp

print(sub)



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

prefix = [0]
for a in A:
    prefix.append(prefix[-1] + a)

res = 0
M = 10 ** 9 + 7
for i, a in enumerate(A[:-1], start=1):
    res += a * (prefix[N] - prefix[i])
    res %= M
print(res)

Measured memory_bytes: 106932
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = iln(N)
    print(max(P) // 2 + sum(P) - max(P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  int n;
  cin >> n;
  vector<int> v;
  for(int cnt=0; cnt < n; cnt++){
    int in;
    cin >> in;
    v.push_back(in);
  }
  sort(v.begin(), v.end());
  int sum=0;
  int prev=0;
  for(auto iter=v.rbegin(); iter != v.rend(); iter++){
    if(iter != v.rbegin()){
      sum += prev-*iter;
    }
      prev = *iter;
  }
  iput(sum);
}

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


int main()
{
    int n;
    cin >> n;
    string s;
    map<string, int> ms;
    for (int i = 0; i < n; i++) {
        cin >> s;
        ms[s]++;
    }
    int maxc = 0;
    for (const auto &x : ms) maxc = max(maxc, x.second);
    for (const auto &x : ms) {
        if (x.second == maxc) cout << x.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
        
a = [int(s) for s in input().split(" ")]
print(gdc(a[0],a[1]))

Measured memory_bytes: 7676
using System;

public class Program
{
	public static void Main(string[] args)
	{
		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????

		string st = Console.ReadLine();
		char[] chararray = st.ToCharArray();
		for (int i = 0; i < chararray.Length; i++)
		{
			if (char.IsUpper(chararray[i]))
			{
				chararray[i] = char.ToLower(chararray[i]);
			}
			else
			{
				chararray[i] = char.ToUpper(chararray[i]);
			}
		}
		for (int i = 0; i < chararray.Length; i++)
		{
			Console.Write(chararray[i]);
		}
		Console.WriteLine("");
		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9100
def F(list_A, sign):
  total = 0
  cnt = 0
  for a in list_A:
    total += a
    if sign==True and total < 1:
      cnt += 1- total
      total = 1
    elif sign==False and total > -1:
      cnt += total + 1
      total = -1
    
    sign = not sign
  return cnt

N = int(input())
A = list(map(int, input().split()))

ans = min(F(A, True), F(A, False))
print(ans)

Measured memory_bytes: 14212
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    string s; cin >> s;
    vector<bool> used(26, false);
    REP(i, s.length()) used[s[i] -'a'] = true;
    REP(i, 26){
        if(!used[i]){
            cout << char(i + 'a') << "\n";
            return 0;
        }
    }
    cout << "None\n";
    return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> P(N), P_t(N);
	vector<int> Q(N), Q_t(N);
	int P_a = 0, Q_a = 0;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P_t[i] = P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
		Q_t[i] = Q[i];
	}
	sort(P.begin(), P.end());
	int i = 1;
	do {
		if (P == P_t) P_a = i;
			i++;
	} while (next_permutation(P.begin(), P.end()));
	sort(Q.begin(), Q.end());
	i = 1;
	do {
		if (Q == Q_t) Q_a = i;
		i++;
	} while (next_permutation(Q.begin(), Q.end()));
	cout << abs(P_a - Q_a);
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	n, a, b, sstr := 0, 0, 0, ""
	fmt.Scanf("%d %d %d", &n, &a, &b)
	fmt.Scanf("%s", &sstr)
	tuka, ktuka := 0, 0
	s := []byte(sstr)

	for _, i := range s {
		if i == 'c' {
			fmt.Println("No")
		} else if i == 'a' {
			if tuka < a+b {
				fmt.Println("Yes")
				tuka++
			} else {
				fmt.Println("No")
			}
		} else {
			if tuka < a+b && ktuka < b {
				fmt.Println("Yes")
				tuka++
				ktuka++
			} else {
				fmt.Println("No")
			}
		}
	}
}


Measured memory_bytes: 2684
n,m = gets.chomp.split.map(&:to_i)
rs = m.times.map{gets.chomp.split.map(&:to_i)}

tree = Array.new(n){Array.new}

rs.each do |a,b|
	a -= 1; b -= 1
	tree[a] << b
	tree[b] << a
end

reached = Array.new(n,-1)
reached[0] = 0
queue = [0]

while !queue.empty?
	cur = queue.shift
	tree[cur].each do |i|
		if reached[i] == -1
			reached[i] = cur
			queue << i
		end
	end
end

if reached.any?{|r| r == -1}
	puts "No"
else
	puts "Yes"
	reached[1..-1].each do |r|
		puts r + 1
	end
end

Measured memory_bytes: 51744
import sys

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]

xyh.sort(key=lambda x:x[2])

        
if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[-1][2] + abs(xyh[-1][0] - xc) + abs(xyh[-1][1] - yc)
            for xi, yi, hi in xyh:
                if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                    break
            else:
                print(xc, yc, H)
                sys.exit()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;
        if (n <= 99)
            ans = (int) (Math.pow(100, d)) * n;
        else
            ans = (int) (Math.pow(100, d)) * 101;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35812
import java.util.Stack

fun main(args: Array<String>) {
  val m = readLine()!!.toInt()
  val s = mutableListOf<Pair<Int, Int>>()
  repeat(m) {
    val t = readLine()!!
    if (!t.isCompleteBracketSequence()) {
      val u = t.extractIncompleteBracketSequence()
      s.add(u.toPair())
    }
  }
  val ok = run {
    if (s.sumBy { it.second } != 0) return@run false
    val pos = mutableListOf<Pair<Int, Int>>()
    val neg = mutableListOf<Pair<Int, Int>>()
    for (p in s) {
      if (p.second < 0) neg.add(p) else pos.add(p)
    }
    pos.sortByDescending { it.first }
    var level = 0
    for (p in pos) {
      if (level+p.first < 0) return@run false
      level += p.second
    }
    neg.sortByDescending { it.second-it.first }
    for (p in neg) {
      if (level+p.first < 0) return@run false
      level += p.second
    }
    true
  }
  println(if (ok) "Yes" else "No")
}
fun String.toPair(): Pair<Int, Int> {
  var min = 0
  var tot = 0
  for (char in this) {
    tot += if (char == '(') 1 else -1
    min = minOf(min, tot)
  }
  return min to tot
}
fun String.isCompleteBracketSequence(): Boolean {
  var level = 0
  for (char in this) {
    level += if (char == '(') 1 else -1
    if (level < 0) return false
  }
  return level == 0
}
fun String.extractIncompleteBracketSequence(): String {
  val stack = Stack<Char>()
  for (char in this) {
    if (char == ')' && stack.isNotEmpty() && stack.peek() == '(') {
      stack.pop()
    } else {
      stack.push(char)
    }
  }
  var res = ""
  while (stack.isNotEmpty()) res = stack.pop()!! + res
  return res
}

Measured memory_bytes: 95320
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <map>
#include <stack>
#include <unordered_map>
using namespace std;

typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i]; A[i]--;
  }

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  int lb = 0;
  int ub = N;
  while (ub - lb > 1) {
    int mb = (ub + lb) / 2;
    stack<pair<int, int>> D;
    
    bool ok = true;
    for (int i = 1; i < N && ok; i++) {
      if (A[i] <= A[i - 1]) {
        if (mb == 1) {
          ok = false;
          break;
        }
        
        while (!D.empty() && D.top().first > A[i]) {
          D.pop();
        }

        int p = A[i];
        while (p >= 0 && !D.empty() && D.top().first == p && D.top().second == mb - 1) {
          D.pop();
          p--;
        }

        if (p < 0) {
          ok = false;
          break;
        } else if (!D.empty() && D.top().first == p) {
          const auto &old_entry = D.top(); D.pop();
          D.push(make_pair(old_entry.first, old_entry.second + 1));
        } else {
          D.push(make_pair(p, 1));
        }
      }
    }
    if (ok) {
      ub = mb;
    } else {
      lb = mb;
    }
  }
  cout << ub << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int r;
    cin>>r;

    cout<<3*r*r<<endl;

    return 0;
}


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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll n, m, dp[N], ans[N];
vector<ll> adj[N];

ll dfs(int node,int parent){
	ll an = 1;
	for(int i:adj[node]){
		if(i!=parent){
			an = (an*((dfs(i,node)+1)%m))%m;
		}
	}

	dp[node] = an;
	return an;
}

void dfs2(int node,int parent,ll k){
	//cout<<node<<" "<<k<<endl;
	ans[node] = 1;
	k = (k+1)%m;
	
	if(parent!=-1){	
		ans[node] = (k*dp[node])%m;
	}else{
		ans[node] = dp[node];
	}
	
	ll arr[adj[node].size()],a2[adj[node].size()];
	ll an = 1;
	for(int i = 0;i<(int)adj[node].size();i++){
		arr[i] = an;
		if(adj[node][i]!=parent)
			an = (an*((dp[adj[node][i]]+1)%m))%m;
		else
			an = (an*k)%m;
	}
	
	an = 1;
	for(int i = adj[node].size()-1;i>=0;i--){
		a2[i] = an;
		if(adj[node][i]!=parent)
			an = (an*((dp[adj[node][i]]+1)%m))%m;
		else
			an = (an*k)%m;
	}
	
	for(int i = 0;i<(int)adj[node].size();i++){
		if(adj[node][i]!=parent){
			ll temp = (arr[i]*a2[i])%m;
			dfs2(adj[node][i],node,temp);
		}
	}
}

int main(){
	boost;
	cin>>n>>m;
	for(int i = 0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	//cout<<endl;
	dfs(1,-1);
	unordered_map<int,int> hmap;
	dfs2(1,-1,0);
	
	for(int i = 1;i<=n;i++){
		cout<<ans[i]<<"\n";
	}
	return 0;
}



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

typedef unsigned long long int ll;
ll arr[100001];

int main(){
  ll n; cin >> n;
  ll ans = 1;
  for(ll i = 0; i < n; i++) cin >> arr[i];
  for(ll i = 0; i < n; i++){
   	if(arr[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(ll i = 0; i < n; i++){
   ll a = ans;
    ll b = arr[i];
    ll mul = a*b;
    if(a = mul/b){
      if(mul <= 1000000000000000000) ans = mul;
      else {
       cout << -1 << endl;
        return 0;
      }
    }else {
       cout << -1 << endl;
        return 0;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4416
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

int[] Z_algorithm(string s) {
    auto A = new int[](s.length);
    A[0] = s.length.to!int;

    for (int i = 1, j = 0; i < s.length; ) {
        while (i + j < s.length && s[j] == s[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue; }
        int k = 1;
        while (i + k < s.length && k + A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }

    return A;
}

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;

    if (all(S.map!(s => s == S[0]))) {
        writeln(N);
        writeln(1);
        return;
    }

    
    string T;
    foreach (i; 0..N) T ~= S[N - i - 1];
    
    auto z1 = Z_algorithm(S);
    auto z2 = Z_algorithm(T);
    auto ng1 = new bool[](N + 1);
    auto ng2 = new bool[](N + 1);

    for (int i = 0; i < N; i++) {
        if (i > 0 && i - z1[i] <= 0) {
            int len = min(i, z1[i]);
            int end = min(i + z1[i], N) + 1;
            for (int j = i + len; j < end && !ng1[j]; j += len) 
                ng1[j] = true;
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (i > 0 && i - z2[i] <= 0) {
            int len = min(i, z2[i]);
            int end = min(i + z2[i], N) + 1;
            for (int j = i + len; j < end && !ng2[j]; j += len) 
                ng2[j] = true;
        }
    }


    ng2.reverse;
    auto ng = (N + 1).iota.map!(i => ng1[i] || ng2[i]);
    
    if (!ng[0]) {
        writeln(1);
        writeln(1);
    } else {
        writeln(2);
        writeln(N + 1 - ng.sum);
    }

    debug {
        z1.writeln;
        z2.writeln;
        ng1.map!(x => x ? 1: 0).writeln;
        ng2.map!(x => x ? 1: 0).writeln;
    }
}


Measured memory_bytes: 8980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

bool a[26];
char al[]="abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        a[s[i]-'a']=true;
    }
    rep(i,26){
        if(a[i]==false){
            cout<<al[i]<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(26);
  int ans = 0;
  rep(i, 4) {
    int t;
    t = s[i]-'A';
    if (cnt[t] == 1) {
      ans++;
    }
    cnt[t]++;
  }
  if (ans == 2) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, m;
	cin >> n >> m;
	map<i64, i64> mp;
	REP(i, n)
	{
		i64 a;
		cin >> a;
		mp[a]++;
	}

	REP(i, m)
	{
		i64 max_a = (*mp.rbegin()).first;
		mp[max_a]--;
		if (mp[max_a] < 1)
			mp.erase(max_a);
		mp[max_a / 2]++;
	}

	i64 ans = 0;
	REPIT(mp)
	{
		ans += (*it).first * (*it).second;
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();

    int[] students = new int[n];

    for (int i = 0; i < n; i++) {
      students[i] = sc.nextInt();
    }

    int[] ordered = new int[n];
    for (int i = 0; i < n; i++) {
      int order = students[i];
      ordered[order - 1] = i + 1;
    }

    StringBuilder ret = new StringBuilder();
    for (int i = 0; i < n; i++) {
      ret.append(ordered[i]);
      if (i != n - 1) {
        ret.append(" ");
      }
    }
    System.out.println(ret.toString());
  }
}


Measured memory_bytes: 50828
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] inputstr = Console.ReadLine().Split(char.Parse(" "));
                int height = int.Parse(inputstr[0]);
                int width = int.Parse(inputstr[1]);
                if (height == 0 && width == 0)
                {
                    return;
                }
                for(int raw = 0; raw < height; raw++)
                {
                    for(int x = 0; x < width; x++)
                    {
                        if(x==0 || x == width - 1)
                        {
                            Console.Write("#");
                            continue;
                        }
                        if(raw==0 || raw == height - 1)
                        {
                            Console.Write("#");
                            continue;
                        }
                        Console.Write(".");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 15948
N, K = (int(x) for x in input().split())

t = 1
r = N - 1
s = 1

while True:
    b = s // K + 1 if s % K else s // K
    if r >= b:
        r -= b
        s += b
        t += 1
    else:
        break

print(t)



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

int LinearSearch(const vector<int> &A, int key){
    int n = A.size();
    int i = 0;
    while(i < n){
        if(A[i] == key)
            return 1;
        ++i;
    }
    return 0;
}
int main(void){
    int n, q, key;
    cin >> n;
    vector<int> S(n, 0);
    for(int i = 0; i < n; ++i)
        cin >> S[i];
    cin >> q;
    int sum = 0;
    for(int i = 0; i < q; ++i){
        cin >> key;
        sum += LinearSearch(S, key);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
string s,t; bool f =0;
cin>>s;
cin>>t;
int x = s.length();
int y = t.length();


 
for(int i =0; i<x ;i++)
{ 
if(s[i]!=t[i])
f =1;
}
if (f== 0)
cout<<"Yes";
else
cout<<"No";
 
 
	return 0;
}

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

int main()
{
    int a,n,sum=0,in,i;
    cin>>a>>n;
    for(i=0;i<n;i++){
        cin>>in;
        sum+=in;
    }
    if(sum>=a) printf("Yes");
    else printf("No");

return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x;
  int k;
  int i  =0;
  int flag = 0;
  scanf("%d",&x);
  k = x/100;
  for(i=0;i<=k;i++){
    if(105*i >= x && 100*i <= x){
      flag = 1;
      break;
    }
  }
    
  printf("%d",flag);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
 
    int tick, n;
    int temp[5] = {0, 6000, 4000, 3000, 2000};
    for(int i=0;i<4;i++){
        cin >> tick >> n;
        cout << temp[tick] * n << endl;
    }
}

Measured memory_bytes: 1160
nb = int(input())
alist = list(map(int,input().split()))
R = [0]*9
for r in alist:
  r //= 400
  if r < 8:
    R[r] = 1
  else:
    R[8] += 1
amin = max(1,sum(R[:8]))
amax = sum(R)
print("{} {}".format(amin,amax))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
	char s[102][102];
	for (int i = 0; i < 102; i++)
		for (int j = 0; j < 102; j++)
			s[i][j] = '#';
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> s[i][j];
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++)
			cout << s[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var N int
	fmt.Scan(&N)
	sc.Split(bufio.ScanWords)
	arr := make([]int64, N)
	for i := 0; i < N; i++ {
		arr[i] = nextInt()
	}
	sort.Slice(arr, func(a, b int) bool { return arr[a] > arr[b] })
	cnt := int64(0)
	ck := []int64{}
	for i, a := range arr {
		if i == 0 {
			ck = append(ck, a)
		} else {
			tmp := ck[0]
			cnt += tmp
			ck = ck[1:]
			ck = append(ck, a)
			ck = append(ck, a)
		}
	}
	fmt.Print(cnt)

}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


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

using namespace std;

struct edge{
	int u,v,w;
};

long long ans=0;
int par[200005],ed[200005]={},sz[200005];

int root(int u){
	if(par[u]!=u){
		return par[u]=root(par[u]);
	}
	return u;
}

void merge(int u, int v, int w){
	int ru=root(u),rv=root(v);
	if(ru==rv){
		if(sz[ru]>ed[ru]){
			ed[ru]++;
			ans+=w;
		}
	}
	else{
		if(sz[ru]+sz[rv]>ed[ru]+ed[rv]){
			if(rand()&1){
				swap(ru,rv);
			}
			par[rv]=ru;
			sz[ru]+=sz[rv];
			ed[ru]+=ed[rv]+1;
			ans+=w;
		}
	}
}

int main(){
	int p,h,w; cin >> p >> h >> w;
	for(int i=0;i<h+w;i++){
		par[i]=i;
		sz[i]=1;
	}
	vector <edge> e(p);
	for(int i=0;i<p;i++){
		cin >> e[i].u >> e[i].v >> e[i].w;
		e[i].u--;e[i].v--;
	}
	sort(e.begin(),e.end(),[](edge &a, edge &b){
		return a.w>b.w;
	});
	for(int i=0;i<p;i++){
		merge(e[i].u,h+e[i].v,e[i].w);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

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

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}

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

    int W, H, C;
    cin >> W >> H >> C;
    cout << W / gcd(W, H) * H / gcd(W, H) * C << endl;
	return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isPowerOfTwo(int n){
    while(n!=0){
        if(n%2 && n!=1){
            return false;
        }
        n/=2;
    }
    return true;
}
int main(){
    int n;
    cin>>n;
    for(int i = n ; i>=1 ; i--){
        if(isPowerOfTwo(i)){
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 256
// Try KEYENCE Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
	macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let s = get().as_bytes();
    let k = b"keyence";
    
    for i in 0..7 {
    	let mut xs = vec![];
        for j in 0..i {
        	xs.push(s[j]);
        }
        for j in i..7 {
        	let j = s.len()-1-(6-j);
            xs.push(s[j]);
        }
    	if xs == k {
    		println!("YES");
        	return;
        }
        // println!("{:?}", k);
        // println!("{:?}", xs);
    }
    
    println!("NO");
}

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

cum_sum = 0
ans_lis = []
sumA = sum(A)
for i in range(0,N-1):
    cum_sum = cum_sum + A[i]
    score = abs(cum_sum - (sumA - cum_sum))

    ans_lis.append(score)

print(min(ans_lis))
    

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

int main() {
  int n; cin >>n;
  vector<int>a(n);
  int count =0;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(a[i]+a[j]<=a[k])break;
        if(a[k]+a[i]<=a[j])break;
        count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    const double pi = acos(-1);
    double r;
    cin >> r;
    printf("%.15f %.15f\n", pi*r*r, 2*pi*r);
}



Measured memory_bytes: 3224