akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
 
fn main() {
    
    let n = read::<usize>();
    let mut a : Vec<u64>= (0..n).map(|_| { read::<u64>() }).collect();
    
    a.sort();
    
    let mut tmp = (a[0] as f64 + a[1] as f64) / 2.;
    
    for i in 2..n {
        tmp = (tmp + a[i] as f64) / 2.;
    }
    
    println!("{}", tmp);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int N = 1e5 + 10;
string s;
int dp[N][2];

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

int solve(int cur, int flag){
	if(cur == -1){
		return 1;
	}
	if(dp[cur][flag] != -1)
		return dp[cur][flag];
	if(flag){
		return dp[cur][flag] = modpow(3,cur+1,MOD);
	}
	int ans = 0;
	if(s[cur] == '1'){
		ans = solve(cur-1,1);
		ans += 2*solve(cur-1,0);
		ans %= MOD;
	}
	else{
		ans = solve(cur-1,0);
	}
	return dp[cur][flag] = ans;
}

//int brute(){
	//int no = 0, cur = 1;
	//for(auto x : s){
		//if(x == '1')
			//no += cur;
		//cur *= 2;
	//}
	//int ans = 0;
	//for(int i = 0; i <= no; i++){
		//for(int j = 0; j <= no; j++){
			//if(i+j <= no && (i+j) == (i^j)){
				//ans++;
			//}
		//}
	//}
	//return ans;
//}

int32_t main(){
	cin >> s;
	memset(dp,-1,sizeof dp);
	reverse(s.begin(),s.end());
	cout << solve((int)s.size()-1,0) << endl;
	
	//cout << brute() << endl;


	return 0;
}



Measured memory_bytes: 6656
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        x: i32,
    }

    let mut ans:i32 = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500*i+100*j+50*k == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

int main() {
    int H, A;
    cin >> H >> A;
    cout << (H+A-1)/A << endl;

}


Measured memory_bytes: 764
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
      	long now = 100;
      	double p = 0;
      	int i =0;

	while (x > now){
      p = now * 0.01;
      now = now + (long)p;
      i++;
    }
            System.out.println(i);
    }
}

Measured memory_bytes: 35788
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dp[40][500][500];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	vector<int>L(N);
	for (int i = 0; i < N;++i) {
		cin >> L[i];
	}

	sort(L.begin(),L.end());
	ll ans = 0;
	for (int i = 0; i < N;++i) {
		for (int j = i + 1; j < N; ++j) {
			int big = L[i] < L[j] ? L[j] : L[i];
			int small = big == L[j] ? L[i] : L[j];
			int minSize = (big + 1) - small;
			int maxSize = L[i] + L[j] - 1;
			if (minSize != maxSize) {
				int a = 1;
			}
			if (L.back() <= maxSize) {
				unsigned int smallIndex = distance(L.begin(), lower_bound(L.begin(), L.end(), minSize));
				int count = N - smallIndex;
				if (minSize <= L[i] && L[i] <= maxSize)count--;
				if (minSize <= L[j] && L[j] <= maxSize)count--;
				ans += count <= 0 ? 0 : count;
			}
			else {
				unsigned int smallIndex = distance(L.begin(), lower_bound(L.begin(), L.end(), minSize));
				unsigned int bigIndex = distance(L.begin(), upper_bound(L.begin(), L.end(), maxSize));
				int count = bigIndex - smallIndex;
				if (minSize <= L[i] && L[i] <= maxSize)count--;
				if (minSize <= L[j] && L[j] <= maxSize)count--;
				ans += count <= 0 ? 0 : count;
			}
		}
	}
	ans /= 3;
	cout << ans << endl;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 2e5 + 5;

int n, h[maxn], a[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    h[0] = 0; a[0] = 0;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    map<int, int> dp;
    for(int i = n; i >= 0; i--)
    {
        auto it = dp.upper_bound(h[i]);
        int sum = a[i];
        if(it != dp.end())
            sum += it -> second;
        dp[h[i]] = sum;
        it = dp.find(h[i]);
        while(it != dp.begin() && prev(it) -> second <= sum)
            it = dp.erase(prev(it));
    }
    cout << dp[0] << "\n";
    return 0;
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
#define pp pair<int,int>
#define MZ 1000000007
#define Pi acos(-1)
#define pq priority_queue

using namespace std;

int num[15];
int ans[15];
char c[6];

int main()
{
    int len,l,r,mid;
    l=1,r=10;
    num[1]=1;
    for(int i=2;i<=10;i++)
        num[i]=num[i-1]*10;
    while(l!=r)
    {
        mid=(l+r+1)/2;
        cout<<"? "<<num[mid];
        cout<<endl;
        fflush(stdout);
        cin>>c;
        if(c[0]=='Y')
            l=mid;
        else
            r=mid-1;
    }
    len=l;
    if(len==10)
    {
        cout<<"? 999999999"<<endl;
        fflush(stdout);
        cin>>c;
        if(c[0]=='Y')
        {
            for(int i=1;i<=9;i++)
            {
                cout<<"? ";
                for(int j=1;j<=i;j++)
                    cout<<9;
                cout<<endl;
                fflush(stdout);
                cin>>c;
                if(c[0]=='Y')
                {
                    cout<<"! 1";
                    for(int j=1;j<i;j++)
                        cout<<0;
                    cout<<endl;
                    fflush(stdout);
                    return 0;
                }
            }
        }
        else
            cout<<"! 1000000000"<<endl;
        return 0;
    }
    for(int i=1;i<len;i++)
    {
        if(i==1)
            l=1;
        else
            l=0;
        r=9;
        while(l!=r)
        {
            mid=(l+r+1)/2;
            cout<<"? ";
            for(int j=1;j<len;j++)
            {
                if(j<i)
                    cout<<ans[j];
                if(j==i)
                    cout<<mid;
                if(j>i)
                    cout<<0;
            }
            cout<<endl;
            fflush(stdout);
            cin>>c;
            if(c[0]=='Y')
                l=mid;
            else
                r=mid-1;
        }
        ans[i]=l;
    }
    for(int i=1;i<=9;i++)
    {
        cout<<"? ";
        for(int j=1;j<len;j++)
            cout<<ans[j];
        cout<<i;
        cout<<0;
        cout<<endl;
        fflush(stdout);
        cin>>c;
        if(c[0]=='Y')
        {
            ans[len]=i;
            break;
        }
    }
    cout<<"! ";
    for(int i=1;i<=len;i++)
        cout<<ans[i];
    cout<<endl;
    fflush(stdout);
    return 0;
}


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

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

typedef long long ll;
using namespace std;

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

  int R;
  cin >> R;
  cout << setprecision(10) << 2 * R * 3.1415926535 << endl;

  return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int

using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(v.size()){
        pt<T>(v[i]);
    }
}

/*********************************reused****************************/
int main()
{
    ulli x,y,z;
    cin>>x>>y>>z;
    cout<<(x-z)/(y+z)<<endl;

   return 0;
}


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

typedef long long ll;

int n, k;
ll res;

int main()
{
    scanf("%d %d", &n, &k);
    int has = n / k;
    res += ll(has) * ll(has) * ll(has);
    if (k % 2 == 0 && k / 2 <= n) {
        n += k / 2;
        has = n / k;
        res += ll(has) * has * has;
    }
    cout << res << endl;
    return 0;
}


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

int main()
{
	int a;
	int b;
	cin >> a >> b;
	if(b == 1) cout << 0 << endl;
	else{
		if(b <= a){
			cout << 1 << endl;
			return 0;
		}else {
			for(int i = 2; ;i++)
				if((a * i - i + 1) >= b){
					cout << i << endl;
					break;
			}	
		}
				
	}
	
	return 0;
}

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

using namespace std;
 
#define len(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
#define print(x) cout << (x) << endl;
 
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(3);
    cerr.setf(ios::fixed); cerr.precision(3);
    solve();    
    return 0;
}
 
const int INF = 1e18, MAXN = 1e6, MOD = 1e9 + 7, BASE = 37; 

void solve() {
	int n;
	cin >> n;
	vec<int> a(n), b(n);
	cin >> a >> b;
	vec<int> ca = a, cb = b;
	sort(all(ca));
	sort(all(cb));
	
	map<int, int> id, elem;
	for (int i = 0; i < n; ++i) {
		elem[cb[i]] = ca[i];
		if (ca[i] > cb[i]) {
			print("No");
			return;
		}
	}
	for (int i = 0; i < n - 1; ++i) {
		if (ca[i + 1] <= cb[i]) {
			print("Yes");
			return;
		}
	}
	for (int i = 0; i < n; ++i) {
		id[a[i]] = i;
	}

	vec<int> per;
	for (auto it : b) {
		per.pb(id[elem[it]]);
	}

	int cnt = 0;
	vec<int> used(n);
	for (int i = 0; i < n; ++i) {
		if (!used[i]) {
			int cur = per[i];
			while (!used[cur]) {
				used[cur] = 1;
				cur = per[cur];
			}
			cnt++;
		}
	}	

	print(cnt >= 2 ? "Yes" : "No");
}

Measured memory_bytes: 17528
#include<iostream>
using namespace std;
int main(void){
  char c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<3;i++){
    cout<<c[i][i];
  }
  cout<<endl;
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

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

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,k;
	cin >>a >>b >>k;
	
	repr(i, min(a,b), 1){
		if(a%i==0 && b%i==0) k--;
		if(k==0){
			cout <<i <<"\n"; break;
		}
		//dbg(i,i%a, i%b);
	}
	
	return 0;
}



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

int main()
{
  ll n, x; cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  for (int i=0; i<n-1; i++) {
    ll t = a[i] + a[i+1];
    if (t > x) {
      ll d = t - x;
      a[i+1] = max(0LL, a[i+1]-d);
      a[i] -= max(0LL, d-a[i+1]);
      ans += d;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val acgt = setOf('A', 'C', 'G', 'T')
    var size = 0
    var max = 0
    readLine()!!.forEach { c ->
        if (acgt.contains(c)) {
            size++
            max = Math.max(max, size)
        } else {
            size = 0
        }
    }
    println(max)
}


Measured memory_bytes: 35780
#include <iostream>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W){
		if(H == 0 && W == 0) return 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
n,m = map(int,input().split())
ans = [False]*n
cnt = [1]*n
ans[0] = True
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    cnt[y] += 1
    if ans[x]:
        ans[y] = True
    cnt[x] -= 1
    if cnt[x]==0:
        ans[x] = False
c = 0
for i in ans:
    if i:
        c += 1

print(c)
        


Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***


ll n,d,a;


void solve()
{
    rd(n,d,a);
    vector<pair<ll,int>> v;
    ll pre[n+1] = {0};
    fo(i,0,n-1){
        ll x,h;rd(x,h);
        v.pb(mk(x,h));
    }  
    sort(all(v));
    fo(i,0,n-1){
        pre[i]=0;
    }
    ll i = 0,j=0;
    ll c = 0;
    while(i<n){
        while(j+1<n and v[i].ff+2*d>=v[j+1].ff)j++;
        ll need = max((v[i].ss+pre[i]+a-1)/a,0LL);
        c+=need;
        pre[i] -= a*need;
        pre[j+1] += a*need;
        i++;
        pre[i] += pre[i-1];
    }
    pp(c);
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 8904
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>

using namespace std;

int main(){
  int ans=1;
  int a,b;
  cin >> a >> b;
  
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  
  int temp = a;
  
  for(int i=0;i<100;i++){
    
    if( temp >= b) {
      cout << ans << endl;
      return 0;
    }
    
    temp += (a-1);
    ans++;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long maxi = 0, mini = 1e10;
  for (int i=0; i<n; ++i) {
    long long tmp = 0;
    cin >> tmp;
    if (maxi < tmp) maxi = tmp;
    if (mini > tmp) mini = tmp;
  }
  cout << maxi - mini << endl;
  return 0;
}


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

int main() {
    ll N, P;
    cin >> N >> P;

    if (N == 1) { 
        cout << P << endl;
    } else {
        int ans = 1;
        for (int i = 2; i <= sqrt(pow(10, 12)); i++) {
             ll factor = pow(i, N);
             if (P % factor == 0) ans = i;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

bool ulg(unsigned long long a1, unsigned long long a2, unsigned long long b1, unsigned long long b2)
{
  if (a1 > a2 && b1 > b2) {
    return a1-a2 > b1-b2;
  }
  if (a1 > a2 && b1 <= b2) {
    return true;
  }
  if (a1 <= a2 && b1 > b2) {
    return false;
  }
  return a2-a1 < b2-b1;
}

int main(void)
{
  int n;
  cin >> n;
  unsigned long long buff;
  unsigned long long sum_a=0, sum_b=0;
  priority_queue< unsigned long long, vector< unsigned long long >, greater< unsigned long long > > a;
  priority_queue< unsigned long long, vector< unsigned long long >, less< unsigned long long > > c;
  unsigned long long b[n], top[n+1], bottom[n+1];
  for (int i = 0; i < n; ++i) {
    cin >> buff;
    a.push(buff);
    sum_a += buff;
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> buff;
    c.push(buff);
    sum_b += buff;
  }
  top[0] = sum_a;
  bottom[0] = sum_b;

  for (int i = 0; i < n; ++i) {
    a.push(b[i]);
    unsigned long long t = a.top();
    a.pop();
    top[i+1] = top[i] + b[i] - t;
    c.push(b[n-1-i]);
    unsigned long long p = c.top();
    c.pop();
    bottom[i+1] = bottom[i] + b[n-1-i] - p;
  }

  unsigned long long best_a, best_b;
  for (int i = 0; i <= n; ++i) {
    if (i == 0 || ulg(top[i], bottom[n-i], best_a, best_b)) {
      best_a = top[i];
      best_b = bottom[n-i];
    }
  }

  if (best_a >= best_b) {
    cout << best_a - best_b << endl;
  } else {
    cout << "-" << best_b - best_a << endl;
  }

  return 0;
}


Measured memory_bytes: 4724
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define rep(i,n)for(int i=0;i<n;++i)
#define p pair<int,int>
int main() {
	int N;
	cin >> N;
	vector<ll>vx(N), vy(N), vh(N);
	int si = -1;
	for (int i = 0; i < N; ++i) {
		cin >> vx[i] >> vy[i] >> vh[i];
		if (vh[i] > 0)
			si = i;
	}
	ll resx = -1, resy = -1, resh = -1;
	for (ll x = 0; x <= 100; ++x) {
		for (ll y = 0; y <= 100; ++y) {
			ll h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
			bool ok = true;
			for (int i = 0; i < N; ++i) {
				if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
				if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
			}
			if (ok)
				resx = x, resy = y, resh = h;
		}
	}
	cout << resx << " " << resy << " " << resh << endl;
	return 0;
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = int(input())
t = [0] * n
for _ in range(n):
    t[_] = int(input())
ans = t[0]
for i in range(1, n):
    ans = lcm(ans, t[i])
print(ans)

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

int check_prime(int n){
	
	if ( n <= 3 ) return 1;
	if( n%2 == 0 || n%3 == 0 ) return 0;
	for(int i = 5; i*i <= n; i += 6){
		if( n%i == 0 || n%(i+2) == 0 ) return 0;
	}
	return 1;
	
}

int main(void){
	
	int N;
	int numbers[10000];
	int primes[10000];
	int prime_track = 0;
	int count = 0;
	
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		scanf("%d", &numbers[i]);
	}
	
	for(int i = 0; i < N; i++){
		count += check_prime(numbers[i]);
	}
	
	printf("%d\n", count);
	
	return 0;
	
}


Measured memory_bytes: 2044
N = int(input())
TXY = []
flag = True
for i in range(N):
	txy = list(map(int,input().split()))
	if not (txy[0] % 2 == (txy[1] + txy[2]) % 2 and txy[0] >= (txy[1] + txy[2])):
		flag = False
if flag == True:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
import java.util.HashSet;
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			char[] s = sc.next().toCharArray();
			HashSet<Character> m = new HashSet<Character>();
			
			for(int i=0;i<s.length;i++) {
				m.add(s[i]);
			}
			
			if(m.size()==4) {
				System.out.println("Yes");
				
			}else if(m.size()==2) {
				if((m.contains('N')&&m.contains('S'))||(m.contains('E')&&m.contains('W'))){
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}else {
				System.out.println("No");
			}	
						
	    }
				
	}
	


Measured memory_bytes: 35828
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    ans = 0
    for i in range(101):
        if i%3 and i%5:
            ans += i
    print(ans)
    return

#B
def B():
    a,b,n = LI()
    x = input()
    for i in x:
        if i == "S":
            a = max(0,a-1)
        elif i == "C":
            b = max(0,b-1)
        else:
            if a >= b:
                a = max(0,a-1)
            else:
                b = max(0,b-1)
    print(a)
    print(b)
    return

#C
def C():
    n = I()
    d = LI()
    m = I()
    t = LI()
    dic = defaultdict(lambda : 0)
    for i in d:
        dic[i] += 1
    for i in t:
        if not dic[i]:
            print("NO")
            return
        dic[i] -= 1
    print("YES")
    return

#D
def D():
    n,m = LI()
    v = []
    f = [defaultdict(list) for i in range(2001)]
    for i in range(m):
        a,b,l = LI()
        v.append((a,b,l))
        v.append((b,a,l))
        f[l][a].append(b)
        f[l][b].append(a)
    ans = 0
    for a,b,l in v:
        rest = 2540-l
        for c in f[rest][b]:
            if a < c:
                ans += 1
    print(ans)
    return

#E
def E():
    def sum(n):
        return n*(n+1)//2
    n = I()
    l = 0
    r = n+1
    while r-l > 1:
        m = (l+r)//2
        if sum(m) < n:
            l = m
        else:
            r = m
    ans = list(range(1,r+1))
    s = sum(r)
    for i in ans:
        if i != s-n:
            print(i)
    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    E()


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

/// Constant:
#define         eps         0.000000001
#define         pi          2*acos(0)
#define         P1          1000000007
#define         P2          1000000009

#define         fast        ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define         lli         long long int
#define         PB          push_back
#define         pb          pop_back
#define         mp          make_pair
#define         I           insert
/// Loop:
#define         f1(a,b)     for (int i=a; i<=b; i++)
#define         f2(a,b)     for (int j=a; j<=b; j++)
#define         f-1(a,b)     for (int i=b; i>=a; i--)
#define         f-2(a,b)     for (int j=b; j>=a; j--)
///Print:
#define         pY          cout<<"YES"<<endl;
#define         pN          cout<<"NO"<<endl;
#define         py          cout<<"Yes"<<endl;
#define         pn          cout<<"No"<<endl;

using namespace std;
///ISNNJB

///Global Variable:
int ara[200005],brr[200005];

/// Functions:
//int mark[1000010];vector<int>primes;void sieve(int n) {memset(mark, 0, sizeof(mark));for (int i=4; i<=n; i+=2)mark[i]=-1;mark[0]=mark[1]=-1;int root=sqrt(n);primes.push_back(2);for(int i=3; i<=root; i+=2) {if(mark[i]==0) {for(int j=i*i; j<=n; j+=2*i)mark[j]=-1;}}for(int i=3; i<=n; i+=2) {if(mark[i]==0)primes.push_back(i);}}
//int phi[500007];void phi(int N){for(int i=2; i<=N; i++)phi[i] = i;for(int i =2; i<=N; i++){if(phi[i]==i){for(int j=i; j<=N; j+=i)phi[j]-=phi[j]/i;}}}
//lli bigmod(lli b, lli p, lli m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ lli res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//lli mod_inverse(lli a, lli mod) { return bigmod(a,mod-2,mod); }
//lli LCM(lli a, lli b) { return a*b/ __gcd(a,b); }
//vector<int>divisors[1000005]; void divisor(int n) { for (int i=1; i<=n; i++)    for (int j=i; j<=n; j+=i)   divisors[j].PB(i);}

///Graph Moves
//const int dx[]= {+1,-1,+0,+0};
//const int dy[]= {+0,+0,+1,-1};
//const int dx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int dy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int dx[]={-2,-2,-1,-1,1,1,2,2};  // Knights Move
//const int dy[]={-1,1,-2,2,-2,2,-1,1}; // Knights Move

///Bitmask
//int Set(int N,int pos){return N = (N (1<<pos));}
//int reset(int N,int pos){return N = (N & ~(1<<pos));}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}

int main() {

    /**freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    fast;

    lli n,m,k,z,t,l,r;
    cin>>t;
    if(t>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {
    int n, h; cin >> n >> h;
    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    sort(all(A)), sort(all(B),greater<ll>());
    
    //刀をi本投げる場合の最低攻撃回数
    ll throw_ = 0; ll res = INF;
    for(int i=0; i<=n; i++){
        ll slash_ = max(h - throw_, (ll)0);
        ll num = slash_ / A[n-1] + i;
        if(slash_ && slash_ % A[n-1]) num++;
        chmin(res, num);
        if(i < n) throw_ += B[i];
    }

    cout << res << ln;
}

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

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

  int i=1;
  while(1){
    int x =i;
    if ( x % 3 == 0 ){
      cout<<" "<<i;
    } else {
      while(1){
	if( x % 10 == 3 ){
	  cout<<" "<<i;
	  break;
	} else {
	  x /= 10;
	  if(x == 0) break;
	}
      }
    }
    if ( ++i > n ) break;
  }
  cout<<endl;

    return 0;
}




Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void func1(string S, vector<int> vec){
    ll cnt = 0;
    rep(i,0,S.size()-2){
        if(S.substr(i,3) == "ABC"){
            S[i] = 'B',S[i+1] = 'C', S[i+2] = 'A';
            
            cnt++;
            int j = i-1;
            while(j >= 0 && S.substr(j,3) == "ABC"){
                S[j] = 'B', S[j + 1] = 'C', S[j + 2] = 'A';
                j--;
                cnt++;
            }
            
            //cout << S << endl;
        }
        cout << i << ":" << cnt << endl;
    }
    cout << cnt << endl;
}
void func2(string S, vector<int> vec){
    ll cnt = 0;
    ll len = 0;
    rep(i,0,S.size()-2){

        if(S.substr(i,3) == "ABC"){
            //cout << i << "hit" << endl;
            S[i] = 'B',S[i+1] = 'C', S[i+2] = 'A';
            
            cnt += len + 1;
            
            i++;

            //cout << S << endl;
        }else if(S[i] == 'A'){
            len++;
        }else{
            len = 0;
        }
        //cout << i << ":" << cnt << endl;
        //rep(j,0,S.size())cout << vec[j] << " \n"[j==S.size()-1];
    }
    cout << cnt << endl;
}
main(){
    string S;
    cin >> S;
    ll cnt = 0;
    vector<int> vec(S.size());
    vec[0] = S[0] == 'A';
    rep(i,1,S.size()){
        if(S[i] == 'A')vec[i] = vec[i-1] + 1;
        else vec[i] = 0;
    }
    //rep(i,0,S.size())cout << vec[i] << " \n"[i==S.size()-1];
    //func1(S, vec);
    //cout << " " << endl;
    func2(S, vec);

}

Measured memory_bytes: 2308
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
using namespace std;
string s;
int n, a[30], ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    for(int i = 1 ; i < n-1 ; i++ )
    {
        if( a[i-1] <= a[i] and a[i] <= a[i+1] ) ans++;
        if( a[i+1] <= a[i] and a[i] <= a[i-1] ) ans++;
    }
    cout<<ans<<endl;
}


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

int main() {

	int N,A,i,j;
	int P[50];
	int c= 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &P[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (P[i] > P[j]) {
				A = P[i];
				P[i] = P[j];
				P[j] = A;
				c=c+1;
				i = 0;
				if (c> 1) {
					break;
				}
			}
		}
		if (c>1) {
			break;
		}
	}

	if (c>1) {
		printf("NO");
	}
	else {
		printf("YES");
	}

	return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};
typedef long long ll;
const int mod = 1e9+7;

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

  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i,h) cin >> field[i];
  queue<P> que;
  vector<vector<int>> cnt(h, vector<int>(w, -1));
  rep(i,h)rep(j,w){
    if(field[i][j] == '#'){
      que.push(make_pair(i,j));
      cnt[i][j] = 0;
    }
  }
  int ans = 0;
  while(!que.empty()){
    int vy = que.front().first;
    int vx = que.front().second;
    que.pop();
    rep(i,4){
      int ny = vy + dy4[i];
      int nx = vx + dx4[i];
      if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if(field[ny][nx] = '.' && cnt[ny][nx] == -1){
        que.push(make_pair(ny, nx));
        cnt[ny][nx] = cnt[vy][vx] + 1;
        ans = max(ans, cnt[ny][nx]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 400;
int a[SIZE],b[SIZE],pos_a[SIZE],pos_b[SIZE];
LL dp[SIZE][SIZE][135][2];
void ADD(LL& x,LL v){x=(x+v)%MOD;}
int main(){
    DRI(N);
    REPP(i,1,N+1){
        RI(a[i]);
        pos_a[a[i]]=i;
    }
    REPP(i,1,N+1){
        RI(b[i]);
        pos_b[b[i]]=i;
    }
    dp[0][0][0][0]=1;
    REP(i,N+1)REP(j,N+1){
        if(i==N&&j==N)break;
        REP(k,N/3+1)REP(r,2){
            if(!dp[i][j][k][r])continue;
            if((j<N&&pos_a[b[j+1]]<=i)||(i<N&&pos_b[a[i+1]]<=j)){
                int nxt_i=i+(i<N&&pos_b[a[i+1]]<=j);
                int nxt_j=j+(j<N&&pos_a[b[j+1]]<=i);
                if(!r||nxt_i==i)ADD(dp[nxt_i][nxt_j][k][r],dp[i][j][k][r]);
            }
            else{
                if(a[i+1]==b[j+1]){
                    if(k>0){
                        if(!r)ADD(dp[i+1][j+1][k-1][r],dp[i][j][k][r]*k);
                    }
                }
                else{
                    if(r)ADD(dp[i+1][j+1][k+1][0],dp[i][j][k][r]);
                    else ADD(dp[i][j][k][1],dp[i][j][k][r]);
                    if(k>0){
                        if(!r)ADD(dp[i+1][j][k-1][r],dp[i][j][k][r]*k);
                        if(r)ADD(dp[i][j+1][k-1][1],dp[i][j][k][r]*k);
                    }
                }
            }
        }
    }
    LL an=(dp[N][N][0][0]+dp[N][N][0][1])%MOD;
    REPP(i,1,N){
        if(i%3)an=an*i%MOD;
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 334720
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N, K, sum = 0;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for(int j = 0; j < K; j++){
        sum += p[j];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=1e5+10;
mat G(N);
ll n,m;

vec d(N);
ll dfs(ll f) {
  if(d[f]) return d[f];
  ll res=0;
  for(ll t:G[f]) {
    res=max(dfs(t),res);
  }
  return d[f]=res+1;
}

int main() {
  cin >> n >> m;
  for(ll i=0;i<m;i++) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    G[x].push_back(y);
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans=max(ans,dfs(i));
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    string s;
    int c0=0,c1=0;
    cin >> s;
    for(char c:s){
        if(c=='0') c0++;
        else c1++;
    }
    cout << 2*min(c0,c1) <<endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
int main(){
	long long int n,m;
	scanf("%lld%lld",&n,&m);
	long long int ans;
	if(n==1){
		if(m==1)ans=1;
		else ans=m-2;
	}else{
		if(m==1)ans=n-2;
		else ans=(n-2)*(m-2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define pb push_back
using ll = long long;

// 約数列挙
vector <ll> divisor(ll n) {
	vector<ll> ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.pb(i);
			if (i * i != n) ret.pb(n / i);
		}
	}
	RSORT(ret);
	return ret;
}

int main() {
	ll n; cin >> n;
	vector<ll> x(n + 1); rep(i, 0, n + 1) cin >> x[i];

	RSORT(x);
	vector<ll> d(n); rep(i, 0, n) d[i] = x[i] - x[i + 1];
	SORT(d);
	vector<ll> div = divisor(d[0]);
	ll D;
	rep(i, 0, div.size()) {
		int j = 0;
		while ((j < n) && (d[j] % div[i] == 0)) j++;
		if (j == n) {
			D = div[i];
			break;
		}
	}

	cout << D << endl;

	return 0;
}

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

int main(){
	const ll INF = 1e9 + 5;
        ll N, W; cin >> N >> W;
        vector<ll> weights(N), value(N);
        for(ll rep = 0; rep < N; ++rep){
            cin >> weights[rep] >> value[rep];
        }
        vector<vector<ll>> maxValue(N, vector<ll>(W + 1, 0));
        for(ll weight = weights[0]; weight <= W; ++weight){
            maxValue[0][weight] = value[0];
        }
        for(ll itemN = 1; itemN < N; ++itemN){
            for(ll curW = 0; curW <= W; ++curW){
            	maxValue[itemN][curW] = maxValue[itemN - 1][curW];
                if(curW < weights[itemN]) continue;
             	maxValue[itemN][curW] = 
                        max(maxValue[itemN - 1][curW - weights[itemN]] + value[itemN],
                        maxValue[itemN][curW]);
            }
        }
        cout << maxValue[N - 1][W] << endl;
    	return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

ll f(string s, string t){
	int op=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])op++;
	}
	return op;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	string s, t;
	cin>>s>>t;
	ll ts = t.size();
	ll ss = s.size();
	ll ans=INT_MAX;
	ll mi=0;
	
	for(int i=0;i<=ss-ts;i++){
//		cout<<s.substr(i, ts)<<" ";
		ans = min(ans, f(s.substr(i, ts), t));
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3664
N, P = map(int, input().split())
S = input()

S = S[::-1]
result = 0
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            result += N - i
else:
    t = [0] * P
    m = 1
    n = 0
    for i in range(len(S)):
        t[n] += 1
        n += int(S[i]) * m
        n %= P
        result += t[n]
        m *= 10
        m %= P
print(result)


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,a[100];
long long ans=0;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=m;i++) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int main() {
	int H,W,c[11][11],a[220][220],ans=0;
	int dis[11][11];
	cin>>H>>W;
	rep(j,0,10)
		rep(i,0,10){
		cin>>c[i][j];
		dis[i][j]=c[i][j];
	}
	rep(k,0,10){
		rep(j,0,10){
			rep(i,0,10){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	rep(j,0,H)
		rep(i,0,W){
		cin>>a[i][j];
		if(a[i][j]!=1&&a[i][j]!=-1){
			ans+=dis[1][a[i][j]];
		}
	}
	cout<<ans<<endl;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int nxt(int x){
    int b = 1;
    while(b <= x) b <<= 1;
    return b;
}

int main() {
	fastio;
	
    int n, res = 0; cin >> n;
    multiset<int> s;
    forn(i,n){
        int x; cin >> x;
        s.insert(x);
    }
    while(!s.empty()){
        auto x = prev(s.end());
        int e = nxt(*x)-*x;
        auto y = s.lower_bound(e);
        if(y != s.end() && y != x && *y == e) res++, s.erase(y);
        s.erase(x);
    }
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define INF 200001
using namespace std;
inline int read()
{
	register int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n=read(),a[INF]={0};
    for(int i=0;i<n;i++)
		a[i]=read();
    for(int i=n-1;i>=0;i-=2)
	{
		write(a[i]);
		putchar(' ');
	} 
    for(int i=(n&1);i<n;i+=2)
    {
		write(a[i]);
		putchar(' ');
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2944
package main

import (
	"fmt"
)

func main() {
	var str string
	fmt.Scan(&str)

	var result string
	for i := 0; i < 3; i++ {
		if string(str[i]) == "1" {
			result += "9"
		} else {
			result += "1"
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
s = input()

ans = True
n = len(s)
if s != s[::-1]:
    ans = False

front = s[0:(n-1)//2]
if front != front[::-1]:
    ans = False


back = s[(n+3)//2-1:n+1]
if back != back[::-1]:
    ans = False

# print(s, front, back)

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060