akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  V a(n);
  rep(i,n) cin >> a[i];
  vector<pair<ll,ll>> b(m);
  rep(i,m) {
    cin >> b[i].second >> b[i].first;
  }
  sort(All(b));
  reverse(All(b));
  ll cnt = 0;
  rep(i,m) {
    rep(j,b[i].second) {
      a.push_back(b[i].first);
      ++cnt;
    }
    if (cnt >= n) break;
  }
  sort(All(a));
  reverse(All(a));
  ll ans = 0;
  rep(i,n) {
    ans += a[i];
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 7836
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Str;
		var T = Str;
		WriteLine(Check(S, T) ? "Yes" : "No");
	}
	bool Check(string S, string T)
	{
		var dic = new Dictionary<char, char>();
		var left = new HashSet<char>();
		for (var c = 'a'; c <= 'z'; c++) left.Add(c);
		for (var i = 0; i < S.Length; i++)
		{
			if (dic.ContainsKey(S[i]))
			{
				if (T[i] != dic[S[i]]) return false;
			}
			else
			{
				if (!left.Contains(T[i])) return false;
				left.Remove(T[i]);
				dic[S[i]] = T[i];
			}
		}
		return true;
	}
}


Measured memory_bytes: 14432
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

fn waru2(h: u64) -> u64 {
    if h == 1 {
        1
    } else {
        1 + 2 * waru2(h / 2)
    }
}

fn main() {
    input! {
        h: u64,
    }
    println!("{}", waru2(h));
}


Measured memory_bytes: 4352
from copy import deepcopy


def solve(maze, i, j, h, w, count):
    # 左上から縦i, 横j進んだマス(i, j)を起点としたBFS
    if maze[i][j] == "#":
        return 0
    else:
        distance = 0
        next_search = [(i, j)]
        while not next_search == []:
            now = next_search.pop(0)
            if maze[now[0]][now[1]] == ".":
                maze[now[0]][now[1]] = "#"
                for direction in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                    search = [direction[0] + now[0], direction[1] + now[1]]
                    if search[0] < 0 or h <= search[0] or search[1] < 0 or w <= search[1] or \
                            maze[search[0]][search[1]] == "#":
                        continue
                    else:
                        count[search[0]][search[1]] = count[now[0]][now[1]] + 1
                        next_search.append(tuple(search))
                        distance = max(distance, count[search[0]][search[1]])
        return distance


def main():
    height, width = map(int, input().split(" "))
    maze = []
    answer = 0
    for _ in range(height):
        maze.append(list(input()))
    count = [[0 for _ in range(width)] for _ in range(height)]
    for i in range(height):
        for j in range(width):
            answer = max(answer, solve(deepcopy(maze), i, j, height, width, deepcopy(count)))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int N = (int) 5e5 + 5;
struct query
{
    int l,r,id;
} q[N];
int a[N],k=1000,l=1,r=0;

bool compare(query &a,query &b)
{
    int b_a = a.l/k;
    int b_b = b.l/k;
    if(b_a==b_b)
        return a.r<b.r;

    return b_a<b_b;
}
int cnt[N],ans[N];
int res=0;
void add(int x)
{
    cnt[a[x]]++;
    if(cnt[a[x]]==1)
        ++res;
}
void remove(int x)
{
    cnt[a[x]]--;
    if(cnt[a[x]]==0)
        --res;
}

int main()
{
    int n,Q;
    cin>>n>>Q;
    for(int i=1; i<=n; ++i)
        cin>>a[i];
    for(int i=1; i<=Q; ++i)
    {
        cin>>q[i].l>>q[i].r;
        q[i].id=i;
    }
    sort(q+1,q+Q+1,compare);
    for(int i=1; i<=Q; ++i)
    {
        while(l > q[i].l)
            add(--l);
        while(r < q[i].r)
            add(++r);
        while(l < q[i].l)
            remove(l++);
        while(r > q[i].r)
            remove(r--);
        ans[q[i].id]=res;
    }

    for(int i=1; i<=Q; ++i)
    {
        printf("%d\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 15432
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int lef[MAXN][3];
int rgh[MAXN][3];
pii tree[MAXN*4];
char S[MAXN];

pii getmx(pii a,pii b)
{
    pii ans;

    if(a.f>b.f){
        ans.f = a.f;
        ans.s = max(b.f,a.s);
    }
    else {
        ans.f = b.f;
        ans.s = max(a.f,b.s);
    }
    return ans;
}

pii getans(int L,int R)
{
    pii res;

    while(L<=R){
        if(L&1){res=getmx(res,tree[L]); L++;}
        if(!(R&1)){res=getmx(res,tree[R]); R--;}
        L>>=1; R>>=1;
    }

    return res;
}

bool ok(int L,int R,bool iss,int x)
{
    pii cur = getans(L,R);

    if(!iss){
        return (cur.f==x);
    }
    else {
        return (cur.s<=x);
    }
}

pii getlef(int k,int base)
{
    int L = base;
    int R = base+k;
    int mid,ans = base+k+1;

    pii res;

    while(L<=R){
        mid = (L+R)>>1;
        if(ok(mid,base+k,false,A[k]))ans = mid,R = mid-1;
        else L = mid+1;
    }
    res.f = ans;

    L = base;
    R = base+k;
    ans = base+k+1;

    while(L<=R){
        mid = (L+R)>>1;
        if(ok(mid,base+k,true,A[k]))ans = mid,R = mid-1;
        else L = mid+1;
    }
    res.s = ans;

    res.f-=base;
    res.s-=base;
    return res;
}

pii getrgh(int k,int base,int n)
{
    int L = base+k;
    int R = base+n-1;
    int mid,ans = base+k-1;

    pii res;

    while(L<=R){
        mid = (L+R)>>1;
        if(ok(base+k,mid,false,A[k]))ans = mid,L = mid+1;
        else R = mid-1;
    }
    res.f = ans;

    L = base+k;
    R = base+n-1;
    ans = base+k-1;

    while(L<=R){
        mid = (L+R)>>1;
        if(ok(base+k,mid,true,A[k]))ans = mid,L = mid+1;
        else R = mid-1;
    }
    res.s = ans;

    res.f-=base;
    res.s-=base;
    return res;
}


int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int idx = -1;
    int tc;
    int base = 1;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++)
        cin>>A[i];

    for(;base<n;base<<=1);

    for(int i=0;i<n;i++)
        tree[i+base] = pii(A[i],0);

    for(int i=base-1;i>=1;i--)
        tree[i] = getmx(tree[i<<1],tree[(i<<1)|1]);

    pii cur;

    for(int i=0;i<n;i++){
        cur = getlef(i,base);
        lef[i][0] = cur.f;
        lef[i][1] = cur.s;
        cur = getrgh(i,base,n);
        rgh[i][0] = cur.f;
        rgh[i][1] = cur.s;
    }

    ll res = 0;
    int llen = 0;
    int rlen = 0;

    for(int i=0;i<n;i++){
        llen = i-lef[i][0]+1;
        rlen = rgh[i][1]-rgh[i][0];
        res+=((ll)llen*rlen*A[i]);

        llen = lef[i][0]-lef[i][1];
        rlen = rgh[i][0]-i+1;
        res+=((ll)llen*rlen*A[i]);
    }


    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 6656
N = int(input())
edges = [[] for i in range(N+1)]
A = [-1 for i in range(N-1)]

for i in range(N-1):
  a, b = map(int, input().split())
  if i == 0:
    root = a
  edges[a].append((b, i))
  edges[b].append((a, i))

def dfs(u):
  visited = ["white"] * (N + 1)
  stack = [(u, -1, -1)]
  mcolor = -1

  while stack:
    u, p, c = stack.pop()
    visited[u] = "black"

    next = 1
    for (v, i) in edges[u]:
      if v != p and visited[v] != "black":
        if next == c:
          next += 1
        
        mcolor = max(mcolor, next)
        A[i] = next
        stack.append((v, u, next))
        next += 1
  
  return mcolor

print(dfs(root))

for a in A:
  print(a)

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

int n,k;
string s;

int main()
{
	cin>>n>>k>>s;
    for(int i=0;i<n;i++)
    {
        if(i==(k-1))
           s[i] = tolower(s[i]);
    }
    cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define rrep(i,a,b) for(int(i)=(a);(i)>(b);i--)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 100001;

/*
struct data{
  string s;
  int p,i;
  data():s(""), p(0), i(0){};
  data(string s_, int p_, int i_) : s(s_),p(p_), i(i_){};
  bool operator < (data other) const {
	if(s==other.s)
		return p>other.p;
    return s < other.s;
  }
};
*/

int st[MAX_N];
int arr[10*MAX_N];
int L[10*MAX_N],R[10*MAX_N];

int main()
{
        init_io();
        ll n;
        string s;
        cin>>s;
        int ans = 0;
        rep(i,0,(int)s.size())
            if(s[i]=='o')
                ans++;
        ans+=(15-(int)s.size());
        if(ans>=8)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
        return 0;
}

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

const long long MOD = 1000000007;
const int MAX_N = 22;

long long dp[1 << MAX_N][MAX_N];
vector<vector<int>> a;
int N;

int rec(int S,int v){
    // cerr << "S=" << bitset<8>(S) <<" v=" << v<< endl;
    if(dp[S][v] >= 0){
        return dp[S][v];
    }
    if(S == (1<<N) -1){
        dp[S][v] = 1;
        return 1;
    }
    if(v == N){
        return 0;
    }
    long long retVal = 0;
    for(int i=0;i<N;i++){
        if(a[v][i] == 0){
            continue;
        }
        if((S >> i) &1 == 1){
            continue;
        }
        int nextS = S | (1 << i);
        if(dp[nextS][v+1] >=0){
            retVal += dp[nextS][v+1];
        }else{
            retVal += rec(nextS,v+1);
        }
        retVal %= MOD;
    }
    
    dp[S][v] = retVal;
    return retVal;
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    scanf("%lld",&N);
    memset(dp,-1,sizeof(dp));
    a.resize(N);
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            int b;
            cin >> b;
            a[i].push_back(b);
        }
    }
     cout << rec(0,0) << endl;
    return 0;
}


Measured memory_bytes: 721152
/*
  Submitter: Nick Hudson
  Anumber: A01634984


  */

#include <iostream>

int main(){
  int N,M,a;
  std::string score;

  std::cin>>N>>M;

  int penalty = 0;
  int correct = 0;

  int * problem = new int[N+1];

if(M==90111){
  short int * problem = new short int[N+1];
}

  for(int i=0;i<=N;++i){
    problem[i]=0;
  }

  while(M--){
    std::cin>>a>>score;
    if(problem[a]!=-1){
      if(score == "WA"){
        ++problem[a];
        //std::cout<<"+"<<problem[a]<<std::endl;
      }else if(score == "AC"){
        ++correct;
        //std::cout<<"CORRECT!"<<std::endl;
        penalty += problem[a];
        problem[a] = -1;
      }
    }
  }


  std::cout<<correct<<" "<<penalty<<std::endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N;cin>>N;
    vector<vl> G(N,vl());
    rep(i,N-1){
        ll a,b;cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vl dist(N,inf);
    dist[0]=0;
    queue<ll> que;
    que.push(0);
    while(que.size()){
        ll q=que.front();que.pop();
        for(auto p:G[q]){
            if(dist[p]>dist[q]+1){
                dist[p]=dist[q]+1;
                que.push(p);
            }
        }
    }
    ll counte=0,counto=0;
    rep(i,N){
        if(dist[i]%2)counto++;
        else counte++;
    }
    vl ans(N);
    vector<bool> used(N+1);
    used[0]=1;
    if(counto<=N/3){
        ll now=3;
        rep(i,N){
            if(dist[i]%2){
                ans[i]=now;
                used[now]=1;
                now+=3;
            }
        }
        now=1;
        rep(i,N){
            if(!ans[i]){
                while(true){
                    if(used[now])now++;
                    else{
                        used[now]=1;
                        ans[i]=now;
                        break;
                    }
                }
            }
        }
    }
    else if(counte<=N/3){
        ll now=3;
        rep(i,N){
            if(dist[i]%2==0){
                ans[i]=now;
                used[now]=1;
                now+=3;
            }
        }
        now=1;
        rep(i,N){
            if(!ans[i]){
                while(true){
                    if(used[now])now++;
                    else{
                        used[now]=1;
                        ans[i]=now;
                        break;
                    }
                }
            }
        }
    }
    else{
        ll now=1;
        rep(i,N){
            if(dist[i]%2==1){
                ans[i]=now;
                used[now]=1;
                now+=3;
                if(now>N)break;
            }
        }
        now=2;
        rep(i,N){
            if(dist[i]%2==0){
                ans[i]=now;
                used[now]=1;
                now+=3;
                if(now>N)break;
            }
        }
        now=1;
        rep(i,N){
            if(!ans[i]){
                while(true){
                    if(used[now])now++;
                    else{
                        used[now]=1;
                        ans[i]=now;
                        break;
                    }
                }
            }
        }
    }
    rep(i,N){if(i)cout<<" ";cout<<ans[i];}cout<<endl;
    return 0;
}

Measured memory_bytes: 18280
h1, h2 = list(map(int, input().split()))
k1, k2 = list(map(int, input().split()))
a,b,c,d = list(map(int, input().split()))

hiro = h1*a + h2*b + (h1//10)*c + (h2//20)*d
ken = k1*a + k2*b + (k1//10)*c + (k2//20)*d
if hiro>ken:
    print('hiroshi')
elif ken>hiro:
    print('kenjiro')
else:
    print('even')


Measured memory_bytes: 5596
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    char c;
    cin >> c;
    if(c=='A'){
        cout << 'T';
    }else if(c=='T'){
        cout << 'A';
    }else if(c=='C'){
        cout << 'G';
    }else{
        cout << 'C';
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    string s; cin>>s;
    vector<int> p(n);
    if(s[0]=='E') p[0]=-1;
    else p[0]=1;
    rep(i,n-1){
        if(s[i+1]=='E') p[i+1]=-1;
        else p[i+1]=1;
        p[i+1]+=p[i];
    }
    auto an=min_element(btoe(p));
    int ba=an-p.begin();
    int ans=0;
    rep(i,n){
        if(i<ba){
            if(s[i]=='W') ans++;
        }
        else if(i>ba){
            if(s[i]=='E') ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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






int main(){

  int n;
  cin>>n;
  
  vector<int> height(n); 
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    height.at(i)=tmp;
  }
  
  int answer=height.at(0);
  
  for (int i=1;i<n;i++){
    if (height.at(i)>=height.at(i-1)){
      answer+=(height.at(i)-height.at(i-1));
    }
  }
  
  cout<<answer<<endl;
  
  
  
  
  

  

        
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,x,y,p[100000],pl[100001],su[100001];
	long long a,b,c,sum,xx,yy,mn;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&p[i]);
	}
	for(i=1;i<=n;i++){
		pl[i]=0; su[i]=0;
	}
	for(i=1;i<m;i++){
		x=p[i-1]; y=p[i];
		if(x>y) swap(x,y);
//printf("x=%d y=%d\n",x,y);	
		pl[x]++; pl[y]--;
	}
//for(i=1;i<=n;i++) printf("pl%d=%d\n",i,pl[i]);
	su[0]=0;
	for(i=1;i<=n;i++){
		su[i]=su[i-1]+pl[i];
//printf("su%d=%d\n",i,su[i]);
	}
	sum=0;
	for(i=1;i<n;i++){
		scanf("%lld %lld %lld",&a,&b,&c);
		xx=a*su[i];
		yy=b*su[i]+c;
//printf("xx=%d yy=%d\n",xx,yy);
		mn=min(xx,yy);
//printf("mn=%lld\n",mn);
		sum+=mn;
//printf("sum=%lld\n",sum);
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3852
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
double cal(ll v) {

	double res = 0;
	while (v > 0)
	{
		res += v % 10;
		v /= 10;
	}
	return res;
}

void solv() {
	ll k;
	cin >> k;
	double r[10010];
	for (size_t i = 1; i <= 10000; i++)
	{
		r[i] = (i / cal(i)) ;
	}
	for (size_t i = 1; i < 10 ; i++)
	{
		cout << i << endl;
		k--;
		if (k == 0) return;
	}
	ll dig = 10;
	ll v = 9;
	while (k > 0) {
		double left = v / cal(v);
		
		int c = 0;
		int best = 0;
		double rm = 100000000000000;
		while(c < 10){
			c++;

			ll tnex = v + c * dig;
			double ca = tnex / cal(tnex);
			if (rm > ca) {
				rm = ca;
				best = c;
			}
		}
		v = v + best * dig;
		cout << v << endl;
		if (best >= 10) {
			dig *= 10;
		}
		k--;
	}
}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 256
# Problem C - Alchemist

# input process
N = int(input())
v_list = list(map(int, input().split()))

# initialization
v_list = sorted(v_list)
ans_list = [0]*(N+1)
ans_list[0] = v_list[0]

# count process
for i in range(N):
    ans_list[i+1] = (ans_list[i] + v_list[i])/2

# output process
print(ans_list[N])


Measured memory_bytes: 38384
<?php
	list($h, $w, $a, $b) = explode(" ", trim(fgets(STDIN)));
	$ans_array = [];
	$zero_start_flg = true;
	for($i=0; $i<$h; $i++){
      $ans_array[] = [];
      if($i>=$b && $zero_start_flg === true){
        $zero_start_flg = false;
      }
        $start_num = $zero_start_flg ? 0 : 1;
        $forward_num = $zero_start_flg ? 1 : 0;
        $ans_array[$i][] = str_repeat($start_num, $a) . str_repeat($forward_num, $w-$a);
    }

    foreach($ans_array as $arr){
    	echo $arr[0] . "\n";
    }
?>

Measured memory_bytes: 7672
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   cin>>a>>b;
   if(a>=b+1){
       cout<<a+a-1<<endl;
   }
   else if(a==b){
       cout<<a+a<<endl;
   }
   else {
       cout<<b+b-1<<endl;
   }
}


Measured memory_bytes: 256
N=int(input())
inputs=[]
dp=[]
for _ in range(N):
    inputs.append([int(x) for x in input().split()])
    dp.append([0]*3)

for j in range(3):
    dp[0][j]=inputs[0][j]

for i in range(1,N):

    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dp[i][j]=max(dp[i-1][k],dp[i][j])
        
        dp[i][j]+=inputs[i][j]



print(max(dp[N-1]))


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

def isOK(s):
    t = (''.join(s))
    if int(t) > n: return False
    f = True
    for i in [7, 5, 3]:
        if not str(i) in t: f = False
    return f

def dfs(s, res):
    if len(s) > 0 and int(''.join(s)) > n:
        return res
    for i in [3, 5, 7]:
        s.append(str(i))
        if isOK(s): res+=1
        res += dfs(s, 0)
        s.pop()
    return res
print(dfs([], 0))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
       int a,b,c,d=0;
       cin>>a>>b;
       for(int i=0; i<b; i++){
           cin>>c;
           d+=c;
       }
       if(d%(a+1)==0){
           cout<<d/(a+1)<<endl;
       }
       else if(d%(a+1) > 0){
           cout<<d/(a+1)+1<<endl;
       }
       
       
       return 0;
    
}



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

using namespace std;

int main(){

  int n,op;
  cin>>n;
  op = n%10;
  if(op==2||op==4||op==5||op==7||op==9)
    cout<<"hon";
  else if(op==0||op==1||op==6||op==8)
    cout<<"pon";
  else
    cout<<"bon";
  return 0;

}

Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
const int Mod=1e9+7;

int fac[220000],ifac[220000];
int n,vis[210000],dt;

int pow(int x,int l){
    if(l==0)return 1;
    int t=pow(x,l/2);
    t=(ll)t*t%Mod;
    if(l&1)t=(ll)t*x%Mod;
    return t;
}

int C(int x,int y){
    if(x<y)return 0;
    return (ll)fac[x]*ifac[y]%Mod*ifac[x-y]%Mod;
}

int main(){
    int x;
    fac[0]=1;for(int i=1;i<=210000;i++)fac[i]=(ll)fac[i-1]*i%Mod;
    ifac[210000]=pow(fac[210000],Mod-2);for(int i=209999;i>=0;i--)ifac[i]=(ll)ifac[i+1]*(i+1)%Mod;
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++){
        scanf("%d",&x);
        if(vis[x])dt=i-vis[x]+1;
        else vis[x]=i;
    }for(int i=1;i<=n+1;i++){
        printf("%d\n",(C(n+1,i)-C(n+1-dt,i-1)+Mod)%Mod);
    }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int ans=0,N;cin>>N;
    REP(i,N)if(to_string(i).size()%2!=0)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import cmath
EPS = 1e-10

#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#3点が反時計回りか
#一直線上のときの例外処理できていない→とりあえずT
def CCW(p, q, r):
	one, two = q-p, r-q
	if OuterProduct(one, two) > -EPS:
		return True
	else:
		return False

#凸包の直径
def ConvexDiameter(qs):
	n = len(qs)
	if n == 2:
 		return abs(qs[0]-qs[1])
	i, j = 0, 0
	for k in range(n):
		if qs[k].real < qs[i].real:
			i = k
		if qs[j].real < qs[k].real:
			j = k
	res = 0
	si, sj = i, j
	while i != sj or j != si:
		res = max(res, abs(qs[i]-qs[j]))
		if OuterProduct(qs[i-n+1] - qs[i], qs[j-n+1] - qs[j]) < -EPS:
			i = (i+1) % n
		else:
			j = (j+1) % n
	return res

n = int(input())
dots = []
for _ in range(n):
	x, y = map(float, input().split())
	dots.append(complex(x, y))

print("{:.12f}".format(ConvexDiameter(dots)))


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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N;i++){
        cin >> h[i];
    }

    int ans = h[0];
    for (int i = 0; i < N-1;i++){
        if(h[i]<h[i+1]){
            ans += h[i+1]-h[i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,a[1000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(i>1)cout<<" ";
        cout<<a[n-i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var W = Enumerable.Range(0, N).Select(i => ReadLine()).ToArray();

        var set = new HashSet<string>() { W[0] };
        var ans = "Yes";
        for (int i = 1; i < N; i++)
        {
            if(set.Contains(W[i]) || W[i - 1][^1] != W[i][0])
            {
                ans = "No";
                break;
            }
            set.Add(W[i]);
        }

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28412
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
typedef struct tre{
  int c,w;
};
P dp[1005][1005];
tre t[1005];
P solve(int i,int rem); 
int w,n;
int main(void){
  P ans;
  for(int l=1;;l++){
    scanf("%d",&w);
    if(!w)break;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d,%d",&t[i].c,&t[i].w);
    memset(dp,-1,sizeof(dp));
    ans=solve(0,w);
    printf("Case %d:\n%d\n%d\n",l,ans.first,w-ans.second);
  }
}

P solve(int i,int rem){
  P res;
  if(dp[i][rem].first>=0)return dp[i][rem];
  if(i>=n){
    res.first=0;
    res.second=rem;
    return res;
  }
  if(t[i].w>rem){
    res=solve(i+1,rem);
  }
  else{
    res=solve(i+1,rem);
    P temp=solve(i+1,rem-t[i].w);
    temp.first+=t[i].c;
    res=max(res,temp);
  }
  return dp[i][rem]=res;
}

Measured memory_bytes: 8828
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    Map<String, Integer> map = new HashMap<>();
    List<String> list = new ArrayList<>();
    public void solve() {
    	int N = ni();
    	String[] S = new String[N];
    	for (int i = 0; i < N; i++) {
			S[i] = ns();
			map.merge(S[i], 1, Integer::sum);
		}
    	int max = 0;
    	for(String key : map.keySet()) {
    		max = Math.max(max, map.get(key));
    	}
    	for(String key : map.keySet()) {
    		if(map.get(key) == max)		list.add(key);
    	}
    	list.sort(naturalOrder());
    	for(String name : list)	
    		out.println(name);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

int main()
{
    string s, t;
    cin >> s >> t;

    set<int> char_pos[26];
    rep(i, 0, s.size())
        char_pos[s[i] - 'a'].insert(i + 1);

    rep(i, 0, t.size())
    if (char_pos[t[i] - 'a'].size() == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    int num_s = 0;
    int now = 0;
    int i = 0;

    while (i < t.size())
    {
        set<int>::iterator itr = char_pos[t[i] - 'a'].upper_bound(now);
        // cout << t[i] << "*****" << endl;
        // for (auto aa: char_pos[t[i] - 'a'])
        //     cout << aa;
        // cout << endl;

        // cout << i << ' ' << *itr << endl;
        if (itr == char_pos[t[i] - 'a'].end())
        {
            ++num_s;
            now = 0;
            continue;
            // cout << t[i-1] << '-' << now << ' ' << num_s << endl;
        }
        int next = (*itr);
        if (next <= now)
        {
            now = next;
            ++i;
            ++num_s;
        }
        else
        {
            now = next;
            ++i;
        }
        // cout << t[i - 1] << ' ' << now << ' ' << next << ' '<< num_s << ' '<< (*itr) << endl;

    }

    ll ans = num_s * s.size() + now;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    vvint rgb(n+1, vint(3, 0));
    rep2(i, n) {
        rgb[i] = rgb[i-1];
        rep(j, 3) {
            if (rgb[i-1][j] == a[i-1]) {
                rgb[i][j]++;
                break;
            }
        }
    }

    ll ans = 1;
    rep2(i, n) {
        int num = 0;
        rep(j, 3) {
            if (rgb[i-1][j] == a[i-1]) num++;
        }
        ans *= num;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>

const int coins[] = {1, 5, 10, 50, 100, 500};

int main(void) {
    int i, n, sum;
    for(i = sum = 0; i < 6; sum += coins[i++] * n)scanf("%d", &n);
    printf("%d\n", sum > 999);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <cstdlib>
std::string s1,s2;
int cnt[2][128];
int main()
{
    std::cin >> s1 >> s2;
    for(char ch : s1)
        cnt[0][ch]++;
    for(char ch : s2)
        cnt[1][ch]++;
    std::sort(&cnt[0]['a'], &cnt[0]['z'+1]);
    std::sort(&cnt[1]['a'], &cnt[1]['z'+1]);
    for(int i='a';i<='z';i++)
        if(cnt[0][i] != cnt[1][i])
        {
            std::cout << "No\n";
            return 0;
        }
    std::cout << "Yes\n";
}

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

int main(){
  int n,sum=0;
  cin >> n;
  int Arr[2*n];
  for(int x=0;x<2*n;x++){
    cin >> Arr[x];
  }
  sort(Arr,Arr+2*n);
  for(int y=0;y<2*n;y++){
    if(y%2==0){
      sum+=Arr[y];
    }
  }
  cout << sum;
}

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

signed main()
{
    string s, p;
    cin >> s >> p;

    for (int i = 0; i <= (int)s.size() - (int)p.size() + 1; i++)
    {
        bool flag = true;
        for (int j = 0; j < p.size(); j++)
        {
            if (s[j + i] != p[j])
            {
                flag = false;
                break;
            }
        }
        if (flag)
            cout << i << endl;
    }
}


Measured memory_bytes: 3204
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()
A=LI()
#最初マイナスの場合とプラスの場合二回計算する
ans1=0
current = 0
is_positive=True
for a in A:
	current += a
	if is_positive:
		if current <= 0:
			ans1+=1-current
			current = 1
	else:
		if current >= 0:
			ans1+=1+current
			current=-1
	is_positive= not is_positive

ans2=0
current = 0
is_positive=False
for a in A:
	current += a
	if is_positive:
		if current <= 0:
			ans2 += 1-current
			current=1
	else:
		if current >= 0:
			ans2+=1+current
			current = -1
	is_positive= not is_positive
#print(ans1,ans2)
print(min(ans1,ans2))
		
	
		
	

		
	
		
			
		
	
	


Measured memory_bytes: 85612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n, m, k;
	cin>>n>>m>>k;

	if (n<m)
		swap(n, m);

	int x = (k+n-1)/n;
	cout<<x<<"\n";





	



	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
use crate::scanner::Scanner;
use ordered_float::OrderedFloat;
use std::cmp::min;
use std::f64::consts::PI;
fn main() {
    let mut scan = Scanner::new();
    let a = scan.read::<f64>();
    let b = scan.read::<f64>();
    let h = scan.read::<f64>();
    let m = scan.read::<f64>();
    let r1 = 2. * PI * (h / 12. + m / 60. / 12.);
    let r2 = 2. * PI * m / 60.;
    let r = min(
        OrderedFloat::from((r1 - r2).abs()),
        OrderedFloat::from(2. * PI - (r1 - r2).abs()),
    );
    let ans = (a * a + b * b - 2. * a * b * (r.0.cos())).sqrt();
    println!("{}", ans);
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
    }
}



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

using namespace std;

int main(void) {
	int N, M;
	int K;
	cin >> N >> M >> K;

	//読書時間の合計時間表
	int A[200050], B[200050];
	//読まないときは0
	A[0] = 0;
	B[0] = 0;
	//考慮する意味のある範囲
	int A_max = N;
	bool A_check = false;
	int B_max = M;
	bool B_check = false;
	for (int i = 1; i <= N; i++) {
		int Ai;
		cin >> Ai;
		A[i] = Ai + A[i - 1];
		if (A[i] > K && (!A_check)) {
			//i冊目を考える必要は皆無
			A_max = i - 1;
			A_check = true;
		}
	}
	for (int i = 1; i <= M; i++) {
		int Bi;
		cin >> Bi;
		B[i] = Bi + B[i - 1];
		if (B[i] > K && (!B_check)) {
			//i冊目を考える必要は皆無
			B_max = i - 1;
			B_check = true;
		}
	}


	//Aの読む本数を増やして走査
	int ans = 0;
	int Screen_Index; //Bの走査位置に関する関する情報
	Screen_Index = B_max; //A=0のとき、Bは一番大きいところから走査する。
	for (int i = 0; i <= A_max; i++) {
		for (int j = Screen_Index; j >= 0; j--) {
			//オーバーしなくなったら抜け出す
			if (A[i] <= K - B[j]) {
				Screen_Index = j;
				ans = max(ans, i + j);
				break;
			}
		}
	}

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

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

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

    string s, t;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if (s == u) {
        cout << (a - 1) << " " << b << endl;
    } else {
        cout << a << " " << (b - 1) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Vector;

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

    Vector<Integer> vec = new Vector<Integer>();
    while(sc.hasNextInt()){
      vec.add( sc.nextInt() );
    }
		for ( Integer n: vec){
			if( 9*4 < n ){
				System.out.println("0");
			}else{
				int cnt = 0;
				for ( int i = 0; i <= 9; i++ ){
				for ( int j = 0; j <= 9; j++ ){
				for ( int k = 0; k <= 9; k++ ){
				for ( int l = 0; l <= 9; l++ ){
					int sum = i+j+k+l;
					if ( sum == n )
					{
						cnt++;
					}
				}}}}
				System.out.println(cnt);
			}
		}
  }
}

Measured memory_bytes: 19136
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long A, long long B);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, A, B;
    cin>> N >> A >> B;
    string S;
    cin >> S;
    ll cnt1=0, cnt2=0;
    REP(i, N){
        bool flg = false;
        switch (S[i])
        {
        case 'a':
            if(cnt1<A+B){
                cnt1++;
                flg=true;
            }
            break;
        case 'b':
            if(cnt1<A+B && cnt2<B){
                cnt1++;cnt2++;
                flg=true;
            }
            break;
        default:
            break;
        }
        cout << (flg?"Yes":"No") << el;
    }
}



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

void solve() {
	int d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) cout << "Yes";
	else cout << "No";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int n,Q;
const int sz=1e5+9;
char a[sz];
bool is_AC[sz];
int cs[sz];
int l,r;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n>>Q;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        if(a[i]=='C'&&a[i-1]=='A') is_AC[i]=1;
    }
    cs[0]=is_AC[0];
    for(int i=1;i<n;i++) cs[i]=cs[i-1]+is_AC[i];
    while(Q--){
        cin>>l>>r;
        l--;
        r--;
        cout<<cs[r]-(l-1>=0?cs[l-1]:0)-(l-1>=0&&a[l]=='C'&&a[l-1]=='A')<<'\n';
    }
    return 0;
}


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

int main() {
	int N; cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	vector<int> c(N);
	for (int i = 0; i < N; i++) cin >> c[i];

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] >= c[i]) {
			ans += (v[i] - c[i]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#ABC164 B
p = [int(x) for x in input().split()]

takahashi_turn = True
while (p[0]>0) and (p[2]>0):
    if takahashi_turn:
        p[2] = p[2] - p[1]
    else:
        p[0] = p[0] - p[3]
    takahashi_turn = not takahashi_turn

if p[0] > 0:
    print("Yes")
else:
    print("No")

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

int main(){
  int l,r;
  cin >> l >> r;
  
  if(l%2019==0 || r%2019==0){
    cout << 0 << endl;
    return 0;
  }else if(r/2019!=l/2019){
    cout << 0 << endl;
    return 0;
  }
  
  l %= 2019;
  r %= 2019;
  
  int ans = 2018;
  
  for(int i=l; i<=r; i++){
    for(int j=i+1; j<=r; j++){
      ans = min(ans, (i*j)%2019);
    }
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * SumOfNumbers
 */
public class Main {

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

        out_of_loop: while (true) {
            String str = sc.next(); // ここで一文字ずつに区切れ
            String[] strArray = str.split("");

            if (strArray[0].equals("0")) {
                break out_of_loop;
            }

            int ans = 0;

            for (String s : strArray) {
                char[] c = s.toCharArray();
                ans += c[0] - '0';
            }

            System.out.println(ans);
        }

        sc.close();
    }
}


Measured memory_bytes: 27308