akhauriyash/Code-Regression huggingface dataset:
n, x, y = map(int, input().split())
x -= 1
y -= 1
k = [0] * n
for i in range(n-1):
  for j in range(i+1,n):
    m = min(abs(j-i), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))
    k[m] += 1

for i in range(1,n):
  print(k[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  reverse(all(H));
  int ans = 0;
  int cnt = 0;
  int temp_H = 0;
  int i = 0;
  while (i < N) {
    if (temp_H <= H[i])
      cnt++;
    else {
      chmax(ans, cnt);
      cnt = 1;
    }
    temp_H = H[i];
    i++;
  }
  chmax(ans, cnt);

  ans = max(ans - 1, 0);
  cout << ans << endl;
}

Measured memory_bytes: 1024
s = input()
n = len(s)
A = [0]*(n+1)

for i in range(n):
    if s[i] == '<':
        A[i+1] = max(A[i+1], A[i]+1)

for i in reversed(range(n)):
    if s[i] == '>':
        A[i] = max(A[i], A[i+1]+1)

print(sum(A))

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

using namespace std;
using pii = pair<int,int>;

#define rep(i,n) for(int i=0; i<n; i++)
#define fi first
#define se second

int main() {
    string s;
    cin >> s;
    
    stack<int> st;
    vector<pii> v;
    vector<char> w;

    long long ans = 0;

    rep(i, s.size()) {
        char c = s[i];

        // cout << st.size() << endl;

        if (c == '(') {
            st.push(v.size());
            v.push_back(pii(0, -1));
            w.push_back(c);
        }
        else if(c == ')') {
            pii vv(0, -1);
            if (st.size()) {
                int top = st.top();
                st.pop();
                vv = pii(1+(top==0?0:v[top-1].fi), top);
                ans += vv.fi;
            }
            v.push_back(vv);
            w.push_back(c);
        }
        else if (c == '-') {
            ans -= v.back().fi;
            if (w.back() == '(') {
                st.pop();
            }
            else if (v.back().se >= 0) {
                st.push(v.back().se);
            }
            v.pop_back();
            w.pop_back();
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 5960
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();


    int[] ps = new int[n];

    for(int i=0; i<n; i++){
      ps[i] = k;
    }
    for(int j=0; j<q; j++){
      int a = sc.nextInt();
      ps[a-1] = ps[a-1] +1;
    }

    for(int i=0; i<n; i++){
      if(q - ps[i]<0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }

  }
}

Measured memory_bytes: 73184
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int left, right, n, d, ans =1;

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

	left = 1;
	right = left + 2*d;

	while(right < n){
		left = right +1 ;
		right = left + 2 *d;
		ans++;
		}

	printf("%d", ans);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int a[3];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N, P := sc.NextInt(), sc.NextInt()

	if N == 1 {
		fmt.Println(P)
		return
	}
	mx := 0
	if N > 40 {
		fmt.Println(1)
		return
	}
	for i := 1; ; i++ {
		A := pow(i, N)
		if A > P {
			break
		}
		if P%A == 0 {
			mx = i
		}
	}
	fmt.Println(mx)

}

//aのb乗をします O(log b)
func pow(a int, b int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b%2 == 1 {
			total *= tmp

		}
		b /= 2
		tmp *= tmp
	}
	return total
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
	int n, k;
	std::cin >> n >> k;

	std::vector<int>arr;
	for(int i = 0; i < n; i++){
		int value;
		std::cin >> value;
		arr.push_back(value);
	}

	std::vector<int>dp(k+2, 0);
 
	for(int i = 0; i <= k; i++){
		for(unsigned int j = 0; j < arr.size(); j++){
			if(i >= arr[j]){
				if(dp[i-arr[j]] == 0){
					dp[i] = 1;
				}
			}
		}
	}
	if(dp[k]){
		std::cout << "First\n";
		return 0;
	}

	std::cout << "Second\n";
	return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int x = input(), y = input();
    int a = input(), b = input(), c = input();
    vector< int > p(a), q(b), r(c);
    cin >> p >> q >> r;
    
    rwhole(sort, p);
    rwhole(sort, q);
    rwhole(sort, r);

    i64 ans = 0;
    vector< i64 > apple;
    range(i, 0, x) {
        ans += p[i];
        apple.push_back(p[i]);
    }
    range(i, 0, y) {
        ans += q[i];
        apple.push_back(q[i]);
    }
    
    whole(sort, apple);
    
    i64 sum = ans;
    range(i, 0, c) {
        if (apple.size() == i) break;
        sum += r[i] - apple[i];
        chmax(ans, sum);
    }
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3572
// abc087_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b,c,x,ans=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;++i) {
    for(int j=0;j<=b;++j) {
      for(int k=0;k<=c;++k) {
        if(500*i+100*j+50*k==x)ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
   
int main(void){
 int x[10],i,j,temp;
 for(i=0; i<10; i++)
  scanf("%d",&x[i]);
 for(i=0; i<10; i++){
  for(j=i+1; j<10; j++){
   if(x[j] > x[i]){
    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
   }
  }
 }
 for(i=0; i<3; i++)
  printf("%d\n",x[i]);
 
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    string s, n;
    cin>>s>>n;
    int ans=0;
    lp(0,s.length()){
        if(s[i]!=n[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3800
main:: IO ()
main = do
    [r,g,b] <- (map read . words) <$> getLine
    putStrLn $ if solve (r,g,b) then "YES" else "NO"

-- |
--
-- >>> solve (2,3,4)
-- False
solve :: (Int, Int, Int) -> Bool
solve (r,g,b) = (100*r + 10*g + 1*b) `mod` 4 == 0


Measured memory_bytes: 508
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    vector<double> dp(n+1);
    dp[0]=1.0;
    //here, the state is how many heads are here so far
    for(int coin=0; coin<n; coin++)
    {
        double p_head;
        cin>>p_head;
        for(ll i=coin+1; i>=0; i--)
        {
            dp[i]=( i==0  ?  0  :  dp[i-1]  *  p_head ) +  dp[i]* (1-p_head);
        }
    }
    double sum=0;
    for(ll i=0; i<=n; i++)      
    {
        ll tail=n-i;
        if(i>tail)
        sum+=dp[i];
    }
    
    std::cout<<std::setprecision(12)<<sum<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 0
    S = input().rstrip('\n')
    w = 0
    for s in S[::-1]:
        if s == 'W':
            w += 1
        else:
            ans += w
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include <cstdio>

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

using namespace std;

int main(){
	int n,h[100000];
	scanf("%d",&n);
	rep(i,n) scanf("%d",h+i);

	for(int i=n-2;i>=0;i--){
		if(h[i]==h[i+1]+1) h[i]--;
		else if(h[i]>h[i+1]+1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#define INF 1000000000
#define pb push_back
#define mp make_pair 
using namespace std;
typedef struct e{
  int to,cost;
}edge;
vector<vector<edge> >E(100010);
int d[100010];
void dijkstra(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  for(int i=0;i<100010;i++)
    d[i]=INF;
  d[s] = 0;
  que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p=que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    for(int j=0;j<E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to]>d[v]+t.cost){
	d[t.to]=d[v]+t.cost;
	que.push(pair<int,int>(d[t.to],t.to));
      }
    }
  }
}
int main(){
  int v,e,r;
  cin>>v>>e>>r;
  for(int i=0;i<e;i++){
    edge ed;
    int a,b,c;
    cin>>a>>b>>c;
    ed.to=b;ed.cost=c;
    E[a].push_back(ed);
  }
  dijkstra(r);
  for(int i=0;i<v;i++){
    if(d[i]==INF)
      cout<<"INF"<<endl;
    else 
      cout<<d[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 13160
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1e9;
const int maxn=50005;
int a[25];
int dp[maxn];
int main()
{
    int n,m;
    cin>>n>>m;
    for (int i=0;i<m;i++)
        cin>>a[i];
    for (int i=0;i<=n;i++) dp[i]=INF;
    dp[0]=0;
    for (int i=1;i<=n;i++){
        for (int j=0;j<m;j++){
            if(a[j]<=i&&dp[i-a[j]]+1<dp[i])
                dp[i]=dp[i-a[j]]+1;
        }
    }
    cout<<dp[n]<<endl;
}

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

int main() {
  int count[4]={0};
  for(int i=0;i<6;i++){
    int temp;
    cin>>temp;
    temp-=1;
    count[temp]++;
  }
  int ans=0;
  for(int i=0;i<4;i++){
    if(count[i]>=3)ans++;
  }
  if(ans==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, a, b, i, j;
	cin >> n >> a >> b;
	vl v(n);
	for (i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	vll C(n + 1, vl(n + 1));
	C[0][0] = 1;
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}

	double sum = 0;
	if (v[0] != v[a - 1]) {
		for (i = 0; i < a; i++) {
			sum += v[i];
		}
		Sp(sum / a);
		int cnt = 0;
		int a2;
		for (i = n-1; i >= 0; i--) {
			if (v[i] == v[a - 1]) {
				cnt++;
				a2 = i;
			}
		}
		cout << C[cnt][a-a2] << endl;
		return 0;
	}

	cout << v[0] << endl;
	int c = 0;
	while (v[c] == v[0]) {
		c++;
		if (c == n)
			break;
	}
	ll ans = 0;
	for (i = a; i <= min(b, c); i++) {
		ans += C[c][i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N;
    cin >> N;
    vel a(N);
    rep(i, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[N - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

double cross(P a, P b){
    return (conj(a)*b).Y;
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}

int main(){
    int n,k;
    cin >> n >> k;
    VP v(n);
    for(int i=0; i<n; i++){
        v[i] = rotate(P(0, 1), 2*PI *i/n);
    }
    VP star;
    for(int i=0; i<n; i++){
        star.push_back(v[i]);
        if(k >= 2){
            star.push_back(crosspointLL(L(v[i], v[(i+k)%n]), L(v[(i+1)%n], v[(i+1-k+n)%n])));
        }
    }
    cout << fixed << setprecision(10);
    cout << getarea(star) << endl;
    return 0;
}



Measured memory_bytes: 51844
def aaa(s):
  if s[0]=='0':
    if s[1]=='0':
      return 'y'
    return 'm'
  elif s[0]=='1':
    if int(s[1])<3:
      return 'm'
  return 'y'
  
s = input()
l = aaa(s[:2])
r = aaa(s[2:])
if l=='m' and r=='m':
  print('AMBIGUOUS')
elif l=='m' and r=='y':
  print('MMYY')
elif l=='y' and r=='m':
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  char alp[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char key[27]="DEFGHIJKLMNOPQRSTUVWXYZABC";
  char data[1001];
  int i,j;

  scanf("%s", data);

  for(i=0;data[i]!='\0';i++){
    for(j=0;j<26;j++){
      if(data[i]==key[j]){
	putchar(alp[j]);
	break;
      }
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int MOD = 1000000007;
long long int beki(int a,int n){
	long long int r;
	if(n==0)return 1;
	r=beki(a,(n-n%2)/2)%MOD;
	r=(r*r)%MOD;
	if(n%2)r=(a*r)%MOD;
	
	return r;
}
int main(){
	long long int n,a,b,res=1,fiv=1,kai=1;
	cin>>n>>a>>b;
	res=beki(2,n)%MOD-1;
	
	for(int i=n;i>n-a;i--){
		fiv*=i;
		fiv%=MOD;
	}
	for(int i=2;i<=a;i++)kai=(kai*i)%MOD;
	res-=(fiv*beki(kai,MOD-2))%MOD;
	if(res<0)res+=MOD;

	kai=fiv=1;
	
	for(int i=n;i>n-b;i--){
		fiv*=i;
		fiv%=MOD;
	}
	for(int i=2;i<=b;i++)kai=(kai*i)%MOD;
	res-=(fiv*beki(kai,MOD-2))%MOD;
	if(res<0)res+=MOD;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N;
	scanf("%d",&N);

	int ans = 0;
	for(int i=0;i<N;i++){
		int l,r;
		scanf("%d %d",&l,&r);
		ans += r-l+1;
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<pint> ab;
    rep(i,n) {
        int ai, bi;
        cin >> ai >> bi;
        ab.emplace_back(bi, ai);
    }
    ssort(ab);
    int tm = 0;
    bool posi = true;
    rep(i,n) {
        if (tm + ab[i].second > ab[i].first) {
            posi = false;
            break;
        }
        tm += ab[i].second;
    }
    cout << (posi ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 5356
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int an[26];
    for(int i=0;i<27;i++){
        an[i]=0;
    }
    while(cin>>ch){
        
        int chi=tolower( ch);
        int num=chi-'a';
        if(0<=num&&num<=25){
        an[num]=an[num]+1;}
    }
        cout<<"a : "<<an[0]<<"\n";
        cout<<"b : "<<an[1]<<"\n";
         cout<<"c : "<<an[2]<<"\n";
          cout<<"d : "<<an[3]<<"\n";
           cout<<"e : "<<an[4]<<"\n";
            cout<<"f : "<<an[5]<<"\n";
             cout<<"g : "<<an[6]<<"\n";
              cout<<"h : "<<an[7]<<"\n";
               cout<<"i : "<<an[8]<<"\n";
                cout<<"j : "<<an[9]<<"\n";
                 cout<<"k : "<<an[10]<<"\n";
                  cout<<"l : "<<an[11]<<"\n";
                   cout<<"m : "<<an[12]<<"\n";
                    cout<<"n : "<<an[13]<<"\n";
                     cout<<"o : "<<an[14]<<"\n";
                      cout<<"p : "<<an[15]<<"\n";
                       cout<<"q : "<<an[16]<<"\n";
                        cout<<"r : "<<an[17]<<"\n";
                         cout<<"s : "<<an[18]<<"\n";
                          cout<<"t : "<<an[19]<<"\n";
                           cout<<"u : "<<an[20]<<"\n";
                            cout<<"v : "<<an[21]<<"\n";
                             cout<<"w : "<<an[22]<<"\n";
                              cout<<"x : "<<an[23]<<"\n";
                               cout<<"y : "<<an[24]<<"\n";
                                cout<<"z : "<<an[25]<<"\n";
return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
#include<string.h>
#define N 1000

int x[N+1][N+1];
char a[N],b[N];
int max(int a,int b){
  if(a<b) return b;
  else return a;
}
int LCS(char *a,char *b){
  int s=strlen(a),t=strlen(b);
  int i,j;
  for(i=1;i<=s;i++){
    for(j=1;j<=t;j++){
      int v=max(x[i][j-1],x[i-1][j]);
      if(a[i-1]==b[j-1]){
        v=max(v,x[i-1][j-1]+1);
      }
      x[i][j]=v;
    }
  }
  return x[s][t];
}

int main(){
  int n,i;
  char p[N+1],q[N+1];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",p);
    scanf("%s",q);
       printf("%d\n",LCS(p,q));
  }
  return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll bin_pow(ll x, ll n, ll mod){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

ll nCk_mod(ll n, ll k, int mod) {
	if(k > n || n <0 || k <0) return 0;
	ll ret = 1, rt2 = 1;
	for(ll i=n-k+1; i<n+1; i++) ret = ( ret * i) % mod;
	for(ll i=1; i<k+1; i++) rt2 = ( rt2 * i) % mod;
	return ( ret * bin_pow( rt2, mod-2, mod)) % mod;
}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, a, b;
	cin >>n >>a >>b;

	ll sm = bin_pow(2, n, MD) - 1;
	ll z1 = nCk_mod(n, a, MD);
	ll z2 = nCk_mod(n, b, MD);
	(sm += 2LL*MD - (z1 + z2) %MD  )%=MD;
	cout << sm <<"\n";
	return 0;
}


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

#define _REP(i,a,b) for(int i = (a) ; i >= (int)(b) ; --i )
#define REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define pii pair<int,int>
#define mp(x,y) make_pair((x), (y))
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x,v) memset((x), (v), sizeof (x))
#define ri1(x) scanf("%d", &(x))
#define ri2(x,y) scanf("%d%d", &(x), &(y))
#define ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define pi1(a) printf("%d\n", (a))
#define pi2(a,b) printf("%d%d\n", (a), (b))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int X;

int main()
{
    ri1(X);
    ll ans = 0;
    ans += 1LL * (X / 500) * 1000;
    X %= 500;
    ans += 1LL * (X / 5) * 5;
    printf("%lld\n",ans);
    return 0;
}


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

int main(){	
    int n, m;
    int i, j, k;

    int mat[100][100] = { {} };
    int ve[100] = {};

    cin >> n >> m;

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            cin >> mat[i][j];
        }
    }

    for (j = 0; j < m; j++) cin >> ve[j];
    for (i = 0; i < n; i++) {
        int x = 0;
        for (j = 0; j < m; j++) x += mat[i][j] * ve[j];
        cout << x << endl;
    }
    return 0;
}


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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int k,a,b;cin>>k>>a>>b;
    if(a/k!=b/k || a%k==0 || b%k==0) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;



    return 0;
}

Measured memory_bytes: 3604
# 2019/04/15 
# AtCoder Beginner Contest 093 - C

# Input
abc = list(map(int, input().split()))

# Sort(Desc)
abc.sort(reverse=True)

# Init
cnt = 0

wsa = abc[0] * 2 - abc[1] - abc[2]

if wsa > 0 and wsa % 2 == 0:
    cnt -= 1

# 0番目と1番目が等しい: 3番目を2足す
# Else:最大でない二つを1ずつ足す
while abc[0] != abc[1] or abc[0] != abc[2]:
    if abc[0] == abc[1]:
        abc[2] += 2
    else:
        abc[1] += 1
        abc[2] += 1
    cnt += 1

# 2番目が最大: 0と1を1足す
# カウントアップしてBreak
    if max(abc) == abc[2]:
        abc[1] += 1
        abc[0] += 1
        cnt += 1
        break
        
print(cnt)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B,i,mi{1000000001};
  cin >> N;
  while(cin >> A >> B){
    if (B < mi) mi = B, i = A; 
  }
  cout << i+mi << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, K, a;
    std::cin >> N >> K;

    vl cum(N);
    vl grades(N);

    floop(N)
    {
        std::cin >> a;
        if(i <= K-1)
        {
            grades[i] = a;
            cum[i] = i == 0 ? a : cum[i-1]+a; 
        }

        else
        {
            grades[i] = a;
            cum[i] = cum[i-1]-grades[i-K]+a;

            if(cum[i] > cum[i-1])
            {
                print("Yes");
            }

            else
            {
                print("No");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6412
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val n = sc.nextInt()
    val s = sc.next()
    var ans = 0
    var before: Char = ' '
    for (i <- 0 until n) {
      if (s(i) != before) {
        ans += 1;
        before = s(i);
      }
    }
    pw.println(ans)

    pw.flush()
  }
}

Measured memory_bytes: 29088
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(auto &&s : S){
        if(s+N>'Z'){
            cout << a[(int)'A' + N - ((int)'Z' - s) - 'A' - 1];
        }else{
            cout << a[(int)s + N - 'A'];  
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
#include <cassert>
using namespace std;

#define maxn 200002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, f[maxn], nextPos[27][maxn];
string s;

int dp(int i) {
    if (i==inf+1) return 0;
    if (i==n) return 1;
    if (f[i]>-1) return f[i];
    f[i] = inf;
    REP(j, 26) {
        f[i] = min(f[i], dp(nextPos[j][i]+1)+1);
    }
    return f[i];
}

void solve(int i) {
    if (i==inf+1 || i==n) return;
    REP(j, 26) {
        if (dp(nextPos[j][i]+1)+1==f[i]) {
            cout << char(j+'a');
            return solve(nextPos[j][i]+1);
        }
    }
}

int main() {
    //freopen("nonsubseq.inp", "r", stdin);
    //freopen("", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    n = s.sz();
    REP(i, 26) nextPos[i][n] = inf;
    REP(i, 26) REPD(j, n) {
        nextPos[i][j] = (s[j]-'a'==i ? j : nextPos[i][j+1]);
    }
    memset(f, -1, sizeof(f));
    dp(0);
    solve(0);
}



Measured memory_bytes: 22164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,total=0,c=0;
    cin>>n>>m;
    int a[1001];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        total+=a[i];
    }
    for(int i=0; i<n; i++)
    {
        if(a[i]>=((double)total/(4*m)))c++;
    }

    if(c>=m)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No";
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;   cin >> s;
    int tmp = 0;
    rep(i, s.size()){
        tmp += s[i] - '0';
        tmp %= 9;
    }
    if(!tmp%9)  cout << "Yes" << endl;
    else        cout << "No"  << endl;
}


Measured memory_bytes: 3716
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    int diff = b - a;
    writeln(iota(1, diff+1).sum - b);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
package main

import (
        "fmt"
        "sort"
)

func solution(n, x int, a []int) int {
        sort.Ints(a)
        for i, c := range a {
                if x < c {
                        return i
                }
                x -= c
        }
        if x == 0 {
                return n
        }
        return n - 1
}

func main() {
        var n, x int
        fmt.Scan(&n, &x)
        a := make([]int, 0, n)
        for i := 0; i < n; i++ {
                t := 0
                fmt.Scan(&t)
                a = append(a, t)
        }
        fmt.Println(solution(n, x, a))
}

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

using namespace std;

const int Nmax = 2e5 + 5;
typedef long long ll;

int A, B, C, X, Y, i, cost;
int ans = INT_MAX;

int main()
{
 //   freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> A >> B >> C >> X >> Y;
    for(i=0; i<=Nmax; ++i)
    {
        cost = i*C + max(0, X - i/2) * A + max(0, Y - i/2) * B;
        ans = min(ans, cost);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, k;
int c[120];

int score(int c[]) {
    int res = 1;
    for (int i = 0; i + k <= n; ++i) {
        int tmp = 1;
        for (int j = i; j < i+k; ++j) tmp *= c[j];
        chmax(res, tmp);
    }
    return res;
}

int main() {
    while (cin >> n >> k) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> c[i];
        int prev = score(c);
        int Max = -1;
        for (int i = 0; i < n; ++i) {
            for (int j = i+1; j < n; ++j) {
                swap(c[i], c[j]);
                int s = score(c);
                swap(c[i], c[j]);
                chmax(Max, s);
            }
        }
        int res = Max - prev;
        if (res >= 0) cout << res << endl;
        else puts("NO GAME");
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d.begin(), d.end());
	
	cout << d[(n + 1) / 2] - d[(n + 1) / 2 - 1 ] << endl;

	return 0;


}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> b(n);
  rep(i, n) {
    if (i == 0)
      b[i] = a[i];
    else
      b[i] = b[i - 1] + a[i];

    
  }

  for (int i = 0; k + i < n; i++) {
    ll x;
    if (i == 0) {
      x = b[k - 1 + i];
    } else {
      x = b[k - 1 + i] - b[i - 1];
    }
    ll y = b[k + i] - b[i];
    if (x < y) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5628
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";

int main()
{
    IOS
    int N,W;
    scanf("%d %d", &N,&W);
    vl dp(W+1, 0);
    //dp[i]=max value when total weight is i
    vi w;
    vi v;
    for(int a=0;a<N;a++)
    {
        int wgt,val;
        scanf("%d %d", &wgt,&val);
        w.pb(wgt);
        v.pb(val);
    }
    for(int a=0;a<N;a++)
    {
        // using push forward dp
        //for(int b=0;b<=W-w[a];b++) picks up same item twice
        for(int b=W-w[a];b>=0;b--) //ierating over items that can already be in the knapsack if i pick up w[a]
        dp[b+w[a]]=max(dp[b+w[a]],dp[b]+v[a]);

    }
    ll res=*max_element(ALL(dp));
    printf("%lld", res);
}


Measured memory_bytes: 3960
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
}

Measured memory_bytes: 35880
/*GRATITUDE*/
//Arise Awake and Stop Not Till the Goal is reached. You are the greatest of all. Hare Krishna
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ff              first
#define ss              second
#define uint            unsigned long long
#define int             long long
#define double           long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define vpii            vector<pii>
#define umpii           unordered_map<int,int>
#define ustii           unordered_set<int>   
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             10000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define all(x)             x.begin(), x.end()
#define all_r(x)           x.rbegin(), x.rend()
#define sortall(x)         sort(all(x))
#define sortall_r(x)       sort(all_r(x))  
#define tr(it, a)          for(auto it = a.begin(); it != a.end(); it++)
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}
/*************************************************************************************************/
//Write your functions here..............................


/***************************************************************************************************/
void solve() {
/*Write your code here*/
int x,n; cin>>x>>n;
vi v; int t;
for_f(0,n-1,1) {
    cin>>t;
    v.pb(t);
}
sortall(v);
int a=0,res=0; 
while(true) {   
int p=inf,q=inf;    
if(!binary_search(all(v),x-a)) {p=x-a;}
if(!binary_search(all(v),x+a)) {q=x+a;}
res=min(p,q);
if(res<inf) break;
a++;
}
cout<<res;
}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 



Measured memory_bytes: 3660