akhauriyash/Code-Regression huggingface dataset:
from sys import stdin


def main():
    N = int(input())
    A_lists = [int(x) for x in stdin.readline().rstrip().split()]
    B_lists = [int(x) for x in stdin.readline().rstrip().split()]

    kazyou = 0
    sum_ = 0

    for A, B in zip(A_lists, B_lists):
        if (A-kazyou) <= B:
            sum_ += A
            if A-kazyou < 0:
                kazyou = B
            else:
                kazyou = abs((A-kazyou)-B)
            # print(sum_, kazyou)
        else:
            sum_ += B + kazyou
            kazyou = 0
            # print(sum_, kazyou)

    if A_lists[N] <= kazyou:
        sum_ += A_lists[N]
    else:
        sum_ += kazyou

    print(sum_)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18436
import math

N = int(input())
A = [int(elm) for elm in input().split(" ")] 

minus_count = 0
min_A = abs(A[0])
min_i = 0
for i in range(N):
    if A[i] < -1:
        minus_count += 1
    abs_a = abs(A[i])
    if min_A > abs_a:
        min_i = i
        min_A = abs_a

A2 = [abs(a) for a in A]
    
if minus_count % 2 == 0:
    out = sum(A2)
else:
    A2[min_i] *= -1
    out = sum(A2)

print(out)



Measured memory_bytes: 14412
s = input()
t = input()

srt = [-1]*26
grl = [-1]*26

for i in range(len(s)):
    n = ord(s[i]) - ord('a')
    m = ord(t[i]) - ord('a')
    
    if srt[n]!=-1 or grl[m] != -1:
        if srt[n] != m or grl[m] != n:
            print('No')
            exit()
    srt[n] = m
    grl[m] = n
print('Yes')
    

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	double n;
	cin>>n;
	double ans;
	ll flag=-1;
	for(int i=1;i<=n+1;i++){
		if(int(i*1.08)==n){
			flag = i;
			break;
		}
	}
	if(flag!=-1){
		cout<<flag<<endl;
	}
	else{
		cout<<":("<<endl;
	}

	


}

Measured memory_bytes: 256
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/agc034/tasks/agc034_b
#B - ABC 
"""
need to consider the case that ticket is not enough to lower everything
"""


def cost(d):
    tc = 0
    d_cnt = 0
    for c in d:
        if c == 'D':
            tc += d_cnt
        else:
            d_cnt += 1

    return tc


s = gw()
d = []
i = 0
ans = 0
while i < len(s):
    if (s[i] == 'A'):
        d.append(s[i])
        i += 1
    elif (s[i] == 'B' and (i + 1) < len(s) and s[i + 1] == 'C'):
        d.append('D')
        i += 2
    else:
        ans += cost(d)
        d = []
        i += 1

ans += cost(d)

print(ans)


Measured memory_bytes: 18856
problem = [x for x in input().split()]

nums = []
for x in problem:
    if x.isnumeric():
        nums.append(int(x))
    else:
        if x == '+':
            a = nums.pop()
            b = nums.pop()
            nums.append(a + b)
        elif x == '-':
            a = nums.pop()
            b = nums.pop()
            nums.append(b - a)
        elif x == '*':
            a = nums.pop()
            b = nums.pop()
            nums.append(a * b)

print(nums[0])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int n,c,k,a[100005];
int main(){
   scanf("%d %d %d",&n,&c,&k);
   for(int i=1;i<=n;i++)
      scanf("%d",&a[i]);
   sort(a+1,a+n+1);
   int last = 1;
   int ans = 1;
   for(int i=1;i<=n;i++){
      if (a[last] + k < a[i]){
         last = i;
         ans++;
         continue;
      }
      if (i - last >= c){
         last = i;
         ans++;
      }
   }
   printf("%d",ans);
}


Measured memory_bytes: 768
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll s;
	cin >> s;
	vector<ll> val(s + 1);
	val[0] = 1;
	rep(i, s + 1) {
		repi(j, 3, s + 1 - i) {
			val[i + j] += val[i];
			val[i + j] %= MOD;
		}
	}
	cout << val[s] << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 3640
#include <stdio.h>
#define max(a, b) ((a)<=(b)?b:a)
int main() {
  long long a,b,c,d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  long long res1, res2, res3, res4;
  res1 = b*d;
  res2 = a*c;
  res3 = a*d;
  res4 = b*c;
  printf("%lld\n", max(res1, max(res2, max(res3, res4))));
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int>&a,const int&depth,int&count)
{
	if(a.size()==depth)
	{
		count--;
		if(!count)
		{
			for(auto&i:a)cout<<i;
			exit(0);
		}
	}
	else
	{
		for(int i=max(0,a.back()-1); i<=min(9,a.back()+1); i++)
		{
			a.push_back(i);
			dfs(a,depth,count);
			a.pop_back();
		}
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;; i++)
	{
		vector<int>a;
		for(int j=1; j<=9; j++)
		{
			a.push_back(j);
			dfs(a,i,n);
			a.pop_back();
		}
	}
}

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

using namespace std;

typedef long long ll;

inline void solve() {
	int n;
	cin >> n;
	set<int> a = { 2, 4, 5, 7 ,9 }, b = { 0,1,6,8 };
	int l = n % 10;
	if (a.find(l) != a.end())
		cout << "hon";
	else if (b.find(l) != b.end())
		cout << "pon";
	else
		cout << "bon";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	int count = 0;

	for (int i = 1; i <= k; i += 2){
		for (int j = 2; j <= k; j += 2){
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.trim()
  var A=0;
  switch(input){
    case "A":
      A="T";
      break;
    case "G":
       A = "C" ;
      break;
    case "T":
      A = "A" ;
      break;
    case "C":
      A ="G"  ;
      break;
              }
  console.log(A)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i,n) {
    if (s[i] == 'W') cnt++;
  }
  int ans = 0;
  rep(i,n-cnt) {
    if (s[i] == 'W') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long a,b,c,d,e,f,g,h;

cin>>a;
long long final=a;
long long count=0;
while(a!=0){
	count+=a%10;
	a=a/10;
}
// cout<<count;
// cout<<count/final;
// cout<<final/count;

if (final%count==0)
{
	/* code */
	cout<<"Yes"<<endl;
}
else
	cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3536
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var XY = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long X = XY[0];
        long Y = XY[1];
        
      
        if(((2*X-Y)%3 == 0) && ((2*Y-X)%3 == 0)&& ((2*Y-X)/3 >= 0) && ((2*X-Y)/3 >= 0)){
          //long N = (X+Y)/3;
          long N = (2*X-Y)/3+(2*Y-X)/3;
          long R = (long)Math.Min((2*X-Y)/3,(2*Y-X)/3);
          //N個のものからR個選ぶ組み合わせ
          var kaijo = new long[1000000];
          //階乗のモジュラー逆数
          var Ikaijo = new long[1000000];
          kaijo[0] = 1;
          Ikaijo[0] = 1;
          for(long i = 1;i < 1000000 ;i++){
            kaijo[i] = (kaijo[i-1]*i)%1000000007;
            Ikaijo[i] = RepeatSquaring(kaijo[i]);
          }
          long mo = 1000000007;
          long ans = (((kaijo[N]%mo)*(Ikaijo[R]%mo)%mo)*Ikaijo[N-R])%mo;
          Console.WriteLine(ans);
        }else{
          Console.WriteLine(0);
        }
    }
  
    //繰り返し2乗法
    static long RepeatSquaring(long N,long M = 1000000005,long mod = 1000000007){
      if(M == 0){
        return 1;
      }else if(M%2 == 0){
        long t = RepeatSquaring(N,(M/2),mod)%mod;
        return (t*t)%mod;
      }else{
        return ((N%mod)*RepeatSquaring(N,M-1,mod))%mod;
      }
    }
}


Measured memory_bytes: 28768
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		if (n == m) {
			System.out.println((kaijo(n) * kaijo(m) * 2) % MOD);
		} else if (Math.abs(m - n) == 1) {
			System.out.println((kaijo(n) * kaijo(m)) % MOD);
		} else {
			System.out.println(0);
		}
	}
	
	static long kaijo(long n) {
		if (n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1) % MOD;
		}
	}
}


Measured memory_bytes: 30932
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
l = input().split(" ");
for i in range(n) :
	l[i] = int(l[i]);
l.sort()
ans = 0;
for i in range(k) :
	ans = ans + int(l[n-1-i]);
print(ans)

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut v = vec![0; n];

    for i in 0..n {
        v[n - a[i]] = i+1;
    }

    v.reverse();
    let mut flag = false;
    for num in v.iter() {
        if !flag {
            print!("{}", num);
            flag = true;
        } else {
            print!(" {}", num);
        }
    }
}


Measured memory_bytes: 6908
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    string s;
    cin >> s;
    string ans;
    for(int i=0;i<s.size();i++){
        if( (i+1)%2 != 0){
        ans.push_back(s[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define int long long int
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int32_t main(){
	FIO
	int x;
	cin>>x;
	for(int i=0;i<=120;i++)
	{
		for(int j=-120;j<=120;j++)
		{
			if(pow(i,5)-pow(j,5)==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4008
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D, enter; vll path;
ll binarySearch(vl V, ll key) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = V.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		if (V[mid] >= key) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	cin >> N >> K;
	vl A(N);
	vl F(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) cin >> F[i];
	sort(A.begin(), A.end());
	sort(F.begin(), F.end());
	reverse(F.begin(), F.end());
	ll left = -1;
	ll right = 0;
	for (i = 0; i < N; i++) {
		right += A[i] * F[i];
	}
	ll mid;
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		ll key = 0;
		for (i = 0; i < N; i++) {
			//debug(i, A[i],F[i], mid);
			if (A[i] * F[i] > mid) key += (A[i] * F[i] - mid - 1) / F[i] + 1;
		}
		//debug(mid, key, K);
		if (key <= K) right = mid;
		else left = mid;
	}
	cout << right;
}

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

int main(){
	int x, y;
	scanf(" %d %d", &x, &y);
	int z=0;
    int x1 = abs(x), y1 = abs(y);
    z += abs(x1-y1);
    if((x1<=y1 && ((x<0 &&y>0) ||(x>0&&y<0))) || (x1>=y1 && ((x<0 &&y>0) ||(x>0&&y<0))) ||(x==0 && y<0)||(x>0 && y==0)){
        z++;
    }
    else if((x1<y1 && x<0&&y<0) || (x1>y1 && x>0 && y>0)){
        z+=2;
    }
	printf("%d", z);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int N,K;

int main() {
	while(true) {
		scanf("%d %d", &N, &K);
		if (N == 0) break;
		vector<bool> v(N+2);
		bool wc = false;
		for (int i = 0; i < K; ++i) {
			int c;
			scanf("%d", &c);
			if (c == 0) {
				wc = true;
			} else {
				v[c] = true;
			}
		}
		int ans = 0;
		vector<int> s,e;
		for (int i = 1; i <= N; ++i) {
			if (!v[i-1] && v[i]) s.push_back(i);
			if (v[i] && !v[i+1]) e.push_back(i);
		}
		for (size_t i = 0; i < s.size(); ++i) {
			ans = max(ans, e[i] - s[i] + 1);
		}
		if (wc) {
			if (K == 1) {
				ans = 1;
			} else {
				for (int i = 1; i <= N; ++i) {
					if (!v[i] && (v[i-1] || v[i+1])) {
						int p = i-1;
						int pc = 0;
						while (v[p]) {
							--p;
							++pc;
						}
						int n = i+1;
						int nc = 0;
						while (v[n]) {
							++n;
							++nc;
						}
						ans = max(ans, pc + nc + 1);
					}
				}
			}
		}
		cout << ans << endl;
	}
  return 0;
}

Measured memory_bytes: 1364
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
m=int(input())
b=list(map(int, input().split()))
ans='YES'
a1=Counter(a)
b1=Counter(b)
for i in b:
    if a1[i]<b1[i]:
        ans='NO'
        break
print(ans)

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  sort(p.begin(), p.end());
reverse(p.begin(), p.end());
  int Z=0;
  for(int i=0;i<K;i++){
    Z+=p.at(i);
  }
  cout<<Z<<endl;
}



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

class DisjointSet {
public:
	vector<int> rank, p;
	
	DisjointSet(){}
	DisjointSet(int size){
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++){
			makeSet(i);
		}
	}
	
	void makeSet(int x){
		p[x]=x;
		rank[x]=0;
	}
	
	void unite(int x, int y){
		link(findSet(x),findSet(y));
	}
	
	void link(int x, int y){
		if(rank[x] < rank[y]){
			p[y]=x;
		} else {
			p[x]=y;
			if(rank[x]==rank[y]){
				rank[y]++;
			}
		}
	}
	
	bool same(int x, int y){
		return findSet(x) == findSet(y);
	}
	
	int findSet(int x){	
		if(p[x]!=x){
			p[x]=findSet(p[x]);
		}
		return p[x];
	}
};

int main(){
	
	int n, q;
	cin >> n >> q;
	
	DisjointSet ds(n);
	
	for(int i=0;i<q;i++){
		int c, x, y;
		cin >> c >> x >> y;
		if (c==0){
			ds.unite(x,y);
		} else if(c==1){ 
			cout << ds.same(x,y) << endl;
		} else {
			cout << "invalid " << c << endl;
		}
	}
	return 0;
}



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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    double n, k; cin >> n >> k;
    double cnt = 0.;
  	
    rep1(i,n){
        double p = 1;
        int q = i;
        while(q < k){
            p /= 2;
            q *= 2;
        }
        cnt += p;
    }
    cout << fixed << setprecision(10) << cnt/n << '\n';
}

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

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

	int array[100];
	for (int i = 0; i < n; i++) {
		cin >> array[i];
	}

	int count = 0;
	for (int i = 0; i <= n - 1; i++) {
		int min = i;
		for (int j = i; j <= n - 1; j++) {
			if (array[j] < array[min]) {
				min = j;
			}
		}
		if (i != min) {
			int tmp = array[i];
			array[i] = array[min];
			array[min] = tmp;
			count++;
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d%c", array[i], i != n - 1 ? ' ' : '\n');
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1148
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y) {
	if (x > y) {
		return gcd(y, x);
	} else if (y % x == 0) {
		return x;
	} else {
		return gcd(y % x, x);
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> Ais;
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;
		Ais.push_back(Ai);
	}
	int max_Ais = *max_element(Ais.begin(), Ais.end());
	int gcd_Ais = Ais[0];
	for (int i = 1; i < N; i++) {
		gcd_Ais = gcd(gcd_Ais, Ais[i]);
	}
	if (K % gcd_Ais == 0 && K <= max_Ais) {
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 892
n,k=map(int, input().split())
a= list(map(int, input().split()))
l=[]
for i in range(len(a)):
  l.append((a[i]+1)/2)
maxans=sum(l[0:k])
ans=sum(l[0:k])
for i in range(len(l)-k):
  ans=ans+l[i+k]-l[i]
  maxans=max(ans,maxans)
 
print(maxans)

Measured memory_bytes: 25060
def resolve():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    if p[0] == 1:
        p[0], p[1] = p[1], p[0]
        ans += 1
    if p[n - 1] == n:
        p[n - 2], p[n - 1] = p[n - 1], p[n - 2]
        ans += 1
    for i in range(n - 1):
        if p[i] == i + 1:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
        int W,a,b;
        cin>>W>>a>>b;
        cout<<max(0,abs(a-b)-W)<<endl;
	return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 int isPrime(int);
#define N 10000
int main(){
  int n,i,judge;
  int num[N];
  scanf("%d",&n);
  judge=0;
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  judge=judge+isPrime(num[i]);
    }
  printf("%d\n",judge);
  return 0;
}

int isPrime(int x){
  int i;
  if(x==2)
    return 1;
  if(x<2||x%2==0)
    return 0;
  for(i=3;i<=sqrt(x);i=i+2){
    if(x%i==0)
      return 0;
      }
  return 1;

}



Measured memory_bytes: 2144
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{

    public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=s.nextInt();
		int count=0;
		boolean flag=false;
		int j=1;
		for(int i=0;i<n;i++)
		{if(a[i]==j)
		{j++;flag=true;}
		else
		count++;}
	if(flag)
		System.out.println(count);
		else
		{System.out.println("-1");}
	}}

Measured memory_bytes: 84440
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (b == 1) {
			System.out.println(0);
			return;
		}

		int n = 1;

		while (b > a + (a - 1) * (n - 1))
			n++;

		System.out.println(n);

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

int main() {
	string str;
	cin >> str;
	stack<int> S1;
	stack<pair<int, int>> S2;
	int area = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '\\') {
			S1.push(i);
		}
		else if (str[i] == '/') {
			if (S1.empty()) continue;
			int area = 0;
			while (S2.size() > 0 && S1.top() < S2.top().first) {
				area += S2.top().second;
				S2.pop();
			}
			area += i - S1.top();
			S1.pop();
			S2.push(make_pair(i, area));
		}
	}
	vector<int> ans;
	int sum = 0;
	while (!S2.empty()) {
		ans.push_back(S2.top().second);
		sum += S2.top().second;
		S2.pop();
	}
	cout << sum << endl;
	cout << ans.size();
	if (ans.size() > 0) cout << ' ';
	else cout << endl;
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];
		if (i == ans.size()-1) cout << endl;
		else cout << ' ';
	}
}



Measured memory_bytes: 3272
N,W=map(int,input().split())
dp = [[0] * (W + 1) for x in range(N + 1)]
for i in range(N):
    value,weight=[int(x) for x in input().split()]
    for k in range(W+1):
        if k>=weight:
            dp[i+1][k]=max(dp[i][k],dp[i][k-weight]+value)
        else:
            dp[i+1][k]=dp[i][k]
print(dp[N][W])


Measured memory_bytes: 25488
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int h,w,n;
    cin>>h>>w>>n;
    Vs s(h);
    REP(i,0,h) cin>>s[i];

    VVi ans(h,Vi(w));
    int now=1;
    REP(i,0,h){
        bool c=false;
        REP(j,0,w){
            if(s[i][j]=='#') c=true;
        }
        if(c){
            bool f=true;
            REP(j,0,w){
                if(s[i][j]=='#' && f==true){
                    ans[i][j]=now;
                    f=false;
                }else if(s[i][j]=='#' && f==false){
                    now++;
                    ans[i][j]=now;
                }else{
                    ans[i][j]=now;
                }
            }
            now++;
        }else{
            REP(j,0,w) ans[i][j]=-1;
        }
    }
    REP(i,1,h){
        if(ans[i][0]==-1){
            REP(j,0,w){
                ans[i][j]=ans[i-1][j];
            }
        }
    }
    REPR(i,h-2,-1){
        if(ans[i][0]==-1){
            REP(j,0,w){
                ans[i][j]=ans[i+1][j];
            }
        }
    }
    vvout(ans);
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int s=0;
    if (b>a){
        s=b+b-1;
        cout << s<< endl;
       }
    else if (a>b) {
    	s=a+a-1;
        cout << s << endl;
       }
    else if (a==b) {
    	s=a+a;
        cout << s << endl;
       }
}

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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,x;
	cin>>n>>x;
	vector<ll> s(n);
	for(int i = 0; i < n; i++){
		cin>>s[i];
	}
	sort(all(s));
	reverse(all(s));
	vector<vector<ll> > dp(n+1,vector<ll>(x+1,0));
	dp[0][x]=1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= x; j++){
			dp[i+1][j] += dp[i][j]*(n-i-1);
			dp[i+1][j] %= mod;
			dp[i+1][j%s[i]] += dp[i][j];
			dp[i+1][j] %= mod;
		}
	}

	ll ans=0;
	for(int i = 0; i <= x; i++){
		ans += (dp[n][i])*i;
		ans%=mod;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 158592
N = int(input())
if N%2 == 0:
    h = N//2
    n = N
    w = N
    print(h, n, w)
else:
    i = 2
    flag = False
    while True:
        child = i * 4
        mother = i * N
        for j in range(1, child-1):
            for k in range(1, child-j):
                m = child - j - k
                if mother%j == 0 and mother%k==0 and mother%m == 0:
                    print(mother//j, mother//k, mother//m)
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
        i += 1

Measured memory_bytes: 3316
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

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

      return 0;
    }


Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	int N;
	cin >> N;
 

	//出力
	
	printf("%d\n", N/3); // lld としないとオーバーフローする
}
 


Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    k: u32,
    a: u32,
    b: u32,
  }
  
  let mut ans = "NG";
  for i in a..=b {
    if i % k == 0 {
      ans = "OK";
      break;
    }
  }
  
  println!("{}", ans);
  
}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int main(){
	int n=read();
	int k=n;
	int ans=0;
	while(n>=10){
		ans+=n%10;
		n/=10;
	}
	ans+=n;
	if(k%ans==0){
		printf("Yes\n");
	}
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 256
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();
      int count = 0;
      if(b==1)System.out.println(0);
      else if(a >= b)System.out.println(1);
      else{
        count = 1;
        b -= a;
      	while(b > 0){
      		b -= a-1;
          	count++;
      	}
        System.out.println(count);
      }
    }
}


Measured memory_bytes: 22612
# -*- coding: utf-8 -*-

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

tak_turn = A[0] // A[3]
if ( A[0] % A[3] > 0 ):
  tak_turn += 1

aok_turn = A[2] // A[1]
if ( A[2] % A[1] > 0 ):
  aok_turn += 1

if ( tak_turn >= aok_turn ):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
v64 dp;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ld p[n+1];
    forn(i,n+1) p[i]=0;
    p[0]=1;
    ld v;
    forn(i,n){
    	cin >> v;
    	rforn(i,n){
    		if(i-1>=0){
    			p[i]=p[i-1]*v+p[i]*(1-v);
    		}
    		else{
    			p[i]=p[i]*(1-v);
    		}
    	}
    	// forn(i,n+1){
    	// 	cout << p[i] << " ";
    	// }
    	// cout << ln;
    }
    ld ans=0;
    ll sh = (n+1)/2;
    forn(i,(n+1)/2){
    	ans += p[sh+i];
    }
    cout << setprecision(30) << fixed;
    // cout << std::fixed;
    // cout << std::setprecision(30);
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int a[N],b[N],n,bad[N];
ll s;
vector<PII> r;
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d%d",a+i,b+i);
		if (b[i]>=a[i]) s+=b[i]-a[i];
		else bad[i]=a[i]-b[i];
		r.pb(mp(max(a[i],b[i]),i));
	}
	sort(all(r));
	int c=0;
	pair<ll,ll> ans(0,1);
	rep(i,0,SZ(r)) {
		if (s>=r[i].fi) s-=r[i].fi,c++;
	}
	rep(i,0,SZ(r)) {
		if (i>=c) {
			if (s>=bad[r[i].se]) {
				ll ca=s-bad[r[i].se],cb=b[r[i].se];
				if (ans.fi*cb<ans.se*ca) ans=mp(ca,cb);
			}
		} else {
			ll cs=s+r[i].fi-r[c].fi;
			if (cs>=bad[r[i].se]) {
				ll ca=cs-bad[r[i].se],cb=b[r[i].se];
				if (ans.fi*cb<ans.se*ca) ans=mp(ca,cb);
			}
		}
	}
	ans.fi=ans.fi+c*ans.se;
	ans.se*=n;
	ll d=gcd(ans.fi,ans.se);
	printf("%lld %lld\n",ans.fi/d,ans.se/d);
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<ll> A;
    rep(i,N) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ll ans = 0;
    
    ans += A[0];
    int now = 1;
    int cnt = 0;
    rep(i,N-2) {
        ans+=A[now];
        //cout << A[now] <<endl;
        cnt++;
        if (cnt==2) {
            cnt = 0;
            now++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5360
# -*- coding: utf-8 -*-


def main():
    from collections import Counter
    ab = list()

    for i in range(3):
        ai, bi = map(int, input().split())
        ab.append(ai)
        ab.append(bi)

    ab_count = Counter(ab)

    for ab_val in ab_count.values():
        if ab_val == 3:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()


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

using namespace std;

const int N=1e6+5;
typedef long long ll;

int main()
{
    int a,n,k;
    cin >> n >> k ;
    for(int i=0;i<n;i++)
    {
         cin >> a;
    }
    cout << (n-1+k-2)/(k-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
        A[i]--;
    }
    vector<ll> when(N);
    bool warp = 0;
    ll before = 0;
    REPS(i,K){
        if(when[A[before]] == 0||warp){
            when[A[before]] = i;
            before = A[before];
        }else{
            K = i + (K-i)%(i-when[A[before]]);
            i--;
            warp = 1;
        }
    }
    cout << before+1 << "\n";
}

Measured memory_bytes: 6368
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

bool check(string s){
  int N = s.size();
  for(int i = 0; i < N/2; i++){
    // cout << s[i] << " " << s[N-1-i] << endl;
    if (s[i] != s[N-1-i]){
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int N = s.size();

  // sが回文であること
  bool flag = check(s);

  // 2番目の条件
  string str = "";
  int m = (N-1)/2;
  for(int i = 0; i < m; i++){
    str += s[i];
  }
  // cout << str << endl;
  bool flag2 = check(str);

  // 3番目の条件
  str = "";
  m = (N+3)/2-1;
  for(int i = m; i < N; i++){
    str += s[i];
  }
  bool flag3 = check(str);
  // cout << "3:" << str << endl;
  
  if (flag && flag2 && flag3) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  for(int i=0;i<n;i++)
    cin>>x.at(i);
  int m=2*(abs(x.at(n-1))+abs(x.at(0)));
  if(0<x.at(0))
    m=x.at(k-1);
  else if(x.at(n-1)<0)
    m=-x.at(n-k);
  else
    for(int i=0;i+k-1<n;i++)
      m=min({m,2*abs(x.at(i))+abs(x.at(i+k-1)),abs(x.at(i))+2*abs(x.at(i+k-1))});
  cout<<m<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
// #define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, x;
int main(void){
	cin >> N >> x;
	if(x == 1 || x == 2 * N - 1){
		printf("No\n");return 0;
	}
	printf("Yes\n");
	set<int> se;
	se.insert({x - 1, x, x + 1});
	int cnt = 0;
	for (int i = 1; i <= 2 * N - 1; ++i){
		if(!se.count(i)){
			se.insert(i);
			cnt++;
			printf("%d\n", i);
		}
		if(cnt == N - 2) break;
	}
	// printf("k\n");
	rep(i, 3){
		printf("%d\n", x + i - 1);
	}
	// printf("k1\n");
	for (int i = 1; i < 2 * N; ++i){
		if(!se.count(i)){
			se.insert(i);
			cnt++;
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 10880
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string S;
  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  
  int x,y,z ;
  cin >>x>>y>>z ;

  int ans = 0 ;
  int i=1;

  while(1){
      int haba = y*i+(i+1)*z ;
      if(haba>x) break ;
      else ans = i ;
      i++ ;
  }

  cout << ans << endl ;  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Lim 9999991
#define Jmp 100003

long long dic[Lim];

long long toint(string s) {
    long long ret = 0;
    for (int i = 0; i < s.size(); ++i) {
        ret <<= 3;
        switch (s[i]) {
            case 'A':
                ret += 1;
                break;
            case 'T':
                ret += 2;
                break;
            case 'G':
                ret += 3;
                break;
            case 'C':
                ret += 4;
                break;
        }
    }
    return ret;
}

void push(string s) {
    long long a = toint(s);
    int i = a % Lim;
    while (true) {
        if (!dic[i]) {
            dic[i] = a;
            return;
        }
        i = (i + Jmp) % Lim;
    }
}

int find(string s) {
    long long a = toint(s);
    int i = a % Lim;
    while (true) {
        if (!dic[i]) {
            return 0;
        }
        if (dic[i] == a) {
            return 1;
        }
        i = (i + Jmp) % Lim;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s, t;
        cin >> s >> t;
        if (s == "insert") {
            push(t);
        }
        else {
            if (find(t)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 73864