akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

const int MAX = 510000;

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

template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< mod >;

int main(){
  COMinit();
  int n;cin>>n;
  modint a[n];rep(i,n)cin>>a[i];
  modint ne=1;
  rep(i,2,n+1){
    ne*=i;
  }
  modint nediv[n+1];
  rep(i,1,n+1){
    modint tmp=ne*inv[i];
    nediv[i]=(nediv[i-1]+tmp);
  }
  modint ans;
  rep(i,n){
    modint l=nediv[i+1]*a[i];
    modint r=nediv[n-i]*a[i];
    ans+=l+r;
    ans-=nediv[1]*a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12928
def main():
    n,ma,mb = map(int,input().split())
    dp = [[[float("inf") for _ in range(401)] for _ in range(401)] for _ in range(n+1)]
    dp[0][0][0]=0

    for i in range(1,n+1):
        a,b,c = map(int,input().split())
        for j in range(401):
            for k in range(401):
                if a<=j and b<=k:
                    dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
                else:
                    dp[i][j][k] = dp[i-1][j][k]
    ans = float("inf")
    for i in range(1,401):
        for j in range(1,401):
            if i*mb == j*ma:
                ans = min(ans,dp[n][i][j])
    if ans==float("inf"):
        print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 141404
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    int n, a, b, c;
    string s, t = "";
    cin >> s;
    int cnt = 0;
    rep(i, 0, s.size()){
        if(cnt == 0 && s[i] == 'C') cnt = 1;
        if(cnt == 1 && s[i] == 'F') cnt = 2;
    }
    cout << (cnt == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main(void)
{
    vector<int> n{0, 0, 0};
    int tmp, min = 100, max = 0;
    for (int i = 1; i <= 3; i++)
    {
        cin >> tmp;
        if (max < tmp)
            max = tmp;
        if (min > tmp)
            min = tmp;
    }
    cout << abs(max - min);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string x;
	int m;
	string front, back;
	int shuffle;

	while (true) {
		cin >> x;
		if (x == "-") break;

		cin >> m;

		for (int i = 0; i < m; i++) {
			cin >> shuffle;
			front = x.substr(0, shuffle);
			back = x.substr(shuffle);

			back.append(front);
			x = back;
		}
	
		cout << x << endl;
	}

}


Measured memory_bytes: 3188
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long t, std::vector<long long> a, std::vector<long long> b){
    for(int i = 0; i < n; ++i)
        ++a[i];
    auto comp = [&](int i, int j){
        i64 x = (b[i] + 1) * a[j] + b[j];
        i64 y = (b[j] + 1) * a[i] + b[i];
        return x < y;
    };
    vector<int> idxes(n);
    iota(idxes.begin(), idxes.end(), 0);
    sort(idxes.begin(), idxes.end(), comp);

    auto aa = a, bb = b;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(aa[idxes[i]] != 1){
            a[cnt] = aa[idxes[i]];
            b[cnt] = bb[idxes[i]];
            ++cnt;
        }
    }
    int border = cnt;
    for(int i = 0; i < n; ++i){
        if(aa[idxes[i]] == 1){
            a[cnt] = aa[idxes[i]];
            b[cnt] = bb[idxes[i]];
            ++cnt;
        }
    }
    vector<vector<i64>> dp(border + 1, vector<i64>(33, INF));
    dp[0][0] = 0;
    for(int i = 0; i < border; ++i){
        for(int j = 0; j <= 32; ++j){
            chmin(dp[i + 1][j], dp[i][j]);
            if(j != 32){
                i64 time = dp[i][j] + 1;
                if(time > t)
                    continue;
                chmin(dp[i + 1][j + 1], a[i] * time + b[i]);
            }
        }
    }
    vector<i64> res = dp.back();
    auto comp2 = [&](int i, int j){
        assert(a[i] == 1);
        assert(a[j] == 1);
        return b[i] < b[j];
    };
    iota(idxes.begin(), idxes.end(), 0);
    sort(next(idxes.begin(), border), idxes.end(), comp2);
    bb = b;
    for(int i = border; i < n; ++i){
        a[i] = 1;
        b[i] = bb[idxes[i]];
    }
    vector<i64> v(1, 0);
    for(int i = border; i < n; ++i)
        v.push_back(v.back() + b[i] + 1);
    int ans = 0;
    for(int i = 0; i <= 32; ++i){
        if(res[i] > t)
            continue;
        auto it = upper_bound(v.begin(), v.end(), t - res[i]);
        int d = distance(v.begin(), it) - 1;
        chmax(ans, i + d);
    }
    cout << ans << endl;

}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, T, std::move(a), std::move(b));
    return 0;
}


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

int main() {
    ll a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    if (a + b >= k) {
        if (k < a) {
            cout << k << endl;
        } else {
            cout << a << endl;
        }
    } else {
        ll tmp = k - a - b;
        if (tmp < c)
            ans = a - tmp;
        else
            ans = a - c;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3580
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

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

if A==L:
    if N%2==0:
        ans=1
        for j in range(int(N/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
    else:
        ans=1
        for j in range(int((N-1)/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
else:
    print(0)



Measured memory_bytes: 17844
import java.util.*
import kotlin.*


fun main(args: Array<String>){
    var line: String = readLine() as String
    val n = line.toInt()
    val red =ArrayList<IntArray>()
    for(i in 0 until n){
        val a=readLine()!!.split(" ")
        red.add(intArrayOf(a[0].toInt(),a[1].toInt()))
    }

    val blue = PriorityQueue<IntArray>(n,Comparator<IntArray>{ o1:IntArray, o2:IntArray -> o1[0]-o2[0] })
    for(i in 0 until n){
        val a=readLine()!!.split(" ")
        blue.add(intArrayOf(a[0].toInt(),a[1].toInt()))
    }

    red.sortBy { it:IntArray->it[1] }//y座標でソート
    var count=0
    while (true){
        val next = blue.poll() ?: break
        var index=red.size-1
        while(index>=0){
            if(red[index][0]<next[0]&&red[index][1]<next[1]){
                count+=1
                red.removeAt(index)
                break
            }
            index -= 1
        }
        if(red.size==0){
            break
        }
    }
    print(count)
}


Measured memory_bytes: 37928
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            
            Console.WriteLine(s[1] == 'B'?"ARC":"ABC");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 25804
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){

  // 入力
  int H,W; cin >> H >> W;
  int n = 10; // 都市数
  vector<vector<int> > dist(n, vector<int>(n)); // 各都市間の所要時間
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> dist[i][j];
    }
  }
  // 初期順列
  vector<int> order(n);
  for (int i = 0; i < n; ++i) order[i] = i;
  v<int> ans(10,INF);
  ans[1]=0;
  do {
    /* 順序 order についての所要時間を計算 */
    int temp_dist = 0;
    int index = order[0];
    if(index==1) continue;
    for (int i = 1; i < n; ++i) {
      temp_dist += dist[order[i-1]][order[i]];
      if(order[i]==1) break;
    }
    /* 暫定値より小さかったら更新 */
    chmin(ans[index],temp_dist);
  } while (next_permutation(order.begin(), order.end()));

  int answer=0;
  rep(i,H) rep(j,W){
    int w; cin >> w;
    if(w==-1);
    else{
      answer+=ans[w];
    }
  }
  // 答えを出力
  cout << answer << endl;
  return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;
int a[MAX_N];

int main(){
  int N; cin >> N;
  int _max = -INF, _min = INF;
  rep(i,N){
    scanf("%d",a+i);
    _max = max(_max,a[i]);
    _min = min(_min,a[i]);
  }
  bool ans = false;
  if(_min==_max){
    if(_min==N-1 || _min<=N/2) ans = true;
  }else if(_max==_min+1){
    int cnt_min = 0;
    rep(i,N) if(a[i]==_min) cnt_min++;
    if(_max >= cnt_min+1 && _max <=(cnt_min)+(N-cnt_min)/2) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 640
let z x=if x=(-0.)then 0. else x;;let rec g()=Scanf.scanf"%f %f %f %f %f %f
"(fun a b c d e f->g(let x=a*.e-.b*.d in let s=(e*.c-.b*.f)/.x and t=(a*.f-.d*.c)/.x in Printf.printf"%.3f %.3f
"(z s)(z t)));;try g()with _->()

Measured memory_bytes: 2368
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	std::vector<int> a;
	int count_=0;
	for(int i=0;i < n;i ++){
        int ai;
        cin>>ai;
        a.push_back(ai);
	}
	//
	sort(a.begin(),a.end());
    bool dp[a[n-1]+1];
    for(int i=0;i <= a[n-1];i ++)
    	dp[i] = true;
    for(int i=0;i < n;i ++){
    	// if((i > 0) && (a[i] == a[i-1])){
    	// 	 dp[a[i]] = false;
    	// 	 dp[a[i-1]]=false;
    	// 	 continue;
    	// }
    	//
        if((i < n-1) && (a[i] == a[i+1])){
        	int j;
    		for(j=a[i]; j <= a[n-1];j += a[i]){
    			if(j > a[i]){
    				dp[j] = false;
    			}
    		}
        	dp[a[i]] = false;
        	// dp[a[i+1]] = false;
        	continue;
        }
        //
    	if(dp[a[i]]){
    		int j;
    		for(j=a[i]; j <= a[n-1];j += a[i]){
    			if(j > a[i]){
    				dp[j] = false;
    			}
    		}
    	}
    }
    //
    for(int i=0;i < n;i ++){
    	 if(dp[a[i]])
    	 	count_++;
    }
    //
    cout<<count_<<"\n";
	return 0;
}

Measured memory_bytes: 5064
#include<stdio.h>
int main()
{
	int a[5], i, j, p;
	for (i=0; i<3; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i=2; i>0; i--)
	{
		for (j=0; j<i; j++)
		{
			if (a[i]<a[j])
			{
				p=a[i];
				a[i]=a[j];
				a[j]=p;
			}
		}
	}
	printf("%d\n", (a[2]-a[1])+(a[1]-a[0]));
	return 0;
}

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

#define AMAX 10000

int main(){

	int n;
	cin >> n;
	int* A = new int[n];
	for (int i = 0; i < n; i++) cin >> A[i];

	int* B = new int[n];
	int* C = new int[AMAX + 1];

	for (int i = 0; i < AMAX + 1; i++) C[i] = 0;
	for (int i = 0; i < n; i++) C[A[i]]++;
	for (int i = 1; i < AMAX + 1; i++) C[i] += C[i - 1];
	for (int i = n - 1; i >= 0; i--) B[--C[A[i]]] = A[i];

	for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << B[i];
	cout << endl;

	delete[] A;
	delete[] B;
	delete[] C;

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> nx(6,0);
  for(int i=0;i<n;i++){
    double h;
    cin>>h;
    int a=(h-160)/5;
    nx[a]++;
  }
  for(int i=0;i<6;i++){
    cout<<i+1<<":";
    for(int j=0;j<nx[i];j++)cout<<"*";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3152
import java.util.*;
import java.util.ArrayList;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	
	while(cin>>n,n){
		vector<int> taro,hana;
		int num[201];
		memset(num,0,sizeof(num));
		
		for(int i=0; i<n; i++){
			int a; cin>>a;
			num[a]=1;
		}
		
		for(int i=1; i<=2*n; i++){
			if( num[i] )taro.push_back(i);
			else 			hana.push_back(i);
		}
		
		int turn=1;
		int ba = 0;
		for(; taro.size() && hana.size();){
			if( turn ){
				vector<int>::iterator it = lower_bound(taro.begin(),taro.end(),ba);
				if( it==taro.end() )ba=0;
				else{
					ba = *it;
					taro.erase( it );
				}
				
			}else{
				vector<int>::iterator it = lower_bound(hana.begin(),hana.end(),ba);
				if( it==hana.end() )ba=0;
				else{
					ba = *it;
					hana.erase( it );
				}
			}
			turn ^= 1;
		}

		printf("%d\n%d\n",hana.size(),taro.size());
	}
	return 0;
}

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

const int N = 2e5 + 10;
const int K = 2e5;

int n , a[N] , cnt[N];
long long ans;

int main(){
	scanf("%d" , &n);
	for(int i = 1; i <= n; i++)
		scanf("%d" , &a[i]) , cnt[a[i]]++;
	for(int i = 0; i <= K; i++)
		ans += 1ll * cnt[i] * (cnt[i] - 1) / 2;
	for(int i = 1; i <= n; i++)
		printf("%lld\n" , ans - cnt[a[i]] + 1);
	return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int gcd(ll a, ll b){
  if(b == 0){
    return a;
  }else{
    return gcd(b,a%b);
  }
}

vector<ll> sieve(ll n){
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int sum = 0;
  int rank = 1;
  REP(i,n){
    char c = s[i];
    if(c == 'a'){
      if(sum < a+b){
        cout << "Yes" << endl;
        sum++;
      }else{
        cout << "No" << endl;
      }
    }else if(c == 'b'){
      if(sum < a+b && rank <= b){
        cout << "Yes" << endl;
        sum++;
        rank++;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3752
//
//  main.cpp
//  Together
//
//  Created by wenhan on 2017/9/2.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;
int a[100005]={0};
int main() {
    int n;
    cin>>n;
    int x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        a[x]++;
    }
    int mmax=0;
    for(int i=1;i<100000;i++)
        mmax=max(mmax, a[i-1]+a[i]+a[i+1]);
    printf("%d\n",mmax);
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;cin>>x;
	for(ll i=0;i<=200;i++){
		for(ll j=-200;j<=i;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){cout<<i<<" "<<j<<'\n';return 0;}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,m;
vll x;
vll d;
lli ans = 0;

int main(){
  cin >> n >> m;
  x = vll(m);
  for(lli i = 0;i < m;i++) cin >> x[i];
  sort(x.begin(), x.end());
  d = vll(m);
  d[0] = LONG_MAX;
  for(lli i = 1;i < m;i++) d[i] = x[i]-x[i-1];
  sort(d.begin(),d.end());
  for(lli i = 0;i < m-n;i++){
    ans += d[i];
  }
  cout << ans << endl;
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    cout << a << " " << b <<" " << c << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <cstring>
#include <bitset>
#include <random>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
//typedef __int128 ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;

int main() {

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

    string s;
    int w;
    cin >> s >> w;

    string ans = "";
    for (int i = 0; i < sz(s); ++i) {
        if (i % w == 0) {
            ans += s[i];
        }
    }
    //reverse(all(ans));
    cout << ans << "\n";

}

Measured memory_bytes: 256
#include <cstdio>
static const int MAXN = 1e5 + 4;
template <typename T> inline T gcd(const T a, const T b) { return b == 0 ? a : gcd(b, a % b); }

int n, k;
int a[MAXN];

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

    int g = a[0];
    for (int i = 1; i < n; ++i) g = gcd(g, a[i]);
    for (int i = 0; i < n; ++i) if (a[i] >= k && (a[i] - k) % g == 0) {
        puts("POSSIBLE"); return 0;
    }

    puts("IMPOSSIBLE"); return 0;
}


Measured memory_bytes: 512
import math

x,y = map(int,input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (2 * y - x) // 3
m = y - 2 * n

if n < 0 or m < 0:
    print(0)
    exit()

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

print(cmb(n+m,m)%mod)


Measured memory_bytes: 44172
//
//  main.cpp
//  codechef
//
//  Created by Krishnam Srivastava on 08/02/20.
//  Copyright © 2020 Krishnam Srivastava. All rights reserved.


#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<numeric>
#include<stack>
#include<string>
#include<climits>
#include<cmath>
#include<iomanip>
#include<unordered_map>
#include<set>
//#include<utility>
#define MAX 2147483647
typedef long long int lli;
using namespace std;

int main(){
    int a[5];
    for(int i=0;i<5;i++)cin>>a[i];
    for(int i=0;i<5;i++){
        if(a[i]==0){
            cout<<i+1<<"\n";
            break;
        }
    }
}


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

const long long INF = 1LL << 60;

int main() {
    long long N, W; cin >> N >> W;
    vector<long long> w(N), v(N);
    for(int i = 0; i < N; ++i) cin >> w[i] >> v[i];
    
    vector<vector<long long>> dp(N+1, vector<long long>(100100, INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i) {
        for(int sum_v = 0; sum_v < 100100; ++sum_v) {
            if(sum_v - v[i] >= 0) {
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            }
            
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    
    long long res = 0;
    for(int sum_v = 0; sum_v < 100100; ++sum_v) {
        if(dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 80256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mehvix
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
}



Measured memory_bytes: 36012
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

vector<int> adj[100100];
int main()
{
    int n,i,x,m,a,b;
    cin>>n>>m;
    vector<bool> used(n+1);
    vector<int> p(n+1);
    queue<int> q;
    q.push(1);
    p[1]=-1;
    for(i=1;i<=n;i++){used[i]=false;}
    used[1]=true;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        for(int u:adj[x])
        {if(!used[u]){q.push(u);used[u]=true;p[u]=x;}}
    }
    for(i=1;i<=n;i++){if(!used[i]){cout<<"No";return 0;}}
    cout<<"Yes"<<"\n";
    for(i=2;i<=n;i++){cout<<p[i]<<"\n";}
    return 0;
}

Measured memory_bytes: 10252
#include <iostream>

using namespace std;

#define MAXN 1005

char arr[MAXN][MAXN];

const int mod = 1e9+7;

int num[MAXN][MAXN];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    int h,w;cin>>h>>w;

    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>arr[i][j];
    
    num[0][1]=1;

    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(arr[i][j]!='#')
                num[i][j] = (num[i-1][j] + num[i][j-1])%mod;

    cout<<num[h][w]<<endl;

}


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

int main()
{
    long int n;
    cin>>n;
    switch(n%10)
    {
 case 2:
 case 4:
 case 5:
 case 7:
 case 9:
     puts("hon");
    break;
    case 0:
    case 1:
    case 6:
    case 8:
    puts("pon");
     break;
    case 3:
        puts("bon");
        break;


    }
}


Measured memory_bytes: 3572
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll Q;
    cin >> Q;
    vector<ll> B(Q), C(Q);
    rep(i, Q) { cin >> B[i] >> C[i]; }

    vector<int> cnt(100001, 0);
    ll sum = 0;
    rep(i, N) {
        sum += A[i];
        cnt[A[i]]++;
    }

    rep(i, Q) {
        sum = sum - B[i] * cnt[B[i]] + C[i] * cnt[B[i]];
        cout << sum << endl;
        cnt[C[i]] += cnt[B[i]];
        cnt[B[i]] = 0;
    }

    return 0;
}

Measured memory_bytes: 5896
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	n := nextInt()
	maxint, _ := new(big.Int).SetString("100000000000000000000000000000000000000000000000000000000000000000000000000000000", 10)

	for i := 0; i < n; i++ {
		aStr := nextString()
		bStr := nextString()

		a, _ := new(big.Int).SetString(aStr, 10)
		b, _ := new(big.Int).SetString(bStr, 10)
		c := big.NewInt(0).Add(a, b)

		if c.Cmp(maxint) < 0 {
			fmt.Println(c)
		} else {
			fmt.Println("overflow")
		}
	}
}



Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, k; cin >> n >> k;
    string s; cin >> s;
    FOR(i, 0, min(k, 13)) {
        string u = s + reversed(s);
        FOR(j, 0, n + 1)chmin(s, u.substr(j, n));
        reverse(all(s));
    }
    print(reversed(s));
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005],t[500005];
bool flag,dame;


int main(){
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	for(i=1;i<=200;i++){
		y[i] = -INF;
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(i + j > n)continue;
			if(i + j  == 0)continue;
			ll top[300];
			num = 0;
			sum = 0;
			for(l=0;l<i;l++){
				top[num++] = x[l];
				sum += x[l];
			}
			for(l=0;l<j;l++){
				top[num++] = x[n-1-l];
				sum += x[n-l-1];
			}
			sort(top,top+i+j);
			y[i+j] = max(y[i+j],sum);
			num = 0;
			for(l=0;l<i+j;l++){
				sum -= top[l];
				y[i+j+l+1] = max(y[i+j+l+1],sum);
			}
		}
	}
	ans = 0;
	for(i=0;i<=k;i++){
		ans = max(ans,y[i]);
		//pe(i);p(y[i]);
	}
	p(ans);
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<string> s(n);
    set<char> se;
    map<char,int> id;
    for(int i=0;i<n;i++){
      cin >> s[i];
      for(int j=0;j<s[i].length();j++){
        se.insert(s[i][j]);
      }
    }
    int k=0;
    for(auto c:se){
      id[c]=k;
      k++;
    }
    vector<vector<int>> v(n);
    for(int i=0;i<n;i++){
      v[i]=vector<int>(s[i].length());
      for(int j=0;j<s[i].length();j++){
        v[i][j]=id[s[i][j]];
      }
    }
    vector<int> per(10);
    for(int i=0;i<10;i++) per[i]=i;
    vector<int> num(n);
    int total;
    int ans=0;
    do{
      for(int i=0;i<n;i++){
        if(v[i].size()>1&&per[v[i][0]]==0) goto next;
        num[i]=0;
        for(int j=0;j<v[i].size();j++){
          num[i]=num[i]*10+per[v[i][j]];
        }
      }
      total=0;
      for(int i=0;i<n-1;i++) total+=num[i];
      if(total==num[n-1]){
        ans++;
      }
      next:
      continue;
    }while(next_permutation(all(per)));
    for(int i=1;i<=10-k;i++){
      ans/=i;
    }
    cout << ans << endl;
  }
  return 0;
}



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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int n=1;n<=N;n++){
    int sum = 0;
    for(char& c : to_string(n)){
      sum += (c-'0');
    }
    if(sum >= A && sum <= B){
      ans+=n;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

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

	if(N >= 3200) cout << s << endl;
	else cout << "red" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import std.stdio,std.string,std.conv,std.array;

int main()
{
	while(true)
	{
		int n = readln.chomp.to!int;
		if(n == 0) break;

		int a[];
		foreach(i;0..n) a ~= readln.chomp.to!int;
		
		a.sort;

		long sum = 0,count = 0;
		long time[];

		foreach(i;0..n-1)
		{
			count += a[i];
			time ~= count;
		}

		foreach(i;0..time.length)
		{
			sum += time[i];
		}

		sum.writeln;

	}
	return 0;
}

Measured memory_bytes: 1508
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		sc.nextLine();
		List<String> wordList = new ArrayList<>();
		int count =0;
		while(sc.hasNextLine()) {
			if (count >= num) {
				break;
			}
			wordList.add(sc.nextLine());
			count++;
		}
		sc.close();
		
		Set<String> usedWordSet = new HashSet<>();
		Character beforeLastWord = null;
		for (String word : wordList) {
			if (usedWordSet.contains(word)) {
				System.out.println("No");
				return;
			}
			usedWordSet.add(word);
			
			if (beforeLastWord == null) {
				beforeLastWord = Character.valueOf(word.charAt(word.length()-1));
				continue;
			}
			Character firstWord = Character.valueOf(word.charAt(0));
			if (!beforeLastWord.equals(firstWord)) {
				System.out.println("No");
				return;
			}
			beforeLastWord = Character.valueOf(word.charAt(word.length()-1));
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{

//整数値の入力
ll a,b;
cin >> a>>b;
//回答が整数の場合
ll ans=0;

if(a%2LL){
    if(((b-a)%4LL)==0LL){ans=a;}
    else if(((b-a)%4LL)==1LL){ans=a^b;}
    else if(((b-a)%4LL)==2LL){ans=a^1LL;}
    else {ans=(a^b)^1LL;}
}
else{
    if(((b-a)%4LL)==0LL){ans=b;}
    else if(((b-a)%4LL)==1LL){ans=1LL;}
    else if(((b-a)%4LL)==2LL){ans=b^1LL;}
    else {ans=0;}
}

//回答
cout << ans << endl;
return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int dice[] = new int[6];
		int pip[] = new int[6];
		int order_length = 0;
		int count = 0;
		String order;
		
		//サイコロの目の入力
		dice =  make_dice(scanner);
		
		pip = dice;
		
		//命令数取得
		order = scanner.next();
		order_length = order.length();
		String[] order_box = new String[order_length];	
		
		for( int i = 0; i < order_length ; i ++ ) {
			order_box[i] = order.substring(i, i+1);
		}

		//命令数実行
		while(true ){
			//命令ごとに処理
			switch( order_box[count] ) {
			case "N":
				pip = diceroll_n(pip);
				break;
			case "E":
				pip = diceroll_e(pip);
				break;
			case "S":
				pip = diceroll_s(pip);
				break;
			case "W":
				pip = diceroll_w(pip);
				break;
				
			default :
				break;
			}
			
			count ++;
			if( count >= order_length){
				break;
			}
		}
		//1番上出力
		System.out.println(pip[0]);
		
		scanner.close();
	}
	
	public static int[] make_dice ( Scanner scanner){
		int dice[] = new int[6];
		
		for(int i = 0; i < 6; i ++){
			dice[i] = scanner.nextInt();
		}
		
		return dice;
	}

	public static int[] diceroll_n(int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[1];
		pip[1] = dice[5];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[0];
		pip[5] = dice[4];
		
		return pip;
	}

	public static int[] diceroll_e (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[3];
		pip[1] = dice[1];
		pip[2] = dice[0];
		pip[3] = dice[5];
		pip[4] = dice[4];
		pip[5] = dice[2];
		
		return pip;
	}

	public static int[] diceroll_w (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[2];
		pip[1] = dice[1];
		pip[2] = dice[5];
		pip[3] = dice[0];
		pip[4] = dice[4];
		pip[5] = dice[3];
		
		return pip;
	}

	public static int[] diceroll_s (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[4];
		pip[1] = dice[0];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[5];
		pip[5] = dice[1];
		
		return pip;
	}
	
}



Measured memory_bytes: 26256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

ll n,ans;
cin >> n;
for(ll i = 0;i < n+1;i++){
    if (n >= i*i)
    {
        ans = i*i;
    }
    
}

cout << ans << endl;





//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
def f(s, e):
    return (e-s+1)*(s+e)//2

N, K = map(int, input().split())
ans = 0
MOD = 10**9+7

for i in range(K, N+2):
    ans += f(N-i+1, N)-f(0, i-1)+1
    ans %= MOD

print(ans)

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

int main(){
	int N;
	cin >> N;
	double A = 0, B;
	for (int i = 0;i < N;i++) {
		cin >> B;
		A += 1.0 / B;
	}
	printf("%.10f", 1.0 / A);
}


Measured memory_bytes: 256
S = input()
T = input()
ans = float('inf')

for i in range(0, len(S) - len(T) + 1):
    tmp = len(T)
    for j in range(0, len(T)):
        if T[j] == S[i + j]:
            tmp -= 1
    ans = min(tmp, ans)

print(ans)


Measured memory_bytes: 9108
var
	N,i,T:Longint;
	K:int64;
	A,B:Array[1..200000]of Longint;
begin
	read(N,K);
	for i:=1 to N do read(A[i]);
	T:=1;
	while K>0 do begin
		if K mod 2=1 then T:=A[T];
		K:=K div 2;
		for i:=1 to N do B[i]:=A[i];
		for i:=1 to N do A[i]:=B[B[i]];
	end;
	writeln(T);
end.


Measured memory_bytes: 1760
w, h, n = map(int, input().split())
x, y, a = [], [], []
m1 = [0, 0]
m2 = [w, h]
for _ in range(n):
    X, Y, A = map(int, input().split())
    x.append(X)
    y.append(Y)
    a.append(A)
for i in range(n):
    if a[i] == 1:
        m1[0] = max(m1[0], x[i])
    elif a[i] == 2:
        m2[0] = min(m2[0], x[i])
    elif a[i] == 3:
        m1[1] = max(m1[1], y[i])
    else:
        m2[1] = min(m2[1], y[i])
s = max(0, (m2[0] - m1[0])) * max(0, (m2[1] - m1[1]))
print(s)

Measured memory_bytes: 3064
n = int(input())
b = list(map(int, input().split()))

ans = []
for _ in range(n):
    for i, bi in enumerate(b[::-1]):
        i = len(b) - i
        if i == bi:
            ans.append(b.pop(i-1))
            break
print(*(ans[::-1] if len(ans) == n else[-1]), sep='\n')


Measured memory_bytes: 63796