akhauriyash/Code-Regression huggingface dataset:
(N,M,P),*E=[list(map(int,s.split()))for s in open(0).readlines()]
D=[0]*2+[-9e9]*N
def f():
	for _ in D:
		for (a,b,c)in E:D[b]=max(D[b],D[a]+c-P)
	return D[N]
s=f()
print([max(s,0),-1][s<f()])

Measured memory_bytes: 52956
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main(){
	int a, b;
	char op[2];
	fscanf(stdin, "%d %c %d", &a, op, &b);
	if (*op == '+') P(d, a + b);
	else P(d, a - b);
	return 0;
}

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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	int m = max(max(a, b), c);
	cout << m * 10 + sum - m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long  ll;

int main(){
    faster
    int n,m; cin >> n >> m;
    vector<int> deg(n);
    vector<int> dp(n);
    vector<vector<int>> g(n);
    for(int i = 0;i < m;i++){
        int x,y; cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
        deg[y]++;
    }
    queue<int> q;
    int ans = 0;
    for(int i = 0;i < n;i++)if(deg[i] == 0)q.push(i);
    while(!q.empty()){
        int v = q.front(); q.pop();
        ans = max(ans, dp[v]);
        for(auto i : g[v]){
            dp[i] = max(dp[i], dp[v] + 1);
            deg[i]--;
            if(deg[i] == 0)q.push(i);
        }
    }
    cout << ans << endl;
    return 0;
}

    



Measured memory_bytes: 6528
N = int(input())
S = [input() for _ in range(N)]
dic = dict()
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
score_sorted = sorted(dic.items(), key=lambda x: -x[1])
m = score_sorted[0][1]
ret = []
for k,v in score_sorted:
    if v == m:
        ret.append(k)
    else:
        break
ret = sorted(ret)
for item in ret:
    print(item)

Measured memory_bytes: 48908
// D - Maze Master
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using vi = vector<int>;
using vvi = vector<vi>;
using VC = vector<char>;
using VVC = vector<VC>;

// ワーシャルフロイド法
#define INF 100000
void warshall_floyd(vvi &D){//D: distance
	rpz(relay,D.size()) rpz(from,D.size()) rpz(to,D.size())
		D[from][to] = min(D[from][to], D[from][relay] + D[relay][to]);
}

int main(){
	int H,W; cin>>H>>W;
	VVC S(H+2, VC(W+2, '#'));//外周を壁で囲む
	rp(h, 1, H+1){
		string s; cin>>s;
		rp(w, 1, W+1) if(s[w-1]=='.') S[h][w] = '.';//未訪問
	}

	// for(auto v:S){for(auto x:v){cout<<x<<" ";}puts("");}///

	int N = H*W;
	vvi D(N, vi(N, INF));//ワーシャルフロイドのコスト表
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	rp(ph, 1, H+1){
		rp(pw, 1, W+1){
			if(S[ph][pw] != '.') continue;//壁
			int i = (ph-1)*W + (pw-1);//from
			D[i][i] = 0;
			rp(k, 0, 4){
				int h = ph + dy[k], w = pw + dx[k];
				if(S[h][w] != '.') continue;//壁
				int j = (h-1)*W + (w-1);//to
				D[i][j] = D[j][i] = 1;
			}
		}
	}

	// for(auto v:D){for(auto x:v){if(x==INF) cout<<"- ";else cout<<x<<" ";}puts("");}///
	// puts("==========================");

	warshall_floyd(D);

	// for(auto v:D){for(auto x:v){if(x==INF) cout<<"- ";else cout<<x<<" ";}puts("");}///
	// puts("==========================");

	int ans = 0;
	rp(i, 0, N){
		rp(j, 0, N){
			if(D[i][j] != INF) ans = max(ans, D[i][j]);
		}
	}
	cout<< ans <<endl;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    double r;
    cin >> r;
    r = 2* r * M_PI;
    c(r);
    return 0;
}


Measured memory_bytes: 3800
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,*A = map(int,read().split())

MOD = 10 ** 9 + 7

lcm = reduce(lambda x,y: x//gcd(x,y)*y, A)

answer = sum(lcm//x for x in A)
answer %= MOD
print(answer)

Measured memory_bytes: 5880
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int n=s.length(),i,j,a[2][2];
    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            a[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        a[i%2][s.at(i)-'0']++;
    }
    cout << min(a[0][0]+a[1][1],a[0][1]+a[1][0]) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll h,w,n;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
const int M = 1000005;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
	//cout << "OK" << endl;
  }
  vector<int> cnt(M);
  
  for(int x : a){
    if(cnt[x] != 0){
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i < M; i += x){
      cnt[i]++;
    }
  }
  int ans = 0;
  for(int x : a){
    if(cnt[x] == 1){
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7960
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
ans = 0

0.upto(A) do |i|
  break if i * 500 > X
  if X == i * 500
    ans += 1
    break
  end
  0.upto(B) do |j|
    # n:残金
    n = X - i * 500
    if j > 0 && n == (j * 100)
      ans += 1
    end
    n = n - j * 100
    if n > 0 && n / 50 <= C
      ans += 1
    end
  end
end

puts ans


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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>s(a);
		int m = 0;
		for (int b = 0; b < a; b++) {
			int d;
			cin >> d;
			s[b] = d;
			m += d;
		}
		sort(s.begin(), s.end());
		cout << (m - s[0] - s[s.size() - 1]) / (a-2) << endl;
	}
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    char c;
    cin>>c;
    c++;
    cout<<c<<nl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S;
    cin >> S;
    S[3]='8';
    cout << S << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(void){
  int *ip;
  int n, i;

// 確保する要素数
  scanf("%d",&n);
  ip = (int *)malloc(n * sizeof(int));

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

  for(i=1; i<=n; i++){
    printf("%d", ip[n-i]);
    if(i==n)
      break;
    printf(" ");
  }
  printf("\n");

  free(ip);
  return 0;

}



Measured memory_bytes: 2048
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

A, B = map(int,input().split())

for i in range(100):
  if i*(A-1)+1 >= B:
    print(i)
    exit()

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

int main() {
  map<string, int> v;
  string a,b,c;
  cin >> a >> b;
  cin >> v[a] >> v[b];
  cin >> c;
  v[c]--;
  cout << v[a] << " " << v[b] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long m = 0, a = 0, r = 0, c = 0, h = 0;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s[0] == 'M') m++;
    if(s[0] == 'A') a++;
    if(s[0] == 'R') r++;
    if(s[0] == 'C') c++;
    if(s[0] == 'H') h++;
  }
  long long ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h 
    + a*r*c + a*r*h + a*c*h + r*c*h;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_A&lang=jp
  * Character - Toggling Cases
  */
object Main {
  def main(args: Array[String]): Unit = {
    println(io.StdIn.readLine().map {
      case c if c.isUpper => c.toLower
      case c if c.isLower => c.toUpper
      case c => c
    })
  }
}

Measured memory_bytes: 43612
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()
int sumd(ll A){
    string S=to_string(A);
    ll size=S.size();
    ll ans=0;
    REP(i,size){
        ans+=S[i]-'0';
    }
    return ans;
}


int main(){
    int k;
    cin>>k;
    ll a=1;
    ll p=1;
    REP(i,k){
        cout<<a<<endl;
        ll c=a+p;
        ll d=a+p*10;
        if(c*sumd(d)<=d*sumd(c)){
            a=c;
        }else{
            a=d;
            p*=10;
        }
    }
}

Measured memory_bytes: 256
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dp = [[0]*3 for _ in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, n):
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i])
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i])
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i])

print(max(dp[-1]))


Measured memory_bytes: 34636
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    query = [list(map(int, input().split())) for _ in range(q)]

    D = Counter(A)
    res = sum(A)
    for b, c in query:
        if D.get(b) is not None:
            res -= b * D.get(b)
            res += c * D.get(b)

        if D.get(c) is not None:
            D[c] += D[b]
        else:
            D[c] = D[b]
        D[b] = 0

        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 40032
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=2e5+5;
int n;
int a[N];
void solve(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    unordered_map<int,int> mp1,mp2;
    ll ans=0;
    for(int i=0;i<n;i++){
        ans=ans+mp1[i+a[i]]+mp2[i-a[i]];
        mp2[i+a[i]]++;
        mp1[i-a[i]]++;
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 34736
N = int(raw_input())
T_list = map(int, raw_input().split())
A_list = map(int, raw_input().split())

low_list = [1]*N
high_list = [1]*N

t_now = 0
for i in range(N):
    if T_list[i] > t_now:
        t_now = T_list[i]
        low_list[i] = T_list[i]
        high_list[i] = T_list[i]
    else:
        high_list[i] = T_list[i]
a_now = 0
for j in range(N):
    i = N - 1 - j
    if A_list[i] > a_now:
        a_now = A_list[i]
        low_list[i] = max(A_list[i], low_list[i])
        high_list[i] = min(A_list[i], high_list[i])
    else:
        high_list[i] = min(A_list[i], high_list[i])
    
res = 1
for i in range(N):
    if high_list[i] < low_list[i]:
        res = 0
        break
    else:
        res = res*(high_list[i] - low_list[i] + 1) % 1000000007

print res

Measured memory_bytes: 14524
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int h, w, n;
int sx, sy;
int c[1001][1001];
int x[10];
int y[10];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int used[1001][1001];

int dfs(int stx, int sty, int gx, int gy){
		queue<P> q;
		for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++)used[i][j] = -1;
		}
		used[stx][sty] = 0;
		q.push(mk(stx, sty));
		while(!q.empty()){
				P p = q.front(); q.pop();
				int xx = p.first;
				int yy = p.second;
				if(xx == gx && yy == gy){
						return used[gx][gy];
				}
				for(int i = 0; i < 4; i++){
						int nx = xx + dx[i];
						int ny = yy + dy[i];
						if(nx >= 0 && nx < h && ny >= 0 && ny < w && used[nx][ny] == -1 && c[nx][ny] == 0){
								used[nx][ny] = used[xx][yy] + 1;
								q.push(mk(nx, ny));
						}
				}
		}
		return -1;
}

int main(int argc, char const* argv[])
{
	cin >> h >> w >> n;
	for(int i = 0; i < h; i++){
			string s;
			cin >> s;
			for(int j = 0; j < w; j++){
					if(s[j] == '.')c[i][j] = 0;
					else if(s[j] == 'X')c[i][j] = -1;
					else if(s[j] == 'S'){
							sx = i;
							sy = j;
							c[i][j] = 0;
					}
					else{
							x[s[j] - '1'] = i;
							y[s[j] - '1'] = j;
							c[i][j] = 0;
					}
			}
	}
	int res = 0;
	for(int i = 0; i < n; i++){
			if(i == 0)res += dfs(sx, sy, x[0], y[0]);
			else res += dfs(x[i-1], y[i-1], x[i], y[i]);
	}
	cout << res << endl;
	return 0;
}



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

int func(int n, int s, int sum = 0, int mx = -1){
  if(n == 0){
    return (s == sum) ? 1 : 0;
  }

  int ans = 0;
  for(int i = mx + 1; i <= 9; i++){
    ans += func(n - 1, s, sum + i, i);
  }
  return ans;
}


int main(void){
  while(true){
    int n, s;
    cin >> n >> s;
    if(n == 0 && s == 0){ break; }
    cout << func(n, s) << endl;
  }
  
  return 0;
}



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

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

//ループマクロ
#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 ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int a, b, c; cin >> a >> b >> c;
  if(a + b + c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}


Measured memory_bytes: 256
import collections

N, K = map(int,input().split())
A = list(map(int,input().split()))
B = collections.Counter(A)
flag = 0
ans = 0
for b in B.most_common()[::-1]:
    if flag == max(0, len(B)-K):
        break
    ans += b[1]
    flag += 1
print(ans)


Measured memory_bytes: 39344
#include <stdio.h>

int main()
{
    int a,b;
    char op;

    while(1) {
      scanf("%d %c %d", &a, &op, &b);

      if(op=='+') {
        printf("%d\n",a+b);
      }else if(op=='-'){
        printf("%d\n",a-b);
      }else if(op=='*'){
        printf("%d\n",a*b);
      }else if(op=='/'){
        printf("%d\n",a/b);
      }else if(op=='?'){
        break;
      }
         
    }

    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int solv(int n) {
  int i, a1[101], a2[101], max, res;

  for (i = 0; i < n; i++) {
    scanf("%d", a1 + i);
  }
  for (i = 0; i < n; i++) {
    scanf("%d", a2 + i);
  }

  for (i = 1; i < n; i++) {
    a1[i] += a1[i - 1];
    a2[n - i - 1] += a2[n - i];
  }

  res = 0;
  max = 0;
  for (i = 0; i < n; i++) {
    if (max < a1[i] + a2[i]) {
      res = i;
      max = a1[i] + a2[i];
    }
  }

  return max;
}

int main(int argc, char **argv) {
  int n;

  while (scanf("%d", &n) != EOF) {
    printf("%d\n", solv(n));
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 100005
ll dp[MX][101];
ll wt[101], val[101];
int main() {
	int n, w;
	cin >> n >> w;
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
		cin >> wt[i] >> val[i], sum += val[i];
	for (int i = 0; i <= n; ++i)
		for (int j = 1; j <= sum; ++j)
			dp[j][i] = 1e18;
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= sum; ++j) {
			if(j >= val[i])
				dp[j][i] =  min(dp[j][i - 1], dp[j - val[i]][i - 1] + wt[i]);
			else
				dp[j][i] = dp[j][i - 1];
		}
	}
	ll ans = 0;
	/*for(int i = 0; i <= n; ++i) {
		for (int j = 0; j <= sum; ++j)
			cout << dp[j][i] << " ";
		cout << endl;
	}*/
	for (ll i = 1; i <= sum; ++i)
		if(dp[i][n] <= w)
			ans = i;
	cout << ans << endl;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace  std;

const double cos60 = cos(M_PI / 3);
const double sin60 = sin(M_PI / 3);

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos60 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin60 + rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin60 
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos60 + rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

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

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

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

using namespace std;

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

    int N; cin>>N;
    vector<string> S(N);
    for(auto& s : S) {
        cin>>s;
        sort(s.begin(), s.end());
    }
    sort(S.begin(), S.end());

    size_t ans = 0;
    string& ps = S[0];
    size_t len = 1;
    for (int i = 1; i < N; i++) {
        if (S[i] == ps)
            len++;
        else {
            ans += len*(len-1)/2;
            len = 1;
        }
        ps = S[i];
    }
    ans += len*(len-1)/2;
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h> 
#include<string.h>
int main()
 {
     char s[200001],t[200001]; 
    int l,i,count=0; 
    scanf("%s%s",s,t); 
    l=strlen(s);
    for(i=0;i<l;i++) { 
        if(s[i]==t[i]) { continue; }
         count++;} 
    printf("%d\n",count); 
    return 0; }


Measured memory_bytes: 2076
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
struct bimatch{
	int n;
	vector<vector<int> >G;
	vector<int>match;
	vector<bool>used;
	bimatch(int _n=0):n(_n),G(n),match(n),used(n){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int u:G[v])

		{
			int w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int count()
	{
		int ans=0;
		bool flag=true;
		fill(match.begin(),match.end(),-1);
		while(flag)
		{
			flag=false;
			fill(used.begin(),used.end(),false);
			for(int v=0;v<n;v++)if(match[v]<0&&dfs(v))ans++,flag=true;
		}
		return ans;
	}
};
int N,M;
string S[100];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>S[i];
	bimatch P(N*M);
	for(int i=0;i<N;i++)for(int j=0;j<M;j++)
	{
		if(S[i][j]=='.')for(int r=0;r<2;r++)
		{
			int x=i+(r==0),y=j+(r==1);
			if(x<N&&y<M&&S[x][y]=='.')
			{
				P.add_edge(i*M+j,x*M+y);
			}
		}
	}
	cout<<P.count()<<endl;
	for(int i=0;i<N;i++)for(int j=0;j<M;j++)if(S[i][j]=='.'&&P.match[i*M+j]>=0)
	{
		int x=P.match[i*M+j]/M,y=P.match[i*M+j]%M;
		S[i][j]=x<i?'^':x>i?'v':y<j?'<':'>';
	}
	for(int i=0;i<N;i++)cout<<S[i]<<endl;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int N,M; cin >> N >> M;
  vector<int> cnt(M,0);
  rep(i,N) {
    int K; cin >> K;
    rep(i,K) {
      int A; cin >> A;
      // cnt is zero-based.
      cnt.at(A-1)++;
    }
  }
  
  sort(cnt.rbegin(), cnt.rend());
  
  int ans = 0;
  rep(i,M) {
    if(cnt.at(i) == N) ans++;
    else { 
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  int x = 0;
  rep(i,n){
    ans = (ans+(ll)a[i]*x)%mod;
    x = (x+a[i])%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

const double EPS = 1e-9;

set<string> ng;
string check(int l, int r, const string &s){
	string ret;
	int n = s.size();
	while (0 <= l - 1 && r + 1 < n){
		if (s[l - 1] != s[r + 1]) return (r - l + 1 < 3?"":s.substr(l, r - l + 1));
		ng.insert(s.substr(l, r - l + 1));
		--l, ++r;
	}
	if (r - l + 1 < 3) return "";
	return s.substr(l, r - l + 1);
}

int main(){
	string in;
	while (getline(cin, in)){
		string s;
		for (auto &c : in){
			if ('a' <= c && c <= 'z') s.push_back(toupper(c));
			if ('A' <= c && c <= 'Z') s.push_back(c);
		}

		ng.clear();
		int n = s.size();
		set<string> ans;
		for (int i = 0; i < n; ++i){
			ans.insert(check(i, i, s));
			ans.insert(check(i+1, i, s));
		}
		bool f = true;
		for (auto &t : ans){
			if (t.empty() || ng.count(t)) continue;
			if (!f) cout << " ";
			cout << t;
			f = false;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, c, k; cin >> n >> c >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i = 0, j = 0; i < n; i = j){
		while(j + 1 < n && j - i + 2 <= c && a[j+1] <= a[i] + k) j++;
		j++;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

A -= 1
num = 0
n = 1
while n <= B:
    count = 0
    m = n * 2
    a1 = 0
    b1 = 0
    if A >= n:
        a1 = (A // m) * n
        r = A % m
        if r >= n:
            a1 += r - n + 1
    if B >= n:
        b1 = (B // m) * n
        r = B % m
        if r >= n:
            b1 += r - n + 1
    num += ((b1 - a1) % 2) * n

    n = n * 2
print(num)

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

using namespace std;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<string> grid;
    for (int i = 0; i < H; ++i)
    {
        string s;
        cin >> s;
        grid.push_back(s);
    }

    vector<string> grid_i;
    vector<string> grid_j;
    grid_i = grid;
    grid_j = grid;

    int ans = 0;

    for (int i = 0; i < pow(2, H); i++)
    {
        grid_i = grid;
        for (int x = 0; x < H; x++)
        {
            if (i >> x & 1)
            {
                for (int a = 0; a < W; ++a)
                {
                    grid_i[x][a] = '*';
                }
            }
        }

        for (int j = 0; j < pow(2, W); j++)
        {
            grid_j = grid_i;
            for (int y = 0; y < W; y++)
            {
                if ((j >> y) & 1 == 1)
                {
                    for (int b = 0; b < H; ++b)
                    {
                        grid_j[b][y] = '*';
                    }
                }
            }

            int count = 0;
            for (int c=0; c < H; ++c)
            {
                for (int d=0; d < W; ++d)
                {
                    if (grid_j[c][d] == '#') count++;
                }
            }
            if (count == K) ans++;
        }
    }

    cout << ans << endl;
}


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

using namespace std;
int arr[101];
int n;
int getstamina(int x){
	int ans = 0;
	for(int i=0;i<n;++i){
	   ans += (arr[i] - x)*(arr[i] - x);
	}
	return ans;
}
int main(){
  int mins = 2000000000;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>arr[i];
  }
  for(int i=0;i<101;++i){
  	if(mins>getstamina(i))
  	 mins = getstamina(i);
  }
  cout<<mins<<endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i, n) for (int i = 0 ; i < int(n) ; i++)
#define fore(i, s, t) for (int i = s ; i < (int)t ; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x)  cout<<it<<endl;
#define pi pair<int,int>
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y) 
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
using namespace std;
typedef long long ll;
const ll P=1e9+7;
int comb(int n){
	if(n<2) return 0;
	return n*(n-1)/2;
}
int main(){   
	int n,m;
	sc2(n,m);
	cout<<comb(n)+comb(m)<<endl;
	
}

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

int main(){
    int n;cin>>n;
    n %= 10;
    if(n==3)
        cout << "b";
    else if(n==0 || n==1 || n==6 || n==8)
        cout << "p";
    else
        cout << "h";
    
    cout << "on" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int H,W,a,b;

	scanf("%d %d",&H,&W);

	scanf("%d %d",&a,&b);

	printf("%d\n",H*(W%b)+W*(H%a)-(W%b)*(H%a));

	return 0;
}



Measured memory_bytes: 3224
#include<stdio.h>

int main (void){
	
	int H,W,i,t;
	
	for(;;){
	scanf("%d %d",&H,&W);
	if(H==0&&W==0)break;
	for(i=0;i<H;i++){
		for(t=0;t<W;t++){
			printf("#");
		}
	printf("\n");
	}
	printf("\n");
	}
	
return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define lli long long int

int main(void)
{
	lli n, k, q;
	scanf("%lld %lld %lld",&n,&k,&q);
	lli *a;
	a = (lli*)malloc(sizeof(lli)*(q));
	lli i = 0;
	while (i < q)
	{
		scanf("%lld",&a[i]);
		i++;
	}
	lli *p;
	p = (lli*)malloc(sizeof(lli)*(n+1));
	i = 0;
	while (i < n + 1)
	{
		p[i] = k-q;
		i++;
	}
	i = 0;
	while (i < q)
	{
		p[a[i]-1]++;
		i++;
	}
	i = 0;
	while (i < n)
	{
		if(p[i] > 0)
			printf("Yes\n");
		else
			printf("No\n");
		i++;
	}
	return(0);
}


Measured memory_bytes: 2048
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define INF 1e9;
#define MOD 1e9 + 7;
int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i, M) cin >> B[i];
    int A[N][M];
    rep(i, N) rep(k, M) cin >> A[i][k];
    int ans = 0;
    rep(i, N) {
        int sum = C;
        rep(k, M) sum += B[k] * A[i][k];
        if (sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int l = s.length();
  bool f = false;
  rep(i,l-1) {
    if(s[i] == 'A' and s[i+1] == 'C') f = true;
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3496
#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 COUT(x) cout<<(x)<<"\n"

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> set1;
    REP(i,s.size()){
        REP(j,k+1){
            string str = s.substr(i,j);
            set1.insert(str);
        }
    }
    auto itr = set1.begin();
    for(int i=0;i<k;i++){
        ++itr;
    }
    COUT(*itr);
    return 0;
}

Measured memory_bytes: 4724
//odds in oddness
#include <bits/stdc++.h>
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pi pair<int,int> 
#define mod 1000000007
#include<stdio.h>
using namespace std;
int main()
{
	ll int a1,b,i;
	cin>>a1>>b;
	ll int gcd=__gcd(a1,b);
	vector<ll int> v;
	for(i=1;i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			v.pb(i);
			if(i*i!=gcd)
			{
				v.pb(gcd/i);
			}
		}
	}
	sort(v.begin(),v.end());
	int sz=v.size(),c=0,j;
	int a[sz];
	memset(a,0,sizeof(a));
	for(i=0;i<sz;i++)
	{
		if(!a[i]) c++;
		for(j=i+1;j<sz;j++)
		{
			if(__gcd(v[i],v[j])!=1)
			{
				a[j]=1;
			}
		}
	}
	cout<<c;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int[] leyes = new int[4];
		int[] reyes = new int[4];

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			double l = Double.parseDouble(line.substring(0, line.indexOf(' ')));
			double r = Double
					.parseDouble(line.substring(line.indexOf(' ') + 1));
			leyes[eyesight(l)]++;
			reyes[eyesight(r)]++;
		}
		for (int i = 0; i < 4; i++) {
			System.out.println(leyes[i] + " " + reyes[i]);
		}
	}

	static int eyesight(double e) {
		int _e = (int) (e * 10);
		if (_e < 2) {
			return 3;
		} else if (_e < 6) {
			return 2;
		} else if (_e < 11) {
			return 1;
		} else {
			return 0;
		}
	}
}

Measured memory_bytes: 16916
#include<stdio.h>
#include<math.h>

int main()
{
  int x;
  
  scanf("%d",&x);
  
  int ans=1;
  int i,j;
  
  for(i=1;i<=40;i++)
  {
    for(j=2;j<=10;j++)
    {
      if(x>=pow(i,j)&&ans<=pow(i,j))
      {
        ans=pow(i,j);
      }
    }
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 512
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut x: Vec<isize> = parse_line().unwrap();
    let mut diff: Vec<isize> = Vec::new();

    x.sort();
    for i in 0..m - 1 {
        diff.push(x[i + 1] - x[i]);
    }
    diff.sort();
    diff.reverse();
    println!(
        "{}",
        (x[m - 1] - x[0]) - diff.iter().take(n - 1).sum::<isize>()
    );
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define N 500006
using namespace std;
struct arr{int to,ne;}e[N];
int n,c,m,st,py,cnt,tot,x,y,head[N],d[N],num[N],sum[N];bool v[N];long long ans;
void add(int x,int y)
{
	e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;
}
void dfs(int x,int fa)
{
	v[x]=1;d[x]=d[fa]+1;py++;
	for(int i=head[x];i;i=e[i].ne){
		if(!v[e[i].to])dfs(e[i].to,x);
		else if((d[x]-d[e[i].to])%2==0)num[tot]=1;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(int i=1;i<=n;i++)if(!v[i]){
		py=0;num[++tot]=2;dfs(i,0);
		if(py==1)tot--,st++;else sum[num[tot]]++,ans+=num[tot];
	}
	for(int i=1;i<=tot;i++){
		if(num[i]==1)ans+=(sum[1]-1)+sum[2];
		else ans+=sum[1]+2LL*(sum[2]-1);
	}
	ans+=2LL*st*n-1LL*st*st;
	cout<<ans<<endl;
}


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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

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

	int n;
	cin >> n;
	const int nax = 2e5+1;
	vll count(nax);
	vi val(n);
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		val[i] = (ll)a;
		count[a]++;
	}

	ll ans = 0;
	for(int i = 1; i < nax; i++) {
		ans += (count[i] * (count[i]-1)) / 2;
	}
	for(int i = 0; i < n; i++) {
		int a = val[i];
		if(count[a] == 0) {
			cout << ans << endl;
		} else {
			ll comp = (count[a] * (count[a] - 1)) / 2;
			ll newAns = ans - comp;
			newAns += max(0LL, (count[a] - 1) * (count[a] - 2) / 2LL);
			cout << newAns << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#define H 250
int main(){
  int i,n;
  int N[H];

  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&N[i]);
  }

  printf("node 1: key = %d, left key = %d, right key = %d, \n",N[1],N[2],N[3]);
  for(i=2;i<n+1;i++){
    printf("node %d: key = %d, parent key = %d, ",i,N[i],N[i/2]);
    if(2*i <= n ) printf("left key = %d, ",N[2*i]);
    if((2*i+1) <= n) printf("right key = %d, ",N[2*i+1]);      
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n;
	if(n>=100000) ans=9+900+90000;
	else if(n>=10000) ans=9+900+n-10000+1;
	else if(n>=1000) ans=9+900;
	else if(n>=100) ans=9+n-100+1;
	else if(n>=10) ans=9;
	else ans=n;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll a,b,c,k; cin >> a>>b>>c>>k;
    ll d=0,e=0,f=0;
    d=a;


    for (int i = 0; i <= k; ++i) {
        e=b;
        d*=2;
        for (int j = 0; j <= k; ++j) {
            f=c;
            e*=2;
            for (int l = 0; l <= k; ++l) {
                f*=2;
                if (i+j+l<=k && e>d && f>e){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int ans1=0,ans2=0;
    double now=0.0;
    int dp[f+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for (int k=0;k<f+1;k++){
        if (dp[k]==0)continue;
        else{
            for (int j=1;j*c+k<f+1;j++){
                dp[j*c+k]=1;
            }
            for (int j=1;j*d+k<f+1;j++){
                dp[j*d+k]=1;
            }
        }
    }
    for (int i=0;i<31;i++){
        for (int j=0;j<31;j++){
            if (i==0 && j==0)continue;
            int w=100*a*i+100*b*j;
            if (w>=f)continue;
            else{
                int sl=f-w;
                int s=-1;
                for (int k=sl;k>=0;k--){
                    if (dp[k]==1){
                        int nn=w/100;
                        if (nn*e>=k){
                            s=k;
                            break;
                        }
                    }
                }
                if (now<=double(s)/(double(s)+double(w))){
                    ans1=w+s;
                    ans2=s;
                    now=double(s)/(double(s)+double(w));
                }
            }
            
        }
    }
    cout<<ans1<<" "<<ans2<<endl;

    return 0;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m; cin >> n >> m;
  vll x(n), y(n), z(n);
  REP(i, n) cin >> x.at(i) >> y.at(i) >> z.at(i);
  vll val(n);
  ll ans = 0, tmp=0;

  REP(i, n) val.at(i) = x.at(i) + y.at(i) + z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = x.at(i) + y.at(i) - z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = x.at(i) - y.at(i) + z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = x.at(i) - y.at(i) - z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = -x.at(i) + y.at(i) + z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = -x.at(i) + y.at(i) - z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = -x.at(i) - y.at(i) + z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);
  REP(i, n) val.at(i) = -x.at(i) - y.at(i) - z.at(i);
  sort(val.begin(), val.end(), greater<ll>()); tmp=0;
  REP(i, m) tmp += val.at(i);
  chmax(ans, tmp);

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int n, x, t;
	cin >> n >> x >> t;
	int cnt = (n + x - 1) / x * t;
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3616
N, A, B = map(int, input().split())

if (B-A) % 2 == 0:
    print((B-A) // 2)
else:
    straight = min(B - 1, N - A)
    wrap = 1 + min(A - 1, N - B) + (B - A) // 2
    print(min(straight, wrap))

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

int main()
{
    int n,k,c=0;
    cin>>n>>k;
    int x[n];
    for(int i=0; i<n; i++) {
        cin>>x[i];
    }
    while(n>k) {
        n=n-k+1;
        c++;
    }
    cout<<(c+1);
    return 0;
}


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

using namespace std;

using ll = long long;

int main(){
   ll n, m;
   cin >> n >> m;
   if(n == 1 && m == 1)cout << 1;
   else if(n == 1 || m == 1){
    cout << max(m, n) - 2;
   }else cout << (m - 2) * (n - 2);
}


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

int main() {
  string c;
  cin >> c;
  if(c == "a"){
   cout << "vowel" << endl;
  }
  else if(c == "i"){
   cout << "vowel" << endl;
  }
  else if(c == "u"){
   cout << "vowel" << endl;
  }
  else if(c == "e"){
   cout << "vowel" << endl;
  }
  else if(c == "o"){
   cout << "vowel" << endl;
  }
  else{
   cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int ans=0;
vector<int> G[100010];
bool c[100010],visited[100010];

bool dfs(int s,int par){
  int v=G[s].size(),num=0;
  for(int t:G[s]){
    if (t==par) continue;
    if (dfs(t,s)) num+=1;
  }
  //cout << s << " " << num << endl;
  if(par!=-1){
    if (v-2>num) {
      ans+=v-2-num;
      return true;
    }
  }
  else{
    if (v-1>num) {
      ans+=v-1-num;
      return true;
    }
  }
  if (num) return true;
  return false;
}

void solve(){
  cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int index=-1;
  rep(i,n){
    if (G[i].size()>2){
      index=i;
    }
  }
  if (index==-1){
    cout << 1 << endl;
    return;
  }
  dfs(index,-1);
  cout << ans << endl;
}

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


Measured memory_bytes: 9216
mod = 10**9 + 7

def main():
    N = iip(listed=False)
    L = iip(True)
    L.sort()

    ret = 0
    for i in range(N):
        for j in range(i+1, N):
            minl = L[j]-L[i]
            maxl = L[j]+L[i]

            left = searchsorted(L, minl, "right")
            left = max(j+1, left)

            right = searchsorted(L, maxl, "left")

            #print(L[i], L[j], left, right)

            #print(i, j, left, right)
            ret += (right-left)
    print(ret)




#####################################################ライブラリ集ここから

def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        return r
    if side == "right":
        return l+1



def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Measured memory_bytes: 48520