akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


int main(int argc, char* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<string> masu(h);
  set<pair<int, int>> kuro;
  int num_kuro = 0;

  rep(i, h) {
    cin >> masu[i];
    rep(j, w) {
      if (masu[i][j] == '#') {
        kuro.insert(make_pair(i, j));
        num_kuro++;
      }
    }
  }

  int ans = 0;
  while (num_kuro < h * w && kuro.size() != 0) {
    ans++;
    set<pair<int, int>> new_kuro;
    for (auto& p : kuro) {
      int y = p.first;
      int x = p.second;
      if (y -1 >= 0 && masu[y-1][x] == '.') {
        new_kuro.insert(make_pair(y-1, x));
        masu[y-1][x] = '#';
        num_kuro++;
      }
      if (y+1 < h && masu[y+1][x] == '.') {
        new_kuro.insert(make_pair(y+1, x));
        masu[y+1][x] = '#';
        num_kuro++;
      }
      if (x -1 >= 0 && masu[y][x-1] == '.') {
        new_kuro.insert(make_pair(y, x-1));
        masu[y][x-1] = '#';
        num_kuro++;
      }
      if (x+1 < w && masu[y][x+1] == '.') {
        new_kuro.insert(make_pair(y, x+1));
        masu[y][x+1] = '#';
        num_kuro++;
      }
    }
    kuro = new_kuro;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 49152
N=int(input())
A=[[] for _ in range(2)]
for i in range(2):
    A[i]=list(map(int,input().split()))
    
S=[[0]*(N+1) for _ in range(2)]

for i in range(2):
    for j in range(N):
        S[i][j+1]=S[i][j]+A[i][j]
        
        
ans=0
for i in range(N):
    temp=S[0][i+1]
    temp+=S[1][-1]-S[1][i]
    ans=max(ans,temp)
    
print(ans)
    

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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (n % k == 0)
        cout << 0 << endl;
    else
        cout << abs(n/k + 1 - n/k) << endl;
    
    

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println((n / 2) * ((n + 1) / 2))
}


Measured memory_bytes: 640
S=gets.chomp.split("").map(&:to_i)
if S.length==1
    puts S
    exit
end
ret=0
S.each_with_index do |s,index|
    count=2**index

    ret+=s*(10**(S.length-index-1))*count
    (S.length-index-2).downto(0) do |l|
        ret+=s*(10**l)*count
        count*=2
    end
end
puts ret


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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
#define fir first
#define sec second

int n, m; 
int a[200]; 
bool v[2000000]; 
bool v2[2000000]; 

int main() {
	cin>>n>>m; 
	for (int i = 1; i <= m; ++i) scanf( "%d", &a[i] ); 
	int l = 0; 
	for (int i = 1; i <= m; ++i) l += a[i]/2; 
	if (l + n/2 < n-1) {
		printf( "Impossible\n" ); 
		return 0; 
	}
	for (int i = 2; i <= m; ++i) 
		if (a[i] % 2 == 1) swap(a[1], a[i]); 
	for (int i = 2; i < m; ++i) 
		if (a[i] % 2 == 1) swap(a[i], a[m]);  
	for (int i = 1; i <= m; ++i) printf( "%d ", a[i] ); 
	puts( "" ); 
	if (a[1] % 2 == 1) {
		if (m == 1) {
			if (a[1] == 1) printf( "1\n1" ); 
			else printf( "2\n%d %d", 1, a[m]-1 ); 
		}
		else {
			vi ans; 
			ans.pb( a[1]+1 ); 
			for (int i = 2; i < m; ++i) ans.pb(a[i]); 
			if (a[m] > 1) ans.pb(a[m]-1); 
			cout<<ans.size()<<endl; 
			for (auto i : ans) printf( "%d ", i ); 
			puts( "" ); 
		}
	}
	else {
		printf( "%d\n", m+1 ); 
		printf( "1 "); 
		for (int i = 1; i < m; ++i) printf( "%d ", a[i] ); 
		printf( "%d ", a[m]-1);
	}
	puts( "" ); 
}


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

int main()
{
    int K, N, D;
    cin >> K >> N;
    vector<int> A(N), d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if (i > 0)
        {
            d.at(i - 1) = A.at(i) - A.at(i - 1);
        }
    }
    d.at(N - 1) = A.at(0) + K - A.at(N - 1);
    D = d.at(0);
    for (int i = 1; i < N; i++)
    {
        if (d.at(i) > D)
        {
            D = d.at(i);
        }
    }
    cout << K - D << endl;
}

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

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

  double sq_m = sqrt(m);
  int ans = 1;
  for ( int i = 1; i <= sq_m; i++ ) {
    if ( m%i != 0 ) { continue; }
    ans = ( i > ans && i <= m/n ) ? i : ans;
    ans = ( m/i > ans && m/i <= m/n ) ? m/i : ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,c,d; cin >>a>>b>>c>>d;

    cout << max(a*b, c*d) << endl;

    return 0;
}




Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []

ok_count = 0

for i in range(n):
    a.append(list(map(int, input().split())))

    sum = c
    for j in range(m):
        sum += a[i][j] * b[j]

    ok_count += 1 if sum > 0 else 0

print(ok_count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); i++) {
        cout << min(a, b);
    }
    cout << endl;
}


Measured memory_bytes: 256
c = [[int(j) for j in input().split()] for i in range(3)]
flag = True
diffb21 = c[0][1] - c[0][0]
diffb32 = c[0][2] - c[0][1]
for i in range(1, 3):
    if c[i][1] - c[i][0] != diffb21 or c[i][2] - c[i][1] != diffb32:
        flag = False
tc = list(zip(*c))
diffa21 = tc[0][1] - tc[0][0]
diffa32 = tc[0][2] - tc[0][1]
for i in range(1, 3):
    if tc[i][1] - tc[i][0] != diffa21 or tc[i][2] - tc[i][1] != diffa32:
        flag = False
print('Yes' if flag else 'No')

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n; double d; cin >> n >> d;
    vector<ll> X(n), Y(n);
    rep(i, n)cin >> X[i] >> Y[i];

    int cnt = 0;
    rep(i, n){
        double tmp = sqrt((X[i] * X[i]) + Y[i] * Y[i]);
        if(tmp <= d)cnt++;
    }
    cout << cnt << ln;
}
    


Measured memory_bytes: 6488
#include<bits/stdc++.h>
using namespace std;
int n,W;
long long w,v;
long long bst[100005];
int main() {
	scanf("%d%d",&n,&W);
	for(int i=0; i<n; i++) {
		scanf("%lld%lld",&w,&v);
		for(int i=W; i>=w; i--) {
			bst[i]=max(bst[i],bst[i-w]+v);
		}
	}
	printf("%lld\n",bst[W]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

int a,b;
char s;
int main(){	
    ios::sync_with_stdio(false);
    cin >> a >> s >> b;
    if (s == '-')
    cout << a-b << "\n";
    else
    cout << a+b << "\n";
    return 0;
}	

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll N;
  cin >> N;
  int maxNum = 0;
  rep(i,N+1){
    if(i*(i+1)/2 >= N){
      maxNum = i;
      break;
    }
  }
  int ignore = maxNum *(maxNum+1) / 2 - N;
  FOR(i,1,maxNum+1){
    if(i != ignore) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int a ;
    int b ;
    int area;
    int perimeter;
    
    scanf("%d",&a);
    scanf("%d",&b);
    area = a * b;
    perimeter = (a + b) * 2;
    printf("%d %d\n",area,perimeter);

    return 0;
}


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

const double PI=3.14159265358979323846;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << endl

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

    print(2*PI*r);
    return 0;
}

Measured memory_bytes: 3796
#include<stdio.h>
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int ans = 0;
	long long int i, j;
	long long int a, b, c, d;
	long long int p = 1000000007;
	for (i = 1; i <= k; i++)
	{
		a = 1;
		for (j = 0; j < i - 1; j++)
		{
			a *= k - j - 1;
			a %= p;
		}
		b = 1;
		for (j = 0; j < i - 1; j++)
		{
			b *= j + 1;
			b %= p;
		}
		c = 1;
		for (j = 0; j < i; j++)
		{
			c *= n - k - j + 1;
			c %= p;
		}
		d = 1;
		for (j = 0; j < i; j++)
		{
			d *= j + 1;
			d %= p;
		}
		b = modpow(b, p - 2, p);
		d = modpow(d, p - 2, p);
		a *= b;
		a %= p;
		c *= d;
		c %= p;
		printf("%lld\n", (a * c) % p);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n;
  string s;
  cin >> n >> s;
  vi cnte(n, 0), cntw(n, 0);
  int cntee = 0, cntww = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'W') cntww++;
    if (s.at(n - 1 - i) == 'E') cntee++;
    cntw.at(i) = cntww;
    cnte.at(n - 1 - i) = cntee;
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    if (i == 0) ans = min(ans, cnte.at(1));
    else if (i == n - 1) ans = min(ans, cntw.at(n - 2));
    else ans = min(ans, cnte.at(i + 1) + cntw.at(i - 1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

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


	for(int i = 0; i < (int)S.size(); i++){
		for(int j = i; j < (int)S.size(); j++){
			if(S.substr(0,i) + S.substr(j) == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}

	cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program2
    {
        static void Main(string[] args)
        {
            //long n = long.Parse(Console.ReadLine());
            char[] inputLongArray1 = Console.ReadLine().Split(' ').Select(i => char.Parse(i)).ToArray();
            //long[] inputLongArray2 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            string result = "a";


            if(Char.IsUpper(inputLongArray1[0]))
            {
                result = "A";
            }

            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            sw.Write(result);
            Console.SetOut(sw);
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26496
N,K=map(int, input().split())
p = list(map(int, input().split()))

p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=e
for i in range(1,N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)

Measured memory_bytes: 25604
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

string s;
int n, k, dp[111][5][2];

signed main() {

    cin >> s >> k;
    n = s.size();
    
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++) {
        s[i] = s[i] - '0';
        dp[i+1][0][1] = 1;
        for(int j = 1; j <= k; j++) {
            dp[i+1][j][1] += dp[i][j-1][1] * 9 + dp[i][j][1];

            if(s[i]) {
                dp[i+1][j][0] = dp[i][j-1][0];
                dp[i+1][j][1] += dp[i][j][0] + dp[i][j-1][0] * (s[i]-1);
            }
            else
                dp[i+1][j][0] = dp[i][j][0];
        
        }

    }

    cout << dp[n][k][1] + dp[n][k][0] << endl;
  
    return 0;
}



Measured memory_bytes: 256
<?php
list($N) = fscanf(STDIN,'%d');
$v = array_map('intval',explode(" ",fgets(STDIN)));
$c = array_map('intval',explode(" ",fgets(STDIN)));
$ans = 0;
for($i=0;$i<$N;$i++){
    if($v[$i]-$c[$i]>0) $ans += $v[$i]-$c[$i];
}
echo $ans;
?>

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

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

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

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

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

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

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

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


pub fn solve(target_num: i64, shops: &mut [(i64,i64)]) -> i64 {
    shops.sort();
    let mut price_sum = 0;
    let mut drink_num = 0;
    for &(price,num) in shops.iter(){
        let diff = target_num - drink_num;
        if diff <= num {
            price_sum = price_sum + diff * price;
            return price_sum
        } else {
            price_sum = price_sum + price * num;
            drink_num = drink_num + num
        }
    };
    price_sum
}


fn main() {
    input!(
        n: i64,
        m: i64,
        shops: [(i64,i64); n],
    );
    let mut s = shops;
    let result = solve(m, &mut s);
    println!("{:?}",result);
}


Measured memory_bytes: 8444
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int h = s.nextInt();
        int x = s.nextInt();
        int y = s.nextInt();
        BigDecimal b = (new BigDecimal(w).multiply(new BigDecimal(h))).divide(new BigDecimal(2),6,BigDecimal.ROUND_HALF_UP);
        System.out.println(b.toPlainString()+" "+((x+x==w&&y+y==h) ? "1":"0"));
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int mi = inf;
  rep(i, 101) {
    int sum = 0;
    rep(j, n) sum += (a[j] - i) * (a[j] - i);
    chmin(mi, sum);
  }
  cout << mi << endl;
}


Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())

plus=[]
minus=[]
for aa in a:
    if aa>=0:
        plus.append(aa)
    else:
        minus.append(aa)

if len(plus)==n:
    plus.sort(reverse=True)
    minus.append(plus.pop())
elif len(minus)==n:
    minus.sort()
    plus.append(minus.pop())

print(sum(plus)-sum(minus))

xy=minus[0]
for i in range(len(plus)-1):
    print('{} {}'.format(xy,plus[i]))
    xy-=plus[i]

print('{} {}'.format(plus[-1],xy))
xy=plus[-1]-xy

for i in range(1,len(minus)):
    print('{} {}'.format(xy,minus[i]))
    xy-=minus[i]



Measured memory_bytes: 93604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int[] a = in.nextIntArray(3);
			Arrays.sort(a);
			out.println(a[2]-a[1] + a[1]-a[0]);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int s;
	cin >> s;
	map <int, int> mp;
	mp[s]++;
	for(int i = 0; i < 1500000; i++){
		if(s & 1){
			s = 3 * s + 1;
			mp[s]++;
			if(mp[s] == 2) return cout << i + 2, 0;
		}
		else{
			s = s / 2;
			mp[s]++;
			if(mp[s] == 2) return cout << i + 2, 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(W >= V) {
        cout << "NO" << endl;
        return 0;
    }
    lint c = (abs(B-A)-1) / (V-W);
    if(c < T) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3580
a, b = map(int,input().strip().split(' '))
a_rev = ""
i = 0
j = 0
cnt = 0

#chk = []

for i in range(b - a + 1):
    
    
    for j in range(len(str(a))):
        a_rev = a_rev + str(a)[len(str(a)) - 1 - j]   

    if str(a_rev) == str(a):
        cnt+=1
#        chk.append(a_rev)   #test
    else:
        pass
    a+=1
    a_rev =""
    
print(cnt)
#print(chk)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pii pair<int,int>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(10)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod = 1000000007;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int red = 0,blue = 0;
    int n = s.size();
    rep(i,n){
        red += (s[i] == '0');
        blue += (s[i] == '1');
    }
    cout << min(red,blue) * 2 << '\n';
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  int n;
  cin >> n;
  cout << 3*n*n << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

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

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
	int n,x = 0, result=0;
	string s;
	gets(n) gets(s)
	rep(i, n){
		if (s[i] == 'I'){
			x += 1;
			result = max(result, x);
		}else{
			x -=1;
		}
	}
	puts(result)
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: "List[List[int]]"):
    print(max(
        sum(A[0][:i + 1]) + sum(A[1][i:])
        for i in range(N)
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(2)]  # type: "List[List[int]]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
fun main( args : Array<String> ) {
  val s = "abcdefghijklmnopqrstuvwxyz".toSet()
  val t = readLine()!!.toSet()
  (s - t).toList().sorted().let {
    when {
      it.size > 0 -> it.first().toString() 
      else -> "None"
    }.let { println(it) }
  }
}

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

int main() {
  int N, W; cin >> N >> W;

  vector<long long> dp(N * 1000 + 1, INF);
  dp[0] = 0;

  rep(i, N) {
    int w, v; cin >> w >> v;
    vector<long long> ndp(dp);
    rep(k, dp.size()) {
      if (dp[k] + w > W) continue;
      ndp[k + v] = min(dp[k + v], dp[k] + w);
    }
    swap(dp, ndp);
  }

  int ans = 0;
  rep(i, dp.size()) {
    if (dp[i] != INF) ans = max(ans, i);
  }
  cout << ans << endl;
}

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

int N;
vector<string> A, B;
string S, T;

string sed(string s, string &a, string &b){
    string res = s;
    
    auto pos = s.find(a);
    int diff = 0;
    while(pos != string::npos){
        res.replace(pos + diff, a.size(), b);
        diff += b.size() - a.size();
        pos = s.find(a, pos + a.size());
    }
    
    return res;
}

int solve(){
    map<string, int> visited;
    
    queue<string> que;
    que.push(S);
    visited[S] = 0;
    
    while(!que.empty()){
        auto s = que.front(); que.pop();
        if(s == T){
            return visited[T];
        }
        if(s.length() < T.length()){
            for(int i=0; i<N; i++){
                string t = sed(s, A[i], B[i]);
                if(visited.find(t) == visited.end()){
                    visited[t] = visited[s] + 1;
                    que.push(t);
                }
            }
        }
    }

    return -1;
}

int main(){
    
    while(cin >> N, N){
        A.resize(N); B.resize(N);
        for(int i=0; i<N; i++)
            cin >> A[i] >> B[i];
        
        cin >> S >> T;
        
        cout << solve() << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {
        string s, t; cin >> s>> t;
        int n= s.size(), m= t.size();

        int mn= m;

        for (int i= 0; i< n- m+ 1; i++) {
                int an= 0;
                for (int j= i, k= 0; k< m; j++, k++) {
                        if (s[j]!= t[k]) an++;
                }
                mn= min(mn, an);
        }
        cout << mn<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n,max=-1000001,min=1000001;
		long sum=0;
		n=stdIn.nextInt();
		for(int i=0;i<n;i++){
			int a=stdIn.nextInt();
			if(a>max)
				max=a;
			if(a<min)
				min=a;
			sum+=a;
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 41104
#include<iostream>

using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull N;
	cin >> N;
	
	if(N % 2 == 1) {
		cout << 0;
		return 0;
	}
	
	ull ans = (N / 10);
	ull tmp = ans;
	
	while(tmp > 0) {
		tmp /= 5;
		ans += tmp;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<numeric>
#include<list>
#include<limits>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>

#define pi 3.141592653589793
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

using namespace std;
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const long long MOD = 10e9 + 7;
const long long INF = 10e9 ;

template <typename T>
std::ostream& operator<<(ostream& os, 
                        const vector<T> &v)
{
    for (T const& i: v) {
        os << i << " ";
    }
    os<<endl;
    return os;
}

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
vector<int> sieve(int n){
    vector<bool> s(n, true);
    for(int i =2 ; i*i <= n; i++ )
        if(s[i])
            for(int j=2*i; j< n; j +=i )
                s[j] = false;

    vector<int> primes;
    for(int i =0; i<n; i++)
        if( s[i] )
            primes.push_back(s[i]);

    return primes;
}

int main(){
    int t;
    cin>>t;
    cout<< 2 * 3.1415 * t;

    return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11

using namespace std;

long long N;
long long d[105];
int main(){
	cin >> N;
	rep(i, N) cin >> d[i];
	long long ans = 0;
  // 組み合わせの実装
	for(long long i = 0; i < N; i++) {
		for(long long j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int gcd(int a, int b);
int main() {
	int a;
	cin >> a ;
	long long int sum = 0;
	for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= a; j++) {
			for (int k = 1; k <= a; k++) {
				sum += gcd(gcd(i,j),k);
			}
		}
	}
	cout << sum;
	return 0;
}
int gcd(int a, int b) {
	int r;
	while (b != 0) {
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    string s;cin>>s;
    bool ans = s.length()==6;

    if(ans)
    ans &= (s[2]==s[3]);
    if(ans)
    ans &= (s[4]==s[5]);
    
    if(ans) cout<<"Yes\n";
    else cout<<"No\n";
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <numeric>

#include <array>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <ostream>
#include <type_traits>
#include <utility>
#include <chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")
#endif

using namespace std;

// Find value on pos
// Add val to range [l,r)
// Set val on pos
template <typename T>
class Fenwick
{
   public:
    Fenwick(int n)
    {
        len = 1;
        while (len < n) len <<= 1;
        data.resize(n + len);
    }

    void add(int l, int r, T val)
    {
        for (l += len, r += len; l < r; l >>= 1, r >>= 1) {
            if ((l % 2) == 1) data[l++] += val;
            if ((r % 2) == 1) data[--r] += val;
        }
    }

    T get(int pos)
    {
        T summa = 0;
        for (pos += len; pos > 0; pos >>= 1) {
            summa += data[pos];
        }
        return summa;
    }

    void set(int pos, T value) { data[pos + len] += value - get(pos); }

   private:
    int len;
    vector<T> data;
};

using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;

#define seq(i,a,b) for (int i = (a); i < (b); ++i)
#define rev(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) (x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) {cerr << #x << ": " << x << endl;}

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m; cin >> n >> m;

    Fenwick<int> F(n);

    seq(_,0,m) {
        int l,r; cin >> l >> r;
        --l;
        F.add(l, r, 1);
    }

    // I could push everything down, but meh
    int res = 0;
    seq(i,0,n) {
        res += m == F.get(i);
    }
    cout << res << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define N 1000100
using namespace std;
typedef pair<int,int> pii;
int n,m,newn,len;
vector<pii> bel[N];
unordered_map<int,int> s[N];
int dis[N],cx[N];
int beg[N],va[N<<2],to[N<<2],nex[N<<2];
bool inq[N];
queue<int> q;
inline void Add(int a,int b,int c){
	nex[++len]=beg[a],beg[a]=len,to[len]=b,va[len]=c;
	nex[++len]=beg[b],beg[b]=len,to[len]=a,va[len]=c;
}
int main(){
	scanf("%d%d",&n,&m);
	newn=n;
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		bel[c].push_back(pii(a,b));
	}
	for(int i=1;i<=1000000;i++){
		int len=bel[i].size();
		if(!len) continue;
		for(int j=0;j<len;j++){
			if(s[i][bel[i][j].first]==0) s[i][bel[i][j].first]=++newn;
			if(s[i][bel[i][j].second]==0) s[i][bel[i][j].second]=++newn;
			int l=s[i][bel[i][j].first],r=s[i][bel[i][j].second];
			cx[l]=bel[i][j].first;
			cx[r]=bel[i][j].second;
			Add(l,r,0);
			Add(l,cx[l],1);
			Add(r,cx[r],1);
		}
	}
	memset(dis,-1,sizeof(dis));
	q.push(1);dis[1]=0;
	while(!q.empty()){
		int st=q.front();q.pop();
		for(int i=beg[st];i;i=nex[i]){
			if(dis[to[i]]>dis[st]+va[i]||dis[to[i]]==-1){
				dis[to[i]]=dis[st]+va[i];
				if(!inq[to[i]]){
					inq[to[i]]=1;
					q.push(to[i]);
				}
			}
		}
		inq[st]=0;
	}
	if(dis[n]<0) puts("-1");
	else printf("%d\n",dis[n]/2);
	return 0;
}

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

int main(){
  int n,k;
  int ans=0;
  
  cin>>n>>k;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());
  
  for(int i=0;i<k;i++){
    ans+=s.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i,j;
  for(i = 1;i < s.size();i++){
    if(s[i] == s[i - 1]){j = i;i = i - 1;break;}
    if(i >= 2)if(s[i] == s[i - 2]){j = i;i = i - 2;break;}
  }
  if(i == s.size()){
    cout << -1 << " " << -1 << endl;
  }else{
    cout << i + 1 << " " <<  j + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner teclado = new Scanner(System.in);
		int x = teclado.nextInt();
		int a = teclado.nextInt();
		if(x < a) {
			System.out.println("0");
		}else {
			System.out.println("10");
		}
		
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<map<int, ll>> dp(N + 1);
    dp[0][0] = 0;
    REP(i, N) {
        if (i == 0) {
            dp[i + 1][0] = 0;
            dp[i + 1][1] = A[i];
            continue;
        }
        FOR(j, i / 2, i / 2 + 2) {
            dp[i + 1][j] = -(ll)1e18;
            if (dp[i].count(j)) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (dp[i - 1].count(j - 1))
                dp[i + 1][j] = max(dp[i + 1][j], dp[i - 1][j - 1] + A[i]);
        }
    }
    cout << dp[N][N / 2] << endl;

    return 0;
}


Measured memory_bytes: 39100
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	N, K := nextInt(), nextInt()

	K2 := K * 2
	black := make([][]int, K2)
	white := make([][]int, K2)
	for i := 0; i < K2; i++ {
		black[i] = make([]int, K2)
		white[i] = make([]int, K2)
	}

	for i := 0; i < N; i++ {
		x, y, c := nextInt(), nextInt(), next()
		xx := x % K2
		yy := y % K2
		if c == "B" {
			black[yy][xx]++
		} else {
			white[yy][xx]++
		}
	}

	bimos := make([][]int, K2+1)
	wimos := make([][]int, K2+1)
	for i := 0; i <= K2; i++ {
		bimos[i] = make([]int, K2+1)
		wimos[i] = make([]int, K2+1)
	}

	for i := 0; i < K2; i++ {
		for j := 0; j < K2; j++ {
			bimos[i+1][j+1] = bimos[i][j+1] + bimos[i+1][j] - bimos[i][j] + black[i][j]
			wimos[i+1][j+1] = wimos[i][j+1] + wimos[i+1][j] - wimos[i][j] + white[i][j]
		}
	}
	res := 0
	/*
	xxx := func(a [][]int) {
		n := len(a)
		for i := 0; i < n; i++ {
			fmt.Println(a[i])
		}
		fmt.Println()
	}
	 xxx(black)
	 xxx(white)
	 xxx(bimos)
	 xxx(wimos)
*/
	calc2 := func(x1, y1, x2, y2 int, a [][]int) int {
		return a[y2][x2] + a[y1][x1] - a[y2][x1] - a[y1][x2]
	}

	calc := func(x, y int, a [][]int) int {
		x2, y2 := x+K, y+K
		if x2 < K2 {
			if y2 <= K2 {
				return calc2(x, y, x2, y2, a)
			} else {
				return calc2(x, y, x2, K2, a) + calc2(x, 0, x2, y2 - K2, a)
				// return (a[K2][x2] - a[y][x]) + (a[y2-K2][x2] - a[0][x])
			}
		} else {
			if y2 < K2 {
				return calc2(x, y, K2, y2, a) + calc2(0, y, x2 - K2, y2, a)
				// return (a[y2][K2] - a[y][x]) + (a[y2][x2-K2] - a[y][0])
			} else {
				return calc2(x, y, K2, K2, a) +
					calc2(x, 0, K2, y2 - K2, a) +
					calc2(0, y, x2 - K2, K2, a) +
					calc2(0, 0, x2 - K2, y2 - K2, a)
				// return (a[K2][K2] - a[y][x]) + (a[y2-K2][K2] - a[0][x]) + (a[K2][x2-K2] - a[y][0]) + (a[y2-K2][x2-K2] - a[0][0])
			}
		}
	}

	for i := 0; i < K; i++ {
		for j := 0; j < K; j++ {
			{
				val := 0
				val += calc(i, j, bimos)
				val += calc(i+K, j+K, bimos)
				val += calc(i, j+K, wimos)
				val += calc(i+K, j, wimos)
				// fmt.Println(i, j, calc(i, j, bimos), calc(i+K, j+K, bimos), calc(i, j+K, wimos), calc(i+K, j, wimos), val)
				res = max(res, val)
			}
			{
				val := 0
				val += calc(i, j, wimos)
				val += calc(i+K, j+K, wimos)
				val += calc(i, j+K, bimos)
				val += calc(i+K, j, bimos)
				res = max(res, val)
			}
		}
	}

	fmt.Println(res)
}

// -------- Library --------
func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func abs(x int) int {
	if x > 0 {
		return x
	} else {
		return -x
	}
}

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 133760
/* MaTb3aa */
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v;
int dp[100005];
int solve(int i) {
	if (i >= n)return 2e9;
	if (i == n - 2)return abs(v[i] - v[n - 1]);
	if (i == n - 3)return abs(v[i] - v[n - 1]);
	int &ret = dp[i];
	if (ret!=2e9)return ret;
	ret = min(ret, solve(i + 1) + abs(v[i] - v[i + 1]));//take1
	ret = min(ret, solve(i + 2) + abs(v[i] - v[i + 2]));//take2
	return ret;
}
int main() {
	cin >> n;
	v.resize(n);
	for (auto& t : v)cin >> t;
	fill(dp, dp + n + 1, 2e9);
	cout<<solve(0);
	
		 
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

a = int(input())
b = list(map(int,input().split()))

def solve(l):
    ret = 0
    if len(l)==1:
        return l[0]
    elif 0 in l:
        part_l = []
        for i in l:
            if i != 0:
                part_l.append(i)
            else:
                if len(part_l)>0:
                    ret+=solve(part_l)
                    part_l = []
        if len(part_l)>0:
            ret+=solve(part_l)
        return ret
    else:
        min_l = min(l)
        ret+=min_l
        l = list(map(lambda x:x-min_l,l))
        return ret + solve(l)

print(solve(b))

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

int main() {
  int N;
  cin >> N;
  vector<int> n(N);
  for (int i = 0; i < N; i++) {
    cin >> n[i];
  }
  for (int i = 0; i < N; i++) {
    if (n[i] % 2 == 0) {
      if (n[i] % 3 == 0 || n[i] % 5 == 0) {
        continue;
      }
      else {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;     
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int N = inputintArray[0];
            int M = inputintArray[1];

            var H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] E = Enumerable.Repeat<int>(1, N).ToArray();

            int j;
            for (j = 0; j < M; j++)
            {

                var Road = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

                if (H[Road[0] - 1] > H[Road[1] - 1])
                {
                    E[Road[1] - 1] = 0;
                    //Console.WriteLine(Road[1]+"yes");
                }
                else if (H[Road[0] - 1] < H[Road[1] - 1])
                {
                    E[Road[0] - 1] = 0;
                    //Console.WriteLine(Road[0]+"no");
                }

                else
                {
                    E[Road[1] - 1] = 0;
                    E[Road[0] - 1] = 0;
                }
            }

            List<int> listE = new List<int>(E);
            Console.WriteLine(listE.Count(x=>x==1));

            //int[] array = listE.ToArray();
            //Console.WriteLine("=== array ===");
            //foreach (var x in array)
            //{
            //    Console.WriteLine(x);
            //}


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 49344
n, m = STDIN.gets.split(' ').map(&:to_i)

cities = Array.new(n, 0)
m.times do
  i, j = STDIN.gets.split(' ').map(&:to_i)
  cities[i - 1] += 1
  cities[j - 1] += 1
end

cities.each do |num|
  puts num
end

Measured memory_bytes: 3836
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<math.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。



int main(){
      int a,b;
      cin>>a>>b;
      if(a>=13) cout<<b<<endl;
      else if(a>=6) cout<<b/2<<endl;
      else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256