akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math.*;
import java.util.*;
import java.math.*;
import java.text.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(8);
        nf.setGroupingUsed(false);
        while(true) {
            int count = Integer.parseInt(br.readLine());
            if(count == 0)break;
            String[] line = br.readLine().split(" ");
            double[] points = new double[count];
            //longの配列に格納
            for(int i=0;i<count;i++) points[i] = Double.parseDouble(line[i]);
            //標準偏差計算
            double sample = 0;
            double ave_d = ave(points);
            double ans = 0;
            for(int i=0;i<points.length;i++)
                sample += (Math.pow((points[i] - ave_d),2));
            ans = Math.sqrt(sample / points.length);
            System.out.println(nf.format(ans));
        }
    }
    static double sum(double[] tag) {
        double sum = 0;
        for(int i=0;i<tag.length;i++)
            sum += tag[i];
        return sum;
    }
    static double ave(double[] tag) {
        return sum(tag) / tag.length;
    }
}

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

signed main() {
    int N;
    cin >> N;

    vector<int> b(N);
    int sum = 0;
    for (int& x : b) cin >> x, sum += x;

    vector<int> a = b;
    vector<int> ans;
    while (a.size()) {
        int idx = -1;
        for (int i = 0; i < a.size(); i++) {
            if (a[i] == i + 1) {
                idx = i;
            }
        }
        if (idx < 0) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(a[idx]);
        a.erase(a.begin() + idx);
    }

    reverse(ans.begin(), ans.end());
    for (int x : ans) cout << x << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>
#include <set>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

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

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

map<ll, ll> prime_decomposition(ll n) {
  map<ll, ll> mp;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p != 0) continue;
    ll cnt = 0;
    while (n % p == 0) {
      cnt++;
      n /= p;
    }
    mp[p] = cnt;
  }
  if (n != 1) mp[n] = 1;
  return mp;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp = prime_decomposition(n);
  ll ans = 0;

  for (auto& x : mp) {
    ll e = x.second;
    ll s = 0, k = 0;
    FOR(i, 1, n) {
      s += i;
      if (e >= s) {
        k = i;
      } else {
        break;
      }
    }
    ans += k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	if (n < 30) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//BufferedReader in = new BufferedReader(new FileReader(new File("input.txt")));
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] line = in.readLine().split(" ");
		int N = conv(line[0]); int M = conv(line[1]);
		int[][] gates = new int[M][2];
		for(int i = 0; i < M; i++) {
			line = in.readLine().split(" ");
			gates[i][0] = conv(line[0]); gates[i][1] = conv(line[1]);
		}
		int Lmax = 0; int Rmin = Integer.MAX_VALUE;
		for(int[] range : gates) {
			if(Lmax < range[0]) {
				Lmax = range[0];
			}
			if(range[1] < Rmin) {
				Rmin = range[1];
			}
		}
		int valid = Rmin - Lmax;
		if(valid < 0) {
			System.out.println(0);
			return;
		}
		System.out.println(valid + 1);
	}
	public static int conv(String s) {
		return Integer.valueOf(s);
	}
}

Measured memory_bytes: 47944
o=str(input())
e=str(input())
s="A"
l=min(len(o),len(e))
for i in range(0,l):
  s=s+o[i]+e[i]
if len(o)<len(e):
  s=s+e[len(e)-1]
elif len(o)>len(e):
  s=s+o[len(o)-1]
s=s.lstrip("A")
print(s)

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

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    finv.assign(n + 1, fact[n].inv());
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
  int x, y;
  cin >> x >> y;
  ModInt::build(1e6);
  int n = x + y;
  if (n % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  n /= 3;
  cout << ModInt::comb(n, (n + 1) / 2 + abs(x - y) / 2) << endl;
}


Measured memory_bytes: 16000
<?php
  /*
    AOJ 0100
    @kankichi573
   */
while(fscanf(STDIN,"%d",$n) && ($n > 0))
  {
    $prev=-1;
    $goukei=array();
    $next=array();
    
    for($i=0;$i<$n;$i++)
      {
	
	fscanf(STDIN,"%d %d %d",$sno,$kosuu,$tanka);
	if(empty($goukei[$sno]))
	  {
	    //fprintf(STDOUT,"EMT=%d\n",$sno);
	    $goukei[$sno] = $kosuu*$tanka;
	    if($prev>0)
	      {
		$next[$prev]=$sno;
		$next[$sno]=0;
	      }
	    else
	      {
		$start=$sno;
		$next[$sno]=0;
	      }
	    $prev=$sno;
	  }
	else
	  $goukei[$sno] += $kosuu*$tanka;
      }
    
    $p=$start;
    $count=0;

    //var_dump($next);
    //var_dump($goukei);

    while(1)
	    {
	      if($goukei[$p]>=1000000)
		{
		  fprintf(STDOUT,"%d\n",$p);
		  $count++;
		}
	      if($next[$p]==0)
		 break;
	      $p=$next[$p];
	    }
	if($count==0)
	  fprintf(STDOUT,"NA\n");
  }
return(0);
?>

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    cout << (a+b)/2+(a+b)%2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    map<ll, ll> mp;
    rep(i, N)
    {
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll cnt = 0;
    for (auto& p : mp) {
        if (p.second % 2)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6528
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Exception
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.Trans.State.Strict
import           Data.Array.Base
import           Data.Array.ST                    (STUArray, runSTUArray)
import           Data.Bits
import           Data.Bool
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.Foldable                    as F
import           Data.Function
import           Data.Int
import qualified Data.IntMap.Strict               as IM
import qualified Data.IntSet                      as IS
import qualified Data.List                        as L
import qualified Data.Map.Strict                  as M
import           Data.Monoid
import           Data.Ord
import qualified Data.Set                         as S
import           Data.STRef
import           Data.Tuple
import           Data.Word
import           Debug.Trace
import           GHC.Arr                          (Array, Ix (..), STArray)
import           GHC.Exts
import           System.Exit
import           System.IO

main :: IO ()
main = do
    n <- readLn :: IO Int
    xs <- L.unfoldr (B.readInt.B.dropWhile isSpace) <$> B.getContents
    print $ solve n xs

solve :: Int -> [Int] -> Int
solve n xs = go IM.empty xs
  where
    go :: IM.IntMap Int -> [Int] -> Int
    go !m (x:xs) = case IM.lookup (x - 1) m of
        Just len -> go (IM.insert x (len + 1) $ IM.delete (x - 1) m) xs
        Nothing  -> go (IM.insert x 1 m) xs
    go m [] = (n - ). maximum.map snd $ IM.toAscList m

Measured memory_bytes: 23932
N, a, b = map(int, input().split())

def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

count = 0

for i in range(1, N + 1):
    sum = findSumOfDigits(i)
    if sum <= b and a <= sum:
        count += i

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=17,M=1<<17,p=1e9+7;
int f[N][M],fac[M],inv[M],finv[M],a[N],n,m;
bool cmp(int a,int b){return a>b;}
int comb(int n,int m){return n<m?0:1ll*fac[n]*finv[m]%p*finv[n-m]%p;}
int lbt(int x){return x&-x;}
int sz(int x){return x?sz(x^lbt(x))+1:0;}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)scanf("%d",&a[i]);
    sort(a+1,a+m+1,cmp);
    fac[0]=finv[0]=inv[1]=fac[1]=finv[1]=1;
    for(int i=2;i<=(1<<n);i++)
        inv[i]=(p-p/i)*1ll*inv[p%i]%p,
        fac[i]=fac[i-1]*1ll*i%p,finv[i]=finv[i-1]*1ll*inv[i]%p;
    f[0][0]=1;
    for(int i=0;i<m;i++)
        for(int j=0;j<(1<<n);j++)
        {
            f[i+1][j]=(f[i+1][j]+f[i][j])%p;
            int x=(1<<n)-j-a[i+1],y;
            for(int k=0;k<n&&(1<<k)-1<=x;k++)
				if(!(j&(1<<k)))f[i+1][j|(1<<k)]=(f[i+1][j|(1<<k)]+1ll*f[i][j]*comb(x,(1<<k)-1)%p*fac[1<<k])%p;
        }
    int ans=0;
    for(int i=0;i<(1<<n);i++)ans=(ans+1ll*f[m][i]*fac[(1<<n)-i-1]%p*(sz(i)&1?p-1:1))%p;
    ans=1ll*ans*(1<<n)%p;
    printf("%d\n",ans);
}


Measured memory_bytes: 9216
#include<stdio.h>
 
long long int FiveFactorical(long long int r){
    return r * r * r * r * r;
}
 
int main(void){
    
    long long int X,i,j,ans;
    
    scanf("%lld",&X);
 
    for(i=-500;i<= 500;i++){
        for(j = -500;j <= 500;j++){
            if(FiveFactorical(i) - FiveFactorical(j) == X){
                printf("%lld %lld\n",i,j);
                return 0;
            }
        }
    }   
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int MAX=0, pre_MAX=0;
    int max_ids=0, pre_ids=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]>MAX){
            pre_MAX = MAX; pre_ids = max_ids;
            MAX = a[i];   max_ids = i;
        }else if(a[i]==MAX){
            pre_MAX = MAX;  pre_ids = i;
        }else if(a[i] > pre_MAX){
            pre_MAX = a[i]; pre_ids = i;
        }
    } 

    for(int i=0; i<n; i++){
        if(i == max_ids)
            cout << pre_MAX << endl;
        else 
            cout << MAX << endl;
    }
    return 0;
}

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

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 region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	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 (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string n; cin >> n;
	int s = 0;
	for (char c : n)
	{
		s += (c - '0');
	}
	if (s % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int ans(int n, int s, int x);
int main(){
  int n,s;
  while(cin >>n>>s,n||s){
    int a = 0;
    for(int i=0; i<10; i++) if(s>=i) a+=ans(n-1,s-i,i+1);
    cout <<a<<endl;
  }
  return 0;
}
int ans(int n, int s, int x){
  int a = 0;
  if(n == 0 && s == 0) return 1;
  else if(n == 0) return 0;
  for(int i=x; i<10&&i<=s; i++) a+=ans(n-1,s-i,i+1);
  return a;
}

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

int main()
{
  int n;
  cin >> n;
  int i, j;
  bool ok = false;
  for(i = 0; i < 100/4; i++)
  {
    for(j = 0; j < 100/7; j++)
    {
      if(4*i+7*j==n) ok = true;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <string>
#include <cmath>
using namespace std;
bool dp[8001][16001];
int d[8001];
string s;
int x,y;
int main(){
  cin >> s;
  cin >> x >> y;
  int t=1;
  bool f=true;
  for(int i=0;i<s.length();i++){
    if(s[i]=='T')t++;
    
    else d[t]++;
    
  }
  if(s[s.length()-1]=='F')t++;
 
  dp[0][8000]=dp[1][8000+d[1]]=true;
  for(int i=2;i<=t;i++){
    for(int j=0;j<=16000;j++){
      if(t%2==0){
	if(j+d[i]<=16000)dp[i][j]|=dp[i-2][j+d[i]];
	if(j-d[i]>=0)dp[i][j]|=dp[i-2][j-d[i]];
      }
      else{
	if(j+d[i]<=16000)dp[i][j]|=dp[i-2][j+d[i]];
	if(j-d[i]>=0)dp[i][j]|=dp[i-2][j-d[i]];
      }
    }
  }
  
  if(t%2==0){
    if(dp[t-1][8000+x] && dp[t][8000+y])printf("Yes\n");
    else printf("No\n");
  }
  else{
    if(dp[t][8000+x] && dp[t-1][8000+y])printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 125184
#include<bits/stdc++.h>
using namespace std;
int dp[3002][3002],i,j;
string s,t,ans;
int main(){
	cin>>s>>t;
	s+='$';t+='%';
	for(;i<s.size();i++){
		for(j=0;j<t.size();j++){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]);
			if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
		}
	}
	for(i=s.size()-1,j=t.size()-1;i+j;){
		if(i&&dp[i-1][j]==dp[i][j])i--;
		else if(j&&dp[i][j-1]==dp[i][j])j--;
		else i--,j--,ans+=s[i];
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            double q = sc.nextInt();
            if (q == -1) {
                break;
            }
            double x = q / 2;
            while (Math.abs(x * x * x - q) >= 0.00001 * q) {
                x = x - (x * x * x - q) / (3 * x * x);
            }
            System.out.printf("%.6f\n", x);
        }
    }
}


Measured memory_bytes: 26672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextInt();
        long m = sc.NextInt();
        long[] a = sc.LongArray();

        long answer = n - a.Sum();
        if(answer < 0)
        {
            answer = -1;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 29056
function main()
  
  N = parse(Float64,readline())
  
  reg = 0
  
  X = floor(N / 1.08)
  
  for i in [-1 0 1]
    
    if floor((X+i)*1.08) == N
      
      println(replace(string(X + i),".0",""))
      reg += 1
      break
    
    end
      
  end
    
  if reg == 0
   
    println(":(")
    
  end
  
end

main()

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

const char c[] = {'.', '#'};

bool ok(string &s1, string &s2) {
	printf("%s\n%s\n", s1.c_str(), s2.c_str()); fflush(stdout);
	string reply; cin >> reply;
	if (reply[0] == 'e') exit(0);
	return reply[0] == 'T';
}

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

	int n;
	cin >> n;
	string s[2];
	s[0] = s[1] = "";

	bool en = false;

	for (int i = 1; i <= n; ) {
		bool found = false;
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				if (found) break;

				auto guess = [&](int j, int k) {
					if (!en) {
						s[0] += c[j]; s[1] += c[k];
						if (ok(s[0], s[1])) return true;
						s[0].pop_back(); s[1].pop_back();
						return false;
					}	else {
						s[0] = c[j] + s[0]; s[1] = c[k] + s[1];
						if (ok(s[0], s[1])) return true;
						s[0].erase(s[0].begin()); s[1].erase(s[1].begin());
						return false;
					}
				};

				if (guess(j, k)) {
					found = true;
					break;
				}
			}
		}
		if (!found) en = true;
		else ++i;
	}
}

Measured memory_bytes: 724
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 , inf = 3e18 + 20 ;
int n , ans , root , d[N] , sz[N] , mn[N] ;
vector <pii> g[N] ;

void pre_dfs (int v , int par = -1) {
	sz[v] = 1 ;

	for (pii ed : g[v]) {
		int u = ed.F ;

		if (u == par) continue ;

		pre_dfs(u , v) ;

		sz[v] += sz[u] ;
	}
}

int find_root (int v , int par = -1) {
	for (pii ed : g[v]) {
		int u = ed.F ;

		if (u == par) continue ;

		if (sz[u] * 2 >= n) return find_root(u , v) ;
	}

	return v ;
}

void final_dfs (int v , int par = -1) {
	sz[v] = 1 ;
	mn[v] = d[v] ;

	for (pii ed : g[v]) {
		int u = ed.F , w = ed.S ;

		if (u == par) continue ;
	
		d[u] = d[v] + w ;
		
		final_dfs(u , v) ;

		sz[v] += sz[u] ;
		mn[v] = min(mn[v] , mn[u]) ;
	}

	ans += 2 * d[v] ;
	
	if (v == root) {
		int val = inf ;

		for (pii ed : g[v]) {
			int u = ed.F ;

			if (sz[u] * 2 == n) {
				val = mn[u]	;
				break ;
			}
			
			val = min(val , mn[u]) ;
		}

		ans -= val ;
	}
}

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

	cin >> n ;

	for (int i = 0 , u , v , w ; i < n - 1 ; i ++) {
		cin >> u >> v >> w ;
		u -- , v -- ;

		g[u].pb({v , w}) ;
		g[v].pb({u , w}) ;
	}

	pre_dfs(0) ;
	root = find_root(0) ;

	final_dfs(root) ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int B[MAXN];
int C[MAXN];
int L[MAXN];
int R[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n;

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

    sort(A+1,A+n+1);
    sort(B+1,B+n+1);
    sort(C+1,C+n+1);

    a = 1;

    for(int i=1;i<=n;i++){
        while(A[a]<B[i]&&a<=n)a++;
        L[i] = a-1;
    }

    b = n;

    for(int i=n;i>=1;i--){
        while(B[i]<C[b]&&b>=0)b--;
        R[i] = n-b;
    }

    ll res = 0;

    for(int i=1;i<=n;i++)
        res+=1LL*L[i]*R[i];

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    if(n==2){
        cout<<a[1]-a[0]<<endl;
        cout<<a[1]<<' '<<a[0]<<endl;
        return 0;
    }
    if(a[n-1]<=0){
        ll m=0;
        rep(i,n-1){
            m+=abs(a[i]);
        }
        m-=abs(a[n-1]);
        cout<<m<<endl;
        cout<<a[n-1]<<' '<<a[0]<<endl;
        ll s=a[n-1]-a[0];
        REP(i,1,n-1){
            cout<<s<<' '<<a[i]<<endl;
            s-=a[i];
        }
    }else if(a[0]>=0){
        ll m=0;
        REP(i,1,n){
            m+=a[i];
        }
        m-=a[0];
        cout<<m<<endl;
        ll s=a[0]-a[n-1];
        cout<<a[0]<<' '<<a[n-1]<<endl;
        ll p=a[n-2];
        REP(i,1,n-2){
            if(a[i]<=0){
                cout<<p<<' '<<a[i]<<endl;
                p-=a[i];
            }else{
                cout<<s<<' '<<a[i]<<endl;
                s-=a[i];
            }
        }
        cout<<p<<' '<<s<<endl;
    }else{
        ll m=0;
        rep(i,n){
            m+=abs(a[i]);
        }
        cout<<m<<endl;
        ll s=a[0];
        ll p=a[n-1];
        REP(i,1,n-1){
            if(a[i]<=0){
                cout<<p<<' '<<a[i]<<endl;
                p-=a[i];
            }else{
                cout<<s<<' '<<a[i]<<endl;
                s-=a[i];
            }
        }
        cout<<p<<' '<<s<<endl;
    }
}

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

int main(void) {
    long long x;
    long long n = 100;
    cin >> x;
    int i = 0;
    while (true) {
        if (n >= x) {
            cout << i;
            return 0;
        }
        n *= 1.01;
        i++;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

ll f[10], n, m, k, u, v;
map<II, ll> ma;

bool check(ll u, ll v) {
    if (!(u >= 1 && u <= n && v >= 1 && v <= m)) return false;
    if (!(u+2 >= 1 && u+2 <= n && v+2 >= 1 && v+2 <= m)) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> m >> k;
    f[0] = (n-2)*(m-2);
    FOR(i,1,k) {
        cin >> u >> v;
        if (check(u-2,v-2)) {
            ll m = ma[II(u-2,v-2)];
            f[__builtin_popcount(m)]--;
            ma[II(u-2,v-2)] = m+1;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u-2,v-1)) {
            ll m = ma[II(u-2,v-1)];
            f[__builtin_popcount(m)]--;
            ma[II(u-2,v-1)] = m+2;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u-2,v)) {
            ll m = ma[II(u-2,v)];
            f[__builtin_popcount(m)]--;
            ma[II(u-2,v)] = m+4;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u-1,v-2)) {
            ll m = ma[II(u-1,v-2)];
            f[__builtin_popcount(m)]--;
            ma[II(u-1,v-2)] = m+8;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u-1,v-1)) {
            ll m = ma[II(u-1,v-1)];
            f[__builtin_popcount(m)]--;
            ma[II(u-1,v-1)] = m+16;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u-1,v)) {
            ll m = ma[II(u-1,v)];
            f[__builtin_popcount(m)]--;
            ma[II(u-1,v)] = m+32;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u,v-2)) {
            ll m = ma[II(u,v-2)];
            f[__builtin_popcount(m)]--;
            ma[II(u,v-2)] = m+64;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u,v-1)) {
            ll m = ma[II(u,v-1)];
            f[__builtin_popcount(m)]--;
            ma[II(u,v-1)] = m+128;
            f[__builtin_popcount(m)+1]++;
        }
        if (check(u,v)) {
            ll m = ma[II(u,v)];
            f[__builtin_popcount(m)]--;
            ma[II(u,v)] = m+256;
            f[__builtin_popcount(m)+1]++;
        }
    }
    FOR(i,0,9) cout << f[i] << endl;
    return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, B = 26;
char s[N];
int nex[N][B], las[B], dp[N];
int main() {
	scanf("%s", s);
	int n = (int) strlen(s);
	for (int i = 0; i < B; ++ i) las[i] = n;
	dp[n] = 1;
	for (int i = n - 1; i >= 0; -- i) {
		las[s[i] - 'a'] = i;
		for (int j = 0; j < B; ++ j) nex[i][j] = las[j];
		int &res = dp[i] = 0;
		for (int j = 0; j < B; ++ j) if (las[j] == n) res = 1;
		if (!res) res = dp[*max_element(las, las + B) + 1] + 1;
	}
	/*puts(s);
	for (int i = 0; i < n; ++ i) printf("%d", dp[i]); puts("");*/
	string ans;
	int cur = 0;
	for (int i = 0; i < dp[0]; ++ i) {
		bool flag = 0;
		for (int c = 0; c < B; ++ c) {
			if (dp[nex[cur][c] + 1] + 1 == dp[0] - i) {
				ans += (char) (c + 'a');
				cur = nex[cur][c] + 1;
				flag = 1;
				break;
			}
		}
		assert(flag);
	}
	printf("%s\n", ans.c_str());
}



Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, W;
  cin >> N >> W;
  
  vector<vector<long long>> dp(N, vector<long long>(W + 1, 0));
  
  long long w, v;
  cin >> w >> v;
  
  for (int i = 0; i <= W; i++) {
    if (i >= w) {
      dp.at(0).at(i) = v;
    }
  }
  
  for (int i = 1; i < N; i++) {
    cin >> w >> v;
    for (int j = 0; j <= W; j++) {
      if (j >= w) {
        dp.at(i).at(j) = max(dp.at(i - 1).at(j), dp.at(i - 1).at(j - w) + v);
      }
      else {
        dp.at(i).at(j) = dp.at(i - 1).at(j);
      }
    }
  }
  
  long long ans = dp.at(N - 1).at(W);
    
  cout << ans << endl;
}

Measured memory_bytes: 82460
N,Q=map(int, input().split())


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    # k: index , x: value
    def update(self, k: int, x):
        k += self.N0 - 1
        ############################
        self.data[k] = x
        ###########################
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])

    def get(self, k):
        return self.query(k,k+1)
    
    # rightは開区間  l<=x<r
    def query(self, left: int, right: int):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        ##########################
        a, b = [], []
        while L < R:
            if L & 1:
                a.append(L - 1)
                L += 1
            if R & 1:
                R -= 1
                b.append(R - 1)
            L >>= 1
            R >>= 1
        for i in a + b[::-1]:
            res = self.segfunc(res, self.data[i])
        ##########################
        return res



"""
     .
 ####.
 ####.
 ####.
 ####.
......

"""
#到達したところまでをxに変える

segW=SegmentTree([N-1]*N, min, float("INF"))
segH=SegmentTree([N-1]*N, min, float("INF"))
ans=(N-2)**2
for i in range(Q):
    q,x=map(int, input().split())
    if q==1:
        res=segW.query(x-1,N)
        now=segH.get(res-1)
        segH.update(res-1, min(x-1, now))
        ans-=max(res-1,0)
    else:
        res=segH.query(x-1,N)
        now=segW.get(res-1)
        segW.update(res-1, min(x-1, now))
        ans-=max(res-1,0)
    #print(res, ans, res-1, x-1, q[0])


print(ans)

Measured memory_bytes: 92944
using System;
using static System.Console;

class Program {
    static void Main(string[] args) {
        string st = ReadLine();
        int WhereSpace = st.IndexOf(' ');
        string XS = st.Substring(0, WhereSpace);
        string YS = st.Substring(WhereSpace + 1, st.Length - WhereSpace - 1);
        int X = Convert.ToInt32(XS, 16);
        int Y = Convert.ToInt32(YS, 16);
        if (X>Y) {
            WriteLine(">");
        } else {
         if (X<Y) {
            WriteLine("<");
         } else {
            WriteLine("=");
         }
        }
    }
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i = 0; i<n; i++)
	cin>>a[i];
	int sum = 0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++){
			sum += a[i]*a[j];
		}
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define R register
#define ll long long
#define sum(a, b, mod) (((a) + (b)) % mod)
 
const int MaxN = 5e5 + 10;
const ll mod = 1ll << 62;
 
struct edge
{
    int next, to;
};
 
edge e[MaxN << 1];
int n, m, cnt;
int head[MaxN], f[MaxN], u[MaxN], v[MaxN];
std::bitset<510> q[25], t[1 << 20];
 
ll fast_pow(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod, b >>= 1;
    }
    return res;
}
 
void add_edge(int u, int v)
{
    ++cnt;
    e[cnt].to = v;
    e[cnt].next = head[u];
    head[u] = cnt;
}
 
void dfs(int u, int fa)
{
    f[u] = fa;
    for (int i = head[u]; i; i = e[i].next)
    {
        int v = e[i].to;
        if (v == fa) continue;
        dfs(v, u);
    }
}
 
void make(int x, int y, int p)
{
    for (int i = x; i != 1; i = f[i])
        q[p].set(i, 1);
    int cur = y;
    for (; cur != 1 && !q[p][cur]; cur = f[cur])
        q[p].set(cur, 1);
    for (; cur != 1; cur = f[cur])
        q[p].set(cur, 0);
}
 
inline int read()
{
    int x = 0;
    char ch = getchar();
    while (ch > '9' || ch < '0')
        ch = getchar();
    while (ch <= '9' && ch >= '0')
        x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    return x;
}
 
int main()
{
    ll ans = 0;
    n = read();
    for (int i = 1; i <= n - 1; i++)
    {
        int u = read(), v = read();
        add_edge(u, v), add_edge(v, u);
    }
    dfs(1, 0), m = read();
    for (int i = 1; i <= m; i++)
    {
        u[i] = read(), v[i] = read();
        make(u[i], v[i], i);
    }
    for(int i = 0; i < (1 << m); i++)
    {
        int cnt = 0, cur = 0;
        for (int j = 0; j < m; j++)
            if (i & (1 << j))
                cnt++, cur = j + 1;
        if (cnt)
            t[i] = t[i ^ (1 << (cur - 1))] | q[cur];
        if (cnt & 1)
            ans = sum(ans, mod - fast_pow(2, n - 1 - t[i].count()), mod);
        else
            ans = sum(ans, fast_pow(2, n - 1 - t[i].count()), mod);
    }
    printf("%lld", ans);
    return 0;
}

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

struct restaurant {
    string city;
    int score;
    int index;
};

bool compare(restaurant a, restaurant b) {
    if(a.city != b.city) {
        return a.city > b.city;
    }
    return a.score < b.score;
}

int main() {
    int n;
    cin >> n;
    
    vector<restaurant> in(n);
    
    for(int i = 0; i < n; ++i) {
        string _city;
        int _score;
        int _index = i+1; 
        cin >> _city >> _score;
        in[i] = {
            _city,
            _score,
            _index,
        };
    }
    
    sort(in.rbegin(), in.rend(), compare);
    
    for(int i = 0; i < n; ++i) {
        cout << in[i].index << endl;
    }   
}


Measured memory_bytes: 256
def main():
    N = int(input())

    i = 1
    ans = 10 ** 18

    while i ** 2 <= N:
        if N % i == 0:
            j = N/i
            ans = min(ans, i+j-2)
        i += 1

    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n=int(input())
st=[]
for i in range(n):
    s,t=input().split()
    st.append([s,int(t)])
#print(st)
x=input()
for i in range(n):
    if st[i][0]==x:
        ans=0
        for j in range(i+1,n):
            ans+=st[j][1]
print(ans)


Measured memory_bytes: 38340
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,sum=0;
	cin>>n;
	for(long long i=0;i<=n;i++){
		if(i%3==0||i%5==0){
			sum=sum;
		}
		else{
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
}	

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
LL s[100010];

void solve() {
  cin >> n;
  REP(i, n) cin >> s[i];
  LL res = 0;
  FOR(c, 1, n-1) {
    set<int> se;
    int l = 0, r = n-1;
    LL sum = 0;
    while(l+c < n-1) {
      sum += s[l];
      sum += s[r];
      chmax(res, sum);
      l += c;
      r -= c;
      if (se.count(l) > 0) break;
      se.insert(l);
      if (se.count(r) > 0) break;
      se.insert(r);
    }
    // if ((n-1)%c == 0) {
    //   while(l<r) {
    //     sum += s[l];
    //     sum += s[r];
    //     chmax(res, sum);
    //     l += c;
    //     r -= c;
    //   }
    // } else {
    //   while(l < n-1) {
    //     sum += s[l];
    //     sum += s[r];
    //     chmax(res, sum);
    //     l += c;
    //     r -= c;
    //   }
    // }
  }
  cout << res << endl;
}

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


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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a.at(i);

  vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
  rep(i, N) dp.at(i).at(i) = 0;

  for (int l = 1; l <= N; l++) {
    for (int i = 0; i + l <= N; i++) {
      int j = i + l;
      if ((N - l) % 2 == 0) {
        dp.at(i).at(j) = max(dp.at(i + 1).at(j) + a.at(i), dp.at(i).at(j - 1) + a.at(j - 1));
      } else {
        dp.at(i).at(j) = min(dp.at(i + 1).at(j) - a.at(i), dp.at(i).at(j - 1) - a.at(j - 1));
      }
    }
  }
  cout << dp.at(0).at(N) << endl;
  return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    int r; cin >> r;
    cout << 3*r*r << endl;

}

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

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, rui[500000] = {}, dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {

	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] >= a)sum++;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 4480
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S = ST()
    
    def z_algorithm(S):
        N = len(S)
        A = [N] + [0] * (N-1)
        left = 1
        length = 0
        while left < N:
            while left+length<N and S[length] == S[left+length]:
                length += 1
            A[left] = length
            if not length:
                left += 1
                continue
            k = 1
            while k+left<N and k+A[k]<length:
                A[left+k] = A[k]
                k += 1
            
            left += k
            length -= k

        return A

    ans = 0
    for i in range(N):
        A = z_algorithm(S[i:])
        for i,a in enumerate(A):
            ans = max(ans, min(a,i))
    print(ans)
    


    """
    # めぐる式二分探索
    def meguru_bisect(ok, ng):
        while abs(ok - ng) > 1:
            mid=(ok + ng) // 2
            if is_ok(mid):
                ok=mid
            else:
                ng=mid
        return ok

    def is_ok(l):
        for i,s in enumerate(S[:-l + 1]):
            st = S[i:i+l]
            if st in S[i+l:]:
                return True
        return False

    ans = meguru_bisect(0,len(S))
    print(ans)
    """


if __name__ == '__main__':
    main()

Measured memory_bytes: 50480
package main
import "fmt"

func main() {
	var n,l int
	ans := 0
	fmt.Scan(&n,&l)
	x:=(n+l-1) * l
	if x <= 0 {
		for i:=l;i<=(n+l-1);i+=1 {
			ans += i;
		}
	} else {
		if l>0 {
			for i:=l+1;i<=(n+l-1);i+=1 {
				ans += i;
			}
		} else {
			for i:=l;i<=(n+l-2);i+=1 {
				ans += i;
			}
		}
	}
	fmt.Println(ans)

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

typedef pair<int,int> P;

vector<int> A;
vector<int> B;
vector<ll> ans;

int N, M, Q;
vector<int> a, b, c, d;

ll score(vector<int> &A, int Q, vector<int> &a, vector<int> &b, vector<int> &c, vector<int> &d) {
	ll res = 0;
	for (int i = 0; i < Q; i++) {
		if (A[b[i] - 1] - A[a[i] - 1] == c[i]) res += d[i]; 
	}

	return res;
}

//Aにnextを追加し、next以上M以下の数をさらに追加していく
void dfs(vector<int> &A, int next, int N, int M, int Q, vector<int> &a, vector<int> &b, vector<int> &c, vector<int> &d) {
	A.push_back(next);

	if (A.size() == N) {
		//for (int i = 0; i < N; i++) cout << A[i] << " ";
		//cout << endl;
		ans.push_back(score(A, Q, a, b, c, d));
		return;
	}

	for (int i = next; i <= M; i++) {
		dfs(A, i, N, M, Q, a, b, c, d);
		A.pop_back();
	}
	

}

int main() {
	cin >> N >> M >> Q;
	a.resize(Q);
	b.resize(Q);
	c.resize(Q);
	d.resize(Q);

	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	
	for (int i = 1; i <= M; i++) {
		dfs(A, i, N, M, Q, a, b, c, d);
		A = B;
	}
	sort(ans.begin(), ans.end());

	cout << ans[ans.size()-1] << endl;
}


Measured memory_bytes: 4240
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
void run_case()
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n)
    {
        n = n / k;
        ans++;
    }
    cout << ans << "\n";
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    return 0;
}

Measured memory_bytes: 3648
a, b, c, d, e = readlines.map &:to_i
array = [a, b, c, d, e]

def calculate(v)
  i = v % 10
  (10 - i) % 10
end

sum = 0
array.sort! { |x, y| calculate(x) <=> calculate(y) }
array.each do |i|
  sum += i + calculate(i)
end
puts sum - calculate(array.last)


Measured memory_bytes: 1788