akhauriyash/Code-Regression huggingface dataset:
const val P = 1000000007L

fun solveCase(): Long {
  val n = readLine()!!.toInt()
  val xs = readLine()!!.split(" ").map { it.toInt() }
  val xorArray = IntArray(n + 1)
  for (i in 1..n) {
    xorArray[i] = xorArray[i - 1] xor xs[i - 1]
  }
  val zeroCountArray = IntArray(n + 1)
  zeroCountArray[0] = 1
  for (i in 1..n) {
    zeroCountArray[i] = zeroCountArray[i - 1] + (if (xorArray[i] == 0) 1 else 0)
  }

  val indexLists = Array(1 shl 20, { mutableListOf<Int>() })
  for (i in 1..n) {
    if (xorArray[i] != 0) {
      indexLists[xorArray[i]].add(i)
    }
  }

  if (xorArray[n] != 0) {
    val x = xorArray[n]
    // println(indexLists[x])
    val xIndexArray = indexLists[x].toIntArray()
    if (xIndexArray.size == 1) return 1L

    val dp1 = LongArray(xIndexArray.size)
    val dp2 = LongArray(xIndexArray.size)
    dp1[0] = 1
    dp2[0] = 1
    for (i in 1 until dp1.size) {
      val zeroCountDiff = zeroCountArray[xIndexArray[i]] - zeroCountArray[xIndexArray[i - 1]]
      dp1[i] = dp2[i - 1] * zeroCountDiff  + dp1[i - 1]
      dp1[i] %= P
      dp2[i] = dp2[i - 1] + dp1[i]
      dp2[i] %= P
    }

    return dp1.last()
  }

//  println(xorArray.asList())
//  println(zeroCountArray.asList())
  var count = pow2(zeroCountArray.last() - 2)
  for (x in 1 until (1 shl 20)) {
    if (indexLists[x].isEmpty()) continue
//    println("x: $x")
//    println(indexLists[x])
    if (indexLists[x].size == 1) {
      count += 1
      count %= P
      // println("count: $count")
      continue
    }

    val xIndexArray = indexLists[x].toIntArray()
    val dp1 = LongArray(xIndexArray.size)
    val dp2 = LongArray(xIndexArray.size)
    dp1[0] = 1
    dp2[0] = 1
    for (i in 1 until dp1.size) {
      val zeroCountDiff = zeroCountArray[xIndexArray[i]] - zeroCountArray[xIndexArray[i - 1]]
      dp1[i] = dp2[i - 1] * zeroCountDiff  + dp1[i - 1]
      dp1[i] %= P
      dp2[i] = dp2[i - 1] + dp1[i]
      dp2[i] %= P
    }

    count += dp2.last()
    count %= P
    // println("count: $count")
  }
  return count
}

fun pow2(p: Int): Long {
  var ret = 1L
  repeat(p) {
    ret *= 2L
    ret %= P
  }
  return ret
}

fun main(args: Array<String>) {
  println(solveCase())
}


Measured memory_bytes: 173004
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  double R;
  cin>>R;
  cout<<setprecision(10);
  cout<<R*2*3.1415926535<<endl;
}



Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,d;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    while(cin>>n)
    {
        vector<ll> arr;
        vector<ll> a1;
        for(int i=0;i<n;i++)
        {
            ll x;
            cin>>x;
            arr.push_back(x);
            a1.push_back(x);
        }
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            ll x=a1[i];
            if(x==arr[n-1])
            {
                cout<<arr[n-2]<<endl;
            }
            else cout<<arr[n-1]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4964
def resolve():
    N, x = [int(i) for i in input().split()]
    A = sorted([int(i) for i in input().split()])
    sumA = 0
    cnt = 0
    for i in range(N):
        if A[i] <= (x - sumA):
            sumA += A[i]
            cnt += 1
        else:
            break
    else:
        if sumA != x:
            cnt -= 1
    print(cnt)


resolve()


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))
#define nl "\n"

using namespace std;
typedef long long ll;

int main() {
    int n, a, i;
    deque<int> d;

    cin >> n;

    cin >> a;
    d.push_back(a);

    for (i = 1; i < n; ++i) {
        cin >> a;
        if (i & 1) d.push_back(a);
            else d.push_front(a);
    }

    if (n % 2 == 0) {
        reverse(d.begin(), d.end());
    }

    deque<int>::iterator it = d.begin();
    cout << *it++;
    while (it != d.end()) cout << " " << *it++;
    cout << nl;

    return 0;
}


Measured memory_bytes: 2944
from collections import deque

X,Y,A,B,C = map(int,input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

s = p[:X] + q[:Y] + r
s.sort(reverse=True)
s = s[:X+Y]

print(sum(s))

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int diff = 0;
	string S; cin >> S;
	for(int i=1; i<SZ(S); i++) {
		if(S[i-1] != S[i]) diff++;
	}
	cout << diff << endl;
	return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    int sum=0,ev=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
        if(i%2==1)ev+=A[i];
    }
    int now=sum-ev*2;
    cout<<now<<' ';
    for(int i=0;i<N-1;i++){
        now=A[i]*2-now;
        cout<<now<<' ';
    }
    return 0;
}

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

int main(){
  int n;cin>>n;
  n=n%10;
  if(n==3)cout<<"bon";
  else if(n==0||n==1||n==6||n==8)cout<<"pon";
  else cout<<"hon";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, M;
  long sum = 0;
  cin >> N >> M;
  vector<int> A(M);

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if(N < sum){
    cout << "-1" << endl;
  }else{
    cout << N - sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  int x;
  cin >> x;
  int n = x/100;
  int dif = x - n * 100;
  if(dif<= 5 * n){
    cout << 1 <<endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        double res = 1 - (double)(a/2) / (double) a;
        System.out.println(res);
        sc.close();
    }
}

class io{
    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)

def main():
    N,M,K = [int(i) for i in input().strip().split()]
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    pre_A = [0] * (N + 1)
    pre_B = [0] * (M + 1)


    for i in range(1,N+1):
        pre_A[i] = pre_A[i-1] + A[i-1]
        if pre_A[i] > K:
            idx_a = i-1
            break
    else:
        idx_a = N

    for i in range(1,M+1):
        pre_B[i]= pre_B[i-1] + B[i-1]
        if pre_B[i] > K:
            idx_b = i-1
            break
    else:
        idx_b = M

    ans = max(idx_a,idx_b)

    j = idx_b
    for i in range(idx_a + 1):
        while pre_B[j] > K - pre_A[i]:
            j -= 1
        ans = max(ans,i+j)

    return ans

if __name__ == "__main__":
    print(main())

Measured memory_bytes: 111944
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v,pick[200000];
map<string, vector<LL>>ma;
multiset<LL>st[3];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL staring(int n, int k) {
	if (n < k)return 0;
	if (n == k)return 1;
	if (k == 1)return 1;
	if (dp[n][k] != -1)return dp[n][k];
	LL rev = 0;
	rev = (staring(n - 1, k - 1) + k * staring(n - 1, k)+MOD)%MOD;
	return dp[n][k] = rev;
}

int main() {
	cin >> n >> m;
	rep(i, n+1)rep(j, m+1)dp[i][j] = -1;
	cout << staring(n,m)<< endl;
	return 0;
}



Measured memory_bytes: 24408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = array[0];
            var R = array[1];

            if (N >= 10)
            {
                Console.WriteLine(R);
            }
            else
            {
                Console.WriteLine(R + (100 * (10 - N)));
            }
        }
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"

using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

int cnt[266];

int main () {
    string s;
    cin >> s;
    int n = s.size();

    long long res = 1LL *  n * (n - 1) / 2 + 1;
    forn(i, n){
        cnt[s[i]]++;
    }
    fore(i, 'a', 'z') {
        if (cnt[i] > 1) res -= 1LL * cnt[i] * (cnt[i] - 1) / 2;
    }
    //cout << sum << "\n";
    cout << res;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define ll long long
#define mst(a) memset(a, 0, sizeof a)

const int mod = 1e9+7;
const int maxn = 1e5+50;
const int inf = 1e9;

char s[maxn];

int main()
{
  //  freopen("in", "r", stdin);
    scanf("%s", s);
    int n = strlen(s);
    int ans = inf;
    for (int i = 1; i < n; ++i)
        if (s[i] != s[i-1])
            ans = min(ans, max(i, n-i));
    if (ans == inf) ans = n;
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int D,G;
  cin >> D >> G;
  vector<vector<int>>s(D,vector<int>(2));
  for(int i=0;i<D;i++){
    for(int j=0;j<2;j++){
      cin >> s.at(i).at(j);
    }
  }
  int ans=1e9;
  for (int tmp =0; tmp < (1 << 10); tmp++ ){
    bitset<10>a(tmp);
    
    int x=0;
    int num=0;
    int rest_max =-1;
    for(int i=0;i<D;i++){
      if(a.test(i)){
        x +=100*(i+1)*s.at(i).at(0)+s.at(i).at(1);
        num += s.at(i).at(0);
      }
      else{
        rest_max =i;
      }
    }
    if(x < G){
      int x1 = 100*(rest_max + 1);
      int need = (G - x + x1 -1)/x1;
      if(need >= s.at(rest_max).at(0)){
        continue;
      }
      num += need;
    }
    
    ans = min(ans, num);
  }
  cout << ans << endl;
}

        
      
      


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

int main()
{
    ll a, b;
    cin >> a >> b;
    for (int i = 1; i <= b; i++) {
        if ((a * i) % b == 0) {
            cout << a * i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

class Program
{
    static int n;
    static long[] a;

    public static void Main(string[] args)
    {
        n = Input.NextInt();
        a = Input.LineLong();

        long minmove = Calc(a);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = -a[i];
        }
        minmove = Math.Min(minmove, Calc(a));

        Console.WriteLine(minmove);
    }

    private static long Calc(long[] a)
    {
        checked
        {
            long curr = 0;
            long move = 0;
            for (long i = 0; i < a.Length; i++)
            {
                long dif = 0;
                switch (i % 2)
                {
                    case 0:
                        {
                            var newc = curr + a[i];
                            dif = newc <= 0 ? 1 - newc : 0;
                        }
                        break;
                    case 1:
                        {
                            var newc = curr + a[i];
                            dif = newc >= 0 ? -1 - newc : 0;
                        }
                        break;
                }
                curr += a[i] + dif;
                move += Math.Abs(dif);
            }

            return move;
        }
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 31324
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
  ll N, P;
  cin >> N >> P;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a%2==1) flag = false;
  }
  if (flag&&P==1) cout << 0 << endl;
  if (flag&&P==0) cout << (long long)pow(2, N) << endl;
  if (!flag) cout << (long long)pow(2, N-1) << endl;
}

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

#define ll long long 

using namespace std;

int n,r;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    vector <int> a(n+1);
    for (int i=1; i<=n; i++){
        cin>>a[i];
    }
    int o=0;
    for (int i=1; i<=n; i++){
        if(a[i]==1) {
            o=1;
            break;
        }
    }
    if (!o) return cout<<-1,0;
    else{
        int k=1;
        for (int i=1; i<=n; i++){
            if(a[i]!=k) r++;
            else{
                k+=1;
                continue;
            }
        }
        cout<<r;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
int a, b, c, K;
cin >> a >> b >> c >> K;
long long z = max({a, b, c})*pow(2, K);
cout << a + b + c - max({a, b, c}) + z << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18 ;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	ll f=0,n,i,j;
	cin>>n;
	for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                f=1;
                break;
            }
        }
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

std::vector<int> a[100000], b[100000];
int n, m, k, x, y, tmp, cnt, ans[100001], lbl[100001];
bool done[100001];

void solve() {
	std::cin >> n >> m >> k;
    for (int i=0; i<m; ++i) {
		std::cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	cnt = 0;
	for (int i=0; i<100001; ++i) {
		done[i] = 0;
		ans[i] = 0;
	}
	std::queue<int> idx;
    for (int i=1; i<n+1; ++i) {
		std::vector<int> group;
		if (done[i] == true)
            continue;
		done[i] = true;
		group.push_back(i);
		for (int nx : a[i]) {
			idx.push(nx);
			done[nx] = true;
			group.push_back(nx);
		}
		while (!idx.empty()) {
			tmp = idx.front();
			idx.pop();
			for (int nx : a[tmp]) {
				if (done[nx] == true)
                    continue;
				idx.push(nx);
				done[nx] = true;
				group.push_back(nx);
			}
		}
		for (int s : group) {
			ans[s] = group.size();
			lbl[s] = cnt;
		}
		cnt++;
	}

    for (int i=0; i<k; ++i) {
		std::cin >> x >> y;
		if (lbl[x] == lbl[y]) {
			b[x].push_back(y);
			b[y].push_back(x);
		}
	}

    for (int i=1; i<n+1; ++i)
		std::cout << ans[i] - a[i].size() - b[i].size() - 1 << " ";
    std::cout << std::endl;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


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

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

    int min_diff = 999;
    for (int i = 0; i < S.size() - 2; i++) {
        int X = stoi(S.substr(i, 3));
        int diff = abs(X - 753);
        min_diff = min(min_diff, diff);
    }
    cout << min_diff << endl;
}


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

using namespace std;

typedef long long ll;

int main(){
  int n, m; cin >> n >> m;
  ll a = 1900*m + 100*(n-m);
  ll ans = a * pow(2, m);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N;cin>>N;
	for(ll h = 1; h <= 3500; h++) {
		for(ll n = 1; n <= 3500; n++) {
			if ((4 * h * n - N * n - N * h) > 0 && (N * h * n) %(4 * h * n - N * n - N * h) == 0){
				cout << h << ' ' << n << ' ' << (N * h * n)  / (4 * h * n - N * n - N * h) << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void) {
  int n;
  char s[50];
  int c=0 ,i=0;
  
  scanf("%d",&n);
  scanf("%s",s);
  
  while(i < n - 2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
      c ++;
    i ++;
  } 
  printf("%d",c);
 
  return 0;
}

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

namespace ABC095_C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = double.Parse(input[0]);
            var B = double.Parse(input[1]);
            var AB = double.Parse(input[2]);
            var X = double.Parse(input[3]);
            var Y = double.Parse(input[4]);

            var commonCount = Math.Min(X, Y); //XとYの両方必要な分量
            var remainingCount = Math.Abs(X - Y);
            double ans = 0;
            if (AB <= (A + B) / 2)
            {
                ans += AB * commonCount*2;
                if (X > Y)
                {
                    if (AB*2 > A)
                    {
                        ans += A * remainingCount;
                    }
                    else
                    {
                        ans += AB * remainingCount*2;
                    }
                }
                else if (Y > X)
                {
                    if (AB*2 > B)
                    {
                        ans += B * remainingCount;
                    }
                    else
                    {
                        ans += AB * remainingCount*2;
                    }
                }
            }
            else
            {
                ans += A * X + B * Y;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
        int[] a=new int[n];
int c=0;
		for(int i=0;i<n;i++)
          a[i]=sc.nextInt();
        	                Arrays.sort(a);
		for(int i=0;i<n;i++)
        {
          	for(int j=i+1;j<n;j++)
            {
              	for(int h=j+1;h<n;h++)
                {
                  	if(a[i]!=a[j] && a[j]!=a[h] )
                    	{
                      		  if(a[i]+a[j]>a[h])
                          			c++;
                    	}
                }
            }
        }
System.out.println(c);
	}
}

Measured memory_bytes: 36356
#include <stdio.h>
int main()
{
          int x,a;
          scanf("%d",&x);
          a=x%10;
          if (a==2||a==4||a==5||a==7||a==9)
                    printf("hon\n");
          else if(a==0||a==1||a==6||a==8)
                    printf("pon\n");
          else
                    printf("bon\n");
          return 0;
}


Measured memory_bytes: 1616
# D - Friend Suggestions

from queue import Queue

N, M, K = map(int, input().split())

friends =  [(i, []) for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    friends[a][1].append(b)
    friends[b][1].append(a)

blocks = [(i, []) for i in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    blocks[c][1].append(d)
    blocks[d][1].append(c)

Q = Queue()
visited = [False] * N
group = [0] * N
for i in range(N):
    if visited[i]:
        continue
    Q.put(friends[i])
    visited[i] = True
    while not Q.empty():
        q = Q.get()
        group[q[0]] = i
        for j in q[1]:
            if not visited[j]:
                visited[j] = True
                Q.put(friends[j])

cnt = {}
for num in group:
    if num in cnt:
        cnt[num] += 1
    else:
        cnt[num] = 1

ans = [0] * N
for i in range(N):
    ans[i] = cnt[group[i]] - len(friends[i][1]) - 1
    for block in blocks[i][1]:
        if group[i] == group[block]:
            ans[i] -= 1

print(*ans)


Measured memory_bytes: 68112
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000005
#define MOD 1000000007 
#define N 300005
#define M 1000000
#define LOG 17
#define KOK 300
#define EPS 0.0000001
using namespace std;

int n,m;
int cnt[N],vis[N],out[N],u[N];
ii e[N];
vector<int> v[N];

void dfs2(int node,int ata) {

	vis[node]=1;

	for(int i:v[node]) {

		int go=e[i].st^e[i].nd^node;

		if(go==ata || vis[go]) continue ;

		dfs2(go,node);

		if(cnt[go]&1) swap(e[i].st,e[i].nd);

		cnt[node]+=cnt[go];

	}

}

void dfs(int node,int ata) {

	vis[node]=1;

	for(int i:v[node]) {

		int go=e[i].st^e[i].nd^node;

		if(go==ata || vis[go]) continue ;

		u[i]=1;

		dfs(go,node);

		if(out[go]&1) {

			e[i]={go,node};

		}
		else {

			e[i]={node,go};
			out[node]++;

		}

	}

}

int main() {

	scanf("%d %d",&n,&m);

	for(int i=1;i<=m;i++) {

		int x,y;

		scanf("%d %d",&x,&y);

		e[i]={x,y};

		v[x].pb(i);
		v[y].pb(i);

	}

	dfs(1,0);

	if((out[1]&1)!=((m-(n-1))&1)) {printf("-1");return 0;}

	for(int i=1;i<=m;i++) {

		if(u[i]) continue ;

		cnt[e[i].st]++;

	}

	memset(vis,0,sizeof(vis));

	dfs2(1,0);

	for(int i=1;i<=m;i++) printf("%d %d\n",e[i].st,e[i].nd);

}	

Measured memory_bytes: 25600
#include<bits/stdc++.h>
using namespace std;
const int lim = 1e6;
int spf[lim+2];
void sieve()
{
    spf[1]=1;
    spf[0]=1;
    for(int i=2; i<=lim; i++)
        spf[i]=i;
    for(int i=2; i*i<=lim; i++){
        if(spf[i]==i){
            for(int j=i*i; j<=lim; j+=i){
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }
}
int main()
{
    sieve();
    int n;
    cin>>n;
    long long res=0;
    for(int i=1; i<n; i++){
        int rem = n-i, temp=rem;
        if(rem==1){
            res+=1;
            continue;
        }
        //Factorize rem
        vector<pair<int, int>> facto;
        int currPrime = -1, count=0;
        while(spf[temp]!=1){
            if(spf[temp]!=currPrime && currPrime!=-1){
                facto.push_back({currPrime, count});
                currPrime = spf[temp];
                count=1;
            }else{
                currPrime = spf[temp];
                count++;
            }
            temp/=spf[temp];
        }
        facto.push_back({currPrime, count});
        temp = 1;
        for(int j=0; j<facto.size(); j++)
            temp*=(facto[j].second+1);
        res+=temp;
    }
    cout<<res;
}


Measured memory_bytes: 7532
/// I am Ryuk..........


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <iomanip>

#define ll long long
#define MAX 300005
#define pp pair<int,int>
#define pb push_back
#define mod 1000000007

using namespace std;

double dis(double x1, double y1, double x2, double y2) {
    return sqrt((abs(x2 - x1) * abs(x2 - x1)) + (abs(y1 - y2) * abs(y1 - y2)));
}

double parpendicular_dis(double x, double y, int m, double c) {
    double m1 = -1.0 / m;
    double new_x = (y - (m1 * x) - c) / 2.0 * m;
    double new_y = m * new_x + c;
    return dis(x, y, new_x, new_y);

}


ll maxx(ll a, ll b) {
    return (a > b) ? a : b;
}

ll mini(ll a, ll b) {
    return (a < b) ? a : b;
}

double reac(double XX, double YY) {
    if (XX < YY) {
        double temp = XX;
        XX = YY;
        YY = temp;
    }


    ll x1 = 0;
    ll y1 = 0;
    ll x2 = XX;
    ll y2 = YY;
    ll dif_X = abs(x1 - x2);
    ll dif_y = abs(y1 - y2);
    ll m = 1;
    double c;
    double xx, yy;
    if (dif_X >= dif_y) {
        double xxx = y2 - (y1 - (m * x1));
        double diff = abs(xxx - x2) / 2.0;
        xx = (double) x1 + diff;
        yy = y1;
    } else {
        assert(0);
    }
    c = yy - m * xx;
    double d1 = parpendicular_dis(x1, y1, m, c);
    double d2 = parpendicular_dis(x2, y2, m, c);
    if (d1 != d2) {
        assert(0);
    }
    return d1;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.second / a.first) < (b.second / b.first);
}


int main() {
    int n;
    cin >> n;
    ll arr[n];
    for (int i = 0; i < n; i++)cin >> arr[i];

    ll dp[n][n][2];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j][1] = dp[i][j][0] = 0;
        }
    }

    for (int l = 1; l <= n; l++) {
        for (int i = 0; i < n; i++) {
            int j = i + l - 1;
            if (j >= n) continue;
            if (i == j) {
                dp[i][j][0] = arr[i];
                dp[i][j][1] = -arr[i];
                continue;
            }
            if (i > j) {
                dp[i][j][0] = 0;
                dp[i][j][1] = 0;
                continue;
            }
            dp[i][j][0] = maxx(arr[i] + dp[i + 1][j][1], arr[j] + dp[i][j - 1][1]);
            dp[i][j][1] = mini(-arr[i] + dp[i + 1][j][0], -arr[j] + dp[i][j - 1][0]);
        }
    }
    cout << (dp[0][n - 1][0]) << endl;

}

/*
    1
    14
    0 0
    10 1
    10 2
    10 3
    10 4
    10 5
    10 6
    10 7
    10 8
    10 9
    10 11
    10 12
    10 13
    10 14
    */





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

const int INF = 1001001001;
vector<vector<int>> cost;
vector<int> mincost;
vector<bool> used;
int V;

int prim(){
    mincost.assign(V,INF);
    used.assign(V,0);
    mincost[0] = 0;
    int res = 0;
    while(true){
        int v = -1;
        for(int u = 0; u < V; ++u){
            if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }
        if(v == -1) break;//completed
        used[v] = 1;
        res += mincost[v];
        for(int u = 0; u < V; ++u){
            if(cost[v][u] != -1)mincost[u] = min(mincost[u], cost[v][u]);//確定した頂点から行ける頂点について、最小コストを更新
        }
    }
    return res;
}


int main(){
    cin >> V;
    cost.assign(V,vector<int>(V));
    rep(i,V)rep(j,V) cin >> cost[i][j];
    int ans = prim();
    cout << ans << endl;
}



Measured memory_bytes: 3184
#include <stdio.h>
int main(){
int n,ans=0,cnt;
scanf("%d",&n);
for(int i=1;i<=n;i+=2){
cnt=0;
for(int j=1;j<=i;j++)if(i%j==0)cnt++;
if(cnt==8)ans++;
}
printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int sum = 0;
  FOR(i,0,4) {
    int in;
    cin >> in;
    sum += in;
  }
  cout << sum / 60 << endl;
  cout << sum % 60 << endl;
  return 0;
}

Measured memory_bytes: 3096
import sys
import collections
sys.setrecursionlimit(10 ** 8)
INF = 10 ** 7

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W, N = ZZ()
    field = [input() for _ in range(H)]
    D = [(1, 0), (-1, 0), (0, 1), (0, -1)]

    def bfs(start, goal):
        dist = [[INF] * W for _ in range(H)]
        deq = collections.deque()
        sx, sy = start
        dist[sx][sy] = 0
        deq.append([sx, sy])

        while deq:
            x, y = deq.popleft()
            for dx, dy in D:
                nx, ny = x+dx, y+dy
                if 0 <= nx < H and 0 <= ny < W and field[nx][ny] != 'X' and dist[nx][ny] == INF:
                    dist[nx][ny] = dist[x][y] + 1
                    deq.append([nx, ny])
        return dist[goal[0]][goal[1]]

    factory = [[] for _ in range(N+1)]
    for i in range(H):
        for j in range(W):
            if field[i][j] == 'S': factory[0] = [i, j]
            elif field[i][j] in {'1', '2', '3', '4', '5', '6', '7', '8', '9'}:
                factory[int(field[i][j])] = [i, j]
    ans = 0
    for i in range(N): ans += bfs(factory[i], factory[i+1])
    print(ans)

    return

if __name__ == '__main__':
    main()



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

const int N = 105;
int a[N];

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

    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);

    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            for(int k = j + 1; k < n; k++)
            {
                if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                {
                    if(a[i] + a[j] > a[k])
                    {
                        cnt++;
                    }
                }
            }
        }
    }
    cout << cnt << '\n';


    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll x;
int main(){FAST;
cin>>x;
ll sum = 0;
for(ll i=1;i<=x;++i){
  if(i%3 == 0 or i%5 == 0)continue;
  sum+=i;
}
cout<<sum;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 3652
k,s = map(int, input().split())

x=0
y=0
z=0

count=0

for i in range(0,k+1):
    x=i
    for j in range(0,k+1):
        y=j
        if x+y>s:
            break
        if s-(x+y)<=k:
            count+=1
            #print(x,y)
        

print(count)

Measured memory_bytes: 3064
import java.io.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            String line = scanner.next();
            int zIndex = line.length();
            String letter = line.substring(zIndex-1, zIndex);
            while (!letter.equals("Z") && zIndex > 0) {
                zIndex--;
                letter = line.substring(zIndex-1, zIndex);
            }
            letter = line.substring(0, 1);
            int aIndex = 0;
            while (!letter.equals("A") && aIndex < line.length()) {
                aIndex++;
                letter = line.substring(aIndex, aIndex+1);
            }
            if (aIndex < zIndex) {
                System.out.println(zIndex - aIndex);
            } else {
                System.out.println("0");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

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

int main(){
    int N, cnt;
    cin >> N;
    vector<int> a(N), index(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        index[i] = i + 1;
    }
    cnt = 0;
    for(int i = 0; i < N; i++){
        if(index[i] == a[a[i]-1]) cnt++;
    }
    cout << cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
from itertools import product
n, m = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
cnt = 0
for pr in product([0, 1], repeat=n):
    pr = list(pr)
    for i, a in enumerate(ks):
        k = a[0]
        s = a[1:]

        c = 0
        for j in range(k):
            c += pr[s[j]-1]
        if c % 2 == p[i]:
            continue
        else:
            break
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
N = int(input())
A = [int(input()) for i in range(N)]

s = 0
L = [False]*44
for a in A:
    s ^= a
    c = 0
    while a&1==0:
        c += 1
        a >>= 1
    L[c] = True
if s==0:
    print(0)
    exit()
ss = "0" + bin(s)[2:]
ans = 0
for i in range(len(ss)-1):
    if ss[-1-i] != ss[-2-i]:
        if L[i]:
            ans += 1
        else:
            print(-1)
            exit()
print(ans)


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = 0, y = 0;
	y += a + b + c + d;
	while (y >= 60) {
		y -= 60;
		x++;
	}
	cout << x << endl << y << endl;
}

Measured memory_bytes: 3096
#![allow(unused_mut, non_snake_case, unused_imports)]

use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::swap;
use std::collections::{HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//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")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:https://beta.atcoder.jp/contests/abc111/tasks/abc111_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main() {
    input!(n:chars);
    let n:Vec<char> = n;
    let ans = n.into_iter().map(|c| if c=='1'{'9'} else {'1'}).collect::<String>();
    println!("{}",ans);
}

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

int main(){
	int a,b,s=0;
	cin>>a>>b;
	int A[a];
	for(int i=0;i<a;i++){
		cin>>A[i];
	}
	sort(A,A+a);
	for(int i=a-1;i>=a-b;i--){
		s=s+A[i];
	}
	cout<<s;
	return 0;
}

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

int main(){
   int H,N;
   cin>>H>>N;
   int sum_N=0;
   
   for(int i=0;i<N;i++){
      int a;
      cin>>a;
      sum_N+=a;
   }
  
   if(sum_N>=H){
   cout<<"Yes"<<endl;
   }
  
   if(sum_N<H){
   cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include<stdio.h>
int ic(const void *_a, const void *_b){int a = *(int *)_a;int b = *(int *)_b;if(a<b){return -1;}else if(a>b){return 1;}else{return 0;}}
void main(){int V,d,count;while(scanf("%d%d",&V,&d)!=EOF){int i,fib[V],j;count=0;fib[0]=2,fib[1]=3;for(i=2;i<V;i++)fib[i]=((j = fib[i-1]+fib[i-2])>1001)?(j-1001):j;qsort(fib,V,sizeof(int),ic);for(i=1; i<V; i++)if((fib[i] - fib[i-1]) >= d)count++;printf("%d\n",++count);}}

Measured memory_bytes: 0
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        index = bisect.bisect_left(L, L[i] + L[j])
        n = index - j - 1
        ans += n

print(ans)


Measured memory_bytes: 3188
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(1,n+1):
  if f>1:
    print('NO')
    break
  if i!=a[i-1]:
    tmp=a[a[i-1]-1]
    a[a[i-1]-1]=a[i-1]
    a[i-1]=tmp
    f+=1
    
else:
  print('YES')

  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define pc(c) putchar_unlocked(c)
typedef long long ll;

char arr[11];
int n;

// index 0-based
// t 今まで登場した種類数
void dfs(int index, int t)
{
  if (index == n)
  {
    cout << arr << endl;
    return;
  }

  rep(i, t)
  {
    arr[index] = 'a' + i;
    dfs(1 + index, t);
  }
  // new!!初登場
  arr[index] = 'a' + t;
  dfs(++index, ++t);
}

int main()
{
  cin >> n;
  arr[n] = '\0';
  dfs(0, 0);
}


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

int main() {
    int r, s, p;
    cin >> r >> s >> p;
    map<int, int> mp;
    rep(i, p) {
        int x, y;
        cin >> y >> x;
        if (x > s) x = abs(x-s*2)+1;
        mp[s-x+1+r-y+1]++;
    }
    ll ans = 0;
    for (auto t : mp) {
        if (t.second > 1) mp[t.first+1] += t.second-1;
        ans = t.first;
    }
    cout << ans << endl;
}



Measured memory_bytes: 26536
#include <iostream>

using namespace std;

int main()
{
    string c;
    
    cin >> c;
    
    if (c == "a" || c == "e" || c == "i" || c == "o" || c == "u")
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a,b;

signed main() {
    cin >> a >> b;
    cout << (a*b)/__gcd(a,b) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    
    long sum = 0;
    long cnt = 0;
    for(int i = 0; i < n; i++){
        if(s[n-i-1] == 'B'){
            cnt++;
            sum += i;
        }
    }
    cout << sum - (cnt*(cnt-1))/2 << endl;
}

Measured memory_bytes: 640