akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
#define mp(x,y) make_pair(x,y)
using namespace std;

ll a,b,c,d;
map<ll,ll> m; 
ll solve(ll n){
	if(n==0) return 0;
	else if(n==1) return d;
	if(m.count(n)) return m[n];

	ll two_c= ((n+1)/2)*2;
	ll two_f= (n/2)*2;
	
	ll three_c= ((n+2)/3)*3;
	ll three_f=(n/3)*3;

	ll five_c =((n+4)/5)*5;
	ll five_f =(n/5)*5;

	ll res=1e18;
	if(d<res/n) res=n*d;

	res=min(res,1ll*abs(n-two_c)*d+a+solve(two_c/2));
	res=min(res,1ll*abs(n-two_f)*d+a+solve(two_f/2));
	res=min(res,1ll*abs(n-three_c)*d+b+solve(three_c/3));
	res=min(res,1ll*abs(n-three_f)*d+b+solve(three_f/3));
	res=min(res,1ll*abs(n-five_c)*d+c+solve(five_c/5));
	res=min(res,1ll*abs(n-five_f)*d+c+solve(five_f/5));

	m[n]=res;
	return res;



}

void solve(){
          ll n;
          m.clear();
          cin>>n;
          cin>>a>>b>>c>>d;
          cout<<solve(n)<<'\n';
  	
	
	
	
	
	
	
	
	
	
	
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//	freopen("input.txt","r",stdin);
	int t;
//	t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}






Measured memory_bytes: 4332
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))


struct edge{
	int to,co,p;
};

vector<edge> vs[1005];

void cleae(){
	rep(i,1005)vs[i].clear();
}

void adde(int a,int b,int c){
	//printf("fr %d to %d co %d\n",a,b,c);
	int sa=vs[a].size(),
		sb=vs[b].size();
	edge e; 
	e.co=c; e.to=b; e.p=sb; vs[a].push_back(e);
	e.co=0; e.to=a; e.p=sa; vs[b].push_back(e);
}

int st,gl;
int gone[1005];
int dfs(int no,int f){
	if(gone[no])return 0;
	gone[no]=1;
	if(no==gl)return f;
	rep(i,vs[no].size()){
		edge& e=vs[no][i];
		if(gone[e.to])continue;
		if(e.co>0){
			int gf = dfs(e.to,min(e.co,f));
			if(gf>0){
				e.co-=gf;
				vs[e.to][e.p].co+=gf;
				return gf;
			}
		}
	}
	return 0;
}

int flow(){
	int res=0;
	for(;;){
		memset(gone,0,sizeof(gone));
		int f = dfs(st,IINF);
		if(f==0)return res;
		res+=f;
	}
}

int na,nb;
int da[505];
int db[505];
int gcd(int p,int q){
	if(p<q)swap(p,q);
	if(p%q==0)return q;
	return gcd(q,p%q);
}

int main(void){
	for(;;){
		scanf("%d%d",&na,&nb);
		if(na==0)break;
		rep(i,na)scanf("%d",&da[i]);
		rep(i,nb)scanf("%d",&db[i]);
		cleae();
		
		st=0;
		gl=na+nb+1;
		rep(i,na)adde(st,i+1,1);
		rep(i,nb)adde(i+na+1,gl,1);
		
		rep(i,na)rep(j,nb){
			if(gcd(da[i],db[j])>1)adde(i+1,j+na+1,1);
		}
		printf("%d\n",flow());
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string S[n];
  for (int i=0; i<n; i++)
    cin >> S[i];
  int ans[26] = {};
  for (int i=0; i<S[0].size(); i++)
    ans[S[0][i]-'a']++;
  for (int i=1; i<n; i++) {
    int cnt[26] = {};
    for (int j=0; j<S[i].size(); j++)
      cnt[S[i][j]-'a']++;
    for (int j=0; j<26; j++)
      if (ans[j] > cnt[j])
        ans[j] = cnt[j];
  }
  for (int i=0; i<26; i++) {
    char c = i+'a';
    int num = ans[i];
    while (num>0) {
      printf("%c", c);
      num--;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
p=[[] for i in range(8)]
for i in range(N):
    x,y,z=map(int,input().split())
    for k in range(8):
        p[k].append(x*(-1)**(k%2)+y*(-1)**((k//2)%2)+z*(-1)**(k//4))

for pi in p:
    pi.sort(reverse=True)

print(max([sum(p[k][:M]) for k in range(8)]))

Measured memory_bytes: 46444
<?php
$arr = explode(' ', trim(fgets(STDIN)));
for ($i = (int)$arr[0]; $i < min((int)$arr[0] + (int)$arr[2], (int)$arr[1]); $i++) {
    echo $i . PHP_EOL;
}

for ($i = max($i, (int)$arr[1] - (int)$arr[2] + 1); $i <= (int)$arr[1]; $i++) {
    echo $i . PHP_EOL;
}

Measured memory_bytes: 4856
import itertools
N,M=map(int,input().split())
S = [list(map(int, input().split())) for i in range(M)]
p= list(map(int, input().split()))
l=list(itertools.product([0,1],repeat=N))
a=0
for i in range(len(l)):
    for j in range(M):
        c=0
        for k in range(S[j][0]):
            c+=l[i][S[j][k+1]-1]
        if c%2!=p[j]:
            break
    else:a+=1
print(a)

Measured memory_bytes: 40560
if __FILE__==$0
	rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)}
	rl_s=lambda{|str,dl|str.strip.split(dl)}
	r_i=lambda{|str|str.strip.to_i}
	r_s=lambda{|str|str.strip}
	dl=" "
	n=r_i[gets]
	num=rl_i[gets,dl] #num,ac,ti
	num.sort!
	#p num
	x=num.length
	for i in 1..num.length-1
		if num[i-1]*2<num[i]
			num[i]+=num[i-1]
			num[i-1]=0
		else
			num[i]+=num[i-1]
		end
		#p num
	end
	r=0
	idx=num.length-1
	while idx>=0 && num[idx]>0
		idx-=1
		r+=1
	end
	p r
end

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

typedef long long LL;
#define MAXN 250000
#define _MOD 1000000009

int main() {
#ifdef OJ
    //freopen("input.txt", "rt", stdin);
    //    freopen("output.txt", "wt", stdout);
#endif
    std::ios_base::sync_with_stdio(false);

    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    if (X < Y) {
        swap(A,B);
        swap(X,Y);
    }

    int ans = min(Y*(A+B), 2*Y*C);
    X -= Y;
    ans += min(X*A, 2*X*C);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<double> vec(N);
  double answer;
  
  // ここにプログラムを追記
  for(int i=0; i<vec.size();i++){
   cin >> vec.at(i);
}
  
  sort(vec.begin(), vec.end());
  //reverse(vec.begin(), vec.end());
  answer = vec.at(0);
  //小さいじゅん
  for(int i=1; i<vec.size();i++){
   answer = (answer + vec.at(i))/2;
    
}
  
  

  std::cout << std::setprecision(5) << answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int n,k;
  cin >>n >>k;
  ll a[n];
  rep(i,n)cin >> a[i];
  rep(i,n-k){
    if(a[i]<a[i+k]){cout << "Yes" << endl;}else{cout << "No" << endl;}
  }
}

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

int main() {
  long long n,m,k;
  cin>>n>>m>>k;
  bool ans=false;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if((n-i)*(m-j)+i*j==k)ans=true;
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	string s;
	cin>>s;
	int n=s.length();
	ll int c=0;
	ll int j=0;
	for(int i=0;i<n-1;i++){
		if(s[i]=='A')j++;
		else if(s[i]=='B'&&s[i+1]=='C'){
			c+=j;
			i++;
		}
		else j=0;
	}
	cout<<c;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 720
#include<cstdio>
#include<cstring>
#define Mod 1000000007
int n,l;
long long f[2][5005],g[5005],h[2][5005],k[5005],ans;
char c[5005];
int main()
{
	scanf("%d",&n);
	scanf("%s",c);l=strlen(c);
	f[0][0]=h[0][0]=g[0]=1;
	for(int i=1;i<=n-l;++i){
		f[i&1][0]=(f[1&i^1][1]+f[1&i^1][0])%Mod;;g[i]=f[i&1][0];
		for(int j=1;j<=i;++j)f[i&1][j]=(f[1&i^1][j+1]+2*f[1&i^1][j-1])%Mod;
	}
	for(int i=1;i<=n;++i){
		h[i&1][0]=0;
		for(int j=1;j<=i;++j)h[i&1][j]=(h[1&i^1][j+1]+2*h[1&i^1][j-1])%Mod;
		k[i]=h[i&1][l];
	}
	for(int i=0;i<=n-l;i+=2)ans=(ans+g[n-l-i]*k[l+i])%Mod;
	for(int i=1;i<=l;++i)ans=ans*(Mod/2+1)%Mod;
	printf("%lld\n",ans);
	return 0;
}

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

score = 0
for i in range(n):
  if a[i] >= b[i]:
    score += b[i]
  elif a[i]+a[i+1] >= b[i]:
    score += b[i]
    a[i+1] = a[i]+a[i+1] - b[i]
  else:
    score += a[i]+a[i+1]
    a[i+1] = 0

print(score)

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> l(q);
    vector<int> r(q);
    for(int i=0;i<q;i++) {
        cin >> l.at(i); l.at(i)--;
        cin >> r.at(i); r.at(i)--;
    }

    vector<int> sum(n);
    for(int i=0;i<n;i++) {
        if(i==0) sum.at(i) = 0;
        else {
            if(s.at(i-1)=='A'&&s.at(i)=='C') sum.at(i) = sum.at(i-1) + 1;
            else sum.at(i) = sum.at(i-1);
        }
    }

    for(int i=0;i<q;i++) {
        cout << sum.at(r.at(i)) - sum.at(l.at(i)) << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
 int seek[1000000],n;
 int Bsearch(int);
int main(){
  int a,q,k,sum = 0,i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&seek[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(Bsearch(k))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

int Bsearch(int key){
  int left=0,right =n,mid;
  while(left < right){
    mid = (left + right) /2;
    if(key == seek[mid])return 1;
    else if(key > seek[mid])left = mid + 1;
    else if(key < seek[mid])right = mid;
  }
  return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    double n,k,ans=0;
    cin>>n>>k;
    rep(i,n) ans+=(1/pow(2,ceil(log2(ceil(k/(i+1))))))/n;
    cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,l;
    cin>>n>>l;
    int arr[n+1];
    for(int i=1;i<=n;i++) arr[i]=l+i-1;
    sort(arr+1,arr+n);
    int no;
    ll sum=0;
    for(int i=1;i<=n;i++) sum+=arr[i];
    for(int i=1;i<=n;i++) if(arr[i]>=0) {no=arr[i]; break;}
    cout<<sum-no;
    return 0;
    
    
    

 

}

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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int> v_to_i(n + 1, -1);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    v_to_i[v] = i;
  }

  set<int> s;
  s.insert(-1);
  s.insert(n);
  int64 ans = 0;
  for (int v = 1; v <= n; v++) {
    int i = v_to_i[v];
    auto iter = s.lower_bound(i);
    int r = *iter;
    iter--;
    int l = *iter;
    // cout << "v: " << v << " i: " << i << " l: " << l << " r: " << r << endl;

    ans += static_cast<int64>(i - l) * static_cast<int64>(r - i) * v;

    s.insert(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, m;
int p[100100];
string s[100100];
int a[100100];

signed main() {

    cin >> n >> m;
    int ans  = 0;
    int ac = 0;
    for(int i = 0; i < m; i++) {
        cin >> p[i] >> s[i];
        if(s[i]=="WA") {
            if(a[p[i]] <= 0) a[p[i]]--;
        }
        else {
            if(a[p[i]] <= 0) ans += -a[p[i]], a[p[i]] = 1, ac++;
        }
    }

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



Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<string> s(n);
  vector<ll> p(n);
  REP(i,n) cin >> s[i] >> p[i];
  auto comp = [=](ll x, ll y){
    if(s[x]==s[y]) return p[x]>p[y];
    return s[x] < s[y];
  };
  vector<ll> ord(n);
  iota(ALL(ord),0);
  sort(ALL(ord),comp);
  REP(i,n) cout << ord[i] + 1 << endl;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(
    g: &Vec<Vec<usize>>,
    cur: usize,
    parent: usize,
    query: &Vec<i64>,
    count: &mut Vec<i64>,
    increment: i64,
) {
    let increment = increment + query[cur];
    count[cur] += increment;
    for &child in g[cur].iter() {
        if child == parent {
            continue;
        }
        dfs(g, child, cur, query, count, increment);
    }
}

fn main() {
    let v = read_vec::<usize>();
    let (n, q) = (v[0], v[1]);
    let mut g = vec![vec![]; n];
    for i in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        g[a].push(b);
        g[b].push(a);
    }

    let mut query = vec![0i64; n];
    for _ in 0..q {
        let v = read_vec::<usize>();
        let (p, x) = (v[0] - 1, v[1] as i64);
        query[p] += x;
    }
    let mut count = vec![0i64; n];
    dfs(&g, 0, n, &query, &mut count, 0);
    print_array(&count);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


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

//bucketmethod

int main() {
  int n;
  int cnt=0;
  cin >>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];
  vector<int> bucket(101,0); //d_iは最大100種類あるのでbucketも100個用意
  rep(i,n) bucket[d[i]]=bucket[d[i]]+1; //d[i]が同じなら同じbucketに入る
  rep(i,101){
    if(bucket[i]>0) cnt=cnt+1; //bucketに1以上入っているものをカウント
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
a.sort()

work = 1
exceeded = False
for i in a:
    work *= i
    if work > 1000000000000000000:
        exceeded = True
        break

if work > 1000000000000000000:
    exceeded = True

if exceeded:
    print(-1)
else:
    print(work)
        


Measured memory_bytes: 21648
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MIN;
ll mn=INT_MAX;
ll MOD=1e9+7;
ll INF = 1e18;
const int maxs=2e5+10;
const int lg=22;

vll V;

void pre(){
    for(ll i=1; i<=1000000; i++){
        ll tmp=(i*(i+1))/2;
        V.pb(tmp);
    }
}

void code_idhr_h(){
    ll N; cin>>N;
    ll ans=0;
    for(ll i=2; i<=sqrt(N); i++){
        if(N%i==0){
            ll cnt=0;
            while(N%i==0){
                N/=i;
                cnt++;
            }
            ans=ans+ub(V.begin(), V.end(), cnt)-V.begin();
            //cout<<ans<<" "<<i<<" "<<cnt<<endl;
        }
    }
    if(N>2) ans++;
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        pre();
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 11580
#include<iostream>

using namespace std;

int main(){
  long long int n,a,b,x[200005],res=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    cin>>x[i];
  }
  for(int i=1;i<=n-1;i++){
    res+=min(a*(x[i+1]-x[i]),b);
  }
  cout<<res;
}

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

int main() {
  string N;
  cin >> N;
  
  string ans = "No";
  for (int i = 0; i < 3; i++) {
    if (N.at(i) == '7') ans = "Yes";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3560
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[600005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[20000];

ll ha[2];

ll x, y;

int main() {
	cin >> N;

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

	f = true;
	if (N == 1) {
		f = true;
	}
	else {
		A[0]--;

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

		for (int i = 1; i < N; i++) {
			if (A[i] >= A[i - 1]) {

			}
			else {
				f = false;
			}
		}
	}
	
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 16512
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

A = {}
for i in S:
    A.setdefault(i, 1)
    A[i] += 1

B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)

for i in C:
    print(i)

Measured memory_bytes: 35232
N, M = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

Ms = [list(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i==j:
            continue
        a, b = Ms[j]
        uf.union(a-1, b-1)
    if uf.group_count()!=1:
        ans += 1
print(ans)

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

using namespace std;

int main()
{
    int N,M;
    string S;
    cin>>N;
    cin>>S;
    M=S.length();
   if(S.length()>N)
    {
        for(int i=M-1;i>N-1;i--)
        {
            S.erase(i);
        }
    cout<<S<<"...";
    }
    else
    {
        cout<<S;
    }

    return 0;
}


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> vs(h);
  for(int i=0;i<h;i++) cin >> vs[i];
  for(int i=0;i<2*h;i++) cout << vs[i/2] << endl;

  return 0;
}

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

using namespace std;
# define M_PI 3.14159265358979323846
# define epsi 1e-9
# define F first
# define S second
# define REP(i,a,b) for(int i=a;i<=b;i++)
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
using ll = long long int;
const int MOD = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        ll temp1,temp2,temp3;
        cin>>temp1>>temp2>>temp3;
        a[i]=temp1;
        b[i]=temp2;
        c[i]=temp3;
    }
    ll dp[n][3];
    dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=max(a[i]+dp[i-1][j+1],a[i]+dp[i-1][j+2]);
            }
            else if(j==1)
            {
                dp[i][j]=max(b[i]+dp[i-1][j+1],b[i]+dp[i-1][j-1]);
            }
            else if(j==2)
            {
                dp[i][j]=max(c[i]+dp[i-1][j-1],c[i]+dp[i-1][j-2]);
            }
        }
    }
    ll ans=0;
    for(int i=0;i<3;i++)
    {
        ans=max(ans,dp[n-1][i]);
    }
    cout<<ans;
}

Measured memory_bytes: 8304
#include <cstdio>

int L[2000][2000];
int R[2000][2000];
int U[2000][2000];
int D[2000][2000];

int main()
{
  char s[2000][2001];
  int h, w;
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i)
  {
    scanf("%s", s[i]);
    
    for (int j = 0; j < w; ++j)
    {
      if (s[i][j] == '#')
      {
        L[i][j] = 0;
      }
      else
      {
        L[i][j] = 1 + (j == 0 ? 0 : L[i][j - 1]);
      }
      
      if (s[i][w - 1 - j] == '#')
      {
        R[i][w - 1 - j] = 0;
      }
      else
      {
        R[i][w - 1 - j] = 1 + (j == 0 ? 0 : R[i][w - j]);
      }
    }
  }
  for (int j = 0; j < w; ++j)
  {
    for (int i = 0; i < h; ++i)
    {
      if (s[i][j] == '#')
      {
        U[i][j] = 0;
      }
      else
      {
        U[i][j] = 1 + (i == 0 ? 0 : U[i - 1][j]);
      }
      
      if (s[h - 1 - i][j] == '#')
      {
        D[h - 1 - i][j] = 0;
      }
      else
      {
        D[h - 1 - i][j] = 1 + (i == 0 ? 0 : D[h - i][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if (s[i][j] == '#') continue;
      int&& a = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      if (a > ans) ans = a;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 66560
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int a, b, c, d;

int main()
{
	cin >> a >> b >> c >> d;
	
	cout << min(a, b) + min(c, d);
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, M;
  cin >> N >> M;
  int num[50] = {};
  REP(i, N)
  {
    int K;
    cin >> K;
    REP(j, K)
    {
      int A;
      cin >> A;
      num[A]++;
    }
  }
  int ans = 0;
  REP1(i, M)
  {
    if (num[i] == N)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


a, b = LS()
print(int(a) * int(b.replace('.', '')) // 100)


Measured memory_bytes: 69216
l, r = (int(_) for _ in input().split())

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        ans = 1000000
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            for i in range(start, stop + 1):
                for j in range(i+1, stop + 1):
                    if i * j % 2019 < ans:
                        ans = i * j % 2019
            print(ans)
                




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

using namespace std;

int main(int argc, const char *argv[]) {
  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
ll n, x, ans = 0;
vector<int> a;
int main() { ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	REP(i,n) cin >> x, a.pb(x);
	sort(a.begin(), a.end());
	
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n-1; j++) {
			auto ub = lower_bound(a.begin()+j+1, a.end(), a[i]+a[j]);
			/*
			int lo = j+1, hi = n-1, mid;
			while (lo < hi) {
				mid = lo + (hi - lo) / 2;
				if (a[i]+a[j] > a[mid]) hi = mid; else lo = mid+1;
			}*/
			//cout << a[i] << ", " << a[j] <<  " : ";
			//if (a[i]+a[j] > a[ub-a.begin()]) {
			//	cout << ub-a.begin()-j -1;
				ans += ub - a.begin() - j - 1;
			//}
			/*if (1 and a[i]+a[j] > a[lo]) {
				cout << lo-j;
				ans += (lo-j);
			}*/
			//cout << endl;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
int dis[MAX];
int n,m;
int vis[MAX];
vector<pair<int, int> >adj[MAX];
void dfs(int s){
	 vis[s]=1;
	for(int i=0;i<adj[s].size();i++){
		if(vis[adj[s][i].first]!=1){
			dis[adj[s][i].first]=dis[s]+adj[s][i].second;
			dfs(adj[s][i].first);
		}
	}

}
int main(){
	int indeg[MAX];
	int i, j,l;
	cin>>n;
	m=n-1;
	memset(vis, 0, sizeof(vis));
	memset(dis, 0 , sizeof(dis));
	while(m--){
		int x,y,w;
		cin>>x>>y>>w;
		adj[x].push_back(make_pair(y,w));
		adj[y].push_back(make_pair(x,w));
		indeg[y]++;
	}
	int root;
	dis[0]=0;
	dfs(0);
	int mx=-1;
	for(int i=0;i<n;i++){
		if(mx<dis[i])
		{
			mx=dis[i];
			root=i;
		}
	}
	memset(dis, 0, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dfs(root);
	mx=-1;
	for(int i=0;i<n;i++){
		if(mx<dis[i])
			mx=dis[i];
	}
	cout<<mx<<"\n";

}



Measured memory_bytes: 12464
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
    int n, l, r;
	int ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	
	cout << ans << endl;
}

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

int main(){
	long long n,t;
	vector <int> a;
	cin >>n;
	long long ans =0;
	for(int i=0;i<n;i++){
		cin >> t;
		if(t%2){
			ans += t/2;
			a.push_back(1);
		}else{
			if(t==0){
				a.push_back(0);
			}else{
				ans +=(t/2)-1;
				a.push_back(2);
			}
		}
	}
	int num =0;
	while(num<n){
		if(a[num]==0){
			num +=1;
		}else if(a[num]==1){
			if(num==(n-1)){
				break;
			} 
			if(a[num+1]>0){
				a[num+1]-=1;
				num +=1;
				ans +=1;
			}else{
				num +=1;
			}
		}else if(a[num]==2){
			ans +=1;
			num +=1;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 200005
int vis1[MAX];
int vis2[MAX];
int a,b;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        if(a==1)
            vis1[b]=1;
            if(b==1)
                vis1[a]=1;
            if(a==n)
                vis2[b]=1;
            if(b==n)
                vis2[a]=1;
    }
    int flag=0;
    for(int i=1;i<=n;i++)
        if(vis1[i]&&vis2[i])
        {
            flag=1;
            break;
        }
        if(flag)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;
const int N=1e3+10,mod=1e9+7;
ll dp[N][N];

ll fac[N];
ll power(ll n, ll k){
    if (k==0 || k==n){
        return 1;
    }
    else{
        if (k%2==0){
            ll x=power(n,k/2);
            return x*x%mod;
        }
        else{
            ll x=power(n,k/2);
            x=x*x%mod;
            return x*n%mod;
        }
    }
}
ll fm[N];
ll ent(ll k, ll n){
	if (k==0 || k==n){
        return 1;
	}

	return (((fac[n]*fm[k])%mod)*fm[n-k])%mod;
}
int32_t main(){
    fac[0] = 1;

	for(int i=1;i<N;i++) {
        fac[i]=(fac[i-1]*i)%mod;
	}
	for(int i=0;i<N;i++) {
        fm[i]=power(fac[i],mod-2);
	}
	ll n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	//dp[a][a]=1;
	for (int i=0;i<N;i++){
        dp[0][i]=1;
	}
	for (int i=a;i<=n;i++){
        for (int j=a;j<=b;j++){
            /// dp[i][j]; i nafar be grohaye max j nafari chan ravesh
            dp[i][j]=dp[i][j-1];
            ll s=i;
            ll z=1;
            ll p1=1;

            for (int k=1;k<=d;k++){
                if (j>s){
                    break;
                }
                z*=ent(j,s);
                z%=mod;



                s-=j;

                if (k>=c){
                    dp[i][j]+=dp[s][j-1]*z%mod*fm[p1]%mod;
                    dp[i][j]%=mod;

                }
                p1++;
            }
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
	}
	cout << dp[n][b]%mod;;

}


Measured memory_bytes: 8192
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	int n, m, x, ans1 = 0, ans2 = 0;;
	cin >> n >> m >> x;
	VI A(m);
	rep(i, m) {
		cin >> A[i];
	}

	rep(i, m) {
		if (A[i] < x) ans1++;
		else if (x < A[i]) ans2++;
	}


	cout << min(ans1, ans2) << endl;
}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

x = int(input())

tmp = [i ** 5 for i in range(ceil(x ** 0.25) + 1)]
res = 0

for a in range(len(tmp) - 1):
    for b in range(a + 1, len(tmp)):
        if tmp[a] - tmp[b] == x:
            res = f"{a} {b}"
            break
        elif tmp[a] + tmp[b] == x:
            res = f"{a} {-b}"
            break
        elif -tmp[a] + tmp[b] == x:
            res = f"{-a} {-b}"
            break
        elif -tmp[a] - tmp[b] == x:
            res = f"{-a} {b}"
            break

print(res)


Measured memory_bytes: 30920
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,h[100005],dp[100005]={};
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  dp[1]=0;
  for(int i=2;i<=n;i++){
    if(i!=2){
      dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }
    else{
      dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    }
  }
  cout<<dp[n]<<'\n';
  return(0);
}


Measured memory_bytes: 1024
/*================================================================
Love China, Love YALI, Love OI!
*   
*   File Name：C.cpp
*   Author：YaliKiWi
*   Date：2019年09月01日
*   Discribe：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define max_(x,y) ((x)>(y)?(x):(y))
#define min_(x,y) ((x)<(y)?(x):(y))
#define dd double
#define ull unsigned long long
#define ll long long
#define maxn 100000+10
int a[maxn],dp[maxn],n;
int ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	fo(i,1,n)cin>>a[i];
	dp[n]=1;
	for(register int i=n-1;i>=1;i--){
		if(a[i+1]<=a[i]){
			dp[i]=dp[i+1]+1;
			ans=max_(dp[i],ans);
		}
		else dp[i]=1;
		ans=max_(ans,dp[i]);
	}
	cout<<max_(ans-1,0);
	return 0;
}

Measured memory_bytes: 1024
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut aa: [usize; n]
    }


    for _ in 0..std::cmp::min(k, 50) {
        let mut bb = vec![0isize; n];

        for i in 0..n {
            let l = std::cmp::max(0, i as isize -aa[i] as isize) as usize;
            let r = std::cmp::min(n-1, i+aa[i]);
            bb[l] += 1;
            if r+1 < n {
                bb[r+1] -= 1;
            }
        }
    
        for i in 1..n {
            bb[i] += bb[i-1];
        }

        aa = bb.into_iter().map(|x| x as usize).collect();
    }


    let ans = aa.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", ans);
}

Measured memory_bytes: 17200
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            max = Math.max(max, a);
            map.put(a, b);
        }
        int ans = map.get(max);
        ans += max;
        System.out.println(ans);
    }
}


Measured memory_bytes: 98792
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 n, p; scanf("%lld%lld", &n, &p);
	
	std::vector<std::pair<i64, i64>> vec;
	for(i64 i = 2; i * i <= p; i++) {
		if(p % i) continue;
		vec.push_back({i, 0});
		while(p % i == 0) {
			vec.back().second++;
			p /= i;
		}
	}
	if(p != 1) vec.push_back({p, 1});
	
	i64 ans = 1;
	for(auto v : vec) {
		while(v.second >= n) {
			ans *= v.first;
			v.second -= n;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[2];
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> a[0] >> a[1];
    sum += (a[1]-a[0]+1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N=int(input())
L=[]
for i in range(N):
    A, B=list(map(int,input().split()))
    L.append((A,B))
L1=sorted(L,key=lambda x: x[0])
L2=sorted(L,key=lambda x: x[1])
if N%2==1:
    n=N//2
    print(L2[n][1] -L1[n][0]+1)
else:
    n=N//2
    m=(L1[n-1][1]+L1[n][1])/2
    print(L2[n-1][1]+L2[n][1]-L1[n-1][0]-L1[n][0]+1)

Measured memory_bytes: 42032
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        
        Scanner scanner = new Scanner(System.in);
        int count = 1;
        while(true) {
            String input = scanner.nextLine();
            
            if (input.equals("0")) {
                break;
            }
            
            System.out.println(String.format("Case %d: %s", count, input));
            count++;
        }
    }
}


Measured memory_bytes: 71272
#include <iostream>

using namespace std;

int main(){
  int n,x,ans;
  while(1){
    cin >> n >> x;
    ans = 0;
    if(n == 0 && x == 0) break; // n == x == 0 の時読み込み終了
    for(int i = 1; i <= n-2 ; i++){
      for(int j = i+1; j <= n-1 ; j++){
        for(int k = j + 1 ; k <= n ; k++){
          if((i+j+k) == x) ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  string s; cin >> s;
  rep(i,s.size()){
    s[i] = 'x';
  }
  cout << s << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>

int n,m;
bool b[10];
string dp[11000];

int size(int k){
  if(k==1) return 2;
  if(k==7) return 3;
  if(k==4) return 4;
  if(k==2||k==3||k==5) return 5;
  if(k==6||k==9) return 6;
  if(k==8) return 7;
}

string f(string s,string t,char c){
  string res="";
  int i=0;
  while(i<t.size()&&t[i]>c){
    res+=t[i];
    i++;
  }
  res+=c;
  while(i<t.size()){
    res+=t[i];
    i++;
  }

  i=0;
  if(res.size()>s.size()) return res;
  if(res.size()<s.size()) return s;
  while(i<res.size()){
    if(res[i]>s[i]) return res;
    if(res[i]<s[i]) return s;
    i++;
  }

  return res;
}



signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n>>m;
  rep(i,m){
    int a;
    cin>>a;
    b[a]=true;
  }

 
  rep(i,n+1){
    rep(j,10){
      if(!b[j]) continue;
      int k=i-size(j);
      if(k<0||k!=0&&dp[k]=="") continue;
      dp[i]=f(dp[i],dp[k],j+'0');
      //cout<<i<<' '<<dp[i]<<endl;
    }
  }

  cout<<dp[n]<<endl;


}

Measured memory_bytes: 49280
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
  ll N;
  cin>>N;
  ll tmpN = N;
  vector<ll> primearr;
  for(ll i=2;i*i<=tmpN;++i){
    if(tmpN%i==0){
      primearr.push_back(i);
      while(tmpN%i==0) tmpN/=i;
    }
  }
  if(tmpN>1) primearr.push_back(tmpN);
  ll tmp;
  int num;
  ll ans = 0;
  for(int bit=0;bit<(1<<primearr.size());++bit){
    tmp = 1;
    num = 0;
    for(int i=0;i<primearr.size();++i){
      if((bit&(1<<i))==0) continue;
      tmp *= primearr[i];
      num++;
    }
    if(num%2==0){
      ans += N/tmp;
    }
    else{
      ans -= N/tmp;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3156
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n;
    cin >> n;
    if(n % 1000)
        cout << 1000 - n % 1000 << endl;
    else
        cout << 0 << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	int count = 0;
	vector <int> a(n);
	int mi;
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		if (i == 0) {
			mi = a[i];
		}
		if (mi >= a[i]) {
			count++;
		}
		mi = min(mi,a[i]);
	}
	cout << count << endl;
}



Measured memory_bytes: 1024
import java.util.Arrays;
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];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		if (A[0]!=0) {
			System.out.println(0);
			return ;
		}
		Arrays.parallelSort(A);
		if (N==1) {
			System.out.println(1);
			return ;
		}
		if (A[1]==0) {
			System.out.println(0);
			return ;
		}
		long B[] = new long[N];
		for (int i=1;i<N;i++) {
			if (A[i]!=A[i-1]&&A[i]!=A[i-1]+1) {
				System.out.println(0);
				return;
			}
			B[A[i]]++;
		}
		long count =1l;
		B[0]=1;
		for (int i=1;i<N;i++) {
			for (int j=0;j<B[i];j++) {
				count = (count *B[i-1])%998244353l;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 59556