akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
	int n,l;
    cin>>n>>l;
        string s[105];
        for(int i = 0 ; i < n; i++ )
        {
            cin>>s[i];
        }
        sort(s,s+n);
        for(int j = 0 ; j < n ; j++ )
        cout<<s[j];

    return 0;
}


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

void t(){
  int N, a;
  cin>>N;
  int check = 1;
  int keep = 0;
  for(int i=0; i<N; i++){
    cin>>a;
    if(a == check){
      keep++;
      check++;
    }
  }
  if(keep==0)keep=N+1;
  cout<<N-keep<<endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int n;
	cin >> n;
	int l[n];
	int sum = 0;
	rep(i, n) {
		cin >> l[i];
		sum += l[i];
	}
	bool flag = true;
	rep(i, n) {
		if (l[i] >= sum - l[i]) {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;




	return 0;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

total = 0
for i in range(n):
    total += b[a[i] - 1]
    if i < n-1:
        if a[i] + 1 == a[i+1]:
            total += c[a[i]-1]
print(total)

Measured memory_bytes: 3064
a=1
while a==1:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    i=1
    while i<h+1:
        j=1
        while j<w+1:
            if (j%2==1and i%2==1)or(j%2==0and i%2==0):
                print('#', end="")
            else:
                print('.', end="")
            j+=1
        print('\n', end='')
        i+=1
    print('\n', end="")


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

constexpr int mod = 1e9 + 7;
int main() {
    // input
    int n, sum_c; scanf("%d%d", &n, &sum_c);
    vector<int> a(n); REP (i, n) scanf("%d", &a[i]);
    vector<int> b(n); REP (i, n) scanf("%d", &b[i]);
    // solve
    vector<int> cur(sum_c + 1);
    cur[0] = 1;
    REP (i, n) {
        vector<int> prv(sum_c + 1);
        cur.swap(prv);
        vector<ll> pow_x_c(b[i] - a[i] + 1, 1);
        REP (c_i, sum_c + 1) {
            ll sum_pow_x_a = 0;
            REP3 (x_i, a[i], b[i] + 1) {
                sum_pow_x_a += pow_x_c[x_i - a[i]];
                (pow_x_c[x_i - a[i]] *= x_i) %= mod;
            }
            sum_pow_x_a %= mod;
            REP (sum_a, sum_c + 1 - c_i) {
                auto & it = cur[sum_a + c_i];
                it += prv[sum_a] * sum_pow_x_a % mod;
                if (it >= mod) it -= mod;
            }
        }
    }
    // output
    printf("%d\n", cur[sum_c]);
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

print("YES" if -(-N//2) >= K else "NO")


Measured memory_bytes: 5148
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか

int main() {
	long long int n;
	cin >> n;
	map<long long int,long long int>s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s[a] = s[a] + 1;
	}
	long long int ans = 0;
	for (auto iter = s.begin(); iter != s.end(); iter++) {
		if (iter->first <= iter->second) {
			ans = ans + (iter->second - iter->first);
		}
		else {
			ans = ans + iter->second;
		}
	}
	cout << ans;

}

Measured memory_bytes: 6272
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long long H, N; cin >> H >> N;
  vector<int> A(N);
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    sum += a;
  }
  cout << (sum >= H ? "Yes" : "No") << endl;

}


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

int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort (a.begin(), a.end());
  reverse (a.begin(), a.end());
  
  int AliceScore = 0;
  for (int i = 0; 2 * i < N; i++) {
    AliceScore += a.at(2 * i);
  }
  
  int BobScore = 0;
  for (int i = 0; 2 * i + 1 < N; i++) {
    BobScore += a.at(2 * i + 1);
  }
  
  cout << AliceScore - BobScore << endl;
                             
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
PP x[200000],y[200000];
int n;
bool used[200000];
P mutu(int a){
	int z=0,ans=a;
	for(int i=lower_bound(x,x+n-1,PP(P(a,0),0))-x;x[i].F.F==a;i++){
		if(!used[x[i].S]){
			used[x[i].S]=true;
			P p=mutu(x[i].F.S);
			if(z<p.F+1){
				z=p.F+1;
				ans=p.S;
			}
			used[x[i].S]=false;
		}
	}
	for(int i=lower_bound(y,y+n-1,PP(P(a,0),0))-y;y[i].F.F==a;i++){
		if(!used[y[i].S]){
			used[y[i].S]=true;
			P p=mutu(y[i].F.S);
			if(z<p.F+1){
				z=p.F+1;
				ans=p.S;
			}
			used[y[i].S]=false;
		}
	}
	return P(z,ans);
}
signed main(){
	cin>>n;
	f(i,n-1){
		cin>>x[i].F.F>>x[i].F.S;
		y[i].F.F=x[i].F.S;
		y[i].F.S=x[i].F.F;
		x[i].S=i;
		y[i].S=i;
	}
	sort(x,x+n-1);
	sort(y,y+n-1);
	P p=mutu(1);
	p=mutu(p.S);
	if(p.F%3==1) puts("Second");
	else puts("First");
	return 0;
}


Measured memory_bytes: 25472
n,k = map(int,input().split())

########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################

a = Base_10_to_n(n, k)

print(len(a))

"""
#####関数をつかってみる．#####
######今回は二進数に変換######
x10 = 35
x2 = Base_10_to_n(x10, 2)
print( x2 )#"100011"が表示される．
#
#http://www.pursue.ne.jp/jouhousyo/sysad/sysad010.htm
#
"""


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    int m = n;
    int sum = 0;
    while (m) {
        sum += m % 10;
        m /= 10;
    }
    if (n % sum) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int max=a[0];
        int min=a[0];
        for(int i=0;i<n;i++){
            max=Math.max(max,a[i]);
            min=Math.min(min,a[i]);
        }
        System.out.println(max-min);
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n = stoi(to_string(a) + to_string(b));

    bool ans = false;
    for (int i = 0; i * i <= n; i++) {
        if (i * i == n) {
            ans = true;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    //start(0):S,end(N-1):Eと表記
    int SX = X-1;
    int XY = Y-X;
    int YE = N-1-Y;
    vector<int> dist(N-1);
    rep(i,N-1){
        for(int j = i+1; j < N; j++) {
            if(i<=X) {
                if(j<=(X+Y)/2) {
                    dist.at(j-i)++;
                }
                if((X+Y)/2<j&&j<=Y) {
                    dist.at(Y-j+1+X-i)++;
                }
                if(Y<j) {
                    dist.at(j-Y+1+X-i)++;
                }
            }
            else if(i<(X+Y)/2) {
                if(j<=Y) {
                    dist.at(min(j-i,Y-X+1-j+i))++;
                }
                if(Y<j) {
                    dist.at(j-Y+i-X+1)++;
                }
            }
            else if((X+Y)/2<=i) {
                dist.at(j-i)++;
            }
        }
    }
    rep(i,N-1){
        if(i==0) continue;
        cout << dist.at(i) << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

public class Main {

	static int count = 0;

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

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int a[] = new int[n];

		int num[] = new int[1000010];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
			num[a[i]]++;
		}

		Arrays.sort(a);

		Set<Integer> set = new HashSet<>();

		for (int i = 0; i < n; i++) {
			ArrayList<Integer> list = divisor(a[i]);

			boolean flag = false;
			for (int j = 0; j < list.size(); j++) {
				if (set.contains(list.get(j))) {
					flag = true;
					break;
				}
			}

			if (!flag) {
				set.add(a[i]);
				count++;
			}
		}

		set.forEach(new Consumer<Integer>() {
			@Override
			public void accept(Integer t) {
				if (num[t] != 1) {
					count--;
				}
			}
		});

		System.out.println(count);
	}

	public static final ArrayList<Integer> divisor(final int n) {
		final ArrayList<Integer> list = new ArrayList<>();

		for (int i = 1; i * i <= n; i++) { // √n
			if (n % i == 0) {
				list.add(i); // a x b
				if (i != n / i) {
					list.add(n / i); // b x a (逆向き)
				}
			}
		}
		return list;
	}
}


Measured memory_bytes: 79740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,ans=0,b,o,p;
	cin>>n>>a>>b>>o;
	for(int i=1;i<n;i++)
	{
		cin>>p;
		if((p-o)*a>b)ans+=b;
		else ans+=a*(p-o);
		o=p;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
 
int main(void){
    int n,s;
    int A[N];
    int i,j,k;
    int p;
    
    scanf("%d",&n);
    
    for(i = 0 ;i < n ;i++){        //????????????
        scanf("%d",&s);
        A[i] = s;
    }
 
    
    for(i=0;i<n;i++){
        p = A[i];
        j = i-1;
        while(j >= 0 && p < A[j]){        //?????\?????????
            A[j+1] = A[j];
            j--;
            A[j+1] = p;
        }
        for(j=0 ;j < n ;j++){
            printf("%d",A[j]);
            if(j == n-1) printf("\n");    //?????????????????¨?????¬?????????????????§?????¨??????
            else printf(" ");
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	int A,B,C,X;
	cin >> A >> B >> C >> X;
	
	int counter = 0;
	for(int a = 0; a <= A; a++){
		for(int b = 0; b <= B; b++){
			for(int c = 0; c <= C; c++){
				int money = 500 * a + 100 * b + 50 * c;
					if(money == X) counter++;				
			}
		}
	}
	
	
	cout << counter << endl;
	
	

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<vector<ll>>;
graph g;
ll n;
int main(){
    cin >> n;
    g.resize(n);
    for (ll i = 0; i < n; i++) {
        ll u, k; cin >> u >> k;
        for (ll j = 0; j < k; j++) {
            ll x; cin >> x;
            g[i].push_back(x-1);
        }
    }

    vector<ll> dist(n, -1);
    queue<ll> que;
    dist[0] = 0, que.push(0);
    while(!que.empty()){
        ll v = que.front(); que.pop();
        for(ll nv : g[v]){
            if(dist[nv] == -1){
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
    }
    for (ll i = 0; i < n; i++)  printf("%lld %lld\n", i+1, dist[i]);
        
    return 0;
}


Measured memory_bytes: 3252
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,t;
  scanf("%d%d",&n,&t);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int ans=0;
  int before=0;
  for(i=1;i<n;i++){
    if(a[i]-t>a[i-1]){
      ans+=a[i-1]+t-a[before];
      before=i;
    }
  }
  ans+=a[n-1]+t-a[before];
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void) {

  int n;

  int a[6000];

  while(1) {

    int max_a=-100000;
    int sum;

    int i,j;

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

    if(n==0) break;

    for(i=0;i<n;i++) scanf("%d",&a[i]);

    //for(i=0;i<n;i++) printf("%d ",a[i]);

    for(i=0;i<n;i++) {

      sum=0;

      for(j=i;j<n;j++) {

	sum+=a[j];

	if(max_a<sum) max_a=sum;
	//printf("%d ",max_a);
      }

    }
    
    printf("%d\n",max_a);

  }

  return 0;

}

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

int main(){
    int n;
    cin >> n;
    priority_queue<pair<int,int>> pq;
    for(int i = 0; i < n; i++){
        int s, t;   cin >> s >> t;
        pq.push({-t, s});
    }
    int now = 0, ans = 0;
    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        int f = p.second, e = -p.first;
        if(now < f){
            ans++;
            now = e;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		int A = io.nextInt();
		int B = io.nextInt();
		int C = io.nextInt();
		
		int uq = 101;
		while(uq!=0){
			uq = A%B;
			A = B;
			B = uq;
		}
		
		System.out.println((C%A==0)?"YES":"NO");
		
	}
		
}	

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a<=b*c){
    cout<< "Yes" <<endl;
  }
  else if(false){
    cout<< "" <<endl;
  }
  else{
    cout<< "No" <<endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


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


Measured memory_bytes: 3632
# ABC137C

from math import factorial
 
def unique(w):
    d = {}
    for c in w:
        if c in d.keys():
            d[c] += 1
        else:
            d.setdefault(c, 1)
    return list(d.values())
 
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
# s = sorted([''.join(sorted(list(t))) for t in s])
s = [''.join(sorted(list(t))) for t in s]
values = unique(s)
count = 0
for i in values:
    if i > 1:
        count += factorial(i) // factorial(2) // factorial(i - 2)
print(count)

Measured memory_bytes: 20048
s = str(input())
num = ['01','02','03','04','05','06','07','08','09','10','11','12']
if s[:2] in num and s[2:] in num:
    print("AMBIGUOUS")
elif s[:2] in num:
    print("MMYY")
elif s[2:] in num:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9008
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		if(Math.abs(a-c)<=d){
			System.out.println("Yes");
		} else if(Math.abs(a-b)<=d && Math.abs(b-c)<=d){
			System.out.println("Yes");
		} else System.out.println("No");
	}
}

Measured memory_bytes: 23892
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>
#include <queue>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;


int main() {
	vector<vector<pair<int, int>>> adjlist(100000, vector < pair<int, int>>());
	int r, D, x, i;
	cin >> r >> D >> x;
	for (i = 1; i <= 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
	return 0;

}



Measured memory_bytes: 2560
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, Z, W;
	cin >> N >> Z >> W;
	vector<LL>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	LL ans = abs(W - A[N - 1]);

	if (N >= 2) {
		ans = max(ans, abs(A[N - 2] - A[N - 1]));
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
dic = defaultdict(int)
dic[0] = 1
for i in range(1,N+1):
    S[i] = S[i-1] + A[i-1]
    dic[S[i]] += 1
ans = 0
for _,v in dic.items():
    if v > 0:
        ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 112976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t INF = 1LL << 60;

  int N;
  cin >> N;
  
  vector<int> h(N);
  for (int i=0; i<N; i++) cin >> h.at(i);
  
  vector<int64_t> dp(N+2, INF);
  dp.at(0) = 0;
  
  for (int i=0; i<N-1; i++) {
     dp.at(i + 1) = min( dp.at(i + 1), dp.at(i) + abs( h.at(i) - h.at(i + 1)) );
     if(i < N-2) dp.at(i + 2) = min( dp.at(i + 2), dp.at(i) + abs( h.at(i) - h.at(i + 2)) );
    }

  cout << dp.at(N-1) << endl;
  
  return 0;
}

Measured memory_bytes: 1408
//https://atcoder.jp/contests/abc042/tasks/arc058_b
//D - いろはちゃんとマス目 / Iroha and a Grid
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constexpr ll MOD=1e9+7;

const int MAX = 510000;
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() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H,W,A,B; cin>>H>>W>>A>>B;
    COMinit();
    ll ans = 0;
    ll h1=H-A-1;
    ll w1=B;
    ll h2=A-1;
    ll w2=W-B-1;
    for(ll i=0;i<W-B;++i){
        //h1+w1+i C h1
        //h2+w1-i C h2
        ll a = COM(h1+w1+i,h1);
        ll b = COM(h2+w2-i,h2);
        ans = ans + (a * b)%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
    return 0;
}
#if 0
int main() {
    int dp[3][100002]={};
    //int dp[3][10]={};
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H,W,A,B; cin>>H>>W>>A>>B;
    ll px=0,xx=0;
    dp[px][H] = 1;
    for(ll x=W;x>=1;--x){
        px=xx;
        xx=(xx+1)%3;
        for(ll y=H;y>=1;--y){
            if (x<=B && H-y+1<=A) {
                dp[xx][y] = 0;
                continue;
            }
            dp[xx][y] = (dp[px][y] + dp[xx][y+1])%MOD;
            //cout<<dp[xx][y]<<":"<<dp[px][y]<<","<<dp[xx][y+1]<<endl;
        }
    }
    cout<<dp[xx][1]<<endl;
    return 0;
}
#endif

Measured memory_bytes: 12160
def main():
    mod=1000000007
    inv=lambda x: pow(x,mod-2,mod)
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    B=A[::-1]
    ans=1
    if A[-1]<=0:
        if k%2==0:
            for a in A[:k]:
                ans*=a
                ans%=mod
        else:
            for a in B[:k]:
                ans*=a
                ans%=mod
        return ans
    if n==k:
        for a in A:
            ans*=a
            ans%=mod
        return ans
    Neg=[]; Pos=[]
    zero=0
    for a in A:
        if a>0:
            Pos.append(a)
        elif a<0:
            Neg.append(a)
        else:
            zero+=1
    if zero>n-k:
        return 0
    pos=len(Pos); neg=len(Neg)
    if neg==0:
        for a in B[:k]:
            ans*=a
            ans%=mod
        return ans
    for _ in range(zero):
        Neg.append(0)
    Neg.reverse()
    Pos.reverse()
    cnt=k
    while cnt>pos:
        cnt-=2
    Pos=Pos[:cnt]
    for p in Pos:
        ans*=p
        ans%=mod
    for _ in range(k-cnt):
        ans*=Neg.pop()
        ans%=mod
    while len(Pos)>=2 and len(Neg)>=2:
        p1=Pos.pop()
        p2=Pos.pop()
        n1=Neg.pop()
        n2=Neg.pop()
        if p1*p2<=n1*n2:
            ans*=inv(p1)*inv(p2)
            ans*=n1
            ans%=mod
            ans*=n2
            ans%=mod
        else:
            break
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 107844
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

cum_a = [a.first]
(1..n-1).to_a.each do |index|
  cum_a[index] = cum_a[index-1]+a[index]
end

minus_first_result = 0
minus_first_base = 0

(0..n-1).to_a.each do |index|
  current = cum_a[index]
  if index.even? && (revised = current+minus_first_base) >= 0
    minus_first_result += (revised+1)
    minus_first_base -= (revised+1)
  elsif index.odd? && (revised = current+minus_first_base) <= 0
    minus_first_result += (-1*revised+1)
    minus_first_base += (-1*revised+1)
  end
end


plus_first_result = 0
plus_first_base=0

(0..n-1).to_a.each do |index|
  current = cum_a[index]
  if index.even? && (revised = current+plus_first_base) <= 0
    plus_first_result += (-1*revised+1)
    plus_first_base += (-1*revised+1)
  elsif index.odd? && (revised = current+plus_first_base) >= 0
    plus_first_result += (revised+1)
    plus_first_base -= (revised+1)
  end
end


p [plus_first_result, minus_first_result].min


Measured memory_bytes: 14860
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

int main()
{
	int N, D;
	cin >> N >> D;
	std::vector<int> X(N * D);

	for (int i = 0; i < N * D; i++)
	{
		cin >> X[i];
	}

	int good = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int dist2 = 0;
			for (int k = 0; k < D; k++)
			{
				int d = X[i*D + k] - X[j*D + k];
				dist2 += d * d;
			}
			int dist = std::sqrt(float(dist2));
			if((dist2 == (dist-1) * (dist-1)) || (dist2 == dist * dist) || (dist2 == (dist+1) * (dist+1)) ){
				good++;
			}
		}
	}


	cout << good;
	return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer :: n, i, mi, res
  integer, allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) a(:)
  mi = 99999999
  res = 0
  do i = 1, n
    if (a(i) <= mi) res = res + 1
    mi = min(mi, a(i))
  end do
  write (*, "(i0)") res
end program main


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll a,b,k;
    cin >> a >> b >> k;
    if(k >= a+b) cout << 0 << " " << 0 << endl;
    else if(a < k) cout << 0 << " " << b - (k - a) << endl;
    else cout << a -k << " " << b << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9;
constexpr llong inf = mod * mod;

int main() {
  llong N;

  cin >> N;
  __int128_t ans = 1;
  for (int i = 0; i < N; ++i) {
    llong in;
    cin >> in;
    if (ans <= inf || in == 0) {
      ans *= in;
    }
  }
  if (ans > inf) {
    ans = -1;
  }

  cout << llong(ans) << endl;

  return 0;
}


Measured memory_bytes: 3636
s = gets.chomp.reverse

N = s.size
MOD = 2019

ans = 0
cnt = Array.new(MOD, 0)
total = 0
coef = 1

for i in 0...N do
    cnt[total] += 1
    total = (s[i].to_i * coef + total) % MOD
    ans += cnt[total]
    coef = (coef * 10) % MOD

    #p "i:#{i} ai:#{s[i]} coef:#{coef} total:#{total} ans:#{ans} cnt[#{total}]:#{cnt[total]}"
end

puts ans


Measured memory_bytes: 14948
N,M=map(int,input().split())
list1=[]
list2=[]
list3=[]
for i in range(N):
    list2=[]
    for j in range(N):
        list2.append(1111)
    list1.append(list2)
    
#print(list1)
for k in range(M):
    a,b,c=map(int,input().split())
    list3.append([a,b,c])
    list1[a-1][b-1]=c
    list1[b-1][a-1]=c
#print(list1)
#print(list3)
list2=list1

for a in range(N):
    for b in range(N):
        for c in range(N):
            if list2[b][a]+list2[a][c]<list2[b][c]:
                list2[b][c]=list2[b][a]+list2[a][c]
#print(list2)
count=0
for x in range(M):
    if list2[list3[x][0]-1][list3[x][1]-1]!=list3[x][2]:
        count+=1
print(count)


Measured memory_bytes: 3440
m,d = map(int,input().split())
ans = 0
if d < 10:
    print(ans)
else:
    for month in range(1,m+1):
        for day in range(10,d+1):
            if int(str(day)[0])*int(str(day)[1]) == month:
                if int(str(day)[1]) >= 2 and int(str(day)[0]) >= 2:
                    ans += 1
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>.
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<pair<ll,  ll>> jobs(N);

  rep(i,N){
    ll a, b;
    cin >> a >> b;
    jobs[i] = make_pair(b,a);
  }
  sort(jobs.begin(),jobs.end());

  ll time = 0;
  bool answer = true;
  for(int i = 0; i < N; i++){
    pair<ll, ll> cb = jobs[i];
    time += cb.second;
    if(time > cb.first) answer = false;
  }

  if(answer) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int B = -1;
    vector<int> a;
    rep(i,n){
        int ai; cin >> ai;
        if(B == -1) B = ai;
        else B ^= ai;

        a.push_back(ai);
    }
    rep(i,n){
        cout << (B^a[i]);
        if(i != n-1) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 4200
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static si R;

void solve(void) {
  cout << R * R << endl;
}

int main(void) {
  cin >> R;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>    
                       
int main() {           
    int h, w = 0;      
    char point1[2] = {'#', '.'};
    char point2[2] = {'.', '#'};
                       
    while(std::cin >> h >> w, h || w) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(i % 2 == 0) {
                    std::cout << point1[j%2];
                }else {
                    std::cout << point2[j%2];
                }      
            }          
            std::cout << std::endl;
        }              
        std::cout << std::endl;
    }                  
                       
    return 0;          
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define pii pair<int, int>
#define F first
#define S second
#define loop(i, s, n) for(int i = s; i < n; i++)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost;
    
    int n, k;
    cin >> n >> k;

    v(int) p(n), prefix_min(n);
    loop(i, 0, n) cin >> p[i];

    int ans = 1;

    set<int> s;
    loop(i, 0, k + 1) s.insert(p[i]);
    v(int) q(n - k + 1, 0);

    int flag = 0, j = 1;

    loop(i, 0, n - k + 1)
    {
        for(j = max(j, i + 1); j < i + k && j < n; j++)
        {
            if(p[j] < p[j - 1])
            {
                flag = 1;
                break;
            }
        }

        while(flag && i < j && i < n - k + 1)
        {
            q[i] = 1;
            i++;
        }
        if(flag == 1) flag = 0, i--;
    }

    flag = 0;
    loop(i, 1, n - k + 1)
    {
        int min_ = *s.begin();
        int max_ = *prev(s.end());

        if(min_ != p[i - 1] || max_ != p[i + k - 1])
        {
            if(!q[i]) flag = 1;
            else ans++;
        }
        
        s.erase(p[i - 1]);

      	if(i == n - k) continue;
        s.insert(p[i + k]);
    }
    if(flag == 1 && q[0] == 0) flag = 0;

    cout << ans + flag << nl;

    return 0;
}

Measured memory_bytes: 11264
package main

import (
	"fmt"
)

const MAX = 3000000
const MOD = 1000000007

var (
	fac  [MAX]int64
	finv [MAX]int64
	inv  [MAX]int64
)

func init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := int64(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
	}
}

func COM(n, k int) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}
func main() {
	var X, Y int
	fmt.Scanf("%d %d\n", &X, &Y)

	if (X+Y)%3 != 0 {
		fmt.Println(0)
		return
	}
	m := (2*X - Y) / 3
	n := (2*Y - X) / 3
	if m < 0 || n < 0 {
		fmt.Println(0)
		return
	}

	fmt.Println(COM(m+n, m))
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <limits.h>

#define MAX 2000000000

typedef struct
{
    int x;
    char c;
} card;

int Partition(int, int);
void Quicksort(int, int);
void merge(int, int, int, card[]);
void mergeSort(int, int, card[]);

card B[100000];

int main()
{
    int i, p, n;
    char c;
    card C[100000];

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

    for (i = 0; i < n; i++)
    {
        scanf("%c%d%c", &C[i].c, &C[i].x, &c);
        B[i] = C[i];
    }

    p = 0;

    mergeSort(0, n, C);
    Quicksort(0, n - 1);

    for (i = 0; i < n; i++)
    {
        if (C[i].c != B[i].c)
        {
            printf("Not stable\n");
            break;
        }

        if (i == (n - 1))
            printf("Stable\n");
    }

    for (i = 0; i < n; i++)
    {
        printf("%c %d\n", B[i].c, B[i].x);
    }

    return 0;
}

int Partition(int p, int r)
{

    card tmp;

    int x, i, j;

    x = B[r].x;
    i = p - 1;

    for (j = p; j < r; j++)
    {
        if (B[j].x <= x)
        {
            i++;
            tmp = B[i];
            B[i] = B[j];
            B[j] = tmp;
        }
    }

    tmp = B[i + 1];
    B[i + 1] = B[r];
    B[r] = tmp;
    return (i + 1);
}

void Quicksort(int p, int r)
{

    int q;

    if (p < r)
    {
        q = Partition(p, r);
        Quicksort(p, q - 1);
        Quicksort(q + 1, r);
    }
}

void merge(int left, int mid, int right, card A[])
{

    int i, j, k;

    int n1 = mid - left;
    int n2 = right - mid;

    card L[100001], R[100001];

    for (i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }

    for (i = 0; i < n2; i++)
    {
        R[i] = A[mid + i];
    }
    L[n1].x = MAX;
    R[n2].x = MAX;

    i = 0;
    j = 0;

    for (k = left; k < right; k++)
    {

        if (L[i].x <= R[j].x)
            A[k] = L[i++];
        else
            A[k] = R[j++];
    }
}

void mergeSort(int left, int right, card A[])
{

    if ((left + 1) < right)
    {
        int mid = (left + right) / 2;
        mergeSort(left, mid, A);
        mergeSort(mid, right, A);
        merge(left, mid, right, A);
    }
}


Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int x, t;
  scanf("%d%d", &x, &t);
  printf("%d\n", t < x ? x - t : 0);
 
  return 0;
}


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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	int x[100000];
	rep(i,n) scanf("%d",x+i);

	lint ans=INF;
	rep(i,n-k+1){
		lint l=x[i],r=x[k+i-1];
		if(r<=0){
			ans=min(ans,-l);
		}
		else if(0<=l){
			ans=min(ans,r);
		}
		else{
			ans=min({ans,r-2*l,2*r-l});
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, val;
    cin >> n;
    unordered_map<int, int> cnt;
    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[val] += 1;
    }
    int ans = 0;
    for(auto p: cnt) {
        if (p.first <= p.second)
            ans += p.second - p.first;
        else
            ans += p.second;
    }
    cout << ans << endl;
    return 0;
}




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

int main() {
	int r;
	bool band=false;
	cin>>r;
	for (int a=1; a<10;a++) {
		for (int b=1; b<10;b++) {
			if (a*b==r)
				band=true;
		}
	}
	if (band)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=n-1;i>=0;--i){
        cout << a[i];
        if(i!=0) cout << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3076
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int[] p = new int[10000];
	putN(p);
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int i=0;
		int s=0;  //連続した素数の和
		int l=0;  //連続素数のうち最小
		int c = 0;  //表現できたパターン数
		while(p[i]!=0){
		    if(s < n) {
			s += p[i];
			i++;
		    }
		    else if(s>n){
			s -= p[l];
			l++;
		    }
		    else;

		    if(s==n) {
			c++;
			s += p[i];
			i++;
		    }
		}	 
		System.out.println(c);
	    }
	}
    }

    
    
    
    static void putN(int[] p){
	int i=0, k;
	for(k=2; k<10000; k++){
	    if(check(k)) {
		p[i] = k;
		//System.out.print(p[i]+" ");
		i++;
	    }
	}

    }
    static boolean check(int n){
	int a, c=0;
	for(a=1; a<=n; a++){
	    if(n%a==0) c++;
	}
	if(c>2) return false;
	return true;
    }    
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	ll ans = 0;
	cin >> n;
	ans += n / 500 * 1000;
	n %= 500;
	ans += n / 5 * 5;
	cout << ans << endl;
}


Measured memory_bytes: 256
type bs_tree = Nil | Node of node and
     node = {
         key:int;
         mutable left:bs_tree;
         mutable right:bs_tree
       };;

let new_node key = {key=key;left=Nil;right=Nil};;

let insert t z =
  let rec loop y = function
      Nil -> y
    | Node x ->
       if z.key < x.key then
         loop (Node x) (x.left)
       else
         loop (Node x) (x.right)
  in
  let y = loop t t in
  match y with
    Nil -> (Node z)
  | Node y ->
     if z.key < y.key then
       y.left <- (Node z)
     else
       y.right <- (Node z)
    ;t
;;

let rec print_in = function
    Nil -> ()
  | Node x ->
     print_in (x.left);
     Printf.printf " %d" x.key;
     print_in (x.right)
;;

let rec print_pre = function
    Nil -> ()
  | Node x ->
     Printf.printf " %d" x.key;
     print_pre (x.left);print_pre (x.right)
;;

let () =
  let n = read_int () in
  let rec read t = function
      0 -> ()
    | i ->
       let com = Scanf.scanf "%s" (fun x -> x) in
       if com = "insert" then begin
           let arg = Scanf.scanf " %d\n" (fun x -> x) in
           let z = new_node arg in
           read (insert t z) (i-1)
         end
       else if com = "print" then begin
           let _ = Scanf.scanf "%s\n" (fun x -> x) in
           print_in t;print_newline ();
           print_pre t;print_newline ();
           read t (i-1)
         end
       else ()
  in read Nil n
;;

Measured memory_bytes: 28372
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	int N; SCD(N);
	double p[3001] = {};
	FORq(i,1,N){
		cin >> p[i];
	}

	static double dp[3002][3002] = {};
	dp[0][0] = 1;

	FORq(i,1,N){
		FORq(x,0,N){
			if (x==0) dp[i][x] = dp[i-1][x] * (1- p[i]);
			else dp[i][x] = dp[i-1][x] * (1-p[i]) + dp[i-1][x-1] * p[i];	
		}
	}

	double ans = 0;
	FORq(i,0,N){
		if (N-i < i){
			ans += dp[N][i];
		}
	}

	cout << setprecision(10) <<  ans << "\n";
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
double x[200000],y[200000];
char d[200000][2];
int dx[]{1,-1,0,0},dy[]{0,0,1,-1};
map<char,int>dir;

double f(double t,int mode){
	double Min=-1,Max=-1;
	rep(i,n){
		double X;
		if(mode==0)X=x[i]+dx[dir[d[i][0]]]*t;
		else X=y[i]+dy[dir[d[i][0]]]*t;
		if(i==0){
			Min=Max=X;
		}
		else{
			Min=min(Min,X);
			Max=max(Max,X);
		}
	}
	return Max-Min;
}
int main(){
	dir['R']=0;
	dir['L']=1;
	dir['U']=2;
	dir['D']=3;
	cin>>n;
	rep(i,n){
		scanf("%lf%lf%s",&x[i],&y[i],d[i]);
	}
	double l=0,r=1e15;
	rep(i,200){
		double l1=(l+l+r)/3;
		double l2=(l+r+r)/3;
		if(f(l1,0)*f(l1,1)<f(l2,0)*f(l2,1))r=l2;
		else l=l1;
	}
	printf("%.12lf\n",f(l,0)*f(l,1));
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	string s,t;
	cin >> s >> t;
	int ls=s.length(),lt=t.length(); 
	int max1=0;
	for(int i=0;i<=ls-lt;i++){
		int sum=0;
		for(int j=0;j<lt;j++){
			if(s[i+j]==t[j]){
				sum++;
			}
		}
		max1=max(sum,max1);
	}
	cout << lt-max1 << endl;
	return 0;
}

/**
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	string s,t;
	cin >> s >> t;
	int ls=s.length(),lt=t.length();
	int min1=0x3f3f3f3f;   //无穷大 
	for(int i=0;i<=ls-lt;i++){
		int sum=0;
		for(int j=0;j<lt;j++){
			if(s[i+j]!=t[j]){
				sum++;
			}
		}
		min1=min(sum,min1);
	}
	cout << min1 << endl;
	return 0;
}
**/

Measured memory_bytes: 3172