akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int n, m, a, b, c;
 
int main() {
    vector<int> w(3);
    cin >> n >> m >> w[0] >> w[1] >> w[2];
    sort(w.begin(), w.end());
    a = w[0], b = w[1], c = w[2];
    vector<vector<set<int>>> ls(n + 1, vector<set<int>>(101));
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        ls[t][0].insert(s);
    }
 
    for (int i = 1; i <= c; i++) {
        for  (int j = 1; j <= n; j++) {
            for (auto k : ls[j][i - 1]) {
                for (auto l : ls[k][0]) {
                    ls[j][i].insert(l);
                }
            }
        }
    }
 
    set<int> slist;
    slist.insert(n);
    set<int> s;
    s.insert(n);
    vector<set<int>> touch(3);
    int turn = 0;
    bool flag = false;
    while (s.size()) {
        turn++;
        set<int> s_(s);
        s.clear();
        for (auto i : s_) {
            auto a_ = ls[i][a - 1];
            auto b_ = ls[i][b - 1];
            auto c_ = ls[i][c - 1];
            for (int j = 1; j <= n; j++) {
                if (
                        (a_.find(j) != a_.end() || touch[0].find(j) != touch[0].end())
                     && (b_.find(j) != b_.end() || touch[1].find(j) != touch[1].end())
                     && (c_.find(j) != c_.end() || touch[2].find(j) != touch[2].end())) {
                    if (slist.find(j) != slist.end()) continue;
                    slist.insert(j);
                    s.insert(j);
                }
                if (a_.find(j) != a_.end()) touch[0].insert(j);
                if (b_.find(j) != b_.end()) touch[1].insert(j);
                if (c_.find(j) != c_.end()) touch[2].insert(j);
            }
        }
        if (s.find(1) != s.end()) {
            flag = true;
            break;
        }
    }
 
    if (flag) {
        cout << turn << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 6972
#include <stdio.h>
void CountingSort(int *,int *,int);
int C[2000000],max=0;
int main(void){
  int n,A[2000000],B[2000000],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(max<A[i])max=A[i];
  }
  CountingSort(A,B,n);
  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  return 0;
}
void CountingSort(int *A,int *B,int k){
  int i;
  for(i=0;i<=k;i++)
    C[i]=0;

  /* C[i] に i の出現数を記録する */
  for(i=0;i<k;i++)
    C[A[i]]++;

  /* C[i] に i 以下の数の出現数を記録する*/
  for(i=1;i<=max;i++)
    C[i]=C[i]+C[i-1];

  for(i=k-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
}


Measured memory_bytes: 25176
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long long int ar[100013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//int sieve(long long int a)
//{
//    long long int i,j;
//    memset(ar,0,sizeof(ar));
//    for(i=2; i<=10013; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=10013; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    if(ar[a]==0)
//    {
//        return ar[a];
//    }
//}

void Ok()
{
    long int a,b,c,h,t,i = 0,j = 0,k,l,m,n;
    long int ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag = 0,temp,sum = 0;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc[113],ddd;
    string spc,in;

    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
            sum += i;
    }
    cout<<sum<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

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

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

int K;
int A, B;

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

    cin >> K;
    cin >> A >> B;

    bool flag = false;

    int k = K;

    while (k <= 1000) {
        if (A <= k && k <= B) {
            flag = true;
            break;
        }
        k += K;
    }

    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    
    return 0;
}

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

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    map<int, int> mp;
    ll tmp = N;
    for (int i = 2; i < sqrt(tmp) + 10; ++i) {
        if (N % i == 0) {
            while (N % i == 0) {
                N = N / i;
                mp[i] += 1;
            }
        }
    }
    if (N != 1) mp[N] += 1;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        for (int i = 1; itr->second >= 0; ++i) {
            itr->second -= i;
            if (itr->second >= 0) {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
<?php
$answer = 0;

fscanf(STDIN, "%d %d", $N, $M);
$origN = $N;
$origM = $M;
if ($N >= 5) {
    $HX = max(0, $N - 4);
    $N = 5;
}
if ($M >= 5) {
    $WX = max(0, $M - 4);
    $M = 5;
}
$sum = array_pad(array(), $N, '0');
foreach ($sum as $k => $v) {
    $sum[$k] = array_pad(array(), $M, 0);
}
// var_dump($sum);

for ($h = 0; $h < $N; $h++) {
    for ($w = 0; $w < $M; $w++) {
        $sum[$h][$w]++;
        if (isset($sum[$h-1][$w-1])) $sum[$h-1][$w-1]++;
        if (isset($sum[$h-1][$w  ])) $sum[$h-1][$w  ]++;
        if (isset($sum[$h-1][$w+1])) $sum[$h-1][$w+1]++;
        if (isset($sum[$h  ][$w-1])) $sum[$h  ][$w-1]++;
        if (isset($sum[$h  ][$w+1])) $sum[$h  ][$w+1]++;
        if (isset($sum[$h+1][$w-1])) $sum[$h+1][$w-1]++;
        if (isset($sum[$h+1][$w  ])) $sum[$h+1][$w  ]++;
        if (isset($sum[$h+1][$w+1])) $sum[$h+1][$w+1]++;
    }
}

// var_dump($sum);

for ($h = 0; $h < $N; $h++) {
    for ($w = 0; $w < $M; $w++) {
        if ($h == 2 && $HX != 0) {
            $tmpH = $origN - 4;
        } else {
            $tmpH = 1;
        }
        if ($w == 2 && $WX != 0) {
            $tmpW = $origM - 4;
        } else {
            $tmpW = 1;
        }
        $area = $tmpH * $tmpW;
        if ($sum[$h][$w] % 2 == 1) {
            $answer += $area;
        }
    }
}
echo $answer . PHP_EOL;


Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define int long long
#define MAX 2000006
#define NIL -1
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int h,A[MAX];
void maxheap(int i){
  int l=2*i;
  int r=2*i+1;
  int lgst;
  if(l<=h&&A[l]>A[i])lgst=l;
  else lgst=i;
  if(r<=h&&A[r]>A[lgst])lgst=r;
  if(lgst!=i){
    swap(A[i],A[lgst]);
    maxheap(lgst);
  }
}


signed main(){
  cin>>h;
  loop(i,1,h+1)cin>>A[i];
  for(int i=h/2;i>=1;i--)maxheap(i);
  loop(i,1,h+1)cout<<" "<<A[i];
  cout<<endl;

  return 0;
}

Measured memory_bytes: 6984
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int a, b; std::cin >> a >> b;
  std::string A;
  rep(i,b) A += std::to_string(a);
  std::string B;
  rep(i,a) B += std::to_string(b);
  if ( A < B ) std::cout << A << std::endl;
  else std::cout << B << std::endl;
  return 0;
}


Measured memory_bytes: 256
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())
i = 1
seta = set([s])
while True:
    s = f(s)
    if s in seta:
        break
    seta.add(s)
    i += 1
print(i + 1)

Measured memory_bytes: 3060
N = int(input())
siawaseList = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(3)] for __ in range(N)]

#初期値(添字0：a,添字1：b,添字2：cとする)
dp[0][0] = siawaseList[0][0]
dp[0][1] = siawaseList[0][1]
dp[0][2] = siawaseList[0][2] 
for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+siawaseList[i][0],dp[i-1][2]+siawaseList[i][0])
    dp[i][1] = max(dp[i-1][0]+siawaseList[i][1],dp[i-1][2]+siawaseList[i][1])
    dp[i][2] = max(dp[i-1][0]+siawaseList[i][2],dp[i-1][1]+siawaseList[i][2])
print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))

Measured memory_bytes: 47344
N, x = gets.split.map(&:to_i)
an = gets.split.map(&:to_i)

ans = 0

an.sort.each do |a|
  x = x - a
  ans += 1
  if x == 0
    break
  elsif x < 0
    ans -= 1
    break
  end
end

ans -= 1 if x > 0

puts ans

Measured memory_bytes: 14408
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] arr = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(arr[i], -1);
			int a = sc.nextInt();
			for (int j = 0; j < a; j++) {
				int x = sc.nextInt() - 1;
				int y = sc.nextInt();
				arr[i][x] = y;
			}
		}
		sc.close();

		int ans = 0;
		int end = 1 << n;
		for (int i = 0; i < end; i++) {
			int[] c = new int[n];
			Arrays.fill(c, -1);
			boolean flg = true;
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if ((i >> j & 1) == 1) {
					cnt++;
					c[j] = 1;
				}
			}
			label:
			for (int j = 0; j < n; j++) {
				if (c[j] == 1) {
					for (int k = 0; k < n; k++) {
						int y = arr[j][k];
						if (y == 1 && c[k] != 1) {
							flg = false;
							break label;
						}
						if (y == 0 && c[k] == 1) {
							flg = false;
							break label;
						}
					}
				}
			}
			if (flg) {
				ans = Math.max(ans, cnt);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24788
Scanf.scanf "%d %d %d %d" (fun r1 c1 r2 c2 ->
    let m = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( */) a b = ((a mod m) * (b mod m) ) mod m in
    let ( //) a b = a */ inv b m in
    let ( +/) a b = (a + b) mod m in
    let ( -/) a b = (((a - b) mod m) + m) mod m in

    let wholesum r c =
        let rec loop cur acc a b i =
            if i > c then acc else loop (cur */ a // b) (acc + cur) (a + 1) (b + 1) (i + 1)
        in
        loop (r + 1) 0 (r + 2) 2 0
    in
    let ans = wholesum r2 c2 -/ wholesum (r1 - 1) c2 -/ wholesum r2 (c1 - 1) +/ wholesum (r1 - 1) (c1 - 1) in
    Printf.printf "%d\n" ans
)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int ans = 0;
    int N = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (to_string(i).length() % 2 == 1) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;

vector<pp> edge[100010];

map<pp,pll> dp;
map<pp,int> E;

int nu[100010];
pll cc[100010];

inline void add(pll&a, pll b, ll d){
	a.x += b.x;
	a.y += b.y + d*b.x;
}
inline void del(pll&a, pll b, ll d){
	a.x -= b.x;
	a.y -= b.y + d*b.x;
}

pll f(int x, int from){
	pp key{x, from};
	auto it=dp.find(key);
	if(it != dp.end()) return it->second;
	
	if(nu[x]){
		add(cc[x], f(nu[x], x), E[pp{x, nu[x]}]);
		del(cc[x], f(from, x), E[pp{x, from}]);
		nu[x]=from;
		return dp[key]=cc[x];
	}
	
	cc[x].x=1;
	for(auto tmp:edge[x]){
		int y, d; tie(y, d) = tmp;
		if(y == from) continue;
		auto t = f(y, x);
		add(cc[x], t, d);
	}
	nu[x]=from;
	return dp[key]=cc[x];
}

int main()
{
	read(n);
	for(int i=1; i<n; ++i){
		int a, b, c;
		read(a, b, c);
		edge[a].eb(b, c);
		edge[b].eb(a, c);
		E[pp{a,b}]=c; E[pp{b,a}]=c;
	}
	ll ans = 0;
	for(int i=1; i<=n; ++i){
		ll mc = 0;
		ll ds = 0;
		int md = 1e9;
		int fmd = 0;
		for(auto tmp:edge[i]){
			int y, d; tie(y, d) = tmp;
			md = min(md, d);
			auto t=f(y, i);
			if(t.x == n/2 && n%2==0) fmd = d;
			mc=max(mc, t.x);
			ds+=t.y+t.x*d;
		}
		//printf("from %d: mc %lld, ds %lld\n", i, mc, ds);
		if(mc <= n/2) ans=max(ans, ds*2-(fmd?fmd:md));
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int n,a[100],t[40000000],p,num;
long long res;

void gen(int i,int s, int e, int sum) {
    if (i==e+1) {
        t[++num] = sum;
        return;
    }
    for (int j=0;j<=1;j++) {
        gen(i+1,s,e,sum+j*a[i]);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen("in.txt","r",stdin);
    cin>>n>>p;
    for (int i=1;i<=n;i++) cin>>a[i];
    long long c1=0,c2=0,l1=0,l2=0;
    gen(1,1,n/2,0);
    for (int i=1;i<=num;i++) {
        if (t[i]%2==0) c1++;
        else l1++;
    }
    num=0;
    gen(n/2+1,n/2+1,n,0);
    for (int i=1;i<=num;i++) {
        if (t[i]%2==0) c2++;
        else l2++;
    }
    if (p==0) cout<<c1*c2+l1*l2;
    else cout<<c1*l2+l1*c2;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long X, Y;
	cin >> X >> Y;
	int cnt = 1;
	while(X < Y) {
		X *= 2;
		if(X <= Y) ++cnt;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

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

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long c = in.nextLong();
			long[] x = new long[n], v = new long[n];
			for (int i = 0; i < n; i++) {
				x[i] = in.nextLong(); v[i] = in.nextLong();
			}

			// right
			long ans1 = 0;
			long cur = 0;
			for (int i = 0; i < n; i++) {
				cur += v[i];
				ans1 = max(ans1, cur - x[i]);
			}

			// left
			long ans2 = 0;
			cur = 0;
			for (int i = n - 1; i >= 0; i--) {
				cur += v[i];
				ans2 = max(ans2, cur - (c - x[i]));
			}

			// right -> left
			long ans3 = 0;
			cur = 0;
			long[] value = new long[n];
			for (int i = 0; i < n; i++) {
				cur += v[i];
				if (i == 0) {
					value[i] = cur - 2*x[i];
				} else {
					value[i] = max(cur - 2*x[i], value[i-1]);
				}
			}
			cur = 0;
			for (int i = n - 1; i > 0; i--) {
				cur += v[i];
				ans3 = max(ans3, cur - (c - x[i]) + value[i-1]);
			}

			// left -> right
			long ans4 = 0;
			cur = 0;
			value = new long[n];
			for (int i = n - 1; i >= 0; i--) {
				cur += v[i];
				if (i == n - 1) {
					value[i] = cur - 2*(c - x[i]);
				} else {
					value[i] = max(cur - 2*(c - x[i]), value[i+1]);
				}
			}
			cur = 0;
			for (int i = 0; i < n-1; i++) {
				cur += v[i];
				ans4 = max(ans4, cur - x[i] + value[i+1]);
			}

			out.println(max(max(ans1, ans2), max(ans3, ans4)));
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        string S; cin >> S;
        cout << S << endl;
        cout << S << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = G();
		var ans = 0;
		var cnt = new Dictionary<int, int>();
		foreach (var x in a)
		{
			if (!cnt.ContainsKey(x)) cnt[x] = 1;
			else cnt[x]++;
		}
		foreach (var x in cnt.Keys)
		{
			if (cnt[x] >= x) ans += cnt[x] - x;
			else ans += cnt[x];
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 27744
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
my $ans = $n;
for my $i (1..int($n/2)) {
  my $j = $n - $i;
  my $sum = sum0(split('', $i));
  $sum += sum0(split('', $j)) if $ans > $sum;
  $ans = $sum if $ans > $sum;
}
say $ans;

Measured memory_bytes: 768
from heapq import heappush, heappop, heapify, heapreplace

class Solution:
    def main(self):
        N, K = map(int, input().split())
        V = list(map(int, input().split()))
        res = 0
        for n_l in range(min(N, K)+1):
            for n_r in range(min(N-n_l, K-n_l)+1):
                array = sorted(V[:n_l] + V[N - n_r:])
                # print(n_l, n_r, array, end=' ')
                for n_d in range(0, min(K-n_l-n_r, len(array))):
                    if array[0] < 0:
                        array.pop(0)
                    else:
                        break
                res = max(res, sum(array))
                # print(array)
        print(res)


if __name__ == '__main__':
    Solution().main()

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

using namespace std;
typedef long long LL;

int main(){
  int N, L;
  cin >> N >> L;
  int sum=0;
  rep(i,N) sum+=L+i;
  if(L>0) sum-=L;
  if(L+N-1<0) sum-=L+N-1;
  cout << sum << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;

string s;

void solve(){
    bool c = false;
    REP(i,s.size()){
        if(s[i] == 'C'){
            c = true;
        }
        if(c==true && s[i] == 'F'){
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 384
def postorder(preo,ino):
    if preo:
        root = preo[0]
        inroot = ino.index(root)
        leftpre = preo[1:inroot+1]
        leftin = ino[:inroot]
        rightpre = preo[inroot+1:]
        rightin = ino[inroot+1:]
        postorder(leftpre,leftin)
        postorder(rightpre,rightin)
        post.append(root)

index = int(input())
preorder = [int(n) for n in input().split(' ')]
inorder = [int(n) for n in input().split(' ')]
post = []
postorder(preorder,inorder)
print(*post)

Measured memory_bytes: 7748
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [d] <- readInt
  put $ f d

f 25 = "Christmas"
f 24 = "Christmas Eve"
f 23 = "Christmas Eve Eve"
f 22 = "Christmas Eve Eve Eve"


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

string decrypt(string cr)
{
	string ret;
	for(int i=0;i<cr.size();i++)
	{
		//1文字のずらすやつの場合
		if(cr[i]=='+' || cr[i]=='-')
		{
			int cnt=0;
			while(cr[i]=='+' || cr[i]=='-')
			{
				if(cr[i]=='+')
					cnt++;
				if(cr[i]=='-')
					cnt--;
				i++;
			}
			//ずらす個数に従ってずらす
			ret+=(char)((((cr[i]-'A')+cnt)+130)%26+'A');
		}else if(cr[i]=='['){
			//反転の場合
			string tmp;
			int para=1;
			i++;
			while(para!=0)
			{
				tmp+=cr[i];
				if(cr[i]=='[')
					para++;
				if(cr[i]==']')
					para--;
				i++;
			}
			i--;
			tmp.resize(tmp.size()-1);
			//cerr<<tmp<<endl;
			tmp=decrypt(tmp);
			reverse(tmp.begin(),tmp.end());
			ret+=tmp;
		}else if(cr[i]>='A' && cr[i]<='Z'){
			//ただの文字
			ret+=cr[i];
		}
	}
	return ret;
}

string dfs(string cr,vector<int> q,int now)
{
	string tmp=cr;
	string ret="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
	if(now==q.size())
		return decrypt(tmp);
	for(int i=0;i<26;i++)
	{
		tmp[q[now]]=(char)('A'+i);
		ret=min(ret,dfs(tmp,q,now+1));
	}
	return ret;
}

int main()
{
	while(1)
	{
		string s;
		string ans;
		cin>>s;
		if(s==".")
			break;
		//?の位置を調べる
		vector<int> q;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='?')
				q.push_back(i);
		}

		//?にすべての文字を入れる全探索
		if(q.size()==0)
			ans=decrypt(s);
		else
			ans=dfs(s,q,0);
		
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3200
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

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

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	map<char, bool> used;
	for(auto &c : s) used[c] = true;
	for(int i = 0; i < 26; ++i) if(!used.count(static_cast<char>('a' + i))) return cout << static_cast<char>('a' + i) << '\n', 0;
	cout << "None\n";
}

Measured memory_bytes: 3716
#include <stdio.h>

int main(void){
    int m, n, tmp;

    scanf("%d %d", &m, &n);
    while (n != 0 || m!=0){
        if (m > n){
            tmp = m; m = n; n = tmp;
        }
        printf("%d %d\n", m, n);
        scanf("%d %d", &m, &n);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main(){
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		a[i]--;
	}

	ll s = 0;
	set<ll> v;
	while (1)
	{
		if(v.count(s) == 1){
			break;
		}
		v.insert(s);
		s = a[s];
		k--;
		if(k == 0){
			cout << s + 1 << endl;
			return 0;
		}
	}
	ll num = 0;
	ll now = s;
	while (a[now] != s){
		num++;
		now = a[now];
	}
	num++;
	now = s;
	k %= num;
	rep(i, k)
	{
		now = a[now];
	}
	cout << now+1 << endl;

	return 0;
}

Measured memory_bytes: 12236
# Problem https://atcoder.jp/contests/abc088/tasks/abc088_a
# Reference https://atcoder.jp/contests/abc088/submissions/7236946
# Ruby 1st Try
N = gets.chomp('\n').to_i
A = gets.chomp('\n').to_i
yes = "Yes"
no = "No"

modYen = N % 500
if modYen <= A
    puts(yes)
else
    puts(no)
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bits/stdc++.h>
#include <string>
#include <deque>
#include <array>
#include <tuple>
#include <forward_list>
#include <queue>
#include <stack>
#include <iterator>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>

const int N = 1e5+1;
int arr[N][3];
int dp[3];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }

    for(int i=0; i<3; i++) dp[i]=arr[0][i];

    for(int i=1; i<n; i++){
        int a = max(dp[1]+arr[i][0], dp[2]+arr[i][0]);
        int b = max(dp[0]+arr[i][1], dp[2]+arr[i][1]);
        int c = max(dp[0]+arr[i][2], dp[1]+arr[i][2]);
        dp[0] = a, dp[1] = b, dp[2] = c;
    }

    cout << max(dp[0], max(dp[1], dp[2])) << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
        d[i] /= 10;
    }
    int can1 = d[0];
    for (int i = 1; i < n; ++i) {
        if (d[i] > 0) {
            if (can1 < i) {
                cout << "no" << '\n';
                return 0;
            }
            can1 = max(can1, i + d[i]);
        } else {
            if (can1 <= i) {
                cout << "no" << '\n';
                return 0;
            }
        }
    }
    vector<int> dd(n);
    for (int i = 0; i < n; ++i) {
        dd[n - i - 1] = d[i];
    }
    int can2 = dd[0];
    for (int i = 1; i < n; ++i) {
        if (dd[i] > 0) {
            if (can2 < i) {
                cout << "no" << '\n';
                return 0;
            }
            can2 = max(can2, i + dd[i]);
        } else {
            if (can2 <= i) {
                cout << "no" << '\n';
                return 0;
            }
        }
    }
    cout << "yes" << '\n';
    return 0;
}


Measured memory_bytes: 5104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		System.out.println((N * (N - 1) / 2) + (M * (M - 1) / 2));
	}
}


Measured memory_bytes: 23764
def main():
    import sys
    input = sys.stdin.buffer.readline
    from bisect import bisect, bisect_left
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort()
    C.sort()
    ans = 0
    for b in B:
        a = bisect_left(A, b)
        c = N - bisect(C, b)
        ans += a*c
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 104664
N, X = [int(x) for x in input().split(' ')]

city = [abs(int(x) - X) for x in input().split(' ')]
max_fact = city[0]

for x in city:
    while x!=0:
        x %= max_fact
        if x > 0:
            tmp = max_fact
            max_fact = x
            x = tmp
    if max_fact==1:
        break

print(max_fact)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}

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

int wt[101];
int v[101];
int n,w;
ll dp[101][100001];

ll solve(ll w, ll i){
    if(i>n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    ll ans = solve(w,i+1);
    if(wt[i]<=w){
        ans = max(ans,v[i] + solve(w-wt[i],i+1));
    }
    return dp[i][w]=ans;
}

ll run() {
    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
    for(int i=1;i<=n;i++){
        cin>>wt[i]>>v[i];
    }
    cout<<solve(w,1);
}


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

int n;
map<int, int> cnt;

bool check() {
	int l = cnt.rbegin() -> first, h;
	if(l & 1) {
		if(cnt[l + 1 >> 1] != 2)
			return false;
		h = l + 3 >> 1;
	} else {
		if(cnt[l >> 1] != 1)
			return false;
		h = l + 2 >> 1;
	}
	for(int i = h; i <= l; ++i)
		if(cnt[i] < 2)
			return false;
	h -= 2;
	for(int i = 1; i <= h; ++i)
		if(cnt[i] > 0)
			return false;
	return true;
}

int main() {
	scanf("%d", &n);
	for(int i = 0, t; i <n ;++ i) {
		scanf("%d", &t);
		++cnt[t];
	}
	puts(check() ? "Possible" : "Impossible");	
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

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

  int ma = max(max(a,b),max(b,c));
  int mi = min(min(a, b), min(b, c));
  int mid = (a + b + c) - (ma + mi);

  cout << ma * 10 + mid + mi << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	int* h =new int[n];
  	for(int i=0;i<n;i++){
      cin>>h[i];
    }
  	int* dp=new int[n];
  	for(int i=n-1;i>=0;i--){
    	if(i==n-1)
          dp[i]=0;
      	else if(i==n-2)
          dp[i]=abs(h[i+1]-h[i])+dp[i+1];
        else
          dp[i]=min(abs(h[i+1]-h[i])+dp[i+1],abs(h[i+2]-h[i])+dp[i+2]);
      //cout<<dp[i]<<" ";
    }
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n; cin>>n;
    ll sq=sqrt(n),mind=n-1,t=1,t1=n;
    for(int i=sq;i>=1;i--){
        if((n%i)==0){
            if(abs((n/i)-i)<mind){
                mind=abs((n/i)-i); t=n/i; t1=i; break;
            }
        }
    }
    cout<<(t-1)+(t1-1);
    return 0;
}


Measured memory_bytes: 256
import Text.Printf
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s 
  let w = map acc v
  mapM_ putStrLn w

acc :: [Int] -> String
acc [a,b,c,d,e,f] = (printf "%.3f" $ x) ++ " " ++ (printf "%.3f" $ y)
  where
    eps = 1e-5
    det = fromIntegral(a*e - b*d) :: Double
    x = fromIntegral(e*c-b*f) / det + eps
    y = fromIntegral(-c*d+a*f) /det + eps

Measured memory_bytes: 4348
import java.util.*;
 
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int abc = sc.nextInt();
    int a = abc/100;
    int b = (abc-a*100)/10;
    int c = (abc-a*100-b*10)/1;
    
    System.out.println(a+b+c);
  }
}

Measured memory_bytes: 21844
package main

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

const MAX_ELEM = 10000

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	sorted := countingSort(elems)
	printlnInts(sorted)
}

func countingSort(as []int) []int {
	cs := make([]int, MAX_ELEM+1)
	for _, v := range as {
		cs[v] = cs[v] + 1
	}
	for i := 1; i < len(cs); i++ {
		cs[i] = cs[i] + cs[i-1]
	}
	bs := make([]int, len(as))
	for i := 0; i < len(as); i++ {
		bs[cs[as[i]]-1] = as[i]
		cs[as[i]] = cs[as[i]] - 1
	}
	return bs
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	rs := make([]int, n)
	for i, _ := range rs {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		rs[i] = x
	}
	return rs, nil
}

func printlnInts(xs []int) {
	rs := make([]string, len(xs))
	for i, _ := range rs {
		rs[i] = strconv.Itoa(xs[i])
	}
	fmt.Println(strings.Join(rs, " "))
}



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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){

	int n;cin >> n;
	cout << "Christmas";
	REP(i,25 - n){
		cout << " Eve";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
const long long inf=(long long)(1e12);
vector<vector<long long> >G;
vector<long long>dp;
vector<long long>points;
int n;
long long fun(int mask)
{
    if(dp[mask]!=-inf) return dp[mask];
    int i,j,k,sub;
    long long ans=-inf;
    int base=(~mask)&((1<<n)-1);
    for(sub=base;sub;sub=((sub-1)&base))
    {
        ans=max(ans,points[sub]+fun(mask|sub));
    }
    dp[mask]=ans;
    return ans;
}
void pre_compute()
{
    points.resize(1<<n);
    for(int i=0;i<(1<<n);i++)
    {
        points[i]=0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            for(int k=j+1;k<n;k++)
                if(i&(1<<k)) points[i]+=G[j][k];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,j;
    cin>>n;
    vector<long long>tmp(n);
    G.resize(n,tmp);
    for(i=0;i<n;i++)    for(j=0;j<n;j++)    cin>>G[i][j];
    pre_compute();
    dp.resize((1<<n),-inf);
    dp[(1<<n)-1]=0;
    for(i=0;i<n;i++) dp[1<<i]=0;
    cout<<fun(0);
}


Measured memory_bytes: 1408
#include<stdio.h>
#define MIN(x,y) ((x<y)?(x):(y))

int main(void){
  short map[50][50];
  int mins[50][50];
  int i,j,l,m;
  int h,w;
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%1hd",&map[i][j]);
    }
  }
  mins[0][0]=map[0][0];
  for(i=1;i<w;i++) mins[0][i]=map[0][i]+mins[0][i-1];
  for(i=1;i<h;i++){
    mins[i][0]=map[i][0]+mins[i-1][0];
    for(j=1;j<w;j++){
      mins[i][j]=map[i][j]+MIN(mins[i-1][j],mins[i][j-1]);
    }
  }
  printf("%d\n",mins[h-1][w-1]);
  return 0;
}

      

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n;
	cin >> n;
	int l[n], r[n], ans=0;
	for(int i = 0; i < n; i++){
		cin >> l[i] >> r[i];
	}
	for(int i = 0; i < n; i++){
		ans += r[i] - l[i] + 1;
	}
	cout << ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
  vector<int> vec(5);
  for (auto &v : vec)
    cin >> v;
  sort(vec.begin(), vec.end());
  int ans = INT_MAX;
  do {
    int tmp = 0;
    for (int i = 0; i < 4; ++i)
      tmp += (vec[i] + 9) / 10 * 10;
    tmp += vec[4];
    ans = min(ans, tmp);
  } while(next_permutation(vec.begin(), vec.end()));
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	vector<int> X(N);
	rep(i, N) cin >> X[i];

	int dist = 100000000;
	reple(i, 1, 100)
	{
		int tmp = 0;
		rep(j, N)
		{
			tmp += (X[j] - i) * (X[j] - i);
		}

		dist = min(tmp, dist);
	}

	cout << dist << endl;

	return 0;
}

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

def main():
    [H, W, K] = list(map(int, input().split()))

    if W == 1:
        print(1)
        return

    dp = []
    for h in range(H + 1):
        dp.append([0] * (W + 1))

    ft = [1, 1, 2, 3, 5, 8, 13, 21, 34]

    d = 10 ** 9 + 7
    dp[0][1] = 1
    for h in range(1, H + 1):
        for w in range(1, W + 1):
            v = dp[h - 1][w] * ft[w - 1] * ft[W - w]
            if 2 <= w:
                v += dp[h - 1][w - 1] * ft[w - 2] * ft[W - w]
            if w <= W - 1:
                v += dp[h - 1][w + 1] * ft[w - 1] * ft[W - w - 1]
            dp[h][w] = v % d

    print(dp[H][K])


if __name__ == '__main__':
    main()



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

int main(){
int N,T,A;
int C = 1001;
cin >> N >> T;
int c[N],t[N];
for(int i = 0;i<N;i++){
	cin >> c[i] >> t[i];
}
for(int i=0;i<N;i++){
	if(T>=t[i]){
		if(C>=c[i]){
			C = c[i];
		}
	}
}
if(C < 1001){
cout << C << endl;
}
else
cout << "TLE" << endl;
}


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

int main() {
  int N;
  cin >> N;
  int Sum =0;
  for (int i=0; i<N; i++){
  	int l,r;
    cin >> l >> r;
    Sum += r-l+1;
  	if (i+1==N){
      cout << Sum << endl;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int n, t, a, ans;
    cin>>n>>t>>a;
    double min = 2e9;
    int i, j;
    int h[n];
    for(i=0; i<n; i++){
        cin>>h[i];
        double hikaku =  (double)t-(double)h[i]*0.006-a;
        if(hikaku<0)
            hikaku *= -1;
        if(min>hikaku){
            min = hikaku;
            ans = i+1;
        }
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256