akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
     
const int maxn(1e5 + 5);
const int mod(1e9 + 7);

inline void Inc(int &x, int y) {
    x = x + y >= mod ? x + y - mod : x + y;
}

inline void Dec(int &x, int y) {
    x = x - y < 0 ? x - y + mod : x - y;
}

inline int Add(int x, int y) {
    return x + y >= mod ? x + y - mod : x + y;
}
     
int n, w[maxn], ans, inv[maxn];

int main() {
    int i;
    scanf("%d", &n), inv[1] = 1;
    for (i = 2; i <= n; ++i) inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
    for (i = 2; i <= n; ++i) Inc(inv[i], inv[i - 1]);
    for (i = 1; i <= n; ++i) scanf("%d", &w[i]), Dec(ans, w[i]);
    for (i = 1; i <= n; ++i) Inc(ans, (ll)w[i] * Add(inv[i], inv[n - i + 1]) % mod);
	for (i = 1; i <= n; ++i) ans = (ll)ans * i % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
import * as fs from 'fs';

//in
// 1 3
//out
// 3 = (3+3)/2
const main = (inp: string) => {
    const [a, p]: number[] = inp.split(' ').map(Number);
    console.log(Math.floor((a * 3 + p) / 2));
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int digit_sum(int n){
  if(n==0){
    return 0;
  }else{
    int res = 0;
    res = n%10;
    res += digit_sum(n/10);
    return res;
  }
}

int main(){
  
  int n;
  cin>>n;
  int ans=0;
  int a[n],b[n],c[n-1];
  REP(i,n){
    cin>>a[i];
    a[i]--;
  }
  REP(i,n){
    cin>>b[i];
  }
  REP(i,n){
    cin>>c[i];
  }
  REP(i,n){
    if(i==0){
      ans += b[a[i]];
    }else{
      ans += b[a[i]];
      if(a[i-1]+1==a[i]){
        ans += c[a[i-1]];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
q = int(input())

flag = 1
for i in range(q):
  st = input().split()
  if int(st[0]) == 1:
    flag *= -1
  else:
    tmp = int(st[1])*flag
    if tmp == 1 or tmp == -2:
      s.appendleft(st[2])
    else:
      s.append(st[2])

if flag == -1:
  s.reverse()
print(''.join(s))

Measured memory_bytes: 8564
N,M=gets.split(" ").map(&:to_i)
x=gets.split(" ").map(&:to_i)
if N>=M
	puts 0
else
	x=x.sort
	d=Array.new(M-1,0)
	for i in 0..M-2
		d[i]=x[i+1]-x[i]
	end
	d=d.sort
	sum=x[M-1]-x[0]
	for i in 0..N-2
		sum-=d[M-2-i]
	end
	puts sum
end

Measured memory_bytes: 11256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,Q,i,l,r;string S;
  cin>>N>>Q>>S;deque<ll>X;
  REP(i,N-1)if(S[i]=='A'&&S[i+1]=='C')X.push_back(i);
  REP(i,Q){
    cin>>l>>r;
    cout<<lower_bound(ALL(X),r-1)-lower_bound(ALL(X),l-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
    char buffer[256];
    int a, b, output[256], counter=0, i;
    char op;
    while (1)
    {
        fgets(buffer, 256, stdin);
        sscanf(buffer, "%d %c %d", &a, &op, &b);
        if (op == '?') break;
        switch (op)
        {
        case '+':
            output[counter] = a + b;
            break;
        case '-':
            output[counter] = a - b;
            break;
        case '*':
            output[counter] = a * b;
            break;
        case '/':
            output[counter] = a / b;
            break;
        }
        counter++;
    }
    for (i = 0; i < counter; i++)
    {
        printf("%d\n", output[i]);
    }

}


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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 100, MAX_W = 1e5;
ll N, W;
ll wt[MAX_N], vl[MAX_N];
ll dp[MAX_N + 1][MAX_W + 1] = {};
int main(){
  cin >> N >> W;
  REP(i, N){
    cin >> wt[i] >> vl[i];
  }
  REP(i, N){
    REP(w, MAX_W + 1){
      if(w >= wt[i]){
        dp[i + 1][w] = max(dp[i][w-wt[i]] + vl[i], dp[i][w]);
      }
      else dp[i+1][w] = dp[i][w];
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, m;
    cin >> n >> m;

    multiset<int> v;
    for(int i = 0, tp; i < n; i++)cin >> tp, v.insert(tp);

    vector<pair<int,int>> q(m);
    for(int i = 0; i < m; i++)cin >> q[i].first >> q[i].second;
    sort(q.begin(), q.end(), [](pair<int,int> a,pair<int,int> b){
        return a.second > b.second;
    });
    for(int i = 0; i < m;i++){
        int ct = q[i].first;
        while(ct-- and *v.begin() < q[i].second){
            v.erase(v.begin());
            v.insert(q[i].second);
        }
        if(ct == q[i].first)break;
    }
    int64_t ans = 0;
    for(auto x: v){
        ans += x;
        // cout << x << endl;
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 6528
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
import bisect
for i in range(n):
    for j in range(n):
        if i<j:
            a=l[i]
            b=l[j]
            x=bisect.bisect_left(l,a+b)
            y=bisect.bisect_right(l,b-a)
            if b-a>=a:
                ans+=max(0,x-y-1)
            else:
                ans+=max(0,x-y-2)
print(ans//3)


Measured memory_bytes: 49784
#Reconciled?
import numpy as np
import math as mt
N,M = list(map(int, input().split()))
if(abs(N-M)>1):
    a=0
else:
    if (N==M):
        a = 2*mt.factorial(N)**2
    if (N!=M):
        a = mt.factorial(N)*mt.factorial(M)
print(a%(10**9+7))     

Measured memory_bytes: 14308
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [a, b] <- readInt
  if even (a * b)
    then putStrLn "Even"
    else putStrLn "Odd"


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
int dy[4] = {-1,0,0,1};
int dx[4] = {0,1,-1,0};


int main(){

  ll n;
  cin >> n;
  bool is = true;
  if(n < 0)is = false,n *= -1;
  vector<bool> v(36,0);
  rep(i,36){
    if(is){
      if(!(i & 1))continue;
      if(n >> i & 1)n += (1 << i),v[i] = true;
    }else{
      if(i & 1)continue;
      if(n >> i & 1)n += (1 << i),v[i] = true;
    }
  }
  vector<int> res;
  rep(i,36){
    if((n >>i & 1) || v[i])res.push_back(1);
    else res.push_back(0);
  }
  reverse(ALL(res));
  if(n == 0){
    cout << 0 << endl;
  }else{
    int fir = 0;
    rep(i,36){
      if(res[i] == 1){
        fir = i;
        break;
      }
    }
    for(int i = fir;i < res.size();i++)cout << res[i];
    cout << endl;
  }





  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[101010];

int main() {
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. 操作回数を計算.
    // 2-1. + - + - ... の 順.
    LL p = 0, pSum = 0;
    rep(i, N){
        pSum += a[i];
        if(i & 1){
            if(pSum >= 0) p += pSum + 1, pSum = -1;
        }else{
            if(pSum <= 0) p += -pSum + 1, pSum = 1;
        }
    }
    
    // 2-2. - + - + ... の 順.
    LL m = 0, mSum = 0;
    rep(i, N){
        mSum += a[i];
        if(i & 1){
            if(mSum <= 0) m += -mSum + 1, mSum = 1;
        }else{
            if(mSum >= 0) m += mSum + 1, mSum = -1;
        }
    }
    
    // 3. 出力.
    printf("%lld\n", min(p, m));
    return 0;
    
}

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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);

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

        boolean isPossible = true;
        int cur = arr[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            if (cur >= arr[i]) {
                cur = arr[i];
            } else if  (cur + 1 < arr[i]) {
                isPossible = false;
                break;
            } else {
                // do nothing
            }
        }
        System.out.println(isPossible ? "Yes" : "No");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 51952
#include<iostream>
#include<cstdio>
using namespace std;
#pragma warning(disable:4996)
int n, l[2], d[2], m[2], a, b, c;
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < 2; i++) { l[i] = 0; d[i] = 0; m[i] = 0; }
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d %02d", &a, &b, &c);
			if (b > c)c += 60;
			if (a >= 11 && a < 15) {
				l[1]++; if (c - b <= 8)l[0]++;
			}
			if (a >= 18 && a < 21) {
				d[1]++; if (c - b <= 8)d[0]++;
			}
			if (a >= 21 || a < 2) {
				m[1]++; if (c - b <= 8)m[0]++;
			}
		}
		cout << "lunch ";
		if (l[1] == 0)cout << "no guest" << endl;
		else { cout << l[0] * 100 / l[1] << endl; }
		cout << "dinner ";
		if (d[1] == 0)cout << "no guest" << endl;
		else { cout << d[0] * 100 / d[1] << endl; }
		cout << "midnight ";
		if (m[1] == 0)cout << "no guest" << endl;
		else { cout << m[0] * 100 / m[1] << endl; }
	}
	return 0;
}

Measured memory_bytes: 1240
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 12 * 100001
for i in range(1, 2 ** n):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    if su:
        sc = min(sc, cc)
sc = -1 if sc > 12 * 100000 else sc
print(sc)

Measured memory_bytes: 9220
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,m,x[101][101],y[101],z,a,i,j;
	cin>>n>>m;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>x[i][j];
		}
	}
	for(i=0;i<n;i++){
		y[i]=0;
		for(j=0;j<m;j++){
			y[i]=y[i]+x[i][j];
			cout<<x[i][j]<<' ';
		}
		cout<<y[i];
		cout<<endl;
	}
	a=0;
	z=0;
	for(i=0;i<n;i++){
		z=z+y[i];
	}
	for(j=0;j<m;j++){
		for(i=0;i<n;i++){
			a=a+x[i][j];
			if((i+1)%n==0){
				cout<<a<<' ';
				a=0;
			}
		}
	}
	cout<<z;
	cout<<endl;
			
	return 0;
}



Measured memory_bytes: 3120
{-# LANGUAGE BangPatterns #-}

import Control.Applicative ((<$>))
import Data.List (splitAt, unfoldr)
import qualified Data.ByteString.Char8 as BS

divide :: Int -> [Int] -> (Int, [Int])
divide !c []     = (c, [])
divide !c ((!x):[]) = (c, [x])
divide !c !xs     = conq (divide c left) (divide c right)
  where
    (left, right) = splitAt (length xs `div` 2) xs


conq :: (Int, [Int]) -> (Int, [Int]) -> (Int, [Int])
conq (!c1, []) (!c2, !ys) = (c1 + c2 + length ys, ys)
conq (!c1, !xs) (!c2, []) = (c1 + c2 + length xs, xs)
conq (!c1, !xs) (!c2, !ys)
    | y < x     = f y $ conq (c1, xs) (c2 + 1, tail ys)
    | otherwise = f x $ conq (c1 + 1, tail xs) (c2, ys)
  where
    f !a (!b, !c) = (b, (a:c))
    x = head xs
    y = head ys


main :: IO ()
main = do
    getLine
    xs <- unfoldr (BS.readInt . BS.dropWhile (== ' ')) <$> BS.getLine :: IO [Int]
    let (a, bs) = divide 0 xs
    putStrLn $ unwords (map show bs)
    print a



Measured memory_bytes: 81916
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	
	string ans = "";
	for (int i=0, n=S.size(); i<n; ++i) {
		int c = (S[i] - 'A') + N;
		ans += char('A' + c % 26);
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

int main(){
  int N;
  cin >> N;
  set<int> A;
  for(int i=0;i<N;i++){
    int B;
    cin >> B;
    if(A.count(B)){
      A.erase(B);
    }
    else{
      A.insert(B);
    }
  }
  cout << A.size() << endl;
}
    

Measured memory_bytes: 4864
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadIntArray(3);
            var ans = a.Sum() - a.Max();
            WriteLine(ans);
        }

        public long C(long n, long r)
        {
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  vector<int> v;
  int n;
  REP(i, 3) {
    cin >> n;
    v.push_back(n);
  }

  sort(v.begin(), v.end());

  cout << v[2] * 10 + v[1] + v[0] << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));

int main(){
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    rep(i, ty - sy){
        printf("U");
    }
    rep(i, tx - sx){
        printf("R");
    }
    rep(i, ty - sy){
        printf("D");
    }
    rep(i, tx - sx){
        printf("L");
    }
    // once end
    
    printf("L");
    rep(i, ty - sy + 1){
        printf("U");
    }
    rep(i, tx - sx + 1){
        printf("R");
    }
    printf("DR");
    rep(i, ty - sy + 1){
        printf("D");
    }
    rep(i, tx - sx + 1){
        printf("L");
    }
    printf("U\n");
    return 0;
}


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

void taskD() {
	string s;
	cin >> s;
	int n = 0;
	for (c : s)
		n += c == 'p';
	cout << s.length() / 2 - n << endl;
}

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


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 500;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
ll w[N], v[N], dp[101][N];

int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	int n, c;
	cin >> n >> c;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];

	}
	for (int cap = 0; cap <= c; cap++) {
		for (int i = n - 1; i >= 0; i--) {
			dp[i][cap] = dp[i + 1][cap];

			if (cap >= w[i])
				dp[i][cap] = max(dp[i][cap], dp[i + 1][cap - w[i]] + v[i]);
		}

	}
	cout << dp[0][c];
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (w >= v) {
        print("NO");
    } else {
        if (t * (v - w) >= abs(b - a)) {
            print("YES");
        } else {
            print("NO");
        }
    }
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> pic(H + 2);
  string ud;
  for (int i = 0; i < W + 2; i++){
    ud += "#";
  }
  pic.at(0) = ud;
  pic.at(H +1) = ud;
  for (int i = 1; i < H + 1; i++){
    string S;
    cin >> S;
    pic.at(i) = "#" + S + "#";
  }
  for (int i = 0; i < H + 2; i++){
    cout << pic.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 116
	// https://atcoder.jp/contests/abc116/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int prevH = 0;
		int res = 0;
		
		for (int i = 0; i < n; i++) {
			int height = sc.nextInt();
			
			if (height > prevH) {
				res += (height - prevH);
			}
			prevH = height;
		}
		System.out.println(res);
		
	}
	
	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; 
        } 
    } 
}


Measured memory_bytes: 21204
# h, n, *L = map(int, open(0).read().split())
# a = map(int, input().split())
# i = int(input())
# a = [map(int, input().split()) for _ in range(i)]
# print(list(a))

# [(a,b) for a, b in zip(*[iter(L)] * 2)]


s = input()

ans = "Yes"
if len(s) % 2 != 0:
    print("No")
    exit()

for i in range(0, len(s) - 1, 2):
    str = s[i] + s[i + 1]
    if str == 'hi':
        continue
    ans = "No"

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

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

int main(){
	string in;
	int count = 0;
	while(cin >> in){
		if(cin.eof()) break;
		if(check(in)) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,a,b;
ll h[100000];
bool enough(ll t){
    ll k=0;
    for (ll i=0; i<n; i++){
        k+=max(0ll,((h[i]-t*b+a-b-1ll)/(a-b)));
    }
    return k<=t;
}
ll bisearch(ll left, ll right){
    if (left+1>=right){
        if (enough(left)){
          return left;
        }else {
          return right;
        }
    }
    else {
        ll mid=(left+right)/2;
        if (enough(mid)){
            bisearch(left,mid);
        }else {
            bisearch(mid+1,right);
        }
    }
}

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

    for (ll i=0; i<n; i++){
        cin >> h[i];
    }
    cout << bisearch(1,10000000000) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n,m,a,b,c;
  cin >> n >> m;
  map<ll,ll,greater<ll>>mp;
  rep(i,n){
    cin >> a;
    mp[a]++;
  }
  rep(i,m){
    cin >> b >> c;
    mp[c]+=b;
  }
  ll num=0;
  ll sum=0;
  for(auto p:mp){
    sum+=min(n-num,p.second)*p.first;
    num+=min(n-num,p.second);
    if(n==num)break;
  }
  cout << sum << endl;
    
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC153C()
{
	int N, K;
	cin >> N >> K;
	if (K >= N)
	{
		cout << 0 << endl;
		return;
	}

	vl H(N);
	for (auto& x : H)
		cin >> x;
	sort(H.begin(), H.end(), greater<ll>());

	ll y = accumulate(H.begin() + K, H.end(), 0ll);
	cout << y << endl;
}


int main()
{
	ABC153C();
	return 0;
}

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

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


int main()
{
	int n; cin >> n;
	vector<vector<int>> v(n, vector<int>(n));
	rep(i, n)rep(j, n)cin >> v[i][j];
	rep(k, n)rep(i, n)rep(j, n)
	{
		if (v[i][j] > v[i][k] + v[k][j])
		{
			cout << -1 << endl;
			return 0;
		}
	}
	ll res = 0;
	rep(i, n)for (int j = i + 1; j < n; ++j)
	{
		bool isNecessary = true;
		rep(k, n)
		{
			if (k == i || k == j)continue;
			if (v[i][j] == v[i][k] + v[k][j])
			{
				isNecessary = false;
				break;
			}
		}
		if (isNecessary)res += v[i][j];
	}
	cout << res << endl;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    vector<vector<int>> sum(N, vector<int>(N));
    for (int i = 0; i < N; i++) cin >> d.at(i);
    vector<int> D(N);
    int ans = 0;
    for (int i = 0; i < N; i++) D.at(i) = d.at(i);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            sum.at(i).at(j) = d.at(i) * D.at(j);
            if (sum.at(i).at(j) != sum.at(j).at(i)) ans += sum.at(i).at(j);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9;
#define EQ(n,m) (abs((n)-(m)) < EPS)

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSP(Point a1, Point a2, Point b) {
  return !ccw(a1, a2, b);
}

Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

VP crosspointSC(Point a1, Point a2, Point c, double r) {
  VP ps;
  Point ft = proj(a1, a2, c);
  if (r*r < norm(ft-c)) return ps;
  Point dir = sqrt(max(r*r - norm(ft-c), 0.0)) / abs(a2-a1) * (a2-a1);
  if(isecSP(a1,a2,ft+dir)) ps.push_back(ft+dir);
  if (!EQ(r*r, norm(ft-c)) && isecSP(a1,a2,ft-dir))
    ps.push_back(ft-dir);
  return ps;
}

// a??????b???????????¢?§??????????(0,0)???[-pi,+pi]
double angle(Point a,Point b){
    double t = -arg(a);
    return arg(Point(b.X*cos(t)-b.Y*sin(t),b.X*sin(t)+b.Y*cos(t)));    
}

int main(void){
    int n;
    double r,x,y;
    cin>>n>>r;
    VP ps(n);
    rep(i,n){
        cin>>x>>y;
        ps[i] = Point(x,y);
    }

    double area=0;
    rep(i,n){
        Point p=ps[i], q=ps[(i+1)%n];
        VP cp = crosspointSC(p,q,Point(0,0),r);
        if(abs(p)<r && abs(q)<r){
            assert(cp.size()==0);
            area += cross(p,q)/2;
        }
        else if(abs(p)<r && abs(q)>=r){
            assert(cp.size()==1);
            area += cross(p,cp[0])/2;
            area += r*r*angle(cp[0],q)/2;
        }
        else if(abs(p)>=r && abs(q)<r){
            assert(cp.size()==1);
            area += r*r*angle(p,cp[0])/2;
            area += cross(cp[0],q)/2;
        }
        // abs(p)>=r && abs(q)>=r
        else if(cp.size()==2){
            if(abs(p-cp[0])>abs(p-cp[1])) swap(cp[0],cp[1]);
            area += r*r*angle(p,cp[0])/2;
            area += cross(cp[0],cp[1])/2;
            area += r*r*angle(cp[1],q)/2;
        }
        else area += r*r*angle(p,q)/2;
    }
    printf("%.10f\n",area);

    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
vector<int> G[1000];
int X[1000];
int inf = 1e9;
int dp[1000];

int main(){
	cin>>N;
	rep(i,N-1){
		int p;
		cin>>p;
		p--;
		G[p].pb(i+1);
	}
	rep(i,N) cin>>X[i];
	for(int v = N-1; v>=0; v--){
		dp[v] = inf;
		vector<int> tmp(5001,inf);
		tmp[0] = 0;
		for(int u:G[v]){
			vector<int> ntmp(5001,inf);
			rep(x,5001){
				if(x+X[u]<=5000)  chmin(ntmp[x+X[u]],tmp[x]+dp[u]);
				if(x+dp[u]<=5000) chmin(ntmp[x+dp[u]],tmp[x]+X[u]);
			}
			tmp = ntmp;
		}
		rep(x,X[v]+1) chmin(dp[v],tmp[x]);
	}
	if(dp[0] == inf) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  long a, b, c;
  
  scanf("%ld %ld %ld", &a, &b, &c);
  
  long d = c - a - b;
  
  if(d >= 0 && d*d > 4*a*b)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}


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

int main () {
  string A,B;
  cin >> A >> B;
  if (A[0] == B[2] && A[1] == B[1] && A[2] == B[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

int gcd(int x, int y){
  while (x % y != 0){
    int a=x;
    x=y;
    y=a%y;
  }
  return y;
}

int main() {
  int K;
  cin >> K;
  int sum=0;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      int g=gcd(a,b);
      for(int c=1;c<=K;c++){
        sum+= gcd(g,c);
      }
    }
  }
  cout << sum << endl;        
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  int N;
  cin >> N;
  vi X(N);
  REP(i, N) cin >> X.at(i);
  
  int r = INT_MAX;
  REP(i, 100) {
    int t = 0;
    REP(x, N) {
      t += (X.at(x) - i) * (X.at(x) - i);
    }
    r = min(r, t);
  }
  
  cout << r << endl;
}

Measured memory_bytes: 3628
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

int n, a[21][21], dp[21][1u << 21u];

void add(int &a, int b) {
    a += b;
    if (a >= mod)a -= mod;
}

int dfs(int pos, int mask) {
    if (pos == n)return 1;
    if (~dp[pos][mask])return dp[pos][mask];
    int ans = 0;
    for (int w = 0; w < n; ++w) {
        if (a[pos][w] && !(mask & (1 << w)))add(ans, dfs(pos + 1, mask ^ (1 << w)));
    }
    return dp[pos][mask] = ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 344320
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }
int main(){
  int ans = 0;
  int N;
  string S;
  cin >> N >> S;
  for(int i=0; i<=999; ++i){
    std::ostringstream sout;
    sout << setfill('0') << setw(3) << i;
    string str = sout.str();
    int flg = 0;
    for(int j=0; j<N; ++j){
      if(S[j]==str[flg]) ++flg;
      if(flg==3){
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<ll> a(n+1),sum(n+1,0);
	multiset<ll> beauty;
	FOR(i,1,n+1){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	FOR(l,1,n+1)FOR(r,l,n+1){
		beauty.insert(sum[r]-sum[l-1]);
	}
	for(ll i=60;i>=0;i--){
		ll cnt=0;
		for(auto itr:beauty){
			if(1ll<<i & itr){
				cnt++;
			}
		}
		if(cnt>=k){
			multiset<ll> nb;
			for(auto itr:beauty){
				if(1ll<<i & itr){
					nb.insert(itr);
				}
			}
			swap(beauty,nb);
		}
	}
	ll ans=(1ll<<60)-1;
	for(auto itr:beauty){
		ans&=itr;
	}
	cout<<ans<<endl;
}

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

int main(){
	int n;
  	cin >> n;
  	int a,mini = 99999999;
  	for(int i = 1; i <= n/2+1; i++) {
    	a = (i /10000) + (i/1000) % 10 + (i/100) % 10 + (i/10) % 10 + i % 10;
      	a += ((n-i)/10000)+ ((n-i)/1000) % 10 + ((n-i)/100) % 10 + 
          ((n-i)/10) % 10 + (n-i)% 10;
      	
      	if(a < mini)
          	mini = a;
    }
  	cout << mini << endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for(int i=0; i<N; i++){
        cin >> l[i];
    }

    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());

    int ans = 0;
    for(int j=0; j<K; j++){
        ans += l[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>n>>m;
		// n=s.length();
		// ll a[n];
		cs=inf;
		rep(i,n)
		{
			c+=m+i;
			cs=min(cs,abs(m+i));
			// debug3(m+i,c,cs);
		}
		
		if((cs>0 && c>0) || (c<0 && cs<0))
			c-=cs;
		else c+=cs;
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var ini = 1;
            while (ini <= N)
                ini *= 2;
            WriteLine(ini / 2);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  ll sum=0;
  vector<ll> vec(N-1);
  for(ll i=0;i<N-1;i++){
    cin>>vec.at(i);
  }
  sum+=vec.at(0)+vec.at(N-2);
  for(ll i=0;i<N-2;i++){
    sum+=min(vec.at(i),vec.at(i+1));
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end() 
#define ret return 0
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rev(s) reverse(s.begin(),s.end())
#define WL(t) while(t --)
#define MOD 1000000007
int main()
{
      boost;
      ll a,b,c,X,cnt=0;
      cin>>a>>b>>c>>X;
      for(int i=0;i<=a;i++)
      {
            for(int j=0;j<=b;j++)
            {
                  for(int k=0;k<=c;k++)
                  {
                        int x=(500*i)+(100*j)+(50*k);
                        if(x==X)
                        {
                              cnt++;
                        }
                  }
            }
      }
      cout<<cnt<<endl;
}

Measured memory_bytes: 256