akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut map = HashMap::new();
    for k in 1..(n + 1) {
        let mut l = 2;
        let mut k = k;
        while l * l <= k {
            if k % l == 0 {
                if !map.contains_key(&l) {
                    map.insert(l, 0);
                }
                *map.get_mut(&l).unwrap() += 1;
                k /= l;

                if l == 1 {
                    l += 1;
                }
                continue;
            }
            l += 1;
        }
        if !map.contains_key(&k) {
            map.insert(k, 0);
        }
        *map.get_mut(&k).unwrap() += 1;
        //dbg!(&map);
    }

    let MOD = 1_000_000_007usize;
    let mut ans = 1;
    for k in &map {
        if *k.0 == 1 {
            continue;
        }
        ans = ans * (*k.1 + 1) % MOD;
    }
    println!("{}", ans);
    //dbg!(ans, map);
}

#[allow(unused_imports)]
use std::cmp::*;
use std::collections::HashMap;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
 
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)
 
#define ALL(c) (c).begin(), (c).end()
#define CLEAR(x) memset(x,0,sizeof x);
 
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>
 
#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
 
using namespace std;
 
int num,i,j,len;
string s;
char l,n;
VS v;
 
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>num;
	cin >>s;
	l=s[s.size()-1];
	v.PB(s);
	for (i=1;i<num;i++)
	{
		cin >>s;
		n=s[0];
		if (n!=l)
		{
			cout <<"No"<<endl;
			return 0;
		}
		REP(j,len)
		{
			if (v[j]==s)
			{
				cout <<"No"<<endl;
				return 0;
			}
		}
		v.PB(s); len++; l=s[s.size()-1];
	}
	cout <<"Yes"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/

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

int main() {
  int n; cin >> n;
  vector<int> l(2*n);
  for (int i = 0; i < 2*n; ++i) cin >> l[i];
  sort(l.begin(), l.end());
  ll ans = 0;
  for (int i = 0; i < n; ++i) ans += l[i*2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    for j in range(Y // 5000 + 1):
        temp = N - i - j
        if Y - 10000 * i - 5000 * j < 0 or temp < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * temp:
            yen[0] = i
            yen[1] = j
            yen[2] = temp
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
    if (Y - 10000 * i) // 5000 > N - i:
        break
print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N, P;
ll dp[5555];

int main(){
    
    dp[0] = 1;
    
    cin >> N >> P;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        for(int j = 5050; j >= 0; j--){
            dp[j + a] += dp[j];
        }
    }
    ll ans = 0;
    for(int i = 0; i <= 5050; i++){
        if(i % 2 == P)ans += dp[i];
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    string str;
    cin >> str;
    reverse(str.begin(), str.end());
    double num = 0;
    long long sum = 0;
    for(int i = 0; i < (int) str.size(); ++i) {
        num += (str[i] - '0') * pow(10, i);
        sum += str[i] - '0';
    }
//    cout << num << endl;
//    cout << sum << endl;
    if((long long) num % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <sstream>

void get_array(int* arr, std::istream& stream) {
    std::string buf;
    std::getline(stream, buf);

    std::stringstream str;
    str << buf;
    std::string tmp;
    for (int i = 0; std::getline(str, tmp, ' '); ++i) {
        arr[i] = std::stoi(tmp);
    }
    return;
}

int count(int const* s, const int n, int const* t, const int q) {
    int counter = 0;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (s[j] == t[i]) {
                ++counter;
                break;
            }
        }
    }
    return counter;
}

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    int s[10000];
    get_array(s, std::cin);

    int q;
    std::cin >> q;
    std::cin.ignore();

    int t[500];
    get_array(t, std::cin);

    std::cout << count(s, n, t, q) << std::endl;

    return 0;
}

Measured memory_bytes: 3324
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

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

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


int main()
{
	int N, M;
	string U, T;
	vector<string> ids;
	bool key = false;
	
	cin >> N;
	REP(N)
	{
		cin >> U;
		ids.push_back(U);
	}
	cin >> M;
	REP(M)
	{
		cin >> T;
		if (find(ids.begin(), ids.end(), T) != ids.end())
		{
			//見つかった場合
			if (key)
			{
				cout << "Closed by " << T << endl;
				key = !key;
			} else {
				cout << "Opened by " << T << endl;
				key = !key;
			}
		} else {
			cout << "Unknown " << T << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  vector<map<char,int>> mp(n);
  rep(i,n){
    string s;
    cin>>s;
    int sz=s.size();
    rep(j,sz){mp[i][s[j]]++;}
  }

  for(char i='a'; i<='z'; i++){
    int cnt=inf;
    rep(j,n){cnt=min(cnt,mp[j][i]);}
    rep(j,cnt){cout<<i;}
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,n-1){
        if (x>=a.at(i)) {ans++;
        x-=a.at(i);}
        
    }
    if (a.at(n-1)==x) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
//std::numeric_limits<int>::max(), min()

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

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

ll N, W;
std::vector<std::vector<ll>> dp;
std::vector<P> items;

// dp[n][v] : 0個目からn個目までを、
// 価値がv以上となるように積めたときの,重さの最小値
const ll INF  = 1e15;
const ll INIT = 1e16; // 更新されてINFになったのと初期値のINFの区別がないと、
// すでに計算結果で更新されたのにも関わらず初期値で未更新と勘違いしてしまう
ll sol ( int n, int v ){
  if ( v < 0 ) return 0;
  if ( n < 0 && v > 0 ) return INF;
  else if ( n < 0 && v == 0 ) return 0;

  if ( dp[n][v] != INIT ) return dp[n][v];
  return dp[n][v] = std::min( sol(n-1,v-items[n].second)+items[n].first, sol(n-1,v) );
}

int main (void) {

  std::cin >> N >> W;
  items.resize(N);  for(ll i=0; i<N; i++) std::cin >> items[i].first >> items[i].second;
  ll vmax = 0; rep(i,N) vmax+=items[i].second;
  dp.resize(N+1); rep(i,N+1) dp[i].assign(vmax+1, INIT);

  ll ans = 0;
  for(int v=0; v<vmax+1; v++) {
    if ( sol(N-1,v) <= W ) ans = v;
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 79488
n, t = [ int(v) for v in input().split() ]
on_list = [ int(v) for v in input().split() ]

total = 0
part = t
for i in range(n-1):

	if on_list[i+1] > on_list[i] + t:
		total+= part
		part = t
	else:
		part += on_list[i+1] - on_list[i]
total+= part
print(total)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int t=ceil(a-1)/d+1,s=ceil(c-1)/b+1;
//		cout<<t<<' '<<s;
		if(s>t)
		cout<<"No";
		else
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i,N) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = INF;
    for(int i=0;i<N-K+1;i++){
        chmin(ans, abs(h[i] - h[i+K-1]));
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


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

using namespace std;

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

const int inf = 1e9;

int dp[2][2][5050];

signed main()
{
	int n; cin >> n;
	
	vector<int> t(n-1);
	
	rep(i, n-1) cin>>t[i+1];
	
	rep(i,2)rep(j,2)rep(k,n/2+1) dp[i][j][k] = inf;
	
	dp[0][1][0] = 0;
	
	rep(i, n) {
		//cout<<"t["<<i<<"] = " << t[i] << endl;
		rep(j, min(n/2, i)+1) {
			dp[(i+1)%2][1][j+1] = min(dp[i&1][1][j], dp[i&1][0][j] + t[i]);
			dp[(i+1)%2][0][j] = min(dp[i&1][0][j], dp[i&1][1][j] + t[i]);
		}
		dp[(i+1)&1][1][0] = inf;
	}
	
	//rep(i,n) rep(j,n/2+1) printf("dp[%d][%d] = %d\n", i,j,dp[i][j]);
	
	cout << min(dp[0][0][n/2], dp[0][1][n/2]) << endl;
}

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

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

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: 2??¨??°???????????????????????§??????????????°
// TimeComplexity: $ \mathcal{O}(EV) $ 
// Verifyed: AOJ GRL_7_A

int bipartite_matching(const G &graph){
	int res=0,n=graph.size();
	vector<int> match(n,-1),used(n,0);

	auto dfs=[&](int v){
        auto func=[&](int v,auto func)->int{
        	used[v]=true;
			for(auto &e:graph[v]){
				const int u=e.to,w=match[u];
				if(w<0||(!used[w] && func(w,func))){
					match[v]=u,match[u]=v;
					return true;
				}
			}
			return false;
        };
        return func(v,func);
    };

	rep(v,n){
		if(match[v]>=0) continue;
		fill(_all(used),false);
		if(dfs(v)) res++;
	}
	return res;
}

int main(void){
	int x,y,e;
	cin >> x >> y >> e;
	G graph(x+y);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,x+b);
	}

	cout << bipartite_matching(graph) << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll A[32]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
   ll K;
   cin >> K;
   K--;
   cout << A[K] << endl;
}

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

int N;

long long int M[10][10];


int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		int n, m;
		m = i % 10;
		int tmp = i;
		while (tmp > 0) { n = tmp % 10; tmp /= 10; }
		M[n][m]++;
	}

	long long int ans = 0;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += M[i][j] * M[j][i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    int n,k;
    ll s;
    cin>>n>>k>>s;
    for(int i=1; i<=k; i++)
        printf("%I64d ",s);
    ll p=s+1;
    if(p>1e9)
        p=1;
    for(int i=1; i<=n-k; i++)
        printf("%I64d ",p);
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	ll n, k; cin >> n >> k; k++;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i, n) {
		int x;
		cin >> x;
		x--;
		a[i] = x;
	}
	ll now = 0;
	b[0] = 1;
	ll cnt = 1;
	while (true) {
		if (cnt == k) {
			now++;
			cout << now << endl;
			return 0;
		}
		if (b[a[now]] == 0) {
			cnt++;
			now = a[now];
			b[now] = cnt;
		}
		else {
			now = a[now];
			cnt++;
			break;
		}
	}
	k -= cnt;
	ll loop = cnt - b[now];
	ll r = k % loop;
	rep(i, n) {
		if (b[i] == b[now]+r) {
			i++;
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

int main()
{

   long long n,i,j,sum=0,sum1=0,o;
    cin>>n;
   long long arr[n+1],brr[n];
    for(i=0; i<n+1; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }

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

    for(i=0; i<n; i++)
    {
        for(j=i; j<=i+1; j++)
        {
            if(brr[i]>=arr[j])
            {
                brr[i]-=arr[j];
                arr[j]=0;

            }
            else
            {
                arr[j]-=brr[i];
                brr[i]=0;

            }

        }

    }
    for(i=0; i<n+1; i++)
    {

        sum1+=arr[i];
    }
    //cout<<sum<<" "<<sum1<<endl;

   o=sum-sum1;
    cout<<o<<endl;





    return 0;

}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
long long a,b,c,e,f;
 
int main()
{
	cin>>a>>b>>c;
	e = max(a - c,(long long)0);
	f = max(b - max(c - a,(long long)0),(long long)0);
	cout<<e<<' '<<f;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

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

    vector<vector<int>> v(n,vector<int>(0));
    rep(i,0,q){
        int cmd;cin>>cmd;
        if(cmd==0){
            int t,x;
            cin>>t>>x;
            v[t].push_back(x);
        }else if(cmd==1){
            int t;cin>>t;
            rep(p,0,v[t].size()){
                if(p)cout<<" ";
                cout<<v[t][p];
            }
            cout<<endl;
        }else {
            int t;cin>>t;
            v[t].clear();
        }
    }
    

}



/*

*/


Measured memory_bytes: 5788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"
#define w 1e5
const ll q=1e5+2;
vector<ll> dp(q,1e12);
//dp[i] be minimium cost for reaching ith stone
ll k;
void solve()
{
    ll n;
    k=2;
    cin>>n;
    vl a(n+1);
    loop(i,1,n+1)
    cin>>a[i];
    dp[1]=0;
    loop(i,1,n+1)
    {
        for(ll j=1;j<=k;j++)
        {
            if(i+j<=n)
            dp[i+j]=min(dp[i+j],abs(a[j+i]-a[i])+dp[i]);
        }
    }
    cout<<dp[n];
}
int main() {
	// your code goes here
	io;
    solve();
	return 0;
}


Measured memory_bytes: 1792
/*******************************************
* AUTHOR : Adnan Masroor :-)
* NICK : adnanlari
* COLLEGE : NIT Durgapur
********************************************/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll MOD=1000000007,BMOD=100000000700000;

int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	/*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif*/
	//the main code starts here
    
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	if(n!=0 && n!=1)
		ans+=n*(n-1);
	if(m!=0 && m!=1)
		ans+=m*(m-1);
	cout<<(ans/2)<<"\n";





	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
a = []
b = []

for i in range(M):
    c, d = map(int, input().split())
    a.append(c)
    b.append(d)

s = set()

for i in range(M):
    if b[i] == N:
        s.add(a[i])

for i in range(M):
    if a[i] == 1 and b[i] in s:
        print('POSSIBLE')
        sys.exit()

print('IMPOSSIBLE')


Measured memory_bytes: 21888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int a = in.nextInt();
        int b = in.nextInt();
        String as = "";
        String bs = "";
        for (int i = 0; i < b; i++) {
            as += a;
        }
        for (int i = 0; i < a; i++) {
            bs += b;
        }
        System.out.println(String.CASE_INSENSITIVE_ORDER.compare(as, bs) < 0 ? as : bs);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 20692
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include <deque>
#include<sstream>

using namespace std;
typedef long long int lli;

const int INF = 100100100;

int main()
{
    string line, s;
    getline(cin, line);
    istringstream iss(line);
    lli begin = -1, end = -1;

    char c;
    int i = 1;
    deque<char> v;
    while (iss >> c) {
        if(v.size() >= 3) v.pop_front();
        v.push_back(c);

        if (v.size() == 2) {
            if (v[0] == v[1]) {
                begin = i - 1;
                end = i;
                break;
            }
        }

        if(v.size() >= 3) {
            if ((v[0] == v[1]) | (v[1] == v[2]) | (v[0] == v[2])) {
                begin = i - 2;
                end = i;
                break;
            }
        }

        i++;

    }

    cout << begin << " " << end << endl;
    return 0;
}

Measured memory_bytes: 3724
def main():
    s = [ss == 'R' for ss in input()]
    n = len(s)

    child = [1] * n

    # move right
    for i in range(n-2):
        if s[i]:
            if s[i+1]:
                c = child[i]
                child[i] = 0
                child[i+2] += c

    # move left
    for i in range(2, n)[::-1]:
        if not s[i]:
            if not s[i-1]:
                c = child[i]
                child[i] = 0
                child[i-2] += c
    print(*child)


main()


Measured memory_bytes: 49300
from bisect import bisect_left


def main():
    n = int(input())
    l = [int(x) for x in input().split()]
    l.sort()
    answer = 0
    for i in range(n):
        for j in range(i + 1, n):
            index = bisect_left(l, l[j] + l[i])
            answer += index - j - 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
//Debt Hell
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll debt(ll x, int n){
  if(n==0)return x;
  else{
    x*=1.05;
    if(x%1000!=0)return debt(x-x%1000+1000, n-1);
    else return debt(x, n-1);
  }
}

int main(){
  int n;
  scanf("%d", &n);
  printf("%lld\n", debt(100000, n));
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>

struct pair{int w;int s;}ans;
bool used[3001][3001];

using namespace std;

int main(){
	memset(used,false,sizeof(used));
	ans.w = 0;
	ans.s = 0;
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	vector<int> water;
	vector<int> suger;
	int num = 0;
	while(1){
		int sum = num * a * 100;
		if(sum > f) break;
		if(num > 0)water.push_back(sum);
		while(1){
			sum += b*100;
			if(sum > f) break;
			water.push_back(sum);
		}
		num++;
	}
	
	num = 0;
	while(1){
		int sum = num * c;
		if(sum > f) break;
		suger.push_back(sum);
		while(1){
			sum += d;
			if(sum > f) break;
			suger.push_back(sum);
		}
		num++;
	}
	sort(suger.begin(),suger.end());
	sort(water.begin(),water.end());
	
	for(int i = 0;i < water.size();i++){
		for(int j = 0;j < suger.size();j++){
			if(!used[water[i]][suger[j]]){
				if((water[i]+suger[j] > f) || (water[i]*e < suger[j]*100))break;
				if(ans.s*(water[i]+suger[j]) <= suger[j]*(ans.w+ans.s)){
					ans.s = suger[j];
					ans.w = water[i];
				}
				used[water[i]][suger[j]] = true;
			}
		}
	}
	
	cout << (ans.w+ans.s) << " " << ans.s << endl;
	return 0;
}

Measured memory_bytes: 10232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner cin = new Scanner(System.in);
		
		int N = cin.nextInt();
		int M = cin.nextInt();
		
		
		int ans = N*(N-1)/2+M*(M-1)/2;
		

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
B=0
for i in range(1, N+2):
    B+=(abs(A[i]-A[i-1]))
for i in range(N):
    print(B-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])+abs(A[i+2]-A[i]))

Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define INF 1e9

int n,k,q;
int res = INF;

void solve(int border,vector<int> &a){
    using PQ = priority_queue<int,vector<int>,greater<int>>;
    PQ qu,seg;
    rep(i,n){
        if(a[i] < border){
            while(!seg.empty()){
                if((int)seg.size() >= k){
                    qu.push(seg.top());
                }
                seg.pop();
            }
        }else{
            seg.push(a[i]);
        }
    }
    while(!seg.empty()){
        if((int)seg.size() >= k){
            qu.push(seg.top());
        }
        seg.pop();
    }
    if((int)qu.size() < q) return;
    int Y = qu.top();
    rep(i,q-1){
        qu.pop();
    }
    int X = qu.top();
    res = min(res, X-Y);
}


int main(void){
    cin>>n>>k>>q;
    vector<int> a(n);
    set<int> sm;
    rep(i,n){
        cin>>a[i];
        sm.insert(a[i]);
    }
    for(int x : sm){
        solve(x,a);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 384
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, t] <- map read . words <$> getLine
  let toTuple [c, t] = (c, t)
  cs <- replicateM n $ toTuple <$> map read . words <$> getLine
  let result = sortOn fst $ filter ((<= t) . snd) cs
  putStrLn $ if length result == 0 then "TLE" else show . fst $ head result

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;
    int ans=MOD;
    rep(i,s.size()-t.size()+1){
        int cnt=0;
        rep(j,t.size()){
            if(s[i+j]!=t[j])cnt++;
        }
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3656
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}
use input::*;

fn main() {
    let (a, b, c, d): (usize, usize, usize, usize);
    input!(a, b, c, d);
    let l = a + b;
    let r = c + d;

    if l > r {
        println!("Left");
    } else if l < r {
        println!("Right")
    } else {
        println!("Balanced");
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

int main()
{
	ll n;
	cin >> n;
	ll a[n],b[n],c[n],dp[3][n];
	for(ll i=0;i<n;i++) { cin >> a[i]; cin  >> b[i]; cin >> c[i]; }
	
	dp[0][0]=a[0]; dp[1][0]=b[0]; dp[2][0]=c[0];
	
	for(ll i=1;i<n;i++)
	{
		dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
	}
	
	cout << max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1])) << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(){
  int a,b;
  int i;
  int result = 0;
  scanf("%d %d",&a,&b);
  //printf("%d+%d\n",a,b);
  for(i=0;i<2;++i){
    if(a > b){
      result += a;
      --a;
    }else{
      result += b;
      --b;
    }
  }
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 128
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;
    var height = fieldInfo[1] - 0;
          
    if(!width && !height){
      break;
    }
          
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    var c;
    for(var y = height; y--;){
      i++;
      var ni = input[i];
      for(var x = 0; x < width; x++){
        c = ni[x];
        
        if(c === '.'){
        }else if(c === '1' || c === '2' || c === '3' || c === '4' || c === '5'){
          var e = elem[c - 1];
          e[e.length] = pos(x, y);
        }else if(c === 'S'){
          start = pos(x, y);
        }else{
          goal = pos(x, y);
        }
          
      }
    }
          
    var INF = 1 << 30;
    var bestElement = -1;
    var distance = INF;
    
    for (var startElem = 0; startElem < 5; startElem++) {
      
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        var initdph = dp[h];
        initdph.length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          initdph[hidx] = INF;
        }
      }
      
      var first = (startElem + 1) % 5;
      var firstLength = elem[first].length;
      var dpf = dp[first];
      var elemf = elem[first];
      for (var j = 0; j < firstLength; j++) {
        dpf[j] = dist(start, elemf[j]);
      }
      
      for (var e = 0; e < 3; e++) {
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var dpnw = dp[now];
        var dpnx = dp[next];
        var elnw = elem[now];
        var elnx = elem[next];
        var nowLength = elnw.length;
        var nextLength = elnx.length;
        for (var j = 0; j < nowLength; j++) {
          var dpnwj = dpnw[j];
          var elnwj = elnw[j];
          for (var k = 0; k < nextLength; k++) {
            dpnx[k] = min(
              dpnx[k],
              dpnwj + 
                  dist(elnwj, elnx[k]));
          }
        }
      }

      var last = (first + 3) % 5;
      var dpl = dp[last];
      var ell = elem[last];
      var lastLength = ell.length;
      for (var j = 0; j < lastLength; j++) {
        var d = dpl[j] + dist(ell[j], goal);
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
                  
      }
                
    }
              
    if (distance == INF) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
          
    i++;
  }
            
          
}
          
function dist(from, to){
  return abs((from >> 11) - (to >> 11)) + abs((from & 2047) - (to & 2047));
}
          
function min(a, b){
  var t = a - b;
 return b + (t & (t >> 31));
}
          
function pos(a, b){
  return (a << 11) + b;
}
         
function abs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
          
var
input = '';
          
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n,k;
    cin>>n>>k;
    cout<<(min(k-n%k,n%k))<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,a;
  cin >> n >> m;
  vector<bool> broken(n+1);
  for(ll i = 0; i < m; ++i){
    cin >> a;
    broken[a] = true;
    if(broken[a-1] or a == n){
      cout << 0;
      return 0;
    }
  }
  vector<ll> cnt(n+1);
  cnt[0] = 1;
  if(!broken[1]) cnt[1] = 1;
  for(ll i = 2; i <= n; ++i){
    if(!broken[i]){
      if(!broken[i-1]) cnt[i] = cnt[i-1];
      if(!broken[i-2]) cnt[i] = (cnt[i]+cnt[i-2])%MOD;
    }
  }
  cout << cnt[n]%MOD;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll inf = 1001001001001001001;
int main(){
  ll N,K,i;scanf("%lld%lld",&N,&K);
  ll P[N],C[N];
  for(i=0;i<N;i++){
    scanf("%lld",&P[i]);P[i]--;
  }
  for(i=0;i<N;i++) scanf("%lld",&C[i]);
  ll ans = -inf,np,nc,l;
  for(i=0;i<N;i++){
    vector<ll> v;
    np = i,nc = 0;
    np = P[np];v.emplace_back(C[np]);
    nc = 1;
    while(nc < K && np != i){
      np = P[np];v.emplace_back(v.back()+C[np]);
      nc++;
    }
    if(v.back() <= 0 || nc == K){
      ans = max(ans,*max_element(v.begin(),v.end()));
      continue;
    }
    l = K/v.size();
    if(K%v.size() != 0) ans = max(ans,v.back()*l+*max_element(v.begin(),v.begin()+K%v.size()));
    ans = max(ans,v.back()*(l-1)+*max_element(v.begin()+K%v.size(),v.end()));
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 3964
#include <cstdio>
#include <utility>
#include <vector>

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  if (n % 2 == 1) {
    for (int i = 1; i <= m; ++i)
      printf("%d %d\n", i, n-i);
    return 0;
  }

  std::vector<std::pair<int, int>> res;
  for (int i = 1; i <= n/4; ++i) {
    if (i == n/2-i) continue;
    res.emplace_back(i, n/2-i);
  }
  for (int i = 1; i <= n/4; ++i) {
    if (n/2+i == n-i+1) continue;
    res.emplace_back(n/2+i, n-i+1);
  }

  res.resize(m);
  for (auto [x, y]: res) printf("%d %d\n", x, y);
}


Measured memory_bytes: 3760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll N;

  cin >> N;

  cout << (N-1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,w,k; cin >> h >> w >> k;
  vector<string> s(h); rep(i,h) cin >> s[i];

  vector<bool> yoko(h,false);
  rep(i,h) rep(j,w) if(s[i][j] == '#') yoko[i] = true;
  vector<vi> ans(h,vi(w));
  int cnt = 0, piece = 1;
  rep(i,h){
    if(yoko[i]){
      rep(j,w){
        if(s[i][j] == '#') cnt++;
        if(cnt == 2){
          cnt = 1;
          piece++;
        }
        ans[i][j] = piece;
      }
      cnt = 0;
      piece++;
    }
  }
  rep(i,h){
    if(i != 0 && !yoko[i]){
      rep(j,w) ans[i][j] = ans[i-1][j];
      if(ans[i][0] != 0) yoko[i] = true;
    }
  }
  for(int i = h-2; 0 <= i; i--){
    if(!yoko[i]){
      rep(j,w) ans[i][j] = ans[i+1][j];
    }
  }
  rep(i,h){
    rep(j,w) cout << ans[i][j] << " ";
    cout << endl;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3880
#include <stdio.h>
#include <bits/stdc++.h>
#include <unistd.h>

using namespace std;
const int N = 1e5 + 5;

int n, i;

void init()
{
	cin >> n >> i;
	int res = n - i;
	cout << res + 1 << endl;	
}

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



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

int main()
{
	long long n, c;
	cin >> n >> c;
	vector<long long> x(n), v(n), a(n + 1);
	vector<long long> l(n + 1), r(n + 1);
	for(int i = 0; i < n; i++) cin >> x[i] >> v[i];
	for(int i = 0; i < n; i++) {
		l[i + 1] = v[i];
		l[i + 1] += l[i];
		r[n - i - 1] = v[n - i - 1];
		r[n - i - 1] += r[n - i];
	}
	vector<long long> l2 = l;
	vector<long long> r2 = r;
	for(int i = 0; i < n; i++){
		l[i + 1] -= x[i] * 2;
		l2[i + 1] -= x[i];
		r[n - i - 1] -= c - x[n - i - 1];
		r2[n - i - 1] -= (c - x[n - i - 1]) * 2;
	}
	vector<long long> lmax(n + 1), lmax2(n + 1);
	long long ans = -100100100100100100;
	long long tmp = ans;
	long long tmp2 = ans;
	for(int i = 0; i < n + 1; i++){
		if(tmp < l[i]) tmp = l[i];
		if(tmp2 < l2[i]) tmp2 = l2[i];
		lmax[i] = tmp;
		lmax2[i] = tmp2;
	}
	for(int i = n; i >= 0; i--){
		long long ans1 = r[i] + lmax[i];
		long long ans2 = r2[i] + lmax2[i];
		ans = max({ans, ans1, ans2});
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10396
#include<iostream>
#include<iomanip>
using namespace std;
double n,dp[333][333][333];
int a,cnt[4];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		cnt[a]++;
	}
	for(int k=0;k<=n;k++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int i=0;i<=n;i++)
			{
				if(!i&&!j&&!k)continue;
				dp[i][j][k]=(
					(i?i/n*(dp[i-1][j][k]+n/(i+j+k)):0)+
					(j?j/n*(dp[i+1][j-1][k]+n/(i+j+k)):0)+
					(k?k/n*(dp[i][j+1][k-1]+n/(i+j+k)):0)
				)*n/(i+j+k);
			}
		}
	}
	cout<<fixed<<setprecision(15)<<dp[cnt[1]][cnt[2]][cnt[3]]<<endl;
}

Measured memory_bytes: 262272
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
using namespace std;
const int N=1e5+10;
int n,a[N],b[N],ans;
inline int read(){
	char ch=getchar(); int x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline int abss(int x){return x>0 ? x : -x;}
int fnd(int x)
{
	int l=1, r=n;
	while(l<=r)
	{
		int mid=l+(r-l)/2;
		if(a[mid]==x) return mid;
		if(a[mid]<x) l=mid+1;
		else r=mid-1;
	}
}
int main()
{
	//freopen("BBuBBBlesort.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) a[i]=b[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		int pos=fnd(b[i]);
		ans+=(abss(pos-i)&1);
	}
	printf("%d\n",ans>>1);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 1024