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

//最大公約数
long long GCD(long long a, long long b)
{
   if (a%b == 0) {
       return(b);
   }
   else{
       return(GCD(b, a%b));
   }
}

//最小公倍数
long long LCM(long long a, long long b){
   return a * b / GCD(a, b);
}


int main() {
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  A--;
  long long x = A-((A/C)+(A/D)-(A/LCM(C,D)));
  long long y = B-((B/C)+(B/D)-(B/LCM(C,D)));
  cout << y-x << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    ll count = 0;
    cin >> S;
    rep(i, 1LL << (S.size() - 1LL)) {
        ll temp = 0;
        rep(j, S.size()) {
            temp = temp * 10 + S[j] - '0';
            if((i >> j) & 1LL) {
                count += temp;
                temp = 0;
            }
        }
        count += temp;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
  	cin >> N;
  	int height[N];
    int ans[N];
	for(int i = 0; i < N; i++){
    	cin >> height[i];
  }
  ans[0] = 0;
 	ans[1] = abs(height[1]-height[0]);
  for(int i = 2; i < N; i++){
    ans[i] = min(ans[i-1] + abs(height[i] - height[i-1]), ans[i-2] + abs(height[i] - height[i-2]));
  }
  cout << ans[N-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;
 
ll MOD = 1000000007;
 
int main()
{
    string t, s;
    cin >> s >> t;
  
  	ll tmp=0;
  	ll ans = t.size();
    
  	for(ll i=0;i <= s.size()-t.size(); i++){
      tmp =0;
      for(ll j=0; j<t.size(); j++){
        if(s[i+j]!=t[j])
          tmp++;
      }
      
      ans = min(tmp, ans);
    }
  	
  	cout << ans << endl;
  
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;


int main(){

    int n;
    cin >> n;
    vector<int> p(ARRAY_MAX);
    for(int i = 1;i <= n;i++){
        int tmp;
        cin >> tmp;
        p[tmp] = i;

    }

    vector<int> a(ARRAY_MAX),b(ARRAY_MAX);
    for(int i = 1;i <= n;i++){
        a[i] = 30000*i;
        b[i] = 30000*(n-i) + p[i];
    }

    for(int i = 1;i <= n;i++){
        if(i == 1){
            cout << a[i];
        }else{
            cout << " " <<  a[i];
        }
    }
    cout << endl;

    for(int i = 1;i <= n;i++){
        if(i == 1){
            cout << b[i];
        }else{
            cout << " " <<  b[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<int,int>> vpii;

bool a[505][505];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int N;
	cin >> N;
	char c;
	bool any = false;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			cin >> c;
			a[i][j] = (c == '#');
			any |= a[i][j];
		}
	}
	if(!any) {
		cout << -1 << endl;
		return 0;
	}
	int init = 0;
	for(int j = 0; j < N; j++) {
		bool all = true;
		for(int i = 0; i < N; i++) {
			all &= a[i][j];
		}
		init += !all;
	}
	int best_part = N*N;
	int best_i = 0;
	for(int i = 0; i < N; i++) {
		bool col_i = false;
		for(int j = 0; j < N; j++) {
			col_i |= a[j][i];
		}
		int part = (!col_i);
		for(int j = 0; j < N; j++) {
			part += !a[i][j];
		}
		if(part < best_part) {
			best_part = part;
			best_i = i;
		}
	}
	cout << init + best_part << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int n, m, d[N], id[N], rk[N], dp[N], r;
vector<int> G[N];
int main() {
	cin >> n >> m;
	while (m--) {
		int x, y;
		scanf("%d %d", &x, &y);
		G[x].push_back(y);
	//	G[y].push_back(x);
		d[y]++;
	}
	queue<int> Q;
	for (int i = 1; i <= n; ++i)
		if (d[i] == 0) Q.push(i);
	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();
		rk[x] = ++r;
		for (int i: G[x]) {
			d[i]--;
			if (d[i] == 0)
				Q.push(i);
		}
	}
	for (int i = 1; i <= n; ++i) id[i] = i;
	sort(id + 1, id + 1 + n, [&](int i, int j) {
		return rk[i] < rk[j];
	});
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, dp[i]);
		for (int j: G[id[i]]) {
			dp[rk[j]] = max(dp[rk[j]], dp[i] + 1);
		}
	}
	cout << ans;
}

Measured memory_bytes: 21760
def dot(c1, c2):
    return c1.real * c2.real + c1.imag * c2.imag

def cross(c1, c2):
    return c1.real * c2.imag - c1.imag * c2.real

def string_to_complex(s):
    x, y = map(int, s.split())
    return x + y * 1j

def contains(polygon, point):
    flag = False
    for v1, v2 in zip(polygon[0:], polygon[1:]):
        a = v1 - point
        b = v2 - point
        if a.imag > b.imag:
            a, b = b, a
        cross_ab = cross(a, b)
        if cross_ab == 0 and dot(a, b) <= 0:
            return 1
        if a.imag <= 0 and b.imag > 0 and cross_ab > 0:
            flag = not flag
    if flag:
        return 2
    else:
        return 0

import sys

file_input = sys.stdin

n = int(file_input.readline())

polygon = [string_to_complex(file_input.readline()) for i in range(n)]
polygon.append(polygon[0])

q = int(file_input.readline())

for line in file_input:
    t = string_to_complex(line)
    print(contains(polygon, t))

Measured memory_bytes: 7936
#include<iostream>
using namespace std;
int main() {
	int a, b, k, number[100000];
	cin >> a >> b >> k;
	for (int i = 0;i < b;i++) {
		number[i] = i+1 ;
		if (number[i] >= a&&number[i] < a + k) {
			cout << number[i]<<" ";
		}
		else if (number[i] <= b&&number[i] > b - k) {
			if (number[i] >= a) {
				cout << number[i] << " ";
			}
		}
	}
}
			

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

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

  rep(i,5) {
    if(x[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3592
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb puch_back
#define mk make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N, M;

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

  if (N == 1 && M == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (N == 1) {
    cout << M-2 << endl;
    return 0;
  }

  if (M == 1) {
    cout << N-2 << endl;
    return 0;
  }

  cout << (N-2)*(M-2) << endl;
}


Measured memory_bytes: 256
n,k,*L=map(int,open(0).read().split())
X=[];Y=[]
for x,y in sorted((x,y) for x,y in zip(*[iter(L)]*2)):
	X.append(x)
	Y.append(y)
ans=float("inf")
for i in range(n-k+1):
	for j in range(i+k-1,n):
		w=X[j]-X[i]
		l=sorted(Y[i:j+1])
		h=min(My-my for my,My in zip(l,l[k-1:]))
		ans=min(ans,w*h)
print(ans)

Measured memory_bytes: 3064
import sys, math, bisect



def solve(W_N, V_N, bombs, H, W):

    max_x = 1
    xs = []
    for i in range(W):
        if(W_N[i] > max_x):
            max_x = W_N[i]
            xs = [i]
        elif(W_N[i] == max_x):
            xs.append(i)
    max_y = 1
    ys = []
    for j in range(H):
        if(V_N[j] > max_y):
            max_y = V_N[j]
            ys = [j]
        elif(V_N[j] == max_y):
            ys.append(j)

    value = max_x + max_y

    for j in ys:

        bombs[j].sort()
        for i in xs:
            index = bisect.bisect_left(bombs[j], i)
            if(index == V_N[j] or i != bombs[j][index]):
                return value
            
    return value-1



if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W, N_bombs= map(int, input().strip().split() )


    V_N = [0] * H
    W_N = [0] * W
    bombs = [ [] for _ in range(H) ]


    for i in range(N_bombs):
        y, x = map(int, input().strip().split() )
        """
        W_N_bomb[x-1][0] += 1
        V_N_bomb[y-1][0] += 1
        """
        V_N[y-1] += 1
        W_N[x-1] += 1
        bombs[y-1].append(x-1)




    print( solve(W_N, V_N, bombs, H, W) )


Measured memory_bytes: 77860
#include <iostream>
using namespace std;
int main() {
    int n, flag = 1;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int cur; cin >> cur;
        if (!(cur & 1) && (cur % 3 && cur % 5)) {
            flag = 0; break;
        }
    }
    if (flag) puts("APPROVED");
    else puts("DENIED");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(a,b,c) for(int c=a;c<=b;c++)
using namespace std;
int n,k;
int ans;
void input();
void output();
int main(){
    ans=1;
    input();
    rep(1,n,i){
        if(ans>k) ans+=k;
        else ans*=2;
    }
    output();
}
void input(){
    cin>>n>>k;
}
void output(){
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 998244353
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n,m;cin >> n >> m;
	bool b[n + 1] = {};
	int cnt[n + 1] = {};
	b[1] = 1;
	fu(i,1,n)cnt[i] = 1;
	while(m--){
		int x,y;
		cin >> x >> y;
		if(cnt[x] == 1){
			if(b[x] == 1){
				b[y] = 1;	
				b[x] = 0;
			}
			--cnt[x];
			++cnt[y];
		}
		else{
			if(b[x] == 1){
				b[y] = 1;
			}
			--cnt[x];
			++cnt[y];
		}
	}
	int res = 0;
	fu(i,1,n)res += b[i];
	cout << res << '\n';
}


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


int main() {
  int n;
  while (cin >> n) {
    int cnt = 0;
    for (int a = 0; a <= 9; a++) {
      for (int b = 0; b <= 9; b++) {
	for (int c = 0; c <= 9; c++) {
	  int d = n - a - b- c;
	  if (0 <= d && d <= 9) cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  

  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n, k;
    cin >> n >> k;
    int ans = k;
    for(int i = 1; i < n; i++)
        ans *= (k-1);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		final long X = 1000000;

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] AB = new long[N];
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			AB[i] = a * X + b;
		}
		Arrays.sort(AB);

		PriorityQueue<Integer> q = new PriorityQueue<>();
		int abi = 0;
		int sum = 0;
		for (int i = 0; i <= M; i++) {
			// push
			while (abi < N && AB[abi] < (i+1) * X) {
				int b = (int)(AB[abi] % X);
				q.add(-b);
				abi++;
				// System.out.println("X");
			}
			if (q.size() > 0) {
				int v = q.poll();
				sum += -v;
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 82760
N = int(input())
A = input().split(" ")
A = [int(i) for i in A]
A = sorted(A)
#print(A)

for i in range(N-1):
    A[1] = (A[0] + A[1]) / 2
    A.pop(0)
    A = sorted(A)
    #print(A)
print(A[0])

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

int main() {
    int n;cin>>n;
    int s[n];
    int ans=0;
    for(int i=0;i<n;++i){
        cin>>s[i];
    }
    for(int i=1;i<n-1;++i){
        if     (s[i-1]<s[i]  &&s[i]<s[i+1])ans+=1;
        else if(s[i-1]>s[i]  &&s[i]>s[i+1])ans+=1;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstdio>

#define X first
#define Y second

using namespace std;

typedef pair<int,int> P;

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
string idx="ABCDEFGHI";

int main(void){
	
	map<char,P> mp;
	int cnt=0,b;
	
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			mp[idx[cnt++]]=P(i,j);
	
	P s,t,d;
	char S,T,D;
	while(cin >> b >> S >> T >> D){
		
		s.X=mp[S].X,s.Y=mp[S].Y;
		t.X=mp[T].X,t.Y=mp[T].Y;
		d.X=mp[D].X,d.Y=mp[D].Y;
		
		double dp[16][3][3];
		
		for(int i=0;i<16;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)dp[i][j][k]=0;
		
		dp[0][s.Y][s.X]=1;
		
		for(int k=0;k<b;k++){
			for(int x=0;x<3;x++){
				for(int y=0;y<3;y++){
					for(int i=0;i<4;i++){
						int nx=x+dx[i],ny=y+dy[i];
						if(nx<0 || ny<0 || 2<nx || 2<ny || (nx==d.X && ny==d.Y))nx=x,ny=y;
						dp[k+1][ny][nx]+=dp[k][y][x]/4;
					}
				}
			}
		}
		printf("%.8f\n",dp[b][t.Y][t.X]);
	}
	
	return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    if (c == 'A') cout << "T" << endl;
    if (c == 'T') cout << "A" << endl;
    if (c == 'C') cout << "G" << endl;
    if (c == 'G') cout << "C" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N,r,t;
	cin>>N;
	for(int i=0;i<N;i++){
  		cin>>r>>t;
		if(r%100==0){
			if(t%30==0){
				cout<<t/30*5+r/100<<endl;
			}else{
				cout<<t/30*5+r/100<<" "<<(t/30+1)*5+r/100<<endl;
			}
		}else{
			if(t%30==0){
				cout<<t/30*5+r/100<<" "<<t/30*5+r/100+1<<endl;
			}else{
				cout<<t/30*5+r/100<<" "<<t/30*5+r/100+1<<" "<<(t/30+1)*5+r/100<<" "<<(t/30+1)*5+r/100+1<<endl;
			}
		}
	}
	return 0;
}
	

Measured memory_bytes: 3096
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer>
inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 205, INF = 1e9;

int Sum;

int main() {
	int n = read<int>(), l = read<int>(), x = l, flag = 0;
	rep (i, 1, n) {
		if (l == 0) flag = 1;
		Sum += l, ++l;
	}
	if (!flag) Sum -= x > 0 ? x : l - 1;
	cout << Sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN=105,INF=1e18;
LL bneck,adj[MAXN][MAXN],source,sink,ans,n,a[MAXN];
bool visited[MAXN],sudah;

void dfs(LL node,LL bottleneck){
	if(node==sink){
		ans-=bottleneck;
		sudah=true;
		bneck=bottleneck;
		return;
	}
	if(!visited[node]){
		visited[node]=true;
		for(LL i=1;i<=n+2;i++){
			if(adj[node][i]>0){
				dfs(i,min(adj[node][i],bottleneck));
				if(sudah){
					adj[node][i]-=bneck;
					adj[i][node]+=bneck;
					return;
				}
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	for(LL i=1;i<=n;i++){
		cin >> a[i];
		if(a[i]>0){
			ans+=a[i];
			adj[i][n+2]=a[i];
		}
		else adj[n+1][i]=-a[i];
	}
	for(LL i=1;i<=n;i++){
		for(LL j=i+i;j<=n;j+=i)adj[i][j]=INF;
	}
	source=n+1;sink=n+2;
	sudah=true;
	while(sudah){
		memset(visited,false,sizeof(visited));
		sudah=false;
		dfs(source,INF);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N;
    cin >> N;
    ll ans = 0;
    for(int i = 2; i <= 1000000; i++) {
        int cnt = 0;
        while(N % i == 0) {
            cnt++;
            N /= i;
        }
//        if(cnt > 0) {
//            cout << i << ":" << cnt << endl;
//        }
        int lvl = 0;
        int cur = 1;
        while(cnt >= cur) {
            lvl++;
            cnt -= cur;
            cur++;
        }
        ans += lvl;
    }
    if(N > 1) ans++;
    output(ans);
    
    
    return 0;
}


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

using namespace std;

template <typename T>
inline T read()
{
	T x = 0;
	char ch = getchar();
	bool f = 0;
	while(ch < '0' || ch > '9')
	{
		f = (ch == '-');
		ch = getchar();
	}
	while(ch <= '9' && ch >= '0')
	{
		x = ((x + (x << 2)) << 1) + (ch - '0');
		ch = getchar();
	}
	return  f? -x : x;
}

template <typename T>
void put(T x)
{
	if(x < 0)
	{
		x = -x;
		putchar('-');
	}
	if(x < 10) {
		putchar(x + 48);
		return;
	}
	put(x / 10);
	putchar(x % 10 + 48);
	return ;
}

#define reg register
#define rd read <int>
#define pt(i) put <int> (i), putchar(' ')

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull;
typedef unsigned int ui;

const int Maxn = 2e5 + 111;

ll n, ans;

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

int main()
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			for(int k = 1; k <= n; ++k)
			{
				int gc = gcd(max(i, j), min(i, j));
				gc = gcd(max(gc, k), min(gc, k));
				ans += gc;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#a = list(map(int, input().split()))
if a < c and b < c:
    print(0)
elif a <= c and c <= b:
    if b < d:
        print(b-c)
    else:
        print(d-c)
elif c <= a and a <=d:
    if d <= b:
        print(d-a)
    else:
        print(b-a)
else:
    print(0)

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

int main() {
	int A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
	int swater,sugar;
	float p=0;
	for(int a=0;100*a<=F;a+=A){
		for(int b=0;100*a+100*b<=F;b+=B){
			for(int c=0;100*a+100*b+c<=F;c+=C){
				for(int d=0;100*a+100*b+c+d<=F;d+=D){
					if((c+d+a+b)!=0){
					if((a+b)*E>=(c+d)){
						float x=100*a+100*b;
						float y=c+d;
						if(p<=y/(x+y)){
							p=y/(x+y);
							swater=100*a+100*b+c+d;
							sugar=c+d;
						}
					}
					}

				}
			}
		}
	}
	if(swater){
	cout<<swater<<' '<<sugar<<endl;
	}else{
		cout<<100*A<<" 0"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    ll n;
    cin>>n;
    vector<ll>vec(n);
    map<ll,ll>mp;
    for(auto &i:vec)
    {
        cin>>i;
        mp[i]++;
    }
    vector<ll> ans;
    map<ll,ll>:: iterator it,it1;
    it=mp.end();
    it--;
    it1=mp.begin();
    it1--;
    ll count=0;
    for(;it!=it1;it--)
    {
        if(it->ss>=4)
        {
            count+=4;
            ans.pb(it->ff);
        }
        else if(it->ss>=2)
        {
            count+=2;
            ans.pb(it->ff);
        }
        if(count==4)break;

    }
    if(count<4)cout<<0<<endl;
    else
    {
        if(ans.size()==1)cout<<1LL*ans[0]*ans[0]<<endl;
        else cout<<1LL*ans[0]*ans[1]<<endl;
    }
}



Measured memory_bytes: 10324
n,k=[int(x) for x in input().split()]
p=[(int(x)+1)/2 for x in input().split()]
dp=[0]*(n-k+1)
dp[0]=sum(p[:k])
for i in range(1,n-k+1):
    dp[i]=dp[i-1]+p[k+i-1]-p[i-1]
print(max(dp))
# print(dp)

Measured memory_bytes: 23588
#include <stdio.h>

int main( void ) {
	int n, debt = 100000;

	for ( scanf( "%d", &n ); n--; debt = ( (int)( debt * 1.05 - 1 ) / 1000 + 1 ) * 1000 ) ;

	printf( "%d\n", debt );

	return 0;
}

Measured memory_bytes: 592
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()
A = [0]  # 累積和
for i in range(N):
    A.append(A[-1]+I()-K)

# Ai<=Aj たる i<j の個数を数え上げる

B = sorted(list(set(A)))
d = {}
for i in range(len(B)):
    d[B[i]] = i+1

for i in range(N+1):
    A[i] = d[A[i]]

# Aを大小関係を保ち座標圧縮


class BIT():
    def __init__(self,init_value):
        self.n = len(init_value)
        self.tree = [0]*(self.n+1)
        for i in range(1,self.n+1):
            x = init_value[i-1]
            while i <= self.n:
                self.tree[i] += x
                i += i & (-i)
    def update(self,i,x):  # i(1-index)番目の値を+x
        while i <= self.n:
            self.tree[i] += x
            i += i & (-i)
        return
    def query(self,i):  # 1番目からi(1-index)番目までの和を返す
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & (-i)
        return res


BIT = BIT([0]*(N+1))
ans = 0
for i in range(N+1):
    ans += BIT.query(A[i])
    BIT.update(A[i],1)
print(ans)


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

Measured memory_bytes: 3064
#!/usr/bin/env python3


def solv(s):
    s = sorted(s)
    if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':

    s = input()

    ans = solv(s)

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 
int main() 
{
	fastio
	//t_case
	{
		ll sum=0,ans=inf,n,m=0,mx=-inf,mn=inf,p,f ;//cin>> n ;
		string s,t; cin>>s>>t;
		fr(i,0,s.length()-t.length()+1 ) {
			ll cnt=0;
			for(int j=0;j<t.length();j++ ){
				if(s[i+j]!=t[j]) cnt++;
			}
			ans=min(ans,cnt);
		}
		cout<<ans;
		cout<<endl;
	}
	return 0;
}

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



int main(){
	int n;
	cin>>n;
	
	int k;
	cin>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int count=0;
	for(int i=0;i<n;i++){
		if(v[i]>=k){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DDecayedBridges solver = new DDecayedBridges();
    solver.solve(1, in, out);
    out.close();
  }

  static class DDecayedBridges {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      long n = in.nextLong();
      int m = in.nextInt();
      long[] a = new long[m];
      long[] b = new long[m];
      long[] inconv = new long[m];
      UnionFind uf = new UnionFind();
      uf.init((int) n);
      for (int i = 0; i < m; i++) {
        a[i] = in.nextInt();
        b[i] = in.nextInt();
      }

      inconv[m - 1] = (n * (n - 1)) / 2;
      for (int i = m - 1; i > 0; i--) {
        if (uf.same((int) a[i], (int) b[i])) {
          inconv[i - 1] = inconv[i];
        } else {
          inconv[i - 1] = inconv[i] - uf.size((int) a[i]) * uf.size((int) b[i]);
        }
        uf.union((int) a[i], (int) b[i]);
      }

      for (int i = 0; i < m; i++) {
        out.println(inconv[i]);
      }

    }

  }

  static class UnionFind {

    private int MAX_N = 1000000;
    int[] parent = new int[MAX_N];
    int[] treeSize = new int[MAX_N];

    void init(int n) {
      for (int i = 0; i < n; i++) {
        parent[i] = i;
        treeSize[i] = 1;
      }
    }

    int find(int x) {
      if (parent[x] == x) {
        // X is Root
        return x;
      } else {
        return parent[x] = find(parent[x]);
      }
    }

    boolean same(int x, int y) {
      return find(x) == find(y);
    }

    void union(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) {
        return;
      } else {
        treeSize[find(y)] += treeSize[find(x)];
        parent[x] = y;
      }
    }

    long size(int x) {
      return treeSize[find(x)];
    }

  }
}



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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000009

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i,0,n) cin >> p[i];
    
    ll cnt = 0;
    REP(i,1,n-1) {
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) ++cnt;
    }
    _PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 256
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N,M=ipt()
ab=ipt(N)
cd=ipt(M)

def m_dist(a,b,c,d):
    return abs(a-c)+abs(b-d)

for i in range(N):
    ans = ""
    ans_d = 10**9
    for j in range(M):
        m = m_dist(ab[i][0],ab[i][1],cd[j][0],cd[j][1])
        if ans_d > m:
            ans_d = m
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
ll a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n;
	const ll lim = 1e18;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if(a[i]==0) {
			cout << 0 << '\n';
			return 0;
		}
	}
	ll cur = 1;
	for (int i = 1; i <= n; ++i) {
		if(cur > lim / a[i]) {
			cout << "-1\n";
			return 0;
		}
		cur *= a[i];
	}

	if(cur > lim) cur = -1;

	cout << cur << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 18516
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

typedef struct {
    int c;
    int s;
    int f;

} Dat;

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

    int n;
    cin >> n;

    Dat a[SIZE];
    for( int i = 0; i < n - 1; ++i ) {
        cin >> a[i].c >> a[i].s >> a[i].f;

    }

    for( int i = 0; i < n; ++i ) {
        int time = 0;
        for( int j = i; j < n - 1; ++j ) {
            if( time < a[j].s ) time = a[j].s;
            while( ( time - a[j].s ) % a[j].f != 0 ) ++time;
            time += a[j].c;

        }
        cout << time << endl;

    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int K,N; //Kは湖の周、Nが軒数
    cin >> K >> N;
    vector<int> H(N); //北端からの距離配列
    for(int i=0;i<N;i++){
        cin >> H.at(i);
    }
    int maxdis = -1;
    for(int i=1;i<N;i++){
        maxdis = max( H.at(i)-H.at(i-1) , maxdis);
    }
    maxdis = max( H.at(0)+K-H.at(N-1) , maxdis);
    cout << K-maxdis;
}

Measured memory_bytes: 1024
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    grid = [":"*(W+2)] + [":"+ST()+":" for _ in range(H)] + [":"*(W+2)]
    # print(grid)
    for i in range(1,H+1):
        for j in range(1,W+1):
            # print(i,j,grid[i][j])
            if grid[i][j] == ".":
                cnt=0
                for dx in range(-1,2):
                    for dy in range(-1,2):
                        cnt += grid[i+dy][j+dx]=="#"
                print(cnt,end="")
            elif grid[i][j] == "#":
                print("#",end="")

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

Measured memory_bytes: 46556
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long int a,b,A,B;
  long long int t;
  cin >> a >> A >> b >> B >> t;
  if(a == b) cout << "YES" << endl;
  else{
    if(a > b){
      if(A == B) cout << "NO" << endl;
      else{
        if(A < B) cout << "NO" << endl;
        else{
            if(A*t+b-a>=B*t) cout << "YES"<< endl;
            else cout << "NO" << endl;
        }
      }
    }
    else{
      if(A == B) cout << "NO" << endl;
      else{
        if(A < B) cout << "NO" << endl;
        else{
            if(A*t+a-b>=B*t) cout << "YES"<< endl;
            else cout << "NO" << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    int n, m;
    std::vector<int> a;

    std::cin >> n >> m;

    a.resize(n);

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

    const double threshold = static_cast<double>(total) / (4.0 * m);
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= threshold) {count++;}
    }

    if (count >= m) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1000000007;

#define fr first
#define sc second

int d(int x){
	if(x&1)return 1;
	else return 1+d(x>>1);
}

int main(){
	int n;
	cin >> n;
	
	for(int i = 0 ; i < n-1 ; i ++){
		for(int j = i+1 ; j < n ; j ++){
			printf("%d%c",d(i^j),(j==n-1)?'\n':' ');
		}
	}
}

Measured memory_bytes: 512
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int IMF = 1'000'000'000; //1e9
const int MIL = -1;
const long long LIMF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N; std::cin >> N;
    long long leaf(0), ans(1), now(1);
    std::vector<int> A(N+1);
    for(int i(0); i <= N; ++i){
        std::cin >> A[i];
        leaf += A[i];
    }
    if(!N){
        if(A[0] == 1) std::cout << 1 << std::endl;
        else std::cout << -1 << std::endl;
        return 0;
    }
    if(A[0]){
        std::cout << -1 << std::endl;
        return 0;
    }
    for(int i(1); i <= N; ++i){
        long long a(std::min(leaf, 2*now));
        if(a < A[i]){
            std::cout << -1 << std::endl;
            return 0;
        }
        now = a - A[i];
        ans += a;
        leaf -= A[i];
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3760
n = int(input())
ans = 10 ** 12
for i in range(1, n):
    a = str(i)
    b = str(n - i)
    C = []
    for j in a:
        C.append(int(j))
    for k in b:
        C.append(int(k))
    ans = min(ans, sum(C))
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a >= h && b >= w) ans++;
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

int main() {
    long long a, b, k;
    cin >> a >> b >> k;

    if (a < k) {
        cout << 0 << " " << max(0LL, b - (k - a)) << endl;
    } else {
        cout << a - k << " " << b << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){
	int a[3];

	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);

	if(a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    int t = k*(k-1)/2;
    t %= MOD;
    rep(i,n){
        int cnt1 = 0, cnt2 = 0;
        rep(j,n)if(a[i] > a[j]){
            cnt1++;
            if(i<j)cnt2++;
        }
        ans += cnt2*k%MOD;
        ans %= MOD;
        ans += cnt1*t%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    
    let answer = [];
    
    for(let i=X-K+1; i<=X+(K-1); i++) {
        answer.push(i);
    }
    
    console.log(answer.join(" "));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   string n;
   cin >> n;
   cout << "ABC" + n << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a[1010],sum[1010][1010] = {0},ans = 1099511627775;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long i,j,l,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(j==0) sum[i][j] = a[j];
			else sum[i][j] += sum[i][j-1] + a[j];
		}
	}
	ans = 0;
	for(l=40;l>=0;l--){
		int cnt = 0;
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				if((1LL<<l)&sum[i][j]) cnt++;
			}
		}
		if(cnt>=k){
			ans |= 1LL<<l;
			for(i=0;i<n;i++){
				for(j=i;j<n;j++){
					if(!((1LL<<l)&sum[i][j])) sum[i][j] = 0;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			//if(sum[i][j]) ans &= sum[i][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7424