akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using p = pair<int,int>;

int main(){
int s,w;
cin >> s >> w;
cout << ((s>w)?"safe":"unsafe" )<< endl;
    return 0;
}

Measured memory_bytes: 3580
package main

import "fmt"

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&s, &k)

	l := len(s)
	if k < l {
		l = k
	}
	for _, r := range s[:l] {
		if r != '1' {
			fmt.Println(string(r))
			return
		}
	}
	fmt.Println(1)
}


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

typedef long long ll;
#define re(n) cin >> n
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define ff(i,x,n) for(ll i=(int)x;i<(int)n;i++)
#define f(i,n) ff(i,0,n)
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define te(t) ll t; re(t); while(t--)
#define MOD 1000000007

int main(){
	ll n, d;
	re(n >> d);
	d *= d;
	ll ans = 0;
	f(i, n){
		ll x, y;
		re(x >> y);
		ll dis = (x*x)+(y*y);
		if(dis<=d){
			ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, Q;
llint v[1<<18], w[1<<18];
const llint B = 1<<9;
vector<P> vec[B], mvec[B], tmp;

void calc(llint p, llint V, llint W, llint s)
{
	if(p == 0){
		vec[s].push_back(P(W, V));
		return;
	}
	calc(p/2, V, W, s);
	calc(p/2, V+v[p], W+w[p], s);
}

llint calc2(llint p, llint V, llint W)
{
	if(p < B){
		tmp.push_back(P(W, V));
		return p;
	}
	calc2(p/2, V, W);
	return calc2(p/2, V+v[p], W+w[p]);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= min(n, B-1); i++){
		calc(i, 0, 0, i);
		sort(vec[i].begin(), vec[i].end());
		
		llint mx = 0;
		for(int j = 0; j < vec[i].size(); j++){
			mx = max(mx, vec[i][j].second);
			mvec[i].push_back(P(vec[i][j].first, mx));
		}
	}
	
	cin >> Q;
	llint q, l;
	for(int i = 1; i <= Q; i++){
		cin >> q >> l;
		if(q < B){
			llint ans = 0;
			for(int j = 0; j < vec[q].size(); j++){
				if(vec[q][j].first <= l) ans = max(ans, vec[q][j].second);
			}
			cout << ans << endl;
			continue;
		}
		tmp.clear();
		llint res = calc2(q, 0, 0);
		
		llint ans = 0;
		for(int j = 0; j < tmp.size(); j++){
			llint v = tmp[j].second, w = tmp[j].first;
			llint p = upper_bound(mvec[res].begin(), mvec[res].end(), P(l-w, inf)) - mvec[res].begin();
			if(p == 0) continue;
			p--;
			ans = max(ans, v + mvec[res][p].second);
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

typedef long long ll;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
const int INF = 1e18, MAX = 2500;
vector<pair<int,pii>> graph[52];


signed main(){

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


	int n,m,s;
	cin>>n>>m>>s;
	vector<int> cost(n+1) , d(n+1);

	s = min(s,MAX);

	for(int i=0;i<m;i++){
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		graph[u].pb({v,{a,b}});
		graph[v].pb({u,{a,b}});
	}
	for(int i=1;i<=n;i++){
		cin>>cost[i]>>d[i];
		cost[i] = min(cost[i],MAX);
	}

	vector<vector<int>> dist(n+1,vector<int> (MAX+1,INF)), visited(n+1,vector<int> (MAX+1,0));
	priority_queue<pair<int,pii>, vector<pair<int,pii>>, greater<pair<int,pii>> > pq;

	pq.push({0,{1,s}});
	dist[1][s] = 0;
	while(!pq.empty()){
		auto cur = pq.top();
		pq.pop();
		int cur_d = cur.ff, u = cur.ss.ff, cur_c = cur.ss.ss;
		if (visited[u][cur_c])
			continue;
		visited[u][cur_c] = 1;

		if (dist[u][min(cur_c+cost[u],MAX)] > cur_d + d[u]){
			dist[u][min(cur_c+cost[u],MAX)] = cur_d + d[u];
			pq.push({cur_d + d[u],{u,min(cur_c+cost[u],MAX)}});
		}


		for(auto v:graph[u]){
			if (v.ss.ff <= cur_c and dist[v.ff][cur_c - v.ss.ff] > cur_d + v.ss.ss){
				dist[v.ff][cur_c - v.ss.ff] = cur_d + v.ss.ss;
				pq.push({cur_d + v.ss.ss,{v.ff,cur_c - v.ss.ff}});
			}
		}
		
	}



	for(int j=2;j<=n;j++){
		int ans = INF;
		for(int i=0;i<MAX+1;i++)
			ans = min(ans,dist[j][i]);
		cout<<ans<<"\n";
	}

	return 0;
}

Measured memory_bytes: 8252
fun main(args : Array<String>) {
    val (sx, sy, tx, ty) = readLine()!!.split(" ").map { it.toInt() }

    val diffX = Math.abs(tx - sx)
    val diffY = Math.abs(ty - sy)

    var ans = ""

    // first (clockwise)
    repeat(diffY) {
        ans += 'U'
    }
    repeat(diffX) {
        ans += 'R'
    }
    repeat(diffY) {
        ans += 'D'
    }
    repeat(diffX) {
        ans += 'L'
    }

    // second (clockwise)
    ans += 'L'
    repeat(diffY+1) {
        ans += 'U'
    }
    repeat(diffX+1) {
        ans += 'R'
    }
    ans += 'D'
    ans += 'R'
    repeat(diffY+1) {
        ans += 'D'
    }
    repeat(diffX+1) {
        ans += 'L'
    }
    ans += 'U'

    println(ans)
}

Measured memory_bytes: 53356
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	
	bool ok = false;
	rep(i,n+1){
		rep(j,m+1){
			int p = 0;
			p += i*m;
			p += j*n;
			p -= i*j*2;
			
			//printf("%d %d %d \n",i,j,p);
			if(p==k)ok=true;
		}
	}
	
	if(ok)puts("Yes");
	else puts("No");
}

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

int main()
{
  int n;
  cin >> n;
  vector<tuple<string,int,int>> r(n);
  for(int i=0;i<n;++i){
    get<2>(r.at(i))=i+1;
    cin >> get<0>(r.at(i)) >> get<1>(r.at(i));
    get<1>(r.at(i))*=(-1);
  }
  sort(r.begin(),r.end());
  for(int i=0;i<n;++i){
    cout << get<2>(r.at(i)) << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

struct SuffixArray {
  int N, k;
  string S;
  vector<int> sa, rank, tmp;
  vector<int> lcp, rank_lcp;
  SuffixArray(string S) : S(S) {
    N = S.size();
    sa.resize(N+1), rank.resize(N+1), tmp.resize(N+1);
    construct();
  }

  void construct() {
    for (int i = 0; i <= N; i++) {
      sa[i] = i;
      rank[i] = i < N ? S[i] : -1;
    }

    function<bool(int, int)> compare = [&](int i, int j) {
      if (rank[i] != rank[j]) {
        return rank[i] < rank[j];
      } else {
        int ri = i + k <= N ? rank[i + k] : -1;
        int rj = j + k <= N ? rank[j + k] : -1;
        return ri < rj;
      }
    };
    for (k = 1; k <= N; k *= 2) {
      sort(sa.begin(), sa.end(), compare);

      tmp[sa[0]] = 0;
      for (int i = 1; i <= N; i++) {
        tmp[sa[i]] = tmp[sa[i-1]] + (compare(sa[i-1], sa[i]) ? 1 : 0);
      }
      for (int i = 0; i <= N; i++) rank[i] = tmp[i];
    }
  }

  bool contain(string T) {
    int left = 0, right = N;
    while (left + 1 < right) {
      int mid = (left + right) / 2;
      (S.compare(sa[mid], T.length(), T) < 0 ? left : right) = mid;
    }
    return S.compare(sa[right], T.length(), T) == 0;
  }

  void construct_lcp() {
    lcp.resize(N), rank_lcp.resize(N+1);
    for (int i = 0; i <= N; i++) rank_lcp[sa[i]] = i;

    int h = 0;
    lcp[0] = 0;
    for (int i = 0; i < N; i++) {
      int j = sa[rank[i] - 1];

      if (h > 0) h--;
      for (; j + h < N and i + h < N; h++) {
        if (S[j + h] != S[i + h]) break;
      }

      lcp[rank[i] - 1] = h;
    }
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string T; cin >> T;
  SuffixArray sa(T);
  int Q; cin >> Q;
  REP(_, Q) {
    string P; cin >> P;
    cout << sa.contain(P) << endl;
  }

  return 0;
}

Measured memory_bytes: 16752
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010], m[1000005];
int main()
{
    ll t,n,i,j,k,l,r,mn=0, mx=1;
    sl(n);
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        sl(a[i]); m[a[i]]++;
    }

    ll f =0;
    for(int i=0; i<n; i++)
    {
        f=0;
        if(m[a[i]]>1) continue;
        for(ll j=1; j*j<=a[i]; j++)
        {

            if(a[i]%j==0)
            {
                if(m[j]>0 && j!=a[i]) f=1;

                ll p=a[i]/j;
                if(m[p]>0 && p!=a[i]) f=1;
            }
        }
        //cout<<a[i]<<" "<<f<<endl;
        if(f==0) cnt++;
    }
  cout<<cnt;
}


Measured memory_bytes: 12956
n,k = [int(x) for x in input().split()]
a = [list(map(int, list(bin(int(x))[2:]))) for x in input().split()]
b = list(map(int, list(bin(k)[2:])))
m = len(b)
for i in a:
    m = max(m,len(i))
for i in range(n):
    for j in range(m-len(a[i])):
        a[i].insert(0,0)
for j in range(m-len(b)):
    b.insert(0,0)
s = [[0,0] for i in range(m)]
for i in a:
    for j in range(m):
        s[j][1-i[j]] += 1
dp = [[0 for i in range(2)] for k in range(m+1)]
dp[0][1] = -float("inf")
f = [1<<(m-i-1) for i in range(m)]
for i in range(m):
    for j in range(2):
        x = 1 if j else b[i]
        for d in range(x+1):
            dp[i+1][j | (d < b[i])] = max(dp[i+1][j | (d < b[i])], dp[i][j]+f[i]*s[i][d])

print(max(dp[m]))


Measured memory_bytes: 119732
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      printf("%lf %d\n", double(a)*double(b)/2 , c + c==a && d+d==b);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
const int inf=1e9+7;
#define MAXNUM 3333
int dp[MAXNUM];pii num[MAXNUM];
int main()
{
    int n,t,a,b;scanf("%d%d",&n,&t);
    rep(i,1,t+2)dp[i]=-inf;
    dp[0]=0;
    rep(i,1,n+1)
        scanf("%d%d",&num[i].first,&num[i].second);
    sort(num+1,num+n+1);
    rep(i,1,n+1)
    {
        a=num[i].first,b=num[i].second;
        for(int i=t-1;i>=max(0,t-a);i--)dp[t]=max(dp[t],dp[i]+b);
        for(int i=t-1;i>=a;i--)
            dp[i]=max(dp[i],dp[i-a]+b);
    }
    int res=-inf;
    rep(i,0,t+1)res=max(res,dp[i]);
    printf("%d\n",res);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	ll n, a[5] = { 0 }, ans = 0;
	char c[100000];
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::string s;
		std::cin >> s;
		c[i] = s[0];
		if (c[i] == 'M')a[0]++;
		else if (c[i] == 'A')a[1]++;
		else if (c[i] == 'R')a[2]++;
		else if (c[i] == 'C')a[3]++;
		else if (c[i] == 'H')a[4]++;
	}
	for (int i = 0;i < 5;i++) {
		for (int j = i + 1;j < 5;j++) {
			for (int k = j + 1;k < 5;k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	std::cout << ans << std::endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

vector<vector<int>> item;
vector<int> i2g;

void init(int N) {
  item.resize(N);
  i2g.resize(N);
  for(int i = 0; i < N; i++) {
    item[i].push_back(i);
    i2g[i] = i;
  }
}

void marge(int a, int b) {
  int ga = i2g[a], gb = i2g[b];
  if (item[ga].size() < item[gb].size()) {
    swap(ga, gb);
  }
  for(int i = 0; i < item[gb].size(); i++) {
    i2g[item[gb][i]] = i2g[item[ga][0]];
  }
  for(int i = 0; i < item[gb].size(); i++) {
    item[ga].push_back(item[gb][i]);
  }
  item[gb].clear();
}

int main() {
  ll N, M;
  cin >> N >> M;
  init(N);
  vector<int> A(M), B(M);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    A[i] = a; B[i] = b;
  }

  vector<ll> ans(M);
  ll now = N * (N - 1) / 2;
  ans.back() = now;
  for(int i = M - 1; i > 0; i--) {
    if (i2g[A[i]] == i2g[B[i]]) {
      ans[i - 1] = now;
    } else {
      ll s1 = item[i2g[A[i]]].size();
      ll s2 = item[i2g[B[i]]].size();
      now -= s1 * s2;
      ans[i - 1] = now;
      marge(A[i], B[i]);
    }
  }

  for(int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 12536
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let a: i32 = scan.next();
    let b: i32 = scan.next();
    println!("{}", a*b);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


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

int main()
{
    string s;
    cin >> s;
    int cnt_zero = 0, cnt_one = 0;

    for (auto i = 0; i < s.size(); i++)
    {
        if (s[i] == '0')
        {
            cnt_zero += 1;
        }
        else
        {
            cnt_one += 1;
        }
    }

    cout << s.size() - abs(cnt_zero - cnt_one) << endl;
}


Measured memory_bytes: 512
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$num_array = [];

// for($i=0; $i<$a; $i++){
// 	$num = trim(fgets(STDIN));
// 	if($i===0){
// 		$num_array[]=$num;
// 	}else{
// 		$array_count = count($num_array);
// 		for($j=0; $j<$array_count; $j++){
// 			if($num_array[$j] <= $num){
// 				array_splice($num_array, $j, 0, $num);
// 				if($array_count-$j+1>=$b){
// 					if(!isset($ans)){
// 						$ans = $num_array[$j]-$num_array[$j+$b-1];
// 					}else{
// 						if($ans>$num_array[$j]-$num_array[$j+$b-1]){
// 							$ans=$num_array[$j]-$num_array[$j+$b-1];
// 						}
// 					}
// 				}
// 				break;
// 			}
// 		}
// 	}
// }

for($i=0; $i<$a; $i++){
	$num_array[] = trim(fgets(STDIN));
}
sort($num_array);
$ans = null;
for($i=$b; $i<=$a; $i++){
	if($i===$b){
		$ans = $num_array[$i-1]-$num_array[$i-$b];
	}else{
		$num = $num_array[$i-1]- $num_array[$i-$b];
		$ans = $ans < $num ? $ans : $num;

	}
}

echo $ans . "\n";
 
 


Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define ALL(v) (v).begin(), (v).end()

//aでex回割れる
vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <=N; a++){
        ll tmp=N;
        if(tmp % a != 0) continue;
        ll ex = 0;
        while(tmp % a == 0){
            ex++;
            tmp /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    else ret.push_back({1, 2});
    return ret;
}
 
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    //
    for(ll i=(ll)(n); i>(ll)(0); i--){
        auto v = prime_factorize(i);
        ll tmp=0;
        for(auto e : v){
            if(e.second>=2){
                tmp=max( (ll)(pow(e.first,e.second)), tmp);
            }
            ans=max(tmp,ans);
        }
    }
    //
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int a, b, x, y;
    //cin >> a >> b >> x >> y;
    scanf("%d%d%d%d",&a,&b,&x,&y);
//    int ans = 0;
//    if(x == a / 2 && y == b / 2) ans = 1;
    //cout << setprecision(9) << (double(a)*double(b))/2 << " " << ans << endl;
    printf("%lf %d\n", double(a) * double(b) / 2, x+x==a && y+y==b);
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int s[N];
	int sum = 0;
	/*
	int d[N];
	memset(d, 0, sizeof(d));

	rep(i, N - 1)
	{
		if (d[i] + )
	}
	*/
	rep(i, N)
	{
		cin >> s[i];
		sum += s[i];
	}

	sort(s, s + N);

	if (sum % 10 != 0)
	{
		cout << sum << endl;
	}
	else
	{
		int i = 0;
		while(i < N && s[i] % 10 == 0) i++;

		if (i == N)
		{
			cout << 0 << endl; 
		}
		else
		{
			cout << sum - s[i] << endl;
		}
		
	}

	
	return 0;
}


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




int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int n, a[100][2];
	int ans = 0, max = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i][0]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i][1]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j < i)
				ans += a[j][0];
			else if (j == i)
				ans += a[j][0] + a[j][1];
			else if(j > i)
				ans += a[j][1];
			//printf("%d ",ans);
		}
		//printf("右に%d回進む%d\n",i,ans);
		if (ans > max)
			max = ans;
		ans = 0;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

main() {
  int i, j, H, W;
  
  while(1){

      scanf("%d %d", &H, &W);
  
      if (H == 0 && W == 0) break;
      for (i = 0; i < H; i++) {
	for (j = 0; j < W; j++) {
	  //	scanf("%d %d", &H, &W);
	printf("#");
	}
	printf("\n");
     }
      printf("\n");
        }
      return 0;
}

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

int n,k;
int a[100001];
int main(){
  cin>>n>>k;
  int mx=0;
  int x=1;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0)x=a[i];
    x=__gcd(x,a[i]);
    mx=max(a[i],mx);
  }
  if(k<=mx && k%x==0){
    cout<<"POSSIBLE"<<endl;
  }else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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

int main(){
  int N, size;
  long long ret;
  cin >> N;
  size = 10;

  map<string,int> mp;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s] ++;
  }
  ret = 0;
  for(auto ele : mp){
    auto k = ele.first;
    int v = ele.second;
    ret += (long long)v*(v-1)/2;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main(void){
	int a=0,b=0,i=0;
	for(i=0;i<5;i++){
		scanf("%d",&a);
		if (a<40) b+=40;
		else b+=a;
	}
	
	printf("%d\n",b/5);
	
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

#include<stdlib.h>

 

struct node{

  struct node *p;

  struct node *r;

  struct node *l;

  int key;

};

 

 

typedef struct node * Node;

Node root;

 

void inorder(Node root)

{

 

  if(root != NULL){

    inorder(root->l);

    printf(" %d", root->key);

    inorder(root->r);

  }

}

 

void preorder(Node root)

{

if(root != NULL){

   printf(" %d", root->key);

   preorder(root->l);

   preorder(root->r);

 }

}

 

void insert(int k)

{

  Node y = NULL;

  Node x = root;

  Node z=malloc(sizeof(struct node));

  z->key = k;

  z->l = NULL;

  z->r = NULL;

  while(x!=NULL){

    y = x;

    if(z->key<x->key){

      x=x->l;

    }else{

      x=x->r;

    }

  }

  z->p=y;

  if(y == NULL){

    root=z;

  }else if(z->key<y->key) {

    y->l=z;

  }else{

    y->r=z;

  }

}

 

 

 

 

int main()

{

  int n,i,x;

  char com[100];

 

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%s",com);

    if(com[0]=='i'){

      scanf("%d",&x);

      insert(x);

    }

    else if(com[0]=='p'){

      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

  }

  return 0;

}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n;
int main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
    cout<<((n/1000+1)*1000-n)%1000<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a,b; cin >> n >> a >> b;
  if(a>b){ 
    cout << 0 << endl;
  }else if(n==1){
    cout << (a==b ? 1 : 0 ) << endl;
  }else{
    cout << (b-a)*(n-2)+1 << endl;
  }
    
  return 0;
}


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

int main() {
  string S;
  int x = 0;
  cin >> S;
  for(int i=0; i < S.length(); i++){
    if(S.at(i) == 'x'){
      x++;
    }
  }
  if(x > 7)
    cout << "NO" <<endl;
  else
    cout << "YES" << endl;
}




Measured memory_bytes: 256
S=input()
x="None"
T="abcdefghijklmnopqrstuvwxyz"
num=[0 for i in range(26)]
for i in range(26):
    num[i]+=S.count(T[i])

for j in range(26):
    if num[j]==0:
        x=T[j]
        break

print(x)


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

int main()
{
    int N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    long long a1[N], a2[N];
    map<long long, long long> count;
    for (int i = 0; i < N; i++)
    {
        a1[i] = A[i] + i;
        a2[i] = i - A[i];
        count[a2[i]]++;
    }
    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += count[a1[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 30904
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use std::collections::VecDeque;
use std::io::stdin;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let hp = sc.next_usize();
    let n = sc.next_usize();

    let mut damage = Vec::with_capacity(n);
    let mut magic = Vec::with_capacity(n);

    for _i in 0..n {
        let a = sc.next_usize();
        let b = sc.next_usize();
        damage.push(a);
        magic.push(b);
    }

    let damage = damage;
    let magic = magic;

    let mut dp = vec![U_INF; hp + 1];
    dp[0] = 0;

    for i in 1..=n {
        for j in 0..hp {
            if j + damage[i - 1] >= hp {
                dp[hp] = dp[hp].min(dp[j] + magic[i - 1]);
            } else {
                dp[j + damage[i - 1]] = dp[j + damage[i - 1]].min(dp[j] + magic[i - 1]);
            }
        }
    }

    println!("{}", dp[hp]);
}

pub struct Scanner {
    buf: VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: VecDeque::new(),
        }
    }

    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }

            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }

    pub fn next_usize(&mut self) -> usize {
        self.next()
    }

    pub fn next_isize(&mut self) -> isize {
        self.next()
    }

    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect_vec()
    }

    pub fn next_string(&mut self) -> String {
        self.next()
    }

    pub fn fill_vec_line<T: FromStr>(&mut self, v: &mut Vec<T>) {
        for vi in v {
            *vi = self.next();
        }
    }

    pub fn fill_vec<T: FromStr>(&mut self, v: &mut Vec<Vec<T>>) {
        for vi in v {
            for vii in vi {
                *vii = self.next();
            }
        }
    }

    pub fn make_vec_line<T: FromStr + Default + Clone>(&mut self, i: usize) -> Vec<T> {
        let mut v = vec![Default::default(); i];
        self.fill_vec_line(&mut v);
        v
    }

    pub fn make_vec<T: FromStr + Default + Clone>(&mut self, i: usize, j: usize) -> Vec<Vec<T>> {
        let mut v = vec![vec![Default::default(); j]; i];
        self.fill_vec(&mut v);
        v
    }
}


Measured memory_bytes: 2264
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	bool wk=true;
	if(k>=(1<<n)){
		cout<<-1;
		return 0;
	}
	if(k==0)	{
		for(int i=0;i<(1<<n);i++){
			cout<<i<<' '<<i<<' ';
		}
	}
	else{
		int ans=0;
		for(int i=0;i<(1<<n);i++){
			if(i==k) continue;
			ans=ans^i;
		}
		if(ans==k){
			for(int i=0;i<(1<<n);i++){
				if(i==k) continue;
				cout<<i<<' ';
			}
			cout<<k<<' ';
			for(int i=(1<<n)-1;i>=0;i--){
				if(i==k) continue;
				cout<<i<<' ';
			}
			cout<<k;
		}
		else{
			cout<<-1;
		}
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pp __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;

int main()
{
    ARB
    int m,n;
    int arr[1005];
    cin>>n>>m;
    int sum=0;
    for (int i=0; i<n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    int ans=0;
    for (int i=0; i<n; i++)
    {
        if (arr[i]*(4*m) >= sum)
        {
            ans++;
        }
    }
    cout << (ans >= m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll int
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=5100;
const long long inf=1e18+800;
long long A,B;

ll a[maxn];
ll bish[maxn][maxn];
ll kamt[maxn][maxn];

long long price(ll i,ll j){
	if(a[i]>a[j])return inf;
	if(kamt[i][j-1]+bish[i+1][j]!=(j-i-1))return inf;
	return kamt[i][j-1]*B+bish[i+1][j]*A;
}
long long dp[maxn];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n;
	cin>>n>>A>>B;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	a[0]=0;
	a[n+1]=n+1;
	n+=2;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			kamt[i][j]=kamt[i][j-1];
			if(a[j]<a[i]){
				kamt[i][j]++;
			}	
		}		
	}
	for(ll j=0;j<n;j++){
		for(ll i=j-1;i>=0;i--){
			bish[i][j]=bish[i+1][j];
			if(a[j]<a[i]){
				bish[i][j]++;
			}	
		}		
	}
	dp[0]=0;
	for(ll i=1;i<n;i++){
		dp[i]=inf;
		for(ll j=0;j<i;j++){
			dp[i]=min(dp[i],dp[j]+price(j,i));
		}
	}
	cout<<dp[n-1];

}




















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

int main() 
{
    ll x;
    cin >> x;

    ll c = 100;

    ll y = 0;
    while (c < x) {
        y++;
        c += c * 0.01;
    }

    cout << y << endl;

    return 0;
}


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

int main() {
    ull N, same_num;
    ull ans=0;
    vector<string> vec;
    string si, prev_si;

    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> si;
        sort(si.begin(), si.end());
        vec.push_back(si);
    }

    sort(vec.begin(), vec.end());
    prev_si = vec[0];
    same_num = 1;
    for (int i=1; i<N; i++) {
        si = vec[i];
        if (si == prev_si) same_num++;
        else if (same_num >= 2) {
            ans += same_num * (same_num - 1) / 2;
            same_num = 1;
        }
        prev_si = si;
    }

    if (same_num >= 2) ans += same_num * (same_num - 1) / 2;
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5748
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	int tab[100000];
	
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
	
	for(int i = 0; i < n; i++){
		if(tab[i+1] > tab[i]){
			tab[i+1]--;
		}
	}
	
	//cout << "wyswietlenie tablicy tab: " << endl;
	//for(int i = 0; i <n; i++){
		//cout << tab[i] << " ";
	//}
	
	
	for(int i = 1; i < n; i++){
		if(tab[i] < tab[i-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;	
	
	
	
	
	
	

	
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            char[] s = sc.chararr;
            char[] t = sc.chararr;

            Array.Sort(s);

            Array.Sort(t);
            Array.Reverse(t);

            int index = 0;

            while (index < s.Length && index < t.Length)
            {
                if (s[index] < t[index])
                {
                    Console.WriteLine("Yes");
                    return;
                }
                else if (s[index] > t[index])
                {
                    Console.WriteLine("No");
                    return;
                }

                index++;

            }

            if(s.Length < t.Length)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 11348
#include <stdio.h>
int main() {
	int N, M, i, A, B, p = 0, m = 0;
	scanf("%d %d", &N, &M);
	for (i = 0; i<M; i++)
	{
		scanf("%d %d", &A, &B);
		if (N - A>0) p = p + N - A;
		if (m<N - A) m = N - A;
	}
	printf("%d\n", p - m);
	return 0;
}

Measured memory_bytes: 1748
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
for i in range(min(n, k) + 1):
    for j in range(min(n, k) - i + 1):
        lis = sorted(v[:i] + v[n - j:])
        for l in range(k - i - j + 1):
            ans = max(ans, sum(lis[l:]))
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  double n;
  cin >> n;
  double cnt = 0;
  rep(i,n){
    if((i+1)%2==1) cnt++;
  }
  cout << fixed << setprecision(7) << cnt/n << endl;
  
}


Measured memory_bytes: 256
// AtCoder Beginner Contest 127 - Problem F: Absolute Minima (https://abc127.contest.atcoder.jp/tasks/abc127_f) 
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

struct Query { ll cmd, a, b; };

vector<ii> solve(const vector<Query>& qs)
{
    vector<ii> ans;

    priority_queue<int> L;
    priority_queue<int, vector<int>, greater<int>> R;

    ll ls = 0, rs = 0, bs = 0;

    for (auto q : qs)
    {
        switch (q.cmd) {
        case 1:
            {
                L.push(q.a);
                ls += q.a;

                while (not R.empty() and L.top() > R.top())
                {
                    auto x = L.top(), y = R.top();

                    L.pop();
                    R.pop();

                    ls -= x;
                    ls += y;
                    L.push(y);

                    rs -= y;
                    rs += x;
                    R.push(x);
                }

                if (L.size() - R.size() > 1)
                {
                    auto x = L.top();
                    L.pop();

                    ls -= x;
                    rs += x;

                    R.push(x);
                }

                bs += q.b;
            } 
            break;

        default:
            {
                auto median = L.top();
                auto f = bs + (median * L.size() - ls) + (rs - median * R.size());

                ans.push_back(ii(median, f));
            }

            break;
        }
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int Q;
    cin >> Q;

    vector<Query> qs(Q);

    for (int i = 0; i < Q; ++i)
    {
        cin >> qs[i].cmd;

        if (qs[i].cmd == 2)
            continue;

        cin >> qs[i].a >> qs[i].b;
    }

    auto ans = solve(qs);

    for (auto p : ans)
        cout << p.first << ' ' << p.second << '\n';

    return 0;
}


Measured memory_bytes: 9712
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

string s;
void solve() {
    set<string> cnt;
    cnt.insert(s);
    rep(i, s.size()) {
        if (i == 0) continue;
        auto s1 = s.substr(0, i);
        auto s2 = s.substr(i);
        cnt.insert(s1 + s2);
        cnt.insert(s2 + s1);

        reverse(s1.begin(), s1.end());
        cnt.insert(s1 + s2);
        cnt.insert(s2 + s1);

        reverse(s2.begin(), s2.end());
        cnt.insert(s1 + s2);
        cnt.insert(s2 + s1);

        reverse(s1.begin(), s1.end());
        cnt.insert(s1 + s2);
        cnt.insert(s2 + s1);
    }
    cout << cnt.size() << endl;
}
int main() {
    int m;
    cin >> m;
    rep(i, m) {
        cin >> s;
        solve();
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
        cin>>n>>m;
        vector<pll> v(n);
        forn(i,n)cin>>v[i].ff>>v[i].ss;
        ll c=0;
        ll ans=0;
        sort(all(v));
        while(m){
            ans+=v[c].ff*min(m,v[c].ss);
            m-=min(m,v[c].ss);
            ++c;
        }
        cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);

  int price;
  int flag = 0;
  for (int i = 0; i*7 <= n; i++) {
    price = n-i*7;
    if (price%4 == 0) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    A.sort();

    if (N >= M) {
        writeln(0);
        return;
    }

    auto B = new Tuple!(int, long)[](M-1);
    foreach (i; 0..M-1) B[i] = tuple(i, A[i+1] - A[i]);
    B.sort!"a[1] > b[1]";

    auto C = new bool[](M+1);
    foreach (i; 0..N-1) C[B[i][0]+1] = true;

    long ans = 0;
    long tmp = 0;
    long start = 0;

    foreach (i; 1..M) {
        if (C[i]) {
            ans += A[i-1] - A[start];
            start = i;
        } else {
        }
    }

    ans += A.back - A[start];

    ans.writeln;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

int main(){
	string s;
	cin >>s;
	int sum=0;
	for(int i=1; i < s.length();i++){
		if(s[i]!=s[i-1] )sum++;

	}
	cout << sum;

	return 0;
}

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

ll N, ans;

int main()
{
	cin >> N;
	for (ll i = 2, M = N; i * i <= M; i++)
	{
		ll z = i;
		while (N % z == 0)
			ans++, N /= z, z *= i;
		while (N % i == 0)
			N /= i;
	}

	cout << ans + (N != 1) << "\n";
}


Measured memory_bytes: 3632
n = int(input())
li_a = []
for i in range(9):
  li_a.append([0,0,0,0,0,0,0,0,0])
for i in range(1, n+1):
  k = str(i)
  k0 = int(k[0])
  k1 = int(k[-1])
  if k0*k1 != 0:
    li_a[k0-1][k1-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += li_a[i][j]*li_a[j][i]
print(ans)

Measured memory_bytes: 3064