akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main()
{
    int n, cnt = 0;
    cin >> n;
    vector <int> vec (n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec[i];
        if (vec[i] % 2 != 0 && (i + 1) % 2 != 0)
            cnt ++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(){
  int x,y,tmp,r;
  
  scanf("%d %d",&x,&y);
  
  if(1<=x && x<=1000000000) {
    if(1<=y && y<=1000000000){
     
if(x<=y){
  tmp = x;
  x = y;
  y = tmp;
 }

 r = x%y;

 while(r!=0){
   x = y;
   y = r;
   r = x%y;
 }
printf("%d\n",y);
    }
  }
  
return 0;
}








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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	if(s=="Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if(s=="Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else 
	{
		cout << "Sunny" << endl;
	}
}


Measured memory_bytes: 256
# 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>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

struct BIT {
	int s[1 << 18];
	void init() {
		REP(i, (1 << 18))s[i] = 0;
	}
	void add(int k, int x) {
		while (k > 0) {
			s[k] += x;
			k -= k&-k;
		}
	}
	int sum(int k) {
		int ret = 0;
		while (k < (1 << 18)) {
			ret += s[k];
			k += k&-k;
		}
		return ret;
	}
}bit;

int n, m, l[303030], r[303030];
int main() {
	cin >> n >> m;
	REP(i, n)cin >> l[i] >> r[i];
	vector<pair<int, int>>v;
	bit.init();
	REP(i, n)v.emplace_back(mp(r[i] - l[i] + 1, i));
	sort(ALL(v));
	int k = 0;
	for (int i = 1; i <= m; i++) {
		while (k < v.size() && v[k].first < i) {
			bit.add(l[v[k].second] - 1, -1);
			bit.add(r[v[k].second], 1);
			k++;
		}
		int ret = n - k;
		for (int j = 1; i*j <= m; j++) {
			ret += bit.sum(i*j);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 9840
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n+1)
dp[2]=abs(arr[0]-arr[1])
for i in range(3,n+1):
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
 
print(dp[n])



Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}
bool divisor(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
   ll div[n + 1]={0};
    memset(div, 0, sizeof div);

    for (int i = 1; i <= n; i++) {

        for (int j = 1; j * i <= n; j++)
            div[i * j]++;
    }

   ll ans=0;
    for (int i = 1; i <= n; i++)
        ans+=i*div[i];
    cout<<ans;
	return 0;
}


Measured memory_bytes: 81732
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX;

fn solve() {
    let x = read!(i64);
    if x>=30 {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn run() {
    solve();
}


Measured memory_bytes: 2240
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	vector<string> s(3);
	cin >> s[0] >> s[1] >> s[2];
	unordered_map<char, int> mp;
	mp['a'] = 0;
	mp['b'] = 1;
	mp['c'] = 2;
	int nxt = 0;
	int ind = 0;
	while (1) {
		nxt = mp[s[ind][0]];
		s[ind].erase(s[ind].begin());
		ind = nxt;
		if (s[ind].size() == 0) {
			break;
		}
		//cout << s[0] << endl << s[1] << endl << s[2] << endl;
	}
	if (ind == 0) cout << "A";
	else if (ind == 1) cout << "B";
	else cout << "C";
	return 0;

}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n;
	cin>>n;
	int p[10];
	int q[10];
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	int a,b;
	int cnt=0;
	int r[10];
	rep(i,n)r[i]=i+1;
	do{
		bool bp=true;
		bool bq=true;
		rep(i,n)if(r[i]!=p[i])bp=false;
		rep(i,n)if(r[i]!=q[i])bq=false;
		if(bp)a=cnt;
		if(bq)b=cnt;
		cnt++;
	}while(next_permutation(r,r+n));
	cout<<abs(a-b)<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
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 pair<int,int> pi;
typedef pair<ll,ll> pl;

const vi dx={1,0,-1,0},dy={0,1,0,-1};

int main(){

    int h,w,k,x1,y1,x2,y2;
    cin>>h>>w>>k>>y1>>x1>>y2>>x2;
    vc<string> c(h+2);
    rep(i,w+2)c[0].push_back('@');
    c[h+1]=c[0];
    repa(i,1,h+1){
        cin>>c[i];
        c[i]="@"+c[i]+"@";
    }
    vvi kaki(h+2,vi(w+2,-1));

    // rep(i,h+2){
    //     rep(j,w+2){
    //         cerr<<c[i][j];
    //     }
    //     cerr<<"\n";
    // }

    queue<pi> que;
    que.emplace(y1,x1);
    kaki[y1][x1]=0;

    // rep(i,h+2){
    //     rep(j,w+2){
    //         cerr<<kaki[i][j]<<" ";
    //     }
    //     cerr<<"\n";
    // }

    while(!que.empty()){
        int x=que.front().second,y=que.front().first;
        que.pop();
        if(c[y][x]=='@')continue;
        c[y][x]='@';
        rep(i,4){
            int yd=y,xd=x,cnt=0;
            while(cnt<k && c[yd+dy[i]][xd+dx[i]]=='.'){
                if(kaki[yd+dy[i]][xd+dx[i]]==-1){
                    kaki[yd+dy[i]][xd+dx[i]]=kaki[y][x]+1;
                    que.emplace(yd+dy[i],xd+dx[i]);
                }
                yd+=dy[i];
                xd+=dx[i];
                cnt++;
            }
        }
    }

    // rep(i,h+2){
    //     rep(j,w+2){
    //         cerr<<kaki[i][j]<<" ";
    //     }
    //     cerr<<"\n";
    // }

    cout<<kaki[y2][x2]<<"\n";

    return 0;

}

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

void solver() {
  long n;
  cin >> n;

  long m[n+1];
  long mc[n+1];
  vector<long> as;
  for (int i = 0; i < n; i++) {
    m[i] = 0;
    mc[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    long a = 0;
    cin >> a;
    m[a-1]++;
    as.push_back(a-1);
  }

  long base = 0;
  for (int i = 0; i < n; i++){
    if(m[i] < 2) mc[i] = 0;
    else {
      mc[i] = (m[i] * (m[i] - 1)) / 2;
    }
    base += mc[i];
  }

  for (int i = 0; i < n; i++) {
    long a = as[i];
    long ans = base - mc[a];
    if(m[a]-1 < 2) {
      cout << ans << "\n";
    } else {
      ans = ans + (((m[a] - 1) * (m[a] - 2)) / 2);
      cout << ans << "\n";
    }
  }
}

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


Measured memory_bytes: 7408
def main():
    S = input()
    n = len(S)
    p = 2019 # 法p
    # (1) a≡b,c≡dならばa+c≡b+d
    # (2) aと法pが互いに素である時、ab≡acならばb≡c
    # ex).S=1817181712114(idxは最下位が0とする), n=len(S)
    # 4≡4%p <- modp[0]
    # 14=10+4≡10%p+modp[0] <- modp[1]
    # 114=100+14≡100%p+modp[1] <- modp[2]
    # 2114=2000+114≡2000%p+modp[2] <- modp[3]
    # ...
    # 1817181712114≡100000000000%p+modp[n-2] <- modp[n-1]
    # したがって、S[1:4]=21%pについては
    # 2100=2114-14≡modp[3]-modp[1]
    # ここでaとpが互いに素なので(a=100,p=7)
    # 2100≡21 が言える
    # よって21≡modp[3]-modp[1]
    # 一般化すると、
    # S[i:j+1]≡modp[j]-modp[i]
    # すなわちmodp[j]==modp[i]となるi,jを選んだ時、S[i:j+1]はpで割り切れるという事になる

    # Sをreverseする
    S = [S[i] for i in range(n-1,-1,-1)]
    # modpを作成
    modp_counter = [0] * p
    modp = 0
    modp_counter[0] = 1 # 割り切れるやつが入る場所の初期値を1にしておかないと、1つ割り切れるやつがきたときにpair_count+=0となってしまう(pair_count+=1になるべきなのに)
    pair_count = 0
    d = 1
    for s in S:
        modp = (int(s)*d%p+modp)%p
        pair_count += modp_counter[modp]
        modp_counter[modp] += 1
        d *= 10
        d %= p # 計算量削減
    print(pair_count)


main()


Measured memory_bytes: 10788
/* 
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    vector<int> h(n+5);
    for(int i = 0; i < n; ++i) cin >> h[i];
    int prev = 0, curr = abs(h[1]-h[0]);
    for(int i = 2; i < n; ++i)
    {
        int temp = min(abs(h[i]-h[i-1]) + curr, abs(h[i]-h[i-2]) + prev);
        swap(temp, curr);
        swap(temp, prev);
    }
    cout << curr << "\n";
    return 0; 
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	nums := scanNums(5)
	var k int
	fmt.Scan(&k)
	if nums[4]-nums[0] > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 512
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = (LL)1e9 + 7;


int main() {
	
	string s;
	cin >> s;
	int N = SZ(s);
	char a = s[0];
	int lastindex = 0;
	int num = 0;
	FOR (i, 1, N) {
		if (s[i] != a) {
			num++;
			a = s[i];
		}
	}
	cout << num << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  int cnt=0;
  for (int i = 0;i<N;i++) {
    int a;
    cin >> a;
    if (!mp.count(a)) cnt++;
    mp[a]++;
  }
 // cout << cnt <<endl;
  if (cnt <= K) cout << 0 << endl;
  else {
    vector<int> vec;
    for (pair<int,int> p : mp) {
      if (p.second != 0) {
       vec.push_back(p.second);
      }
    }
    sort(vec.begin(),vec.end());
    int ans = 0;
    for (int i = 0;i<cnt-K;i++) {
      ans += vec[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 10748
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> BAs(M);
    REP(m, M) {
        cin >> BAs[m].second >> BAs[m].first;
    }
    sort(ALL(BAs));

    int prev = -1;
    int ans = 0;
    for(auto ba: BAs) {
        auto b = ba.first;
        auto a = ba.second;
        if (prev == -1) {
            prev = b - 1;
            ++ans;
        }
        else {
            if (prev < a) {
                prev = b - 1;
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve


struct ConvexHullTrick {
    struct Line {
        long long a, b;
        long long get(long long x) { return a * x + b; }
    };
    deque<Line> que;
    bool check(Line a, Line b, Line c) {
        return (b.b - c.b) * (b.a - a.a) <= (a.b - b.b) * (c.a - b.a);
    }
    void add(long long a, long long b) {
        Line l{a, b};
        while(que.size() > 1 && check(que[que.size() - 2], que.back(), l))
            que.pop_back();
        que.push_back(l);
    }
    long long query(long long x) {
        if(que.empty()) return INT64_MAX;
        while(que.size() > 1 && que[0].get(x) >= que[1].get(x))
            que.pop_front();
        return que[0].get(x);
    }
};


// int D
void solve(void)
{
  int N,C;
  cin>>N>>C;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin>>H[i];
  }
  ConvexHullTrick CHT;
  CHT.add(-2*H[0],H[0]*H[0]);
  vector<int> DP(N+1);
  for (int i = 1; i < N; i++)
  {
    DP[i] = CHT.query(H[i]) + H[i]*H[i] + C;
    CHT.add(-2*H[i],DP[i]+H[i]*H[i]);
  }
  cout<<DP[N-1]<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.


int main() {
int N, W;
cin >> N >> W;
long long int a[N][2];
for (int i = 0; i < N; ++i)
{
	cin >> a[i][0] >> a[i][1];
}

long long int dp[W+1] = {0};
long long int mx;

for (int i = 0; i < N; ++i)
{

	for (int j = W; j >=a[i][0]; --j)
	{
		dp[j] = max(dp[j], a[i][1] + dp[j-a[i][0]]);
	}

}
	mx = INT_MIN;
for (int i = 0; i <=W; ++i)
{
	if(dp[i] > mx) mx = dp[i];
}
cout << mx << endl;
return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,Q;
char s[202020];
char t[10], d[10];
pair<char,char> mg[202020];
ll i,j,l, r,ans;
int ck(ll a){
    //printf("\n:%lld ",a);
    ll i;
    fornum(i,0,Q){
        //printf("%c:%c ", mg[i].first, s[a]);
        if(mg[i].first==s[a]){
            if(mg[i].second=='R'){
                a++;
            }else{
                a--;
            }
            //printf("%lld,%lld ", i,a);
            if(N<=a){
                //printf("a");
                return 1;
            }
            if(a<0){
                //printf("b");
                return -1;
            }
        }
    }
    
    return 0;
}

int main(){
    scanf("%lld%lld%s", &N, &Q,s);
    
    j = 0;
    fornum(i,0,Q){
        scanf("%s%s", t, d);
        mg[i] = {t[0], d[0]};
        //printf("%c,%c\n", mg[i].first, mg[i].second);
    }
    l = -1;
    r = N - 1;
    while(l<r){
        ll c = (l + r+1) / 2;
        if(ck(c)==1){
            r = c-1;
        }else{
            l=c;
        }
    }
    ans = l+1;
    //printf("%lld ", N-1-l);

    l = 0;
    r = N;
    while(l<r){
        ll c = (l + r) / 2;
        if(ck(c)==-1){
            l = c+1;
        }else{
            r = c;
        }
        //printf("%lld %lld,%lldl\n", c,l,r);
    }
    ans -=r;
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 896
//https://atcoder.jp/contests/abc089/tasks/abc089_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
struct Info {
    ll m_a;
    ll m_val=0;
    ll m_sum=0;
    const Info* m_prev=nullptr;
};
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H,W,D; cin>>H>>W>>D;
    vector<vector<Info>> aij(H+1,vector<Info>(W+1));
    unordered_map<ll,pair<ll,ll>> posmap;
    FOR(y,1,H+1){
        FOR(x,1,W+1){
            ll a; cin>>a;
            aij.at(y).at(x).m_a=a;
            posmap[a]={x,y};
        }
    }
    ll Q; cin>>Q;
    vector<pair<ll,ll>> lrs(Q);
    for(auto&& lr:lrs){
        cin>>lr.first>>lr.second;
    }

    FOR(y,1,H+1){
        FOR(x,1,W+1){
            auto& info = aij.at(y).at(x);
            auto n = info.m_a + D;
            if (n<=H*W) {
                auto& it = posmap.at(n); //次pos
                info.m_val = abs(it.first-x) + abs(it.second-y);
                //info.m_prev = &aij.at(it.second).at(it.first);
            }
        }
    }
    //累積和
    auto get_info = [&](ll n)->Info&{
        const auto& it = posmap.at(n);
        return aij.at(it.second).at(it.first);
    };
    FOR(n,1,H*W+1){
        if(n+D<=H*W){
            auto& a = get_info(n);
            auto& b = get_info(n+D);
            b.m_sum = a.m_sum + a.m_val;
        }
    }

    for(const auto& lr:lrs){
        ll ans = 0;
        ll ans2 = 0;
        auto l = lr.first;
        auto r = lr.second;
        // while(l!=r){
        //     auto& it = posmap.at(l);
        //     const auto& a = aij.at(it.second).at(it.first);
        //     assert(l==a.m_a);
        //     l += D;
        //     ans += a.m_val;
        // }
        auto rv = get_info(r).m_sum;
        auto lv = get_info(l).m_sum;
        ans2 = rv - lv;
        cout<<ans2<<endl;
    }

    return 0;
}

Measured memory_bytes: 10788
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z')
        cout << 'a';
    else if (a >= 'A' && a <= 'Z')
        cout << 'A';
    return 0;
}

Measured memory_bytes: 3632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


pll good(pll A,pll B,ll a,ll b){
    if(abs(A.F)+abs(A.S)<abs(B.F)+abs(B.S) || (abs(A.F)+abs(A.S)==abs(B.F)+abs(B.S) && abs(A.F)*a+abs(A.S)*b<abs(B.F)*a+abs(B.S)*b)){return A;}
    return B;
}

const ll MX=100000;

int main(){
    ll A,B,C;
    while(cin>>A>>B>>C){
        if(A==0){return 0;}
        pll ret={MOD,MOD};
        for(ll i=-MX;i<=MX;i++){
            ll k=C+i*A;
            if(k%B==0){ret=good(ret,{i,k/B},A,B);}
        }
        cout<<abs(ret.F)<<" "<<abs(ret.S)<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3032
#include<stdio.h>
int main(){
    int S[13]= {}, H[13]= {}, C[13]= {}, D[13]= {}, n, i, num, r;
    char key;
    scanf("%d",&n);
    
    for( i = 0; i < n; i++ ){
        (void)getchar();
        scanf("%c %d", &key, &num); 
        if( key == 'S' ){
            S[num - 1] += 1;
        }
        else if( key == 'H' ){
            H[num - 1] += 1;
        }
        else if( key == 'C' ){
            C[num - 1] += 1;
        }
        else if( key == 'D' ){
            D[num - 1] += 1;
        }
    }
    for( i = 0; i < 4; i++ ){
        for( r = 0; r < 13; r++ ){
            if( i == 0 ){
                if( S[r] != 1 ){
                    
                        printf("S %d\n",r+1);
                    
                }
            }else if( i == 1 ){
                if( H[r] != 1 ){
                    
                        printf("H %d\n",r+1);
                    
                }
            }else if( i == 2 ){
                if( C[r] != 1 ){
                    
                        printf("C %d\n",r+1);
                    
                }
            }else {
                if( D[r] != 1 ){
                    
                        printf("D %d\n",r+1);
                    
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 600
def calc(N, M, a, c):
    for j in range(N):
        u = sum([c[i][j] for i in range(M)])
        if u == 0:
            return -1
    inf = 10 ** 7 + 1
    L = 2 ** N
    dp = [inf for _ in range(L)]
    dp[0] = 0
    C = [sum([_c[i] * 2 ** i for i in range(N)]) for _c in c]
    for _ in range(M):
        dp_x = list(dp)
        for i in range(M):
            for j in range(L):
                if dp[j] == inf:
                    continue
                dp_x[j | C[i]] = min(dp_x[j | C[i]], dp[j] + a[i])
            dp = dp_x
        if dp[L - 1] < inf:
            return dp[L - 1]
    return -1


(N, M) = tuple([int(s) for s in input().split(' ')])
a = [0 for _ in range(M)]
c = [[0 for _ in range(N)] for _ in range(M)]
for i in range(M):
    (_a, _b) = tuple([int(s) for s in input().split(' ')])
    a[i] = _a
    for _c in [int(s) for s in input().split(' ')]:
        c[i][_c - 1] = 1
print(calc(N, M, a, c))

Measured memory_bytes: 3432
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;
int main(void){
	long ans,A,B,C,X,Y;
	
	scanf("%ld%ld%ld%ld%ld", &A,&B,&C,&X,&Y);
	if(A+B<=2*C)ans = A*X+B*Y;
	else if(X>=Y){
		if(A>=2*C)ans = 2*C*X;
		else ans = 2*C*Y + (X-Y)*A;
	}
	else{
		if(B>=2*C)ans = 2*C*Y;
		else ans = 2*C*X + (Y-X)*B;
	}
	
	printf("%ld\n",ans);
	fflush(stdout);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int num[300005];
vector<int> v1;
int s[300005];

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        a--;
        num[a]++;
    }
    for(i=0;i<n;i++){
        if(num[i]==0)continue;
        v1.push_back(num[i]);
    }
    sort(v1.begin(),v1.end());
    a=n;
    m=v1.size();
    for(i=n,j=1,k=m-1;i>0;i--){
        a-=m-1-k;
        while(k>=0 && v1[k]==i)k--;
        for(;j<=a/i;j++){
            s[j]=i;
        }
    }
    for(i=1;i<=n;i++){
        if(i>m)cout<<0<<endl;
        else cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 4336
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int N,s=0,a;
	cin>>N;
	a=N;
	 while(a!=0)
	 {
	  s+=a%10;
	  a/=10;
	 }
	 if(N%s==0)
	 cout<<"Yes"<<endl;
	 else
	 cout<<"No"<<endl;
	 return 0; 
}

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

int main(void){
    int a;
    cin >> a;
    int b=0;
    for (int i = 10; i < 11; i++){
        b = a %10;
        a/=10;

    }
    if (b==2 || b ==4 || b==5 || b==7 || b==9)
    {
        cout << "hon" << endl;
    }else if(b==0 || b==1 ||b ==6 || b == 8){
        cout << "pon" << endl;
    }else if(b==3){
        cout << "bon" << endl;
    }
    
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main() {
	int n;
	ll a[201];
	cin >> n;
	REP(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	bool flag = false;
	while (1) {
		REP(i, n) {
			if (a[i] % 2 == 1) {
				flag = true;
			}
			a[i] = a[i] / 2;
		}
		if (flag) {
			break;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    char X;
    char Y;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.X = sc.next().charAt(0);
        this.Y = sc.next().charAt(0);
    }
    
    //解答処理
    private char solve() {
    	//大小関係はアスキーコードと同じ
        char answer = '>';
        
        if (X == Y) {
        	answer = '=';
        } else if (X < Y) {
        	answer = '<';
        }
        
        return answer;
    }
    
    //出力
    public void show(char answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35184
use std::io;
use std::f64;

fn main() {
    let pi = f64::consts::PI;
    let mut S = String::new();
    io::stdin().read_line(&mut S);
    let vec :Vec<&str> = S.trim().split_whitespace().collect();
    let a :f64 = vec[0].parse().unwrap();
    let b :f64 = vec[1].parse().unwrap();
    let h :f64 = vec[2].parse().unwrap();
    let m :f64 = vec[3].parse().unwrap();
    let mut l :f64 = 0.0;
    let (mut hx , mut hy) = (0.0 ,0.0);
    let (mut mx , mut my) = (0.0 ,0.0);

    mx = b * (2.0*pi*m/60.0).cos();
    my = b * (2.0*pi*m/60.0).sin();

    hx = a * (2.0 * pi * (h + m / 60.0 )/12.0).cos();
    hy = a * (2.0 * pi * (h + m / 60.0 )/12.0).sin();

    l = ((mx - hx)*(mx - hx) + (my - hy)*(my - hy)).sqrt();

    println!("{}",l)
}

Measured memory_bytes: 2964
#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 <iomanip>
#include <array>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
const int INF = 1e9;
const double PI = acos(-1.0);


ll f(ll n) {
	ll ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

double g(ll n) {
	return (double)n / f(n);
}

int main() {
	
	vector<ll> res;
	ll base = 1;

	rep(i, 15) {
		REP(j, 1, 150)res.push_back(base*(j + 1) - 1);
		base *= 10;
	}
	sort(res.begin(), res.end());
	res.erase(unique(res.begin(), res.end()), res.end());

	for (ll i = 0; i < (ll)res.size(); i++) {
		for (ll j = i + 1; j < (ll)res.size(); j++) {
			if (g(res[i]) > g(res[j])) {
				res.erase(res.begin() + i--);
				break;
			}
		}
	}

	ll k;
	cin >> k;
	for (ll i = 0; i < k; i++) cout << res[i] << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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; }

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
int N;
vector<int> V(101);

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void sol(int X){
    for(int i = 2; i <= X; i++){
        if(X % i == 0){
            V[i]++;
            if(X/i == 1) return;
            else{
              sol(X/i);
              return;
            }
        }
    }
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    COMinit();
    cin >> N;
    if(N <= 9){
        cout << 0 << endl;
        return 0;
    }
    int cnt5 = 0,cnt3 = 0,cnt15 = 0,cnt25 = 0,cnt75 = 0;
    REPP(i,2,N+1){
        sol(i);
    }
    REP(i,N+1){
        if(V[i] >= 4){
            cnt5++;
        }
        if(V[i] >= 2){
            cnt3++;
        }
        if(V[i] >= 14){
            cnt15++;
        }
        if(V[i] >= 24){
            cnt25++;
        }
        if(V[i] >= 74){
            cnt75++;
        }
    }
    int ans = COM(cnt5,2) * (cnt3-2);
    ans += cnt15*(cnt5-1);
    ans += cnt25*(cnt3-1);
    ans += cnt75;
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <cmath>

using namespace std;

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

    double s = x/a;
    double rad;
    if(s >= a*b/2){
        double h = 2*(a*b-s)/a;
        rad = atan2(h, a);
    }else{ // x/a < a*b/2.0
        double w = 2*s/b;
        rad = atan2(b, w);
    }

    double deg = rad/(2*M_PI)*360;
    printf("%.10f\n", deg);


    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#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)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int R;
    string ans;
    cin >> R;
    if(R<1200) ans = "ABC";
    if(1200<=R && R<2800) ans = "ARC";
    if(R>=2800) ans = "AGC";
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)1000000007
#define pb push_back
#define endl "\n"
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repo(i,b) for(int i=(int)0;i<b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed solve(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	repo(i,n) cin>>a[i]>>b[i]>>c[i];
	int dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0],dp2[0]=b[0],dp3[0]=c[0];
	for(int i=1;i<n;i++){
		dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=c[i]+max(dp2[i-1],dp1[i-1]);
	}
	cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]))<<endl;
	return 0;
}

signed main(){
	fast;
	int tests=1;
	// cin>>tests;
	while(tests--){
		solve();
	}
}

Measured memory_bytes: 8308
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vector<ll> a(3 * n);
	for(int i = 0; i < 3 * n; i++) cin >> a[i];
	
	vector<ll> pre(3 * n), suf(3 * n);
	ll sum = 0;
	multiset<ll> s;
	for(int i = 0; i < n; i++) {
		s.insert(a[i]);
		sum += a[i];
	}
	
	pre[n - 1] = sum;
	for(int i = n; i < 2 * n; i++) {
		if(a[i] > *s.begin()) {
			sum -= *s.begin();
			s.erase(s.begin());
			s.insert(a[i]);
			sum += a[i];
		}
		
		pre[i] = sum;
	}
	
	sum = 0;
	s.clear();
	for(int i = 3 * n - 1; i >= 2 * n; i--) {
		s.insert(a[i]);
		sum += a[i];
	}
	
	suf[2 * n] = sum;
	for(int i = 2 * n - 1; i > n - 1; i--) {
		auto it = s.end();
		it--;
		if(a[i] < *it) {
			sum -= *it;
			s.erase(it);
			s.insert(a[i]);
			sum += a[i];
		}
		
		suf[i] = sum;
	}
	
	ll ans = -INF;
	for(int i = n - 1; i < 2 * n; i++) {
		ans = max(ans, pre[i] - suf[i + 1]);
	}
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}	

Measured memory_bytes: 15112
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int H, W, A, B; cin >> H >> W >> A >> B;
    mat ans(H, vec(W, 0));
    REP(i, H) REP(j, W){
        if((i < B) == (j < A)) ans[i][j] = 1;
    }
    REP(i, H){
        REP(j, W) cout << ans[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 9088