akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
  ll N,M; cin >> N >> M;
  vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i]; A[i] %= M;}
  
  for(ll i = 0; i < N; i++){
    if(i){ A[i] += A[i-1]; A[i] %= M;}}
  
  map<ll,ll> mp; mp[0]++;
  
  for(ll i = 0; i < N; i++){ mp[A[i]]++;}
  
  ll res = 0;
  
  for(auto ne : mp){
    res += ne.second*(ne.second-1)/2; }
  
  cout << res << endl; return 0;}
  
  

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int n = s.size();
  if(n <= k) cout << s << endl;
  else{
    rep(i, k) cout << s[i];
    rep(i, 3) cout << ".";
    cout << endl;
  }

  return 0;
}


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

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

  int ans = 0;  

  rep2(i, n) {
    if (i % 2 == 1) {
      int count = 0;
      rep2(j, i) if (i % j == 0) count++;
      if (count == 8) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long LL;

int main()
{
    LL n,a,b;
    scanf("%lld %lld %lld", &n, &a, &b);
    if(n==1){
        if(a!=b)printf("0");
        if(a==b)printf("1");
        return 0;
    }
    if(a>b){
        printf("0");
        return 0;
    }
    printf("%lld", (n-2)*(b-a)+1);
    return 0;
}


Measured memory_bytes: 128
/*input
4 4
.###
#...
.###
####
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-6;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e2+5;
const ll maxlg=__lg(maxn)+2; 
ll h, w, dp[maxn][maxn];
string s[maxn];
int main(){
	cin>>h>>w;
	REP(i,h) cin>>s[i];
	REP(i,h) REP(j,w) dp[i][j]=INF; 
	dp[0][0]=(s[0][0]=='#');
	REP(i,h){
		REP(j,w){
			if(i>0){
				if(s[i-1][j] == '.'){
					if(s[i][j] == '.'){
						MNTO(dp[i][j],dp[i-1][j]);
					}
					else{
						MNTO(dp[i][j],dp[i-1][j]+1);
					}
				}
				else{
					MNTO(dp[i][j],dp[i-1][j]);
				}
			}
			if(j > 0){
				if(s[i][j-1] == '.'){
					if(s[i][j] == '.'){
						MNTO(dp[i][j],dp[i][j-1]);
					}
					else{
						MNTO(dp[i][j],dp[i][j-1]+1);
					}
				}
				else{
					MNTO(dp[i][j],dp[i][j-1]);
				}
			}
		}
	}
	cout<<(dp[h-1][w-1]);
	return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    N = int(input())
    X = it()
    a = 0 
    for x in X:
        a = a ^ x
    
    ans = ''
    for x in X:
        ans += str(x ^ a) + ' '
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 31964
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll dp[3001][3001] ={0};
int main()
{
    fast;
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[n][m];
    ll index=dp[n][m];
    ll i=n,j=m;
    char lcs[index+1];
    lcs[index] = '\0';
    while(i>0&& j>0)
    {
        if(s[i-1]==t[j-1])
        {
            lcs[index-1]=s[i-1];
            index--;
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    cout<<lcs;
}


Measured memory_bytes: 70656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        s: chars
    }
    let mut ans: usize = 0;
    let mut bc: usize = 0;
    for i in 0..s.len() {
        if s[i] == 'B' {
            bc += 1;
        } else {
            ans += bc;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int total = 0, ans = 0;
		for(int i = 1; i <= X; i++) {
			ans++;
			total += i;
			if(total >= X)
				break;
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 23892
#include <stdio.h>
#include <string.h>
int main(){
  char s[200000+2]={0};
  char *ptr1;
  char *ptr2;

  scanf("%s", s);
  ptr1 = strchr(s, 'A');
  ptr2 = strrchr(s, 'Z');
  printf("%d\n", (int)(ptr2-ptr1)+1);

  return 0;
}

Measured memory_bytes: 1892
X = int(input())

if 400 <= X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)


Measured memory_bytes: 9176
#include <stdio.h>

int main(void)
{
    int X, Y;
    int A, B, C, D, P;
    
    scanf("%d%d%d%d%d", &A, &B, &C, &D, &P);
    
    X = A * P;
    
    Y = B;
    if (P > C){
        Y += (P - C) * D;
    }
    
    if (X < Y){
        printf("%d\n", X);
    }
    else {
        printf("%d\n", Y);
    }
    
    return (0);
}

Measured memory_bytes: 596
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

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

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

newtype MyGraph = MyGraph (A.Array Int [Int])

listToGraph :: Int -> [(Int, Int)] -> Bool -> MyGraph
listToGraph n paths inverse = MyGraph $ STA.runSTArray $ do
    a <- MA.newArray (1, n) []
    forM_ paths $ \(from, to) -> do
        f <- MA.readArray a from
        MA.writeArray a from $ to : f
        when inverse $ do 
            t <- MA.readArray a to
            MA.writeArray a to $ from : t
    pure a

getPaths :: Int -> MyGraph -> [Int]
getPaths i (MyGraph lst) = lst A.! i


solve :: Int -> UV.Vector Int -> [(Int, Int)] -> Int
solve n heights paths = let 
    grp = listToGraph n paths True
    isGood i = case getPaths i grp of
        [] -> True
        paths -> let
            mine = heights GV.! i
            in
            all ((mine>) . (heights GV.!) ) paths
    in 
    length $ filter isGood [1..n]

readIntS :: BC.ByteString -> Maybe (Int, BC.ByteString)
readIntS = fmap (BC.tail <$>) . BC.readInt

readIntsV :: Int -> IO (UV.Vector Int)
readIntsV n = UV.unfoldrN n readIntS <$> BC.getLine

readTuple2' :: IO (Int, Int)
readTuple2' = do
    v <- readIntsV 2
    pure (v GV.! 0, v GV.! 1)

main :: IO ()
main = do
    (n, m) <- readTuple2'
    heights <- GV.cons 0 <$> readIntsV n
    paths <- replicateM m readTuple2
    print $ solve n heights paths





Measured memory_bytes: 46604
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

int T[MAXN];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	int n, c, k, ans = 0, p = 0, cur = 0;
	cin >> n >> c >> k;
	REP(i, n)
		cin >> T[i];
	sort(T, T + n);
	REP(i, n)
	{		
		if (cur == c || T[i] > T[p] + k)
		{
			++ans;
			cur = 0;
			p = i;
		}
		++cur;
	}
	if (cur) ++ans;
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

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

namespace ABC125A
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            int ans = 0;
            for(int i = 1; i <= s[2]; i++)
            {
                if (i * s[0] <= s[2])
                {
                    ans += s[1];
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32

int main() {
	int n;
	cin >> n;
	vector<ll>v(n);
	cin >> v[0];
	for(int i=1;i<n;i++) {
		cin >> v[i];
		v[i] += v[i - 1];
	}
	ll ans=1e9;
	rep(i, n) {
		ans = min(ans,(ll)labs(v[i]-(v[n-1]-v[i])));
	}
	cout << ans;
}
	



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b,x;cin>>a>>b>>x;
    if(a<=x && x<=a+b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X;
    cin >> N >> X;
    ll L[110];
    rep(i,0,N) cin >> L[i];
    ll ans = 1;
    ll v = 0;
    rep(i,0,N){
        v += L[i];
        if(v <= X) ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<long double> a(n);
    long double ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] = 1.0 / a[i];
        ans += a[i];
    }

    cout << fixed << setprecision(10) << 1.0 / ans << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace (traceShow, traceShowM)
import qualified Data.ByteString.Char8 as B

import Control.Monad.ST
import Data.Array.ST

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    n <- readLn
    as <- fmap readi . B.words <$> B.getLine
    q <- readLn
    ms <- fmap readi . B.words <$> B.getLine
    let bs = solve n as q ms
    forM_ bs $ \b -> do
        if b then putStrLn "yes" else putStrLn "no"

solve :: Int -> [Int] -> Int -> [Int] -> [Bool]
solve n as q ms = runST $ do
    dp <- newArray ((0, 0), (n, maxm)) False :: ST s (STUArray s (Int, Int) Bool)
    writeArray dp (0, 0) True
    bs <- newListArray (1, n) as :: ST s (STUArray s Int Int)
    forM_ [1 .. n] $ \i -> do
        forM_ [0 .. maxm] $ \j -> do
            bi <- readArray bs i
            v1 <- readArray dp (i - 1, j)
            if j < bi
                then writeArray dp (i, j) v1
                else do
                    v2 <- readArray dp (i - 1, j - bi)
                    writeArray dp (i, j) (v1 || v2)
    sequence [readArray dp (n, m) | m <- ms]
  where
    maxm = maximum ms



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

using namespace std;

typedef long long ll;

void fastIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main()
{
    fastIO();
    char s[20];
    cin>>s;
    if(strlen(s)%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<strlen(s);i++){
        if(i%2){
            if(s[i]!='i'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
        if(s[i]!='h'){
            cout<<"No"<<endl;
            return 0;
        }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int r,g,b;
  cin>>r>>g>>b;
  int ans=100*r+10*g+b;
  if(ans%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  b = b/k*k;
  if(a>b)cout << "NG" << endl;
  else cout << "OK" << endl;
  return 0;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll tmp = 0;
	ll ans = INF;
	for (int i = 0; i < n; i++) {
		tmp += a[i];
		ans = min(ans, abs(sum - 2 * tmp));
	}
	dump(ans);
	return 0;
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n;cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=1;i<n;i++){
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(b[i-1],a[i-1]);
    }
    cout<<max(a[n-1],max(b[n-1],c[n-1]));
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 int main()
{
    fast();
    int n, m, a[10005],sum=0;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (sum <= n)
        cout << n - sum;
    else
        cout << "-1";
    return 0;
    }

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

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

    vector<pll> around;
    for (ll i = -1; i <= 1; i++) for (ll j = -1; j <= 1; j++) around.push_back({i, j});

    ll h, w, n;
    cin >> h >> w >> n;
    map<pll, bool> mp;
    set<pll> check;

    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        mp[MP(a, b)] = true;
        for (auto c : around) check.insert(MP(a + c.first, b + c.second));
    }

    ll ans[10] = {};
    ll black_any = 0;
    for (auto p : check) {
        if (p.first - 1 < 0 || p.first + 1 >= h || p.second - 1 < 0 || p.second + 1 >= w) continue;
        black_any++;
        ll cnt = 0;
        for (auto c : around) if (mp [{p.first + c.first, p.second + c.second}
                ]) cnt++;
        ans[cnt]++;
    }
    ans[0] = (h - 2)*(w - 2) - black_any;
    rep(i, 10) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 212736
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

side = ((2-1, 3-1, 5-1, 4-1), (6-1, 3-1, 1-1, 4-1), (1-1, 2-1, 6-1, 5-1),
        (1-1, 5-1, 6-1, 2-1), (1-1, 3-1, 6-1, 4-1), (5-1, 3-1, 2-1, 4-1))

def check_rotate(face1, face2, f2_index):
    f1_bot = face1[5]
    if face2[5-f2_index] != f1_bot:
        return False
    f2_side_index = side[f2_index] * 2
    f2_side = [face2[f2_side_index[i]] for i in range(len(f2_side_index))]
    f1_side = [face1[i] for i in (2-1, 3-1, 5-1, 4-1)]
    # print(f1_side, f2_side)

    for i in range(4):
        if f1_side == f2_side[i:i+4]:
            return True

    return False

def check_ident(face1, face2):
    f1_top = face1[0]
    for index in range(len(face2)):
        if face2[index] == f1_top:
            if check_rotate(face1, face2, index):
                return True

    return False


face1 = sys.stdin.readline().split()
face2 = sys.stdin.readline().split()

if check_ident(face1, face2):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5584
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	ll cnt[n+1] = {};
	vector<int> vec(n);
	for(int i = 0; i < n; i++){
		int sayi; cin>>sayi;
		vec[i] = sayi;
		cnt[sayi]++;
	}
	ll top = 0;
	for(int i = 1; i <= n; i++){
		top += cnt[i] * (cnt[i]-1) / 2;
	}
	for(int i = 0; i < n; i++){
		ll cikar = 0;
		if(cnt[vec[i]]) cikar = cnt[vec[i]] - 1;
		cout<<top - cikar << "\n";
	}
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
ll dp[100001];
ll maxval(ll ar[],ll n,ll i){
	if(i==0){
		return 0;
	}
	if(i==1){
		return abs(ar[0]-ar[1]);
	}
	if(dp[i]!=-1){
		return dp[i];
	}

	ll a,b;
	a=maxval(ar,n,i-1)+abs(ar[i]-ar[i-1]);
	b=maxval(ar,n,i-2)+abs(ar[i]-ar[i-2]);
	return dp[i]=min(a,b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	memset(dp,-1,sizeof(dp));
	ll i,j,k,l,n;
	cin>>n;

	ll ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	k=maxval(ar,n,n-1);
	cout<<k;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, h;
    cin >> n >> h;
    vec a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    int mx = 0;
    rep(i, n) {
        mx = max(mx, a[i]);
    }

    int res = 0;

    sort(all(b), greater<int>());

    rep(i, n) {
        if (b[i] > mx) {
            h -= b[i];
            res++;
        }
        if (h <= 0) break;
    }

    if (h > 0) {
        res += (h + mx - 1) / mx;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main(){
  int N,K;
  cin >> N >> K;
  int ans = 0;
  while(N){
    N/=K;
    ans++;
  }

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




Measured memory_bytes: 256
n=int(input().rstrip())
ans=[]
flag=0
dame=0
for i in range(n):
  data=input().rstrip()
  if flag==1:
    if data in ans or ans[i-1][-1]!=data[0]:
      dame=1
      break
  ans.append(data)
  flag=1
if dame==1:
  print("No")
else:
  print("Yes")

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

int main()
{
    int arr[5];
    for(int i=0;i<5;i++){
    	cin >> arr[i];
	}
    for (int i=1;i<6;i++){
    	if(arr[i-1]==0){
    		cout << i;
		}
	}
	return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int N = 50;
const long double EPS = 1e-9;

using namespace std;


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

	int n;
	long long ans;
	cin >> n;
	ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 && i % 5)
			ans += i;
	}
	cout << ans << '\n';
}

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

int main()
{
	int r, D;
	std::vector<long long> x(11);
	scanf("%d%d%lld", &r, &D, &x[0]);
	for (int i{1}; i <= 10; i++)
	{
		x[i] = x[i - 1] * r - D;
		printf("%d\n", x[i]);
	}

	return 0;
}

Measured memory_bytes: 256
INF = 10 ** 20

def solve(n):
  ans = INF
  for i in range(n // 500 + 1):
    for j in range((n - 500 * i) // 300 + 1):
      if not (n - 500 * i - 300 * j) % 200:
        a = (n - 500 * i - 300 * j) // 200
        va = a // 5 * 1900 * 0.8  + a % 5 * 380
        vb = j // 4 * 2200 * 0.85 + j % 4 * 550
        vc = i // 3 * 2550 * 0.88 + i % 3 * 850
        ans = min(ans, va + vb + vc)
  print(int(ans))

while True:
  n = int(input())
  if not n:
    break
  solve(n)


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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

ll a[110];
ll dp[100050];

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, cap;

    while(sl(n) != EOF)
    {
        sl(k);
        for (i = 1; i <= n; i++)
            sl(a[i]);

        for (i = 1; i <= k; i++)
        {
            for (j = 1; j <= n; j++)
            {
                if (i-a[j] >= 0)
                {
                    if (dp[i-a[j]] == 0)
                        dp[i] = 1;
                }
            }
          //  cout << i << " " << dp[i] << endl;
        }

        if (dp[k])
            printf("First\n");
        else printf("Second\n");
    }
    return 0;
}


Measured memory_bytes: 1024
import math


A, B, H, M = map(int, input().split())

Tp = (H * 60 + M) / (12 * 60) * (2 * math.pi)
Tq = M / 60 * (2 * math.pi)
Px = A * math.sin(Tp)
Py = A * math.cos(Tp)
Qx = B * math.sin(Tq)
Qy = B * math.cos(Tq)

print(math.sqrt((Px - Qx) ** 2 + (Py - Qy) ** 2))


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

ll F[700010];
ll Finv[700010];

void init_combination() {
    const int MAX = 700000;
    F[0] = 1;
    for (int i = 1; i <= MAX; i++) {
        F[i] = F[i - 1] * i % mod;
    }
    Finv[MAX] = beki(F[MAX], mod - 2, mod);
    for (ll i = MAX - 1; i >= 0; i--) {
        Finv[i] = Finv[i + 1] * (i + 1) % mod;
    }
    return;
}

int main(){
    init_combination();
    ll n, a, b;
    cin >> n >> a >> b;
    ll na = 1, nb = 1;
    for (int i = 0; i < a; i++) {
        na = na * (n - i) % mod;
    }
    for (int i = 0; i < b; i++) {
        nb = nb * (n - i) % mod;
    }
    na = na * Finv[a];
    nb = nb * Finv[b];
    ll nn = beki(2, n, mod);

    cout << ((nn - na - nb) % mod + mod) % mod - 1 << endl;
    return 0;
}

Measured memory_bytes: 11136
a_num = int(input())
b_num = int(input())
c_num = int(input())
x = int(input())

a = b = c = 0
count = 0
max_val = 500*a_num + 100*b_num + 50*c_num

for a in range(a_num+1):
    
    for b in range(b_num+1):
        
        for c in range(c_num+1):    
            val = 500*a + 100*b + 50*c
            if val == x:
                count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N,K;
cin>>N>>K;
vector<int>H(N);
rep(i,N)cin>>H[i];
sort(H.begin(),H.end(),greater<int>());
ll total=0;
reps(i,N,K){
    total+=H[i];
}
cout<<total<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1024
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        r: i32
    }
    let ans = r * r;
    println!("{}", ans);
}


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

int main(){
    while(true){
        string Red,Green,Out;
        // cin>>Red;
        getline(cin,Red);
        if(Red[0]=='-') return 0;
        // cin>>Green>>Out;
        getline(cin,Green);
        getline(cin,Out);
        if(!Out.size()){
            cout<<Green<<endl;
            continue;
        }
        // cout<<Red<<' '<<Green<<' '<<Out<<endl;
        queue<char> R,G,O;
        for(auto c:Red) R.push(c);
        for(auto c:Green) G.push(c);
        for(auto c:Out) O.push(c);

        char centre = G.front(); G.pop();
        int cnt = Green.size();
        while(true){
            // cout<<'?'<<centre<<' '<<O.front()<<endl;
            if(!O.empty()&&centre==O.front()){
                centre=R.front(); R.pop();
                O.pop();
            }else{
                cout<<centre;
                cnt--;
                if(!cnt){
                    cout<<endl;
                    break;   
                }
                centre=G.front(); G.pop();                    
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector<vector<int>> ans(h, vector<int>(w));
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int now = 0;
    for(int i = 0; i < h; i++) {
        if(i&1^1) {
            for(int j = 0; j < w; j++) {
                ans[i][j] = now+1;
                a[now]--;
                if(a[now]==0) now++; 
            }
        }else{
            for(int j = w-1; j >= 0; j--) {
                ans[i][j] = now+1;
                a[now]--;
                if(a[now]==0) now++;
            }
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
}

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

void bubbleSort(int A[]) {
    bool flag = 1;
    while(flag) {
        flag = 0;
        for(int i = 2; i > 0; i--) {
            if(A[i] < A[i - 1]) {
                swap(A[i], A[i - 1]);
                flag = 1;
            }
        }
    }
}

int main() {
    int A[10];
    for(int i = 0; i < 3; i++) cin >> A[i];

    bubbleSort(A);

    for(int i = 0; i < 3; i++) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define vout rep(i, v.size()) cout << v[i] << " "; cout << endl;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];
    vector<int> v;
    v.push_back(a[0]);
    rrep(i, 1, n) {
        if (v[v.size() - 1] < a[i]) {
            v.push_back(a[i]);
        } else if (v[v.size() - 1] == a[i]) {
            continue;
        } else {
            rep(j, v.size()) {
                if (v[j] >= a[i]) {
                    v[j] = a[i];
                    break;
                }
            }
        }
    }
    //vout
    cout << v.size() << endl;
}





Measured memory_bytes: 3972
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = b[a[0] - 1]
for i in range(n - 1):
    ans += b[a[i + 1] - 1]
    if a[i + 1] == a[i] + 1:
        ans += c[a[i] - 1]

print(ans)

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

int n, l;
long long m = 0;
int a[100000];

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

	vector<pair<int, int>> p(n);
	
	for (int i = 0; i < n; i++)
		cin >> p[i].first >> p[i].second;

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

	for (int i = 0; i < n; i++) {
		if (p[i].second == 0)
			m += p[i].first - i - 1;
		else
			m -= p[i].first - i - 1;
	}

	long long m1 = m;

	for (int i = 0; i < n; i++) {
		if (p[n - i - 1].second == 1)
			m1 += l - n;
		else
			m1 -= l - n;

		if (m1 > m)
			m = m1;
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 3500
import numpy as np
from bisect import bisect_left
n, a, b = map(int, input().split())
v = sorted(map(int, input().split()))[::-1]
print(sum(v[:a])/a)
prev = v[0]
cnt = 0
rle = []
for i in v:
    if i != prev:
        rle.append(cnt)
        prev = i
        cnt = 1
    else:
        cnt += 1
rle.append(cnt)
cum = [0]
for i in rle:
    cum.append(cum[-1] + i)

left = bisect_left(cum, a)
m = rle[left-1]
a = a - cum[left-1]
if left == 1:
    b = min(cum[left], b) - cum[left-1]
else:
    b = a

from math import factorial
def comb(n, r):
    return factorial(n) // factorial(n-r) // factorial(r)

ans = 0
for i in range(a, b+1):
    ans += comb(m,i)
print(ans)


Measured memory_bytes: 21892
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#define LL long long
using namespace std;
LL dp[2];
int main(){
	int n,m,i,k,j,x;
	scanf("%d%d",&n,&m);
	dp[0]=1;
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x%2==0)dp[0]*=2,dp[1]*=2;
		else {
			LL d0=dp[0],d1=dp[1];
			dp[0]+=d1,dp[1]+=d0;
		}
//		dp[x%2]++;
//		printf("%lld %lld\n",dp[0],dp[1]);
	}
	printf("%lld",dp[m%2]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,C; cin >> N >> C;
  
  vector<vector<int>> D(C,vector<int> (C));
  
  
  for(int i = 0; i < C; i++){ for(int j = 0; j < C; j++){ cin >> D[i][j];}}
   
  
  vector<int> mod0; vector<int> mod1; vector<int> mod2;

   for(int i = 1; i <= N; i++){ for(int j = 1; j <= N; j++){
    int c; cin >> c;
    if((i+j)%3 == 0){ mod0.push_back(c);} 
    else if((i+j)%3 == 1){ mod1.push_back(c);}
    else if((i+j)%3 == 2){ mod2.push_back(c);}
  }
 }                            
                             
  
 vector<pair<int,int>> diff0,diff1,diff2;  
                              
  for(int k0 = 1; k0 <= C; k0++){int d0 = 0;
    for(int s = 0; s < (int) mod0.size(); s++){
      d0 += D[mod0[s]-1][k0-1]; } //コストの総和
     diff0.push_back(make_pair(d0,k0));}
  
  for(int k1 = 1; k1 <= C; k1++){int d1 = 0;
    for(int s = 0; s < (int) mod1.size(); s++){                             
      d1 += D[mod1[s]-1][k1-1]; }
     diff1.push_back(make_pair(d1,k1));}
                              
  for(int k2 = 1; k2 <= C; k2++){int d2 = 0;
    for(int s = 0; s < (int) mod2.size(); s++){
      d2 += D[mod2[s]-1][k2-1]; }
     diff2.push_back(make_pair(d2,k2));}
  
  int ans = 1e9;                        
   
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      for(int k = 0; k < C; k++){
        int a = diff0[i].second; int b = diff1[j].second; int c = diff2[k].second;
        if( a != b && b != c && c != a){
          int sum = diff0[i].first + diff1[j].first + diff2[k].first;
           ans = min(ans, sum);}
      }
    }
  }
                              
    cout << ans << endl; return 0;}                          
                              
        
                              
    
                              
        

Measured memory_bytes: 1524
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll curT = 0, curX = 0, curY = 0;
    rep(i,n){
        ll t, x, y;
        cin >> t >> x >> y;
        ll dist = abs(curX - x) + abs(curY - y);
        if(t - curT >= dist && (t - curT - dist)%2 == 0){
            curT = t;
            curX = x;
            curY = y;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int p[N];
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    a[i] = p[i];
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] != p[i]) cnt++;
  }
  if (cnt <= 2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "rail.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e16;
const long long MOD = 1e9+7;
const int MAX=100015;
vector<int> adj[MAX];
bool block[MAX];
bool DFS(int ver,int par=-1){
    bool ret=(adj[ver].size()>2);
    for(auto i : adj[ver]){
        if(i==par)continue;
        ret=max(ret,DFS(i,ver));
    }
    if(ret==0)block[ver]=1;
    R ret;
}
int dfs(int ver,int par){
    bool b=0;
    int res=0;
    for(auto i : adj[ver]){
        if(i==par)continue;
        if(block[i]){
            if(b==0)b=1;
            else res++;
        }
        else{
            res+=dfs(i,ver);
        }

    }
    return res;
}
int main(){
    int n;
    cin>>n;
    int x,y;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int s=-1;
    for(int i=0;i<n;i++){
        if(adj[i].size()>2)s=i;
    }
    if(s==-1){cout<<1; R 0;}
    DFS(s);
    for(int i=0;i<n;i++)if(block[i])s=i;
    for(int i=0;i<n;i++){
        if(block[i])continue;
        bool b=0;
        for(auto j : adj[i]){
            if(block[j]){
                if(b==0)b=1;
                else{
                    s=j;
                }
            }
        }
    }
    cout<<dfs(s,-1)+1;
}


Measured memory_bytes: 9344
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int r=read();
    cout<<2*PI*r<<endl;
	return 0;
}


Measured memory_bytes: 3788