akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,m;
	cin>>n>>m;
	cout<<m*n;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

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

using namespace std;
typedef long long ll;



int main(void){
	ll n,ans=0;
	cin >> n;

	for (ll i = 1; i <= n; i++) {
		if (i % 3 == 0 && i % 5 == 0) {}
		else if (i % 3 == 0) {}
		else if (i % 5 == 0) {}
		else
			ans += i;

	}
	cout << ans;
	cout << endl;
}


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

const int MAXN = 200010;
int N;
bool dp[MAXN];
vector<int> adj[MAXN];
int s, md;

void dfs(int cur, int prv, int d) {
	if (d > md) {
		s = cur;
		md = d;
	}
	for (int nxt : adj[cur]) {
		if (nxt == prv) continue;
		dfs(nxt, cur, d+1);
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	dfs(1, -1, 1);
	dfs(s, -1, 1);

	dp[0] = false;
	dp[1] = true;
	dp[2] = false;
	for (int i = 3; i <= md; i++) {
		dp[i] = (!dp[i-1] || !dp[i-2]);
	}
	if (dp[md]) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}

	return 0;
}


Measured memory_bytes: 20736
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
ulong MIDDLE = 100_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    auto wood = new Pair[](0);
    a.sort();
    long iter;

    while(iter < n)
    {
        long tmp = a[iter], cnt = 1;
        while(iter + 1 < n && tmp == a[iter + 1])
            iter++, cnt++;
        wood ~= Pair(tmp, cnt / 2);
        iter++;
    }
    wood.sort!"a.flag > b.flag"();
    long row, hei;
    foreach(e; wood)
    {
        if(e.num > 1 && !row && !hei)
        {
            row = hei = e.flag;
            break;
        }
        
        if(e.num && !row)
            row = e.flag;
        else if(e.num && !hei)
            hei = e.flag;
    }
    writeln(row * hei);
}


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
#define pc(x) putchar(x)
namespace ib {char b[100];}
inline void pi(int x){
	if(x==0) {pc(48); return;}
	if(x<0) {pc('-'); x=-x;}
	char *s=ib::b;
	while(x) *(++s)=x%10,x/=10;
	while(s!=ib::b) pc((*(s--))+48);
}
inline void ri(int &x){
	x=0; static char c; bool t(0);
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=(x<<1)+(x<<3)+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
const int N=2024,M=924844033;
int siz[2*N],pre[2*N],JC[N],F[N],G[N][N];
inline int gf(int x){
	if(pre[x]==x) return x;
	pre[x]=gf(pre[x]);
	return pre[x];
}
inline void merge(int x,int y){
	int h=gf(x),q=gf(y);
	if(h!=q){
		pre[h]=q;
		siz[q]+=siz[h];
	}
}
int main(){
	int i,j,k,n,K,ans=0; ri(n); ri(K);
	for(i=1;i<=n+n;++i) pre[i]=i,siz[i]=1;
	for(i=1;i<=n;++i){
		if(i-K>0) merge(i,i-K+n);
		if(i+K<=n) merge(i,i+K+n);
	}
	G[0][0]=G[1][0]=1;
	for(i=2;i<=n;++i){
		G[i][0]=1;
		for(j=1;j<=n;++j) G[i][j]=(G[i-2][j-1]+G[i-1][j])%M;
	}
	F[0]=1;
	for(k=1;k<=n+n;++k)
	if(gf(k)==k){
		for(i=n;i;--i)
		for(j=1;j<=min(i,siz[k]/2);++j)
		F[i]=(F[i]+(long long)F[i-j]*G[siz[k]][j])%M;
	}
	JC[0]=1; for(i=1;i<=n;++i) JC[i]=(long long)JC[i-1]*i%M;
	for(i=0;i<=n;++i) F[i]=(long long)F[i]*JC[n-i]%M;
	for(i=0;i<=n;++i) if(i&1) ans=(ans-F[i]+M)%M; else ans=(ans+F[i])%M;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
const int INF = (int)1e9;
#ifdef WIN32
#include "dbg.h"  // https://github.com/sharkdp/dbg-macro
#else
#define dbg(...)
#endif

map<ll, int> m;
int main()
{
	int k; cin >> k;
	queue<ll> q;
	for (int i = 1; i < 10; i++) q.push(i);
	while (q.size()) {
		ll n = q.front(); q.pop();
		m[n] = 1;
		if (m.size() > 100000) break;
		if(n%10!=0) q.push(n * 10 + n % 10 - 1);
		q.push(n * 10 + n % 10);
		if(n%10!=9) q.push(n * 10 + n % 10 + 1);
	}
	int ix = 1;
	for (auto a : m) {
		if (ix++ == k) cout << a.first << endl;
	}
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
int main(){
  int i,j,mi=10000,mj=100000;
  for(j=0;j<3;j++){
    scanf("%d",&i);
    if(mi>i)mi=i;
  }
  for(j=0;j<2;j++){
    scanf("%d",&i);
    if(mj>i)mj=i;
  }
  printf("%d\n",mi+mj-50);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

int n, T;
int c, t;

signed main() {
	cin >> n >> T;
	
	int i;
	int ans = 114514;
	for (i = 0; i < n; i++) {
		cin >> c >> t;
		if (t <= T) ans = min(ans, c);
	}
	if (ans == 114514) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [| for i in 1..n -> stream.ReadLine().Split() |> Array.map f |]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let s = util.Scan1 string

s
|> String.map (function
    | '1' -> '9'
    | '9' -> '1'
    | c -> c)
|> printfn "%s"

util.Close()


Measured memory_bytes: 13916
from collections import Counter

def solve(n, m, a):
    b = [0] * n
    b[0] = a[0] % m
    for i in range(1, n):
        b[i] = (b[i-1] + a[i]) % m
    c = Counter(b)
    res = c[0]
    for num in c.values():
        if num > 1:
            res += num * (num-1) // 2
    return res

n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a))

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

using namespace std;


int main(){

  int N,Y;
  cin>>N>>Y;

  for(int i=0;i<=N; i++){
    for(int j=0;j<=N-i;j++){
      int a=Y-10000*i-5000*j;
      if((a/1000+i+j)==N){
	cout<<i<<" "<<j<<" "<<a/1000<<endl;
	return 0;
      }
    }
  }

  cout<<-1<<" "<<-1<<" "<<-1<<endl;



  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort()
pm = s = 0
m_minus_1 = m - 1
for item in a:
    pm += item[1]
    if pm > m_minus_1:
        print(s + item[0] * (m - pm + item[1]))
        break
    else:
        s += item[0] * item[1]


Measured memory_bytes: 27880
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		int left = 0;
		for (int i = 0; i < N; i++) {
			if(s.charAt(i) == '(') left++;
			else left--;
			if (left < 0) {
				s = "(" + s;
				N++;
				i++;
				left++;
			}
		}
		for (int i = left ; i > 0; i--) {
			s = s + ")";
		}
		System.out.println(s);
    }
}

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

using namespace std;

using LL = long long;

void solver() {
    int n; cin >> n;
    vector<int> a(n);
    for(int &x : a) cin >> x;

    multiset<int> ms;
    for(int x : a) ms.insert(x);

    LL ans = 0;
    for(int i = n - 1; i >= 0; --i) {
        int now = a[i];
        auto it = ms.rbegin();

        //cout << "i = " << i << ' ' << "max = " << (*it) << '\n';

        ans += ((*it) - now);
        ms.erase(ms.find(now));
    }

    cout << ans << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 13456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#define SZ(x) ((int) (x).size())

typedef long long ll;

std::vector<int> ans[1005];

int main() {
	ll n, k;
	std::cin >> n;
	for(k = 1; k * (k - 1) < n * 2; ++k);
	if(k * (k - 1) != n * 2) {
		puts("No");
		return 0;
	}
	int cnt = 0;
	for(int i = 2; i <= k; ++i) {
		for(int j = 1; j < i; ++j) {
			ans[i].push_back(++cnt);
			ans[j].push_back(cnt);
		}
	}
	puts("Yes");
	std::cout << k << '\n';
	for(int i = 1; i <= k; ++i) {
		std::cout << SZ(ans[i]);
		for(auto& val : ans[i]) {
			std::cout << ' ' << val;
		}
		std::cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n; cin>> n;
  vector<ll> A(n);
   for(int i = 0;i<n;++i){
     cin >> A[i];
       if(A[i] == 0){
        cout << 0 << endl;
        return 0;
       }
   }
  
	ll ans = 1, max = 1e18; 
	  for(ll x : A){
	    if(x > max/ans){
	      cout << -1 << endl;
	      return 0;
	    }
	    ans *= x;
	  }
	cout << ans << endl;
  
}

Measured memory_bytes: 4032
import sys
sys.setrecursionlimit(10**6)

class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self.par[y] = x

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M, K = map(int, input().split())
uf = UnionFind(N)

fre = [set() for i in range(N)]

for i in range(M):
  a, b = map(int, input().split())
  fre[a-1].add(b-1)
  fre[b-1].add(a-1)
  uf.unite(a-1, b-1)

ble = [tuple(map(int, input().split())) for i in range(K)]

ans = [0] * N
t = {}
for n in range(N):
  t[uf.root(n)] = t.get(uf.root(n), 0) + 1

for n in range(N):
  ans[n] = t[uf.root(n)] - len(fre[n]) - 1

for a, b in ble:
  if uf.same(a-1, b-1):
    ans[a-1] -= 1
    ans[b-1] -= 1

print(*ans)

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

using namespace std;

int main() {
    // Input
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    // Process
    if (U == S) A--;
    if (U == T) B--;

    // Output
    printf("%d %d\n", A, B);
    return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n = read_as_vec::<usize>()[0];
    let mut a = read_as_vec::<usize>();
    let original_len = a.len();
    a.sort();
    a.dedup();
    if (original_len - a.len()) % 2 == 0 {
        println!("{}", a.len());
    } else {
        println!("{}", a.len() - 1);
    }
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

struct S{
	int p;
	bool isFly;
} a[200005];
int n, h;

bool cmp(S a, S b) {
	return a.p > b.p;
}

int main() {
	cin >> n >> h;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i].p >> a[n + i].p;
		a[n + i].isFly = true;
	}
	sort(a + 1, a + 2 * n + 1, cmp);
	int s = 0;
	int t = 0;
	for (int i = 1; i <= 2 * n; i ++) {
		if (a[i].isFly == true) {
			t ++;
			s += a[i].p;
		} else {;
			t += ceil((double)(h - s) / a[i].p);
			s = INT_MAX;
		}
		if (s >= h) {
			cout << t << endl;
			break;
		}
	}

	return 0;
}

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

int main(){
  int k,s;
  int z;
  cin >> k >> s;
  long counter=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      z=s-x-y;
      if(z>=0&&z<=k)counter++;
    }
  }
  cout << counter << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

struct Task {
    ll next;
    ll cost; // 0か1
    ll prev_cost; // ここまでのコストの累積
};

void insertTask(ll i, ll current_cost, ll k, vector<bool> &visited, deque<Task> &q) {
    if (visited[i]) {
        return;
    }
    visited[i] = true;


    // 10倍
    {
        ll next = (i * 10) % k;
        Task t = {next, 0, current_cost};
        q.push_front(t);
    }
    // +1
    {
        ll next = (i + 1) % k;
        Task t = {next, 1, current_cost};
        q.push_back(t);
    }

}

ll dfs(ll k) {

    vector<bool> visited(k);
    deque<Task> q;
    Task first = {1, 0, 0};
    q.push_back(first);

    while (!q.empty()) {
        Task t = q.front();
        q.pop_front();

        if (t.next == 0) {
            return t.prev_cost + t.cost;
        }
        insertTask(t.next, t.prev_cost + t.cost, k, visited, q);
    }
    return -1;
}

int main() {

    ll k;
    cin >> k;


    ll ans = dfs(k);
    cout << ans + 1 << endl;
}


Measured memory_bytes: 2688
#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef long ll;


int sw[11];
int p[11];

int n, m;

#define DB

int main(int, char**)
{
	int ans = 0;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int a;
			cin >> a;
			sw[i] |= (1 << (a - 1));
		}
	}
	for (int i = 0; i < m; ++i) {
		cin >> p[i];
	}

	for (int i = 0; i < (1 << n); ++i) {
		bool isOK = true;
		for (int j = 0; j < m; ++j) {
			int cnt = 0;
			int m = 1;
			for (int k = 0; k < n; ++k) {
				if (((sw[j] & m) > 0) && ((i & m) > 0))
					cnt++;
				m <<= 1;
			}
			if (cnt % 2 != p[j]) {
				isOK = false;
				break;
			}
		}
		if (isOK)
			ans++;
	}
	cout << ans << endl;

	return 0;
}



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

using namespace std;

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

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

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

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

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

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

int n;
vector<string> v;

bool Check(int p){
  debug(p);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(v[i][j+p] != v[j][i+p])return false;
    }
  }
  return true;
}

int main(){
  cin >> n;
  v.resize(n);
  for(auto&e:v){cin >> e;e+=e;}
  int cnt = 0;  
  for(int i = 0; i < n; ++i)if(Check(i))cnt++;
  cout << cnt*n << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];    
    ll ans = 0;
    int hv = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == 0) {
            hv = false;
            continue;
        }
        if (hv) {
            hv = false;
            ++ans;
            --a[i];
        }
        ans += a[i] / 2;
        a[i] %= 2;
        hv = a[i] == 1;
    } 
    cout << ans << '\n';
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int a, b, c, d, e;
    string s, t;
    cin >> a >> b >> c;
  cout << (a + b - 1) / b * c << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		Set<Integer> list = new HashSet<>();
		list.add(sc.nextInt());
		list.add(sc.nextInt());
		list.add(sc.nextInt());
		if (list.size()==2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
}

Measured memory_bytes: 23252
N,M = map(int,input().split())
A = []
x = 0
for i in range(N):
    S = list(map(int,input().split()))
    for k in range(1,S[0]+1):
        A.append(S[k])
A.sort()
for i in range(1,M+1):
    if A.count(i) == N:
        x = x + 1
print(x)

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

using namespace std;

typedef long long ll;

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

int n;
vector<ll> x, y, p;
vector<ll> ans;

vector<vector<ll>> cx, cy;

void dfs(int k, int d, vector<int> &w){
	if(w.size() == n){
		ll xb = 0, yb = 0;
		rep(i, n){
			if(w[i] == 1) xb |= (1 << i);
			if(w[i] == 2) yb |= (1 << i);
		}

		ll t = 0;
		rep(i, n){
			t += p[i] * min(cx[i][xb], cy[i][yb]);
		}
		chmin(ans[d], t);
		return;
	}

	w.push_back(0);
	dfs(k, d, w);
	w.pop_back();

	w.push_back(1);
	dfs(k, d+1, w);
	w.pop_back();

	w.push_back(2);
	dfs(k, d+1, w);
	w.pop_back();
}

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

	cin >> n;

	x.resize(n);
	y.resize(n);
	p.resize(n);
	rep(i, n) cin >> x[i] >> y[i] >> p[i];

	cx.resize(n, vector<ll>((1 << n), 0));
	cy.resize(n, vector<ll>((1 << n), 0));
	
	rep(i, n){
		for(ll bit = 0; bit < (1 << n); bit++){
			ll t = abs(x[i] - 0);
			rep(j, n){
				if((bit >> j) & 1) chmin(t, abs(x[i] - x[j]));
			}
			cx[i][bit] = t;
		}
	}

	rep(i, n){
		for(ll bit = 0; bit < (1 << n); bit++){
			ll t = abs(y[i] - 0);
			rep(j, n){
				if((bit >> j) & 1) chmin(t, abs(y[i] - y[j]));
			}
			cy[i][bit] = t;
		}
	}

	ans.resize(n+1, 1e18);
	vector<int> w;
	dfs(0, 0, w);
	rep(i, n+1) cout << ans[i] << endl;
}


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

using namespace std;

bool chk(int pos, const string& S, const string& T) {
    int s = S.size();
    for (int i = 0; i < s; ++i) {
        if (S[i] != T[(pos + i) % s]) {
            return false;
        }
    }
    return true;
}

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

    string S, T;
    cin >> S >> T;

    bool ans = false;
    for (int p = 0; p < (int)S.size(); ++p) {
        if (chk(p, S, T)) {
            ans = true;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了……
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1000100;
int n,m,l,k;
int a[N],f[N][30];
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
//	freopen("trav.in","r",stdin);
//	freopen("trav.out","w",stdout);
	n=read();
	k=log2(n)+1;
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
	}
	l=read();
	for(int i=1,j=2;i<=n;++i)
	{
		while(j<=n)
		{
			if(a[j]-a[i]<=l)
			{
				++j;
			}
			else
			{
				break;
			}
		}
		f[i][0]=j-1;
	}
	for(int i=1;i<=k;++i)
	{
		for(int j=1;j<=n;++j)
		{
			f[j][i]=f[f[j][i-1]][i-1];
		}
	}
	m=read();
	while(m--)
	{
		int x=read(),y=read(),z=0;
		if(x>y)
		{
			swap(x,y);
		}
		for(int i=k;i>=0;--i)
		{
			if(f[x][i]<y)
			{
				z+=1<<i;
				x=f[x][i];
			}
		}
		printf("%d\n",z+1);
	}
	return 0;
}





Measured memory_bytes: 15104
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n,a;
	double t,d=INF;
	cin >> n;
	vector<int>vec(n);
	rep(i, n) {
		cin >> vec[i];
		t += vec[i];
	}
	t /= (n+0.0);
	rep(i, n) {
		if (d > abs(vec[i] - t)) {
			d = abs(vec[i] - t);
			a = i;
		}
	}
	cout << a << endl;
}


Measured memory_bytes: 256
import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,s = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    mod = 998244353
    two = [1]*(n+1)
    for i in range(n):
        two[i+1] = two[i]*2%mod
    dp = np.zeros(3010,dtype = int)
    dp[0] = 1
    for i,ai in enumerate(a):
        ndp = dp*2
        ndp[ai:] += dp[:-ai]
        ndp %= mod
        dp = ndp
    print(dp[s])
    return

if __name__ == '__main__':
    main()


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

int main(){
int n;
int count = 0;
cin >> n;
vector<int> h(n);
for (int i = 0;i < n;i++){
  cin >> h.at(i);
}
int max = 0;
for(int i = 0;i < n;i++){
if (h.at(i) >= max){
  count += 1;
  max = h.at(i);
}
}
cout << count << endl;
}

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

const int MN = 702;

int N, M;
int adj[MN][MN];
int col[MN];

vector<int> A, B;

bool dfs(int u) {
    if(col[u]) A.push_back(u);
    else B.push_back(u);

    for(int v = 0; v < N; v++) {
        if(u == v) continue;
        if(adj[u][v]) continue;
        if(col[v] != -1) {
            if(col[v] == col[u]) return false;
            continue;
        }
        col[v] = col[u] ^ 1;
        if(!dfs(v)) return false;
    }
    return true;
}

int tot, sum;
vector<int> V;
int dp[MN * MN];

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

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u][v] = adj[v][u] = 1;
    }

    memset(col, -1, sizeof(col));
    for(int i = 0; i < N; i++) if(col[i] == -1) {
        A.clear();
        B.clear();

        col[i] = 0;
        if(!dfs(i)) {
            printf("-1");
            return 0;
        }

        for(int j = 0; j < A.size(); j++) {
            for(int k = 0; k < B.size(); k++) {
                if(!adj[ A[j] ][ B[k] ]) tot++;
            }
        }

        int a = A.size();
        int b = B.size();
        if(a > b) swap(a, b);
        sum += a;
        V.push_back(b - a);
    }

    dp[0] = 1;
    for(int i = 0; i < V.size(); i++) {
        for(int j = MN * MN - 1; j >= V[i]; j--) {
            dp[j] |= dp[ j - V[i] ];
        }
    }

    int mul = 0;
    for(int i = 0; i < MN * MN; i++) {
        if(dp[i]) {
            int a = sum + i;
            int b = N - a;
            mul = max(mul, a * b);
        }
    }
    printf("%d", M - mul + tot);
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    vi b(a);
    sort(all(b));
    REP(i,n){
        a[i]=lower_bound(all(b), a[i])-b.begin();
    }
    int c=0;
    REP(i,n){
        if((a[i]-i)%2)++c;
    }
    if(c%2){
        c+=3;
    }
    cout<<c/2<<endl;

}


Measured memory_bytes: 1024
n,m = map(int,input().split())
h = list(map(int,input().split()))
r = [1] * n
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
    if h[a[i]-1] < h[b[i]-1] :
        r[a[i]-1] = 0
    elif h[a[i]-1] > h[b[i]-1] :
        r[b[i]-1] = 0
    else :
        r[a[i]-1] = 0
        r[b[i]-1] = 0
print(r.count(1))

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

int main() {
    int n, k;
    cin >> n >> k;
    
    double ans = (1/(double)n);
    double s = 0;
    for (int i = 1; i <= n; i++) {
        int coin_num = 0;
        if (i <= k) {
            coin_num = ceil(log2((double)k/i));
        }
        s += pow(0.5, coin_num);
    }
    
    cout << fixed << setprecision(10) << ans*s << endl;
}

Measured memory_bytes: 512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


xs,ys,xt,yt = list(map(int, input().split()))
n = int(input())
xyr = [None]*(n+2)
for i in range(n):
    xyr[i] = tuple(map(int, input().split()))
from itertools import product
ns = [[] for _ in range(n+2)]
s = n
t = n+1
xyr[s] = (xs,ys,0)
xyr[t] = (xt,yt,0)
for i,j in product(range(n+2), range(n+2)):
    if i<j:
        d = max(0, ((xyr[i][0]-xyr[j][0])**2 + (xyr[i][1]-xyr[j][1])**2)**0.5 - (xyr[i][2]+xyr[j][2]))
        ns[i].append((d,j))
        ns[j].append((d,i))
def dijkstra(start):
    import heapq
    vals = [None] * (n+2)
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    while h:
        val, u = heapq.heappop(h)
        if u==t:
            break
        if val>vals[u]:
          continue
        for d, v in ns[u]:
            if vals[v] is None or vals[v]>val+d:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
    return vals
vals = dijkstra(s)
ans = vals[t]
print(ans)


Measured memory_bytes: 177680
n = int(input())

c = 0
flag = False

for i in range(n):
    x, y = list(map(int, input().split()))
    if x == y:
        c += 1
        if c == 3:
            flag = True
            break
    else:
        c = 0

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
      cin >> D.at(i);
  }
  sort (D.begin(), D.end());
  cout << D.at(N / 2) - D.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
char s[305];
int n=0,len,k,a[305],b[305],mod=998244353;
long long f[305][305][305];
int main(){
	
	std::cin>>s>>k;
	len=strlen(s);
	n=1;
	for (int i=0;i<len;++i) {
		if (s[i]=='0') ++n;
		else ++a[n];
	}
	++n; 
	for (int i=n-1;i>=0;--i) b[i]=b[i+1]+a[i];
	k=std::min(b[1],k);
	f[0][0][0]=1;
	for (int i=1;i<=n;++i) {
		for (int c=0;c<=a[i];++c){
			for (int j=c;j<=k;++j) {
				for (int l=j;l<=k;++l) {
					f[i][l][j-c]=(f[i][l][j-c]+f[i-1][l][j])%mod;
				}
			}
		}
		for (int c=1;c<=k;++c){
			for (int j=k-c;j>=0;--j) {
				for (int l=0;l<=j;++l) {
					f[i][j+c][l+c]=(f[i][j+c][l+c]+f[i-1][j][l])%mod;
				}
			}
		}
	}
	long long ans=0;
	for (int i=0;i<=k;++i) ans+=f[n][i][0];
	printf("%lld",ans%mod);
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  return a.second > b.second;
}

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  vector<pair<ll, ll>> bc(m);
  for (ll i = 0; i < m; ++i) {
    ll b, c;
    cin >> b >> c;
    bc[i] = pair<ll, ll>(b, c);
  }
  sort(bc.begin(), bc.end(), comp);

  vector<ll> bcv;
  for (ll i = 0; i < m; ++i) {
    for (ll j = 0; j < bc[i].first; ++j) {
      bcv.push_back(bc[i].second);
      if (bcv.size() == n) break;
    }
    if (bcv.size() == n) break;
  }

  ll j = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] < bcv[j]) {
      a[i] = bcv[j];
      ++j;
    }
    if (j == bcv.size()) break;
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ans += a[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3704
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

  print(count)


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

int main() {
  int A, B;
  cin >> A >> B;

  int price = 0;
  if (A >= 13) {
    price = B;
  } else if (A >= 6) {
    price = B / 2;
  }

  cout << price << endl;

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: chars,
    }

    let len = n.len();

    let mut num = 0;
    let mut mul = 1;

    for i in n.iter().rev() {
        num = num + i.to_digit(10).unwrap() * mul;
        mul = mul * 10;
    } 


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

    let mut ans = 0;
    if num < 10 {
        ans = num;
    } else if num < 100 {
        ans = 9;   
    } else if num < 1000 {
        ans = num - 99 + 9;
    } else if num < 10000 {
        ans = 900 + 9;
    } else if num < 100000 {
        ans = num - 9999 + 900 + 9;
    } else {
        ans = 90000+900+9;
    }

    println!("{}", ans);

}


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

int	main()
{
	int	N;
	cin >> N;
	unordered_map<string, int>	cnt_map;
	string	s;
	for (int i = 0; i < N; ++i) {
		cin >> s;
		if (cnt_map.count(s))
			++cnt_map[s];
		else
			cnt_map[s] = 1;
	}
	int	M;
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> s;
		if (cnt_map.count(s))
			--cnt_map[s];
		else
			cnt_map[s] = -1;
	}
	int	max_amount = 0;
	int	amount = 0;
	for (auto pr : cnt_map) {
		amount = pr.second;
		if (max_amount < amount) max_amount = amount;
	}
	cout << max_amount << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define ll long long
#define rep( i, a, n ) for( int i = a; i < n; i++ )
#define per( i, a, n ) for( int i = n - 1; i >= a; i-- )
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define MOD 8191
#define INF 0x3f3f3f3f
#define e 2.71828
using namespace std;
const int N = 1e5 + 40;
const int M = 150;
const int MAX = 5;
const ll inv = 500000004;
const double g = 9.80;
const double PI = acos( -1.0 );
int n, a[N];

struct node{
    int id, num;
    node( ){ id = num = 0; }
    node( int ii, int nn ){
        id = ii, num = nn;
    }
};

bool cmp( node p1, node p2 ){
    return p1.num > p2.num;
}
int main(){
    while( scanf( "%d", &n ) != EOF ){
        mem( a, 0 );
        node vis1[N], vis2[N];
        rep( i, 1, n+1 ){
            scanf( "%d", a + i );
            if( i%2 == 1 ) vis1[a[i]].id = a[i], vis1[a[i]].num++;
            else vis2[a[i]].id = a[i], vis2[a[i]].num++;
        }
        /*int ma1 = -INF, ma2 = -INF, pos1 = -1, pos2 = 0;
        rep( i, 1, n+1 ){
            if( vis1[a[i]] > ma1 ) ma1 = vis1[a[i]], pos1 = a[i];
            if( vis2[a[i]] > ma2 ) ma2 = vis2[a[i]], pos2 = a[i];
        }
        if( pos1 == pos2 ){
            int tmp1 = n/2 - ma1;
            int tmp2 = n/2 - ma2;
            if( tmp1<tmp2 ){
                vis1[pos1] = 0;
                ma1 = -INF;
                rep( i, 1, n + 1 )
                    if( vis1[a[i]] > ma1 ) ma1 = vis1[a[i]];

            }
            else{
                vis2[pos2] = 0;
                ma2 = -INF;
                rep( i, 1, n+1 )
                    if( vis2[a[i]] > ma2 ) ma2 = vis2[a[i]];
            }
        }*/
        sort( vis1 +1, vis1 + N, cmp );
        sort( vis2 +1, vis2 + N, cmp );
        int ma = -INF;
        rep( i, 1, 100 ){
            rep( j, 1, 100 ){
                if( vis1[i].id != vis2[j].id ){
                    int tmp = vis2[i].num + vis1[j].num;
                    if( tmp > ma )
                        ma = tmp;
                }
            }
        }
        printf( "%d\n", n - ma );
        //rep( i, 1, 100)
        //printf( "%d\n", n - ma1 - ma2 );
    }
    return 0;
}


Measured memory_bytes: 2176
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let s = get!(String).chars().collect::<Vec<_>>();

    let mut vec = vec![0usize; 3];
    for &c in &s {
        match c {
            'R' => vec[0] += 1,
            'G' => vec[1] += 1,
            'B' => vec[2] += 1,
            _ => (),
        }
    }

    let mut count = 0usize;
    for l in 1..n {
        for i in 0..n {
            if i + 2 * l > n - 1 {
                break;
            }
            let j = i + l;
            let k = i + 2 * l;
            let si = s[i];
            let sj = s[j];
            let sk = s[k];
            if si != sj && sj != sk && sk != si {
                count += 1;
            }
        }
    }

    println!("{}", vec[0] * vec[1] * vec[2] - count);
}


Measured memory_bytes: 2264
#define ll long long
#define pb push_back
#include<bits/stdc++.h>

ll mod =  1e9+7;

using namespace std;

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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    vector<ll>pos,neg,all;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>=0)
        {
            pos.pb(a[i]);
        }
        else
        {
            neg.pb(a[i]);
        }
    }
    ll ans = 1;
    if((int)pos.size())
    {
        if(k%2)
        {
            sort(pos.begin(),pos.end());
            ans = mul(ans,pos.back());
            pos.pop_back();
            k--;
        }
        vector<ll>ok;
        sort(pos.begin(),pos.end(),greater<>());
        sort(neg.begin(),neg.end());
        for(int i=0;i+1<(int)pos.size();i+=2)
        {
            ok.pb(pos[i]*pos[i+1]);
        }
        for(int i=0;i+1<(int)neg.size();i+=2)
        {
            ok.pb(neg[i]*neg[i+1]);
        }
        if((int)pos.size()%2 && (int) neg.size()%2)
        {
            ok.pb(pos.back()*neg.back());
        }
        sort(ok.begin(),ok.end(),greater<>());
        for(int i=0;i<(k/2);i++)
        {
            ans = mul(ans,ok[i]);
        }
        cout<<ans<<endl;

    }
    else{
        sort(neg.begin(),neg.end());
        if(k%2)
        {
            reverse(neg.begin(),neg.end());
        }
        for(int i=0;i<k;i++)
        {
            ans = mul(ans,neg[i]);
        }
        cout<<ans<<endl;
    }


}


Measured memory_bytes: 8232
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//temmie_のsnippet

#define N 100009

int main(){
	LL n,a[N],b[N],c[N];
	scanf("%lld", &n);
	rep(i,n)scanf("%lld",a+i);
	qsort(a,n,sizeof(LL),acs);
	rep(i,n)scanf("%lld",b+i);
	qsort(b,n,sizeof(LL),acs);
	rep(i,n)scanf("%lld",c+i);
	qsort(c,n,sizeof(LL),des);

	LL ans=0;
	rep(i,n){//b[i] fix
		LL ap=0,aq=n/2,ar=n-1,cp=0,cq=n/2,cr=n-1;
		while(ar-ap>1){
			if(b[i]>a[aq])ap=aq;
			if(b[i]<=a[aq])ar=aq;
			aq=(ap+ar)/2;
		}
		while(cr-cp>1){
			if(b[i]<c[cq])cp=cq;
			if(b[i]>=c[cq])cr=cq;
			cq=(cp+cr)/2;
		}
		LL A=-1,C=-1;
		if(b[i]>a[ap])A=ap;
		if(b[i]>a[aq])A=aq;
		if(b[i]>a[ar])A=ar;
		if(b[i]<c[cp])C=cp;
		if(b[i]<c[cq])C=cq;
		if(b[i]<c[cr])C=cr;
		ans+=(A+1)*(C+1);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4824
#include <cstdio>

int n,head[200001],nxt[400001],b[400001],k,ans2[200001];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
void dfs(int x,int f,int mx,int skdmx,int down,bool update){
	if(x>mx)skdmx=mx,mx=x,update=1;
	else if(x>skdmx)skdmx=x,update=0;
	++ans2[x],--ans2[update?mx:down];
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=f)dfs(b[i],x,mx,skdmx,(x==mx)?b[i]:down,update);
}
void dfs2(int x,int f){
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=f)dfs2(b[i],x),ans2[x]+=ans2[b[i]];
}
void getans(int x,int f,int sum){
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=f)sum+=ans2[b[i]];
	ans2[x]=++sum;
	for(int i=head[x];i;i=nxt[i])
		if(b[i]!=f)getans(b[i],x,sum-ans2[b[i]]);
}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++){
		scanf("%d%d",&u,&v);
		push(u,v);
		push(v,u);
	}
	dfs(1,0,0,0,0,0);
	dfs2(1,0);
	getans(1,0,-1);
	for(int i=2;i<=n;i++)printf("%d ",ans2[i]);
}

Measured memory_bytes: 21888