akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

string s,t;
vector<int>v[26];

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

    int i,cnt=0,cur=0;
    cin>>s>>t;
    for(i=0;i<s.size();i++)v[s[i]-'a'].push_back(i);
    for(i=0;i<t.size();i++){
        if(v[t[i]-'a'].empty()){
            cout<<"-1\n";
            return 0;
        }
    }
    for(i=0;i<t.size();i++){
        cur = lower_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),cur)-v[t[i]-'a'].begin();
        if(cur == v[t[i]-'a'].size()){
            cnt++;
            cur = lower_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),0)-v[t[i]-'a'].begin();
            cur = v[t[i]-'a'][cur]+1;
        }
        else{
            //cout<<v[t[i]-'a'][cur]<<endl;
            cur = v[t[i]-'a'][cur]+1;
        }
    }
    //cout<<cnt<<endl;
    cout<<(long long)s.size()*(long long)cnt+(long long)cur<<'\n';
    return 0;
}


Measured memory_bytes: 1228
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve(mut ds: Vec<usize>) -> usize {
    let n = ds.len();

    ds.sort();

    if ds[n / 2 - 1] == ds[n / 2] {
        return 0;
    }

    ds[n / 2] - ds[n / 2 - 1]
}

fn main() {
    read_line!();

    let ds = parse_vec!(usize);
    println!("{}", solve(ds));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![9, 1, 4, 4, 6, 7]), 2);
    assert_eq!(solve(vec![9, 1, 14, 5, 5, 4, 4, 14]), 0);
}


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

void AttackFaise(int*,int*);
bool CheckDeath(int*);

int main() {
	int takahashi_hp;
	int takahashi_attack;
	int aoki_hp;
	int aoki_attack;

	cin >> takahashi_hp >> takahashi_attack >> aoki_hp >> aoki_attack;

	bool playerTurnT = true;

	while (true) {
		int* attacker_attack,* receiver_hp;
		if (playerTurnT) {
			attacker_attack = &takahashi_attack;
			receiver_hp = &aoki_hp;
		}
		else {
			attacker_attack = &aoki_attack;
			receiver_hp = &takahashi_hp;
		}
		AttackFaise(receiver_hp, attacker_attack);
		if (CheckDeath(receiver_hp)) {
			break;
		}
		playerTurnT = !playerTurnT;
	}
	cout << ((playerTurnT) ? "Yes" : "No") << endl;

	return 0;
}

void AttackFaise(int* receiver_hp, int* attacker_point) {
	*receiver_hp -= *attacker_point;
}

bool CheckDeath(int* hp) {
	return (*hp <= 0) ? true : false;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(void) {
    std::map<std::string, int> seqLen;
  map<string, int> m;
  
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string tmp;
    cin >> tmp;
    auto itr = m.find(tmp);
    
    if(itr != m.end()){
      m[tmp] += 1;
    } else { 
      m[tmp] = 1;
    }
  }
  
  int M;
  cin >> M;
  for(int i = 0; i < M; i++){
    string tmp;
    cin >> tmp;
    auto itr = m.find(tmp);
    if(itr != m.end()){
      m[tmp] -= 1;
    } else { 
      
    }
  }
  
  int ans = 0;
  
  for(auto x : m){
    if(x.second > ans){
      ans = x.second;
    }
  }

  cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    long double A, B;
    cin >> A >> B;
    ll ans = A * B + 0.001;
    cout << ans << endl;
}

Measured memory_bytes: 3780
from itertools import groupby
s = input()
a = [1 if c in ['A', 'G', 'C', 'T'] else 0 for c in s]
l = 0
for n, c in groupby(a):
	c = sum(1 for i in c)
	if n == 1 and c > l:
		l = c
print(l)


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

const int N = 3005;

int n;
int a[N], f[N];
vector<int> imp;
vector<int> G[N];

bool cmp(int x,int y) { return a[x] < a[y]; }

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], imp.push_back(i);
	for (int i = 1; i <= n - 1; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v), G[v].push_back(u);
	} 
	
	sort(imp.begin(), imp.end(), cmp);
	for (int u : imp) if(!f[u]) {
		for (int v : G[u]) f[v] |= (a[v] > a[u]);
	}  
	for (int i = 1; i <= n; ++i) if (f[i]) {
		cout << i << ' ';
	}
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> st;
	rep(i, n){
		ll a, b;
		cin >> a >> b;
		st.pb(mp(a, b));
	}
	sort(all(st));
	ll cur = 0;
	ll sum = 0;
	rep(i, n){
		ll pos = min(m - cur, st[i].se);
		cur += pos;
		sum += st[i].fi * pos;
	}
	cout << sum << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2420
#include<iostream>
#include <stdlib.h>
using namespace std;

int main() {
	int a=0, b=0, c=0, d=0,A,B,C,Aabs,Babs,Cabs;

	cin >>a>>b>>c>>d;

	A =b - a;
	B =c - b;
	C =c - a;

	Aabs = abs(A);
	Babs = abs(B);
	Cabs = abs(C);

	if(Cabs <= d)
	cout << "Yes";
	else if (Aabs <= d && Babs <= d)
	cout << "Yes";
	else
	cout << "No";

	return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	int L, R, Ln=0, Rn=N-1;
	for(int i=0; i<M; i++){
	    cin >> L >> R;
	    Ln=max(L-1,Ln);
	    Rn=min(R-1,Rn);
	}
	cout << max(Rn-Ln+1,0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if((a < b) && (b < c)){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string s, t;

int main() {
    cin >> s ;
    t = "abc";
    do {
        if(s == t) {
            cout << "Yes" <<endl;
            exit(0);
        }
    }while(next_permutation(t.begin(), t.end()));
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ary = gets.split.map(&:to_i).sort.reverse

alice = 0
bob   = 0

for i in 0 .. n - 1
  if i % 2 == 0
    alice += ary[i]
  else
    bob   += ary[i]
  end
end

puts alice - bob


Measured memory_bytes: 1788
chomp (my $n = readline ARGV);
my @l;
for (1..$n-1) {
  chomp (my ($c, $s, $f) = split / /, readline ARGV);
  push @l, [$c, $s, $f];
}

sub calc {
  my $bgn = shift;
  my $t = 0;
  for my $i ($bgn-1..$n-2) {
    my ($c, $s, $f) = @{$l[$i]};
    $t += $t < $s ? $s - $t : int(($t - $s) % $f) ? $f - int(($t - $s) % $f) : 0;
    $t += $c;
  }
  $t;
}

print calc($_), "\n" for 1 .. $n;

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;



int main(int argc, char *argv[]) {
    int n;
    int l;
    cin >> n >> l;
    string s;
    vector<string> vs;
    for (int i = 0; i < n; i++) {
        cin >> s;
        vs.push_back(s);
    }
    sort(vs.begin(), vs.end());
    s = "";
    for (auto ss : vs) {
        s += ss;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N==2){
            System.out.println(2);
            return;
        }
        if(N==3){
            System.out.println(3);
            return;
        }
        int limit = 1000000;
        ArrayList<Integer> Sosuu = new ArrayList<Integer>();
        int warukazu, amari;
        
        Sosuu.add(2);
        Sosuu.add(3);
        for (int i = 3; i < limit; i += 2) {
            warukazu = 0;
            amari = 1;
            while (amari != 0) {
                amari = i % Sosuu.get(warukazu);
                if (Sosuu.size() < warukazu || Sosuu.get(warukazu) > i / 2) {
                    amari = 0;
                    Sosuu.add(i);
                    if(i>=N){
                        System.out.println(i);
                        return;
                    }
                    break;
                }
                warukazu++;
            }
        }
    }
}

Measured memory_bytes: 24652
#include<stdio.h>

int main(void) {
int n;
int x;
int num;
int min = 1000000;
int max = -1000000;
long long int total = 0;

scanf("%d", &n);
for (x = 0; x < n; x++) {
scanf("%d", &num);
if (min > num) min = num;
if (max < num) max = num;
total += num;
}
printf("%d %d %ld\n", min, max, total);

return (0);
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
	int n,i;
	double t,x=1000,a,h,w,y;
	cin >> n >> t >> a;
	for(i=0;i<n;i++){
		cin >> h;
		w=t-0.006*h-a;
		if(w<0)
			w=-w;
		if(w<x){
			x=w;
			y=i;
		}
	}
	cout << y+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	int n = ri();
	int t = n;
	int sum = 0;
	while(1) {
		sum += (t%10);
		t /= 10;
		if (!t) break;
	}
	
	printf("%s", (n%sum) ? "No" : "Yes");
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int main(){
	string a,b;
  	cin>>a>>b;
  
  	if(a.size() != b.size()-1){
    	cout<<"No"<<endl;
      	return 0;
    }
  	else{
    	int size = a.size();
      	for(int i=0;i<size;i++){
        	if(a[i] != b[i]){
            	cout<<"No"<<endl;
              	return 0;
            }
        }
    }
  
  	cout<<"Yes"<<endl;
  	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define N 100009
#define ll long long
#define ff first
#define ss second
#define mod 998244353
using namespace std;
ll n, a, b;
int main() {
    cin>>n>>a>>b;
    ll to = (a + b) / 2;
    if((a + b) % 2 == 0)
        cout<<(b - to);
    else {
        if(a <= n - b + 1) {
            ll ans = a - 1;
            ans++;
            b -= a;
            a = 1;
            ans += (a + b) / 2;
            ans--;
            cout<<ans;
        }
        else {
            ll ans = n - b;
            ans++;
            a += (n - b + 1);
            b = n;
            ans += ((a + b) / 2 - a);
            cout<<ans;
        }
    }
}


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

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

    if (N >= 1000) {
        while (true) {
          N -= 1000;
          if (N < 1000) {
               break;
          }
        }
    }

    if (N > 0) {
        cout << 1000 - N << endl;
    }
    else if (N == 0) {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	


	void solve(){

		ini(k);
		ins(morty);
		if(morty.size()<= k)out(morty);
		else{
			FOR(i,0,k){
				cout<<morty[i];
			}
			cout<<"...";
			out();
		}
		






	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n, x ;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0;
    rep(i, n - 1) {
        if (a[i] + a[i + 1] > x) {
            ll to = max(0LL, x - a[i]);
            sum += a[i + 1] - to;
            a[i + 1] = to;
            
            ll rem = a[i] + a[i + 1] - x;
            sum += rem;
            a[i] -= rem;
        }
    }

    put(sum);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4008
#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
#define ld long double

int main() {
    int a,b;
  cin>>a>>b;
if(a<=b) rep(i,b)cout<<a;
 else rep(i,a)cout<<b;
  
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
// #define int long long

const int MAX_V=1000;
int memo[1000001]={0};
int dist[MAX_V][MAX_V];



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    int n;
    cin>>n;

    bool flag=false;

    int arr[n]={0};
    int count;
    int ans=0;

    REP(i,n){
    	cin>>arr[i];
    }

    while(1){
   		
    	count=0;

    	REP(i,n){
    		if(arr[i]%2==0){
    			count++;
    			arr[i]=arr[i]/2;
    		}
    	}
    	// cout<<"count:"<<count<<endl;
    	if(count==n)ans++;
    	else flag=true;
    	

    	if(flag)break;

    	// REP(i,n){
    	// 	cout<<arr[i]<<" ";
    	// }cout<<endl;

    }

    cout<<ans<<endl;

    return 0;
    
}




Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int bs[15];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		int t1, t2;
		scanf("%d", &t1);
		while (t1--) {
			scanf("%d", &t2);
			t2--;
			bs[t2] ^= 1 << i;
		}
	}
	int st = 0;
	for (i = 0; i < M; i++) {
		int t;
		scanf("%d", &t);
		if (!t) st ^= 1 << i;
	}

	int ans = 0;
	for (i = 0; i < (1 << N); i++) {
		int s = st;
		for (j = 0; j < N; j++) {
			if (i & (1 << j)) {
				s ^= bs[j];
			}
		}
		if (s == (1 << M) - 1) ans++;
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

s = 0
r = [0] * N
r[0] = a[0]

for i in range(1, N):
    r[i] = r[i-1] + a[i]

for i in range(N-1):
    s += a[i] * (r[N-1] - r[i])

print(s % (10 ** 9 + 7))

Measured memory_bytes: 31436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace algorithm
{
	class Program
	{
		public static void Main()
		{
			Console.ReadLine();
			var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			int l = 0, r = 1;
			int max = 0;
			if (nm.Length==1)
			{
				max = 1;
			}
			else
			{
				Array.Sort(nm);
				while (r < nm.Length)
				{
					if (nm[l] == nm[r] || nm[l] == nm[r] - 1 || nm[l] == nm[r] - 2)
					{
						r++;
						max = Math.Max(max, r - l);
					}
					else
					{
						l++;
						r = l;
					}
				}
			}
			Console.WriteLine(max);

		}
	}
}




Measured memory_bytes: 18912
N = int(input())
a = list(map(int,input().split()))
num = [0 for i in range(9)]
for i in a:
    if i >= 3200:
        num[8] += 1
    else:
        num[i//400] += 1

zero = num[:8].count(0)
print(max(8-zero,1), end = ' ')
print(8-zero + num[8])

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		B solver = new B();
		solver.solve(1, in, out);
		out.close();
	}

	static class B {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			long n = in.nextLong(), a = in.nextLong(), b = in.nextLong();
			long blue = 0;

			//		if(a != 0 && b != 0) {
			//            while (n > 0) {
			//                if (n >= a) {
			//                    blue += a;
			//                } else {
			//                    blue += n;
			//                }
			//
			//                n -= (a + b);
			//
			//            }
			//        }

			blue += n / (a + b) * a;

			long amari = n % (a + b);
			if (amari > 0) {
				if (amari >= a) {
					blue += a;
				} else {
					blue += amari;
				}
			}

			out.println(blue);
		}

	}
}



Measured memory_bytes: 23124
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;

		pr.printf("%c%d%c\n", s[0], n - 2, s[n - 1]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define llt long long int
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
	speed;
	int n, m;
	cin >> n  >> m;
	cout << n*(n-1)/2 + m*(m-1)/2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[100002];
int L[100002];
int R[100002];
vector<int>G[100002];
int root=-1;
bool used[100002];
bool ans=true;
LL dfs(int x){
     used[x]=true;
     LL total=0;
     LL m=0;
     if(G[x].size()==1)return A[x];
     REP(i,G[x].size()){
         if(used[G[x][i]]==false){
            LL temp=dfs(G[x][i]);
            //cout<<"a"<<G[x][i]<<" "<<temp<<endl;
            total+=temp;
            m=max(m,temp);
         }
     }
     if(A[x]<m)ans=false;
     if(A[x]<total/2)ans=false;
     if(A[x]>total)ans=false;
     //cout<<"b"<<x<<" "<<2*A[x]-total<<endl;
     return 2*A[x]-total;
}

int cnt[100002];
int main(){
        REP(i,100002){
            cnt[i]=0;
            used[i]=false;
        }
        ans=true;
	cin>>N;
	REP(i,N){
	    cin>>A[i];
	}
	REP(i,N-1){
	    int a,b;
	    cin>>a>>b;
	    a--;
	    b--;
	    cnt[a]++;
	    cnt[b]++;
	    G[a].push_back(b);
	    G[b].push_back(a);
	}
	if(N==2){
	   if(A[0]==A[1]){
	      cout<<"YES"<<endl;
	   }else{
	      cout<<"NO"<<endl;
	   }
	   cout<<endl;
	   return 0;
	}
	
	REP(i,N){
	    if(cnt[i]>=2){
	       root=i;
	       break;
	    }
	}
//	cout<<"root"<<root;
        LL aaa=dfs(root);
        /*REP(i,N){
            cout<<A[i]<<endl;
        }*/
	if(ans&&aaa==0){
	   cout<<"YES"<<endl;
	}else{
           cout<<"NO"<<endl;
        }
	return(0);
}

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

int main(void){
    int n,l;
    cin >> n >> l;
    vector<string> str(n);
    for(int i=0; i<n; i++) cin >> str[i];

    sort(str.begin(), str.end());
    string ans;
    for(int i=0; i<n; i++) ans += str[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
Module Module1

    Sub Main()
        Dim readline As String
        Dim len As Integer = 0
        Dim hogehoge() As String

        hogehoge = Console.ReadLine.Split(" "c)

        If CType(hogehoge(0), Integer) >= 10 Then
            Console.WriteLine(CType(hogehoge(1), Integer).ToString)
        Else
            Console.WriteLine((CType(hogehoge(1), Integer) + ((10 - CType(hogehoge(0), Integer)) * 100)).ToString)
        End If

    End Sub


End Module


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 998244353;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int h, w, n;
    cin >> h >> w >> n;
    if (h>w) swap(w, h);
    print((n+w-1)/w);
}


Measured memory_bytes: 256
import math

n = int(input())

def dividing_point(p1, p2, ratio):
    return ( p1[0]*(1-ratio) + p2[0]*ratio, p1[1]*(1-ratio) + p2[1]*ratio)

def rotate_vec_60deg(v):
    return (v[0]/2 - math.sqrt(3)*v[1]/2, math.sqrt(3)*v[0]/2 + v[1]/2)
    

def koch(depth, p_left, p_right):
    if depth == 0:
        return
    
    s = dividing_point(p_left, p_right, 1/3)
    t = dividing_point(p_left, p_right, 2/3)
    tmpvec = rotate_vec_60deg((s[0] - p_left[0], s[1] - p_left[1] ))
    u = (s[0] + tmpvec[0], s[1] + tmpvec[1])
    
    koch(depth - 1, p_left, s)
    print(s[0], s[1])
    koch(depth - 1, s, u)
    print(u[0], u[1])
    koch(depth - 1, u, t)
    print(t[0], t[1])
    koch(depth - 1, t, p_right)
    
    
print(0.0, 0.0)
koch(n, (0,0), (100, 0))
print(100.0, 0)


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define intmax 2147483647
#define sp ' '
using namespace std;
typedef long long ll;

ll n,q,s,t,x,a[1<<18],b[1<<18],u;
bool f;

void add(int s,int t,int x,int k,int l,int r){
	if(!(r<s||t<l)){
		a[k]+=x*(min(t,r)-max(s,l)+1);
		if(s<=l&&r<=t){
			b[k]+=x;
		}
		else{
			add(s,t,x,k*2,l,(l+r)/2);
			add(s,t,x,k*2+1,(l+r)/2+1,r);
		}
	}
}
ll getSum(int s,int t,int k,int l,int r){
	if(r<s||t<l)return 0;
	else if(s<=l&&r<=t){
		return a[k];
	}
	else{
		b[k*2]+=b[k];
		b[k*2+1]+=b[k];
		a[k*2]+=b[k]*(r-l+1)/2;
		a[k*2+1]+=b[k]*(r-l+1)/2;
		b[k]=0;
		return getSum(s,t,k*2,l,(l+r)/2)+getSum(s,t,k*2+1,(l+r)/2+1,r);
	}
}

int main(){
	cin>>n>>q;
	for(int i=1;;++i){
		if((1<<i)/n>=2){
			u=1<<i-1;
			break;
		}
	}
	for(int i=0;i!=q;++i){
		cin>>f>>s>>t;
		--s;
		--t;
		if(f)
			cout<<getSum(s,t,1,0,u-1)<<endl;
		else{
			cin>>x;
			add(s,t,x,1,0,u-1);
		}
	}
	return 0;
}



Measured memory_bytes: 6260
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
 
    int l[15];
    int i,a,b;
 
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)!=EOF){
 
        double sum=0;
        for(i=0;i<10;i++){
            sum+=(double)l[i];
        }
 
    double c=0,d=0;
    for(i=0;i<10;i++){
        //c+=l[i];
        c+=l[i];
        d+=(double)l[i]/a*b;
        //cout<<"-"<<c<<"-"<<d<<endl;
        if(c+d>=sum)break;
    }
    cout<<i+1<<endl;
 
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e9
#define mod 1000000007

struct song{
  ll t,p,f;
};

ll N,T;
vector<song> ss;
ll t[4001],p[4001],f[4001];
ll dp[4001][4001];
deque<P> deq[4001];

ll calc(P func,ll x){ return func.fi*x+func.se; }

bool check(P f1,P f2,P f3){
  ll a1=f1.fi, b1=f1.se;
  ll a2=f2.fi, b2=f2.se;
  ll a3=f3.fi, b3=f3.se;
  return (a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2);
}

void add(ll k,ll A,ll B){
  ll sz=deq[k].size();
  while(deq[k].size()>1&&check(deq[k][sz-2],deq[k][sz-1],P(A,B))){
    deq[k].pop_back(); sz=deq[k].size();
  }
  deq[k].push_back(P(A,B));
}

ll query(ll k,ll x){
  if(deq[k].size()==0)return -INF;
  while(deq[k].size()>1&&calc(deq[k][0],x)<=calc(deq[k][1],x)){
    deq[k].pop_front(); 
  }
  return calc(deq[k][0],x);
}

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

  cin>>N>>T;
  rep(i,N){
    ll tt,pp,ff;
    cin>>tt>>pp>>ff;
    ss.push_back((song){tt,pp,ff});
  }
  sort(all(ss),[](const song& a,const song& b){
    if(a.f==b.f) return a.p < b.p;
    else return a.f < b.f;
  });
  rep(i,N){
    t[i]=ss[i].t; p[i]=ss[i].p; f[i]=ss[i].f;
  }
  rep(i,4001)rep(j,4001)dp[i][j]=-INF;
  rep(i,N){
    dp[i][t[i]]=p[i];
  }

  ll res=0;
  rep(i,N){
    rep(j,T+1){
      ll l=j-t[i];
      if(l>0){
        maxch(dp[i][j],p[i]-f[i]*f[i]+query(l,f[i]));
      }
      maxch(res,dp[i][j]);
    }
    rep(j,T+1){
      if(dp[i][j]!=-INF)add(j,2LL*f[i],dp[i][j]-f[i]*f[i]);
    }
  }

  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 132784
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

bool have[100];

int main(){
	int N, K;
	cin >> N >> K;

	for (int i=0; i<K; i++) {
		int d;
		cin >> d;

		for (int j=0; j<d; j++) {
			int A;
			cin >> A;
			A--;
			have[A] = true;
		}
	}

	int ans = N;

	for (int i=0; i<N; i++) {
		if (have[i]) ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next().toCharArray

    val plus = new Array[Int](n)
    val minus = new Array[Int](n)
    for (i <- plus.indices) {
      if (i == 0) {
        s(i) match {
          case 'I' =>
            plus(i) = 1
            minus(i) = 0
          case 'D' =>
            plus(i) = 0
            minus(i) = 1
        }
      } else {
        s(i) match {
          case 'I' =>
            plus(i) = plus(i - 1) + 1
            minus(i) = minus(i - 1)
          case 'D' =>
            plus(i) = plus(i - 1)
            minus(i) = minus(i - 1) + 1
        }
      }
    }

    val ans = new Array[Int](n)
    for (i <- plus.indices) {
      ans(i) = plus(i) - minus(i)
    }
    println(math.max(ans.max, 0))
  }
}


Measured memory_bytes: 26048
n = int(input())
l = list(map(int, input().split()))
ans = []

cnt =1
rain_others = 0
while cnt != n:
    rain_others += l[cnt] * 2
    cnt += 2
ans.append(sum(l)-rain_others)

for i in range(1, n):
    ans.append(l[i-1]*2-ans[i-1])

print(" ".join(list(map(str, ans))))

Measured memory_bytes: 19096
n = int(input())
if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9:
    print('hon')
elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9176
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc=new Scanner(System.in);
        while(true){
           int H=sc.nextInt();
           int W=sc.nextInt();
           if(H==0){
               if(W==0)break;
           }else{
               for(int i=1;i<=H;i++){
                   if(i==1 || i==H){
                       for(int j=1;j<=W;j++){
                           System.out.print("#");
                       }
                      
                   }else{
                       for(int j=1;j<=W;j++){
                           if(j==1 || j==W){
                               System.out.print("#");
                           }else{
                               System.out.print(".");
                           }
                            
                           
                       }
                   }
                   System.out.println();
                   
               }
               System.out.println();
           }
        }
           
    }
}



Measured memory_bytes: 34408
N,M = map(int,input().split())

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def ans(N,M):
    if N>=2 and M<2:
        return combinations_count(N,2)
    elif N<2 and M>=2:
        return combinations_count(M,2)
    elif N<2 and M<2:
        return 0
    else:
        return combinations_count(N,2) + combinations_count(M,2) 


print(ans(N,M))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e15;
int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  for(int i=0;i<N;i++)
    cin >> h[i];
  vector<ll> dp(N, INF);
  dp[0] = 0;
  for(int from = 0;from < N-1;from++){
    for(int to = from+1;to<=from+K && to < N;to++){
      dp[to] = min(dp[to], dp[from] + abs(h[from] - h[to]));
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
var lines = [];
var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var s = lines[0].split("");

    for (var i = 0; i < s.length; i++) {
        if(s[i] === '1'){result++;}
     }

     console.log(result);
});

Measured memory_bytes: 7628
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>
#include <climits>

using namespace std;

#define pb push_back
#define x  first
#define y  second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
// #define debug(...) 42
#endif

const int MX =1e5;
const ll MD= LLONG_MAX;
const ld PI=acos(-1);

int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		map<ll,ll>mp;
		int x,ch=1;
		cin>>x;
		for(int i=-MX;i<=MX;i++){
			ll pro=1;
			if(i==0){
				pro=0;
			}
			else{
				for(int j=0;j<5;j++){
					if(abs(pro)>abs(MD/i)) break;
					pro*=i;
				}
			}
			if(mp[pro-x]){
				cout<<i<<" "<<mp[pro-x];
				return 0;
			}
			mp[pro]=i;
		}
	}
	return 0;	
}


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

const int MAX = 2100; // 適宜
const int MOD = 1e9 + 7;


ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(){
	
	// 前処理
    COMinit();
	
	int n,k;
	cin >> n >> k;
	

	rep(i,k){
		int res = ( COM(n-k+1,i+1) * COM(k-1,i) )%MOD;
		cout << res << endl;
	}

	return 0;
}

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

using namespace std;

stack <int> st;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector <int> ans;
	for (int i = 0; i < n; ++i) {
		if(s[i] == 'S') {
			st.push(0);
		}
		else {
			if(!st.empty()) {
				st.pop();
			} else {
				ans.push_back(1);
			}
		}
	}
	while(!st.empty()) {
		st.pop();
		ans.push_back(1);
	}
	printf("%d\n", (int)ans.size());

}

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

int cnt,flag[maxn],head[maxn];

ll black,white,n,m;

struct E{
	int to,nxt;
}edge[maxn<<1];

inline void add(int u,int v){edge[++cnt]=(E){v,head[u]};head[u]=cnt;}

void dfs(int u,int col){
	flag[u]=col;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(flag[v]==-1) dfs(v,col^1);
		if(flag[v]==col){
			printf("%lld",n*(n-1)/2-m);
			exit(0);
		}
	}
}

int main(){
	scanf("%lld%lld",&n,&m);
	memset(flag,-1,sizeof(flag));
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) flag[i] == 1 ? white++ : black++;
	printf("%lld",white*black-m);
	return 0;
}

Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int t = Integer.parseInt(chr[2]);

			 System.out.println(t/a*b);
		}
	}
}

Measured memory_bytes: 25172
for q in range(int(input())):
    xa, ya, ra, xb, yb, rb = map(float, input().split())
    d2 = ((xb - xa) ** 2) + ((yb - ya) ** 2)
    if rb < ra and d2 < ((ra - rb) ** 2):
        print(2)
    elif ra < rb and d2 < ((rb - ra) ** 2):
        print(-2)
    elif ((ra + rb) ** 2) < d2:
        print(0)
    else:
        print(1)



Measured memory_bytes: 5612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,    
        n: usize,
        ass: [usize;n]
    }
    
    let mut ass = ass;
    let mut pre = ass[0].clone();
    let mut max = 0;
    let mut ans = 0;
    ass.push(k + pre);
    for i in ass[1..].iter(){
        let xx = i - pre;
        max = std::cmp::max(xx, max);
        ans += xx;
        pre = *i;
    }
    println!("{}", ans - max);
    
}


Measured memory_bytes: 10492
use std::io;


fn main() {
    let n = read_one::<usize>();
    let pn = read::<usize>();
    let mut cnt = 0;
    for i in 1..(n - 1) {
        if pn[i - 1] < pn[i] && pn[i] < pn[i + 1] { cnt += 1; }
        if pn[i - 1] > pn[i] && pn[i] > pn[i + 1] { cnt += 1; }
    }
    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vl x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    ll l, q;
    cin >> l >> q;
    vl a(q), b(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    vvl dbl(n, vl(20, n - 1));
    int nxt = 0;
    for (int i = 0; i < n; ++i) {
        while (x[nxt] - x[i] <= l && nxt < n) {
            nxt++;
        }
        nxt--;
        dbl[i][0] = nxt;
    }
    for (int i = 1; i <= 17; ++i) {
        for (int j = 0; j < n; ++j) {
            dbl[j][i] = dbl[dbl[j][i - 1]][i - 1];
        }
    }
    auto check = [&](int mid, int i) {
        int l = min(a[i], b[i]);
        int r = max(a[i], b[i]);
        for (int j = 17; j >= 0; --j) {
            if (mid & 1 << j)
                l = dbl[l][j];
        }
        return r <= l;
    };
    for (int i = 0; i < q; ++i) {
        int ok = n;
        int ng = 0;
        while (ng + 1 != ok) {
            int mid = (ok + ng) / 2;
            if (check(mid, i))
                ok = mid;
            else
                ng = mid;
        }
        cout << ok << "\n";
    }
    return 0;
}

Measured memory_bytes: 22784
#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);
  ll n; cin >> n;
  if(n%2==1){
    cout << 0;
  }else{
    ll ans = 0;
    for(ll i = 10; i <= n; i*=5) ans += n/i;
    cout << ans;
  }
  cout << "\n";
  return 0;
}


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

inline unsigned f(unsigned n) {
  unsigned cnt = 0;
  while (n % 2 == 0) {
    n /= 2;
    cnt++;
  }
  return cnt;
}

void solve() {
  int N;
  cin >> N;
  unsigned mx = 0;
  unsigned ans = 0;
  for (int i = 2; i <= N; i += 2) {
    int chk = f(i);
    if (mx < chk) {
      mx = chk;
      ans = i;
    }
  };
  cout << ((N == 1) ? 1 : ans) << endl;
}

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,l;
  cin>>n>>l;
  vector<int> appletaste(n);
  for(int i=0;i<n;i++){
      appletaste.at(i) = l + i;/*問題文のiは１から始まるのでl+(i+1)-1とする*/
    }
  
  if(l>=0){/*l>=0とl<0で場合分け*/
    
    int tastesum = 0;
    for(int i=1;i<n;i++){
      tastesum+=appletaste.at(i);/*l>=0の場合は配列の最初の要素を除けばよい*/
    }
    cout<<tastesum<<endl;/*合計出力*/
  }
  
  else if(l<0){/*l<0の場合*/
    
    int tastesum = 0;
    /*appletasteは昇順になっていて、要素に0を含むかどうかの場合分けが必要*/
      if(appletaste.at(n-1)>=0){/*最後(最大)の要素が0以上の場合(要素に0を含む)*/
        for(int i=0;i<n;i++){
          if(appletaste.at(i)==0){/*0となる要素を取り除く*/
            continue;
          }
          else{
            tastesum+=appletaste.at(i);/*それ以外を足す*/
          }
        }
        cout<<tastesum<<endl;/*合計出力*/
      }
    else{/*最後(最大)の要素が0未満の場合(0を含まない)*/
      for(int i=0;i<n-1;i++){
        tastesum+=appletaste.at(i);/*最後の要素以外全部足そう*/
      }
      cout<<tastesum<<endl;/*合計出力*/
    }
    
  }
  return 0;
}

Measured memory_bytes: 256