akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    let mut cnt = 1;
    while !r2.is_empty() {
        if !rems.is_empty() {
            cnt += 1;
        }
        while let Some(s_idx) = q.pop_front() {
            rems.remove(&s_idx);
            if !r2.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = r2.iter().next() {
            // q.push_back(r);
            cnt += r;
        }
    }
    if cnt > 1e18 as usize{
        println!("{}", "hoge");
    }
    println!("{}", ans);
}


Measured memory_bytes: 27576
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 10001
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair




int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout); 
#endif
ll n,k;
cin>>n>>k;
ll a[n];
fr(n) cin>>a[i];
ll dp[n];
dp[0]=0;
//fr(k-1) dp[i+1]=abs(a[0]-a[i]);
rep(i,1,n){
   ll  mn=1e10;
    rep(j,1,k+1){
        if(j<=i)
        mn=min(dp[i-j]+abs(a[i]-a[i-j]),mn);
    }    
    //cout<<x<<" "<<y<<endl;
    dp[i]=mn;
}
//fr(n) cout<<dp[i]<<" ";
cout<<dp[n-1];

    return 0; 
} 

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

int main(){
  int n,x;
  cin>>n;
  vector<vector<int>>v(n+1);
  for(int i=1;i<n;i++){
    cin>>x;
    v[x].push_back(i+1);
  }
  for(int i=1;i<=n;i++){
    cout<<v[i].size()<<endl;
  }

}

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

int main() {

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> l(q), r(q);
	rep(i, q) cin >> l[i] >> r[i];

	vector<int> sum(n+1, 0);

	for (int i = 1; i < n; i++) {
		if ( s[i-1] == 'A' && s[i] == 'C') {
			sum[i+1] = sum[i] + 1; 
		} else {
			sum[i+1] = sum[i];
		}
	}
	//0 1 2 3 4 5 6
	// A C A C A C
	// 1 2 3 4 5 6

	rep(i, q) {
		int ans = sum[r[i]] - sum[l[i]];
		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 2176
n = int(input())
x = list(map(int, input().split()))

x_sorted = sorted(x)
larger_candidate = x_sorted[n//2]
smaller_candidate = x_sorted[n//2-1]

for i in range(len(x)):
    if x[i] <= smaller_candidate:
        print(larger_candidate)
    else:
        print(smaller_candidate)





Measured memory_bytes: 25620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

int n;
vector<int> dp;
vector<int> costs;

int dpf(int i){
    if(dp[i] != -1){
        return dp[i];
    }
    if(i == n - 1){
        dp[i] = 0;
        return dp[i];
    }
    if(i == n - 2){
        dp[i] = dpf(i + 1) + abs(costs[i] - costs[i + 1]);
        return dp[i];
    }
    dp[i] = min(dpf(i + 1) + abs(costs[i] - costs[i + 1]), dpf(i + 2) + abs(costs[i] - costs[i + 2]));
    return dp[i];
}

signed main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        costs.push_back(x);
        dp.push_back(-1);
    }
    dpf(0);
    cout << dp[0];
}


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


int main(){
int d;
cin >>d;
if (d==25) cout <<"Christmas"<<endl;
if (d==24) cout <<"Christmas Eve"<<endl;
if (d==23) cout <<"Christmas Eve Eve"<<endl;
if (d==22) cout <<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_122
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            switch (s[0])
            {
                case 'A':
                    WriteLine('T');
                    break;
                case 'C':
                    WriteLine('G');
                    break;
                case 'G':
                    WriteLine('C');
                    break;
                case 'T':
                    WriteLine('A');
                    break;
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  int64_t N,A=1;
  cin>>N;
  vector<int64_t> B(N);
  for(int64_t &i:B){
    cin>>i;
    if(i==0){
      cout<<0<<endl;
      return 0;
    }
  }
  for(int64_t &j:B){
    if(1000000000000000000/A<j){
      cout<<-1<<endl;
      return 0;
    }
    A*=j;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){

    int n;
    cin >> n;

    int h;
    int ans = 0;
    int max = 0;
    for(int i = 0; i < n; i++){
        cin >> h;
        if(h >= max){
            max = h;
            ans += 1;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
#define md 998244353
#define md1 998244353 
#define pb push_back
#define in insert
#define mkp make_pair
#define f(i,yha,wha) for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha) for(ll i=wha;i>=yha;i--)
#define mpll map<ll,ll>
#define len(p) p.size()
#define pll pair<ll,ll>
#define arr_sort_rev(arr,n) sort(arr, arr+n, greater<ll>());
#define vec_sort_rev(v) sort(v.begin(), v.end(), greater<ll>());
#define arr_sort(arr,n) sort(arr,arr+n)
#define vec_sort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define mem(a,t) memset(a,t,sizeof(a))
#define endl "\n"

void flash()
{
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
}

ll pw(ll x,ll y)
{
    if(y==0)
      return 1;
    if(y==1)
      return x;
    ll ans=pw(x,y/2);
    ans=ans*ans;
    if(y%2==1)
        ans=ans*x;
    return ans;
}
 
ll pwm(ll x,ll y)
{
    if(y==0)
      return 1;
    if(y==1)
      return x;
    ll ans=pwm(x,y/2)%md;
    ans=(ans*ans)%md;
    if(y%2==1)
        ans=(ans*x)%md;
    return ans;
}
 
int check(ll n)
{
    if(n<0)
      return 0;
    else
      return 1;
}
 
ll add(ll a,ll b)
{
    return a+b;
}
 
ll max(ll a,ll b)
{
    if(a>b)
      return a;
     else
      return b;
}
 
ll min(ll a,ll b)
{
    if(a>b)
      return b;
     else
      return a;
}

ll minv(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m,t = m; 
        m = a % m, a = t,t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
bool cmp(ll i1,ll i2) 
{ 
   
    // i1<i2 for increasing order
    // i1>i2 for decreasing order
    return (i1 < i2); 
}

void solve()
{
    
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<"\n";
    
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>

using namespace std;

#define rep(countName, left, right) for (int countName = left; countName < right; countName++)

/* ****************************** ユークリッド互除法 ****************************** */
long long GCD(long long a, long long b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return GCD(b, a % b);
    }
}
/* ****************************** ユークリッド互除法 ****************************** */

/* ****************************** 累積和 ****************************** */
vector<long long> CUSUM(vector<long long> &&v)
{
    int n = v.size();
    vector<long long> cusum(n);
    cusum[0] = v[0];
    rep(i, 1, n)
    {
        cusum[i] = v[i] + cusum[i - 1];
    }
    return cusum;
}

//部分和

long long partSum(vector<long long> &&v, long long left, long long right)
{
    return (v[right] - v[left]);
}

/* ****************************** 累積和 ****************************** */

/* ****************************** 二項係数 ****************************** */
//けんちょんさん作

const int MAX = 800000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
    {
        return 0;
    }
    if (n < 0 || k < 0)
    {
        return 0;
    }

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/* ****************************** 二項係数 ****************************** */

int main(void)
{
    int n;
    string input;
    cin >> n >> input;
    if ((int)input.length() == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        if (input.substr(0, (n / 2)) == input.substr(n / 2, input.length() - 1))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int d = scan.nextInt();
		System.out.print("Christmas ");
		for(int i = 0; i < 25 - d; i++) {
			System.out.print("Eve ");
		}
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 26880
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> B(N);
    rep(i, N) cin >> B[i];
    ll sumA = 0;
    ll sumB = 0;
    rep(i, N) {
        sumA += A[i];
        sumB += B[i];
    }
    if (sumA > sumB) {
        cout << "No" << endl;
        return 0;
    }
    ll cnt = 0;
    rep(i, N) {
        if (A[i] < B[i]) {
            cnt += (B[i]-A[i] + 2 - 1) / 2;
        }
    }
    if (cnt > sumB - sumA) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  string S;
  cin >> S;

  if (S[2]==S[3] && S[4] == S[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long ll;

int N;
ll A[200000];

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

    ll sum = 0;
    for(int i=0;i<N;i++){
        scanf("%lld", A+i);
        A[i+N] = A[i];
        sum += A[i];
    }

    for(int i=1;i<2*N;i++){
        A[i] += A[i-1];
    }

    ll res = 0ll;
    for(int i=0;i<N;i++){
        ll lb = 0, ub = sum;
        while(ub-lb > 1){
            ll mid = (lb+ub) / 2;
            // A[i] + ... + A[j] >= mid
            // A[0] + ... + A[j] >= A[0] + ... + A[i-1] + mid
            int index = std::lower_bound(A+i, A+i+N, (i>0?A[i-1]:0) + mid) - A;
            if(index == i+N){
                ub = mid;
                continue;
            }
            
            int index2 = std::lower_bound(A+index+1, A+i+N, A[index] + mid) - A;
            if(index2 >= i+N-1){
                ub = mid;
                continue;
            }

            if(A[i+N-1] - A[index2] >= mid){
                lb = mid;
            }else{
                ub = mid;
            }
        }

        res = std::max(res, lb);
    }

    printf("%lld\n", res);
}

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	long long n, k;
	cin >> n >> k;
	cout << (long long )(k * pow(k - 1, n - 1)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

main()
{
	IO;
	string s,t,ans="";
	cin>>s>>t;
	
	int dp[s.size()+1][t.size()+1];
	
	for(int i=0;i<=s.size();i++)
	{
		for(int j=0;j<=t.size();j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=0;
			}
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	
	/*for(int i=0;i<=s.size();i++)
	{
		for(int j=0;j<=t.size();j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	
	int i=s.size()-1,j=t.size()-1;
	
	while(i>=0 && j>=0)
	{
		if(s[i]==t[j])
		{
			ans+=s[i];
			i--;
			j--;
		}
		
		else if(dp[i][j+1]>dp[i+1][j])
		{
			i--;
		}
		
		else
		{
			j--;
		}
		
		//cout<<i<<j<<endl;
	}
	
	//cout<<i<<j;
	for(int i=ans.size()-1;i>=0;i--)
	cout<<ans[i];
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<vector>
//#include<queue>
//#include<sstream>
//#include<cmath>
//#include<set>
//#include<algorithm>
//#include<map>
#define mp make_pair
#define pii pair<int,int>
#pragma GCC optimize ("O3")
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 1e5+9;
const double pi=acos(-1.0);
const int inf = 1e9+9;
const int mod = 10007;
char op[10][10];
int pq[10][10];
int main()
{
    ios::sync_with_stdio(false);
    int r,c,k,ans=0;
    cin>>r>>c>>k;
    for(int i=0;i<r;++i) cin>>op[i];
    for(int i=0;i<(1<<r+c);++i){
        for(int j=0;j<r;++j){
            for(int p=0;p<c;++p){
                if(op[j][p]=='.') pq[j][p]=0;
                else pq[j][p]=1;
            }
        }
        for(int j=0;j<r;++j){
            if(i>>j&1){
                for(int p=0;p<c;++p) pq[j][p]=2;
            }
        }
        for(int j=r;j<r+c;++j){
            if(i>>j&1){
                for(int p=0;p<r;++p) pq[p][j-r]=2;
            }
        }
        int jk=0;
        for(int j=0;j<r;++j){
            for(int p=0;p<c;++p){
                if(pq[j][p]==1) ++jk;
            }
        }
        if(jk==k) ++ans;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<usize>();
    }
    seq.sort();
    let mut ans = 0;
    for i in 0..n {
        let mut k = i + 2;
        for j in i + 1..n {
            if k == j {
                k += 1;
            }
            while k < n && seq[k] < seq[i] + seq[j] {
                k += 1;
            }
            ans += k - j - 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


const int limit = 50;

int n,m;
int a[limit],b[limit];
bool G[limit][limit];
bool visited[limit];

void dfs(int v)
{
    visited[v] = true;
    for(int i = 0; i < n; i++){
        if(!visited[i]){
            if(G[v][i]){
                dfs(i);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < m; i++){
        G[a[i]][b[i]] = false;
        G[b[i]][a[i]] = false;

        for(int j = 0; j < n; j++){
            visited[j] = false;
        }

        dfs(0);

        bool flag = false;
        for(int j = 0; j < n; j++){
            if(!visited[j]) flag = true;
        }
        if(flag) ans++;

        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

ll n,d;

double dist(const vector<double>& x,const vector<double>& y){
    vector<double> sa(d,0.0);
    rep(i,d){
        sa[i]=(x[i]-y[i])*(x[i]-y[i]);
    }
    return( sqrt(accumulate(sa.begin(),sa.end(),0.0)));
}

vector<vector<double>> x;
void input(){
    cin>>n>>d;
    x.resize(n);
    rep(i,n){
        x[i].resize(d);
    }

    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
}
void src(){
    ll count=0;
    rep(i,n){
        repi(j,i+1,n){
            double dd = dist(x[i],x[j]);
            if(floor(dd)==dd) count++;
        }
    }
    cout<<count;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int main(void){
    double r;
    std::cin >> r;
    std::cout << r*2*M_PI << std::endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << max(A*B,C*D) << endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define rep(i,a,n) for (int i=a; i<=n; ++i)
# define per(i,a,n) for (int i=a; i>=n; --i)
# define bug puts("H");
# define pb push_back
# define mp make_pair
# define all(x) (x).begin(), (x).end()
# define SZ(x) (int)x.size()
# define fi first
# define se second
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mem(a,b) memset(a,b,sizeof(a))
# define INF 1000000001
# define MOD (1ll<<32)
typedef vector<int> Vi;
typedef long long i64;
typedef pair<int, int> Pi;
mt19937 mrand(random_device{}());
int rnd(int x) {return mrand()%x;}
i64 powmod(i64 a, i64 b){i64 res=1;a%=MOD;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
i64 Inv(i64 b){return powmod(b,(i64)MOD-2);}
const int N = 100005;
const double eps = 1e-9;
const long long inf = 1e18;

Vi E[N];
bool vis[N];

void dfs(int x) {
    vis[x] = true;
    for (auto i: E[x]) if (!vis[i]) dfs(i);
}
int main()
{
    int n, m, u, v;
    scanf("%d%d", &n, &m);
    rep(i,1,m) scanf("%d%d", &u, &v), E[u].pb(v), E[v].pb(u);
    int ans = 0;
    rep(i,1,n) {
        if (!vis[i]) dfs(i), ++ans;
    }
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 9764
using System;


public class Hello{
    public static void Main(){
        // Your code here!
        var line = System.Console.ReadLine();
        string[] argvalueList =line.Split(' ');
        
        var W = Double.Parse(argvalueList[0]);
        var H = Double.Parse(argvalueList[1]);
        var x = Double.Parse(argvalueList[2]);
        var y = Double.Parse(argvalueList[3]);
        var num = 0;
        
        var area = ( W * H )/2;
        string ans = string.Format("{0:F6}", area);
        
        if(W == x*2 && H == y*2){
            num = 1;
        }else{
            num = 0;
        }
        
        System.Console.WriteLine("{0} {1}",ans,num);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <cctype>

using namespace std;

int mcxi_to_i(string s) {
  int ans = 0;
  int keta = 1;
  for(unsigned int i=0; i<s.size(); i++) {
    switch(s[i]) {
    case 'm': ans += 1000 * keta; keta = 1; break;
    case 'c': ans += 100 * keta; keta = 1; break;
    case 'x': ans += 10 * keta; keta = 1; break;
    case 'i': ans += 1 * keta; keta = 1; break;
    default: 
      // cerr << s[i] << endl;
      keta = (int) s[i] - '0';
      // cerr << "keta: " << keta << endl;
      break;
    }
  }
  // cerr << ans << endl;
  return ans;
}

string keta(int x, int waru, string k) {
  int keta = (x%(waru*10))/waru;
  if (keta == 0) return "";
  if (keta == 1) return k;
  stringstream ss;
  ss << keta;
  return ss.str() + k;
}

string i_to_mcxi(int x) {
  return keta(x, 1000, "m") + keta(x, 100, "c") 
    + keta(x, 10, "x") + keta(x, 1, "i");
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    string a, b;
    cin >> a >> b;
    int c = mcxi_to_i(a) + mcxi_to_i(b);
    cout << i_to_mcxi(c) << endl;
  }
}

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

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
double ans = 0;
int water[2];
int suger[2];
int e,f;
int ans1;
int ans2;
void maxSuger(int w){
  for(int i = 0; i * suger[0] + w <= f; i++){
    for(int j = 0; suger[0] * i + suger[1] * j + w <= f;j++){
      int s = suger[0] * i + suger[1] * j;
      //条件判定
      if(s <= w/100 * e)
      //最大値更新
      if(ans <= 100*s/(double)(s + w)){
        ans = 100*s/(double)(s + w);
        ans1 = s+w;
        ans2 = s;
      }
    }
  }
}
int main(){
  cin >> water[0] >> water[1] >> suger[0] >> suger[1] >> e >> f;

  for(int i = 0; i <= 30; i++){
    for(int j = 0; i+j <= 30;j++){
      if(i==0 && j==0) continue;
      maxSuger(100 * (water[0] * i + water[1] * j));
    }
  }
  cout << ans1 << ' ' << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	var s []string
	for _, v := range S {
		s = append(s, string(v))
	}
	m := map[string]int{}
	for i := 0; i < 1000; i++ {
		w := fmt.Sprintf("%03d", i)
		x := -1
		for j := 0; j < len(s); j++ {
			if s[j] == w[0:1] {
				x = j
				break
			}
		}
		if x < 0 {
			continue
		}
		y := -1
		for j := x + 1; j < len(s); j++ {
			if s[j] == w[1:2] {
				y = j
				break
			}
		}
		if y < 0 {
			continue
		}
		for j := y + 1; j < len(s); j++ {
			if s[j] == w[2:3] {
				m[w]++
				break
			}
		}

	}
	fmt.Println(len(m))
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,i,j,k;
    vector<long long int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    j=v[0];
    for(i=1;i<n;i++)
    {
        j=__gcd(j,v[i]);
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    ll y;
    cin >> n >> y;
    rep(i,n+1){
        rep(j,n-i+1){
            if((y-i*10000-j*5000)-(n-i-j)*1000==0){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint dp[N+5][5]={};
    int K=N%2?2:1;
    rep(i,N+5) rep(j,5) dp[i][j]=-LINF;
    dp[0][0]=0,dp[1][0]=A[0];
    if(N>=2) dp[2][1]=A[1];
    if(N>=3) dp[3][2]=A[2];
    rep(i,N) rep(j,3){
        if(i+2>N) continue;
        dp[i+2][j]=max(dp[i+2][j],dp[i][j]+A[i+1]);
        if(i+3>N) continue;
        dp[i+3][j+1]=max(dp[i+3][j+1],dp[i][j]+A[i+2]);
        if(i+4>N) continue;
        dp[i+4][j+2]=max(dp[i+4][j+2],dp[i][j]+A[i+3]);
    }
    lint ans=max(dp[N][K],dp[N-1][K-1]);
    if(K==2) ans=max(ans,dp[N-2][0]);
    cout << ans << endl;
}

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

int main() {
  int N;
  int result = 0;
  cin >> N;

  for (int i=0; i<N; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      cout << "Four" << endl;
      result = 1;
      break;
    }
  }
  if (result == 0){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=['']*N
for i in range(N):
    A[i]=input()
B=['']*M
for i in range(M):
    B[i]=input()

ans='No'
i=0
while i+M<=N:
    j=0
    while j+M<=N:
        k=0
        count=0
        while k<M:
            if A[j+k][i:i+M]==B[k]:
                count+=1
            else:
                break
            if count==M:
                ans='Yes'
            k+=1
        j+=1
    i+=1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    
    boolean fun(double[] s){
        double x1=s[0],y1=s[1],x2=s[2],y2=s[3],x3=s[4],y3=s[5],xp=s[6],yp=s[7],v,w;
        v=((x1-xp)*(y1-y3)-(x1-x3)*(y1-yp)) / ((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2));
        w=((x1-xp)*(y1-y2)-(x1-x2)*(y1-yp)) / (-(x1-x2)*(y1-y3)+(x1-x3)*(y1-y2));
        if(0<v && v<1 && 0<w && w<1 && v+w<1)return true;
        return false;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double[] lst=new double[8];String s;
        while(sc.hasNext()){
            for(int i=0;i<8;i++){lst[i]=sc.nextDouble();}
            System.out.println(s = new Main().fun(lst) ? "YES" : "NO" );
        }
    }
}


Measured memory_bytes: 31796
n = gets.chomp.to_i
times = gets.chomp.split.map {|i| i.to_i}
base_total_time = times.inject(:+)
m = gets.chomp.to_i

m.times do |i|
  p, x = gets.chomp.split.map {|item| item.to_i}
  diff = times[p-1] - x
  puts base_total_time - diff
end

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

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

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

class IndependentSet{
  typedef unsigned long long ll;
  std::vector<ll>  graph;
  std::vector<int> weight;
  
  ll              used;
  inline int  degree(int v) { return __builtin_popcountll(graph[v] & ~used); }
public:
  
  IndependentSet(int V, std::vector<int> weight)
    : graph(V), weight(weight), used(0)
  {
    assert(V < 64);
    for (int i = 0; i < V; i++){
      graph[i] |= 1LL << i;
    }
  }
  
  void add_edge(int u, int v){
    assert(u < (int)graph.size() && v < (int)graph.size());
    graph[u] |= 1LL << v;
    graph[v] |= 1LL << u;
  }
  
  int solve(){
    int res      = 0;
    int next     = -1;
    ll  old_used = used;
    
    for (size_t v = 0; v < graph.size(); v++){
      if (used & (1LL << v)){
        continue;
      } else if (degree(v) <=  1){
        next = v;
        break;
      } else if (next == -1 || degree(v) > degree(next)){
        next = v;
      }
    }

    if (next == -1){
      return 0;
    } else if (degree(next) > 1){
      used |= 1LL << next;
      res = solve();
      used = old_used;
    }
    
    used |= graph[next];
    res = std::max(res, solve() + weight[next]);
    used = old_used;
    return res;
  }
};


int main(){
  ios::sync_with_stdio(false);

  int N;
  
  while (cin >> N && N){
    map<string, int> city_to_id;
    
    int adj[N][N];
    vector<int> weight(N);
    
    memset(adj, 0, sizeof(adj));
    REP(i, N){
      string city;
      cin >> city;
      if (city_to_id.count(city) == 0) {
        size_t id = city_to_id.size();
        city_to_id[city] = id;
      }
      cin >> weight[city_to_id[city]];

      int num_adj;
      cin >> num_adj;
      REP(j, num_adj){
        string adj_city;
        cin >> adj_city;
        if (city_to_id.count(adj_city) == 0) {
          size_t id = city_to_id.size();
          city_to_id[adj_city] = id;
        }
        adj[city_to_id[city]][city_to_id[adj_city]] = 1;
        adj[city_to_id[adj_city]][city_to_id[city]] = 1;
      }
    }

    const int INF = 1e9;
    weight[0] += INF;
    IndependentSet is(N, weight);
    REP(i, N) REP(j, N) if (adj[i][j]) is.add_edge(i, j);
    cout << is.solve() - INF << endl;
  }
  return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int>T(N);
  for (int i=0 ; i<N ; i++){
    T.at(i)=1;
  }
  vector<int>H(N);
  for(int i=0 ; i<N ; i++)
  cin >> H.at(i);
  for (int i=0 ; i<M ; i++){
    int A,B;
    cin >> A >> B;
    if(H.at(A-1)>H.at(B-1)){
      T.at(B-1)=0;
    }
    else if (H.at(A-1)==H.at(B-1)){
      T.at(A-1)=0;
      T.at(B-1)=0;
    }
    else{
      T.at(A-1)=0;
    }
  }
  cout << count(T.begin(),T.end(),1) << endl;
}

Measured memory_bytes: 4052
s = input()
sp = s[:2]
ss = s[2:]
m = ["{0:02d}".format(i) for i in range(1,13)]
def check(s):
    if s in m:
        return True

sp_c = check(sp)
ss_c = check(ss)

if sp_c and ss_c:
    print("AMBIGUOUS")
elif sp_c and not ss_c:
    print("MMYY")
elif ss_c and not sp_c:
    print("YYMM")
else:
    print("NA")

    

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <random>
#include <string>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  REP(i, t.length()) {
    if (t[i] != s[i]) {
      if (i > 0) {
        int rec1 = (int)s.rfind(s[i], i-1);
        int rec2 = (int)s.rfind(t[i], i-1);
        if ((rec1 >= 0 && rec1 < i) || (rec2 >= 0 && rec2 < i)) {
          cout << "No" << "\n";
          return 0;
        }
      }
      char temp = s[i];
      FOR(j, i, s.length()) {
        if (s[j] == temp) {
          s[j] = t[i];
        } else if (s[j] == t[i]) {
          s[j] = temp;
        }
      }
    }
  }
  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n,l,sum=0,ma=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l;
    sum+=l;
    ma=max(ma,l);
  }
  if(ma<sum-ma)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int r=stdIn.nextInt(),g=stdIn.nextInt(),b=stdIn.nextInt();
		System.out.print((r*100+g*10+b)%4==0?"YES":"NO");
	}
}

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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if ((i != 0 && i != H - 1) && (j != 0 && j != W - 1)) {
          cout << ".";
        } else {
          cout << "#";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        if(!(cin >> s))
            return 0;

        char c = 'd';
        for(int i=0; i<3; ++i){
            if(s[i*3] != 's' && s[i*3] == s[i*3+1] && s[i*3] == s[i*3+2])
                c = s[i*3];
            if(s[i] != 's' && s[i] == s[3+i] && s[i] == s[6+i])
                c = s[i];
        }
        if(s[0] != 's' && s[0] == s[4] && s[0] == s[8])
            c = s[0];
        if(s[2] != 's' && s[2] == s[4] && s[2] == s[6])
            c = s[2];
        cout << c << endl;
    }
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"


void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &x:v)cin>>x;
    map<int,int> vis;
    for(auto x:v)vis[x]++;
    int ans=0;
    for(auto x:v){
        int cnt=0;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                cnt+=vis[i];
                if(x/i!=i)cnt+=vis[x/i];
            }
        }

        ans+=cnt==1;
    }
    cout<<ans<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 32988
#include <iostream>

using namespace std;

int N, K;

int main(void) {

	cin >> N >> K;

	long long int num, num2;
	long long int ans;

	if (K % 2 == 1) {
		num = N / K;
		ans = (long long int)num*num*num;
	}
	else {
		num = N / K;
		ans = (long long int) num*num*num;
		if (N >= K / 2) {
			num2 = (long long int) (N - K / 2) / K + 1;
			ans += num2*num2*num2;
		}
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int K; cin >> K;
    deque<LLONG> luns{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    LLONG x;
    for (int i = 0; i < K; ++i)
    {
        x = luns.front(); luns.pop_front();
        LLONG lowest = x % 10;
        if (lowest != 0)
        {
            luns.push_back(x * 10 + lowest - 1);
        }
        luns.push_back(x * 10 + lowest);
        if (lowest != 9)
        {
            luns.push_back(x * 10 + lowest + 1);
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N; cin >> N; int hight = 0; int cnt = 0;
  for(int i = 0; i < N; i++){
    int H; cin >> H;
    if(hight <= H){cnt++;}
    hight = max(hight,H);}
  
  cout << cnt << endl;
  
  return 0;}

Measured memory_bytes: 256
N, u, v = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

isLeaf, dU, dV = [len(g) == 1 for g in G], [-1] * N, [-1] * N

for D, P in [(dU, u - 1), (dV, v - 1)]:
    S = [(P, 0)]
    while len(S) > 0:
        p, d = S.pop()
        D[p] = d
        for g in G[p]:
            if D[g] == -1:
                S.append((g, d + 1))

ans = 0
for i in range(N):
    if isLeaf[i] and dU[i] < dV[i]:
        ans = max(ans, dV[i] - 1)

print(ans)


Measured memory_bytes: 72172
fn main() {
    let (x, y, z) = read();
    let ans = solve(x, y, z);
    write(ans);
}

fn read() -> (i32, i32, i32) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let mut iter = l1.trim().split_whitespace();
    let x: i32 = iter.next().unwrap().parse().unwrap();
    let y: i32 = iter.next().unwrap().parse().unwrap();
    let z: i32 = iter.next().unwrap().parse().unwrap();

    (x, y, z)
}

fn write(ans: (i32, i32, i32)) {
    println!("{} {} {}", ans.0, ans.1, ans.2);
}

fn solve(x: i32, y: i32, z: i32) -> (i32, i32, i32) {
    (z, x, y)
}


Measured memory_bytes: 2072
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
   int a, b, c, d, sum = 0;
   cin >> a >> b >> c;
   for(int i = a;i <= b;i++){
       d = c % i;
       if(d == 0) sum += 1;
   }
    
    cout << sum << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int f[10001] = { 0 };
  int ret = 6;
  int x = 1, y = 1, z = 1;
  for(x = 1;x <= 100;x++) {
    for(y = x;y <= 100;y++) {
      for(z = y;z <= n;z++) {
        ret = x*x + y*y + z*z + x*y + y*z + z*x;
        if(ret > n) continue;
        if(x == y && y == z) { f[ret] += 1; }
        else if(x == y || y == z || z == x) { f[ret] += 3; }
        else f[ret] += 6;
      }
    }
  }
  for(int i = 1;i <= n;i++) {
    printf("%d\n", f[i]);
  }
  return 0;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    long long count = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            count += (b[i] - a[i]) / 2;
        } else {
            count -= a[i] - b[i];
        }
    }

    std::cout << (count >= 0 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define MAXN 100
using namespace std;

int main()
{
  int a,n,b;
  cin >> n>> a >> b;
  vector<int> v,vv,vvv;
  for(int i = 0;i < n;i++) {
    int t;
    cin >> t;
    if(t <= a) {
      v.push_back(t);
    } else if(t <= b) {
      vv.push_back(t);
    } else {
      vvv.push_back(t);
    }
  }

  int res = min(v.size(),min(vv.size(),vvv.size()));
  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);
int main(){
  int n, m, r;cin>>n>>m>>r;
  vector<vector<int>> dis(n, vector<int>(n, INF));
  vector<int> town(r);
  for(int i=0;i<r;i++)cin>>town[i];
  sort(town.begin(), town.end());
  for(int i=0;i<m;i++){
  	int a, b, c;cin>>a>>b>>c;
    a--;b--;
    dis[a][b]=dis[b][a]=c;
  }
  for(int i=0;i<n;i++)dis[i][i]=0;
  for(int k=0;k<n;k++){
  	for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
      	if(dis[i][k]==INF || dis[k][j]==INF)continue;
        dis[i][j]=min(dis[i][j], dis[i][k]+dis[k][j]);
      }
    }
  }
  ll ans=1e10;
  do{
    // for(int x: town)cout<<x<<" ";
    // cout<<endl;
  	ll sum=0;
    for(int i=0;i<r-1;i++){
    	sum += dis[town[i]-1][town[i+1]-1];
    }
    ans = min(ans, sum);
  }while(next_permutation(town.begin(), town.end()));
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
#include<cmath>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25

float logn(int n, int base) {
	return (log(n) / log(base));
}

int dfs(int n, int count) {
	int mn9 = INF;
	int mn6 = INF;
	int mn1 = INF;
	if (n == 0) {
		return count;
	}
	if (n >= 9)
		mn9 = dfs(n - pow(9, (int)logn(n, 9)), count + 1);
	if (n >= 6)
	 	mn6 = dfs(n - pow(6, (int)logn(n, 6)), count + 1);
	if (n < 6) {
		mn1 = n + count;
	}
	int ret = INF;
	ret = min(mn9, mn6);
	ret = min(mn1, ret);
	return ret;
}

int main()
{
	int n;
	int count = 0;
	cin >> n;
	cout << dfs(n, 0) << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 1;
int dp[N], h[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 2; i<= n; i++) {
        dp[i] = 1e9;
        for (int j = 1; j <= k; j++) {
            if (i - j >= 1) {
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024