akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

}


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

int  main(){
    int N;
    int a,b;
    int tmp = 1e9, ans = 0;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    for(int i = N-1; i >= 0 ; i--){
        if(tmp > d[i]){
            ans++;
            tmp = d[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n;
vl a(220000);
l_l f[220000];
vl dp(220000);
ll bit[220000];
void set_val(ll *bit,ll ind,ll val){
    ind++;
    while(ind<220000){
        bit[ind]=max(bit[ind],val);
        ind+=ind&-ind;
    }
    return;
}
ll max_val(ll *bit,ll ind){
    ind++;
    ll res=0;
    while(ind>0){
        res=max(res,bit[ind]);
        ind-=ind&-ind;
    }
    return res;
}
int main(){
    cin>>n;
    rep(i,n){
        ll h;cin>>h;
        f[i]={h,i};
    }
    sort(f,f+n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    rep(i,n){
        ll ni=f[i].se;
        dp[ni]=max_val(bit,ni-1)+a[ni];
        set_val(bit,ni,dp[ni]);
        ans=max(ans,dp[ni]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,0,n) cin >> p[i];
  sort(p.begin(),p.end());
  int sum = 0;
  rep(i,0,k) sum += p[i];
  cout << sum << endl;
  return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans = ((n-1)/x)*t+t;
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;

int main(void)
{
	int n, *p , x[3];
	cin >> n;
	p = new int[n];

	for (int i = 0; i < n; i++)
		cin >> p[i];

	int cnt=0;

	for (int i = 1; i < n - 1; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			x[j] = p[i - 1 + j];
		}

		if ((x[0] < x[1] && x[1] < x[2])|| x[0] > x[1] && x[1] >x[2])
			cnt++;
	}

	cout << cnt;
	delete p;

	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int maxn = 1e3 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}
int a[maxn][maxn];
int dp[maxn][maxn];


int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
	int n;cin>>n;
	for(int i = 1;i <= 2;i++) {
        for(int j = 1;j <= n;j++) {
            cin>>a[i][j];
        }
	}
	for(int i = 1;i <= 2;i++) {
        for(int j = 1;j <= n;j++) {
            a[i][j] += max(a[i - 1][j],a[i][j - 1]);
        }
	}
	cout<<a[2][n]<<endl;
    return 0;
}


Measured memory_bytes: 2304
using System;
using System.Linq;

class Program {
  static void Main() {
    var s = Console.ReadLine();
    Console.WriteLine(A(s) && B(s) && C(s) ? "AC" : "WA");
  }

  static bool A(string s) {
    return s[0] == 'A';
  }

  static bool B(string s) {
    return s.Substring(2, s.Length - 3).Count(x => x == 'C') == 1;
  }

  static bool C(string s) {
    foreach (var c in s.Where(x => x != 'A' && x != 'C')) {
      if (char.IsUpper(c)) return false;
    }
    return true;
  }
}

Measured memory_bytes: 11220
/* Remon Hasan - UAP-accepted*/
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long int

string repeat(string s, int n)
{
    string s1 = s;
    for (int i=1; i<n;i++)
        s += s1;

    return s;
}

int main ()
{
/*
  #ifndef ONLINE_JUDGE
  	freopen("input.txt", "r", stdin);
  	freopen("output.txt", "w", stdout);
  #endif
*/
    string s = "ACL";
    int n;
    cin>>n;
    cout << repeat(s, n) << endl;;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main (void)
{
	char s[3];
	int i,k,max=0;
	scanf("%s",s);
	for(i=0;i<=2;i++){
		k=0;
		if(s[i]=='R'){
			k++;
			if(s[i+1]=='R'){
				k++;
				if(s[i+2]=='R'){
					k++;
				}
			}
		}
		if(k>max){
			max=k;
		}
	}
	printf("%d",max);
	return 0;
}
						

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    if(x==y){
        pl(0)
    } else if(abs(x)==abs(y)){
        pl(1)
    } else if(x*y>=0 && y > x){
        pl(y - x)
    } else if(x*y>0  && x > y){
        pl(x - y + 2)
    } else if(x*y==0 && x > y){
        pl(x - y + 1)        
    } else {
        pl(abs(abs(x)-abs(y))+1)
    }
    
    return 0;
}

Measured memory_bytes: 256
//Eating Symbols Easy
#include <iostream>
using namespace std;

int main() {
    string s;
    cin>>s;
    int rst=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+')rst++;
        if(s[i]=='-')rst--;
    }
    cout<<rst<<endl;
}


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

int P = 0, Q = 0, R = 0;

int factor(itr &begin);
int num(itr &begin);
int expression(itr &begin);

int factor(itr &begin){
    if(*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    }
    else if(*begin == '-'){
            begin++;
            return 2 - factor(begin);
        }
    else {
        return num(begin);
    }
}

int num(itr &begin){
    int ret = 0;
    if(*begin == 'R') ret = R;
    else if(*begin == 'P') ret = P;
    else if(*begin == 'Q') ret = Q;
    else ret = *begin - '0';
    begin++;
    return ret;
}

int expression(itr &begin){
    int ret = factor(begin);
    for(;;){
        if(*begin == '*'){
            begin++;
            ret = min(ret, factor(begin));
        }
        else if(*begin == '+'){
            begin++;
            ret = max(ret, factor(begin));
        }
        else break;
    }
    return ret;
}

int main(){
    string s; 
    while(true){
        cin >> s;
        if(s == ".") return 0;
        int ans = 0;
        for(R=0; R<=2; R++){
            for(P=0; P<=2; P++){
                for(Q=0; Q<=2; Q++){
                    itr begin = s.begin();
                    int res = expression(begin);
                    if(res == 2) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3092
def resolve():
    N, K = [int(i) for i in input().split()]
    import math
    ans = 0
    for i in range(1, N + 1):
        if i < K:
            coin = math.ceil(math.log2(K / i))
            ans += (1 / N) * ((1 / 2)**coin)
        else:
            ans += (1 / N)
    print(ans)


resolve()


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

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (abs(a - b) <= w)
    cout << 0 << endl;
  else if (b < a)
    cout << a - (b + w) << endl;
  else
    cout << b - (a + w) << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 1000002
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

i64 a[maxn] , b[maxn] ;

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

    scanf("%lld",&n) ;

    for(i=1 ; i<=n; i++) scanf("%lld",&a[i]) ;
    for(i=1 ; i<=n; i++) scanf("%lld",&b[i]) ;

    i64 suma = 0 , sumb = 0 ;

    for(i=1 ; i<=n ; i++)
    {
        suma += a[i] ; sumb+= b[i] ;
    }

    i64 op = suma-sumb ;

    i64 x = 0 , y = 0 ;

    for(i=1 ; i<=n ; i++)
    {
        if( a[i]>=b[i] )
        {
            y += (a[i]-b[i]) ;
            b[i] = a[i] ;
        }
        else{
            if( a[i]%2==b[i]%2 )
            {
                x += (b[i]-a[i])/2 ;
                a[i] = b[i] ;
            }
            else{
                b[i]++ ;
                y++ ;
                x += (b[i]-a[i])/2 ;
            }
        }
    }

    if( x>=y )
    {
        i64 t = (x-y) ;
        x += t ;
        y += 2*t ;
        printf("Yes\n") ;
    }
    else printf("No\n") ;

    return 0 ;
}


Measured memory_bytes: 2432
#include<stdio.h>
main(){
  
  int n,m,i,j,ya[111111]={0},temp,ans=0;
  
  //入力
  scanf("%d %d",&n,&m);

  while(n!=0 && m!=0){
    for(i=0;i<n;i++){
      scanf("%d",&ya[i]);
    }
    
    //並び替え
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(ya[j]>ya[j-1]){
	  temp=ya[j];
	  ya[j]=ya[j-1];
	  ya[j-1]=temp;
	}
      }
    }
  
    //無料になる野菜を探す
    for(i=m-1;i<n;i+=m){
      ya[i]=0;
    }
    for(i=0;i<n;i++){
      ans+=ya[i];
    }
    
    //出力
    printf("%d\n",ans);
    scanf("%d %d",&n,&m);
    ans=0;
  }
  
  return 0;
}

Measured memory_bytes: 1040
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  string S;
  in(S);
  ll N=S.size();
  vector<ll>T(N);
  T[N-1]=1;
  dw(i,N-1,1)T[i-1]=T[i]*10%2019;
  map<ll,ll>cnt;
  ll mod=0,ans=0;
  cnt[0]=1;
  rep(i,N){
    mod=(mod+(S[i]-'0')*T[i])%2019;
    ans+=cnt[mod]++;
  }
  out(ans);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 5128
n = int(input())

v = [i for i in input().split()]

v1 = {}

v2 = {}

for i in range(n//2):
    if  v[2 *i +1] in v1.keys():
        v1[v[2 * i +1]] += 1
    else:
        v1[v[2 * i + 1]] = 1

    if v[2 * i] in v2.keys():
        v2[v[2 * i]] += 1
    else:
        v2[v[2 * i]] = 1


v1 = sorted(v1.items(),key=lambda x:  x[1])
v2 = sorted(v2.items(),key=lambda x:  x[1])
v1.reverse()
v2.reverse()
v1.append((None,0))
v2.append((None,0))
#print(v1)
if v1[0][0] == v2[0][0]:
    ans = max(v1[0][1]+v2[1][1] , v1[1][1] + v2[0][1])
else:
    ans = v1[0][1] + v2[0][1]

print(n - ans)

Measured memory_bytes: 20120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p)
{
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

typedef long long ll;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);

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

    int ans = 1000000007;

    for (int i = 1; i < n; i++)
    {
        ans = min(gcd(a[i], a[i - 1]), ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read

n, d = map(int, input().split())
xy = np.array(read().split(), dtype=np.int64)
x = xy[::2]
y = xy[1::2]
ans = np.count_nonzero(x**2 + y**2 <= d**2)
print(ans)

Measured memory_bytes: 71316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for (int i = s; i < (int)(n); i++)
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vstr = vector<string>;
const ll MOD=1000000007;
vll dx{0,1,0,-1};
vll dy{1,0,-1,0};
int i,j,k,h,n,m,a,b,c;
ll res,ans;

template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

template <class type> void inputVector(vector<type>& vec){
    for(ll i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
}

void solve(){
    ll h;
    cin >> n >> h;
    vll b(n);
    ll ma=0;
    rep(i,0,n){
        ll a;cin>>a>>b[i];
        ma=max(a,ma);
    }
    sort(b.rbegin(),b.rend());
    res=0;
    for(i=0;ma<b[i];i++)
    {
        h-=b[i];
        res++;
        if(h<=0)break;
    }
    if(0<h)res+=ceil((double)h/ma);
    cout<<res;
}

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

Measured memory_bytes: 4040
#include <stdio.h>

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void){
    int x[5];
    int j;
    scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
    while(1) {
        int i;
        int count;
        count = 0;
        for(i = 0; i < 5 - 1; i++){
            if(x[i] < x[i + 1]) {
                swap(x + i, x + (i + 1));
                count ++;
            }
        }
        if(count == 0) {
            break;
        }
    }
    for(j = 0; j < 5; j++) {
        if(j < 4)
            printf("%d ", x[j]);
        else
            printf("%d", x[j]);
    }

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

Measured memory_bytes: 600
while 1:
    N, H = map(int, input().split())
    if N == H == 0:
        break
    s = set()
    for i in range(H):
        c, a, b = input().split(); a = int(a)-1; b = int(b)-1
        if c == "xy":
            s.update((a, b, i) for i in range(N))
        if c == "xz":
            s.update((a, i, b) for i in range(N))
        if c == "yz":
            s.update((i, a, b) for i in range(N))
    print(N**3 - len(s))



Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int n, m, q;
vecint a, b, c, d;
int ans;
vecint pos;
int cnt;
int dfs(int depth, int i) {
  if (depth != -1) {
    pos[depth] = i;
  }
  int res = 0;
  if (depth == n - 1) {
    // REP(i, n) cout << pos[i] << " ";
    // cout << endl;
    cnt++;
    REP(j, q) {
      if (pos[b[j]] - pos[a[j]] == c[j]) {
        res += d[j];
      }
    }
    return res;
  } else {
    for (int j = i; j <= m; j++) {
      res = max(res, dfs(depth + 1, j));
    }
    return res;
  }
}
////////////////////////////////////////////////
int main() {
  init();
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  REP(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  cnt = 0;
  pos.resize(n);
  cout << dfs(-1, 1) << endl;
  // cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define LINY "YES\n"
#define LINN "NO\n"
#define umap unordered_map

int N,a,ok=1;
umap<int,int> mp;
int main(){
  cin>>N;
  REP(i,N){
    cin >> a;
    if(mp[a]==0){++mp[a];}
    else{ok=false;break;}
  }
  cout <<(ok?LINY:LINN);
}

Measured memory_bytes: 8520
#include<iostream>
using namespace std;
int main(){


	int H,W,i,o,p,a,g;
 
   for(p=0;p<300;p++)//全てのループ
   {
       cin>>H>>W;
       if(H==0 && W==0)
       {
           break;
       }
       
	   for(i=0;i<W;i++)
	   {
		   cout<<"#";
	   }
	   cout<<endl;
	   for(o=0;o<H-2;o++)
	   {
		   cout<<"#";
		   for(a=0;a<W-2;a++)
		   {
			   cout<<".";
		   }
		   cout<<"#";
		   cout<<endl;


	   }
	   for(g=0;g<W;g++)
	   {
		   cout<<"#";
	   }
	   cout<<endl;

	   
	   cout<<endl;
   }
 
     
		   


		 
      
     
   


	return 0;
}


Measured memory_bytes: 3080
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

const int maxn = 2000009;

void solve(){
    
   double n;
   cin >> n;

   cout << fixed << setprecision(12) << pow(n/3.0,3)<< endl;
    

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        
        solve();
        //cout << endl;
    }
    return 0;
} 

 


Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
s = input()
l = []
for i in s:
  if i==".":
    l.append(0)
  else:
    l.append(1)
l1 = list(accumulate([0]+l))
#print(l1)
l = []
for i in s[::-1]:
  if i==".":
    l.append(1)
  else:
    l.append(0)
l2 = list(accumulate([0]+l))[::-1]
#print(l2)
cou = 10**6
if "#" not in s or "." not in s :
  print(0)
else:
  #左が"."　右が"#"  左は#の個数調べて右は.の個数調べる
  for j,k in zip(l1,l2):
    a = j+k
    cou = min(cou,a)
  print(cou)
  

Measured memory_bytes: 23856
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define int long long
using namespace std;

int INF = 1e+18;
int a[3], d;
map<int, int> dp;

int dfs(int n) {
	if (n <= 1) return n * d;
	if (dp.find(n) != dp.end()) return dp[n];
	
	vector<int> ks = {2, 3, 5};
	int res, ret = (n <= INF / d) ? n * d : INF;
	for (int i = 0; i < 3; i++) {
		int k = ks[i];
		int l = n / k; l *= k;				//l <= n, lはkの倍数となるlの最大
		int r = (n + k - 1) / k; r *= k;	//n <= r, rはkの倍数となるrの最小
		
		if (n - l <= ret / d) {
			res = dfs(l / k) + d * (n - l) + a[i];
			ret = min(ret, res);
		}
		if (r - n <= ret / d) {
			res = dfs(r / k) + d * (r - n) + a[i];
			ret = min(ret, res);
		}
	}
	return dp[n] = ret;
}

void solve() {
	int n;
	cin >> n >> a[0] >> a[1] >> a[2] >> d;
	dp.clear();
	cout << dfs(n) << endl;
}

signed main() {
	int T; cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4312
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B = ri_()
print('Yay!' if max(A, B) <= 8 else ':(')


Measured memory_bytes: 63724
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

ll total = 0;
set<string> smallest;
set<string> largest;

void dfs(string &str, size_t cur, int mask){
  if (cur == str.size()){
    total++;
    smallest.insert(str);
    largest.insert(str);

    if ((int)smallest.size() > 10){
      smallest.erase(*smallest.rbegin());
      largest.erase(*largest.begin());
    }
  } else {
    int offset = str[cur] - 'a';
    
    if (str[cur] == 'a' || (mask & (1 << offset))){
      dfs(str, cur + 1, mask);
    }

    if (str[cur] < 'z' && !(mask & (1 << (offset + 1)))){
      mask |= (1 << (offset + 1));
      str[cur]++;
      dfs(str, cur + 1, mask);
      str[cur]--;
    }
  }
}

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

  string str;
  while (cin >> str && str != "#"){

    total = 0;
    smallest.clear();
    largest.clear();
    
    dfs(str, 0, 0);

    cout << total << endl;
    if ((int)smallest.size() < 10){
      for (const auto &str : smallest) cout << str << endl;
    } else {
      vector<string> vs;
      for (const auto &str : smallest) vs.push_back(str);
      for (const auto &str : largest ) vs.push_back(str);
      sort(ALL(vs));
      vs.erase(unique(ALL(vs)), vs.end());

      REP(i, 5) cout << vs[i] << endl;
      REP(i, 5) cout << vs[vs.size() - 5 + i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>


using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> hs(n), ps(n);
    priority_queue<pair<li, li>> q;
    for (int i = 0; i < n; ++i) {
        cin >> hs[i] >> ps[i];
        q.emplace(-hs[i] - ps[i], i);
    }

    const li inf = 1LL << 60;
    vector<li> min_tall(n + 1, inf);
    min_tall[0] = 0;
    li ans = 0;
    while (not q.empty()) {
        li i = q.top().second; q.pop();

        for (int j = n - 1; j >= 0; --j) {
            if (min_tall[j] <= hs[i]) {
                li next_tall = min_tall[j] + ps[i];
                if (next_tall < min_tall[j + 1]) {
                    min_tall[j + 1] = next_tall;
                    ans = max(ans, j + 1LL);
                }
            }
        }
    }

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


Measured memory_bytes: 512
def make_card(i, card):
    suit, value = card.split()
    return (int(value), i, card)


def partition_stable(a, p, r):
    x, i = a[r], p - 1
    for j in range(p, r):
        if a[j] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    i += 1
    a[i], a[r] = a[r], a[i]
    return i


def partition_not_stable(a, p, r):
    x, i = a[r][0], p - 1
    for j in range(p, r):
        if a[j][0] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    i += 1
    a[i], a[r] = a[r], a[i]
    return i


def quick_sort(a, p, r, func):
    if p < r:
        q = func(a, p, r)
        quick_sort(a, p, q - 1, func)
        quick_sort(a, q + 1, r, func)


n = int(input())
a = list(make_card(i, input()) for i in range(n))
b = a[:]

quick_sort(a, 0, n - 1, partition_not_stable)
quick_sort(b, 0, n - 1, partition_stable)
print(('S' if a == b else 'Not s') + 'table')
print('\n'.join(card[2] for card in a))

Measured memory_bytes: 30392
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    if (s=="ABC") cout << "ARC" << '\n';
    else cout << "ABC" << '\n';
    return 0;
}

Measured memory_bytes: 3552
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
struct edge{
	int to;
	edge *nxt;
}edges[MAXN + 5], *adj[MAXN + 5], *ecnt = &edges[0];
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
}
struct node{
	int ind; int dep;
}a[MAXN + 5];
bool operator < (node a, node b) {
	return a.dep < b.dep;
}
int N, K;
int fa[MAXN + 5], vis[MAXN + 5], rev[MAXN + 5];
void dfs(int rt) {
	for(edge *p=adj[rt];p!=NULL;p=p->nxt) {
		a[p->to].dep = a[rt].dep + 1;
		dfs(p->to);
	}
}
void dfs2(int rt) {
	if( vis[rt] ) return ;
	vis[rt] = true;
	for(edge *p=adj[rt];p!=NULL;p=p->nxt)
		dfs2(p->to);
}
int main() {
	int ans = 0;
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++) {
		scanf("%d", &fa[i]);
		if( i != 1 ) addedge(fa[i], i);
		else if( fa[i] != 1 ) ans++;
		a[i].ind = i;
	}
	dfs(1);
	sort(a+1, a+N+1);
	for(int i=N;i>=1;i--) {
		if( a[i].dep <= K ) break;
		if( vis[a[i].ind] ) continue;
		ans++; int x = a[i].ind;
		for(int j=1;j<K;j++)
			x = fa[x];
		dfs2(x);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 2;

int main()
{
    int d, s, t;
    cin>>d>>t>>s;
    int time = (d + s - 1)/s;
    if(time <= t) cout<<"Yes\n";
    else cout<<"No\n";
}




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

int main() {
    int n;
    cin >> n;

    int taro_point = 0;
    int hanako_point = 0;
    vector<string> cards(2);

    for(int i=0; i<n; ++i) {
        string taro, hanako;
        cin >> taro >> hanako;

        if (taro == hanako) {
            taro_point++;
            hanako_point++;
        } else {
            cards[0] = taro;
            cards[1] = hanako;
            sort(cards.begin(), cards.end());
            if (cards[1] == taro) {
                taro_point += 3;
            } else if (cards[1] == hanako) {
                hanako_point += 3;
            }
        }
    }

    cout << taro_point << " " << hanako_point << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 a, p;
  cin >> a >> p;
  cout << (a * 3 + p) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import heapq
from collections import defaultdict, deque
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n=r()
a=[1]*(n+1)
cnt=1
for i in range(2,n+1):
    for j in range(i,n+1,i):
        a[j]+=1
    cnt+=i*a[i]
print(cnt)

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

using namespace std;

int main()
{
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> p(a), q(b);
  for (int &i : p)
    cin >> i;
  for (int &i : q)
    cin >> i;
  vector<vector<int>> discount(m, vector<int>(3, 0));
  for (int i = 0; i < m; i++)
  {
    cin >> discount[i][0] >> discount[i][1] >> discount[i][2];
  }
  int minp = INT_MAX, minq = INT_MAX;
  for (int i : p)
    minp = min(minp, i);
  for (int i : q)
    minq = min(minq, i);
  int ans = minp + minq;
  for (int i = 0; i < m; i++)
  {
    ans = min((p[discount[i][0] - 1] + q[discount[i][1] - 1] - discount[i][2]), ans);
  }
  cout << ans << "\n";
}


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

int main(){
    string S;
    set<char> tmp;
    cin >> S;

    bool ok = true;
    rep(i, S.size()){
        tmp.insert(S[i]);
    }

    if(S.size() != tmp.size()) ok = false;

    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s1,s2;
int ans;
signed main()
{
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	ans+=(s1[i]!=s2[i]);
	printf("%lld",ans);
	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	int w = 0, r = 0;
	for(int i = 0; i < n; i++) {
		w += s[i] == 'W';
		r += s[i] == 'R';
	}
	int cnt = 0;
	for(int i = n - w; i < n; i++) {
		cnt += s[i] == 'R';
	}
	printf("%d\n", cnt);
}

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

int main() {
    ll n; cin >> n;
    ll ans = (ll) 1e13-1;
    for (ll i = 1; i <= sqrt(n)+1; i++)
    {
        if (n % i == 0) {
            ans = min(ans, n/i-1 + i-1);
        }
    }
    cout << min(ans, n-1) << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
d = {1:-1, 2:-1, 3:-1}

for _ in range(M):
    s, c = map(int, input().split())
    if d[s]!=-1 and d[s]!=c:
        print(-1)
        break
    d[s] = c
else:
    for i in list(range(10**(N-1) + (-1 if N==1 else 0), 10**N)):
        n = i
        for j in range(1, N+1)[::-1]:
            if not (d[j] == -1 or d[j] == i%10):
                break
            i//=10
        else:
            print(n)
            break
    else:
        print(-1)


Measured memory_bytes: 3064
object Main extends App {
  import scala.io.StdIn._


  val n = readInt
  val persons = Array.tabulate(n){_ ⇒
    val Array(ash, asm, aeh, aem, bsh, bsm, beh, bem, csh, csm, ceh, cem) = readLine.trim.split(' ').map(_.toInt)
    Person(IntRange(ash * 60 + asm, aeh * 60 + aem), IntRange(bsh * 60 + bsm, beh * 60 + bem), IntRange(csh * 60 + csm, ceh * 60 + cem))
  }
  println(
    (0 until n).map(a ⇒ (0 until n).map(b ⇒ (0 until n).map(c ⇒ persons.count(_.canEatAll(persons(a).breakFirst.from, persons(b).lunch.from, persons(c).dinner.from))).max).max).max
  )
  case class Person(breakFirst: IntRange, lunch: IntRange, dinner: IntRange){
    def canEatAll(breakFirstTime: Int, lunchTime: Int, dinnerTime: Int): Boolean = breakFirst.contains(breakFirstTime) && lunch.contains(lunchTime) && dinner.contains(dinnerTime)
  }
  case class IntRange(from: Int, to: Int) {
    def contains(value: Int): Boolean = from <= value && value <= to
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


Measured memory_bytes: 53996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int[] a = new int[4];
			int[] b = new int[4];
			boolean[] bl = new boolean[10];
			for(int i=0;i<4;i++) {
				a[i] = sc.nextInt();
				bl[a[i]] = true;
			}
			for(int i=0;i<4;i++) {
				b[i] = sc.nextInt();
			}
			int hit = 0;
			int blow = 0;
			for(int i=0;i<4;i++) {
				if (b[i] == a[i]) {
					hit++;
				}else if(bl[b[i]]) {
					blow++;
				}
			}
			System.out.println(hit + " " + blow);
		}
	}

}

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

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

const INF: i64 = 1 << 60;

fn main() {
    input!{
        s: chars,
        t: chars,
    }
    let n = s.len();
    let m = t.len();
    let mut dp = vec![vec![0; m + 10]; n + 10];
    dp[0][0] = 0;
    for i in 1..(n+1) {
        for j in 1..(m+1) {
            chmax!(dp[i][j], dp[i-1][j]);
            chmax!(dp[i][j], dp[i][j-1]);
            if s[i-1] == t[j-1] {
                chmax!(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
    }
    let mut ans = String::new();
    let (mut i, mut j) = (n, m);
    while i > 0 && j > 0 {
        if dp[i][j] == dp[i-1][j] {
            i -= 1;
        } else if dp[i][j] == dp[i][j-1] {
            j -= 1;
        } else if dp[i][j] == dp[i-1][j-1] + 1 {
            ans.push(s[i-1]);
            i -= 1; j -= 1;
        }
    }
    let ans = ans.chars().rev().collect::<String>();
    println!("{}", ans);
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int num[100002] = {};
    num[1] = 1;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        num[a]++, num[b + 1]--;
    }
    int ans = 1;
    repl(i, 2, n + 2) {
        num[i] += num[i - 1];
        if (i <= num[i]) ans = i;
    }
    cout << ans - 1 << endl;

    return 0;
}

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

#define QUESIZE 100001

typedef struct{
	char name[11];
	int time;
} process;

void que_enqueue(process);
process que_dequeue(void);
int que_size(void);
int que_free(void);
int que_empty(void);
void que_clear(void);

process que[QUESIZE];
int head=0, tail=0;

void que_enqueue(process n)
{
  tail=(tail+1)%QUESIZE;
  que[tail]=n;
}

process que_dequeue(void)
{
  head=(head+1)%QUESIZE;
  return que[head];
}

int que_size(void)
{
  if(head < tail) return tail-head;
  else return tail-head+QUESIZE;
}

int que_free(void)
{
  return QUESIZE-1-que_size();
}

int que_empty(void)
{
  return head==tail;
}

void que_clear(void)
{
  head = tail = 0;
}

int main(void){
	int n,q;
	int i;
	int Mom=0;
	process q_in,q_out;
	scanf("%d %d",&n,&q);
	for(i=0;i<n;i++){
		scanf("%s %d",q_in.name,&q_in.time);
		que_enqueue(q_in);
	}
	while(1){
		if(que_empty()) break;
		
		q_out=que_dequeue();
		if(q_out.time <= q){
			Mom += q_out.time;
			printf("%s %d\n",q_out.name,Mom);
		}
		else{
			Mom += q;
			q_out.time -= q;
			que_enqueue(q_out);
		}
	}
	return 0;
}

Measured memory_bytes: 3356
//Lucas Number

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    ll n;cin>>n;
    vector<ll>a(86);
    a[0]=2;a[1]=1;
    rep(i,2,87){
        a[i]=a[i-1]+a[i-2];
    }
    cout << a[n]<< endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
ans=0
a=sum(L)
mod=1000000007
for i in range(N):
  ans+=L[i]*(a-L[i])
  ans%=mod
if ans%2==0:
  print(ans//2)
else:
  print((ans+mod)//2)

Measured memory_bytes: 31752
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;
 
typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l,r;
    cin>>l>>r;
    if(r-l>3000) {
        cout<<0<<endl;
    }
    else {
        int res = 3000;
        rep(i,l,r) {
            rep(j,i+1,r+1) {
                res = min(res,int((i*(ll)j)%2019));
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
def bfs(s):
    visited=[-1]*n
    q=deque([s])
    visited[s]=0
    while q:
        x=q.popleft()
        for nx in edge[x]:
            if visited[nx]==-1:
                visited[nx]=visited[x]+1
                q.append(nx)
    return visited
visited1=bfs(0)
visitedn=bfs(n-1)
dist=visited1[n-1]-1
if dist%2:
    for i in range(n):
        if visited1[i]==-(-dist//2) and visitedn[i]==-(-dist//2):
            a=i
        if visited1[i]==-(-dist//2)+1 and visitedn[i]==-(-dist//2)-1:
            b=i
else:
    for i in range(n):
        if visited1[i]==-(-dist//2) and visitedn[i]==-(-dist//2)+1:
            a=i
        if visitedn[i]==-(-dist//2) and visited1[i]==-(-dist//2)+1:
            b=i
edge[a].remove(b)
edge[b].remove(a)
visited=[0]*n
q=deque([0])
visited[0]=1
while q:
    x=q.popleft()
    for nx in edge[x]:
        if visited[nx]==0:
            visited[nx]=1
            q.append(nx)
fs=sum(visited)+(-dist//2)-1
ss=n-sum(visited)-dist//2-1
if dist%2:
    if fs>=ss:
        print("Fennec")
    else:
        print("Snuke")
else:
    if fs>ss:
        print("Fennec")
    else:
        print("Snuke")

Measured memory_bytes: 34824
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
bool cmp(int a,int b){return a>b;}
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
        if(i+1>a[i+1])
        {
        	int ans=0;
            for(int j=i+1;a[j]>=i&&j<=n;++j)ans^=1;
            ans|=(a[i]-i)&1;
            if(ans)puts("First");
            else puts("Second");
            return 0;
		}
	}
}

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

A = list(map(int,input().split()))

ans = 0


for i in range(N):

    A[i] -= i + 1

A.sort()



if N % 2 != 0:

    kz = A[ N // 2 ]

elif A[N // 2] - A[N // 2 - 1] > 1:
    kz = A[ N // 2 ] - 1

else:
    kz = A[ N // 2 ]


for i in A:

    i -= kz

    if i < 0:
        ans -= i
    else:
        ans += i

print (ans)



        


Measured memory_bytes: 25196