akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int mod = 1e9 + 7;

int fac[200005], rev[200005];

int binpow(int x, int p) {
    if (p == 0) return 1;

    if (p % 2 == 0)
        return binpow((x * x) % mod, p / 2);
    else
        return (x * binpow(x, p - 1)) % mod;
}

int nCr(int n, int r) {
    if (r > n) return 0;
    return ((fac[n] * rev[r]) % mod * rev[n - r]) % mod;
}
void precalc(int n) {
    fac[0] = fac[1] = 1;
    FOR(i, 2, n + 2)
        fac[i] = (fac[i - 1] * i) % mod;

    rev[n + 1] = binpow(fac[n + 1], mod - 2) % mod;
    REV(i, n, 0) { rev[i] = (rev[i + 1] * (i + 1)) % mod; }
}

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


    int N, M;
    cin >> N >> M;
    precalc(200000);

    map<int, int> m;
    for (int i = 2; i * i <= M; i++) {
        if (M % i != 0) continue;
        while (M % i == 0) {
            m[i]++;
            M /= i;
        }
    }
    if (M > 1) {
        m[M]++;
    }

    int ans = 1;
    for (auto kv :m) {
        ans = ans * nCr(N + kv.second - 1, N-1);
        ans %= mod;
    }
    cout << ans << endl;



    return 0;
}


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

using ll = long long;
const int m = 2019;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    unordered_map<int, int> modmap;
    modmap[0] = 1;
    int sum = 0;
    int ans = 0;
    int power = 1;
    for(int i = n-1; i >= 0; i--) {
        sum = (sum + power*(s[i]-'0')) % m;
        sum = sum % m;
        ans += modmap[sum];
        modmap[sum]++;
        power = power*10 % m;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
N = int(input())
N = str(N)
if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
elif N[-1] == "3":
    print("bon")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100 + 10;
int a[N];
signed main() {
	int n;
	cin >> n;
	int pos = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos += a[i];
	}
	pos /= n;
	int ans = 1e9 + 7;
	int res = 0;
	for (int i = 1; i <= n; i++) {
		res += (a[i] - pos) * (a[i] - pos);
	}
	ans = min(res, ans);
	res = 0;
	for (int i = 1; i <= n; i++) {
		res += (a[i] - pos - 1) * (a[i] - pos - 1);
	}
	ans = min(ans, res);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void xin(){
	#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
int f[100005] = {0};
void findDivisors(ll div[],int n) 
{ 
  
     
  
    
    for (ll i = 1; i <= n; i++) { 
  
         
        for (ll j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
}

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

    ll n;
    cin>>n;
    ll ans=0;
    ll div[n+1] = {0};
    findDivisors(div,n);
    for(int i=1;i<=n;i++)
    {
    	ans += i*div[i];
    }
    
    cout<<ans<<endl;
 }

Measured memory_bytes: 81720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int v,e,m;
    cin>>v>>e>>m;
    vector<int> r(m);
    rep(i,m)cin>>r[i];
    rep(i,m)r[i]--;
    
    int d[201][201];
    rep(i,201)rep(j,201)d[i][j] = INF;
    rep(i,201)d[i][i] = 0;
    
    rep(i,e){
        int u,v,c;
        cin>>u>>v>>c;
        u--,v--;
        d[u][v] = d[v][u] = c;
    }
    
    rep(k,v){
        rep(i,v){
            rep(j,v){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    sort(all(r));
    
    int ans = INF;
    do{
        int sum = 0;
        rep(i,r.size()-1){
            sum+=d[r[i]][r[i+1]];
        }
        ans = min(ans,sum);
    }while(next_permutation(all(r)));
    
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b==1)
    {
    	cout<<"0";
    	return 0;
	}
    if(a>=b)
    {
    	cout<<"1";
    	return 0;
	}
	for(int i=1;;i++)
	{
		if(a+a*i-i>=b)
		{
			cout<<i+1;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

        cin>>n;
        
        for(i=0; i<n; i++)
        {
            cin>>a;
            
            sum=max(sum,a);
            
            if(a==sum)ans++;
        }
        
        cout<<ans<<endl;



}



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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}

template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int a[5];
string s;
int main() {
    int n = in();
    REP(i, n) {
        cin >> s;
        switch (s[0]) {
        case 'M':
            a[1]++;
            break;
        case 'A':
            a[2]++;
            break;
        case 'R':
            a[3]++;
            break;
        case 'C':
            a[4]++;
            break;
        case 'H':
            a[0]++;
            break;
        }
    }
    ll ans = 0;
    ll comb = (1 << 3) - 1;
    while (comb < 1 << 5) {
        ll buf = 1;
        REP(i, 5) {
            buf *= (comb >> i) & 1 ? a[i] : 1;
        }
        ans += buf;
        comb = sized_subset(comb);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    ll N;
    cin>>N;
    ll ans=N*(N+1)*(N+2)/6;
    for (int i = 0; i < N-1; i++){
        int u,v;
        cin>>u>>v;
        ll m=min(u,v);
        ll M=max(u,v);
        ans-=m*(N-M+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<stdio.h>                                                
#include<string.h>                                               
                                                                 
signed main()                                                    
{                                                                
  char s[100];                                                   
  scanf("%s", s);                                                
                                                                 
  int sum = 0;                                                   
  int len = strlen(s);                                           
  for ( int i = 0; i < len; ++i ) {                              
    if( s[i] == 'o' ) sum += 1;                                  
  }                                                              
                                                                 
  if( (15 - len) + sum >= 8 ) puts("YES");                       
  else puts("NO");                                               
                                                                 
  return 0;                                                      
}                                                                

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int N;
  int A[210];
  int count = 0;
  cin >> N;
  for (int i = 0; i < N; ++i) cin  >> A[i];

  bool flag = true;
  int waru_kaisuu = 0;
  int waru = 2;
  while(true){
    for(int i = 0;i<N;i++){
      if(A[i]%waru != 0){
        cout << waru_kaisuu;
        return 0;
      }
    }
    waru_kaisuu++;
    waru *= 2;
  }

  cout << waru_kaisuu;
  return 0;
}

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

namespace AtCoder
{
    class Abc168D
    {
        class Node
        {
            public List<int> Next;
            public Node()
            {
                Next = new List<int>();
            }
        }

        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = nm[0];
            var m = nm[1];
            var nodes = new Node[n];
            for (int i = 0; i < n; i++)
                nodes[i] = new Node();

            for(int i = 0; i < m; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(j => int.Parse(j) - 1).ToArray();
                if (ab[0] != 0)
                    nodes[ab[1]].Next.Add(ab[0]);
                if (ab[1] != 0)
                    nodes[ab[0]].Next.Add(ab[1]);
            }

            var move = new int[n];
            var queue = new Queue<int>();
            queue.Enqueue(0);
            while (queue.Any())
            {
                var i = queue.Dequeue();
                foreach (var next in nodes[i].Next)
                {
                    if (move[next] == 0)
                    {
                        move[next] = i + 1;
                        queue.Enqueue(next);
                    }
                }
            }

            Console.WriteLine("Yes");
            for (int i = 1; i < n; i++)
                Console.WriteLine(move[i]);
        }
    }
}


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

using namespace std;

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

bool sosu(int x){
    for(int i = 2; i*i <= x; i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    int k = 1;
    int num = 0;
    while(num < N){
        int a = 5*k-1;
        bool valid = sosu(a);
        if(valid){
            printf("%d ", a);
            num++;
        }
        k++;
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


ll gcd(ll x,ll y){
  return y==0? x:gcd(y,x%y);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  string ans;
  repeat(i,(S.length()+1)/2){
    ans += S[2*i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
using namespace std;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll max(ll a, ll b)
{
    if(a>b) return a;
    return b;
}

void solve()
{
    int n, m, k;
    cin>>n>>m>>k;

    vi a(n);
    rep(i, n) cin>>a[i];

    vi b(m);

    rep(i, m) cin>>b[i];

    vl pref_a(n+1);
    vl pref_b(m+1);

    pref_a[0] = pref_b[0] = 0;

    for(int i = 1; i <= n; i++)
    {
        pref_a[i] = pref_a[i-1] + a[i-1];

    }

    for(int i = 1; i <= m; i++)
    {
        pref_b[i] = pref_b[i-1] + b[i-1];
    }

    ll ans = 0;

    for(int i = 0; i <= n; i++)
    {
        ll rem = k - pref_a[i];
        if(rem < 0) break;
        auto it = upper_bound(all(pref_b), rem);
        // cout<<rem<<" "<<(it - pref_b.begin())<<endl;
        // if(it!=pref_b.end())
        // {
        //     auto it2 = it;
        //     it2++;
        //     if(*it2 == rem)
        //     {
        //         it++;
        //     }
        //     // cout<<*it2<<endl;
        // }

        ans = max(ans, i + (it - pref_b.begin() - 1));

    }

    // for(int i = 0; i<=n; i++)
    // {
    //     cout<<pref_a[i]<<" ";
    // }
    // cout<<endl;

    // for(int i = 0; i<=m;i++)
    // {
    //     cout<<pref_b[i]<<" ";
    // }
    // cout<<endl;

    cout<<ans<<endl;





}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 19568
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

//ifstream ifs("input.txt");
//#define cin ifs

// 24ñÅ³ÉàÇé
class Dice{
private:
  int yoko;
  int tate;
  int round;

private:
    int face[3][4];

public:
  int getFace(const int idx)const{
    if(idx==0)
      return face[1][1];
    else if(idx==1)
      return face[2][1];
    else if(idx==2)
      return face[1][2];
    else if(idx==3)
      return face[1][0];
    else if(idx==4)
      return face[0][1];
    else if(idx==5)
      return face[1][3];
    return -1;
  }
  Dice(const vector<int> &v){
    init();
    face[1][1]=v[0];
    face[2][1]=v[1];
    face[1][2]=v[2];
    face[1][0]=v[3];
    face[0][1]=v[4];
    face[1][3]=v[5];
  }
private:
  // _CXÌú»
  void init(){
	  for(int i=0;i<3;i++)for(int j=0;j<4;j++)face[i][j]=-1;
    yoko=0;
    tate=0;
    round=0;
  }
public:
  // _CXÌñ]
  void rotate(){
    if(round<4){
    	int tmp = face[2][1];
    	face[2][1]=face[1][2];
    	face[1][2]=face[0][1];
    	face[0][1]=face[1][0];
    	face[1][0]=tmp;
    	round++;
    }
    if(round>=4){
    	round=0;
    	// àÇÁÄ«½çA¡ÌXbgðñ]³¹é
    	if(yoko<4){
    		int tmp = face[1][3];
    		for(int i = 2; i >= 0; i--){
    			face[1][i+1]=face[1][i];
    		}
    		face[1][0]=tmp;
    		yoko++;
    	}
    	// àÇÁÄ«½çAcÌXbgðñ]³¹é
    	if(yoko>=4){
    		if(tate<4){
    			tate++;
    			int tmp = face[1][3];
    			face[1][3]=face[0][1];
    			for(int i = 0; i < 2; i++){
    				face[i][1]=face[i+1][1];
    			}
    			face[2][1]=tmp;
    		}
    		if(tate>=4){
    			round=0;
    			tate=0;
    			yoko=0;
    		}
    	}
    }
  };
};

int main(){
	int n;
	while(cin>>n&&n!=0){
		map<string,int> dict;
		dict["Cyan"]=0;
		dict["Yellow"]=1;
		dict["Red"]=2;
		dict["Magenta"]=3;
		dict["Green"]=4;
		dict["Blue"]=5;
		vector<Dice> vd;
		for(int i=0;i<n;i++){
			vector<int> vs;
			for(int j=0;j<6;j++){
				string s;
				cin>>s;
				vs.push_back(dict[s]);
			}
			vd.push_back(Dice(vs));
		}
		int cnt=0;
		// ¡ÜÅÉo»µ½p^[ðo^
		set<vector<int> > svs;
		for(int i=0;i<n;i++){
			Dice &dice=vd[i];
			vector<int> vs2;
			// ¡ñÌÊðÂ­é
			for(int k=0;k<6;k++)
				vs2.push_back(dice.getFace(k));
			// ±ÌÊª¡ÜÅo»µÄ¢êÎAcontinue
			if(svs.find(vs2)!=svs.end())continue;
			// »¤ÅÈ¯êÎAJEgðâ·
			cnt++;
			// ¡ñÌ_CXÌSu«ûðo^
			for(int j=0;j<28;j++){
				vector<int> vs;
				for(int k=0;k<6;k++)
					vs.push_back(dice.getFace(k));
				// u«ûðo^
				svs.insert(vs);
				// _CXðñ]
				dice.rotate();
			}
		}
		// o»µ½p^[ÌðAn©çø­
		cout<<n-cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
#define rua system("pause")
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

const int MOD = 998244353;
inline int mul(int x, int y) {return (ll)x * y % MOD;}
inline int inc(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline void add(int &x, int y) {y += x; x = y >= MOD ? y - MOD : y;}

map<string, int> f;
int pw[105]; string s;

int dfs(const string &s)
{
	if (s.length() == 0) return 1;
	else if (s.length() == 1) return s[0] - '0' + 1;
	if (f.count(s)) return f[s];
	int res = 0, len = s.length();
	if (s[0] == '0') res = dfs(s.substr(1, len - 1));
	else res = mul(dfs(s.substr(1, len - 1)), 2);
	for (int i = 1; i * 2 <= len; i ++)
	{
		string cur = s.substr(0, i);
		for (int j = 2; j * i <= len; j ++)
		{
			int st = (j - 1) * i, ed = j * i, cnt = 0;
			for (int k = 0; k < i; k ++)
			{
				if (cur[k] == '1')
				{
					if (s[k + st] == '1') ++ cnt;
					else cur[k] = '0';
				}
			}
			add(res, mul(dfs(cur), dfs(s.substr(ed, len - ed))));
		}
	}
	return f[s] = res;
}

int main()
{
	pw[0] = 1;
	for (int i = 1; i <= 100; i ++) pw[i] = mul(pw[i - 1], 2);
	cin >> s;
	cout << dfs(s) << endl;	

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int64_t N;
string S;

bool f(int len)
{
  for (int l = 0; l < N - (len - 1); l++)
  {
    string s1 = S.substr(l, len);
    for (int l2 = l + len; l2 < N - (len - 1); l2++)
    {
      if (s1[0] != S[l2])
        continue;
      if (s1 == S.substr(l2, len))
        return true;
    }
  }
  return false;
}

int main()
{
  cin >> N >> S;
  vector<int> Count(26, 0);
  int mi = 0;
  for (int i = 0; i < N; i++)
  {
    int j = S.at(i) - 'a';
    if (Count.at(j))
      mi = 1;
    Count.at(j)++;
  }
  int left = 0, right = N;
  while (right - left > 1)
  {
    int mid = (right + left) / 2;
    if (f(mid))
      left = mid;
    else
      right = mid;
  }
  cout << max(mi, left) << endl;
}


Measured memory_bytes: 3632
import java.io.PrintWriter
import kotlin.math.max

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()
private fun readLongs(): LongArray = readLn().map { it.toLong() }.toLongArray()

fun main() {
//    val (n, m) = readInts()
//    val a = readInts()
//
//    var sum = 0L;
//    for (i in a) sum += i
//    val r = n - sum
//
//    println(if (r < 0) -1 else r)

    val (n, m) = readInts()
    val a = readInts()

    println(max(n - a.sum(), -1))
}

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

int main() {
  
	int N;
  	cin >> N;
  
    string A,B;
  	cin >> A >> B;
  
    int i = 0;
    while ( i < N ){
      cout << A.at(i) << B.at(i);
      i ++;
    }
  
  	cout << endl;
  
}

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

int main(){
    int N ;
    string S ;
    cin >> N >> S ;
    int ans = 0; 
    for(int i=0; i < 1000; i++){
        vector<int> number = {i/100,(i%100 - i % 10)/10 ,i % 10};
        int k = 0, cnt = 0 ;
        while(1){
            if(k >= N) break;
            else{
                if(number[cnt] + '0' == S[k]) {
                    cnt++ ;
                }
                k++ ;
            }
        }
        if(cnt>=3) ans++;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 384
fun main(args: Array<String>) {

    val N = 5000000000000000L
    val S = readLine()!!
    val K = readLine()!!.toLong()

    var count = 0L
    for (c in S) {
        if (c == '1') {
            count++
        }else{
            println(c)
            return
        }
        if (K == count) {
            println(1)
            return
        }
    }

}

Measured memory_bytes: 33780
N = list('0'+input())
l = len(N)
ans = 0
i = l-1
while i > 0:
    if int(N[i])>=6 or (int(N[i]) == 5 and int(N[i-1])>=5):
        ans+=10-int(N[i])
        i-=1
        while N[i] == '9':
            i-=1
        N[i] = str(int(N[i])+1)
    else:
        ans+=int(N[i])
        i-=1
ans+=int(N[0])
print(ans)
    

Measured memory_bytes: 128708
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define pb push_back


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<long long> vll;

const int MAXN = 1e6 + 10;

int n, m, k;
string s[MAXN];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n >> m >> k;
    rep(i, 0, n) cin >> s[i];

    vvi res(n, vi(m));
    int cur = 1;

    int lb0 = 0;
    rep(i, 0, n) {
    	if(s[i] == string(m, '.')) continue;
    	int lb = 0;
    	rep(j, 0, m) {
    		if(s[i][j] == '#') {
    			for(int jj = j; jj >= lb; jj--) {
    				res[i][jj] = cur;
    			}
    			cur++;
    			lb = j + 1;
    		}
    	}
    	rep(j, lb, m) res[i][j] = res[i][lb - 1];

    	for(int ii = i - 1; ii >= lb0; ii--)
    		res[ii] = res[i];
    	lb0 = i + 1;
    }
    rep(i, lb0, n)
    	res[i] = res[lb0 - 1];

    rep(i, 0, n) {
    	rep(j, 0, m) cout << res[i][j] << ' ';
    	cout << endl;
    }


    return 0;
}













Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int K;
ll dp[201];
ll m[201][201][201];

ll rec(int k) {
    ll sum = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {

                sum += __gcd(__gcd(i, j), l);
            }
        }
    }
    return sum;
}

void solve() {
    cin >> K;
    memset(dp, -1, sizeof(dp));
    cout << rec(K) << endl;
}

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


Measured memory_bytes: 3644
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split(" ");
const x = +input[0];
const y = +input[1];

const A = [0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1];

console.log(A[x] == A[y] ? 'Yes' : 'No');

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;
import java.util.function.*;
 
public class Main{
	
	public void solve(){
		long A = nextInt();
		long B = nextInt();
		
		if(A <= 0 && 0 <= B){
			out.println("Zero");
			
		}else if(A < 0 && B < 0){
			if((B - A) % 2 == 0){
				out.println("Negative");
			}else{
				out.println("Positive");
			}
		}else{
			out.println("Positive");
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 7892
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = "No";

		for (int i = 0; i <= n; i += 4) {
			if ((n - i) % 7 == 0) {
				ans = "Yes";
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(b<=a)
  {
    b=b*2;
    k--;
  }
  while(c<=b)
  {
    c=c*2;
    k--;
  }
  if(k<0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}


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

int main(){
   int n,q;
   string s;
   cin >> n >> q >> s;
   int l,r;
   int ans=0;
   vector<int> f(s.size());
   for (int i=0;i<s.size()-1;i++){
      if(i>0)f.at(i)=f.at(i-1);
      if(s.at(i)=='A'&&s.at(i+1)=='C'){
         f.at(i)++;
      }
   }
   for(int i=0;i<q;i++){
      cin >> l >> r;
      l--;r--;
      if(l>0)cout << f.at(r-1)-f.at(l-1) << endl;
      else cout << f.at(r-1) << endl;
   }
}

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

class E
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		if (s[0] != '1' || s[^1] != '0' || Enumerable.Range(0, n / 2).Any(i => s[i] != s[^(i + 2)])) { Console.WriteLine(-1); return; }

		var r = new List<string>();
		Enumerable.Range(1, n - 1).Aggregate(n, (p, i) =>
		{
			r.Add($"{p} {i}");
			return s[i - 1] == '1' ? i : p;
		});
		Console.WriteLine(string.Join("\n", r));
	}
}


Measured memory_bytes: 42800
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int N,A,x[NMAX+1];
ll dp[NMAX+1][NMAX+1][5002],sum;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>A;
    for(int i=1;i<=N;i++) cin>>x[i];
    
    memset(dp,0,sizeof(dp)); //全て0で初期化
    dp[0][0][0]=1ll; //j=0,k=0,s=0の時は何も選ばないもので、1通り。最後に引く
    
    for(int j=1;j<=N;j++){
        for(int k=0;k<=N;k++){ //x1~xiのうち使う枚数
            for(int s=0;s<=N*A;s++){ //
                if(k>=1&&s>=x[j]) dp[j][k][s]=dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
                else if(s<x[j]) dp[j][k][s] = dp[j-1][k][s];
            }
        }
    }
    
    for(int i=1;i<=N;i++){
        sum+=dp[N][i][i*A];
    }
    
    cout<<sum<<"\n";
    
    return 0;
}


Measured memory_bytes: 101888
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct Point {
  double x;
  double y;
};
struct Line {
  struct Point s;
  struct Point e;
};
double convex_cut(int size, struct Point *p);
int main(void){
  int i, n, q;
  struct Point *p;
  scanf("%d", &n);
  p = (struct Point*)malloc(sizeof(struct Point) * (n + 1));
  for (i = 0; i < n; i++) scanf("%lf %lf", &p[i].x, &p[i].y);
  p[i].x = p[0].x;
  p[i].y = p[0].y;
  scanf("%d", &q);
  for (i = 0; i < q; i++) printf("%.6f\n", convex_cut(n, p));
  free(p);
}
double convex_cut(int size, struct Point *p)
{
  int i, num;
  double area;
  struct Point pr, lr, *pc;
  struct Line l;
  pc = (struct Point*)malloc(sizeof(struct Point) * (size + 2));
  scanf("%lf %lf %lf %lf", &l.s.x, &l.s.y, &l.e.x, &l.e.y);
  lr.x = l.e.x - l.s.x;
  lr.y = l.e.y - l.s.y;
  for (num = i = 0; i < size; i++) {
    double d1, d2;
    pr.x = p[i].x - l.s.x;
    pr.y = p[i].y - l.s.y;
    d1 = lr.x * pr.y - lr.y * pr.x;
    pr.x = p[i+1].x - l.s.x;
    pr.y = p[i+1].y - l.s.y;
    d2 = lr.x * pr.y - lr.y * pr.x;
    if (d1 >= 0) pc[num++] = p[i];
    if (d1 * d2 < 0) {
      struct Point base, hypo;
      double dt1, dt2, t;
      base.x = p[i+1].x - p[i].x;
      base.y = p[i+1].y - p[i].y;
      hypo.x = p[i].x - l.s.x;
      hypo.y = p[i].y - l.s.y;
      dt1 = fabs(lr.x * hypo.y - lr.y * hypo.x);
      hypo.x = p[i+1].x - l.s.x;
      hypo.y = p[i+1].y - l.s.y;
      dt2 = fabs(lr.x * hypo.y - lr.y * hypo.x);
      t = dt1 / (dt1 + dt2);
      hypo.x = p[i].x + t * base.x;
      hypo.y = p[i].y + t * base.y;
      pc[num++] = hypo;
    }
  }
  pc[num] = pc[0];
  for (area = i = 0; i < num; i++) area += pc[i].x * pc[i+1].y - pc[i].y * pc[i+1].x;
  free(pc);
  return fabs(area) / 2;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a[100005]={0},b[100005]={0},s[100005]={0},i,j,l,r,q;
	for(i=2;i<=100000;i++)
	    a[i]=1;
	for(i=2;i<=sqrt(100000);i++)
	{
		if(a[i]){
			for(j=2;j*i<=100000;j++)
		        a[j*i]=0;
		}	    
	}
	for(i=3;i<=100000;i+=2)
	    if(a[i]&&a[(i+1)/2]) b[i]=1;
	for(i=3;i<=100000;i++)
	    s[i]=s[i-1]+b[i];    
	cin>>q;
	int c[q];
	for(i=0;i<q;i++){
		cin>>l>>r;
		c[i]=s[r]-s[l-1];
	}
	for(i=0;i<q;i++)
		cout<<c[i]<<endl;	
	return 0;
	
}

Measured memory_bytes: 2176
from itertools import product

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i, j, k in product(range(A + 1), range(B + 1), range(C + 1)):
    if (500 * i + 100 * j + 50 * k) == X:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(in) in.begin(),in.end()
#define pb(in,a) in.push_back(a)
using namespace std;
int main(){
  vector<string>a;
  vector<int>b,c;
  string s;
  while(cin>>s){
    bool n=false;
    rep(i,a.size())if(a[i]==s){b[i]++;n=true;}
    if(!n){
      pb(a,s);
      pb(b,1);
      pb(c,s.size());
    }
  }
  int max=0;
  int maxi=0;
  rep(i,a.size())if(max<b[i]){max=b[i];maxi=i;}
  cout<<a[maxi];

  max=maxi=0;
  rep(i,a.size())if(max<c[i]){max=c[i];maxi=i;}
  cout<<" "<<a[maxi]<<endl;
}

Measured memory_bytes: 1212
n = int(input())
c = [None for _ in range(n - 1)]
s = [None for _ in range(n - 1)]
f = [None for _ in range(n - 1)]
for i in range(n - 1):
    c[i], s[i], f[i] = map(int, input().split())
for i in range(n - 1):
    t = 0
    for j in range(i, n - 1):
        if t < s[j]:
            t = s[j] + c[j]
        elif t % f[j] == 0:
            t += c[j]
        else:
            t += f[j] - t % f[j] + c[j]
    print(t)
print(0)

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

int main()
{
	// 整数の入力
	int a;
	cin >> a;

	// 出力
	if(a % 10 == 9 || a >= 90)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,a[N];
char s[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int a=read(),b=read();
	cout<<a/b+(a%b>0);
	return 0;
}

Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(n):
    if i == 0:
        continue

    if a[i-1] > a[i]:
        ans += a[i-1] - a[i]
        a[i] += a[i-1] - a[i]

print(ans)


Measured memory_bytes: 32256
#include<stdio.h>
int main(){
  char a[3];
  int count=0;
  for(int i=0;i<3;i++){
    scanf("%c",&a[i]);
   if(a[i]=='R')
     count++;
  }
  if(count==3)
    printf("3");
  else if(count==2 && a[1]=='S')
    printf("1");
  else if(count==2)
    printf("2");
  else
    printf("%d",count);
}
  


Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  if (a < 1200) {
    cout << "ABC" << endl;
  }
  else if (a < 2800) {
    cout << "ARC" << endl;
  }
  else cout << "AGC" << endl;
}

Measured memory_bytes: 384
_,q=gets.chomp.split(' ').map(&:to_i)
s=gets.chomp
arry=[]
q.times { arry << gets.chomp.split(' ').map(&:to_i) }
a=[0]
s.each_char.with_index(1) do |c,idx|
  a[idx] = a[idx-1]+(c=="A"&&s[idx]=="C" ? 1 : 0)
end

arry.each do |b|
  print("#{(a[(b[0]-1)..(b[1]-1)].last)-(a[(b[0]-1)..(b[1]-1)].first)}\n")
end

Measured memory_bytes: 11332
n = int(input())
s = input()
s_w = [0] * (n)
s_e = [0] * (n)
ans = [0] * (n)

t = 0
for i in range(n-1):
    if s[i] == "W":
        t += 1
    s_w[i+1] += t
t = 0
for i in range(1,n):
    #print(s[-i])
    if s[-i] == "E":
        t += 1
    s_e[i] += t
s_e.reverse()
#print(s_w,s_e)
for i in range(n):
    ans[i] += s_w[i] + s_e[i]

print(min(ans))


Measured memory_bytes: 78844
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return string(str)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	defer out.Flush()
	sc.Split(bufio.ScanWords)
	s := next()
	if s == "ABC" {
		fmt.Fprintln(out, "ARC")
	} else {
		fmt.Fprintln(out, "ABC")
	}

}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); for(auto &x : xs) scan(x);
      long min = xs.front(), max = xs.front();
      for(auto x : xs) min = std::min(min, x), max = std::max(max, x);
      printf("%ld\n", max - min);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

ll mod  = 1e9 + 7;
const int N = 1000005;
vector<ll> fac(N);

void Fac() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
}

ll power(ll n, ll p) {
  if (p == 0) return 1;
  ll t = power(n, p / 2);
  t = (t * t) % mod;
  if (p & 1)
    return (t * n) % mod;
  return t;
}



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

  ll n; cin >> n;
  ll ss = (power(10, n) - power(8, n)) % mod;
  ll ab = (power(9, n) - power(8, n)) % mod;
  ab = (ab * 2) % mod;

  ll res = (ss - ab + mod) % mod;
  cout << res;
  
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    mat G(N);
    REP(i,0,M) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    queue<ll> Q;
    vec D(N, -1);
    Q.push(0);
    D[0] = 0;
    while(!Q.empty()) {
        ll v = Q.front(); Q.pop();
        FORR(nv,G[v]) {
            if(D[nv] == -1) {
                D[nv] = v + 1;
                Q.push(nv);
            }
        }
    }

    PR("Yes");
    REP(i,1,N) PR(D[i]);

    return 0;
}

/*



*/

Measured memory_bytes: 12988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    long long a, b, x;
    cin >> a >> b >> x;

    long long fa = (a-1)/x+1;
    if(a == 0) fa = 0;
    long long fb = b/x+1;

    long long output;
    output = fb - fa;

    cout << output << endl;
}

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

using namespace std;

signed main(){
  int d, t, s;
  cin >> d >> t >> s;
  int ans = t - d/s;
  if(d%s) ans--;
  if(ans>=0){
  	cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
n = int(input())
a = [int(input()) for i in range(n)]

a_sort = sorted(a, reverse=True)

if a_sort[0] == a_sort[1]:
    [print(a_sort[0]) for i in range(n)]
    exit()

for i in range(n):
    if a[i] == a_sort[0]:
        print(a_sort[1])
    else:
        print(a_sort[0])


Measured memory_bytes: 15732
#include <stdio.h>

int main()
{
    int a,b;
    int sum = 0;
    int cnt = 0;
    
    while(scanf("%d%d",&a,&b) != EOF)
    {
        sum = a + b;
        
        while(sum != 0)
        {
            sum /= 10;
            cnt++;
        }
        printf("%d\n",cnt);
        cnt = 0;
    }

    return 0;
}

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

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

  int tmp = 0;
  for (int i = 0; i < s.size(); i += 2) {
    if (s[i] != '0') {
      tmp++;
    }
  }
  for (int i = 1; i < s.size(); i += 2) {
    if (s[i] != '1') {
      tmp++;
    }
  }

  int ans;
  if (tmp <= s.size() / 2) {
    ans = tmp;
  }
  else {
    ans = s.size() - tmp;
  }

  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> v(N);
  rep(i, N) cin >> v[i];
  
  vector<int> cost(N);
  cost[0] = 0;
  cost[1] = 99999;
  for(int i=0; i<N; i++) {
    if(i+1<N) cost[i+1] = min(cost[i+1], abs(v[i+1]-v[i]) + cost[i]);
    if(i+2<N) cost[i+2] = abs(v[i+2] - v[i]) + cost[i];
  }
  cout << cost[N-1] << endl;
  return 0;
}


Measured memory_bytes: 4036
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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


bool vis[20][20][1<<10];

typedef struct{
  int x,y;
  int vis;
  int cost;
}state;

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    int sx,sy;
    string in[h];
    int num=0;
    map<PI,int> durty;
    
    rep(i,h){
      cin>>in[i];
      rep(j,w){
	if(in[i][j]=='o'){
	  sx=i;
	  sy=j;
	  in[i][j]='.';
	}else if(in[i][j]=='*'){
	  durty[mp(i,j)]=num++;
	}
      }
    }

    memset(vis,0,sizeof(vis));

    queue<state> Q;
    state st={sx,sy,0,0};
    Q.push(st);
    int ans=-1;

    while(!Q.empty()){
      int cx=Q.front().x,cy=Q.front().y,cvis=Q.front().vis,cc=Q.front().cost;
      Q.pop();

      if(vis[cx][cy][cvis])continue;
      vis[cx][cy][cvis]=true;

      if(cvis==(1<<num)-1){
	ans=cc;
	break;
      }

      rep(i,4){
	int nx=cx+dx[i],ny=cy+dy[i];
	if(nx<0 || h<=nx || ny<0 || w<=ny || in[nx][ny]=='x')continue;
	int nvis=cvis;
	if(in[nx][ny]=='*')nvis|=1<<durty[mp(nx,ny)];
	st.x=nx;
	st.y=ny;
	st.vis=nvis;
	st.cost=cc+1;
	Q.push(st);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1608
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

long long a, b, x;

long long f(long long n) {
	if (n == -1) {
		return 0;
	}
	else {
		return n/x + 1 ;
	}
}

int main() {
	
	
	cin >> a >> b >> x;

	cout << f(b) - f(a - 1) << endl;



	return 0;
}



Measured memory_bytes: 256