akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

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

   string s;
   cin>>s;
   int n=s.size();
   string s1;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='0')
       {
           s1.append("0");
       }
       else if(s[i]=='1')
       {
           s1.append("1");
       }
       else if(s[i]=='B')
       {
           if(s1.empty()!=1)
           {
               s1.pop_back();
           }
       }
   }
    cout<<s1<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
N=int(input())
n=int(math.sqrt(N))
ans=float('inf')
val=0
a=0
b=0
for i in range(1,n+1):
  if N%i==0:
    a=i
    b=N//i
    val=a+b-2
    ans=min(ans,val)
print(ans)

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

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

  int a=1;
  rep(i,m){
    a*=2;
  }
  int ans=(1900*m+100*(n-m))*a;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int alpha[26]={};
	string s;cin>>s;
	int l=s.size();
	rep(i,l) alpha[s[i]-'a']++;

	bool chk=0;int now=0;
	rep(i,26) {
		if(alpha[i]==0) {
			chk=1;
			now=i;
			break;
		}
	}
	if(chk){
		s=s+(char)('a'+now);
		cout<<s<<"\n";
	}
	else{
		for(int i=l-1;i>0;i--){
			if(s[i-1]<s[i]){
				string t=s.substr(0,i-1);
				//cout<<t<<"\n";
				char tt='z';
				for(int j=i;j<l;j++){
					if(s[i-1]<s[j]) tt=min(tt,s[j]);
				}
				t+=tt;
				cout<<t<<"\n";
				return 0;
			}
		}
		cout<<-1<<"\n";
		return 0;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
long long C[51][51];
void cul(){
	for(int i=0;i<=50;i++){
		for(int j=0;j<=i;j++){
			if(j==0||j==i){
				C[i][j]=1LL;
			}else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		}
	}
}
int main(){
	long long N,A,B;
	vector<long long> V(50);
	cin>>N>>A>>B;
	for(int i=0;i<N;i++){
		cin>>V[i];
	}
	sort(V.rbegin(),V.rend());
	long long sm=0;
	for(int i=0;i<A;i++){
		sm+=V[i];
	}
	double ans=(double)sm/A;
	cout<<fixed<<setprecision(12)<<ans<<endl;
	int l=A-1,r=A;
	while(l-1>=0&&V[l-1]==V[l]){
		l--;
	}
	while(r<N&&V[r-1]==V[r]){
		r++;
	}
	cul();
	long long sum=0;
	if(l==0){
		for(int i=A;i<=B;i++){
			sum+=C[r-l][i];
		}
	}else{
		sum=C[r-l][A-l];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

#define ll long long
const ll  modu = 1e9 + 7;
using namespace std;

//int gcd(int a, int b) {
//	return b == 0 ? a : gcd(b, a % b);
//}
//
//int lcm(int a, int b) {
//	return a * b / gcd(a, b);
//}
//
//bool comp(vector<int> a, vector<int> b)
//{
//	return a[2] < b[2];
//}
//bool isPal(string s)
//{
//	int start = 0; int end = s.size() - 1;
//	while (start < end)
//	{
//		if (s[start] != s[end]) return false;
//		start++;
//		end--;
//	}
//	return true;
//}
////s && l
////bool comp(vector<int> v1, vector<int> v2)
////{
////	return v1[0] < v2[0];
////}

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

	int ret = 753;
	int n = s.size();
	for (int i = 0; i < n - 2; i++)
	{
		ret = min(ret, abs(stoi(s.substr(i, 3)) - 753));
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

char a[15][15];
char b[15][15];
int main() {
 int n, m, k;
 cin >> n >> m >> k;
 for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
        cin >> a[i][j];
    }
 }

 int ans = 0;
 for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << m); j++) {
        for (int ii = 0; ii < n; ii++) {
            for (int jj = 0; jj < m; jj++) {
                b[ii][jj] = a[ii][jj];
            }
        }
        for (int row = 0; row < n; row++) {
            if ((1 << row) & i) {
                for (int ii = 0; ii < m; ii++) {
                    b[row][ii] = 'R';
                }
            }
        }
        for (int col = 0; col < m; col++) {
            if ((1 << col) & j) {
                for (int ii = 0; ii < n; ii++) {
                    b[ii][col] = 'R';
                }
            }
        }
        int curr = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (b[i][j] == '#') {
                    curr++;
                }
            }
        }
        ans += (curr == k);
    }
 }
 cout << ans;
 return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	struct node *cur=nil->next;
	while(cur!=nil&&cur->key!=key){
		cur = cur->next;
		}
		return cur;
}

void init(){
	nil = malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if ( cur == nil ) break;
		if ( isf == 0)  printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
		}
	printf("\n");
}

void deleteNode(NodePointer t){
	if(t==nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	NodePointer t = nil->next;
	if ( t == nil ) return;
	deleteNode(t);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void delete(int key){
	deleteNode(listSearch(key));
}


void insert(int key){
	NodePointer x;
	x = malloc(sizeof(struct node));
	x->key = key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);
		if ( com[0] == 'i' ) {insert(key); np++; size++;}
		else if ( com[0] == 'd' ) {
		if (strlen(com) > 6){
			if ( com[6] == 'F' ) deleteFirst();
			else if ( com[6] == 'L' ) deleteLast();
			} else {
				delete(key); nd++; 
				}
				size--;
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 32984
from bisect import bisect_left, bisect_right

def func(x, y, z):
    yi = bisect_right(y, x)

    if yi == 0 or yi == len(y):
        ans = 0
        if yi == len(y):
            yi -= 1
        ans += abs(y[yi] - x)
        x = y[yi]

        zi = bisect_right(z, x)
        ans += min(abs(z[zi % len(z)] - x), abs(z[(zi-1) % len(z)] - x))
        return ans
    else:
        ans1 = ans2 = 0
        ans1 += abs(y[yi-1] - x)
        x1 = y[yi-1]
        zi = bisect_right(z, x1)
        ans1 += min(abs(z[zi % len(z)] - x1), abs(z[(zi-1) % len(z)] - x1))

        ans2 += abs(y[yi] - x)
        x2 = y[yi]
        zi = bisect_right(z, x2)
        ans2 += min(abs(z[zi % len(z)] - x2), abs(z[(zi-1) % len(z)] - x2))
        return min(ans1, ans2)


a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

for _ in range(q):
    x = int(input())

    print(min(func(x, s, t), func(x, t, s)))


Measured memory_bytes: 12080
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;int a;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  
  a=n/2 -1;
  int b=n/2;
  if(v[a] ==v[b]) 
  {
  	cout<<"0"; return 0;
  }
  else
  {
  	cout<<v[b]-v[a];
  	return 0;
  }
}
  

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

int main()
{
    //
    ll M;
    cin >> M;
    cout << 24 + (24 - M) << endl;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(){
	int a ,b ,t;
	scanf("%d %d %d",&a,&b,&t);

	int ans = 0;
	for (int i = a;i <= t+0.5;i += a){
		ans = ans + b;
	}	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main() {

    int N;
    cin >> N;
    if(N%1000 == 0) cout << 0 << endl;
    else{
    cout << 1000 - (N % 1000) << endl;
    }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

int n; 
int tr[27][600000];
void add(int *tr,int p,int v){
	for(int i=p;i<=n;i+=i&-i)tr[i]+=v;
}
int que(int *tr,int p){
	int ans=0;
	for(int i=p;i>0;i-=i&-i)ans+=tr[i];
	return ans;
}
char s[600000];
signed main()
{
	io;
	cin>>n>>s+1;
	rep(i,1,n){
		add(tr[s[i]-'a'],i,1);
	}
	int q;cin>>q;
	while(q--){
		int op;cin>>op;
		if(op==1){
			int l;char c;cin>>l>>c;
			add(tr[s[l]-'a'],l,-1);
			s[l]=c;
			add(tr[s[l]-'a'],l,1);
		}
		else {
			int ans=0;int l,r;cin>>l>>r;
			rep(i,0,25){
				ans += (que(tr[i],r)-que(tr[i],l-1)) >0;
			}
			cout<<ans<<endl;
		}
	}
	getchar(); //
	getchar();
}

Measured memory_bytes: 123136
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef pair<long long,long long> pll;
typedef long long ll;
const int inf   = 1<<30-1;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int gcd(int x,int y){
  if(x>y)swap(x,y);
  if(y%x==0) return x;
  else return gcd(y%x,x);
  }
int main(){
  int n,p;
  cin>>n>>p;
  int odd=0,even=0;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==0)even++;
    else odd++;
    }
  if(p==1&&odd==0){
    cout<<"0"<<endl;
    return 0;
    }
  if(odd==0){
    cout<<(1LL<<even)<<endl;
    return 0;
    }
  cout<<(1LL<<even)*(1LL<<(odd-1))<<endl;
  return 0;
  
  }


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::unordered_set<i64> options({1, 2, 3});
  options.erase(A);
  options.erase(B);
  std::cout << *options.begin() << std::endl;
  return 0;
}

Measured memory_bytes: 764
#include <cstdio>
int n,k;
int main(){
	scanf("%d %d",&n,&k);
	if((1<<n)<=k || (n == 1 && k == 1))return printf("-1"),0;
	if(n == 1&&k == 0)return printf("0 0 1 1"),0;
	for(int i=0;i<(1<<n);++i)
		if(i != k)printf("%d ",i);
	printf("%d ",k);
	for(int i=(1<<n)-1;~i;--i)
		if(i != k)printf("%d ",i);
	printf("%d ",k);
	return 0;
}

Measured memory_bytes: 1940
using System;
using System.Diagnostics.Tracing;

namespace _176
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solution());
        }

        public static int Solution()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);  /*Produce   Total */     int X = int.Parse(input[1]);   /*Speed  peices/  T minutes */    int T = int.Parse(input[2]);        //Time      Minutes
            int counter = 0;
            while (N > 0)
            {
                N -= X;
                counter += T;
            }

            return counter;
        }
    }
}


Measured memory_bytes: 27520
n, a, b = gets.split(" ").map!{|i| i.to_i}
ans = 0
for i in 1..n do
  cnt = 0
  ic = i.to_s.chomp.chars
#  p ic
  for j in 0...ic.length do
    cnt += ic[j].to_i
  end
  if a <= cnt && cnt <= b
    ans += i
  end
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

void dfs(VV& g, vector<bool>& used, ll now){
    used[now]=true;
    for(ll to:g[now]){
        if(!used[to])dfs(g,used,to);
    }
}

int main() {
    ll n,m;
    cin>>n>>m;
    VV g(n,V());
    rep(i,m){
        ll x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<bool> used(n,false);
    ll ans=0;
    rep(i,n){
        if(!used[i])ans++;
        dfs(g,used,i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.ArrayList;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n=s.nextInt();
        long a[]=new long[n];
        int c=0;
        ArrayList<Long> arr =new ArrayList<Long>(2);
        for(int i=0;i<n;i++)
            a[i]=s.nextLong();
        Arrays.sort(a);
        for(int i=n-1;i>0;i--)
        {
            if(c==2)
                break;
            if(a[i]==a[i-1])
            {
                i--;
                arr.add(a[i]);
                c++;
                
            }  
        }
        if(c==2)
            System.out.println(arr.get(0)*arr.get(1));
        else
            System.out.println("0");
    }
}
        

Measured memory_bytes: 36304
import copy

N=int(input())
D=list(map(int,input().split()))
D.sort()
time=[]
kakutei=[]
tmp=0
for d in D: 
  if d==0:
    print(0)
    exit()
  elif tmp==d:
    count+=1
    if count>=2 or (d==12 and count>=1):
      print(0)
      exit()
  else:
    count=0
  if d not in time:
    if d==12:
      kakutei.append(d)
    else:
      time.append(d)
  elif 24-d not in time:
    kakutei.append(d)
    kakutei.append(24-d)
    time.remove(d)
  tmp=d
kakutei.append(0)
kakutei.append(24)
ans=0
if len(time)==0:
  kakutei.sort()
  minclock=12
  for j in range(len(kakutei)-1):
    minclock=min(minclock,kakutei[j+1]-kakutei[j])
  ans=max(ans,minclock)
  print(ans)
  exit()
for i in range(2**len(time)):
  clock=kakutei.copy()
  bit = format(i, "b").zfill(len(time))
  for i in range(len(bit)):
    if bit[i]=='0':
      clock.append(time[i])
    else:
      clock.append(24-time[i])
  clock.sort()
  minclock=12
  for j in range(len(clock)-1):
    minclock=min(minclock,clock[j+1]-clock[j])
  ans=max(ans,minclock)
print(ans)

Measured memory_bytes: 3444
import sys
n=int(input())
an=[0]*(n+1)
for i in range(n):
  an[i+1]=int(input())

t=1
cnt=0
for _ in range(n*2):
  t=an[t]
  cnt+=1
  if t==2:
    print(cnt)
    sys.exit()
print(-1)
  

Measured memory_bytes: 6980
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q, k;

void solve(){
	cin >> n;
	vi tab(n);
	cin >> tab;
	sort(all(tab));
	reverse(all(tab));
	int ile = n - 2;
	ll ans = tab[0];

	for(int i = 1; i < n; i++){
		if(ile){
			ile--;
			ans += tab[i];
		}
		if(ile){
			ile--;
			ans += tab[i];
		}
	}
	cout << ans << '\n';
}


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

	q = 1;
	// cin >> q;

	while(q--)
		solve();
}	

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

int main() {
  int n;
  cin >> n;
  
  int shou;
  string ans = "No";
  
  for(int i=1; i<10; i++){
    if(n%i==0){
      shou = n/i;
      if(shou <= 9){
        ans = "Yes";
      }
    }
  }
  
  cout << ans << endl;
}
    

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


int main()
{
    int n,m,k,l,p,d,a,b;
    cin>>a>>b;
    if(a>=1 && a<=8 && b>=1 && b<=8)printf("Yay!\n");
    else
        printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool check(int x) {
	if(x%10 == x/10%10 && x%10 == x/100)
		return true;
	else return false;
}
int main() {
	int n;
	cin >> n;
	for(int i = n; i <= 999; i++)
		if(check(i)) {
			cout << i << "\n";
			break;
		}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int N;
	double Y=0;
	scanf("%d",&N);
	double x[N];
	char u[32];
	char s[]="JPY";
	char s1[]="BTC";

	for(int i=0;i<N;i++){
		scanf("%lf",&x[i]);
		scanf("%s",u);
		if((strcmp(s,u))==0){
			Y+=x[i];
		}else if((strcmp(s1,u))==0){
			Y+=x[i]*380000;
		}
	}

		printf("%lf\n",Y);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 10000+5;
const int inf = 1<<30;

int n;
int m;
int c;
int s[N];
int p[N];
int best[N];
int memo[N];

int main(){
	ri3(c, n, m);
	for(int i=1; i<=n; i++) ri2(s[i], p[i]);
	for(int i=1; i<=c; i++) best[i] = -inf;
	best[0] = 0;
	for(int i=1; i<=n; i++){
		for(int j=c; j>=s[i]; j--){
			if(best[j - s[i]] == -inf) continue;
			best[j] = max(best[j], best[j - s[i]] + p[i]);
		}
	}
	for(int i=1; i<=m; i++){
		for(int j=0; j * i <= c; j++){
			if(best[j] == -inf) continue;
			memo[i] = max(memo[i], i * best[j]);
		}
		printf("%d\n",memo[i]);
	}
	return 0;
}


Measured memory_bytes: 3356
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int fn(vector<int> &vec, int X,int MODE = 0)
{
  auto itr = lower_bound(ALL(vec),X);
  
  if(itr == vec.begin()&& MODE == 1) return -1*INF;
  else if(itr == vec.end()) return INF;
  else if(MODE == 1) return *itr;
  else return *(--itr);
}
void solve(void)
{
  int A,B,Q;
  cin>>A>>B>>Q;
  vector<int> vec1,vec2;
  for (int i = 0; i < A; i++)
  {
    int X;cin>>X;
    vec1.push_back(X);
  }
  for (int i = 0; i < B; i++)
  {
    int X; cin>>X;
    vec2.push_back(X);
  }
  vec1.push_back(INF);
  vec1.push_back(-1*INF);
  vec2.push_back(INF);
  vec2.push_back(-1*INF);
  sort(ALL(vec1));
  sort(ALL(vec2));
  for (int q = 0; q < Q; q++)
  {
    int X;cin>>X;
    int L1,L2,R1,R2;
    L1 = fn(vec1,X,0);
    L2 = fn(vec2,X,0);
    R1 = fn(vec1,X,1);
    R2 = fn(vec2,X,1);
    int D1 = abs(max(R1,R2) - X);
    int D2 = abs(min(L1,L2) - X);
    int D3 = min(abs(L1 - X)*2 + abs(R2 - X),abs(L1 - X) + abs(R2 - X)*2);
    int D4 = min(abs(L2 - X)*2 + abs(R1 - X),abs(L2 - X) + abs(R1 - X)*2);
    // DEBUG(L1,L2,R1,R2,X,"\n");
    cout<<min(min(D1,D2),min(D3,D4))<<endl;;
  }
  
  
  
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3060
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) /b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 1 * 1000 * 1000 * 1000 + 200;
const int MAXN = 100 * 1000 + 10;
const int MLOG = 30;
const int NMAX = 20;

int a[MAXN], A, B, n;

bool check(int x) {
	int ans = 0;
	for(int i = 0; i < n; i++)
		if(a[i] - x * B > 0)
			ans += sg(a[i] - x * B, (A - B));
//	cout << "ahh" << ans << ' ' <<  x << endl;
	return ans <= x;
}

signed main() {
	cin >> n >> A >> B;
	set<int> st;
	for(int i = 0; i < n; i++) cin >> a[i];
	int l = 0, r = INF;
	while(r - l >= 2) {
		int mid = (l + r) >> 1;
//		cout << l << ' ' << r << ' ' << mid << ' ' << endl;
		if(check(mid)) r = mid;
		else l = mid;
	}
	cout << r;
}



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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int N) {
	vector<int> v(N);
	rep(i, N) cin >> v[i];
	sort(all(v));
	int res = INT_MAX;
	reps(i, 1, N) {
		chmin(res, abs(v[i-1] - v[i]));
	}
	return res;
}

signed main() {
	int N;
	while (cin >> N, N) cout << solve(N) << endl;
}




Measured memory_bytes: 3116
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int n, m, x, y, box[100010];
	bool boxl[100010];
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
	    box[i] = 1;
	    if (i == 1) boxl[i] = true;
	    else boxl[i] = false;
	}
	for (int i = 1; i <= m; i++) {
	    cin >> x >> y;
	    box[x]--; box[y]++;
	    if (boxl[x] == true) boxl[y] = true;
	    if (box[x] == 0) boxl[x] = false;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
	    if (boxl[i] == true) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 768
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region Combination
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	COMinit();
	int n, k; cin >> n >> k;
	if (k >= n - 1)cout << COM(2 * n - 1, n - 1) << endl;
	else
	{
		ll res = 1;
		for (int i = 1; i <= k; ++i)
		{
			res += COM(n, i)*COM(n - 1, n - i - 1) % MOD;
			res %= MOD;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)



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

    int x[10000];
    rep(i, n) cin >> x[i];

    int minsum = 1000000;
    
    int sum = 0;
    rep(p, 110) {
        int sum = 0;
        rep(i, n) {
            sum += (x[i]-p)*(x[i]-p);
        }



        if (minsum > sum){
            minsum = sum;
        }
        
    }

    
    cout << minsum << endl;

    return 0;
}




Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())

a = int(N / 1000)
b = int(N / 100) - a * 10
c = int(N / 10) - b * 10 - a * 100
d = N % 10

if (a == b) and (b == c):
    print("Yes")
elif (b == c) and (c == d):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    bool fin = true;

    char tm = s[0];
    for(int i = 0; i < s.size(); i++){
        if(tm != s[i]){
            fin = false;
            break;
        }
    }

    if(fin){
        cout << 0 << endl;
        return 0;
    }


    int ans = 1e9;
    for(char i = 'a'; i <= 'z'; i++){
        int cnt = 0;
        vector<char> check(s.size());
        for(int j = 0; j < s.size(); j++){
            check[j] = s[j];
        }
        vector<char> ne(check.size() - 1, '#');
        while(true){

            for(int j = 0; j < check.size() - 1; j++){
                if(check[j] == i || check[j + 1] == i){
                    ne[j] = i;
                }
            }

            
            char tmp = ne[0];
            bool ok = true;
            if(tmp == '#'){
                ok = false;
            }
            for(int k = 1; k < ne.size(); k++){
                if(ne[k] != tmp){
                    ok = false;
                    break;
                }
            }

            cnt++;

            if(ok){
                break;
            }

            

            // ne.pop_back();
            check.pop_back();

            // cout << cnt << endl;
            for(int j = 0; j < check.size(); j++){
                check[j] = ne[j];
            }
            ne.pop_back();
            if(ne.size() == 0){
                break;
            }
        }
        // cout << cnt << endl;
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#define UP 0
#define DOWN 1
#define LEFT 2
#define RIGHT 3

/* 各方向への移動ベクトル (dx,dy) */
int MOVEMENT[4][2] = { {0, -1}, {0, 1}, {-1, 0}, {1, 0} };
/* 迷路 */
int w, h; /* 大きさ */
int wall[30][30][4]; /* 各マスの各方向の壁の有無 */

/* 幅優先探索 */
int memo[30][30]; /* 探索のメモ (あるマスに到達するまでの最短経路長) */
int UNREACHED = INT_MAX;
typedef struct { int step; int x; int y; } Log; /* 探索状態 */

/* FIFOキュー */
typedef Log Data;
Data queue[2000]; int queue_size = 2000; int queue_head; int queue_length;
void initqueue() {
	queue_length = 0;
}
void enqueue(Data d) {
	queue[(queue_head + queue_length) % queue_size] = d;
	queue_length++;
}
Data dequeue() {
	Data d = queue[queue_head];
	queue_head = (queue_head + 1) % queue_size;
	queue_length--;
	return d;
}

/* 幅優先探索をして入口から出口までの最短経路長を返す */
int search(Log l) {
	int min = UNREACHED;
	int i;
	/* この試行が現在いるマスまでの最短経路か確認する */
	if (l.step > memo[l.y][l.x]) return UNREACHED;

	/* 次のマス */
	for (i = 0; i < 4; i++) {
		/* 壁がある方向へは進めない */
		if (wall[l.y][l.x][i]) continue;

		/* 次の動作を行った場合の状態を作る */
		Log next;
		next.x = l.x + MOVEMENT[i][0];
		next.y = l.y + MOVEMENT[i][1];
		next.step = l.step + 1;

		if (next.x == w - 1 && next.y == h - 1) {
			/* ゴールに到達 */
			if (next.step < min) min = next.step;
		} else {
			/* 次に探索する状態をキューに入れる */
			if (next.step < memo[next.y][next.x]) {
				memo[next.y][next.x] = next.step;
				enqueue(next);
			}
		}
	}

	return min;
}

int main(void) {
	int min, i, j;
	int p[59][30];

	/* データセット毎の処理 */
	while (scanf("%d%d", &w, &h) == 2 && w >= 2 && h >= 2) {
		/* 迷路の壁を読み込む */
		for (i = 0; i < h * 2 - 1; i++) {
			for (j = 0; j < w - (i + 1) % 2; j++) {
				scanf("%d", &p[i][j]);
			}
		}
		/* 壁の情報を使いやすい形式に変換する */
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				/* 各マスの各方向に壁があるか (迷路の端には必ず壁があるとする) */
				wall[i][j][UP] = (i == 0) ? 1 : p[i*2-1][j];
				wall[i][j][DOWN] = (i == h-1) ? 1 : p[i*2+1][j];
				wall[i][j][LEFT] = (j == 0) ? 1 : p[i*2][j-1];
				wall[i][j][RIGHT] = (j == w-1) ? 1 : p[i*2][j];
			}
		}

		/* メモを初期化する */
		for (i = 0; i < h; i++) for (j = 0; j < w; j++) memo[i][j] = UNREACHED;

		/* 探索の始点をキューに入れる */
		Log l = {1, 0, 0};
		enqueue(l);

		/* 幅優先探索する */
		min = UNREACHED;
		while (queue_length > 0) {
			int step = search(dequeue());
			if (step < min) min = step;
		}

		/* 結果を出力する */
		if (min == UNREACHED) min = 0;
		printf("%d\n", min);
	}

	return 0;
}

Measured memory_bytes: 644
/* C */
// ???????????\???P129

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14 				// ??\???KEY?????? AACGT		

char H[M][L];

// ??????????????°????????????
int getChar(char ch){
	if ( ch == 'A') return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else if ( ch == 'T') return 4;
	else  return 0;
}

// ?????????????????°??????????????????key???????????????
long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); ++i)
	{
		sum += p * getChar(str[i]);
		p *= 5;								//??? x5?????????????????¨??§????°????????????§?????????????????°????????§???????????????
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + key % (M -1);}

int find (char str[]){
	long long key, h, i;
	key = getKey(str);		// ?????????????????°???
	for(i = 0 ;; i++){
		h = (h1(key) + i*h2(key)) % M;		//??? ???????????\?????????????????¢?????´????????????????????????????????¢?????¬???????????????
		if( strcmp(H[h], str) == 0 ) return 1;  // ???????????£?????????
		else if ( strlen(H[h]) == 0) return 0;	// ????????????????????£??????i??§??????????????????????????????
	}
	return 0;
}

int insert(char str[]){
	long long key, h, i;
	key = getKey(str);		// ?????????????????°???
	for(i = 0 ;; i++){
		h = (h1(key) + i*h2(key)) % M;		//??? ???????????\?????????????????¢?????´????????????????????????????????¢?????¬???????????????
		if( strcmp(H[h], str) == 0 ) return 1;  // ?????????????????£???
		else if ( strlen(H[h]) == 0) {
			// ??????????????¨??????????????£???
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(void)
{
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; ++i) H[i][0] = '\0';
	scanf("%d", &n);

	for ( i = 0; i < n; i++)
	{
		scanf("%s %s", com, str);

		if ( com[0] == 'i'){
			insert(str);
		} else {
			if( find(str) ){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

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

typedef long long int int64;

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int *b=(int *)calloc(n,sizeof(int));
  for(i=0;i<n;i++) scanf("%d",b+i);
  int *c=(int *)calloc(n,sizeof(int));
  int64 sum=0;
  int len=0;
  for(i=0;i<n;i++){
    if(a[i]-b[i]>=0){
      c[len++]=a[i]-b[i];
    } else {
      sum+=a[i]-b[i];
    }
  }
  qsort(c,len,sizeof(int),cmp);
  for(i=0;i<len && sum<0;i++){
    sum+=c[len-1-i];
  }
  if(sum<0){
    printf("-1\n");
  } else {
    printf("%d\n",n-len+i);
  }
} 

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1660
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			String s = sc.next();
			String stn = "";
			for(int i=0;i<s.length();i++){
				String t = s.substring(i,i+1);
				if(t.compareTo("@")==0){
					int len = Integer.valueOf(s.substring(i+1,i+2));
					for(int j=0;j<len;j++){
						stn += s.substring(i+2,i+3);
					}
					i+=2;
				}else{
					stn += t;
				}
			}
			ans.push(stn);
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

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

using namespace std;

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> c(n),v(n);
    for(auto &e:v) cin >>e;
    for(auto &e:c) cin >>e;
    for(int i=0;i<n;i++){
        if(v[i]>c[i]){
            ans += v[i]-c[i];
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    xb = 0
    yb = 0
    tb = 0
    for i in range(n):
        t,x,y = i_map()
        walk = abs(x-xb) + abs(y-yb)
        if walk > t-tb: # 時間足りない
            print("No")
            exit()
        if ((t-tb)-walk)%2 != 0: # 戻って来れん
            print("No")
            exit()
        xb = x
        yb = y
        tb = t
    print("Yes")






if __name__=="__main__":
    main()


Measured memory_bytes: 9440
#include <iostream>
#include <fstream>

#include <cmath>

using namespace std;

int isPrime(int p);
int main(){

    int n,counter=0,p;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> p;
        counter += isPrime(p);
    }

    cout << counter << endl;

    

    return 0;
}

int isPrime(int p){
    for(int i=2;i <= sqrt(p);i++){
        if(!(p%i)){ return 0;}
    }
    return 1;
}


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

using namespace std;

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

    if (k % 2 == 0) {
        cout << (k * k) / 4 << endl;
    } else {
        cout << (k * k - 1) / 4 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//const int N = 1e5 + 5;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    if((n * 500) >= m) puts("Yes");
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static boolean isPrime(int p){
    	if(p%2==0) return false;
    	for(int i=3;i*i<=p;i+=2){
    		if(p%i==0) return false;
    	}
    	return true;
    }
    public static void arrayPrint(int[] array){
    	for(int i=0;i<array.length-1;i++) System.out.print(array[i]+" ");
    	System.out.println(array[array.length-1]);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] primes = new int[N];
        int written = 0;
        for(int k=1;k<=5555;k++){
        	if(isPrime(10*k+1)){
        		primes[written]=10*k+1;
        		written++;
        	}
        	if(written>=N) break;
        }
        arrayPrint(primes);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include<string.h>
//strcmpは=0 以外では使わない方がいい
int main(void) {
  int n, l, i, j;
  scanf("%d %d", &n, &l);
  char s[n][l+1];//文字列の長さより+1されるのは最後に空白\nが格納されるからかな
  for (i = 0; i < n; i++) {
      scanf("%s", s[i]);
  }

  for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j++) {
          if (strcmp(s[i], s[j]) > 0) {//第1引数 > 第2引数 の場合はプラスの値 第1引数 = 第2引数 の場合は0
              char save[l+1];
              strcpy(save, s[i]);
              strcpy(s[i], s[j]);
              strcpy(s[j], save);
          }
      }
  }
  for (i = 0; i < n; i++){
      printf("%s", s[i]);
  }
  return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

	if(a + b >= c) {
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
	}
}

Measured memory_bytes: 21844
N = int(input())
X = int((N / 1.08)//1)
X1 =int(X+1) 
ans_1 = (X*1.08//1)
ans_2 = (X1*1.08//1)
if (ans_1 == N):
    print(X)
elif(ans_2 == N):
    print(X1)
else:
    print(":(")

Measured memory_bytes: 3060
#include <stdio.h>


int main()

 { 
  	int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
	if(a<b)
	{ 
		if(b<c)
			printf("Yes\n");
		else
			printf("No\n");

	}     
	else
		printf("No\n");
 }



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> c(m,0);
  int k,a;
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      c[a-1]++;
    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(c[i]==n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256