akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define int long long
#define Maxn 200000
priority_queue<pair<int,int> >q;
int n,m,b[Maxn+5],a[Maxn+5],pre[Maxn+5],nxt[Maxn+5];
signed main(){
	int i,j,k,ans=0;
	scanf("%lld",&n);
	for(i=1; i<=n; i++)scanf("%lld",&a[i]);
	for(i=1; i<=n; i++) {
		scanf("%lld",&b[i]);
		q.push(mp(b[i],i));
	}
	for(i=1; i<=n; i++) {
		nxt[i]=i+1;
		pre[i]=i-1;
	}
	pre[1]=n;
	nxt[n]=1;
	while(!q.empty()) {
		int x=q.top().se;
		q.pop();
		if(b[x]==a[x])continue;
		int y=pre[x],z=nxt[x];
		if(b[x]-b[y]-b[z]<a[x]) {
			puts("-1");
			return 0;
		}
		k=b[x]-a[x];
		ans+=k/(b[y]+b[z]);
		b[x]=(k%(b[y]+b[z]))+a[x];
		if(a[x]!=b[x])q.push(mp(b[x],x));
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 10604
x = int(input())
beki = []

for i in range(1000):
    for j in range(2,10):
        k = i**j
        if k >1000:
            break
        else:
            beki.append(k)
            
for i in range(x):
    if x-i in beki:
        print(x-i)
        break

Measured memory_bytes: 2940
#include<cstdio>
// printf scanf //
#include<cctype>
// 文字の判別、変換 //

using namespace std;
int main(){
    char ch;
    //chを文字型の箱にしましたよ！//
    
    while(1){
        scanf("%c",&ch);
        if (isalpha(ch)){
            if (islower(ch)) printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        } else printf("%c",ch);
        
        if (ch == '\n') break;
    }
    return 0;
}
    


Measured memory_bytes: 2608
#include <stdio.h>
#include <string.h>

int main()
{
    int a,b;
    scanf("%d%d", &a,&b);
    
    for( int p=0; p<1250; p++ )
    {
        if ( (int) (p * 0.08) == a && (int) (p * 0.1) == b ){
            printf("%d\n",p);
            return 0;
        }
    }
    
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define ipr pair<ll,ll>
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 998244353
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll x,y;
    x=((a+d-1)/d);
    y=((c+b-1)/b);
    if(x>=y){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
	int a,b,dig,sum;
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		dig=0;
		sum=a+b;
		while(sum)
		{
			dig++;
			sum=sum/10;
		}
		printf("%d\n",dig);
	}
	return 0;
}

Measured memory_bytes: 1028
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

k,s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        d = s - i - j
        if d>=0 and d<=k:
            cnt+=1

print(cnt)

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

    using namespace std;

    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(),a.end()
    #define PB push_back

    typedef long long LL;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = INF * (LL)INF;
    const int MAS =4e5; //5;
    const int MOD = 1e9 + 7;
    const double EPS = 1e-8;


    int main() {
        IOS
        //   freopen("series.in","r",stdin);
        //   freopen("series.out","w",stdout);
        int n ;
        cin >> n ;
        string s;
        cin >> s;
        vector<vector<int >> dp(n + 10 ,vector<int > (n + 10 ) );
        dp[1][1] = 1;
        FOR(len,2,n + 1)
         {
            vector<int > pref(len);

            FOR(i,1,len)
            {
               pref[i] = (pref[i-1] + dp[len-1][i] )%MOD ;
            }

            FOR(newdigit,1,len + 1)
            {
               int l,r;
               if(s[len-2] == '<')
               {
                   l =1 ;
                   r =  newdigit - 1;
               }
               else
               {
                   l = newdigit  ;
                   r = len -1;
               }
               if( l  <=r)
               {
                  dp[len][newdigit]+= ( pref[r] - pref[l-1] + MOD  ) %MOD ;
               }
            }
        }
        LL ans = 0 ;
        FOR(i,1,n + 1)
        {
            ans+=dp[n][i];
        }
        cout << ans%MOD;

    }

Measured memory_bytes: 35712
import java.util.*;

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

        int sum = 0;
        int maxL = 0;
        for (int i = 0; i < n; ++i) {
            int l = scan.nextInt();
            maxL = Math.max(maxL, l);
            sum += l;
        }

        if (maxL < sum - maxL) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

void _main(istream &inp){
    ll k,a,b;
    inp >> k >> a >> b;
    k += 1;
    ll ret = k;
    if(b>a+2 && k-a>=0 ){
        ll koukan_kaisu = (k-a)/2;
        ll tataku_kaisu = k - koukan_kaisu*2;
        ret = tataku_kaisu + koukan_kaisu * (b-a);
    }
    cout << ret << endl;

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 256
import sys
#import time

compare_counter = 0
array = [0 for x in range(500000)]

def merge(left, mid, right):
    n_fore = mid - left
    n_rear = right - mid
    l_fore = array[left:left + n_fore]
    l_fore.append(sys.maxsize)
    l_rear = array[mid:mid + n_rear]
    l_rear.append(sys.maxsize)

    #print(left, mid, right)
    i = j = 0
    global compare_counter
    compare_counter += (right - left)
    for k in range(left, right):
        if l_fore[i] < l_rear[j]:
            array[k] = l_fore[i]
            i += 1
        else:
            array[k] = l_rear[j]
            j += 1


def merge_sort(left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(left, mid)
        merge_sort(mid, right)
        merge(left, mid, right)
    return


def main():
    #start = time.time()
    n = int(input())
    for idx, tmp in enumerate(input().split()):
        array[idx] = int(tmp)
    #print("time", time.time()-start)
    merge_sort(0, n)
    #print("time", time.time()-start)
    print(" ".join(map(str, array[:n])))
    print(compare_counter)
    #print("time",time.time()-start)
    return


main()


Measured memory_bytes: 65740
a = []
a[:] = map(int, input().split())
for i in range(1,3):
    v = a[i]
    j = i-1
    while (j>=0 and a[j]>v):
        a[j+1] = a[j]
        j-=1
        a[j+1]=v
s = map(str, a)
print(' '.join(s))



Measured memory_bytes: 5600
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    sp1=min(q,h,s)
    dp2=min(2*q,2*h,2*s,d)

    if n%2==0:
        c=n//2
        print(c*dp2)
    # elif n%2!=0:
    else:
        c=n//2
        print(c*dp2+sp1)
    # else:
    #     print(n*sp1)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 9068
A, B, K = map(int, input().split())

if K-A >= 0:
    t_num = 0
    a_num = B - (K-A)
    if a_num < 0:
        a_num = 0
elif K-A < 0:
    t_num = A-K
    a_num = B

print(t_num,a_num)

Measured memory_bytes: 3060
N, A, B = input().split()

N = int(N)
A = int(A)
B = int(B)

sum = 0
sum_digit = 0

for i in range(N + 1):
  for j in list(str(i)):
    sum_digit += int(j)
  if A <= sum_digit <= B:
    sum += i
  sum_digit = 0

print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=1e5+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif
void solve() {
    int n , k;
    cin >> n >> k;
    map< int , int > mp;
    for(int i=1 ; i<=n ;i++){
        mp[i] = 0;
    }
    while(k--){
        int di;
        cin >> di;
        while(di--){
            int x;
            cin >>x;
            mp[x]++;
        }
    }
    int cnt=0;
    for(int i=1; i<=n ; i++){
        if(mp[i]==0){
            cnt++;
        }
    }
    cout << cnt << endl;

}
signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 3608
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static long mod = 1000000007;

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    ModInt ans = new ModInt(2, mod);
    pw.println(
      ans.pow(n)
        .minus(1)
        .minus(combination(n, a))
        .minus(combination(n, b))
    );
  }

  static ModInt combination(int n, int a) {
    ModInt x = new ModInt(1, mod);
    ModInt y = new ModInt(1, mod);
    for (int i = 0; i < a; i++) {
      x = x.multiplicity(n - i);
      y = y.multiplicity(i + 1);
    }
    return x.divide(y);
  }

  static class ModInt {

    private final long mod;
    private long x;

    ModInt(long x, long mod) {
      this.x = x;
      this.mod = mod;
    }

    ModInt(ModInt m) {
      this.x = m.x;
      this.mod = m.mod;
    }

    ModInt add(long m) {
      ModInt n = new ModInt(this);
      n.x += m;
      n.x %= mod;
      return n;
    }

    ModInt add(ModInt m) {
      return this.add(m.x);
    }

    ModInt minus(long m) {
      ModInt n = new ModInt(this);
      if ((n.x += (mod - m)) >= mod) {
        n.x -= mod;
      }
      return n;
    }

    ModInt minus(ModInt m) {
      return this.minus(m.x);
    }

    ModInt multiplicity(long m) {
      ModInt n = new ModInt(this);
      n.x *= m;
      n.x %= mod;
      return n;
    }

    ModInt pow(long p) {
      if (p == 0) {
        return new ModInt(1, mod);
      }
      ModInt a = pow(p >> 1);
      a = a.multiplicity(a.x);
      if ((p & 1) == 1) {
        a = a.multiplicity(x);
      }
      return a;
    }

    ModInt inv() {
      return pow(mod - 2);
    }

    ModInt divide(ModInt d) {
      ModInt n = new ModInt(this);
      n = n.multiplicity(d.inv().x);
      return n;
    }

    @Override
    public String toString() {
      return String.valueOf(x);
    }
  }
}


Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i, n) {
        ll a;
        cin >> a;
        q.push(a);
    }
    rep(i, m) {
        ll v = q.top();
        q.pop();
        v /= 2;
        q.push(v);
    }

    ll ans = 0;

    rep(i, n) {
        ll v = q.top();
        q.pop();
        ans += v;
    }
    
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000000000;
const double PI = acos(-1);

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){

    
    //累積和を取りながらDP
    int N,K;
    cin >> N >> K;
    
    vi a(N);
    in(N,a);
    
    vvl dp(N+1,vl(K+1,0));
    vl dps(K+1,0);
    dps[0] = 1;
    dp[0][0] = 1;
    
    rep(i,N){
        rep(j,K+1){
            dp[i+1][j] = (dp[i][j] + dps[max(0,j-a[i])]+mod-dps[j])%mod;
        }
        dps[K] = dp[i+1][K];
        for (int j = K-1; j >= 0; j--) {
            dps[j] = (dps[j+1] + dp[i+1][j])%mod;
        }
    }
    
    //outmat(dp);
    cout << dp[N][K] << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 80256
program sample
	implicit none
    integer(8) :: K,A,B
    
    read(*,*) K
    read(*,*) A,B
    
	if ((A-1)/K == B/K) then
    	write(*,*) 'NG'
    else
    	write(*,*) 'OK'
    end if

    stop
end program sample


Measured memory_bytes: 2796
#AtCoder Grand Contest 019 a
q,h,s,d=map(int,input().split())#0.25,0.5,1,2
d=min(d,s*2,h*4,q*8)
s=min(s,h*2,q*4)

n=int(input())
if n%2==0:
    print(n//2*d)
else:
    print(n//2*d+s)


Measured memory_bytes: 9052
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  int64 ans=0;
  for(i=0;i<n-1-i;i++){
    ans+=2*(a[n-1-i]-a[i]);
  }
  if(n%2!=0){
    int m=n/2;
    ans-=MIN(a[m]-a[m-1],a[m+1]-a[m]);
  } else {
    ans-=a[n/2]-a[n/2-1];
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    string s;
    cin >> s;
    rep(i, s.size() - 8)
    {
        cout << s[i];
    }
    cout << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n - 1];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        for(int i = 0; i < n; i++){
            b[i] = sc.nextInt();
        }

        for(int i = 0; i < n - 1; i++){
            c[i] = sc.nextInt();
        }

        int result = b[a[0] - 1];


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

            if(a[i] - a[i - 1] == 1){
                result += c[a[i - 1] - 1];
            }
        }

        System.out.println(result);
    }
}

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

for i in range(n):
    if b[i] >= a[i]:
        ans += a[i]
        if max(0,(a[i+1]-(b[i]-a[i]))) == 0:
            ans += a[i+1]
            a[i+1] = 0
        else:
            ans += (b[i]-a[i])
            a[i+1] -= (b[i]-a[i])
    else:
        ans += b[i]
print(ans)

Measured memory_bytes: 24224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            list.add(new int[]{sc.nextInt(), sc.nextInt()});
        }

        Collections.sort(list, Comparator.comparing(a -> a[1]));

        int count = 0;
        int prev = 0;
        if (!list.isEmpty()) {
            count = 1;
            prev = list.get(0)[1] - 1;
        }

        for (int i = 1; i < list.size(); i++) {
            int[] ab = list.get(i);

            if (ab[0] <= prev) {
                continue;
            }

            count++;
            prev = ab[1] - 1;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 93280
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    s=readline().rstrip()
    t=readline().rstrip()

    ans=0
    for i in range(3):
        if s[i]==t[i]:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 5632
n = int(input())
S = str(input())
ss = sorted((set(list(S))))
k = []
for i in range(len(ss)):
	k.append(S.count(ss[i])+1)
tmp = 1
for i in range(len(k)):
	tmp *= k[i]
ans = tmp - 1
anss = ans % (10**9+7)
print(anss)

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s < t){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
	

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

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> hoge(n + 1);
  hoge[0] = 0;
  int sum = 0;
  int tmp = 0;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    sum += tmp;
    hoge[i + 1] = sum;
  }

  int count = 0;
  for (int i = 0; i < hoge.size(); i++){
    if (hoge[i] > x){
      cout << i << endl;
      return 0;
    }
    if (i == n){
      cout << (i + 1) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n = gets.to_i
arr = n.times.map{gets.chomp}

list = {}
count = 0

for s in arr
  k = s.split('').sort.join
  if list.has_key?(k)
    list[k] += 1
  else
    list[k] = 1
  end
end

list.each do |k, v|
  if v > 1
    count += v * (v - 1) / 2
  end
end
puts count

Measured memory_bytes: 26620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll k,n;
    cin>>k>>n;
    ll a[n],ans=0;
    rep(0,i,n){
        cin>>a[i];
        if(i!=0){
            ans=max(a[i]-a[i-1],ans);
        }
    }
    ans=max(a[0]+k-a[n-1],ans);
    ans=k-ans;
    cout<<ans;
}

Measured memory_bytes: 1916
n = gets.to_i
a = gets.split.map(&:to_i)
def insertionSort(a,n)
  for k in 0..n-2
    print "#{a[k]} "
  end
  puts a[n-1]
  for i in 1..n-1
    v = a[i]
    j = i-1
    while j >= 0 && a[j] > v
      a[j+1] = a[j]
      j -= 1
      a[j+1] = v
    end
    for k in 0..n-2
      print "#{a[k]} "
    end
    puts a[n-1]
  end
end
insertionSort(a,n)

Measured memory_bytes: 8616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int h, w, d; cin >> h >> w >> d;
  vector<int> y(h * w), x(h * w);
  REP(i, h) REP(j, w) {
    int a; cin >> a; --a;
    y[a] = i;
    x[a] = j;
  }
  vector<vector<int> > magic(d, vector<int>(1, 0));
  REP(i, d) {
    for (int j = i; j + d < h * w; j += d) {
      magic[i].emplace_back(abs(y[j + d] - y[j]) + abs(x[j + d] - x[j]));
    }
    FOR(j, 1, magic[i].size()) magic[i][j] += magic[i][j - 1];
  }
  int q; cin >> q;
  while (q--) {
    int l, r; cin >> l >> r; --l; --r;
    cout << magic[r % d][r / d] - magic[l % d][l / d] << '\n';
  }
  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl;
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	int K = S.size(), cnt = 0;
	for(auto& c : S) if(c == 'o') cnt++;
	
	Cout(YES(15 - K >= 8 - cnt));
}


Measured memory_bytes: 256
const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}
    val (h, w) = readLine()!!.split(" ").map{it.toInt()}

    println((H-h)*(W-w))
}


Measured memory_bytes: 37700
N = int(input())
d = len(str(N))
ans = 0
if d == 1:
    ans = N
elif d == 2:
    ans = 9
elif d == 3:
    ans = 9 + N - 99
elif d == 4:
    ans = 9 + 999 - 99
elif d == 5:
    ans = 9 + 999 - 99 + N - 9999
else:
    ans = 9 + 999 - 99 + 99999 - 9999
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool b[1000000];
int n,i,j,ans;
int GCD(int x,int y)
{
	return y==0?x:GCD(y,x%y);
}
void biao()
{
	for(i=2;i<=999999;i++)
	{
		if(b[i]==0)
		for(j=i+i;j<=999999;j=j+i)
			b[j]=1;
	}
}
int main()
{
	biao();
	while(~scanf("%d",&n))
	{
		ans=0;
		for(i=2;i<=n&&i<5;i++)
		{
			if(b[i]==0)
				ans++;
		}
		for(i=5;i<=n;i=i+6)
		{
			if(b[i]==0)
				ans++;
			if(b[i+2]==0&&i+2<=n)
				ans++;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3568
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		String s = "";
		// 出力
		if (a < b) {
			for ( int i=0; i<b; i++ ) {
				s = s.concat(String.valueOf(a));
			}
		} else {
			for ( int i=0; i<a; i++ ) {
				s = s.concat(String.valueOf(b));
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  
  long long int N, tmp;
  std::vector<long long int> W, sum;

  scanf("%lld",&N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    W.push_back(tmp);
  }

  sum.push_back(W[0]);
  for(int i = 1; i < N; i++){
    sum.push_back(W[i] + sum[i-1]);
  }

  long long int ans = 1e5;
  for(long long int T = 0; T < N-1; T++){
    ans = std::min(ans, std::abs(sum[N-1] - 2*sum[T]));
  }

  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
}


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

long long int N=0;
long long int ans=0;
int main(){
    cin>>N;
    ans+=(N/11)*2;
    if(N%11>=7)ans+=2;
    else if(N%11>=1)ans+=1;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()

  gc=0
  pc=0
  p=0

  for x in s:
    if gc<pc+1:
      gc+=1

      if x=='p':
        p-=1
      
    else:
      pc+=1
      if x=='g':
        p+=1

  return p

print(main())


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> x(n),y(n),z(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    ll ret=0;
    for(int a=-1;a<=1;a+=2){
        for(int b=-1;b<=1;b+=2){
            for(int c=-1;c<=1;c+=2){
                vector<ll> s(n);
                for(int i=0;i<n;i++)s[i]=x[i]*a+y[i]*b+z[i]*c;
                sort(s.rbegin(),s.rend());
                ll cnt=0;
                for(int i=0;i<m;i++){
                    cnt+=s[i];
                }
                ret=max(ret,cnt);
            }
        }
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int 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()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n,m; cin >> n >> m;
  int ab[n][2];
  REP(i, n){
    ll a,b; cin >> a >> b;
    ab[i][0] = a; ab[i][1] = b;
  }
  int cd[m][2];
  REP(i, m){
    ll c, d; cin >> c >> d;
    cd[i][0] = c; cd[i][1] = d;
  }
  REP(i, n){
    ll mini = INF;
    ll k;
    REP(j, m){
      ll dist = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1] - cd[j][1]);
      if(mini > dist){
        mini = dist;
        k = j;
      } 
    }
    cout << k+1 << endl;
  }
}

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

int main() {
    int n,m ;
    cin >> n >> m ;
    int a[m] ;
    int SUM  = 0;

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

    if((n-SUM)<0)
     cout << -1 << endl;
    else
     cout << n-SUM << endl;

	return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int N,C[10000],dp[5010][2],i,j;
int main(){
    scanf("%d",&N);for(i=0;i<N-1;i++)scanf("%d",C+i);
    fill_n(*dp,10020,1e9);dp[0][1]=dp[1][0]=0;
    for(i=0;i<N-1;i++)
        for(j=N/2;~j;j--){
            dp[j+1][0]=min(dp[j][0],dp[j][1]+C[i]);
        dp[j][1]=min(dp[j][0]+C[i],dp[j][1]);
    }
    printf("%d\n",min(dp[N/2][0],dp[N/2][1]));
}

Measured memory_bytes: 1264
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <float.h>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long

signed main() {
	int A, B;
	cin >> A >> B;
	if (A == B) {
		cout << "Draw" << endl;
		return 0;
	}
	if (A == 1) A = 999;
	if (B == 1) B = 999;
	if (A > B) {
		cout << "Alice" << endl;
		return 0;
	}
	else {
		cout << "Bob" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


int cum[100010];
void solve() {
	int N, M; cin >> N >> M;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];

	}
	VSORT(A);
	REP(i,N)		cum[i + 1] = cum[i] + A[i];
	ll ok = 0, ng = 2e5+1;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		ll cnt = 0;
		REPR(i, N) {
			auto itr = lb(A, (mid-A[i]));
			int it = itr - A.begin();
			if (it > i)break;
			cnt += 2 * (i - it)+1;
			if (cnt >= M)break;
		}
		//DEBUG(mid); DEBUG(cnt);
		if (cnt >= M)ok = mid;
		else ng = mid;
	}
	//DEBUG(ok);
	int rem = M;
	ll ans = 0;
	//REP(i, N + 1)pe(cum[i]);
	//cout << endl;
	REPR(i, N) {
		if (rem <= 0)break;
		auto itr = ub(A, ok-A[i]);
		int it = itr - A.begin();
		if (it > i)break;
		if (2 * (i + 1 - it)-1 > rem) {
			vector<int>v;
			v.push_back(A[i] + A[i]);
			for (int j = i-1; j >= it; j--) {
				v.push_back(A[i] + A[j]);
				v.push_back(A[i] + A[j]);
			}
			VSORT(v); VREVERSE(v);
			//print_space(v);
			REP(j, rem)ans += v[j];
			rem = 0;
		}
		else {
			rem -= 1;
			rem -= 2 * (i - it);

			ans += 2 * (cum[i] - cum[it]);
			//print(ans);
			ans += 2 * (i - it)*A[i];
			ans += 2 * A[i];
		}
	}
	//print(rem);
	ans += ok * rem;
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;
const int INF = 1e18;

template< typename T, typename E >
struct SegmentTree{
	using F = function< T(T, T) >;
	using G = function< T(T, E) >;
	int sz;
	vector<T> dat;
	F f;
	G g;
	T t1;
	SegmentTree(int n, F f, G g, T t1) : f(f), g(g), t1(t1) {
		sz = 1;
		while(sz < n) sz *= 2;
		dat.clear();
		dat.resize(2 * sz - 1, t1);
	}
	void set(int k, T x) { dat[k + sz - 1] = x; }
	void build() {
		for(int k = sz - 2; k >= 0; k--) {
			dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	void update(int k, E x) {
		k += sz - 1;
		dat[k] = g(dat[k], x);
		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return t1;
		if(a <= l && r <= b) return dat[k];
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
	T query(int a, int b){ return query(a, b, 0, 0, sz); }
	T operator[](int k) { return dat[k + sz - 1]; }
};

struct Compress{
    vector<int> d, unzip;
    map<int, int> zip;        
    Compress(vector<int> a){
        vector<int> b = a;
        d.resize(a.size());
        sort(b.begin(), b.end());
        b.erase(unique(b.begin(), b.end()), b.end());
        unzip.resize(b.size());
        for(int i = 0; i < b.size(); i++){
            zip[b[i]] = i;
            unzip[i] = b[i];
        }
        for(int i = 0; i < a.size(); i++){
            d[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        }
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> s(n), t(n), x(n), d(q);
    vector<PP> a(n); 
    rep(i, 0, n){
        cin >> s[i] >> t[i] >> x[i];
        a[i] = {{s[i] - x[i], t[i] - x[i]}, x[i]};
    }
    rep(i, 0, q){
        cin >> d[i];
    }
    sort(a.begin(), a.end());
    vector<int> b;
    rep(i, 0, n){
        b.push_back(a[i].first.first);
        b.push_back(a[i].first.second);
    }
    rep(i, 0, q){
        b.push_back(d[i]);
    }
    Compress cp(b);
    int MAX = *max_element(cp.d.begin(), cp.d.end());
    vector<vector<P> > st(MAX + 1), ed(MAX + 1);
    vector<bool> qr(MAX + 1); 
    SegmentTree<int, int> rmq(n, 
		[](int a, int b){ return min(a, b); }, 
		[](int a, int b){ return b; }, 
		INF);
    rep(i, 0, n){
        a[i].first.first = cp.d[i * 2];
        a[i].first.second = cp.d[i * 2 + 1];
        st[a[i].first.first].push_back({a[i].second, i});
        ed[a[i].first.second].push_back({a[i].second, i});
    }
    rep(i, 0, q){
        d[i] = cp.d[2 * n + i];
        qr[d[i]] = true;
    }

    for(int i = 0; i <= MAX; i++){
        for(auto j : st[i]){
            rmq.update(j.second, j.first);
        }
        for(auto j : ed[i]){
            rmq.update(j.second, INF);
        }
        if(qr[i]){
            int ans = rmq.query(0LL, n);
            if(ans >= INF) ans = -1;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 109768
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

bool so(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{

    if(a.second == b.second) return a.ff<b.ff;
    return a.ss>b.ss;
}

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

   ll x; cin>>x;
   for(ll i=0;i<=500;i++) {
    for(ll j=i;j<=500;j++) {
        ll a=powl(i,5);
        ll b=powl(j,5);

        ll aa=a-b;
        if(aa==x) {
            cout<<i<<" "<<j<<endl;
            End;
        }

        ll bb=a-((-1)*b);
        if(bb==x) {
            cout<<i<<" "<<(-1)*j<<endl;
            End;
        }

        ll cc=(-1)*a-b;
        if(cc==x) {
            cout<<(-1)*i<<" "<<j<<endl;
            End;
        }

        ll dd=((-1)*a)-((-1)*b);
        if(dd==x) {
            cout<<(-1)*i<<" "<<(-1)*j<<endl;
            End;
        }
    }
   }

   End;
}


Measured memory_bytes: 3712
//C - : (Colon)
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  double a,b,h,m;
  double ans;
  scanf("%lf %lf %lf %lf", &a,&b,&h,&m);

  double c,d,e,f;
  c=(pi/6.0)*(h+(m/60.0));
  //printf("%.20f\n", pi);
  //printf("%.20f\n", c);
  d=2.0*pi*(m/60.0);
  //printf("%.20f\n", d);
  e=max(c,d)-min(c,d);
  f=2.0*pi-e;
  ans=sqrt(a*a+b*b-2.0*a*b*cos(min(e,f)));
  printf("%.20f\n", ans);
  return 0;
}


Measured memory_bytes: 2588
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }
    sort(l.begin(),l.end());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ll start = max((ll)j+1, (ll)distance(l.begin(),upper_bound(l.begin(),l.end(),abs(l[i]-l[j]))));
            ll end = distance(l.begin(),lower_bound(l.begin(),l.end(),l[i]+l[j]))-1;
            res += max(end-start+1,(ll)0);
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
};

int main() {
    int n;
    cin >> n;
    cout << pow(n, 3) + pow(n, 2) + n << endl;
}

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

void solve() {
  int N;
  cin >> N;
  rep(a, 0, 25) {
    rep(b, 0, 14) {
      if (a * 4 + b * 7 == N) {
        cout << "Yes" << endl;
        // cout << a << " " << b << endl;
        return;
      };
    }
  }
  cout << "No" << endl;
}

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

Measured memory_bytes: 3580
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
const int MOD = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
ostream& operator<<(ostream& os, const mint& value) {
    os << value.x;
    return os;
}

#pragma endregion library

// [array index][partition][okflag]
mint dp[42][bit(17)][2];
int main() {
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int mask17 = bit(17) - 1;
    mint ans = 0;
    dp[0][0][0] = 1;
    rep(i, n) rep(j, bit(17)) rep(ok, 2) {
        repi(k, 1, 11) {
            int nj = (j << k) | bit(k - 1);
            nj &= mask17;
            int flag = 0;
            if ((nj & bit(x + y + z - 1)) && (nj & bit(y + z - 1)) && (nj & bit(z - 1))) {
                flag = 1;
            }
            dp[i + 1][nj][flag | ok] += dp[i][j][ok];
        }
    }
    rep(j, bit(17)) {
        ans += dp[n][j][1];
    }
    cout << ans << '\n';
}

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

int main(){
    long long n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int cnt = 0;
        for(int j = i; j < k; j *= 2){
            cnt++;
        }
        // cout << cnt << endl;
        ans += (1.0/(double)n) * pow(0.5, cnt);
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin>>N;
     vector<int> B(N);
   for (int i = 0; i < N-1; i++) {
    cin >> B.at(i);
  }
     vector<int> A(N);
  A[0] = B[0];
for (int i = 1; i <= N-2; i++) {
 A[i] =min(B[i],B[i-1]);
}
A[N-1]=B[N-2];
  int ans=0;
for (int i = 0; i < N; i++) {
 ans +=A[i];
}
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 256