akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
const int mx = 111;
struct Point {
   double x, y;
    Point() {}
    Point(double x,double y):x(x),y(y) {}
}p[mx];

const double eps = 1e-14;
typedef Point Vector;
int dcmp(double x) { //返回x的正负
    if(fabs(x)<eps) return 0;
    return x<0? -1 : 1;
}
Vector operator-(Vector A,Vector B) {return Vector(A.x - B.x, A.y - B.y);}
Vector operator+(Vector A,Vector B) {return Vector(A.x + B.x, A.y + B.y);}
Vector operator*(Vector A,double p) {return Vector(A.x*p, A.y*p);}
Vector operator/(Vector A,double p) {return Vector(A.x/p, A.y/p);}
bool operator<(const Point&a,const Point&b) {return a.x<b.x||(a.x==b.x&&a.y<b.y);}
bool operator==(const Point&a,const Point&b) {return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0;}
double Dot(Vector A,Vector B) { //点积
    return A.x*B.x+A.y*B.y;//如果改成整形记得加LL
}
double Cross(Vector A,Vector B) { //叉积
    return A.x*B.y-A.y*B.x;//如果改成整形记得加LL
}
//向量长度
double Length(Vector A) {
    return sqrt(Dot(A,A));
}
//2个向量之间的夹角
double Angle(Vector A,Vector B) {
    return acos(Dot(A,B)/Length(A)/Length(B));
}
//向量的极角
double angle(Vector v) {
    return atan2(v.y,v.x);
}
//计算ABC的有向面积
double Area(Point A,Point B,Point C) {
    return Cross(B-A,C-A)/2;
}
//将A向量逆时针旋转rad
Vector Rotate( Vector A,double rad) {
    return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
//返回A的逆时针旋转90度的单位法向量
Vector Normal(Vector A) {
    double L=Length(A);
    return Vector(-A.y/L,A.x/L);
}

struct Circle {
    Point c;
    double r;
    Circle() {}
    Circle(Point c,double r):c(c),r(r) {}
    Point getpoint(double rad) {
        return Point(c.x+cos(rad)*r,c.y+sin(rad)*r);
    }
};

Circle CircumscribedCircle(Point p1, Point p2, Point p3) {
    double Bx = p2.x-p1.x, By = p2.y-p1.y;
    double Cx = p3.x-p1.x, Cy = p3.y-p1.y;
    double D = 2*(Bx*Cy-By*Cx);
    double cx = (Cy*(Bx*Bx+By*By) - By*(Cx*Cx+Cy*Cy))/D + p1.x;
    double cy = (Bx*(Cx*Cx+Cy*Cy) - Cx*(Bx*Bx+By*By))/D + p1.y;
    Point p = Point(cx, cy);
    return Circle(p, Length(p1-p));
}

Circle mincirclecover(Point *w,int n) {
    random_shuffle(w,w+n);//随机化
    Circle C(w[0],0);
    for(int i=1; i<n; i++) {
        if(dcmp(Length(C.c-w[i])-C.r)>0) {
            C=Circle(Point((w[0]+w[i])/2),Length(w[0]-w[i])/2);
            for(int j=0; j<i; j++)
                if(dcmp(Length(C.c-w[j])-C.r)>0) {
                    C=Circle(Point((w[i]+w[j])/2),Length(w[i]-w[j])/2);
                    for(int k=0; k<j; k++)
                        if(dcmp(Length(C.c-w[k])-C.r)>0)
                            C=CircumscribedCircle(w[i],w[j], w[k]);
                }
        }
    }
    return  C;
}


int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%lf%lf",&p[i].x,&p[i].y);
    }
    Circle c = mincirclecover(p,n);
    printf("%.8f\n",c.r);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int H=sc.nextInt();
    int W=sc.nextInt();
    int h=sc.nextInt();
    int w=sc.nextInt();
    System.out.println((H-h)*(W-w));
  }
}


Measured memory_bytes: 21844
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);  
int dsu[123456];
struct total{
	int val,u,v;
}; 
int compar(total a,total b){
	return a.val<b.val;
}
vector<total> edges;
vii vec1,vec2;
int x[123456],y[123456];
int calc(int a,int b){
	return min(abs(x[a]-x[b]),abs(y[a]-y[b]));
}
int find(int u){
	if(dsu[u]<0)return u;
	dsu[u]=find(dsu[u]);
	return dsu[u];
}
int merge(int u,int v){
	u=find(u);
	v=find(v);
	if(u!=v){
		if(dsu[u]>dsu[v]){
			dsu[u]=v;
		}
		else{
			dsu[v]=u;
		}
	}
	else{
		dsu[u]=v;
		dsu[v]--;
	}
	return 0;
}
int main(){
    std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int i;
	total haha;
	//return 0;
	rep(i,n){

		dsu[i]=-1;
		cin>>x[i]>>y[i];
		vec1.pb(mp(x[i],i));
		vec2.pb(mp(y[i],i));
	}
	//return 0;
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	//return 0;
	f(i,1,n){
		
		haha.u=vec1[i].ss;
		haha.v=vec1[i-1].ss;
		haha.val=calc(haha.u,haha.v);
		edges.pb(haha);
		
		haha.u=vec2[i].ss;
		haha.v=vec2[i-1].ss;
		haha.val=calc(haha.u,haha.v);
		edges.pb(haha);
	}
	sort(edges.begin(),edges.end(),compar);
	ll ans=0;
    rep(i,edges.size()){
    	//cout<<edges[i].val<<" "<<find(edges[i].u)<<" "<<find(edges[i].v)<<endl;
    	if(find(edges[i].u)!=find(edges[i].v)){
    		ans+=edges[i].val;
    		merge(edges[i].u,edges[i].v);
    	}
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 8168
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
if(a>=13){
    cout<<b;
}else if(a>5){
cout<<b/2;
}else cout<<0;
}


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

int main(void){
    int N,X,T;
    cin >> N >> X >> T;
    int ans = 0;
    int temp = N%X;
    if(temp == 0) cout << N/X*T << endl;
    else cout << N/X*T + T << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long ll;
const int MAXN = 100;

int selectionsort(int *A, int N) {
	int  count = 0;
	for (int i = 0; i < N - 1; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[minj] > A[j])minj = j;
		}
		if (minj != i) {
			swap(A[minj], A[i]);
			count++;
		}
	}
	return count;
}

int main() {
	int  N, count;
	int A[MAXN];
	cin >> N;
	rep(i, N)cin >> A[i];
	count = selectionsort(A, N);
	rep(i, N) {
		if (i != N - 1)cout << A[i] << " ";
		else cout << A[i] << endl;
	}
	cout << count << endl;
	return 0;
}


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

int main() {
    int n;cin>>n;
    ll a=1,b=1,c=1;
    int mod=1e9+7;
    for (int i=0;i<n;i++) {
        a=a*10%mod;
        b=b*9%mod;
        c=c*8%mod;
    }
    cout<<((a-b*2+c)%mod+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
A = inintl()

A = Counter(A)
b = []

m = 0

for a in A:
    if A[a] >= 4:
        if a > m:
            m = a
    if A[a] >= 2:
        b.append(a)

b = sorted(b)[::-1]


if len(b) < 2:
    if m != 0:
        print(m*m)
    else:
        print(0)
elif m*m > b[0]*b[1]:
    print(m*m)
else:
    print(b[0]*b[1])

Measured memory_bytes: 22392
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	static IntStream REPS(int l) {
		return IntStream.range(0,l);
	}
	static List<Integer>hoge=Arrays.asList(5,12,17,24,31);
	public static void main(String[]__){
		ArrayDeque<Integer>d=new ArrayDeque<>();
		
		cases:
		while(true){
			int n=getInt();
			if(n==0)return;
			int[]in=REPS(n).map(i->s.next().length()).toArray();
			int[]psum=new int[n+1];
			for(int i=0;i<n;i++)psum[i+1]=in[i];
			Arrays.parallelPrefix(psum,Integer::sum);
			for(int i=1;i<=n;i++) {
				d.clear();
				d.addAll(hoge);
				
				int v=psum[i-1];
				IntStream.rangeClosed(i,n).map(w->psum[w]-v).forEach(w->{
					if(!d.isEmpty()&&d.peekFirst()==w)
						d.pollFirst();
				});
				if(d.isEmpty()) {
					System.out.println(i);
					continue cases;
				}
			}
		}
	}
}

Measured memory_bytes: 41332
use proconio::input;

fn main() {
  input! {
    x: char
  }

  let ans = 
  //if 'A'<=x && x<='Z' {
  if x.is_uppercase() {
    "A"
  }else{
    "a"
  };

  println!("{}", ans);

  //println!("Hello, AtCoder!");
}


Measured memory_bytes: 2164
(defun sieve (n)
  (let ((is-prime (make-array (1+ n)
                              :initial-element t))
        (primes '()))
    (setf (svref is-prime 0) nil)
    (setf (svref is-prime 1) nil)
    (loop for i from 2 to n
          do (when (svref is-prime i)
               (push i primes)
               (loop for j from (* 2 i) to n by i
                     do (setf (svref is-prime j) nil))))
    (nreverse primes)))

(defparameter goods
  (remove-if (lambda (n) (/= (mod n 5) 1))
             (sieve 55555)))

(defparameter n (read))
(format t "~{~a~^ ~}~%"
        (subseq goods 0 n))


Measured memory_bytes: 17000
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    c, d = map(int, input().split())
    a.append(c)
    b.append(d)
a = max(a)
b = [i for i in b if i > a]
b.sort(reverse=True)
lb = len(b)

for i in range(lb):
    h -= b[i]
    if h <= 0:
        print(i+1)
        exit()
if h % a == 0:
    print(h//a + lb)
else:
    print(h//a + lb + 1)

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

using namespace std;

#define ll long long
const int mxN=1e5;

int main() {
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll cnt=0;
	if(n<3){
		cout<<cnt;
		return 0;
	}
	sort(a,a+n);
	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]){
					if((a[i]+a[j])>a[k])
						cnt++;
				}
			}
		}
	}
	cout<<cnt;
    return 0;
}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long li;
typedef unsigned long long uli;
typedef pair<int, int> pii;
typedef long double ld;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)

const int INF = 1e9 + 1000;
const li INF64 = 1e15 + 1000;
const int M = 26;
const int N = 100 + 100;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = 3.14159265359;

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

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> h(n);
    forn(i, n) {
        cin >> h[i];
    }

    vector<int> dp(n);

    dp[1] = abs(h[1] - h[0]);

    fore(i, 2, n) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << '\n';
    
}

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

import bisect

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
# print(f"N: {N}")
# print(f"A, B, C: {A}, {B}, {C}")

# def binary_search_left(arr, value):
#     left = 0
#     right = len(arr) - 1
#     if value < arr[left]:
#         return left
#     if value > arr[right]:
#         return right + 1
#     while left <= right:
#         mid = (left + right) // 2
#         if value > arr[mid]:
#             left = mid + 1
#         elif value < arr[mid]:
#             right = mid - 1
#         else:
#             # find the leftmost index
#             while arr[mid] == value:
#                 mid -= 1
#             return mid + 1
#     # left == right + 1, so arr[right] < value < arr[left]
#     return left

# def binary_search_right(arr, value):
#     left = 0
#     right = len(arr) - 1
#     if value < arr[left]:
#         return left
#     if value > arr[right]:
#         return right + 1
#     while left <= right:
#         mid = (left + right) // 2
#         if value > arr[mid]:
#             left = mid + 1
#         elif value < arr[mid]:
#             right = mid - 1
#         else:
#             # find the leftmost index
#             while arr[mid] == value:
#                 if mid == len(arr) - 1:
#                     return mid + 1
#                 mid += 1
#             return mid
#     # left == right + 1, so arr[right] < value < arr[left]
#     return left

# count = 0
# for bot in B:
#     # print(f"bot: {bot}")
#     index_A = binary_search_left(A, bot)
#     index_C = binary_search_right(C, bot)
#     # print(f"index_A: {index_A}, index_C: {index_C}")
#     count += index_A * (N - index_C)

# print(count)

count = 0
for bot in B:
    # print(f"bot: {bot}")
    index_A = bisect.bisect_left(A, bot)
    index_C = bisect.bisect_right(C, bot)
    # print(f"index_A: {index_A}, index_C: {index_C}")
    count += index_A * (N - index_C)

print(count)


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

const int MAX = 100005;
const int mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){

COMinit();

 long long int N;
 long long int K;
 cin >> N >> K;
 if(K==1)cout << 0 << endl;
 else{
 long long int a[N];
 long long int i;
 for(i=0;i<N;++i){
   cin >> a[i];
   }

sort(a,a+N);
long long int count = 0;
long long int com = 1;
 for(i=0;i<N-K+1;i++){
     count+=(((a[K-1+i]-a[N-K-i])*COM(i+K-1,K-1))%mod);
     count %= mod;
     com *= (K+i);
     com /= (i+1);
     com %= mod;
 }
cout << count%mod << endl;
 }
}

Measured memory_bytes: 3328
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	ll n, k;
	cin >> n >> k;
	ll ans = (n/k) * (n/k) * (n/k);
	if(k%2==0){
		if(n%k >= k/2) ans += ((n/k)+1) * ((n/k)+1) * ((n/k)+1);
		else ans *= 2;
	}
	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    Scanner sc = new Scanner(System.in);

    Main(){
	int a=sc.nextInt();
	int b=sc.nextInt();
	System.out.println( (a*b) + " " + (a*2+b*2) );
    }

    public static void main(String[] args){
	new Main();
    }
}



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

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X) {
    if (K * 500 >= X) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long K;
    scanf("%lld", &K);
    long long X;
    scanf("%lld", &X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(){
     long long n,a[10000000],b[10000000],c=0;
    cin>>n;
    for(int i=0; i<n+1; i++){
      cin>>a[i];
    }
    for(int i=0; i<n; i++){
        cin>>b[i];
      if(a[i]>=b[i]){
        c=c+b[i];
      }else{
        if(a[i+1]>=(b[i]-a[i])){
          c=c+a[i];
          c=c+(b[i]-a[i]);
          a[i+1]=a[i+1]-(b[i]-a[i]);
        }else{
          c=c+a[i];
          c=c+a[i+1];
          a[i+1]=0;
        }
      }
    }
    cout<<c<<'\n';
  return(0);
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  int t=0;
  int cnt=b-a;
  while(cnt>0){
    t+=cnt;
    cnt--;
  }
  cout<<t-b<<endl;
  return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
Ar = []
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            Ar.append(i)
            break
Ar.append(H)
if len(Ar)==2:
    Ac = []
    for j in range(W):
        if S[Ar[0]][j]=="#":
            Ac.append(j)
    A = [[1 for _ in range(W)] for _ in range(H)]
    Ac.append(W)
    Ac[0]=0
    if len(Ac)>2:
        for k in range(len(Ac)-1):
            for j in range(Ac[k],Ac[k+1]):
                for i in range(H):
                    A[i][j] = k+1
else:
    Ac = {i:[] for i in range(len(Ar)-1)}
    for i in range(len(Ar)-1):
        for j in range(W):
            if S[Ar[i]][j]=="#":
                Ac[i].append(j)
    A = [[1 for _ in range(W)] for _ in range(H)]
    Ar[0] = 0
    cnt = 1
    for i in range(len(Ar)-1):
        Ac[i][0] = 0
        Ac[i].append(W)
        for j in range(len(Ac[i])-1):
            for j1 in range(Ac[i][j],Ac[i][j+1]):
                for i1 in range(Ar[i],Ar[i+1]):
                    A[i1][j1] = cnt
            cnt += 1
for i in range(H):
    print(*A[i])

Measured memory_bytes: 76340
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        List<Integer> placeList = new ArrayList<>();
        for (int i = 0; i < n + 1; i++) {
            placeList.add(0);
        }
        int[] costPlaceList = new int[m];
        for (int i = 0; i < m; i++) {
            costPlaceList[i] =scanner.nextInt();
        }

        for(int costPlace : costPlaceList){
            placeList.set(costPlace, 1);
        }

        int leftCost = sum(placeList.subList(0, x));
        int rightCost = sum(placeList.subList(x+1, placeList.size()));

        if(leftCost < rightCost) {
            System.out.println(leftCost);
        } else {
            System.out.println(rightCost);
        }
    }

    private static int sum(List<Integer> list){
        int result = 0;
        for(int element : list) {
            result += element;
        }
        return result;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e16+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n, arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len = v.size();
    for(int i = 0; i < len; ++i) {
        s<<v[i];
        if(i < len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len = vv.size();
    for(int i = 0; i < len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n, t;
    cin>>n>>t;

    Vec a(n);
    Vec b(n);
    rep(i, n) {
        cin>>a[i]>>b[i];
    }

    VV dp(n+1, Vec(t+1,0));
    VV dp2(n+1, Vec(t+1,0));

    rep(i,t){
        dp[n][i] = 0;
        dp2[n][i] = 0;
    }

    ll ans = 0;
    rep(i, n) {
        rep(j, t) {
            if(i==0){
                if(j>=a[i]){
                    dp[0][j] = b[i];
                }
                continue;
            }
            if(j < a[i]){
                dp[i][j]= dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i]]+b[i]);
            }
        }
    }

    per(i, n-1) {
        rep(j, t) {
            if(j < a[i]){
                dp2[i][j]= dp2[i+1][j];
            }else{
                dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]]+b[i]);
            }
        }
    }

    rep(i,n){
        if(i==0){
            ans = max(ans,b[i]+dp2[i+1][t-1]);
            continue;
        }
        rep(j,t){
            ans = max(ans,dp[i-1][j]+b[i]+dp2[i+1][t-1-j]);
        }
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 143232
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	//input = input.map(e => toIntArr(e.split(' ')));
	var s = input[0];
	var k = toInt(input[1]);
	var l = s.length;
	var arr = [];
	var x;
 
	for(var i = 0; i < l; i++){
		for(var j = i ; j < i+5; j++){
			x = s.slice(i,j+1);
			if(arr.indexOf(x)===-1) arr.push(x);
		}
	}
 
	arr.sort((a,b)=>a<b? -1: 1);
	ans = arr[k-1];
 
	console.log(ans);
}

Measured memory_bytes: 12540
use std::cmp::min;
fn main() {
    let (n,x,y) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s: Vec<usize>=s.split_whitespace().map(|x|x.parse().unwrap()).collect();
        (s[0],s[1],s[2])
    };
    let mut k=vec![0;n];
    let f=|i,j| if i<j {j-i} else {i-j};
    for i in 1..n+1 {
        for j in i+1..n+1 {
            k[min(f(i,j),f(i,x)+f(y,j)+1)]+=1;
        }
    }
    for i in 1..n {
        println!("{}",k[i]);
    }
}

Measured memory_bytes: 4352
n, u, v = map(int, input().split())
u -= 1
v -= 1
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

from collections import deque
q = deque()
q.append(u)
t = [-1]*n
t[u] = 0
while q:
    x = q.popleft()
    for new_x in g[x]:
        if t[new_x] == -1:
            t[new_x] = t[x]+1
            q.append(new_x)

q = deque()
q.append(v)
a = [-1]*n
a[v] = 0
while q:
    x = q.popleft()
    for new_x in g[x]:
        if a[new_x] == -1:
            a[new_x] = a[x]+1
            q.append(new_x)
            
max_ = 0
for i in range(n):
    if t[i] < a[i]:
        max_ = max(max_, a[i])
print(max_-1)

Measured memory_bytes: 29356
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main()
{
    int N;
    cin >> N;
    vector<int> A(3);
    int cache[2][3];
    int c=0;
    for(int i = 0; i < N; i++)
    {
    	for(int j = 0; j < 3; j++)
    	{
    		cin >> A[j];
    		cache[c][j] = A[j];
    	}
    	if(i!=0)
    	{
    		for(int j = 0; j < 3; j++)
    		{
    			int x = 0;
    			for(int k = 0; k < 3; k++)
    			{	
    				if(k != j)	
    				x = max(x, cache[1-c][k]);
    			}
    			cache[c][j] += x;
    		}
    	}
    	c = 1 - c;
    }
    cout << max(cache[1-c][0], max(cache[1-c][1], cache[1-c][2]));
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B,ans;

    cin>>A>>B;

    ans = A - B * 2;

    if(ans <= 0){
        cout<<"0"<<endl;
    }
    else{
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	if (h1 <= h2) cout << ((60 * h2) + m2) - ((60 * h1) + m1) - k;
	else cout << (60 * 24) - (((60 * h2) + m2) - ((60 * h1) + m1)) - k;

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int counter(int x) {
  if(x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}

int main(void) {
  int n;
  int xy[16][16][2];
  int a[16];
  scanf("%d", &n);
  rep(i, 0, n) {
    scanf("%d", &a[i]);
    rep(j, 0, a[i]) {
      scanf("%d %d", &xy[i][j][0], & xy[i][j][1]);
    }
  }
  
  // bit探索
  int ans = 0;
  rep(t, 0, 1 << n) {
    int ok = 1;
    rep(p, 0, n) {
      if ((t & (1 << p)) == 0) continue;
      rep(i, 0, a[p]) {
        if (((t >> (xy[p][i][0] - 1)) & 1) != xy[p][i][1]) 
          goto exit;
      }
    }
    ans = max(ans, counter(t));
    exit: ans += 0;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  int n;
  int a[1000001];
 
  cin >> n;

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

  long long sm = 0;
  for(int i=1; i<n+2; i++){
    sm+=abs(a[i] - a[i-1]);
  }
  
  for(int i=0; i<n; i++){
    cout << sm + abs(a[i+2] - a[i]) - abs(a[i+1] - a[i]) - abs(a[i+2] - a[i+1]) << endl;
  }
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int mod = 1e9 + 7;
  int n, m; cin >> n >> m;
  vector<int> v(n+1, 0), a(m+1, -1);
  rep(i, m) {
    cin >> a[i];
    if((a[i] - a[i-1]) == 1 && i != 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int j = 0;
  v[0] = 1;
  if(a[j] == 1) {
    v[1] = 0;
    ++j;
  } else v[1] = 1;

  int ans = 0;

  for(int i = 2; i <= n; ++i) {
    if(a[j] != i) {
      v[i] = v[i-1] + v[i-2];
      v[i] %= mod;
    } else {
      v[i+1] = v[i-1];
      ++i;
      ++j;
    }
  }
  cout << v[n];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N , C;
  C = 0;
 cin >> N;
  for(int i = 1; i < N ; i++){
    int D;
    D = 0;
    if(N % i == 0){
       D = N / i;
    }
    else{
      D = N / i + 1;
    }
    for(int j = 1; j < D ; j++){
   if(i*j < N){
     C++;
   }
    }
  }
  cout << C << endl;
} 

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

//FenwickTree↓
int dat[N];
void init(){
    rep(i,N)dat[i]=0;
}
void add(int i,int x){
    for(;i<N;i+=i&-i)dat[i]+=x;
}
int sum(int i){
    int res=0;
    for(;i>0;i-=i&-i)res+=dat[i];
    return res;
}
int rangesum(int l,int r){//[l,r]
    return sum(r)-sum(l-1);
}
//FenwickTree↑

int a[N];
vector<int> ql[N],qid[N];
int ans[N];

int n,q,c[N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>c[i];
    rep(i,q){
        int l,r;
        cin>>l>>r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }
    init();
    for(int i=1;i<=n;i++)a[i]=0;
    for(int i=1;i<=n;i++){
        if(a[c[i]]>0)add(a[c[i]],-1);
        add(i,+1);
        a[c[i]]=i;
        rep(j,ql[i].size()){
            ans[qid[i][j]]=rangesum(ql[i][j],i);
        }
    }
    rep(i,q)cout<<ans[i]<<"\n";
}


Measured memory_bytes: 53028
#!python3

import sys
from collections import defaultdict
from math import gcd

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = input()
    it = map(int, sys.stdin.read().split())
    mod = 10**9 + 7

    d1 = [defaultdict(int), defaultdict(int)]
    z0 = 0
    for ai, bi in zip(it, it):
        if ai == 0 and bi == 0:
            z0 += 1
            continue

        ci = gcd(ai, bi)
        ai, bi = ai // ci, bi // ci

        t = ai * bi < 0
        if ai < 0:
            ai, bi = -ai ,-bi
        elif ai == 0:
            bi = -1
            t = 1

        d1[t][(ai, bi)] += 1


    a1, a2 = d1
    ans = 1
    for (ai, bi), v in a1.items():
        k2 = (bi, -ai)
        if k2 in a2:
            v2 = a2[k2]
            ans *= pow(2, v, mod) + pow(2, v2, mod) - 1
        else:
            ans *= pow(2, v, mod)
        ans %= mod

    for (ai, bi), v in a2.items():
        k2 = (-bi, ai)

        if k2 in a1: continue

        ans *= pow(2, v, mod)
        ans %= mod

    print((ans-1+z0) % mod)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 83164
s = input()
ans = 0
i = 0
prev_c = None
for c in s:
    if prev_c == 'B':
        if c == 'C':
            ans += i
        elif c == 'A':
            i = 1
        else: # 'B'
            i = 0
    else: # next to A, C
        if c == 'A':
            i += 1
        elif c == 'C':
            i = 0
        else: # 'B'
            pass
    prev_c = c
print(ans)

Measured memory_bytes: 42204
using System;
using System.Linq;

namespace ConsoleApp_ITP1_7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dimension = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int r = dimension[0];
            int c = dimension[1];
            int[,] matrix = new int[r + 1, c + 1];
            int[] line = new int[c];

            for(int i = 0; i < r; i++)
            {
                line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

                for (int j = 0; j < c; j++)
                {
                    matrix[i, j] = line[j];
                    matrix[i, c] += matrix[i, j];
                    matrix[r, j] += matrix[i, j];
                    matrix[r,c] += matrix[i, j];
                }
            }

            for(int i = 0; i < r + 1; i++)
            {
                for(int j = 0; j < c + 1; j++)
                {
                    Console.Write(matrix[i, j]);
                    if (j < c)
                    {
                        Console.Write(' ');
                    }
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 9732
// #include<stdio.h>
// #include <math.h>

// typedef long long ll;

// int main() {
	
// 	return 0;
// }

#include<stdio.h>
#include <math.h>

typedef long long ll;

int main() {
	
	char c;
	int days = 0, cc = 0;
	
	for (int i = 3; i > 0; i--)
	{
		scanf("%c", &c);
		if (c == 'R')
		{
			cc += 1 << (i - 1);
		}
	}
	switch (cc)
	{
	case 0:
		days = 0;
		break;
	case 1:
	case 2:
	case 4:
	case 5:
		days = 1;
		break;
	case 3:
	case 6:
		days = 2;
		break;
	case 7:
		days = 3;
		break;
	}
	
	printf("%d", days);
	
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll h,d,a;
	cin>>h>>d>>a;
	d*=2;
	vector<pair<ll,ll>>p;
	for(ll i=0;i<h;i++){
		ll x,y;
		cin>>x>>y;
		p.push_back(make_pair(x,y));
	}
	sort(p.begin(),p.end());
	queue<pair<ll,ll>>q;
	ll ans=0;
	ll tot=0;
	for(ll i=0;i<h;i++){
		ll nowx=p[i].first;
		ll nowh=p[i].second;
		if(q.size()!=0){
			ll nexx=q.front().first;
			ll nexa=q.front().second;
			while(nexx<nowx){
				tot-=nexa;
				q.pop();
				if(q.size()!=0){
					nexx=q.front().first;
					nexa=q.front().second;
				}
				else{
					break;
				}
			}
		}
		if(tot<nowh){
			ll nexa=nowh-tot;
			nexa=(nexa+a-1)/a;
			ans+=nexa;
			nexa*=a;
			tot+=nexa;
			q.push(make_pair(nowx+d,nexa));
		}
		//cout <<tot<<endl;
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 7868
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string s;
	cin >> s;
	int sum=0;
	rep(i,s.length()){
		int a = stoi(s.substr(i,1));
		sum+=a;
	}
	int t = stoi(s);
	if(t%sum == 0) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, k, inv[N], f[N], res[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
string s[N];

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

	int a, b, c;
	cin >> a >> b >> c;
	if (c < a)
		swap(a, c);
	if (c < b)
		swap(b, c);

	a = c - a;
	b = c - b;
	if ((b & 1) == (a & 1))
		cout << (a + b) / 2 << endl;
	else 
		cout << (a + b) / 2 + 2 << endl;
}

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

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

bool bin_search(int a, int b, int c){
    int left=1, right=100;
    while(right >= left){
        int mid=left+(right-left)/2;
        int val=b*b+c*c+mid*mid+b*c+c*mid+mid*b;
        if(val == a) return true;
        else if(val > a) right=mid-1;
        else left=mid+1;
    }
    return false;
}

int main(){
    int N; cin >> N;
    vector<ll> f(N+1, 0);
    ll res=0;
    for(int i=1; i<=N; i++){
        for(int j=1; j*j<=N; j++){
            for(int k=1; k*k<=N; k++){
                if(bin_search(i, j, k)) f[i]++;
            }
        }
    }
    for(int i=1; i<=N; i++){
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n,a;
    cin >> n >> a;
    n -= (n / 500) * 500;
    if(n <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7
m,n = map(int,input().split())

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % MOD
        x = x ** 2 % MOD
        n //= 2

    return K * x % MOD

print(pow_k(m,n))


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

using namespace std;

int main(){
  
  int N;
  cin >> N;
  
  int a[2][N];
  
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin >> a[i][j];}
  }
  
  int ans=0;
  vector<int> vec(N,0);
  
  for(int k=0;k<N;k++){
    for(int i=0;i<k+1;i++){
      vec[k] += a[0][i];}
    
     for(int i=k;i<N;i++){
      vec[k] += a[1][i];}
  
     if(ans < vec[k]) ans = vec[k];
}

   cout << ans;

}
    
    

Measured memory_bytes: 256
/*
Link: https://atcoder.jp/contests/dp/tasks/dp_g
Code taken from https://atcoder.jp/contests/dp/submissions/3942508
A linked list is being made in array. To[] stores the edge destination, 
e is edge no, Begin is begining , Next is next pointer.
Seems very efficient. 
*/
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5+7;
int To[N],Begin[N],Next[N],inDegree[N],dist[N];
int e;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++) {
    int u,v; 
    cin >> u >> v;
    To[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
    inDegree[v]++;
  }
  queue<int> q;
  for(int i=1;i<=n;i++) {
    if (inDegree[i] == 0)
      q.push(i);
  }
  while(!q.empty()) {
    auto u = q.front();
    q.pop();
    for(int i=Begin[u];i;i=Next[i]) {
      int y = To[i];
      inDegree[y]--;
      dist[y] = max(dist[y],dist[u] + 1);  
      if (inDegree[y] == 0) {
        q.push(y);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++) {
    ans = max(ans,dist[i+1]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int main(){
	int n,a[3];
	cin >> n >> a[0] >> a[1] >> a[2];
	int l[n];
	for(int i=0;i<n;i++) cin >> l[i];

	int ans=1e9;
	for(int i=0;i<(1<<2*n);i++){
		int tmp=0;
		int length[4]={};
		for(int j=0;j<n;j++){
			int index=(i>>2*j)&3;
			if(index!=3&&length[index]>0) tmp+=10;
			length[index]+=l[j];
		}
		bool flag=false;
		for(int j=0;j<3;j++){
			if(length[j]==0){
				flag=true;
				break;
			}
			tmp+=abs(length[j]-a[j]);
		}
		if(flag) continue;
		ans=min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
package main

import (
    "os"
    "fmt"
    "bufio"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func readInt() int64 {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return int64(n)
}


func main() {
    var ans int64 = 1
    var n int64 = readInt()
    var i int64
    for i = 1; i <= n; i++ {
        ans *= i
    }
    fmt.Println(ans)
}



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

int main() {
  int N,A,B,C;
  cin >>A;
  int X[33];
    X[1]=1;
  X[2]=1;
  X[3]=1;
  X[4]=2;
  X[5]=1;
  X[6]=2;
  X[7]=1;
  X[8]=5;
  X[9]=2;
  X[10]=2;
  X[11]=1;
  X[12]=5;
  X[13]=1;
    X[14]=2;
  X[15]=1;
  X[16]=14;
  X[17]=1;
  X[18]=5;
  X[19]=1;
  X[20]=5;
  X[21]=2;
  X[22]=2;
  X[23]=1;
  X[24]=15;
  X[25]=2;
  X[26]=2;
  X[27]=5;
  X[28]=4;
  X[29]=1;
  X[30]=4;
  X[31]=1;
  X[32]=51;

  cout <<X[A]<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w;
    long ans=0;
    cin>>n>>w;
    vector<vector<long>> nums(n,vector<long>(2));
    for(int i=0;i<n;i++)
        for(int j=0;j<2;j++)
            cin>>nums[i][j];

    vector<vector<long>> dp(n+1,vector<long>(w+1));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(nums[i-1][0]>j)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i][j],max(dp[i-1][j],nums[i-1][1]+dp[i-1][j-nums[i-1][0]]));
            }
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 80256
#include<stdio.h>
int main(void){
   int n[30], i, a, fst = 100, snd = 100;
   for ( i = 1; i <= 30; i++ ) {
      n[i] = 0;
   }
   for ( i = 0; i < 28; i++ ) {
      scanf("%d", &a);
      n[a] = 1;
   }
   for ( i = 1; i <= 30; i++ ) {
      if ( n[i] == 0 && i < fst ) {
         snd = fst;
         fst = i;
      } else if ( n[i] == 0 && i > fst ) {
         snd = i;
      }
      /*printf(" %d\n", i);*/
   }
   printf("%d\n%d\n", fst, snd);
   return 0;
}

Measured memory_bytes: 1844
#define int long long

struct meshi { int time, umami; } meshi[3000];
n, t, dp[3001][3000];

comparator (const void *a, const void *b) {
    return ((struct meshi*)a)->time - ((struct meshi*)b)->time;
}

main ()
{
    scanf("%lld %lld", &n, &t);

    for(int i = 0; i < n; i++) scanf("%lld %lld", &meshi[i].time, &meshi[i].umami);
    qsort(meshi, n, sizeof(struct meshi), comparator);

    for(int tt = 0; tt <= t; tt++)
    {
        for (int nn = 0; nn < n; nn++)
        {
            int taberu = 0, tabenai = 0;

            if (tt >= (tt == t ? 1 : meshi[nn].time))
            {
                taberu += meshi[nn].umami;
                if (nn > 0) taberu += dp[tt - (tt == t ? 1 : meshi[nn].time)][nn - 1];
            }

            if (nn > 0)
            {
                tabenai += dp[tt][nn - 1];
            }

            dp[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    printf("%lld\n", dp[t][n - 1]);
}


Measured memory_bytes: 35452
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int t=s.nextInt(),i=0,a,b,c;int[]n=new int[t];for(;i<t;)n[i]=i++;for(t=s.nextInt(),s.nextLine();t-->0;){z=s.nextLine().split(",");c=n[a=new Integer(z[0])-1];n[a]=n[b=new Integer(z[1])-1];n[b]=c;}for(int e:n)System.out.println(e+1);}}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x[100],i=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){

      x[i-2] = x[i-2] + x[i-1];
      i = i-2;

    } 

    else if ( s[0] == '-' ){
      
      x[i-2] = x[i-2] - x[i-1];
      i = i-2;
  
    } 
    
    else if ( s[0] == '*' ){
    
      x[i-2] = x[i-2] * x[i-1];
      i = i-2;
      
    } 
    
    else {
    
      x[i] = atoi(s);
      
    }
    
    i++;
  }

  printf("%d\n",x[0]);
  
  return 0;
}

Measured memory_bytes: 548
import itertools

def new_lunlun(org_str):
    last_digit = org_str[-1]
    if last_digit == "0":
        return org_str + "0", org_str + "1"
    elif last_digit == "9":
        return org_str + "8", org_str + "9"
    else:
        minus_digit = str(int(last_digit) - 1)
        plus_digit = str(int(last_digit) + 1)
        return org_str + minus_digit, org_str + last_digit, org_str + plus_digit

def get_next_lunluns(lunluns):
    next_lunluns = [list(new_lunlun(lunlun)) for lunlun in lunluns]
    return list(itertools.chain.from_iterable(next_lunluns))

K = int(input())
# K = 100000
sum_num = 0

digits = [0,1,2,3,4,5,6,7,8,9]
ditits_str = list(map(str, digits))
lunluns = ditits_str.copy()[1:]

while(True):
    prev_num = sum_num
    sum_num += len(lunluns)
    if sum_num < K:
        lunluns = get_next_lunluns(lunluns)
    else:
        ind = K - prev_num - 1
        print(lunluns[ind])
        break


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

int main(){
    int a,b;
    cin >> a >> b;
    int sam=0;
    for(int i=a;i<=b;i++){
        int s = i % 10;
        int u = i / 10 % 10;
        int v = i / 1000 % 10;
        int t = i / 10000 % 10;
        if(s==t&&u==v){
            sam++;
        }
    }
    cout << sam << endl;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ').map(Number);
    var w = args[0];
    var h = args[1];
    var x = args[2];
    var y = args[3];
    var r = args[4];
    console.log('%s', 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h ? 'Yes' : 'No');
});

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<int> v(N, 0);

  for(int i = 0; i < N-1; i++){
    int tmp; cin >> tmp;
    tmp--;
    v[tmp]++;
  }

  for(int i = 0; i < N; i++){
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 4012