akhauriyash/Code-Regression huggingface dataset:
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;

   bool ok = false;
   if (n % 10 == 7) ok = true;
   n /= 10;
   if (n % 10 == 7) ok = true;
   n /= 10;
   if (n % 10 == 7) ok = true;
   if (ok)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 3636
N = int(input())
S = [input() for i in range(N)]
c = "MARCH"
num = []
for i in range(5):
    count = 0
    for j in range(N):
        if S[j][0] == c[i]:
            count += 1
    num.append(count)
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += num[i]*num[j]*num[k]
print(ans)

Measured memory_bytes: 9752
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	cnt := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME,...) NAME
#define rep_2(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for(int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME,...) NAME
#define rep_r_2(i, n) for(int i = (int)(n); i > 0; i--) 
#define rep_r_3(i, initial, n) for(int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	ll result = (N - 1) * N / 2;

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int X = scanner.nextInt();

        int dist = X;
        
        int count = 1;
        while(dist != 0) {
            dist = (dist + X) % 360;
            count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 35776
#include<stdio.h>
#include<stdlib.h>

int n,*pre,*in,*post,prenumber=-1,cnt=0;

int infind(int number)//numberが格納されているinの要素番号を返す
{
	int i;
	for(i=0;i<n;i++) if(in[i]==number) return i;
	printf("error\n");
	return 100000;
}

void reconstraction(int l,int r)//後行順巡回を出力する関数
{
	int c,m;
	if(l>=r) return;
	prenumber++;
	c=pre[prenumber];//探索する値をcに格納
	m=infind(c);//inの要素番号をmに格納
	if(m==100000) return;
	reconstraction(l,m);//左部分木を探索
	reconstraction(m+1,r);//右部分木を探索
	
	post[cnt]=c;//葉まで行けば、出力条件を満たすため一度配列に巡回順を格納
	cnt++;
}

int main(void)
{
	int i;
	scanf("%d",&n);
	pre=(int*)malloc(sizeof(int)*n);
	in=(int*)malloc(sizeof(int)*n);
	post=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++) scanf("%d",&pre[i]);
	for(i=0;i<n;i++) scanf("%d",&in[i]);
	
	reconstraction(0,n);
	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",post[i]);
	}
	printf("\n");
	
	free(pre);
	free(in);
	free(post);
	
	return 0;
}


Measured memory_bytes: 2092
A,B = list(map(int,input().split()))
x = 1

def xors(X):
  res = 0
  x = 2
  while True:
    if x > X:
      break
    if (X % (x*2)) >= x and (X % (x*2)) % 2 == 0:
      res = res + x
    x = x*2
  if X % 4 <= 2 and X % 4 >= 1:
    res = res + 1
  return res
print(xors(B) ^ xors(A-1))
  

Measured memory_bytes: 3060
// atcoder/abc161/A/mani.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int a, b, c;
  while (cin >> a >> b >> c) {
    cout << c << ' ' << a << ' ' << b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 2147483647

struct edge{
	int from,to,cost; 
};

edge es[2010];  //?????¨??? 

int d[1010];  // d[i] ??¨??????i???????????????????????? 

int V,E; //??????????????°??? 


//bool find_negative_loop(){
//	fill(d,d+V,0);
//	
//	for(int i = 0;i < V; i++){
//		for(int j = 0;j < E; j++){
//			edge e = es[j];
//			if(d[e.to] > d[e.from] + e.cost){
//				d[e.to] = d[e.from] + e.cost;
//				if(i == V-1) return false;
//			}
//		}
//	}
//	return true;
//}



bool shortest_path(int s){
	fill(d,d+V,INF);
	
	d[s] = 0;
	
	int v = 0;
	while(true){
		bool update = false;
		for(int i = 0;i < E; i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if(v == V-1) return true;
			}
		}
		if(!update) break;
		v++;
	}
	return false;
}


int main(){
	
	int r;
	cin >> V >> E >> r;

	for(int i = 0;i < E; i++) cin >> es[i].from >> es[i].to >>es[i].cost;
	
	if(!shortest_path(r)){
		for(int i = 0;i < V; i++){
			if(d[i] == INF) cout <<"INF" <<endl;
			else cout << d[i] << endl;
		}
	}else{
		cout <<"NEGATIVE CYCLE" <<endl;
	}
	

	return 0;
} 

Measured memory_bytes: 3104
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	n -= 8;
	cout << s.substr(0,n) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A, B, C, K, i;
  scanf("%d %d %d", &A, &B, &C);
  scanf("%d",&K);
  int max=A;
  if(max<B) max=B;
  if(max<C) max=C;
  int sum=A+B+C;
  for(i=0;i<K;i++){
    sum+=max;
    max*=2;
  }
  printf("%d\n",sum);
  return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 200007;
const char *YES = "Yes" , *NO = "No";

int n;char s[_]={0};

int main()
{
	n=ty();
	int sa=ty(),sb=ty(),ta=ty(),tb=ty();
	ts(s+1);
	for(int i=1;i<=n;i++)s[i]=s[i]=='#';
	
	if(ta<tb)
	{
		for(int i=sa;i<tb;i++)if(s[i] && s[i+1]){puts(NO);return 0;}
		puts(YES);
		return 0;
	}

	int got=0;
	for(int i=sb;i<=tb;i++)if(!s[i-1] && !s[i] && !s[i+1]){got=1;break;}
	if(!got){puts(NO);return 0;}
	for(int i=sa;i<ta;i++)if(s[i] && s[i+1]){puts(NO);return 0;}
	puts(YES);

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
vii data;
int n;
int cnt[(int)2e5 + 5];
int add(int i){
    cnt[data[i].second]++;
    if(cnt[data[i].second] == 1)return 1;
    return 0;
}
int remove(int i){
    cnt[data[i].second]--;
    if(cnt[data[i].second] == 0)return -1;
    return 0;
}
bool check(int len){
    memset(cnt, 0, sizeof cnt);
    int ans = 0;
    int i = 1;
    ans += add(i);
    int j = 1;
    i++;
    if(ans == n)return true;
    while(i < data.size() -1){
        ans += add(i);
        while(data[i].first- data[j].first > len){
            ans += remove(j);
            j++;
        }
        i++;
        if(ans == n)return true;
    }
    return false;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    int x, y;
    FOR(i, n){
        cin >> x >> y;
        if(y < x)swap(x, y);
        data.pb(mp(x, i));
        data.pb(mp(y, i));
    }
    sort(data.rbegin(), data.rend());
    map<int, bool> found;
    int ans = 1e18;
    int start =-1;
    FOR(i, data.size()){
        //debug(data[i].first);
        if(found[data[i].second] && start == -1){
            start = data[i].first;
        } 
        found[data[i].second] = true;
        if(found.size() == n){
            ans =min(ans, (data[0].first - data[i].first)*((start == -1 ? data[i+1].first : start)- data.back().first)); 
            break;
        }
    }
    if(data[0].second == data.back().second){
        cout << ans;
        return 0;
    }
    int len = data[0].first - data.back().first;

//    debug(len);
    reverse(data.begin(), data.end());
    int s= 0, e = 1e9;
    while(s <= e){
        int mid = (s+e)/2;
        if(check(mid)){
            e= mid-1;
            ans = min(ans, len*mid);
        }else s= mid+1;
    }
    cout << ans;

}




Measured memory_bytes: 22504
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define mp make_pair
#define REP(m,n) for(ll i=m;i<n;i++)
#define REPj(m,n) for(ll j=m;j<n;j++)
#define MOD 1000000007
#define INF 10000000000000000

int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ans=min(ans*2,ans+k);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

#define AUTO 0

#if AUTO
  lint N = 999'999'999;

  bool query(lint n) {
    std::cout << '?' << ' ' << n << std::endl;
    bool cmp0 = n <= N;
    bool cmp1 = std::to_string(n) <= std::to_string(N);
    bool ans = cmp0 == cmp1;
    debug(cmp0,cmp1);
    char c = ans ? 'Y' : 'N';
    std::cout << c << std::endl;
    return ans;
  }
#else
  bool query(lint x) {
    std::cout << '?' << ' ' << x << std::endl;
    char c; std::cin >> c;
    return c == 'Y';
  }
#endif

void answer(lint x) {
  std::cout << '!' << ' ' << x << std::endl;
  exit(0);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int pmax = 18;
  lint p0 = [&] {
    lint p = 1, q = 10;
    while (p <= 18) {
      if (!query(q)) return p;
      p++, q *= 10;
    }
    return -1ll;
  }();
  lint p1 = [&] {
    auto ck = [&] (lint p) {
      lint q = 1;
      loop(p) q *= 10;
      q--;
      return query(q);
    };
    for (int p = pmax; p >= 1; p--) {
      if (!ck(p)) return p + 1;
    }
    return 1;
  }();
  debug(p0,p1);
  lint p = p0 == -1 ? p1 : std::max(p0,p1);
  assert(1 <= p && p <= pmax);

  if (p == pmax) {
    lint ans = 1;
    loop(p) ans *= pmax;
    answer(ans);
  }

  auto ans = [&] {
    auto ck = [&] (lint mid) {
      lint x = mid * 10 +9;
      return query(x);
    };

    lint ok = 1;
    loop(p) ok *= 10;
    lint ng = ok / 10;
    ok--, ng--;
    while (ok - ng > 1) {
      lint mid = (ok + ng) / 2;
      (ck(mid) ? ok : ng) = mid;
    }
    return ok;
  }();

  answer(ans);
  return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)cout<<k;
    else if(k>a&&k<=(a+b))cout<<a;
    else if(k>a+b&&k<=(a+b+c))cout<<a-(k-a-b);
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>

using namespace std;

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

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

// Warshall–Floyd algorithm ワーシャルフロイド法
std::vector<std::vector<long long>> warshallFloyd(const WGraph &G) {
    int n = (int)G.size();
    std::vector<std::vector<long long>> dis(n, std::vector<long long>(n, LINF));
    for (int i=0; i<n; i++) {
        dis.at(i).at(i) = 0;
    }
    for (int i=0; i<n; i++) {
        for (auto e : G.at(i)) {
            dis.at(i).at(e.first) = e.second;
        }
    }

    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                dis.at(i).at(j) = std::min(dis.at(i).at(j), dis.at(i).at(k) + dis.at(k).at(j));
            }
        }
    }

    return dis;
}

void solve() {
    int n, m;
    cin >> n >> m;
    WGraph G(n);
    for (int i=0; i<m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G.at(a-1).push_back({b-1, c});
        G.at(b-1).push_back({a-1, c});
    }

    int res = 0;
    auto dis = warshallFloyd(G);
    for (int i=0; i<n; i++) {
        for (auto p : G.at(i)) {
            if (dis.at(i).at(p.first) < p.second) {
                res++;
            }
        }
    }

    cout << res / 2 << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 384
import copy
[h,w,k] = [int(i) for i in input().split()]
c = []
for i in range(h):
    tmp = input()
    tmp_ls = []
    for j in range(len(tmp)):
        tmp_ls.append(tmp[j])
    c.append(tmp_ls)
cnt = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        tmp = copy.deepcopy(c)
        cnt_b = 0
        bin_h = bin(i)[2:]
        bin_h = "0" * (h - len(bin_h)) + bin_h
        bin_w = bin(j)[2:]
        bin_w = "0" * (w - len(bin_w)) + bin_w
        #print(bin_h,bin_w)
        for p in range(h):
            for q in range(w):
                if bin_h[p]== "1" or bin_w[q] == "1":
                    tmp[p][q] = "."
        #print(tmp)
        for p in range(h):
            for q in range(w):
                if tmp[p][q] == "#":
                    cnt_b += 1
        #print(cnt_b)
        if cnt_b == k:
            cnt += 1
print(cnt)


Measured memory_bytes: 9336
import sys
input = sys.stdin.readline

n = int(input())
lis = list(map(int, input().split()))
res = sum(lis)
su = [0] * n

for i in range(n):
    if i < 2:
        su[i] = lis[i]
    else:
        su[i] = su[i-2] + lis[i]

ans = []
ans_a = ans.append

for i in range(n):
    if i == 0:
        b = su[-2]
        ans_a(res-2*b)
    elif i == 1:
        b = su[-1] - su[i-1]
        ans_a(res-2*b)
    elif i == n:
        b = su[-1] - lis[-1]
        ans_a(res-2*b)
    elif i % 2 == 0:
        b = su[-2] - su[i-1] + su[i-2]
        ans_a(res-2*b)
    else:
        b = su[-1] - su[i-1] + su[i-2]
        ans_a(res-2*b)
print(*ans)


Measured memory_bytes: 18496
N, M = map(int, input().split())


class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        # 根への距離を管理
        self.weight = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


wuf = WeightedUnionFind(N)
for i in range(M):
    l, r, d = map(int, input().split())
    l, r = l - 1, r - 1
    if wuf.same(l, r):
        if d != wuf.diff(l, r):
            print('No')
            break
    else:
        wuf.union(l, r, d)
else:
    print('Yes')


Measured memory_bytes: 11944
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,k,x[105],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		int b=min(x[i],k-x[i]),a=1e4;
		a=min(a,b*2);
		ans+=a;
	} 
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

bool IsLunlun(string S) {
	int N = S.length();
	for (int i = 0; i < N - 1; i++) {
		if (S[i] < '0' || S[i] > '9') return false;
		if (S[i] - S[i + 1] < -1 || S[i] - S[i + 1]>1) return false;
	}
	if (S[N - 1] < '0' || S[N - 1] > '9') return false;
	return true;
}

long long lunlun(int K) {
	if (K <= 9) return K;
	long long buf = lunlun(K - 1);
	if (IsLunlun(to_string(buf + 1))) return buf + 1;
	else return buf + 9;
}

int main() {
	int K;
	cin >> K;
	vector<string> Lunlun(K + 1);
	int now = 1;
	for (int i = 1; i <= K; i++) {
		if (i <= 10) Lunlun[i] = to_string(i);
		else {
			Lunlun[i] = Lunlun[i - 1];
			Lunlun[i][Lunlun[i].length() - 1]++;
			if (!IsLunlun(Lunlun[i])) {
				now++;
				Lunlun[i] = Lunlun[now] + (char)(Lunlun[now][Lunlun[now].length() - 1] - 1);
				if (!IsLunlun(Lunlun[i])) {
					Lunlun[i] = Lunlun[now] + (char)(Lunlun[now][Lunlun[now].length() - 1]);
				}
			}

		}
	}
	cout << Lunlun[K] << endl;
}

Measured memory_bytes: 6144
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

cnt = 0
flag = False
for i in a:
    if i <= x:
        x -= i
        cnt += 1
        if x == 0:
            flag = True
    else:
        break
else:
    if not flag:
        cnt -= 1
print(cnt)

Measured memory_bytes: 9176
program answer
  implicit none
  integer :: i, A, B, K, c, ans
  read(*,*) A, B, K
  call gcd(A,B,c)
  call yaku(c,K,ans)
  write(*,*) ans
  
  stop
contains
  subroutine gcd(a,b,ans)
    implicit none
    integer :: a, b, ans, c
    if(b>a) then
       c=b
       b=a
       a=c
    end if
    do
       if(mod(a,b)==0) then
          ans=b
          exit
       end if
       c=b
       b=mod(a,b)
       a=c
    end do
  end subroutine gcd

  subroutine yaku(a,k,ans)
    implicit none
    integer :: a, k, ans, i, j
    integer :: s(a)
    s=0
    j=0
    do i = a, 1, -1
       if(mod(a,i)==0) then
          j=j+1
          s(j)=i
       end if
    end do
    ans=s(k)
  end subroutine yaku
 end program answer

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

int main(){
 string A,B;
  cin >> A >>B;
 int x =A.length();
 int y=B.length();
  bool greater=false;
 bool equal=false;
 if(x>y){
   greater=true;
}
 if(x<y){
   greater =false;
   }
 if(x==y){
   for(int i=0;i<x;++i)
    { if(A[i] > B[i]){
   greater=true;
   equal=false;
       break;
       }

        if(A[i]<B[i]){
         greater=false;
         equal=false;
         break;
       }
   if(A[i]==B[i]){
     equal =true;
   }
  }
   }
 if(greater==true && equal==false)
   cout << "GREATER"<<endl;
 if(greater==false && equal==false)
   cout << "LESS"<<endl;

 if(equal==true)
   cout << "EQUAL"<<endl;
 }

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	A := make([]int, N)

	// input
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	isAllEven := true
	ans := 0
	for {
		for i := 0; i < N; i++ {
			if A[i]%2 != 0 {
				isAllEven = false
				break
			}
			A[i] /= 2
		}
		if !isAllEven {
			break
		}
		ans++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>

int main(){
	int A,B,C,D;
	std::cin>>A>>B>>C>>D;
	int start,stop;
	
	if(A>C){
		start = A;
	}else{
		start = C;
	}
	if(B>D){
		stop = D;
	}else{
		stop = B;
	}
	if(stop-start < 0){
		std::cout<<0;
	}else{
		std::cout<<(stop - start);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int D1[N],D2[N];
  for (long i = 0; i < N; i++) {
      cin >> D1[i] >> D2[i];
  }
  
  for (long i = 0; i < N-2; i++) {
      if(D1[i] == D2[i] && D1[i+1] == D2[i+1] && D1[i+2] == D2[i+2]) {
          cout << "Yes" <<endl;
          exit(0);
      }
  }

cout << "No" <<endl;

  
  

}

   
    


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int n,m,q;
int a[510][510];
int s[510][510];
int l,r;

int main()
{
    cin>>n>>m>>q;
    for (int i=0; i<m; ++i)
    {
        cin>>l>>r;
        a[l][r]+=1;
    }
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n; ++j)
            s[i][j]=s[i][j-1]+a[i][j];
    for (int i=1; i<=q; ++i)
    {
        cin>>l>>r;
        int ans=0;
        for (int j=l; j<=r; ++j)
            ans+=s[j][r];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//dream dreamer erase eraser
int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'r' && s[i+1] == 'e'){
      if(s[i+2] == 's' && s[i+3] == 'a' && s[i+4] == 'r' && s[i+5] == 'e'){
        i += 5;
        continue;
      }
      if(s[i+2] == 'm'&&s[i+3] == 'a'&&s[i+4] == 'e'&&s[i+5] == 'r'&&s[i+6] == 'd'){
        i += 6;
        continue;
      }
      else{
        cout << "NO" <<endl;
        return 0;
      }
    }
    if(s[i] == 'm'&&s[i+1] == 'a'&&s[i+2] == 'e'&&s[i+3] == 'r'&&s[i+4] == 'd'){
      i+=4;
      continue;
    }
    if(s[i] == 'e'&&s[i+1] == 's'&&s[i+2] == 'a'&&s[i+3] == 'r'&&s[i+4] == 'e'){
      i += 4;
      continue;
    }else{
      cout << "NO" <<endl;
      return 0;
    }
  }
  cout << "YES"<<endl;
}

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

ll n;
string s;

char tc(ll a) {
	return 'a' + a - 1;
}

void f(ll n, ll k) {
	ll r = n%k;
	ll q = n/k;
	if (n == k) {
		s = tc(k) + s;
	} else if (r == 0) {
		s = tc(k) + s;
		if (q-1 > 0) f(q-1, k);
	} else if (q == 0) {
		s = tc(r) + s;
	} else {
		s = tc(r) + s;
		f(q, k);
	}
	
}

int main() {
	cin >> n;
	s = "";
	f(n, 26);
	cout << s << "\n";
}


Measured memory_bytes: 3628
from itertools import accumulate
r, D, x_2000 = map(int, input().split())

ans = '\n'.join(
    [
        str(x)
        for x in accumulate(
            [x_2000] + list(range(10)),
            lambda acc, _: r * acc - D
        )
    ][1:]
)

print(ans)


Measured memory_bytes: 3060
import math
N,M=map(int,input().split())

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

if N<=1 and M<=1:
    print(0)
elif N>=2 and M>=2:
    print(int(combi(N,2))+int(combi(M,2)))
elif N>=2 and M<=1:
    print(int(combi(N,2)))
elif N<=1 and M>=2:
    print(int(combi(M,2)))

Measured memory_bytes: 3064
n,m = map(int,input().split())
h = tuple(map(int,input().split()))
l = set([tuple(map(int,input().split())) for i in range(m)])
x = [[] for i in range(n)]
ans=0
for t in l:
    x[t[0]-1].append(h[t[1]-1])
    x[t[1]-1].append(h[t[0]-1])
for k,li in enumerate(x):
    a = h[k]
    if li == []:
        ans+=1
    else:
        if a>max(li):
            ans+=1
print(ans)

Measured memory_bytes: 40436
def examA():
    N, A, B = LI()
    ans = min(A*N,B)
    print(ans)
    return

def examB():
    N, D = LI()
    X = [LI() for _ in range(N)]
    ans = 0
    for i,j in itertools.combinations(X,2):
        cur = 0
        for k in range(D):
            cur += (i[k]-j[k])**2
        cur **=0.5
        if cur==int(cur):
            ans +=1
    print(ans)
    return

def examC():
    L, R = LI()
    cur = []; ans = 10**9
    for i in range(L,min(2019+L,R)+1):
        if i%2019==0:
            ans = 0
            break
        else:
            cur.append(i%2019)
    if ans==0:
        print(ans)
        return
    N = len(cur)
    for i,j in itertools.combinations(cur,2):
        ans = min(ans,(i*j)%2019)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


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

int main(){
    int a, b, c, x, y, z, ans;
    cin >> a >> b >> c >> x >> y;
    z = (x > y)? (x-y)*a : (y-x)*b;
    ans = min(a*x + b*y, min(2*c*max(x,y), z + 2*c*min(x, y)));
    cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
           string[] word = Console.ReadLine().Split(' ');
            int a = int.Parse(word[0]);
            int b = int.Parse(word[1]);
            int c = int.Parse(word[2]);
            int m = 0;
            int A = a + b;
            int B = a + c;
            int C = b + c;
            if (a >= b && a >= c)
                m = a;
            else if (b >= a && b >= c)
                m = b;
            else
                m = c;
            //別解
            //int m = a:
            //if(b>m)m=b
            //if(c>m)m=c
            int s = a + b + c - m;



            Console.WriteLine(s);
            //↓消えるのを防ぐ
          
         
             

        }
    }
}


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

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    auto func = [&] (ll x) -> ll {
        return (A*x) / B - A * (x/B);
    };
    // observation: cyclic each B
    /*
    for(int i = 0; i < 100; i++) {
        if (i % B == 0)
            cout << endl;
        cout << func(i) << endl;
    } */
    if (N >= B) {
        cout << func(B-1) << endl;
    } else {
        cout << func(N) << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c] <- getLine
  putStrLn $ if a == b && b == c then "No" else "Yes"


Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
const int MOD=998244353;
map<string,int> ms;
int f(string x)
{
	if(ms.count(x)) return ms[x];
	int l=x.size();
	ll ans=f(x.substr(0,l-1))*(1LL+(x[l-1]=='1'))%MOD;
	for(int i=2;i<=l;++i)
	{
		for(int j=1;j*i<=l;++j)
		{
			ll tmp=f(x.substr(0,l-j*i));
			string tt;
			for(int k=0;k<j;++k) tt.pb('1');
			for(int k=l-j*i;k<l;++k)
				tt[(k-(l-j*i))%j]&=x[k];
			tmp=tmp*f(tt)%MOD;
			ans=(ans+tmp)%MOD;
		}
	}
	return ms[x]=ans%MOD;
}
int main()
{
	ms["0"]=ms[""]=1; ms["1"]=2;
	string c; cin>>c;
	cout<<f(c)<<"\n";
}


Measured memory_bytes: 5632
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int n = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());

		int num = vals[0];
		int elem = vals[1];
		int d=vals[2];



		int u = num * 2 - ( d * 2 );
		if(d==0){u=num;}
		double all = Math.Pow(num, 2);

		double res = (1.0*u / all)*(1.0*elem-1);
		
		
		//for ( int i = 0; i < str.Length; i+=n ) {

			//Console.Write(str[i]);
		//}



		Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}
	
	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
#include<stdint.h>
#include<inttypes.h>
#include<stdio.h>
int main(){
	int64_t n,k;
	scanf("%" SCNd64 " %" SCNd64, &n, &k);
	printf("%" PRId64, n%k > k-(n%k) ? k-(n%k) : n%k);
  return 0;
}


Measured memory_bytes: 2096
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    let s = input[0]
    let t = ""
    const QN = parseInt(input[1]);
    for(let i = 2; i<2+QN; i++){
        let q = input[i].split(" ")
        if(q[0] == 1){
            const tmp = s
            s = t
            t = tmp
        } else {
            if(q[1] == 1){
                t += q[2]
            } else {
                s += q[2]
            }
        }
    }
    t = t.split("").reverse().join("")
    t += s
    console.log(t)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 67400
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <queue>

using namespace std;

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

	int N, H;
	cin >> N >> H;

	int max_a = 0;
	vector<int> b(N, 0);

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a >> b[i];

		max_a = max(max_a, a);
	}

	sort(b.begin(), b.end(), [](const int& l, const int& r)
	{
		return l > r;
	});

	int result = 0;
	for (int e : b)
	{
		if (e > max_a && H > 0)
		{
			H -= e;
			result++;
		}
		else
		{
			break;
		}
	}

	if (H > 0)
	{
		result += (H / max_a) + (H % max_a != 0);
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005, inf=1e9+5;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll h,w;cin>>h>>w;
    char arr[h][w];
    repn(i,h){
        repn(j,w){
            cin>>arr[i][j];
        }
    }
    ll dp[h][w]={};
    dp[h-1][w-1]=1;
    bac(i,h-1,0){
        bac(j,w-1,0){
            if(arr[i][j]=='#')continue;
            if(j+1<w){
                dp[i][j] +=dp[i][j+1];
            }
            if(i+1<h){
                dp[i][j] +=dp[i+1][j];
            }
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[0][0];
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 9088
n,m,l = map(int, input().split())
l1 = [list(map(int,input().split())) for _ in range(n)]
l2 = [list(map(int,input().split())) for _ in range(m)]

ans = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        ansN = 0
        for k in range(m):
            ansN += l1[i][k]*l2[k][j]
        ans[i][j]= ansN

for i in ans:
    print(*i)



Measured memory_bytes: 7048
#include <iostream>
#include <algorithm>

using namespace std;

//O(log n)
const int MAX_N = 100000;

//[1, n]
int n, bit[MAX_N + 1];

int sum(int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}

main(){
  int q;
  cin >> n >> q;
  fill(bit, bit+MAX_N+1, 0);
  for(int i=0;i<q;i++){
    int a, b, c;
    cin >> a >> b >> c;
    if(a) cout << sum(c) - sum(b-1) << endl;
    else add(b, c);
  }
}

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

namespace ABC118B
{
    class MainClass
    {
        static int[] s;


        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            int m = s[1];
            int[] syu = new int[m+1];


            for(int i = 0; i < n; i++)
            {
                int[] ka = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
                for(int j = 1; j <= ka[0]; j++)
                {
                     syu[ka[j]]++;
                }
            }
            int ans = 0;

            for(int i = 0; i < m+1; i++)
            {
                if (syu[i] == n)
                {
                    ans++;
                }
            }


            Console.WriteLine(ans);
            return;
        }
    }
}


Measured memory_bytes: 13268
def draw(h,w):
	t = "#." * 150
	s = t[0:w]
	k = t[1:w+1]
	for i in range(0,h/2):
		print s
		print k
	if h%2==1:
		print s
	print

if __name__ == "__main__":
	while True:
		h,w = map(int, raw_input().split())
		if h==0 and w==0:
			break
		else:
			draw(h,w)

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back



int main(){
int w, a, b;
cin >> w >> a >> b;
if(a<b)swap(a,b);

if(b+w < a)cout << a-(b+w);
else cout << 0 << endl;






return 0;}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch UnevenNumbers | diff UnevenNumbers.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address UnevenNumbers.cpp && ./a.out

/*
 
 8/6/2019
 
 11:49-
 
 */

int N;

void solve() {
  int res=0;
  FORE(n,1,N) {
    int a=n/10000;
    if(0<a&&a<10) {
      ++res;
      continue;
    }
    a=n/100;
    if(0<a&&a<10) {
      ++res;
      continue;
    }
    a=n/1;
    if(0<a&&a<10) ++res;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


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

namespace ABC104A
{
    class ABC104A
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());

            foreach (var v in Solve(n).Reverse())
            {
                Console.Write(v);
            }
            Console.WriteLine();
        }

        static string Solve(double n)
        {
            const double dec = -2;
            if (n == 0)
            {
                return "0";
            }

            var s = "";
            double k = n < 0 ? -1 : 1;

            while (n != 0)
            {
                if (n % dec == 0)
                {
                    s += "0";
                } else
                {
                    s += "1";
                    --n;
                }

                n /= dec;
            }

            return s;
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 

ll mod = 1e9+7;

ll add(ll a, ll b){
	a = a%mod;
	b = b%mod;
	return (mod+(a+b)%mod)%mod;
}

ll mul(ll a, ll b){
	a = a%mod;
	b = b%mod;
	return (mod+(a*b)%mod)%mod;
}

vector<ll> prime(1000001, -1);

void sieve(ll ma){
	
	for(ll i=2;i<=ma;++i){
		if(prime[i]==-1){
			for(ll j=2*i;j<=ma;j+=i){
				if(prime[j]==-1){
					prime[j] = i;
				}
			}
		}
	}
}

int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	sieve(1000001);
	
	ll n;
	cin>>n;
	
	ll arr[n];
	unordered_map<ll,ll> mp;
	ll flg = 0;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		ll x = arr[i];
		while(x>1){
			ll val;
			if(prime[x]==-1){
				val = x;
			}
			else{
				val = prime[x];
			}
			mp[val]++;
			if(mp[val]>1){
				flg = 1;
			}
			while(x%val==0){
				x = x/val;
			}
		}
	}
	
	if(flg==0){
		cout<<"pairwise coprime"<<endl;
	}
	else{
		ll x = arr[0];
		for(ll i=1;i<n;i++){
			x = __gcd(arr[i], x);
		}
		if(x==1){
			cout<<"setwise coprime"<<endl;
		}	
		else{
			cout<<"not coprime"<<endl;
		}
	}
	
}


Measured memory_bytes: 22288
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, a, b;
    cin >> n >> a >> b;
    if (n * a < b) {
        cout << n * a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    for(int i = 0; i < n; ++i){
        if(a[i] % 2 != 0)   continue;
        if(a[i] % 3 != 0 && a[i] % 5 != 0){
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
}

Measured memory_bytes: 256
//s
#include<stdio.h>
#define max(x, y) ((x)<(y)?(y):(x))
typedef long long ll;

int main()
{
	int n;
	ll t, a, s1=0ll, s2=0ll, rate;
	for(scanf("%d", &n); n--;)
	{
		scanf("%lld%lld", &t, &a);
		if(t>=s1 && a>=s2) s1=t, s2=a;
		else
		{
			rate=max(s1/t+(s1%t!=0ll), s2/a+(s2%a!=0ll));
			s1=t*rate, s2=a*rate;
		}
	}
	printf("%lld\n", s1+s2);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main()
{
  int i;

  int n,j;


 
  /*flagojfos*/
  int flag , count=0;


  scanf("%d",&n);

  int a[n];
  

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

    scanf("%d",&a[i]);
  }


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

    if(a[i]==2){}
    else if(a[i]%2==0){
      flag=1;
    }
 
    else {   
      for( j=3;j<=sqrt(a[i]);j+=2 ) {
     
	if( a[i]%j==0 ) {

	  flag = 1;  
	  break;
	  
	}
      }
    }
    
    if( flag==0 ){
      count++;
    }
    
  } 

 
  
  printf("%d\n",count);
 
  return 0;
}



Measured memory_bytes: 2108
X, N = map(int,input().split())
p = {int(x) for x in input().split()}


ans = 0
i = 0

while True:
    tmp = X - i
    if tmp not in p:
        ans = tmp
        break
    tmp = X + i
    if tmp not in p:
        ans = tmp
        break
    i += 1
print(ans)
    

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10,mod=1e9+7;
int x[10],y[10],Fac[N],inv[N];
inline void priwork(){
	Fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<N;i++)Fac[i]=1ll*Fac[i-1]*i%mod;
	for(int i=2;i<N;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<N;i++)inv[i]=1ll*inv[i]*inv[i-1]%mod;
}
inline void add(int &x,int y){x+=y;if(x<0)x=(x%mod+mod)%mod;if(x>=mod)x-=mod;}
inline int C(int a,int b){
	return 1ll*Fac[a]*inv[b]%mod*inv[a-b]%mod;
}
inline int G(int x,int y){return C(x+y,x);}
inline int F(int x1,int y1,int x2,int y2){
	return (1ll*G(x2+1,y2+1)-G(x1,y2+1)-G(x2+1,y1)+G(x1,y1))%mod;
}
int main(){
  priwork();
  for(int i=1;i<=6;i++)cin>>x[i];
  for(int i=1;i<=6;i++)cin>>y[i];

  int ans=0;
  for(int x1=x[3],y1=y[3];x1<=x[4];x1++)
	  add(ans,1ll*F(x1-x[2],y1-1-y[2],x1-x[1],y1-1-y[1])*F(x[5]-x1,y[5]-y1,x[6]-x1,y[6]-y1)%mod*(mod-x1-y1)%mod);
  for(int x1=x[3],y1=y[3];y1<=y[4];y1++)
	  add(ans,1ll*F(x1-1-x[2],y1-y[2],x1-1-x[1],y1-y[1])*F(x[5]-x1,y[5]-y1,x[6]-x1,y[6]-y1)%mod*(mod-x1-y1)%mod);
  for(int x2=x[3],y2=y[4];x2<=x[4];x2++)
	  add(ans,1ll*F(x2-x[2],y2-y[2],x2-x[1],y2-y[1])*F(x[5]-x2,y[5]-y2-1,x[6]-x2,y[6]-y2-1)%mod*(x2+y2+1)%mod);
  for(int x2=x[4],y2=y[3];y2<=y[4];y2++)
	  add(ans,1ll*F(x2-x[2],y2-y[2],x2-x[1],y2-y[1])*F(x[5]-x2-1,y[5]-y2,x[6]-x2-1,y[6]-y2)%mod*(x2+y2+1)%mod);

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


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main(){
  int n;
  double  d;
  cin >> n >> d;
  double x, y;
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    cin >> x >> y;
    double dist = sqrt((x*x) + (y*y));
    if(dist <= d) cnt ++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3836