akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int rain = 0;
    int ans = -99;
    for(int i=0; i<3; i++)
        if(s[i] == 'R'){
            rain++;
            if(i == 2)
                ans = max(ans, rain);
        }
        else{
            ans = max(ans, rain);
            rain = 0;
        }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>

using ll = long long;

using namespace std;

int keta(ll n) {
  ll foo = 10;
  for (int i = 1; i < 100; i++) {
    if (foo > n) {
      return i;
    }
    foo *= 10;
  }

  return -1;
}

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

  ll n = ceil(sqrt((long double)N));

  for (ll i = n; i >= 1; i--) {
    if (N % i == 0) {
      cout << keta(N / i) << endl;
      return 0;
    }
  }

  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,n;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(a==100||b==100||c==100||a+b>=180||a+b+c>=240)cout<<'A'<<endl;
			else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80)))cout<<'B'<<endl;
			else cout<<'C'<<endl;
		}
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>

int main() {
	std::string S;
	std::string T;
	std::cin >> S >> T;

	int ans = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i)) {
			ans++;
		}
	}
	
	std::cout << ans << std::endl;
}

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

int main() {
  int A, B, C, D;
  cin  >>  A  >>  B  >>  C  >>  D;
  if (A  +  B  <  C  +  D)  {
    cout  <<  "Right"  <<  endl;
  }
  if (A  +  B  ==  C  +  D)  {
    cout  <<  "Balanced"  <<  endl;
  }
  if (A  +  B  >  C  +  D)  {
    cout  <<  "Left"  <<  endl;
  }
}


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

int main() {
	int x;
	cin >> x;
	int max = 1;
	for (int b = 2; b < x; b++) {
		for (int p = 2; pow(b, p) <= x; p++) {
			if (max < pow(b, p)) {
				max = pow(b, p);
			}
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
// If I can't Make It then I Should Try Harder
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
#define F first
#define S second
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9+7,INF=8e18;
const ll N = 1e5+5;
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll comb(ll x,ll y){
    if(x==y || y==0)    return 1;
    return ((comb(x-1,y-1))+(comb(x-1,y)))%mod;
}

ll ebi(ll a,ll b){
    return pow(a-b,2);
}

ll a[101],n;

int main() {
    isc;
    cin >> n;ll tmp=0;
    rep(i,0,n)  {cin >> a[i];tmp+=a[i];}
    ll x=tmp/n;ll y=x+1;
    ll ans=0,tmp1=0;
    rep(i,0,n){
        ans+=ebi(a[i],x);
        tmp1+=ebi(a[i],y);
    }
    cout << min(ans,tmp1) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>

using namespace std;

#define LLI long long int

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<LLI> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    LLI count = 0;
    bool able = true;

    if(vec[0] != 0){
        able = false;
    }

    for(int i = n-1;able && i > 0; i--){
        if(vec[i] - vec[i-1] == 1){
            count++;
        }else if(vec[i] - vec[i-1] <= 0){
            count += vec[i];
        }else{
            able = false;
        }
    }

    cout << (able?count:-1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
//Regular 070 C
int main(){

    int X, x;
    int point = 0;
    x = 1;

    scanf("%d", &X);
    while(point<=X){
	point += x;
	x++;
    }

    point -= x-1;
    if(point==X) printf("%d\n",x-2);
    else printf("%d\n", x-1);
    return 0;
}

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

constexpr int nax = 1e5, inf = 1e9;

int n, k, dp[nax], tab[nax];

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

    cin >> n >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> tab[i];
        if (i == 0) dp[i] = 0;
        else
        {
            dp[i] = inf;
            for (int j = 1; j <= k; ++j)
            {
                if (i - j < 0) break;
                dp[i] = min(dp[i], dp[i - j] + abs(tab[i] - tab[i - j]));
            }
        }
    }
    cout << dp[n - 1] << '\n';
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll INF = 1001001001001001001;

int N;
ll A[410];
ll dp[410][410];

ll rec(int l, int r){
    if(r - l == 1){
        return 0;
    }

    if(dp[l][r] != INF){
        return dp[l][r];
    }

    ll res = INF;
    for(int i=l+1;i<r;++i){
        res = std::min(res, (A[l] - A[i]) + (A[i] - A[r]) + rec(l, i) + rec(i, r));
    }

    return dp[l][r] = res;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    for(int i=N-2;i>=0;--i){
        A[i] += A[i+1];
    }

    std::fill(&dp[0][0], &dp[0][0]+410*410, INF);

    ll res = rec(0, N);
    std::cout << res << std::endl;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll INF = LLONG_MAX/3;

// 区間add, 区間min
struct LazySegTree{
    int n; vector<ll> dat,lazy;
    //初期化
    LazySegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
        lazy=vector<ll>(2*n-1,0);
    }

    void show()
    {
        rep(j,dat.size()) printf(" %d: dat= %lld, lazy= %lld\n", j,dat[j],lazy[j]);
    }

    void setLazy(int k, ll v){
        lazy[k] += v;
        dat[k] += v;
    }

    void push(int k, int l, int r){
        if(lazy[k]!=0){
            setLazy(2*k+1,lazy[k]);
            setLazy(2*k+2,lazy[k]);
        }
        lazy[k]=0;
    }

    void fix(int k, int l, int r){
        dat[k]=min(dat[2*k+1],dat[2*k+2]);
    }

    ll merge(ll x, ll y){
        return min(x,y);
    }

    //内部的に投げられるクエリ
    void _add(int a, int b, ll x, int k, int l, int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            setLazy(k,x);
            return;
        }

        push(k,l,r);
        _add(a,b,x,2*k+1,l,(l+r)/2);
        _add(a,b,x,2*k+2,(l+r)/2,r);

        fix(k,l,r);
    }
    //[a,b)に+x
    void add(int a, int b, ll x){
        return _add(a,b,x,0,0,n);
    }

    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return LLONG_MAX/2;
        if(a<=l && r<=b) return dat[k];

        push(k,l,r);
        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return merge(vl,vr);
    }
    //[a,b)の最小値
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

int main()
{
    int n,Q,A,B;
    scanf(" %d %d %d %d", &n, &Q, &A, &B);
    --A;
    --B;

    vector<int> x(Q+1);
    rep(i,Q)
    {
        scanf(" %d", &x[i+1]);
        --x[i+1];
    }
    x[0]=B;

    LazySegTree L(n),R(n);
    L.add(0,A,INF);
    L.add(A,A+1,-A);
    L.add(A+1,n,INF);
    R.add(0,A,INF);
    R.add(A,A+1,A);
    R.add(A+1,n,INF);

    rep(i,Q)
    {
        ll v = min(L.query(0,x[i+1]+1)+x[i+1], R.query(x[i+1],n)-x[i+1]);

        ll d = abs(x[i+1]-x[i]);
        L.add(0,n,d);
        R.add(0,n,d);

        ll vl = L.query(x[i],x[i]+1)+x[i];

        if(v<vl)
        {
            ll ml=L.query(x[i],x[i]+1), mr=R.query(x[i],x[i]+1);

            L.add(x[i],x[i]+1,-ml);
            R.add(x[i],x[i]+1,-mr);

            assert(L.query(x[i],x[i]+1)==0);

            L.add(x[i],x[i]+1,v-x[i]);
            R.add(x[i],x[i]+1,v+x[i]);
        }
    }

    ll ans = INF;
    rep(i,n) ans=min(ans,L.query(i,i+1)+i);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod ((int)1e9+7)
void add(int &a, int b)
{
	a+=b;
	while(a>mod)
		a-=mod;
}
int dp[21+1][(1<<21) + 1]={};
signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	vector<vector<int>> can(n, vector<int> (n));
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j)
			cin>>can[i][j];
	}
	

	
	for(int lastman=0; lastman<n; lastman++)
	{
		for(int mask = 1; mask<=((1<<n)-1); ++mask)
		{
			if(lastman+1 == __builtin_popcountll(mask))
			{
				for(int woman=0; woman<n; ++woman)
				{
					if((mask>>woman & 1) and can[lastman][woman])
					{
						//cout<<lastman<<" "<<woman<<endl;
						if(lastman==0)
							add(dp[lastman][mask], 1LL);
						else add(dp[lastman][mask],  dp[lastman-1][(mask^(1<<woman))]);
					}
				}
			}
		}
	}

	cout<<dp[n-1][(1<<n) - 1];



	return 0;	
}

Measured memory_bytes: 167280
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double s=abs((h/12+m/720)-m/60)*2*pi;
    double ans=a*a+b*b-2*a*b*cos(s);
    ans=sqrt(ans);
    printf("%.15f\n",ans);
    return 0;
}

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

int main(){
  long long n,k,q;
  cin >> n >> k >> q;
  vector<long long> a(q),p(n,k);
  for(int i=0; i<q; i++){
    cin>> a.at(i);
  }for(int i=0; i<q; i++){
    p.at(a.at(i)-1)++;
  }for(int i; i<n; i++){
  if(p.at(i)-q>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  }
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#define EMPTY 0
#define TARO 1
#define HANAKO 2
using namespace std;

int main(){
	int n, n_2, i, num, field, tcnt, hcnt, win;
	while(true){
		cin>>n; if(n==0) break;
		n_2=n*2;
		tcnt=hcnt=n;
		vector<int> card(n_2, HANAKO);
		for(i=0;i<n;i++){
			cin>>num;
			card[num-1] = TARO;
		}
		field = 0;
		while(true){
			//TARO
			for(i=0;i<n_2;i++){
				if(card[i]==TARO && i+1>field){
					field=i+1;
					card[i]=EMPTY;
					tcnt--;
					break;
				}
			}
			if(tcnt==0) break; //win
			if(i==n_2)field = 0; //pass
			//HANAKO
			for(i=0;i<n_2;i++){
				if(card[i]==HANAKO && i+1>field){
					field=i+1;
					card[i]=EMPTY;
					hcnt--;
					break;
				}
			}
			if(hcnt==0) break; //win
			if(i==n_2)field = 0; //pass
		}
		cout<<hcnt<<endl;
		cout<<tcnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
vector<int> nums;
vector<ll> lis;
int bis(ll num){
    int left = -1;
    int right = lis.size() - 1;
    while(right - left != 1){
        int middle = (left + right) / 2;
        if(lis[middle] >= num) right = middle;
        else left = middle;
    }
    return right;
}
int main(){
    int n;
    cin >> n;
    nums.resize(n);
    lis.resize(n, INF);
    for(int i = 0; i < n; i++) cin >> nums[i];
    for(int i = 0; i < n; i++){
        lis[bis(nums[i])] = nums[i];
    }
    for(int i = n - 1; i >= 0; i--){
        if(lis[i] != INF){
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a, b;
    cin >> a >> b;
    int ans = -1;
    for (int i = 0; i <= 10000; i++) {
        int c = i * (0.08);
        int d = i * (0.10);
        if (c == a && d == b) {
            ans = i; break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
main() {
	string s;
	string t;
	cin>>s>>t;
	int val[s.size()][26];
	int pos[26];
	for(int i=0; i<26; i++){
		pos[i]=-1;
	}
	for(int i=0; i<s.size(); i++){
		for(int j=0; j<26; j++){
			val[i][j]=-1;
		}
	}
	
	for(int i=s.size()-1; i>=0; i--){
		for(int j=0; j<26; j++){
			val[i][j]=pos[j];
		}
		pos[(s[i]-'a')]=i;
	}
	
	
	int position=-1;
	int ans=0;
	
	int i=0;
	
	while(i<t.size()){
		
		if(pos[(t[i]-'a')]==-1){
			cout<<-1;
			return 0;
		}
		if(position==-1){
			
			int place=pos[(t[i]-'a')];
			ans+=(place+1);
			position=place;
			
			i++;
			continue;
		}
		int place=val[position][(t[i]-'a')];
		
		if(place==-1){
		
			ans+=(s.size()-position-1);
			position=-1;
			continue;
		}
		ans+=(place-position);
		position=place;
		i++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 24068
N = int(input())
P = list(map(int, input().split()))

A = [1 for i in range(N)]
B = [1 for i in range(N)]

for i in range(N):
    A[P[i] - 1] += i
    B[P[i] - 1] += i

for i in range(N - 1):
    A[i + 1] += A[i]
    B[N - i - 2] += B[N - i - 1]

print(*A)
print(*B)

Measured memory_bytes: 6312
(set! *unchecked-math* true)

(def ^:const D-Y-X
  [[-1 -1] [-1 0] [-1 1] [0 -1] [0 1] [1 -1] [1 0] [1 1]])
(def ^:const one (unchecked-int \0))

(defn get_H_W []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn set_Array [^"[[C" Array H W]
  (dotimes [h H]
    (->> (read-line)
      (char-array W)
      (aset ^"[[C" Array h))))


(defn Minesweeper [^"[[C" Array H W]
  (let [X (range W)
        Y (range H)]
    (doseq [x X
            y Y
            :let [v ^char (aget ^"[C" (aget ^"[[C" Array y) x)]
            :when (not= \# v)]
      (->> (for [d-y-x D-Y-X
                 :let [[dy dx] (map + (list y x) d-y-x)]
                 :when (and
                         (<= 0 dx)
                         (< dx W)
                         (<= 0 dy)
                         (< dy H)
                         (= \# ^char (aget ^"[C" (aget ^"[[C" Array dy) dx)))]
             true)
        count
        (unchecked-add-int one)
        unchecked-char
        (aset ^"[C" (aget ^"[[C" Array y) x)))))

(defn output [^"[[C" Array]
  (print
    (areduce ^"[[C" Array idx ret ""
      ^string (str ret
                (apply str (aget ^"[[C" Array idx))
                "\n"))))

(let [[H W] (get_H_W)]
  (doto (make-array Character/TYPE H W)
    (set_Array H W)
    (Minesweeper H W)
    (output)))

Measured memory_bytes: 74404
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#define ll long long
#define sz 100105
using namespace std;
ll a[sz] , sum;
ll dp[sz];
ll solve(ll n , ll i , ll k){
   if(i<n){
        ll mn = INT_MAX;
        ll len = i - k;
        for(int j = len ; j < i  ; j++){
            mn = min(dp[j]+(abs(a[j] - a[i])),mn);
        }
        dp[i] = mn;
        solve(n,i+1,k);
   }
   else return dp[n-1];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i , j , n , k;
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=1;i<=k;i++)
        dp[i] = abs(a[i]-a[0]);
    ll res = solve(n,k+1,k);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string> v;
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j <= (int)s.size() - i; j++) {
			string t = s.substr(j, i);
			v.insert(t);
		}
	}
	auto it = v.begin();
	for (int i = 0; i < k - 1; i++) {
		it++;
	}
	cout << *it << endl;
	return 0;
}

Measured memory_bytes: 1664
N =int(input())
A = list(int(x) for x in input().split())
check = True

for x in A:
  if x % 2 == 0 and (x % 3 != 0 and x % 5 != 0):
    check = False

if check == True:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],h[100005];
int main() {
	int n;
	cin>>n;double s=0,a;
	while(n-->0)
	{
	    cin>>a;
	    s+=1/a;
	}cout<<1/s<<endl;
	return 0;
}

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

using namespace std;
using lld = long long;

const lld oo = 1LL << 40;

lld gauss(lld n) {
        return n * (n + 1) >> 1;
}

int main() {
        lld x;
        cin >> x;
        lld ans = oo;
        for(lld i = 0; gauss(i) <= oo; ++i) {
                lld l = 0, r = i;
                while(l <= r) {
                        lld m = l + r >> 1;
                        lld p = gauss(i) - m;
                        if(p == x) {
                                ans = min(ans, i);
                                break;
                        } else if(p < x) {
                                r = m - 1;
                        } else {
                                l = m + 1;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}

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

A = []
for _ in range(N):
    A.append(int(input()))

if N == 1:
    print(1)
    exit()

A.sort()

current_number = A[0]
current_count = 1
ans = 0

for i in range(1,N-1):
    if current_number == A[i]:
        current_count += 1
    else:
        current_number = A[i]
        if current_count % 2 != 0:
            ans += 1
        current_count = 1

if current_number == A[N-1]:
    current_count += 1
    if current_count % 2 != 0:
            ans += 1
else:
    if current_count % 2 != 0:
            ans += 1
    ans += 1
print(ans)

Measured memory_bytes: 7388
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
   //  String[] O=sc.nextLine().split(" ");
     String[] E=sc.nextLine().split(" ");

//int n=Integer.parseInt(nyuA);

//int H=Integer.parseInt(O[0]);
//int W=Integer.parseInt(O[1]);

ArrayList<Integer> list=new ArrayList<>();
for(int i=0;i<E.length;i++){
list.add(Integer.parseInt(E[i]));
}

Collections.sort(list);
int res=list.get(list.size()-1)-list.get(0);
System.out.println(res);



//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <string>

using namespace std;

int main(){

string s;
int counts=0,res=0;
  
  cin >> s;
  
  for(int i=0;i<s.length();i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
    counts++;
    res=max(res,counts);
    }
    else{
      counts=0;
    }  
  
  }
  
  cout << res << endl;
  
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/09/23  Problem: 016_agc_b  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N);
	FOR(i, 0, N)cin >> a[i];
	SORT(a);
	int same = 1;
	int p = a[0];
	int diff = 0;
	FOR(i, 1, N) {
		if (p != a[i]) {
			same = 0;
		}
		if (p + 2 <= a[i]) {
			diff = 1;
		}
	}
	if (same&&N-1==p) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (same) {
		int pp = a[0];
		if (N >= 2 * pp) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	else if (diff == 1) {
		cout << "No" << endl;
		return 0;
	}

	int unique_num = 0;
	FOR(i, 0, N) {
		if (a[i] == p) {
			unique_num++;
		}
	}
	FOR(i, 0, N) {
		if (a[i] == p) {
			if (a[i] < unique_num) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			/*if (a[i] >= N - unique_num - 1) {
				;
			}
			else {
				cout << "No" << endl;
				return 0;
			}*/
		}
	}
	int Nuni = a[N-1]- unique_num;//これだけの色がある
	int sz = 0;
	FOR(i, 0, N) {
		if (a[i] == p)continue;
		else {
			sz = N - i; break;
		}
	}
	if (sz < 2*Nuni) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  cout << "ABC" << n << endl;
  
  return (0);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
bool isp(long long x) {
  if (x == 2 or x == 3) return 1;
  if (x <= 1 or x % 2 == 0 or x % 3 == 0) return 0;
  long long q = (long long) sqrt(x) + 1;
  int i = 5, j = 2;
  while (i < q) {
    if (x % i == 0) return 0;
    i += j;
    j = 6 - j;
  }
  return 1;
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> prime;
  for (int i = 5; i <= 55555; i++) {
    if (isp(i) && i % 5 == 1) prime.push_back(i);
  }
  for (int i = 0; i < n; i++) cout << prime[i] << " ";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
	int a,b;
	std::cin >> a >> b;
	std::cout << "a ";
	if(a<b) { std::cout << "< ";}
	if(a==b){ std::cout << "== ";}
	if(a>b) { std::cout << "> ";}
	std::cout << "b" << std::endl;
	
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
int  pow1(int  x, int  y){
int  ans = 1;
	while(y>0){
		if (y&1)
		{
			ans*=x;
		}
		x *= x;
		y>>=1;
	}
return ans;
} 

signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int x ;
		cin>>x;
		for(int i = -1000 ; i <=1000;i++){
			for(int  j =-1000 ; j <=1000;j++){
				int a = pow1(i,5);
				int b = pow1(j,5);
				if(a - b ==x ){
					return cout << i <<" "<< j,0;
				}
			}
		}
	
	
	}
	return 0;
}

Measured memory_bytes: 3660
'use strict'

function Main(input) {
    const nums = input.split('\n')[1].split(' ');
    const map = {};

    for (let n of nums) {
        n = Number(n);
        map[n - 1] = map[n - 1] ? map[n - 1] + 1 : 1;
        map[n] = map[n] ? map[n] + 1 : 1;
        map[n + 1] = map[n + 1] ? map[n + 1] + 1 : 1;
    }
    
    let max = 0;
    Object.keys(map).map((key) => {
        if (map[key] > max) {
            max = map[key];
        }
    })
    console.log(max);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 33224
package main

import "fmt"

func main() {
	var S, T, s string
	fmt.Scan(&S)
	fmt.Scan(&T)
	ok := false
	for i := 0; i <= len(S); i++ {
		if s == T {
			ok = true
			break
		}
		s = S[i:len(S)] + S[0:i]
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
    int n;
    cin >> n;
    ll ans = 1LL;
    for(ll i = 1; i < n+1; i++){
        ans *= i;
        ans %= (ll)1e9 + 7;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second
#define pb push_back
using namespace std;
using ll=long long;
const ll maxn=2e5+5,inf = 1e18+18;
ll a,b,v,w,t;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>a>>v>>b>>w>>t;
	if(w>=v)cout<<"NO";
	else{
		if((abs(a-b)+abs(v-w)-1)/abs(v-w)<=t)cout<<"YES";
		else cout<<"NO";
	}
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    ll d,t,s;cin>>d>>t>>s;
    if(t*s>=d)cout<<"Yes"<<Endl;
    else cout<<"No"<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------










































Measured memory_bytes: 3640
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000;

typedef long long ll;

int main(void) {

  ll n, k;
  ll a[200010], s[200010];
  
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  s[0] = 0;
  rep(i, n) s[i + 1] = (s[i] + a[i]) % k;

  ll t[200010];
  rep(i, n + 1) {
    t[i] = (i - s[i]) % k;
    if (t[i] < 0) t[i] += k;
  }

  ll ans = 0;
  unordered_map<long long, long long> cnt;
  for (int i = 1; i <= n; i++) {
    cnt[t[i - 1]]++;
    if (i >= k) cnt[t[i - k]]--;
    ans += cnt[t[i]];
  }
  cout << ans << endl;

  return 0;
}
      
  
	       


Measured memory_bytes: 13256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main(){
  int K;
  cin>>K;
  int s=0;
  for(int i=1;i<K+1;i++){
    for(int j=1;j<K+1;j++){
      for(int l=1;l<K+1;l++){
        s = s+gcd(j,(gcd(l,i)));
      }
    }
  }
  cout<<s<<endl;
 
  
   
  
}




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

class Dice{
public:
	int num[6];

	Dice(int a, int b, int c, int d, int e, int f);
	void roll(char s);
	void mroll(string s);
};

Dice::Dice(int a, int b, int c, int d, int e, int f){
	num[0] = a;
	num[1] = b;
	num[2] = c;
	num[3] = d;
	num[4] = e;
	num[5] = f;
}

void Dice::roll(char s){
	int dum = num[0];
	switch (s)
	{
		case 'N':
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = dum;
			break;
		case 'E':
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = dum;
			break;
		case 'W':
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = dum;
			break;
		case 'S':
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = dum;
			break;
		default:
			break;
	}
	return;
}

void Dice::mroll(string s){
	for (int i = 0; s[i] != '\0'; i++){
		roll(s[i]);
	}
	return;
}

int main(){
	int a, b, c, d, e, f;
	string s;
	cin >> a >> b >> c >> d >> e >> f >> s;
	Dice dice(a, b, c, d, e, f);
	dice.mroll(s);
	cout << dice.num[0] << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  vector<pii> p;
  ll i = 0;
  while(i*i*i*i*i <= (ll)1e15){
    p.push_back(mp(i*i*i*i*i,i));
    i++;
  }
  ll n;
  cin >> n;
  for(auto x : p){
    for(auto y : p){
      if(x.fi + y.fi == n){
        cout << x.se << " " << -y.se << "\n";
        return 0;
      }
      if(x.fi - y.fi == n){
        cout << x.se << " " << y.se << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>

#include<iostream>
using namespace std;


int main()
{
	int N, M;
	//std::string s, t;
	cin >> N >> M;
	std::vector<int> a;
	a.resize(N);

	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	int dist = 0;
	while (dist != M) {
		std::sort(a.begin(), a.end());
		int max = a[a.size() - 1];
		int c = a.size() / 2;

		while (a[c] < max / 2) {
			++c;
			if (c >= a.size()) {
				c = a.size() - 1;
				break;
			}
		}

		while (a[c] >= max / 2) {
			--c;
			if (c < 0) {
				c = 0;
				break;
			}
		}
		++c;
		if (c >= a.size()) {
			c = a.size() - 1;
		}

		for (int cur = c; cur<a.size()&&dist < M; ++dist, ++cur) {
			a[a.size() - 1 - (cur - c)] /= 2;
		}
	}

/*

	for (int i = 0; i < M; ++i) {
		std::sort(a.begin(), a.end());

		int tmp;
		tmp = a[a.size() - 1] = a[a.size() - 1] / 2;

		if (a.size() >= 2) {
			for (int j = i; j < M-1; ++j) {
				if (tmp > a[a.size() - 2]) {
					tmp = a[a.size() - 1] = a[a.size() - 1] / 2;
					++i;

					continue;
				} else {
					a[a.size() - 2] /= 2;
					++i;
				}
				break;
			}
		}
	}
*/
	/*
	for (int i = 0; i < M; ++i) {
		std::sort(a.begin(), a.end());
		
		a[a.size() - 1] = a[a.size() - 1] / 2;


	}
	*/
	double c = 0;
	for (int i = 0; i < N; ++i) {
		c += a[i];
	}
	printf("%1.f\n", c);

	



	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int md = 1e9+7;
int n;
long long dp[3005];
char s[3005];

int main(){
	scanf("%d\n%s", &n, s);
	rep(i,n) dp[i] = i+1;
	rep(i,n-1){
		if(s[i] == '>') rep(j,n-i-1) dp[j] = (dp[n-i-1] - dp[j] + md) % md;
		rep(j,n-i-2) (dp[j+1] += dp[j]) %= md;
	}
	printf("%lld\n", dp[0]);
}

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

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

using namespace std;

int main(){
  string abc;
  cin>>abc;
  sort(abc.begin(), abc.end());

  if(abc=="abc"){
    cout<<"Yes";
  }else{
    cout<<"No";
  }


  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];   //a_max = 10^9
        int XORsum = 0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            XORsum ^= a[i];
        }
        for(int i=0;i<n;i++){
            if(i != 0){
                System.out.print(" ");
            }
            System.out.print(XORsum ^ a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 50008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n,y;
	cin >> n>>y;
	repp(i, 0, n+1) {
		repp(j, 0, n+1) {
			if (1000 * i + 5000 * j + 10000 * (n - i - j) == y && i + j <= n) {
				cout << n-i-j << " " << j << " " << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl; return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int bsum(int n, int b){
	return n / b == 0 ? n % b : n % b + bsum(n / b, b);
}

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

	int n;
	cin >> n;

	int ans = n;
	for(int x = 0; x <= 5; x++){
		for(int y = 0; y <= n-x; y++){
			ans = min(ans, x + bsum(y, 6) + bsum(n - x - y, 9));
		}
	}
	
	cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
    
    return 0;
}



Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<cmath>
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<ll,ll> LLP;
const int MAXN=2e5+10;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const int MOD=1e9+7;
const int LOGN=20;
int dp[1010][1<<13];
int w[1010];
int v[1010];
signed main()
{
    //freopen("in.txt","r",stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; ++i)
    {
        scanf("%d",&w[i]);
        int q;
        scanf("%d",&q);
        while(q--)
        {
            int pos;
            scanf("%d",&pos);
            v[i]|=(1<<(pos-1));
        }
    }
    for(int i=0; i<=m; ++i)
        for(int j=1; j<(1<<n); ++j)
            dp[i][j]=INF;
    for(int i=1; i<=m; ++i)
    {
        for(int j=0; j<(1<<n); ++j)
        {
            dp[i][j]=dp[i-1][j-(j&v[i])]+w[i];
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    int ans=dp[m][(1<<n)-1];
    ans==INF?puts("-1"):printf("%d\n",ans);
//    printf("%d\n",dp[1][4]);
    return 0;
}


Measured memory_bytes: 30976
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans = 0;
  srep(k,1,N+1) {
    string s = to_string(k);
    int sum = 0;
    rep(i,sz(s)) {
      sum += s[i]-'0';
    }
    if(A <= sum && sum <= B) {
      ans += k;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
template<class T> struct ConvexHullTrick {
  struct Line { T a, b; };
  deque<Line> deq;
  bool monotone_query;
  bool need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
  ConvexHullTrick(bool monotone_query = false) : monotone_query(monotone_query) {}
  void add(T a, T b) {
    if (deq.empty() or a < deq[0].a) {
      while (deq.size() >= 2 and !need({a, b}, deq[0], deq[1])) {
        deq.pop_front();
      }
      deq.emplace_front(Line{a, b});
    } else if (a > deq.back().a) {
      while (deq.size() >= 2 and !need(deq[deq.size() - 2], deq.back(), {a, b})) {
        deq.pop_back();
      }
      deq.emplace_back(Line{a, b});
    } else assert(false);
  }
  T max(T x) {
    if (deq.empty()) return numeric_limits<T>::min();
    if (monotone_query) {
      while (deq.size() >= 2 and deq[0].a * x + deq[0].b <= deq[1].a * x + deq[1].b) {
        deq.pop_front();
      }
      return deq[0].a * x + deq[0].b;
    }
    int ok = 0, ng = deq.size();
    while (ng - ok > 1) {
      int m = ok + ng >> 1;
      (deq[m - 1].a * x + deq[m - 1].b <= deq[m].a * x + deq[m].b ? ok : ng) = m;
    }
    return deq[ok].a * x + deq[ok].b;
  }
};
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  // ConvexHullTrick<lint> cht(true);
  ConvexHullTrick<lint> cht(false);
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 6656
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int K, X;
    cin >> K >> X;

    const int left = X - (K - 1);
    const int right = X + (K - 1);

    vector<int> ans;
    for (int i = -1000000; i <= 1000000; i++) {
        if (i >= left && i <= right)
            ans.push_back(i);
    }

    for (int i = 0; i < (int)ans.size(); i++)
        cout << ans[i] << (i == (int)ans.size() - 1 ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 256
import math

a, b, x = map(float, input().split())
y = (2 * x) / (a * b)


if y <= a:
  result = math.degrees(math.atan(b / y))
  
else:
  z = 2 * x / a ** 2 - b
  h = b - z
  result = math.degrees(math.atan(h / a))

print(result)

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

const long long mod = 1000000007;
long long solve(int n) {
	if(n==1) return 1;
	return (n * (solve(n-1)%mod))%mod;
}	
int main() {
	int n;
	cin >> n;
	cout << solve(n) << endl;
}

Measured memory_bytes: 1792
# ContestName
# URL
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    coins = [1]
    d = 6
    while d <= N:
        coins.append(d)
        d *= 6
    d = 9
    while d <= N:
        coins.append(d)
        d *= 9
    dp = [0] * (N+1)
    for i in range(1, N+1):
        n = 100000
        for c in coins:
            if i - c < 0:
                continue
            t = dp[i-c] + 1
            if t < n:
                n = t
        dp[i] = n
    print(dp[N])

main()


Measured memory_bytes: 41452
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
def com(x):
    return(x*(x-1)//2)
temp = []
for i in range(0, 2*10**5 + 1):
    temp.append(com(c[i]))
temp_sum = sum(temp)
for i in A:
    print(temp_sum-temp[i]+com(c[i]-1))

Measured memory_bytes: 26780
from scipy.special import comb
s = int(input())
mod = 10**9 + 7
answer = 0
if s<=2:
    print(0)
elif s==3:
    print(1)
else:
    i=1
    while s - i*3 >= 0:
        tmp = s - i*3
        answer += comb(tmp+i-1, i-1, exact=True)
        answer %= mod
        i+=1
    print(answer)

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ma = max(a,max(b,c));
    int ans = ma;
    for (int i = 0;i < k;i++){
        ans *= 2;
    }
    int mi = min(a,min(b,c));
    int middle = a + b + c - ma - mi;
    ans = ans +  mi + middle;
    cout << ans << endl;
}

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

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

#ifndef ATAKYN
#define endl '\n'
#endif

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

    int n;
    cin >> n;

    vector<ld> prob(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> prob[i];

    // dp[i][j] = ith coins, j heads
    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1));
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * prob[i];
            dp[i][j] += dp[i - 1][j] * (1 - prob[i]);
        }
    }

    ld ans = 0.0;
    for (int i = 0; i <= n; i++) {
        if (i > (n - i)) {
            ans += dp[n][i];
        }
    }

    cout << setprecision(10) << fixed << ans << endl;
}



Measured memory_bytes: 141056
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
sc = [LI() for _ in range(m)]
for i in range(10**n):
    t = str(i)
    if len(t) != n:
        continue
    for s,c in sc:
        if int(t[s-1]) != c:
            break
    else:
        print(i)
        quit()
print(-1)

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

int aaa(int n){
    map<int,int> m;
    int i=3;
    while(n>1){
        if(n%i==0){
            n/=i; m[i]++;
        }
        else i++;
    }
    int ret=1;
    for(auto i:m){
        ret*=(i.second+1);
    }
    return ret;
}

int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        // cout<<aaa(189)<<endl;
        if(aaa(i)==8) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

const int INF = 1 << 30;

int N;
int h[100010];

int dp[100010];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> h[i];

    for(int i = 0; i < 100010; i++)
        dp[i] = INF;

    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        // dp[i] から dp[i + 1], dp[i + 2] に「配る」
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024