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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> A(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
	}

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

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

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
  char s[0];
  scanf("%s", &s);

  if (s[0] == 'S')
    printf("Cloudy");
  if (s[0] == 'C') 
    printf("Rainy");
  if (s[0] == 'R') 
    printf("Sunny");

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
  char s[27];
  int chara[27];
  int i=0;
  for(i=0;i<26;i++)
    chara[i]=0;
  scanf("%s",s);
  int len=strlen(s);
  for(i=0;i<len;i++){
    chara[s[i]-'a']++;
    if(chara[s[i]-'a']==2){
      puts("no");
      return 0;
    }
  }
  puts("yes");
  return 0;
}

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

using namespace std;

#define ll long long

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, m;
	cin >> n >> m;
	vector<int> a(m);
	int sum = 0;
	
	for(int i = 0; i < m; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	if(sum > n) cout << -1 << "\n";
	else cout << n - sum << "\n";
	
	return 0;
}


Measured memory_bytes: 3688
use std::io;

fn main() {

	let mut line = String::new();
	io::stdin().read_line(&mut line).expect("Failed to read line.");

	let n : &str = line.trim();

	let mut chk : i64 = 0;
	for c in n.chars() {
		// chk += c.parse().unwrap();
		chk += c as i64 - '0' as i64;
		// println!("{},{}", c as i64, '0' as i64);
	}

	// println!("{}", chk);

	let mut ans : &str = "No";
	if chk % 9 == 0 {
		ans = "Yes";
	}


	println!("{}", ans );

}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int h,w; cin >> h >> w;
  int k; cin >> k;
  char c[10][10];
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> c[i][j];
    }
  }
  int ans = 0;
  for(int i = pow(2,h)-1; i >= 0; i--){
    for(int j = pow(2,w)-1; j >= 0; j--){
      int cnt = 0;
      for(int k = 0; k < h; ++k){
	for(int l = 0; l < w; ++l){
	  if(((1<<k)&i) == (1<<k) && ((1<<l)&j) == (1<<l)){
	    if(c[k][l] == '#')cnt++;
	  }
	}
      }
      ans += cnt == k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1]&&a[1]!=a[2])
        cout<<"Yes";
    else if(a[1]==a[2]&&a[0]!=a[1])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
import itertools

H, W, K = map(int, input().split())
C = []

for i in range(H):
  c = list(input())
  C.append(c)
  
ans = 0

for h in itertools.product([0, 1], repeat = H):
  for w in itertools.product([0, 1], repeat = W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if h[i] == 0 and w[j] == 0 and C[i][j] == "#":
          cnt += 1
    if cnt == K:
      ans += 1

print(ans)

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

vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}


int main(){
  int N;
  cin >> N;
  int sum = 0;
  
  vector<int> V, C;
  V = input(N);
  C = input(N);

  for (int i = 0; i < N; i++){
    if((V.at(i) - C.at(i)) > 0){
      sum += V.at(i) - C.at(i);
    }
  }
  
  cout << sum << endl;
  
};


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

ll n;
ll ans = 0;
vll d;

vll t;

void dfs(ll idx) {
  if (idx == n) {
    ll lst = 0;
    ll v = INF;
    REP(i, 24) {
      if (t[i]) {
        chmin(v, i - lst);
        chmin(v, 24 - i + lst);
        lst = i;
      }
    }
    chmin(v, 24 - lst);
    chmin(v, lst);

    chmax(ans, v);
  }

  if (d[idx] == 0) {
    return;
  }

  if (t[d[idx]] == 0) {
    t[d[idx]] = 1;
    dfs(idx + 1);
    t[d[idx]] = 0;
  }

  if (t[24 - d[idx]] == 0) {
    t[24 - d[idx]] = 1;
    dfs(idx + 1);
    t[24 - d[idx]] = 0;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cin >> n;
  d = vll(n);

  t = vll(24);
  rep(i, n) {
    cin >> d[i];
  }

  if (n >= 25) {
    cout << 0 << endl;
    return 0;
  }

  dfs(0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    int res = 300;
    FOR(i, 0, n) {
        FOR(j, 0, n) {
            string conc = s.substr(0, i) + t.substr(j, n-j);
            if (conc.size() >= n && conc.substr(0, n) == s && conc.substr(conc.size()-n, n) == t) {
                res = min(res, (int)conc.size());
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a =  sc.nextInt();
		int b =  sc.nextInt();
		int c =  sc.nextInt();
		int p;
		int num=0;
		for (int i=a; i<=b; i++){
			p = c%i;
			if(p == 0){
				num++;
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 26264
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

last = a
if b % 10 != 0 and (last % 10) > (b % 10):
    last = b
if c % 10 != 0 and (last % 10) > (c % 10):
    last = c
if d % 10 != 0 and (last % 10) > (d % 10):
    last = d
if e % 10 != 0 and (last % 10) > (e % 10):
    last = e

target = [a, b, c, d, e]
target.remove(last)
ans = 0
for v in target:
    ans += (((v + 10 - 1) // 10) * 10)
ans += last
print(ans)


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

using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	ll K;
	cin >> K;
	for (int i = 0; i < s.size(); i++) {
		int cost = 'z' - s[i] + 1;
		if (cost == 26)cost = 0;
		if (cost <= K) {
			s[i] = 'a', K -= cost;
		}
	}
	K %= 26;
	for (int i = 0; i < K; i++) {
		s[s.size() - 1]++;
		if (s[s.size() - 1] > 'z')s[s.size() - 1] = 'a';
	}
	cout << s << endl;
	return 0;
}

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

int main() {
  string S,T;
  cin >>S>>T;
  bool ans=true;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i))
      ans=false;
  }
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

int main() {
	ll n;
	cin >> n;
	ll a[n];
	for(ll i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	ll res=0;
	for(ll rig=n-1;rig>=2;rig--){
		for(ll mid=rig-1;mid>=1;mid--){
			if(a[rig]>=a[mid]+a[mid-1]) continue;
			if(a[rig]<a[mid]+a[0]){
				res+=mid;
				continue;
			}
			ll l=0;
			ll r=mid-1;
			ll m=(l+r)/2;
			while(1){
				if(a[rig]>=a[mid]+a[m]&&a[rig]<a[mid]+a[m+1]){
					res+=mid-m-1;
					break;
				}
				if(a[rig]>=a[mid]+a[m]&&a[rig]>=a[mid]+a[m+1]){
					l=m+1;
					m=(l+r)/2;
				}
				if(a[rig]<a[mid]+a[m]&&a[rig]<a[mid]+a[m+1]){
					r=m;
					m=(l+r)/2;
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

template<class T> struct BIT {
  int n;
  V<T> t;

  BIT(int n) : n(n) {
    t.assign(n + 1, 0);
  }

  void add(int i, int a) {
    for (i++; i < n + 1; i += i & -i) t[i] += a;
  }

  T sum(int l, int r) {
    T res = 0;
    for (; r; r -= r & -r) res += t[r];
    for (; l; l -= l & -l) res -= t[l];
    return res;
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  auto chk = [&](int x) {
    V<> c(n + 1);
    c[0] = n;
    for (int i = 0; i < n; i++) c[i + 1] = c[i] + (a[i] >= x ? 1 : -1);
    lint s = 0;
    BIT<int> bit(2 * n + 1);
    for (int i = 0; i < n + 1; i++) {
      s += bit.sum(0, c[i] + 1);
      bit.add(c[i], 1);
    }
    return 4 * s >= (lint) n * (n + 1);
  };
  V<> b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  b.push_back(2e9);
  auto l = b.begin(), r = --b.end();
  while (r - l > 1) {
    auto m = l + (r - l) / 2;
    if (chk(*m)) l = m;
    else r = m;
  }
  cout << *l << '\n';
}

Measured memory_bytes: 2280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    FAST
    int n,m;
    cin>>n>>m;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    multiset<int>adj[n];
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        u--,v--;
        adj[u].insert(h[v]);
        adj[v].insert(h[u]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(adj[i].size()==0){
            ans++;
            continue;
        }
        if(h[i]>(*adj[i].rbegin())) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 18040
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;

int n, k;
int arr[N];
int fenw[N];
long long b[N];
vector < pair <long long, int> > vec;

void update(int i, int val) {
  for (; i < N; i += i & (-i)) {
    fenw[i] += val;
  }
}

int query(int i) {
  int ans = 0;
  for (; i > 0; i -= i & (-i)) {
    ans += fenw[i];
  }
  return ans;
}

int query(int x, int y) {
  return (query(y) - (x > 1 ? query(x - 1) : 0));
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    b[i] = sum - 1ll * (i + 1) * k;
    vec.push_back({b[i], i + 2});
  }
  vec.push_back({0, 1});
  sort(vec.begin(), vec.end());
  long long ans = 0;
  for (int i = 0; i < vec.size(); i++) {
    ans += query(vec[i].second);
    update(vec[i].second, 1);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8304
def li():
    return [int(x) for x in input().split()]


INF = 10 ** 60

N, W = li()
L = [li() for i in range(N)]
V = 10 ** 5
# W <= 10**9 なので、
# dp[i][w]: i番目の選択で重さwだった時の価値の最大値、は計算量厳しい
# dp[i][v]: i番目の選択で価値vだった時の重さの最小値、で考えて重さの最小値がW以下のものから最大価値を算出する

dp = [[INF] * (V+1) for _ in range(N)]

# 初期条件
# 選ばない
dp[0][0] = 0
# 選ぶ
w0, v0 = L[0]
dp[0][v0] = w0

for i in range(1, N):
    for v in range(V+1):
        cw, cv = L[i]
        # 選ばない
        dp[i][v] = min(dp[i][v], dp[i-1][v])
        # 選ぶ
        if v + cv > V:
            continue
        dp[i][v+cv] = min(dp[i][v+cv], dp[i-1][v] + cw)

# 重さの最小値がW以下で達成できるvの最大値
v_max = 0
for v in range(V+1):
    if dp[N-1][v] <= W:
        v_max = v
print(v_max)

Measured memory_bytes: 164048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N,T,A;
   cin>>N>>T>>A;
   map<double,int> data;
   int H;
   double m=1000;
   rep(i,N){
        cin>>H;
        data[abs(A-T+0.006*H)]=i+1;
        m=min(m,abs(A-T+0.006*H));
   
    }
    cout<<data[m]<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+5;
const ll mod=1e9+7;
vi v(MAX);
vi pref(MAX);
ll dp[405][405];
/*
ll  fun(ll i,ll k)
{
    if(k==i)
        return 0;
        if(dp[i][k]!=-1)
            return dp[i][k];
    ll ans=1e18;
    for(ll j=i;j<k;j++)
    {
        ans=min(ans,fun(i,j)+fun(j+1,k)+pref[k]-pref[i-1]);
    }
    return dp[i][k]=ans;
}*/
ll fun(ll n)
{
    for(ll i=1;i<=n;i++)
        dp[i][i]=0;
    for(ll len=2;len<=n;len++)
    {
        for(ll i=1;i<=n-len+1;i++)
        {
            ll val=1e18;
            for(ll k=i;k<=i+len-2;k++)
            {
                val=min(val,dp[i][k]+dp[k+1][i+len-1]+pref[i+len-1]-pref[i-1]);
            }
            dp[i][i+len-1]=val;
        }
    }
    /*
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            cout<<dp[i][j]<<"  ";
        }
        cout<<endl;
    }*/
    return dp[1][n];
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {

   ll n,k;
   cin>>n;
   pref[0]=0;
   rep(i,1,n+1)
   {
       cin>>v[i];
       pref[i]=pref[i-1]+v[i];

   }
   cout<<fun(n);
    }
    return 0;
}


Measured memory_bytes: 3072
n=int(input())
k=[0,0,0,0]
for _ in range(n):
    a=input()
    if a=="AC":
        k[0]+=1
    elif a=="TLE":
        k[2]+=1
    elif a=="WA":
        k[1]+=1
    else:
        k[3]+=1
print("AC x "+str(k[0]))
print("WA x "+str(k[1]))
print("TLE x "+str(k[2]))
print("RE x "+str(k[3]))


Measured memory_bytes: 9068
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    // 2019 = 3*673
    string S;
    cin >> S;


    ll mod2019[2019] = {};

    mod2019[(S[0]-'0')%2019] = 1;

    ll ans=0;
    for(int j=1; j<S.length(); j++){
        ll new_mod2019[2019] = {};
        for(int n=0; n<2019; n++){
            new_mod2019[(n*10+(S[j]-'0'))%2019] = mod2019[n];
        }
        for(int n=0; n<2019; n++){
            mod2019[n] = new_mod2019[n];
        }
        mod2019[(S[j]-'0')]++;
        ans+=mod2019[0];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3752
s = input()
t = input()
lt = len(t)

def dif(s, t):
    count = 0
    for i in range(lt):
        if s[i] != t[i]:
            count += 1
    return count

if t in s: print(0)
else:
    ans = float('inf')
    for i in range(len(s)-lt+1):
        ans = min(ans, dif(s[i:i+lt], t))
    print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int K;


int S(llint n){
	int sum = 0;
	do {
		sum += n%10;
	} while(n/=10);
	return sum;
}


double snukeV(llint n){
	return (double)n/S(n);
}


void solve(){
	VLL ans;
	llint base = 1;
	rep(i, 0, 15){
		rep(j, 1, 150){
			ans.pb(base*(j+1)-1);
		}
		base *= 10;
	}
	sort(ALL(ans));
	ans.erase(unique(ALL(ans)), ans.end());
	rep(i, 0, SIZE(ans)){
		rep(j, i+1, SIZE(ans)){
			if(snukeV(ans[i]) > snukeV(ans[j])){ ans.erase(ans.begin()+i--); break; }
		}
	}
	rep(i, 0, K) cout << ans[i] << endl;
}


signed main(){
	cin >> K;

	solve();

	return 0;
}

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

int main() {
  string N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N.size(); i++) {
    sum += (int)N.at(i) - 48;
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
} 

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n,a);

    lli l = 0;
    lli r = 1;
    lli cur_xor = a[0];
    lli cur_sum = a[0];
    lli ans = 0;
    // l に対してどこまで r が対応できるかを見ていく
    for (l = 0; l < n; l++) {
        while (true) {
            if (r != n && (cur_xor^a[r]) == cur_sum + a[r]) {
                cur_xor ^= a[r];
                cur_sum += a[r];
                r++;
            }
            else {
                // l から r-1 までを加算
                ans += r - l;
                //cout3(l,r, r - l);
                break;
            }
        }

        // 今の l を消す
        cur_xor ^= a[l];
        cur_sum -= a[l];
    }
    cout << ans << endl;
}


// 5 5 2 4 1 1
//
// 1 0 1
// 0 1 0
// 1 0 0
// 0 0 1
// 0 0 1
//
// => 9



// 6 8 1 2 9 4 4
//
// 1 0 0 0
// 0 0 0 1
// 0 0 1 0
// 1 0 0 1
// 0 1 0 0
// 0 1 0 0
//
// => 12


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
using namespace std;

int main() {
	int n, l, ans = 1000, sum = 0, Ans;
	cin >> n >> l;
	for (int i = 1; i <= n; i++) {
		sum += l + i - 1;
	}
	for (int i = 1; i <= n;i++) {
		if (ans>abs(l+i-1)){
			Ans = l+ i - 1;
			ans = abs(l + i - 1);
		}
	}
	cout << sum - Ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  string s,t;
  cin >> s >> t;
  ll ans=MAX;
  rep(i,s.size()-t.size()+1) {
    string r=s.substr(i,t.size());
    ll cnt=0;
    rep(j,r.size()) {
      if(r[j]!=t[j]) cnt++;
    }
    ans=min(ans,cnt);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
ll n,ans=1e13;
int main()
{
    n=read();reg ll i;
    for(i=1;i*i<=n;++i)
    {
        if(n%i)continue;
        ans=min(ans,i+n/i-2);
    }cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int mod = 1000000007;
int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    vector<vector<ll>> dp(s.size()+1,vector<ll>(13));
    dp[0][0] = 1;
    int x = 1;
    rep(i,s.size()){
        if(s[i]!='?'){
            int num = s[i]-'0';
            rep(j,13){
                int p = (j+num*x)%13;
                dp[i+1][p] += dp[i][j];
                dp[i+1][p] %= mod;
            }
        }else{
            rep(num,10){
                rep(j,13){
                    int p = (j+num*x)%13;
                    dp[i+1][p] += dp[i][j];
                    dp[i+1][p] %= mod;
                }
            }
        }
        x *= 10;
        x %= 13;
    }
    cout << dp[s.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,b;
	set<int> a;
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>b;
        a.insert(b);
    }
    if(a.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=1e5+10,size=1<<20,mod=998244353,inf=2e9;
const ll INF=1e15;

//char buf[size],*p1=buf,*p2=buf;
TP void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
TP void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
TP void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
TP void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

//math
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
    ll c=1;
    while(b) {
        if(b&1) c=c*a%mod;
        b /= 2; a=a*a%mod;
    }
    return c;
}

TP void cmax(o &x,o y) {if(x < y) x=y;}
TP void cmin(o &x,o y) {if(x > y) x=y;}

//dbinom

ll jc[N],inv[N];
void init(int n) {
	jc[0]=1; for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
	inv[n]=power(jc[n]); for(int i=n;i;i--) inv[i-1]=inv[i]*i%mod;
}
ll C(int x,int y) {
	if(x<y || y<0) return 0;
	return jc[x]*inv[y]%mod*inv[x-y]%mod;
}

int n,a[N],sum,m;
ll f[N],g[N],t[N];

void solve() {
	qr(n); m=2*n;
	for(int i=1,x;i<=m;i++) qr(x),a[x]++;
	f[0]=g[0]=1; init(2*n);
	for(int i=1,j=1;i<=n;i++) g[i]=(ll)j*(j+1)/2%mod*g[i-1]%mod,j += 2;
	for(int i=1;i<=n;i++) g[i]=g[i]*inv[i]%mod;
	for(int i=1,len;i<N;i++) if(a[i]>1) {
		len = a[i]/2;
		for(int k=1;k<=len;k++) t[k]=C(a[i],2*k)*g[k]%mod;
		for(int j=sum;j>=0;j--)
			for(int k=1;k<=len;k++)
				f[j+k]=(f[j+k]+f[j]*t[k])%mod;
		sum += len;
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans += (i&1?mod-1:1)*f[i]%mod*g[n-i]%mod;
	pr2((ans%mod+mod)%mod);
}

int main() {
	int T=1;
//	qr(T);
	while(T--)
		solve();
}


Measured memory_bytes: 6348
fun main(args : Array<String>) {
    val n = readLine()!!

    if (n.toLong() < 10) {
        println(n)
        return
    }

    if (n.takeLast(n.length-1).all { it == '9' }) {
        println(n[0].toString().toInt() + 9*(n.length-1))
        return
    }

    println(n[0].toString().toInt()-1 + 9*(n.length-1))
}

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

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

const long long MOD = 1000000007;

int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10) cout << r << endl;
  else cout << r + 100*(10-n) << endl;
}


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

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n, k;
    vector<int> p;
    cin >> n >> k;

    p.resize(n);

    set<int> S;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    for (int i = 0; i < k; ++i) {
        S.insert(p[i]);
    }

    int res = 1;

    for (int i = 1; i + k - 1 < n; ++i) {
        //cerr << "A\n";
        S.erase(p[i-1]);
        int ma = *S.rbegin();
        int mi = *S.begin();
        cerr << p[i-1] << " " << p[i+k-1] << " " << mi << " " << ma << "\n";
        
        if (p[i+k-1] < ma || p[i-1] > mi) {
            res++;
        }

        S.insert(p[i+k-1]);
    }

    int c = 0;
    auto q = p;
    q[0] = 1;
    for (int i = 1; i < n; ++i) {
        if (p[i] > p[i-1]) q[i] = q[i-1] + 1; else q[i] = 1;
        if (q[i] == k) c++;
    }

    cerr << "c= " << c << "\n";
    if (c > 0)
        res -= c-1;
    cout << res  << "\n";

    return 0;
}

Measured memory_bytes: 12800
//  main.cpp
//  Sunkvežimiai (LMIO 2017)
//
//  Created by Augustinas Jucas on 05/10/2019.
//  Copyright © 2019 Augustinas Jucas. All rights reserved.
//
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//const int size = 200010;

int random(int a, int b){
    return a + rand() % (b-a+1);
}
double reiksme(double N, double K){
    for(int k = 1; k <= K; k++){
        if(N != 0) N = random(0, N-1);
        else N = 0;
    }
    return N;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    srand(time(0));
    int n;
    cin >> n;
    cout << (n-1)/2;
    return 0;
}
/*
 
 1 2 3 4 5 6 7 8 9
 1.5
 2
 
 s = (s * kek + sk)/(kek+1)
 = s/(kek+1) * kek + sk/(kek+1)
 
 */


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


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

  int ans = 0, sum = 0;
  for(int i = 1; sum < X; ++i){
    ans++;
    sum += i;
  }

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


Measured memory_bytes: 256
# dp[i][j] := Aをiグラム、Bをjグラムちょうど買うための最小予算。
# i <= N * a_i <= 40*10=400
# j <= N * b_i <= 40*10=400
# ……だとダメだわ。マスの遷移が許されるかどうかの情報が入ってない。
# （ある薬品を2回使うことはできないから、薬品を買ったか否かの情報を入れなきゃいけない）
# dp[k][i][j] := k番目までの薬品を使って、Aをiグラム、Bをjグラムちょうど買うための最小予算。
# 40*400*400で、各マスの計算は2個のマスを参照すれば求まるから、
# 40*400*400*2 = 12800000 = 1280万 間に合う。

n, a_ratio, b_ratio = list(map(int, input().split()))
chemicals = [list(map(int, input().split())) for _ in range(n)]

inf = 10 ** 10
ab_max = 10
dp = [[[inf for j in range(n * ab_max + 1)] for i in range(n * ab_max + 1)] for k in range(n)]

dp[0][0][0] = 0
dp[0][chemicals[0][0]][chemicals[0][1]] = chemicals[0][2]

for k in range(1, n):
    for i in range(n * ab_max + 1):
        for j in range(n * ab_max + 1):
            if i-chemicals[k][0] >= 0 and j-chemicals[k][1] >= 0:
                dp[k][i][j] = min(dp[k-1][i][j],  dp[k-1][i-chemicals[k][0]][j-chemicals[k][1]] + chemicals[k][2])
            else:
                dp[k][i][j] = dp[k-1][i][j]

ans = inf
bai = 1
while(a_ratio * bai <= n * ab_max and b_ratio * bai <= n * ab_max):
    ans = min(ans, dp[n-1][a_ratio * bai][b_ratio * bai])
    bai += 1

if ans < inf:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 126544
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static int[] ToInt(this string[] strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ToLong(this string[] strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SplToInt(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SplToLong(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => (int)Diff(a, (long)b);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static int[] ToFlat(this int[] array) => array.Cast<long>().ToArray().ToFlat().Cast<int>().ToArray();
    public static long[] ToFlat(this long[] array)
    {
        var min = array.Min();
        return array.Select(x => x - min).ToArray();
    }
    public static int Gcd(int a, int b) => (int)Gcd(a, (long)b);
    public static long Gcd(long a, long b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }
    public static int Lcm(int a, int b) => (int)Lcm(a, (long)b);
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;
    //テンプレここまで
}

public static partial class Program
{
    static void Main()
    {
        var n = CRL().ToInt();
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            var input = CRL().ToLong();
            if (ans == 0)
            {
                ans = input;
                continue;
            }

            ans = Lcm(ans, input);
        }

        CWL(ans);
    }
}


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

#define _GLIBCXX_DEBUG
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())




// ループ系
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)

// #define fou(i,a,n) for(int i=a;i<n;i++)
#define elif(c) else if(c)


// 出力系
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}

const ll MAX=1000000007,MAXL=1LL<<61,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};

typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;





void Main() {
    int n, a;

    R n;R a;


    if (n%500 <= a){
        pr("Yes");
    }else{
        pr("No");
    }

}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

int a[100001];

int main(){
  int n;
  int ans = 0;
  cin >> n;
  for (int i = 0; i < 100001; i++){
    a[i] = 0;
  }
  for (int i = 0; i < n; i++){
    int u;
    scanf("%d", &u);
    if (u > 100000) ans++;
    else {
      a[u]++;
    }
  }
  for (int i = 0; i < 100001; i++){
    if (a[i] == i) continue;
    if (a[i] > i) ans += a[i] - i;
    else ans += a[i];
  }
  printf("%d\n", ans);

  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
//head

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

    int n;
    ll k;
    cin >> n >> k;
    vi a(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<vector<int>> st(63,vi(n+1));
    for(int i = 1; i <= n; i++) {
        st[0][i] = a[i];
    }
    for(int i = 1; i <= 62; i++) {
        for(int j = 1; j <= n; j++) {
            st[i][j] = st[i-1][st[i-1][j]];
        }
    }
    int ans = 1;
    for(int i = 62; i >= 0; i--) {
        if(k&(1LL << i)) {
            ans = st[i][ans];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 54132
N = int(input())
S = []
Y = {}
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9]
  if u not in Y:
    Y[u] = 1
  else :
    c += Y[u]
    Y[u] += 1
    


print(c)


Measured memory_bytes: 17892
#include <cstdio>
#include <algorithm>
using namespace std;
int n,cnt;
int l[102];
bool triangle(int i,int j,int k){
	if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k])return false;
	return l[i]+l[j]>l[k];
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",l+i);
	sort(l,l+n);
	for(int i=0;i<n-2;++i){
		for(int j=i+1;j<n-1;++j){
			for(int k=j+1;k<n;++k){
				if(triangle(i,j,k))++cnt;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);

}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m = 0, count = 0, sum = 0, ch = 0;
	llint a, b, c, d;
	bool check = false;
	string s;
	vector<llint> array;
	vstr ss;
	cin >> n;
	rep(i, n) {
		cin >> s;
		ss.push_back(s);
	}
	sort(ss);
	ss.erase(unique(ss.begin(), ss.end()), ss.end());
	cout << ss.size() << endl;

	please AC;
}


Measured memory_bytes: 11636
#define _CRT_SECURE_NO_WARNINGS

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

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int a;
	scanf("%d", &a);
	printf("%d", 3 * a * a);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
    int a,b,c,d,count=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1){
        if(c>0){
            c=c-b;
            count++;
        }else break;
        if(a>0){
            a=a-d;
            count++;
        }else break;
    }
    if(count%2==0)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
char s[200001];
int main(){
  cin>>s;
  int n=strlen(s),ans=0,len=1;
  for(int i=0;i<n;i++){
    if(len==2){
      len=1;
      ans++;
    }
    else{
      if(s[i-1]!=s[i]) ans++;
      else{
        len=2;
        if(n-i>=2)ans++;
        i++;
      }
    }
  }
  cout<<ans<<endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  // A, A + (A-1), A + 2(A-1), ... A + n(A-1)
  ll A, B;
  cin >> A >> B;
  if (B == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (B <= A) {
    cout << 1 << endl;
    return 0;
  }
  ll n = (B-A + A-2) / (A-1);
  cout << (n+1) << endl;
  return 0;
}


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

using namespace std;

int main() 
{
  string s,t;
  cin >> s;
  reverse(s.begin(),s.end());
  
  string ans = "YES";
  for(int i = 0; ; )
  {
    if(s.size() == 0) break;
    if(s.substr(0,2) == "re")
    {
      if(s.substr(0,6) == "resare")
        s.erase(0,6);
      else if(s.substr(0,7) == "remaerd")
        s.erase(0,7);
      else
      {
        ans = "NO";
        break;
      }
    }
    else
    {
      if(s.substr(0,5) == "esare")
        s.erase(0,5);
      else if(s.substr(0,5) == "maerd")
        s.erase(0,5);
      else
      {
        ans = "NO";
        break;
      }
    }
  }  
  cout << ans << endl;
}

Measured memory_bytes: 3740
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 22)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[100001];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
//#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<time.h>
#include<set>
#include <random>
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define fore(i,fa,fb) for(i=fa;i<=fb;++i)
#define all(n) (n.begin(),n.end())
#define F first
#define S second
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int i, j, k, m, n;
	char a, b;
	cin >> a >> b;
	if (a == 'H')
	{
		if (b == 'H')
			cout << 'H';
		else cout << 'D';
	}
	else
	{
		if (b == 'H')
			cout << 'D';
		else cout << 'H';
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26084
def solve(n)
  sqrt_n = Math.sqrt(n).floor
  
  m = 1
  sqrt_n.downto(1).each do |i|
    if n % i == 0
      m = i
      break
    end
  end
  
  (m - 1) + (n / m - 1)
end

n = STDIN.gets.chomp.to_i
puts solve(n)


Measured memory_bytes: 1788