akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(n);
  int cnt4=0,cnt2=0;
  rep(i,n)
  {
    cin>>a[i];
    a[i]=a[i]&-a[i];
    //cout<<a[i]<<endl;
    a[i]=min(4,a[i]);
    if(a[i]==4)cnt4++;
    if(a[i]==2)cnt2++;
  }
  int res=0;
  res+=max(cnt4*2+1,cnt4*2+cnt2);
  if(res>=n)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=0;i<s.length();i++){
            if(i%2==0){
                System.out.print(s.charAt(i));
            }
        }
    }
}

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

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

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 iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int x[3010], y[3010];
bool isHere[5010][5010];

void solve(int n) {
    memset(isHere, false, sizeof(isHere));
    REP(i, n) {
        cin >> x[i] >> y[i];
        isHere[y[i]][x[i]] = true;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int dx = x[i] - x[j];
            int dy = y[i] - y[j];

            dx = dx < 0 ? -dx : dx;
            dy = dy < 0 ? -dy : dy;

            int ax = x[i] + dy, ay = y[i] + dx;
            int bx = x[j] + dy, by = y[j] + dx;

            if (ax > 5000 || ay > 5000 || bx > 5000 || by > 5000) {
                continue;
            }

            if (isHere[ay][ax] && isHere[by][bx]) {
                ans = max(ans, dx * dx + dy * dy);
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    int n;
    while (cin >> n && n) {
        solve(n);
    }
    return 0;
}


Measured memory_bytes: 27552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  vector<int> b(N+1),w(N+1);
  b[0] = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '#') b[i+1] = b[i]+1;
    else b[i+1] = b[i];
  }
  w[N] = 0;
  for (int i = 0; i < N; i++) {
    if (S[N-1-i] == '.') w[N-i-1] = w[N-i]+1;
    else w[N-i-1] = w[N-i];
  }
  int ans = N; 
  for (int i = 0; i < N+1; i++) {
    ans = min(ans,b[i]+w[i]);
  }
  
  cout << ans << endl;   
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a, b, c , d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double tmp = 0;
    int ans_w = 100 * a, ans_s = 0;

    for (int ai = 0; ai <= f; ai+= 100*a) {
        for (int bi = ai; bi <= f; bi += 100*b){
            for (int ci = 0; ci <= f - bi; ci += c){
                for (int di = ci; di <= f - bi; di += d){
                    if (bi + di > f) continue;
                    double dns = double(di) / double(bi + di);
                    if (bi * e >= di * 100 && dns > tmp){
                        ans_w = bi;
                        ans_s = di;
                        tmp = dns;
                    }
                }
            }
        }
    }


    // rep(ai, 31){
    //     rep(bi, 31){
    //         rep(ci, 3001){
    //             rep(di, 3001){
    //                 if (100*ai*a + 100*bi*b + ci*c + di*d <= f){
    //                     double dns = double(ci*c + di*d) / double(100*ai*a + 100*bi*b + ci*c + di*d);
    //                     if ((ai*a + bi*b) * e >= (ci*c + di*d) && dns > tmp){
    //                         ans_w = 100*ai*a + 100*bi*b;
    //                         ans_s = ci*c + di*d;
    //                         tmp = dns;
    //                     }
    //                 }
    //             }
    //         }
    //     }
    // }

    cout << ans_w + ans_s << " " << ans_s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,ans;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'||s.at(i)=='1'){ans+=s.at(i);}
    else if(ans.size()==0){continue;}
    else{ans.pop_back();}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut p: Vec<_> = (0..n).map(|_| {
        let a: i64 = sc.cin();
        let b: i64 = sc.cin();
        (a + b, a, b)
    }).collect();
    p.sort(); p.reverse();
    let mut ans = 0;
    for i in 0..n {
        ans += if i % 2 == 0 { p[i].1 } else { -p[i].2 };
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;

using namespace std;

int main(){
    int n;  cin >> n;
    ll a, b, c, d;
    a = 1;
    b = 1;
    c = 1;
    d = 1;
    for(int i=1; i<=n; i++){
        a *= 10;
        b *= 9;
        c *= 9;
        d *= 8;
        a %= MOD;
        b %= MOD;
        c %= MOD;
        d %= MOD;
    }
    print((a+d-b-c+MOD+MOD) % MOD);
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)


int main(){
	long int n, k;
	scanf("%ld%ld", &n, &k);
	
	long int ans=0;
	for(; k<=n+1; k++){
		ans += (n-k+1)*k+1;
		ans = ans%MOD;
	}

	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if( a<b) {
	cout<<"a < b"<<endl;
}
	if (a>b) {
	cout<<"a > b"<<	endl;
}
	if (a==b) {
	cout<<"a == b"<<endl;
}	
	return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<typeinfo>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	string s;
	cin >> s;
	int ans = 1000000;
	REP(i, 0, s.size() - 2) {
		string t = s.substr(i, 3);
		int tmp = stoi(t);
		ans = min(ans, abs(tmp - 753));
	}
	cout << ans << endl;
	return 0;
}

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

#define db double

struct Poi {
	db x, y;
	void r() { cin >> x; cin >> y; }
	void w() { cout << x << ' ' << y << '\n'; }
	Poi operator -(Poi p) {
		return {x - p.x, y - p.y};
	}
	Poi operator +(Poi p) {
		return {x + p.x, y + p.y};
	}
	Poi operator *(db d) {
		return {x * d, y * d};
	}
	db dot(Poi p) {
		return x * p.x + y * p.y;
	}
	db len2() { return x * x + y * y; }
	Poi proj(Poi p, Poi q) {
		db s = (*this - p).dot(q - p) / (q - p).len2();
		return p + (q - p) * s;
	}
};

int main() {
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(12);

	Poi p, q; p.r(); q.r();
	int T; cin >> T;
	while(T --) {
		Poi t; t.r();
		(t.proj(p, q) * 2 - t).w();
	}
	return 0;
}

Measured memory_bytes: 3264
#include <iostream>

#define REP(i, a, b) for (int i = a; i < b; i++)

using namespace std;

int main()
{
    int H, N;
    int A[100000];

    cin >> H >> N;
    
    int sum = 0;
    REP(i, 0, N)
    {
        cin >> A[i];
        sum += A[i];
    }

    sum >= H ? cout << "Yes\n" : cout << "No\n";

    return 0;
}

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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int n, k;
int h[100010];

int main() {
    cin >> n >> k;
    rep(i, n) cin>>h[i];
    sort(h, h+n);
    int ans = INT_MAX;
    rep(i, n-k+1) ans = min(ans, h[i+k-1]-h[i]);
    cout << ans << endl;
}


Measured memory_bytes: 640
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
m = [['']*w for _ in range(h)]
        
i = 0
cnt = 0
for k in range(h):
    for l in range(w):
        if k % 2 == 1:
            m[k][w-l-1] = i+1
        else:
            m[k][l] = i+1  
            
        cnt += 1    
        if cnt == a[i]:
            i += 1
            cnt = 0

for i in m:
    print(*i)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second << '\n'; return _out; }
template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front() << ' '; for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << *_it <<' '; } return _out; }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; }for (auto _it:_m) { _out << _it.first << ": " << _it.second << '\n'; } return _out; }
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define ll long long
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
struct cord{
    int x;
};
#define ld long double
#define int long long
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, p;
    cin >> n >> p;
    set<int, greater<int> > s;
    for(int i = 1;i <= sqrt(p);i++){
        if(p % i == 0){
            s.insert(i);
            s.insert(p/i);
        }
    }
    for(auto x: s){
        int lol = pow(x, n);
        if(p % lol == 0){
            cout << x;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans=0,A,B;
    bool F=true;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>S;
    T=S.substr(0,A);
    for(auto x:T){
        if(!(0<=x-'0'&&x-'0'<=9)){F=false;break;}
    }
    if(S[A]!='-')F=false;
    T=S.substr(A+1);
    for(auto x:T){
        if(!(0<=x-'0'&&x-'0'<=9)){F=false;break;}
    }

    cout<<(F?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i )
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w){
    if(s[si][sj] == '#') continue;
    vector<vector<int>> dist(h,vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x){
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j));
    };
    update(si,sj,0);
    while(!q.empty()){
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir,4){
        int ni = i+di[dir], nj = j+dj[dir];
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj] == '#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w){
      if(dist[i][j] == INF ) continue;
      ans = max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int x;
    cin >> x;
    int i = 0;
    ll c = 0;
    while (c < x) {
        ++i;
        c += i;
    }
    cout << i << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  ll t9=1e9;
  vll a(n);
  vs ss(n);
  rep(i,n) cin>>ss[i];
  rep(i,n){
    string s=ss[i];
    ll idx=s.find('.');
    ll aa=9-((ll)s.size()-idx);
    if(idx!=string::npos){
      s+=string(9-((ll)s.size()-idx-1), '0');
      s.erase(idx,1);
      a[i]=stoll(s);
    }else{
      a[i]=stoll(s)*t9;
    }
  }
  
  // rep(i,n) cout<<a[i]<<endl;
  vvll dp(51, vll(51));
  ll ans=0;
  
  rep(i,n){
    ll cnt2=0, cnt5=0;
    while(a[i]%2==0 && a[i]!=0) a[i]/=2, cnt2++;
    while(a[i]%5==0 && a[i]!=0) a[i]/=5, cnt5++;
    
    if(i>0){
      rep(i2,51){
        rep(i5,51){
          if(min(cnt2+i2,cnt5+i5)>=18) ans+=dp[i2][i5];
        }
      }
    }
    dp[cnt2][cnt5]++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int v) {
    S[++top] = v;   
}

int pop() {
    top--;
    return S[top + 1];
}

int main(void) {
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s" ,s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2744
#include <iostream>
#include <math.h>
using namespace std;

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

    int X;
    cin >> X;
    int max = 0;
    int temp;

    // 1は計算に入れると長くなるので個別にする
    if(X == 1){
        max = 1;
    }
    else{
        for(int i = 2; i <= X; ++i){
            for(int j = 2; j <= X; ++j){
                temp = pow(i, j);
                if((max < temp) && (temp <= X)){
                    max = temp;
                }
                if(X < temp){
                    continue;
                }
            }
        }
    }
    cout << max << "\n";

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	int sum = 0;
	int minus = 0;
	int x = inf;
	zip(i, 0, n)
	{
		if (a[i] < 0)
		{
			minus++;
		}
		x = min(x, abs(a[i]));
		sum += abs(a[i]);

	}
	if (minus % 2 == 0)
		cout << sum << en;
	else
	{
		cout << sum - 2 * x << en;
	}



	return 0;

}



Measured memory_bytes: 1024
#pragma optimize GCC("Ofast")
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<bool, bool> pbb;
typedef pair<ld, ld> pdd;

const int inf = (int)1e9 + 9;
const ll linf = (ll) 1e18;
const ld eps = 1e-7;
const int mod = (int) 1e9 + 7;

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

vb used;
vector<vi> g;
vi mt;

bool dfs(int pos)
{
	if (used[pos])
	{
		return false;
	}
	used[pos] = true;
	for (auto i : g[pos])
	{
		if (mt[i] == -1 || dfs(mt[i]))
		{
			mt[i] = pos;
			return true;
		}
	}
	return false;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	srand(time(0));
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	used.assign(n, false);
	mt.assign(n, -1);
	vector<pii> red(n), blue(n);
	for (int i = 0; i < n; i++)
	{
		cin >> red[i].fst >> red[i].scn;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> blue[i].fst >> blue[i].scn;
	}
	g.assign(n, vi());
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (blue[i].fst > red[j].fst && blue[i].scn > red[j].scn)
			{
				g[i].pb(j);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		used.assign(n, false);
		dfs(i);
	}
	for (auto i : mt)
	{
		if (i != -1)
		{
			res++;
		}
	}
	cout << res;
}

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

int main()
{
	int sum[2]={};
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(i%2)
		{
			if(s[i]!='0')sum[0]++;
			else sum[1]++;
		}
		else
		{
			if(s[i]!='1')sum[0]++;
			else sum[1]++;
		}
	}
	cout<<min(sum[0],sum[1])<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int constant=1e6;
const ll mod=1e9+7;
/*bool p[1000];
void sieve(){
p[0]=p[1]=1;
for(int i=2;i<=100;i++){
    for(int j=i*i;j<=100;j+=i){
        p[j]=1;
    }
}
}*/
map<int,bool>visited;
vector<int>v[constant];
int dp[constant];
set<int>s;
set<int>::iterator it;
void dfs(int node){
visited[node]=1;
for(int i=0;i<v[node].size();i++){
    if(!visited[v[node][i]]){
        //cout<<"node "<<node<<" dp "<<dp[node]<<" child "<<v[node][i]<<endl;
        dfs(v[node][i]);
    }
        dp[node]=max(dp[node],(1+dp[v[node][i]]));
}

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,x,y,mx=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        s.insert(x);
        s.insert(y);
    }
    for(it=s.begin();it!=s.end();it++){
        dfs(*it);
        

    }
    for(it=s.begin();it!=s.end();it++){

        mx=max(mx,dp[*it]);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 41856
#include <bits/stdc++.h>
  
int main(){
  int n, m;
  
  while(scanf("%d%d" ,&n ,&m), (n | m)){
    int N = n+m, arr[N];
    for(int i = 0 ; i < N ; i++){
      scanf("%d" ,arr+i);
    }
    std::sort(arr, arr+N);
  
    int max = arr[0];
    for(int i = 0 ; i < N ; i++){
      max = std::max(max, arr[i] - arr[i-1]);
    }
    printf("%d\n" ,max);
  }
  
  return 0;
}

Measured memory_bytes: 1284
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    if s + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 9184
#include <stdio.h>

int	main(void)
{
  	int	n;
  	int	k;
  	int a[200002];
  	int	i;
  
  	scanf("%d %d\n", &n, &k);
  	for(i=0; i<n; i++)
    {
      	scanf("%d", &a[i]);
    }
  
  	for(i=k; i<n; i++)
    {
      	if(a[i-k] < a[i])
          	printf("Yes\n");
      	else
          	printf("No\n");
    }
  	return(0);
}

Measured memory_bytes: 2440
#include <stdio.h>

char* day[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int initday[12]={3,-1,0,3,5,1,3,-1,2,4,0,2};

int main(void){
	int month, date;
	while(scanf("%d %d",&month,&date), month--!=0) printf("%s\n",day[(initday[month]+date)%7]);
	return 0;
}

Measured memory_bytes: 0
import java.lang.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String s=sc.next();
			if(s.matches("^>'(=+)#\\1~$"))
				System.out.println("A");
			else if(s.matches("^>\\^(Q=)+~~$"))
				System.out.println("B");
			else
				System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    int cnt = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(L[k] != L[j] && L[i] != L[j] && L[i] != L[k] && L[k] + L[j] > L[i] && L[i] + L[k] > L[j] && L[j] + L[i] > L[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> dp(n+1,vector<int>(n+1,0));
	int ans(0);
	for(int i(n-1);i>=0;--i){
		for(int j(n-1);j>=0;--j){
			if(s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
			if(abs(i-j) >= dp[i][j]) ans = max(ans,dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 98176
#include<bits/stdc++.h>
#define P pair<int,int>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
const int N=100005;
int n,a[N],b[N],cnt,mp[N];
P p[N*2];
const ll inf=(1ll<<60);
ll ans,now,sum1,sum2;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
	   scanf("%d%d",&a[i],&b[i]);
	   p[++cnt]=P(a[i],i);
	   p[++cnt]=P(b[i],i);
	   sum1+=a[i];
	   sum2+=b[i];	
	}
	sort(p+1,p+cnt+1);
	for (int i=1;i<=n;i++)
	{
		now+=p[i].fir;
		mp[p[i].sec]++;
	}
	ans=inf;
	for (int i=1;i<=n;i++)
	{
		if (mp[p[i].sec]==0){
			ans=min(ans,now-p[n].fir-p[n-1].fir+a[i]+b[i]);
		}else if (mp[p[i].sec]==1){
			if (a[i]<b[i]) ans=min(ans,now-((p[n].sec!=i)?p[n].fir:p[n-1].fir)+b[i]);
			else ans=min(ans,now-((p[n].sec!=i)?p[n].fir:p[n-1].fir)+a[i]);
		}else {ans=now;break;}
	}
	printf("%lld\n",min(ans,min(sum1,sum2)));
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int ans = (int)Math.floor(a + Math.pow(a, 2) + Math.pow(a, 3));

		System.out.println(ans);
	}

}


Measured memory_bytes: 35684
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int power(int x, int n)
{
	if (n == 0) {
		return 1;
	}
	else if (n % 2 == 0) {
		int t = power(x, n / 2);
		return 1LL * t * t % MOD;
	}
	else {
		return 1LL * x * power(x, n - 1) % MOD;
	}
}

const int N = 100000 * 2 + 1;

vector<int> fact(N);
vector<int> ifact(N);

int comb(int n, int r)
{
	return 1LL * fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}

int main()
{
	fact[0] = 1;
	ifact[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = 1LL * i * fact[i - 1] % MOD;
		ifact[i] = power(fact[i], MOD - 2);
	}
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int ans = 0;
	for (int x = 0; x < W - B; ++x) {
		int temp = 1LL * comb(B + H - A - 1 + x, H - A - 1) * comb(A - 1 + W - B - 1 - x, A - 1) % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

signed main(){
    ll n,k;
    cin >> n >> k;
    mint fact[n+1] = {};
    fact[0] = 1;
    rep(i,1,n+1) fact[i] = fact[i-1]*i;

    rep(i,1,k+1){
        if(n - k - i + 1 < 0){
            cout << 0 << endl;
        }
        else{
            mint ans;
            ans = fact[k-1]/fact[i-1]/fact[k-i];
            ans *= fact[n-k+1]/fact[i]/fact[n-k-i+1];
            cout << ans << endl;
        }
    }    
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
 
int main(void){
  int i=0,j=0;
  scanf("%d %d",&i,&j);
  if(j>i){
	  int num=1;
	   for(;j>i;j-=i-1)
		   num++;
	   printf("%d",num);
	}
	else{
		if(j<=1){
			printf("0");
		}
		else{
			printf("1");
		}
	}
  return 0;
}

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

int main() {
  int N,K,X,Y;
  int sum = 0;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  for(int i=0;i<N;i++){
    if(i<=K-1){
      sum += X;
    }
    else if(K <= i <= N-1){
      sum += Y;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

ans = 10 ** 5
for i in range(3):
    for j in range(3):
        if i != j:
            k = 3 - i - j
            cost = abs(A[i] - A[j]) + abs(A[j] - A[k])
            ans = min(cost, ans)

print(ans)


Measured memory_bytes: 2940
n,m = map(int,input().split())
c = list(map(int,input().split()))

c.sort(reverse = True)

dp = [[float('inf') for i in range(n+1)] for j in range(m+1)]

for j in range(m+1):
    dp[j][0] = 0

for j in range(1,m+1):
    for i in range(c[j-1],n+1):
        dp[j][i] = min(dp[j-1][i], dp[j][i-c[j-1]] + 1)

print(dp[m][n])

Measured memory_bytes: 40972
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;

int main(){
int n;
cin>>n;
vector<ll>a(n+1);
a.at(0)=2;
a.at(1)=1;
for(int i=2;i<=n;i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
}
cout<<a.at(n)<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int ans = n;
    for(int i=0; i<=n; i++){
        int t = i;
        int cc = 0;
        while(t > 0) cc += t%6, t/= 6;
        t = n - i;
        while(t > 0) cc += t%9, t/=9;
        ans = min(ans, cc);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
def checkValue(count):
    for v in count.values():
        if v % 2 != 0:
            return 'No'
    return 'Yes'

if __name__ == "__main__":
    w = input()

    count = {}

    for i in range(len(w)):
        if w[i] in count:
            count[w[i]] = count[w[i]] + 1
        else:
            count[w[i]] = 1

    print(checkValue(count))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> tp;
struct qq
{
    ll l, r;
    ll id;
}D[100005];
ll ans[1000005];
ll a[10000000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        if((a[i] * 4 * m) >= sum)
        {
            cnt++;
        }
    }
    if(cnt < m)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint D;
llint c[30], csum;
llint s[400][30];
vector<llint> ans;

llint score(vector<llint> ans, llint n)
{
	llint last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 0; i < n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

void search(vector<llint> &ret)
{
	llint cur = score(ret, D);
	for(int t = 0; t < 1000000; t++){
		llint x = rand() % D, y = rand() % D;
		swap(ret[x], ret[y]);
		llint nxt = score(ret, D);
		if(nxt < cur) swap(ret[x], ret[y]);
		else cur = nxt;
		
		x = rand() % D, y = rand() % 26;
		llint tmp = ret[x];
		ret[x] = y;
		nxt = score(ret, D);
		if(nxt < cur) ret[x] = tmp;
		else cur = nxt;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	ans.resize(D);
	for(int i = 0; i < D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i+1);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	
	search(ans);
	
	for(int i = 0; i < D; i++) cout << ans[i]+1 << endl;
	
	
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(2e6);

ll cul(ll n,ll m,ll r,ll a,ll b){
	ll res=0;
	for(int i=0;i<=n-m;i++){
		ll rr=r-m*a-i*(b+1);
		if(rr<0)break;
		if(i%2==0){
			(res+=p.comb(n+rr,rr)*p.comb(n-m,i)%mod)%=mod;
		}else{
			(res-=p.comb(n+rr,rr)*p.comb(n-m,i)%mod)%=mod;
		}
	}
	return res;
}


ll solve(ll n,ll m,ll r){
	ll res=p.comb(n+r,r);
	ll sum=0;
	for(ll i=1;i<=r;i++){
		if((ll)m*i>r)break;
		(sum+=cul(n,m,r,i,i-1)-cul(n,m,r,i+1,i-1))%=mod;
	}
	(sum*=p.comb(n,m))%=mod;
	(res-=sum)%=mod;
	if(res<0)res+=mod;
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,m,l,r; cin >> n >> m >> l >> r;
	ll res=(solve(n,m,r)-solve(n,m,l-1))%mod;
	if(res<0)res+=mod;
	printf("%lld\n",res);
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
struct Node {
    int x, y;
} up[N << 4];
int a[N * 3], n, m, ans, MAX;
int f[N][N], p[N], S[N], L[N][N];
int b[4];
inline int read () {
    int tot = 0, f = 1; char c = getchar ();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar (); }
    while (c >= '0' && c <= '9') { tot = tot * 10 + c - '0'; c = getchar (); }
    return tot * f;
}
inline int chkmax (int &a, int b) { return a = max (a, b); }
signed main () {
    n = read ();
    for (int i = 1; i <= 3 * n; i++) a[i] = read ();
    for (int i = 1; i < n; i++) {
        int psi = 2 + (i - 1) * 3;
        if (a[psi + 1] == a[psi + 2] && a[psi + 2] == a[psi + 3]) ans++, p[i] = 1;
    }
    memset (f, -0x3f, sizeof (f)); memset (S, -0x3f, sizeof (S)); memset (L, -0x3f, sizeof (L));
    L[a[1]][a[2]] = L[a[2]][a[1]] = f[a[1]][a[2]] = f[a[2]][a[1]] = S[a[1]] = S[a[2]] = 0;
    for (int i = 1; i < n; i++) {
        if (p[i]) continue;
        m = 0; int psi = 2 + (i - 1) * 3;
        f[a[psi + 1]][a[psi + 2]] = chkmax (f[a[psi + 2]][a[psi + 1]], max (MAX, L[a[psi + 3]][a[psi + 3]] + 1));
        f[a[psi + 1]][a[psi + 3]] = chkmax (f[a[psi + 3]][a[psi + 1]], max (MAX, L[a[psi + 2]][a[psi + 2]] + 1));
        f[a[psi + 2]][a[psi + 3]] = chkmax (f[a[psi + 3]][a[psi + 2]], max (MAX, L[a[psi + 1]][a[psi + 1]] + 1));
        up[++m].x = a[psi + 1]; up[m].y = a[psi + 2];
        up[++m].x = a[psi + 1]; up[m].y = a[psi + 3];
        up[++m].x = a[psi + 2]; up[m].y = a[psi + 3];
        b[1] = a[psi + 1]; b[2] = a[psi + 2]; b[3] = a[psi + 3];
        sort (b + 1, b + 4); int A = b[1], B = b[2], C = b[3];
        if (B == C) swap (C, A);
        for (int j = 1; j <= n; j++) {
            if (S[j] < 0) continue;
            up[++m].x = j; up[m].y = A; up[++m].x = j; up[m].y = B; up[++m].x = j; up[m].y = C;
            f[A][j] = chkmax (f[j][A], S[j]);
            f[B][j] = chkmax (f[j][B], S[j]);
            f[C][j] = chkmax (f[j][C], S[j]);
        }
        if (A == B) {
            for (int j = 1; j <= n; j++)
            if (L[A][j] >= 0) {
                up[++m].x = j; up[m].y = C;
                f[C][j] = chkmax (f[j][C], L[A][j] + 1);
            }
        }
        for (int j = 1; j <= m; j++) {
            int x = up[j].x, y = up[j].y;
            L[x][y] = L[y][x] = f[x][y];
            MAX = max (MAX, f[x][y]);
            S[x] = max (S[x], f[x][y]); S[y] = max (S[y], f[y][x]);
        }
    }
    printf ("%d\n", max (MAX, f[a[n * 3]][a[n * 3]] + 1) + ans);
    return 0;
}


Measured memory_bytes: 35252
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
typedef pair<long long ,long long> P;
long long sum1;
long long sum2;
long long n;
P a[100006];
long long b;
long long c;
int main()
{
    cin>>n;
    rep(i,n)
    {
        cin>>b;
        a[i]=P(b,i);
    }
    sort(a,a+n);
    long long t=1;
    while(a[t].first<0&&t<=n-2)//n small x
    {
        t++;
    }
    rep(i,t)
    {
        sum1+=a[i].first;
    }
    rep2(i,t,n)
    {
        sum2+=a[i].first;
    }
    cout<<sum2-sum1<<endl;
    if(t==n-1)
    {
        c=a[t].first;
        rep(i,n-1)
        {
            cout<<c<<" "<<a[i].first<<endl;
            c-=a[i].first;
        }
    }
    else{
        c=a[0].first;
        rep2(i,t,n-1)
        {
            cout<<c<<" "<<a[i].first<<endl;
            c-=a[i].first;
        }
        cout<<a[n-1].first<<" "<<c<<endl;
        c=a[n-1].first-c;
        rep2(i,1,t)
        {
            cout<<c<<" "<<a[i].first<<endl;
            c-=a[i].first;
        }
    }
    return  0;
}

Measured memory_bytes: 3456
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    A,B=map(int,input().split())
    if A==B:
        print(A*2)
    else:
        print(max(A,B)*2-1)

if __name__ == '__main__':
    main()


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

#define int long long

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int M[N];

signed main(){
    int n;
	cin >> n;    
    int pre = 1;
    int prex = 0;
    int dp;
    for(int i=1; i<=n; i++){
        int x;
        scanf("%lld", &x);
        if(x == prex) continue;
    	dp = (M[x] + pre) % mod;
//        cout << i << " " << dp << " ss\n";
        M[x] = (M[x] + pre) % mod;
        pre = dp;
        prex = x;
    }
    
    cout << dp;
    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[300000];

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    --a, --b, --c, --d;
    scanf("%s", s);
    auto check = [](int a, int b) {
      for (int i = a; i < b - 1; i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
          return false;
        }
      }
      return true;
    };
    bool result = check(a, c) && check(b, d);
    if (result && c > d) {
      bool change = false;
      for (int i = b; i <= d; i++) {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
          change = true;
        }
      }
      result &= change;
    }
    printf("%s\n", result ? "Yes" : "No");
  }

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
	int h, r;
	cin >> h >> r;
	if (h*-1 == r) {
		cout << "0" << endl;
		goto a;
	}
	if (h + r > 0) {
		cout << "1" << endl;
		goto a;
	}
	if (h + r < 0) {
		cout << "-1" << endl;
		goto a;
	}
	a:;
}


Measured memory_bytes: 3108