akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol-1 0111: Doctor's Memorable Codes
// 2017.8.12 bal4u@uu

#include <stdio.h>
#include <ctype.h>

char *gets(char *);

typedef struct { int l, r, c; } T;
T tbl[63] = { { 1, 2, 0 },
/* 1 */{ 3,  4,  0 },
/* 2 */{ 5,  6,  0 },
/* 3 */{ 7,  8,  0 },
/* 4 */{ 9, 10,  0 },
/* 5 */{ 11, 12,  0 },
/* 6 */{ 13, 14,  0 },
/* 7 */{ 15, 16,  0 },
/* 8 */{ 17, 18,  0 },
/* 9 */{ 19, 20,  0 },
/*10 */{ 21, 22,  0 },
/*11 */{ 23, 24,  0 },
/*12 */{ 0,  0, ' ' },
/*13 */{ 0,  0, 'E' },
/*14 */{ 0,  0, 'P' },
/*15 */{ 25, 26,  0 },
/*16 */{ 0,  0, 'D' },
/*17 */{ 27, 28,  0 },
/*18 */{ 29, 30,  0 },
/*19 */{ 31, 32,  0 },
/*20 */{ 0,  0, 'C' },
/*21 */{ 0,  0, 'K' },
/*22 */{ 0,  0, 'I' },
/*23 */{ 0,  0, 'R' },
/*24 */{ 33, 34,  0 },
/*25 */{ 35, 36,  0 },
/*26 */{ 37, 38,  0 },
/*27 */{ 0,  0, 'L' },
/*28 */{ 0,  0, 'O' },
/*29 */{ 0,  0, 'S' },
/*30 */{ 0,  0, 'T' },
/*31 */{ 39, 40,  0 },
/*32 */{ 0,  0, 'F' },
/*33 */{ 41, 42,  0 },
/*34 */{ 43, 44,  0 },
/*35 */{ 0,  0, '\'' },
/*36 */{ 0,  0, '?' },
/*37 */{ 0,  0, 'W' },
/*38 */{ 0,  0, ',' },
/*39 */{ 0,  0, 'H' },
/*40 */{ 0,  0, '.' },
/*41 */{ 45, 46,  0 },
/*42 */{ 0,  0, 'A' },
/*43 */{ 47, 48,  0 },
/*44 */{ 49, 50,  0 },
/*45 */{ 51, 52,  0 },
/*46 */{ 53, 54,  0 },
/*47 */{ 55, 56,  0 },
/*48 */{ 57, 58,  0 },
/*49 */{ 59, 60,  0 },
/*50 */{ 61, 62,  0 },
/*51 */{ 0,  0, 'Z' },
/*52 */{ 0,  0, '-' },
/*53 */{ 0,  0, 'X' },
/*54 */{ 0,  0, 'Y' },
/*55 */{ 0,  0, 'J' },
/*56 */{ 0,  0, 'M' },
/*57 */{ 0,  0, 'B' },
/*58 */{ 0,  0, 'G' },
/*59 */{ 0,  0, 'U' },
/*60 */{ 0,  0, 'V' },
/*61 */{ 0,  0, 'N' },
/*62 */{ 0,  0, 'Q' }
};
char tr[130];
char buf[250], *p;
char tmp[1050], *tp; int pos;

int getBit(void)
{
	int k;
	static char a[] = { 16, 8, 4, 2, 1 };
	if (!*tp) return -1;
	k = (((*tp) - 1) & a[pos++]) != 0;
	if (pos >= 5) pos = 0, tp++;
	return k;
}

int main()
{
	int i, a, f;

	for (i = 'A'; i <= 'Z'; i++) tr[i] = i - 'A' + 1;
	tr[' '] = 27, tr['.'] = 28, tr[','] = 29, tr['-'] = 30, tr['\''] = 31, tr['?'] = 32;
	while (gets(p = buf) != NULL) {
		tp = tmp;
		//		while (isspace(*p)) p++;
		while (*p) *tp++ = tr[*p++];
		*tp = 0, tp = tmp, pos = 0, f = 1;
		while (f) {
			i = 0;
			while (1) {
				if ((a = getBit()) < 0) { f = 0; break; }
				i = a ? tbl[i].r : tbl[i].l;
				if (tbl[i].c) { putchar(tbl[i].c); break; }
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut aseq = HashMap::<usize, usize>::new();
    for _ in 0..n {
        let v: usize = read();
        let counter = aseq.entry(v).or_insert(0);
        *counter += 1;
    }
    let mut ans = 0;
    for (v, cnt) in aseq {
        ans += if cnt >= v { cnt - v } else { cnt };
    }
    println!("{}", ans);
}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
    ll n,m;
    cin >> n >> m;
    vll h(n);
    REP(i,n) cin >> h[i];
    ll a,b;
    vector<bool> check(n,true);
    REP(i,m) {
        cin >> a >> b;
        a--;
        b--;
        if(h[a]<h[b]) {
            check[a]=false;
        } else if(h[a]>h[b]) {
            check[b]=false;
        } else {
            check[a]=false;
            check[b]=false;
        }
    }
    ll ans=0;
    REP(i,n) {
        if(check[i]) ans++;
    }
    cout << ans << endl;
  return 0;
}


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

namespace AtCoder20190303_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse);
            var possibleTimes = input.ElementAt(1) / input.ElementAt(0);
            var saticefiedTimes = input.ElementAt(2);
            if (possibleTimes > saticefiedTimes)
            {
                Console.WriteLine(saticefiedTimes);
            }
            else
            {
                Console.WriteLine(possibleTimes);
            }
        }
    }
}


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

const int MAX = 1e6;  // 注意

ll fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

// (a%MOD) * modinv(b, MOD) % MOD で　a/b;
ll moddiv(ll a, ll b, ll mod = 1e9+7){
    ll res = (a%mod) * modinv(b, mod) % mod;
    return (res+mod)%mod ;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    ll X, Y; cin >> X >> Y;
    if((X+Y)%3 != 0) { cout << 0 << endl; return 0; }
    ll N = (X+Y)/3;
    ll D = abs(X-Y);
    ll K = (min(X, Y) - D) / 3;
    cout << COM(N, K) << endl;


}


Measured memory_bytes: 27048
H, W = gets.split.map(&:to_i)
#H, W = 50, 50
ss = []
H.times do |i|
    ss[i] = gets.chomp.split('')
    #ss[i] = Array.new(W, '#')
end

H.times do |i|
    W.times do |j|
        if ss[i][j] == '#'
            success = false
            [[i-1,j], [i+1,j], [i,j+1], [i,j-1]].each do |ii, jj|
                next if ii < 0 || ii > H - 1 || jj < 0 || jj > W - 1
                if ss[ii][jj] == '#'
                    success = true
                    break
                end
            end
            if !success
                puts 'No'
                exit
            end
        end
    end
end

puts 'Yes'

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	long S=1;
	for (int i=1; i<=N; i++) {
		S *=i;
		S %=1000000007;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
operator fun Pair<Int, Int>.plus(pair: Pair<Int, Int>) = Pair(first + pair.first, second + pair.second)
operator fun Pair<Int, Int>.minus(pair: Pair<Int, Int>) = Pair(first - pair.first, second - pair.second)
fun Pair<Int, Int>.manhattanTo(pair: Pair<Int, Int>) = (this - pair).manhattanLength()
fun Pair<Int, Int>.manhattanLength() = Math.abs(first) + Math.abs(second)

fun main(args: Array<String>) {
    val (H, W, D) = readLine()!!.split(" ").map { it.toInt() }
    val A = (0 until H).map { readLine()!!.split(" ").map { it.toInt() } }
    val numberCache: Map<Int, Pair<Int, Int>> = {
        val result = mutableMapOf<Int, Pair<Int, Int>>()
        (0 until H).forEach { h ->
            (0 until W).forEach { w ->
                result[A[h][w]] = Pair(h, w)
            }
        }
        result
    }()
    val mpCache: Map<Int, Int> = {
        val result = mutableMapOf<Int, Int>()
        (1 until D + 1).forEach { width ->
            var index = width
            while (index <= H * W) {
                val prevIndex = index - D
                val totalMp = result[prevIndex]?.let { previous ->
                    val diff = numberCache[prevIndex]!!.manhattanTo(numberCache[index]!!)
                    previous + diff
                } ?: 0

                result[index] = totalMp
                index += width
            }
        }
        result
    }()

    val Q = readLine()!!.toInt()
    (0 until Q).forEach {
        val (L, R) = readLine()!!.split(" ").map { it.toInt() }
        println(mpCache[R]!! - mpCache[L]!!)
    }
}

Measured memory_bytes: 107664
#include <iostream>
#include <vector>
using namespace std;
int H, W;
vector<vector<int>> how;
vector<vector<int>> A;
vector<vector<int>> izen;

void func(int x, int y){
	izen[x][y] = 1;
	if(y < W-1 && izen[x][y+1] == 0){
		if(A[x][y] % 2 == 1){
			A[x][y] -=  1;
			A[x][y+1] += 1;
			int xdash = x;
			int ydash = y+1;
			vector<int> v = {x+1,y+1,xdash+1,ydash+1};
			how.push_back(v);
		}
		func(x,y+1);
	}
	else if(y > 0 && izen[x][y-1] == 0){
		if(A[x][y] % 2 == 1){
			A[x][y] -= 1;
			A[x][y-1] += 1;
			int xdash = x;
			int ydash = y-1;
			vector<int> v = {x+1,y+1,xdash+1,ydash+1};
			how.push_back(v);
		}
		func(x,y-1);
	}
	else if(x < H-1 && izen[x+1][y] == 0){
		if(A[x][y] % 2 == 1){
			A[x][y] -= 1;
			A[x+1][y] += 1;
			int xdash = x+1;
			int ydash = y;
			vector<int> v = {x+1,y+1,xdash+1,ydash+1};
			how.push_back(v);
		}
		func(x+1,y);
	}
	else return;
}

int main(){
	cin >> H >> W;
	for(int j=0;j<H;j++){
		vector<int> v(W);
		for(int i=0;i<W;i++){
			cin >> v[i];
		}
		A.push_back(v);
	}
	for(int j=0;j<H;j++){
		vector<int> v(W);
		for(int i=0;i<W;i++){
			v.push_back(0);
		}
		izen.push_back(v);
	}
	func(0,0);
	int howlong = how.size();
	cout << howlong << endl;
	for(int i=0;i<(int)howlong;i++){
		for(int j=0;j<4;j++){
			if(j>0) cout << " ";
			cout << how[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 31408
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int N, *a;
	scanf("%d", &N);

	a = new int[N];
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}

	int N4 = 0, N2 = 0, N1 = 0,N2_=0;
	for (int i = 0; i < N; i++)
	{
		if (a[i] % 4 == 0)
			N4++;
		else if (a[i] % 2 == 0)
			N2++;
		else
			N1++;
	}
	if (N2!=0&&N4 >= N1)
		printf("Yes");
	else if(N2==0&&N4>=N1-1)
	{
		printf("Yes");
	}
	else
		printf("No");
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int a, b;
  cin >> a >> b;
  int c = 0;
  for (int i = a; i <= b; i++) {
    int d1 = i % 10;
    int d2 = (i / 10) % 10;
    int d4 = (i / 1000) % 10;
    int d5 = (i / 10000) % 10;

    if (d1 == d5 && d2 == d4) {
      c++;
    }
  }

  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const INF: i64 = 1 << 60;

fn solve() {
    loop {
        let n: usize = get();
        let m: usize = get();
        if n == 0 && m == 0 { break; }
        let s: Vec<i64> = (0 .. n).map(|_| get()).collect();
        let mut d: Vec<i64> = (0 .. m).map(|_| get()).collect();
        d.sort();
        let mut subsum = vec![0; 1 << n];
        for bits in 1 .. 1 << n {
            for i in 0 .. n {
                if (bits & 1 << i) == 0 { continue; }
                subsum[bits] = subsum[bits ^ 1 << i] + s[i];
                break;
            }
        }
        let mut dp = vec![vec![INF; m + 1]; 1 << n];
        {
            let mut cur = 0;
            for i in 0 .. m + 1 {
                dp[0][i] = cur;
                if i < m {
                    cur += d[i];
                }
            }
        }
        for bits in 0 .. 1 << n {
            for k in 0 .. n {
                if (bits & 1 << k) != 0 {
                    for i in 0 .. m + 1 {
                        dp[bits][i] = min(dp[bits][i], dp[bits ^ 1 << k][i]);
                    }
                }
            }
            for i in 1 .. m + 1 {
                let mut cur = dp[bits][i - 1] + (subsum[bits] - d[i - 1]).abs();
                dp[bits][i] = min(dp[bits][i], cur);
            }
        }
        println!("{}", dp[(1 << n) - 1][m]);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 39812
use petgraph::algo::dijkstra;
use petgraph::graph::{NodeIndex, UnGraph};
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        u: Usize1,
        v: Usize1,
        edges: [(Usize1, Usize1); n-1],
    }

    let g = UnGraph::<usize, usize, usize>::from_edges(&edges);

    let from_u = dijkstra(&g, u.into(), None, |_| 1);
    let from_v = dijkstra(&g, v.into(), None, |_| 1);

    let mut v_vec: Vec<(usize, usize)> = from_v
        .into_iter()
        .map(|(key, value)| (key.index(), value))
        .collect();

    v_vec.sort_by(|a, b| b.1.cmp(&a.1));

    for i in 0..n-1 {
        //println!("distance {}", v_vec[i].1);
        let index = v_vec[i].0;
        if v_vec[i].1 > *from_u.get(&NodeIndex::new(index)).unwrap() {
            println!("{}", v_vec[i].1 - 1);
            break;
        }
    }
}


Measured memory_bytes: 17624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int v[N];
int n;

ll check(ll am){

	for(int i=0;i < n;i++){
		am-=am % v[i];
	}
	return am;
}

int main(){

//	freopen("in.txt","r",stdin);

	scanf("%d",&n);
	for(int i=0;i < n;i++){
		scanf("%d",v + i);
	}
	if(v[n - 1] != 2) return puts("-1"), 0;
	ll l=1,r=2e18 + 5,mn=2e18 + 10,mx=0;
	bool f=0;
	while(l <= r){
		ll mid=(l + r) / 2;
		ll temp=check(mid);
		if(temp >= 2){
			if(temp == 2) mn=min(mn,mid), f=1;
			r=mid - 1;
		}
		else l=mid + 1;
	}
	if(!f) return puts("-1"), 0;
	mx=mn;
	l=1, r=2e18 + 5;
	while(l <= r){
		ll mid=(l + r) / 2;
		ll temp=check(mid);
		if(temp <= 2){
			if(temp == 2) mx=max(mx,mid);
			l=mid + 1;
		}
		else r=mid - 1;
	}
	assert(mn % v[0] == 0);
	cout << mn << " " << mx << endl;

}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,t;cin >> n;
    int a[n],count=0,min1=INF;
    ll sum = 0;
    REP(i,n){
        cin >> t;
        if(t<0){
            a[i]=-t;
            count++;
        }
        min1=min(min1,abs(t));
        sum+=abs(t);
    }
    if(count%2==0)COUT(sum);
    else COUT(sum-2*min1);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
#define _USE_MATH_DEFINES
#include <math.h>
int main() {
	long double n;
	cin>>n;
	n*=2*M_PI;
	printf("%.9Lf",n);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    
    if(c-a-b>0){
        if(4*a*b < (c-a-b)*(c-a-b)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int H,W,N;
	int now=0;
	int a[10010];
	int c[10400]={};
	cin >> H >> W >> N;
	REP(i,N){cin >> a[i];}
	REP(i,N){
	    REP(j,a[i]){
	        c[j+now]=i+1;
	    }
	    now+=a[i];
	}
//	REP(i,H*W){cout << c[i] << " ";}
	if(H%2==0){
	    REP(i,H/2){
	        REP(j,W){
	            cout << c[W*2*i+j] <<  " ";
	        }
	        cout << endl;
	        REP(j,W){
	            cout << c[W*i*2 + 2*W-j-1] <<  " ";
	        }
	        cout << endl;
	    }
	}else{
	    REP(i,H/2){
	        REP(j,W){
	            cout << c[W*i*2+j] <<  " ";
	        }
	        cout << endl;
	        REP(j,W){
	            cout << c[W*i*2+ 2*W-j-1] <<  " ";
	        }
	        cout << endl;
	    }
	        REP(j,W){
	            cout << c[(H-1)*W+j] <<  " ";
	        }
	        cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())
p = Counter([i + idx for idx, i in enumerate(A, 1)])
m = Counter([i - idx for idx, i in enumerate(A, 1)])
answer = 0

for i, j in p.items():
    answer += j * m[-i]

print(answer)


Measured memory_bytes: 61320
#include <iostream>
using namespace std;
int main() {
    int n,m,k,b[20],a[1000][20],i,j,c,d;
    d=0;
    c=0;
    cin>>n>>m>>k;
    for (i=0;i<m;i++){
        cin>>b[i];
    }
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            cin>>a[i][j];
            c=c+a[i][j]*b[j];
            
        }
        if (c+k>0){
            d=d+1;
        }
        c=0;
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

vi init(string& P)
{
    vi b(P.size() + 1);
    int i = 0, j = -1; b[0] = -1;
    while (i < P.size())
    {
        while (j >= 0 && P[i] != P[j]) j = b[j];
        b[++i] = ++j;
    }
    return b;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    string s = b + "#" + a;
    vi v = init(s);
    cout << 2 * n - v.back();
}


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

const int N = 20003;

int a[N], b[N], n, p[N], mark[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
	for (int i = 1; i <= n; ++i) a[i] = a[i - 1] + 20001, b[n - i + 1] = a[i];
	for (int i = 1; i <= n; ++i) {
		mark[p[i]] = 1;
		for (int j = p[i] + 1; j <= n; ++j)
			if (!mark[j]) ++a[j];
		for (int j = p[i] - 1; j >= 1; --j)
			if (!mark[j]) ++b[j];
	}
	
	for (int i = 1; i <= n; ++i) printf("%d ", a[i]); puts("");
	for (int i = 1; i <= n; ++i) printf("%d ", b[i]); puts("");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 20000; i++){
        int a,b,c,d;
        char op;
        cin >> a >> op >> b;
        if(op=='+'){
            c=a+b;
        }else if(op=='-'){
            c=a-b;
        }else if(op=='*'){
            c=a*b;
        }else if(op=='/'){
            c=a/b;
        }else{
            break;
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int n,ret = 0;
bitset<4000010>f;
inline int read(void)
{
	int x = 0,f = 1; char ch = getchar();
	while(!isdigit(ch)){f = ch == '-' ? -1 : 1; ch = getchar();}
	while(isdigit(ch)){x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();}
	return x*f;
}

int main(int argc, char *argv[])
{
	n = read();
	f[0] = 1;
	while(n--)
	{
		int x = read();
		f = f|(f<<x);
		ret += x;
	}
	int i;
	for (i = (ret+1)/2; !f[i]; i++);
	cout << i;
	return 0;
}

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

int main(){
    int H,A;
    cin >> H >> A;
    if(H%A==0){
        cout << H/A << endl;
    }else{
        cout << H/A + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans;
    if (K <= A)
    {
        ans = K;
    }else if (A < K && K <= (A + B))
    {
        ans = A;
    }else if ((A + B) < K)
    {
        ans = A - (K - (A + B));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> prices(N);
  for (int n = 0; n < N; ++n) {
    cin >> prices[n];
  }
  sort(prices.begin(), prices.end());

  int64_t sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += prices[i];
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3624
import sys


INF = 1 << 32 - 1
S = sys.stdin.readlines()
N, M, L = map(int, S[0].split())

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

for i in range(1, M + 1):
    A, B, C = map(int, S[i].split())
    dp[A - 1][B - 1] = C
    dp[B - 1][A - 1] = C
for i in range(N):
    dp[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


dp2 = [[INF] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dp[i][j] <= L:
            dp2[i][j] = 1
# for i in range(N):
#     dp2[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j])


Q = int(S[M + 1])
for i in range(M + 2, M + 2 + Q):
    s, t = map(int, S[i].split())
    refuel = dp2[s - 1][t - 1]
    if refuel >= INF:
        print(-1)
    else:
        print(refuel - 1)


Measured memory_bytes: 72540
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)   //Function to find gcd of two numbers
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n , d;
    cin>>n>>d;
    
    
    int x,y;
    
    int cnt=0;
    
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        
        double dis = sqrt((double)x*x + (double)y*y);
        
        if(ceil(dis)<=d)
        cnt++;
    }
    
    cout<<cnt<<endl;
   

    return 0;
}

Measured memory_bytes: 3696
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

hlist = inputs[1]

# body
if $debugFlag
  p hlist
end

cnt = 0
hlist.size.times do |i|
  flag = true
  i.times do |j|
    if hlist[i] < hlist[j]
      flag = false
    end
  end
  cnt += 1 if flag == true
end

puts cnt


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long int;
const int mod = 1e9+7;
int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ull> suff(n);
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	suff[n-1] = a[n-1];
	for(int i = n-2;i>=0;--i) {
		suff[i] = (suff[i+1]%mod + a[i]%mod)%mod;
	}
	ull ans = 0;
	for(int i=0;i<n-1;i++) {
		ans = (ans + ((suff[i+1]%mod)*(a[i]%mod))%mod)%mod;
	}
	cout<<ans;
}


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


#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define pair < int , int > pii


int n, sum, a, b;

int main(){

	cin >> n >> a >> b;

	for(int i = 1; i <= n; i++){
		int tmp = i;
		int tmpsum = 0;
		while(tmp){
			tmpsum += tmp%10;
			tmp /= 10;
		}
		if(a <= tmpsum && tmpsum <= b)
			sum += i;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem158c(a, b))
}

fun problem158c(a: Int, b: Int): Int {
    val min = Integer.MAX_VALUE
    for (i in 1 until 10000) {
        if ((i * 0.08).toInt() == a && (i * 0.1).toInt() == b) return i
    }
    return -1
}

Measured memory_bytes: 31388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  int cnt =0;
  rep(i,n){
    int p = a[i];
    auto q = upper_bound(ALL(a),p);
    auto r = lower_bound(ALL(a),p);
    if(q-r>=p) cnt+=q-r-p;
    else cnt+=q-r;
    i = q - a.begin() - 1;
    
  }
  cout << cnt << endl;
}




Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a;

int main(){
    INIT;
    cin >> a;
    if(a == 7 || a == 5 || a == 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
N , T = map(int, input().split())
cost = []
error=[]
x = []
for i in range( N ):
    x.append([int(z) for z in input().split()])
for i in range (len(x)):
    if x[i][1]<=T :
        cost.append(x[i][0])
    if x[i][1] > T:
        error.append(x[i][1])
if len(error) == N :
    print("TLE")
else:
    print(min(cost))



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;

int a[100];
int n;

void trace(int N){
  for(int i=0;i<N;i++){
    cout << a[i];
    if(i!=N-1){
      cout << " ";
    }
  }
  cout << endl;
}

void insertionSort(int N){
  for(int i=1;i<N;i++){
    int v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    trace(N);
  }
}

int main (){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  trace(n);
  insertionSort(n);
  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	int A,B;

	cin >> A >> B;
	
	if (A > 8 || B > 8){
		std::cout << ":(" << std::endl;
		return 0;
	}
	else{
		std::cout << "Yay!" << std::endl;
	}

	//std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int r = 0;
  for (string s = "357"; atol(s.c_str()) <= (i64)N; ) {
    bool a = false, b = false, c = false;
    F0R(i, s.size()) {
      if (s[i] == '3') a = true;
      else if (s[i] == '5') b = true;
      else c = true;
    }
    if (a && b && c) r++;

    int i = s.size() - 1;
    while (true) {
      if (i < 0) {
        s = '3' + s;
        break;
      }
      if (s[i] == '3') {
        s[i] = '5';
        break;
      }
      if (s[i] == '5') {
        s[i] = '7';
        break;
      }
      s[i] = '3';
      i--;
    }
  }
  cout << r;
}
#endif


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

vector<pair<int, int> > array_run_length_factorization(vector<int> a){
    vector<pair<int, int> > res;
    a.push_back(INT_MAX);
    int now = a[0];
    int cnt = 1;
    for(int i = 1; i < a.size(); i++){
        if(a[i] != now){
            res.push_back({now, cnt});
            now = a[i]; cnt = 1;
        }else cnt++;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<P> b = array_run_length_factorization(a);
    int ans = 0;
    for(int i = 0; i < b.size(); i++){
        ans += b[i].second / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
vector<int> makeBitPrimes(int n) {
    vector<int> v(n + 1, 1);v[0] = v[1] = 0;
    rep(i, 2, sqrt(n)) if (v[i]) for (int j = 0; i * (j + 2) < n; j++) v[i * (j + 2)] = 0;return v;}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int Q;
int A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    auto ps = makeBitPrimes(101010);
    rep(i, 1, 101010) if (ps[i] and ps[(i + 1) / 2]) A[i] = 1;
    rep(i, 1, 101010) B[i] = B[i - 1] + A[i];

    cin >> Q;
    rep(q, 0, Q) {
        int L, R;
        cin >> L >> R;

        int ans = B[R] - B[L - 1];
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1792
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (3e5);
    static List<Integer>[] edges;
    static int n,m;
    static boolean cycle;
    static boolean[] vis;
    static int[] viscnt;
    static List<Integer> path;
    
	public static void main(String[] args) {
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i=a;i<=b;++i) {
			if(i%k == 0) {
				out.print("OK");
				out.close();
				return;
			}
		}
		out.print("NG");
		out.close();
   }
	 
}

Measured memory_bytes: 32656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e9;
 
int main() {
    int n; cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    } 
    sort(A.begin(), A.end());
    ll ans = 0;
    int cnt = 1, t;
    for (int i = 0; i < n - 1; i++) {
        t = A[i];
        if (t == A[i + 1]) { 
            cnt++;
        } else {
            if (t < cnt) ans += cnt - t;
            else if (t == cnt) cnt = 1;
            else ans += cnt;
            cnt = 1;
        }
    }
    t = A[n - 1];
    if (t < cnt) ans += cnt - t;
    else if (t == cnt) cnt = 1;
    else ans += cnt;
    cnt = 1;
    cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

# 各数字の個数を格納
dict = {}
for a in A:
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1

# k番目の値を消さない場合の場合分けの個数
ans = 0
for d in dict.values():
    if d > 1:
        ans += (d * (d - 1)) // 2

# k番目の値を除いた場合に減る場合の数を引いて答えを出力
for k in range(N):
    w = dict[A[k]]
    # 減る数
    decrease = 0
    if w == 1:
        pass
    elif w == 2:
        decrease = -1
    elif w > 2:
        decrease = ((w - 1) * (w - 2) // 2) - (w * (w - 1) // 2 )
    print(ans + decrease)


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
int main(){vector<string> s;
string p,x;
long long n,i;
cin>>n;
long long a[n],j,k=0;
for(i=0;i<n;i++){
    cin>>p;
    s.push_back(p);
    cin>>a[i];
}cin>>x;
for(i=0;i<n;i++){
    if(x==s[i]){
        j=i;break;
    }
}for(i=j+1;i<n;i++){
    k=k+a[i];
}cout<<k;

    return 0;
  
}


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


Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C755 solver = new C755();
        solver.solve(1, in, out);
        out.close();
    }

    static class C755 {
        static int n;
        static int ans;

        static void dfs(int now, long act) {
            long a = act * 10 + now;
            String s = String.valueOf(a);
            boolean b3 = false, b5 = false, b7 = false;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '3') {
                    b3 = true;
                } else if (s.charAt(i) == '5') {
                    b5 = true;
                } else if (s.charAt(i) == '7') {
                    b7 = true;
                }
            }
            if (b3 && b5 && b7 && a <= n) {
                ans++;
            }
            if (a <= n) {
                dfs(3, a);
                dfs(5, a);
                dfs(7, a);
            }
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            n = sc.nextInt();
            ans = 0;
            dfs(3, 0);
            dfs(5, 0);
            dfs(7, 0);
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////

const int N = 200;

int arr[N + 5];
int n,m;

int solve(){
	int tot = 0;
	REP(i,1,n){
		tot += arr[i];
	}
	int tot2, mn = INF, ret = 0;
	REP(i,1,n){
		tot2 = 0;
		REP(j,1,n){
			if(i == j) continue;
			tot2 += arr[j];
		}
		if(abs(tot-tot2) < mn){
			mn = abs(tot-tot2);
			ret = tot2;
		}
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	REP(i,1,n){
		arr[i] = m + i - 1;
	}
	cout << solve() << endl;
	return 0;
}

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

int main()
{
	long long n, k, q; cin >> n >> k >> q;
	
	vector<int> a(q); 
	for (int i = 0; i < q; i++) { cin >> a[i]; }

	vector<long long>  point(n); 
	for (int j = 0; j < n; j++) { point[j] = k; }

	for (int i = 0; i < q; i++) {
		point[a[i] - 1]++;
	}

	for (int j = 0; j < n; j++) { 

		if (point[j] - q  > 0 ) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[n - 1] == 's')
        s.append("es");
    else
        s.append("s");
    cout << s << "\n";
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

int main() {
	ll h, w; cin >> h >> w;

	// h > w;
	if (!(h % 3) || !(w % 3)) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = ((h > w) ? w : h);

	ll s = MAX_L;
	rep(i, 1, h) {
		ll a = i * w;
		ll b = w / 2 * (h - i);
		if (w & 1) {
			ll c = (w / 2 + ((w & 1) ? 1 : 0)) * (h - i);
			ll maxS = max(a, max(b, c));
			ll minS = min(a, min(b, c));
			s = min(s, maxS - minS);
		}
		else {
			s = min(s, abs(a - b));
		}
	}

	ll t = MAX_L;
	rep(i, 1, w) {
		ll a = i * h;
		ll b = h / 2 * (w - i);
		if (h & 1) {
			ll c = (h / 2 + ((h & 1) ? 1 : 0)) * (w - i);
			ll maxS = max(a, max(b, c));
			ll minS = min(a, min(b, c));
			t = min(t, maxS - minS);
		}
		else {
			s = min(s, abs(a - b));
		}
	}
	cout << min(ans, min(s, t)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//'a'=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
long long SUM(vector<int> Vec){//配列の和
  int n=Vec.size();
  int sum= 0;
  for(int i=0;i<n;i++){
    sum+=Vec[i];
  }
  return sum;}
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  ll all=SUM(v);
  int m;
  cin>>m;
  int cp;
  int nt;cerr<<all;
  rep(j,m){
    cin>>cp;
    cp--;
    cin>>nt;
    cout<<all-v[cp]+nt<<endl;
  }
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N, K, Q = map(int, sys.stdin.readline().split())

# default = [K - Q] * N
acquire = [0] * N

for _ in range(Q):
    X = int(sys.stdin.readline()) - 1
    acquire[X] += 1

default = K - Q
for a in acquire:
    if default + a > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 73428
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
vector<ll> seive(10000001,1);
int main()
{
	int n;
	cin>>n;
	for(int i=2;i<=10000000;i++)
	{
		if(seive[i]==1)
		{
			for(int j=2*i;j<=10000000;j+=i)
			{
				ll x=0;
				int f=j;
				while(f%i==0)
				{
					x++;
					f=f/i;
				}
				seive[j]*=(x+1);
			}
		}
	}
	ll ans=0;
	for(int i=2;i<=n;i++)
	{
		if(seive[i]==1)seive[i]=2;
		ans+=(i*seive[i]);
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 81216