akhauriyash/Code-Regression huggingface dataset:
import sys

for line in sys.stdin:
    a, b = map(float, line.rstrip().split())
    if a < 35.50 and b < 71.00:
        print 'AAA'
    elif a < 37.50 and b < 77.00:
        print 'AA'
    elif a < 40.00 and b < 83.00:
        print 'A'
    elif a < 43.00 and b < 89.00:
        print 'B'
    elif a < 50.00 and b < 105.00:
        print 'C'
    elif a < 55.00 and b < 116.00:
        print 'D'
    elif a < 70.00 and b < 148.00:
        print 'E'
    else:
        print 'NA'

Measured memory_bytes: 4236
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(0);/*cin.tie(0); cout.tie(0);*/
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 200010

using namespace std;


ll M;

int main(){
FAST_READ;
cin>>M;
cout<<(24-M)+24<<endl;






return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int n,k;
    cin>>n>>k;
    vector<ll>num(k,0);
    for(int i=1;i<=n;i++){
        num[i%k]++;
    } 
    ll res=0;
    for(int a=0;a<k;a++){
        int b,c;
        b=(k-a)%k;
        c=(k-a)%k;
        if((b+c)%k!=0)continue;
        res+=num[a]*num[b]*num[c];
    }
    cout<<res<<endl;
     return 0;   
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    
    int DP[N+10];
    DP[0] = 0;
    rep1(i,N-1){
        int ans = 1e9;
        rep1(j,min(i,K)) ans = min(ans,DP[i-j]+abs(h[i]-h[i-j]));
        DP[i] = ans;
    }
    pr(DP[N-1]);
}


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

int main (void) {
    char x, y;
    cin >> x >> y;

    if (x < y){
        cout << "<" << endl;
    }else if(x == y){
        cout << "=" << endl;
    }else{
        cout << ">" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n+1]={false};
  for(int i=0;i<k;i++){
    int s;
    cin >> s;
    for(int j=0;j<s;j++){
      int A;
      cin >> A;
      a[A]=true;
    }
  }
  int count=0;
  for(int i=1;i<=n;i++){
    if(a[i]==false)count++;
  }
  cout << count << endl;
}
    


Measured memory_bytes: 3616
import math
n = int(input())

A = [0] * n
for i in range(n):
    A[i] = int(input())

# Naive method
def is_prime(n):
    if n < 2:
        return False
    elif n == 2 or n == 3 or n == 5 or n == 7:
        return True
    elif n % 2 == 0:
        return False
    else:
        for i in range(3, int(math.sqrt(n))+1, 2):
            if n % i == 0:
                return False
    return True

print(len([x for x in A if is_prime(x)]))

Measured memory_bytes: 6052
arr = gets.split.map(&:to_i)
taka = 0
aoki = 0

until arr[2] <= 0 do
	arr[2] -= arr[1]
	aoki += 1
end

until arr[0] <= 0 do
	arr[0] -= arr[3]
	taka += 1
end

if aoki > taka
	puts "No"
else
	puts "Yes"
end

Measured memory_bytes: 14312
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }
    else if(a+b<c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Balanced" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve():
    A, B = map(int, input().split())
    print(lcm(A, B))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9952
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    S = str(input())
    stack_rem = 0

    need_left = 0

    for i in range(N):
        if S[i] == '(':
            stack_rem += 1
        elif stack_rem > 0:
            stack_rem -= 1
        else:
            need_left += 1
    need_right = stack_rem
    print('('*need_left+S+')'*need_right)

resolve()

Measured memory_bytes: 38384
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in);
    String S = scanner.nextLine();
    
    if(S.charAt(0)==S.charAt(1) && S.charAt(0)==S.charAt(2)){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
    
  }
}

    

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

int main() {
    int H, W; cin >> H >> W;
    vector< vector<int> > c(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    vector< vector<int> > A(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != -1) {
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

long A[100][100];
long B[100][100];
long C[100][100];
int n,m,l;
int i,j,k;

main(){
	scanf("%d %d %d",&n,&m,&l);
	for(i=0; i<n; i++){
		for(j=0 ; j <m; j++){
			scanf("%ld",&A[i][j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			scanf("%ld",&B[i][j]);
		}
	}
	for(i=0; i<n; i++){
		for(j=0 ; j <l; j++){
			C[i][j]=0;
			for(k=0;k<m;k++){
				C[i][j] += A[i][k]*B[k][j];
			}
		}
	}
	for(i=0; i<n; i++){
		for(j=0 ; j <l; j++){
			if(j){
			printf(" ");
			}
			printf("%ld",C[i][j]);
		}
		printf("\n");
	}
	return 0;
}
	
	
	
	
	

Measured memory_bytes: 836
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> p(n);

    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    int c = 0;
    for (int i = 2; i < n; ++i) {
        // cout << p[i-2] << " " << p[i-1] << " " << p[i]<< endl;
        if (p[i-2] < p[i-1] && p[i-1] < p[i]) c++;
        if (p[i-2] > p[i-1] && p[i-1] > p[i]) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
number = str(input())[::-1]
remainderDictionary = {0: 1}
digitDictionary = {'1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}

sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum = (sum + digitDictionary[i] * x) % 2019 
  remainderDictionary[sum] = remainderDictionary.get(sum,0) + 1

ans = 0
for i in remainderDictionary:
  value = remainderDictionary[i]
  if value > 1:
    ans += value * (value - 1) // 2 # N C 2
print(ans)

Measured memory_bytes: 9340
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

P tiz[100];
char g[1100][1100];
int w, h, k;
int d[4][2] = {
    {1, 0},
    {-1, 0},
    {0, 1},
    {0, -1}
};
int used[1100][1100];
int solve(P s, P e) {
    fill_n(used[0], 1100*1100, false);
    queue<T> q;
    q.push(T(s.first, s.second, 0));
    while (!q.empty()) {
        T p = q.front(); q.pop();
        int x, y, t;
        tie(x, y, t) = p;
        if (P(x, y) == e) return t;
        if (x < 0 || w <= x || y < 0 || h <= y) continue;
        if (g[x][y] == 'X') continue;
        if (used[x][y]) continue;
        used[x][y] = true;
        for (int i = 0; i < 4; i++) {
            q.push(T(x+d[i][0], y+d[i][1], t+1));
        }
    }
    return -1;
}

int main() {
    cin >> w >> h >> k;
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            char c;
            cin >> c;
            g[i][j] = c;
            if (c == 'S') {
                tiz[0] = P(i, j);
            }
            if (isdigit(c)) {
                tiz[c-'0'] = P(i, j);
            }
        }
    }
    int r = 0;
    for (int i = 0; i < k; i++) {
        r += solve(tiz[i], tiz[i+1]);
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 7016
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,x = gets.chomp.split.map(&:to_i)
l = gets.chomp.split.map(&:to_i)

d = 0
ans = 1
n.times do |i|
  d += l[i]
  ans += 1
  unless d <= x
    ans -= 1
    break
  end
end

puts ans

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b;
	for(auto &i:a)cin >> i;
	b= a;
	sort(b.begin(),b.end());
	map<int,int> mp;
	for(int i = 0;i<n;i++)
	{
		mp[b[i]] = i%2;
	}
	int cnt = 0;
	for(int i =0;i<n;i++)
	{
		if(mp[a[i]]!=(i%2))cnt++;
	}
	cout << cnt/2 << endl;
}


Measured memory_bytes: 8788
S = list(input())
T = list(input())
N = len(S)
L = [[0]*2 for i in range(N)]

for i in range(N):
    L[i][0] = S[i]
    L[i][1] = T[i]

L.sort()

#print(L)

now = L[0][1]
for i in range(1,N):
    if L[i][0] == L[i-1][0]:
        if L[i][1] != now:
            print("No")
            break
    else:
        now = L[i][1]
else:
    for i in range(N):
        L[i][0] = T[i]
        L[i][1] = S[i]

    L.sort()

    #print(L)

    now = L[0][1]
    for i in range(1,N):
        if L[i][0] == L[i-1][0]:
            if L[i][1] != now:
                print("No")
                break
        else:
            now = L[i][1]
    else:
        print("Yes")

Measured memory_bytes: 116424
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
// dp[i][j] is the prob. of having j heads among the first i coins
// sum(dp[n-1][(n+1)/2->n-1]) should be the answer
void solve()
{
    ll n;
    cin>>n;
    vd p(n);
    forr(i, n)
    {
    	cin>>p[i];
    }
    vector<vd> dp(n+1, vd(n+1, 0));
    dp[0][0]=1;
    forr1(i, n)
    {
    	dp[i][0]=dp[i-1][0]*(1-p[i-1]);
    }
    forr1(i, n)
    {
    	forr1(j, i)
    	{
    		dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
    	}
    }
    double sum=0;
    for(ll i=(n+1)/2; i<=n; i++)
    	sum+=dp[n][i];
    std::cout<<setprecision(10)<<sum<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main()
{
  int64_t N, A, B, minsum, maxsum;
  cin >> N >> A >> B;
  if (A > B || (N == 1 && (B - A) > 0))
  {
    cout << 0 << endl;
  }
  else
  {
    minsum = B + A * (N - 1);
    maxsum = A + B * (N - 1);
    cout << maxsum - minsum + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<int> a(N);
    scan(a);

    int now = 0;
    rep(i, N) {
        if (a[i] == now + 1) {
            now++;
        }
    }
    int ans = N - now;
    if (ans == N) {
        print(-1);
    } else {
        print(ans);
    }

    return 0;
}

Measured memory_bytes: 1024
n,m=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort
while m>0
  as[-1]/=2
  m-=1
  break if m==0
  (n-2).downto(0) do |i|
    if as[-1]<as[i]
      as[i]/=2
      m-=1
    else
      break
    end
    break if m==0
  end
  as.sort! if m!=0
end
puts as.map(&:to_i).inject(:+)


Measured memory_bytes: 10112
#[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")
    };
}

use std::cmp::{max, min};
use std::collections::BTreeMap;

fn main() {
    input! {
        n: usize,
        a: [[usize1; n-1]; n],
    }

    let mut ans = 0;
    let mut cur = vec![0; n];

    let mut mm = BTreeMap::new();
    let mut ps = vec![];
    for i in 0..n {
        let x = a[i][cur[i]];
        let key = (min(i, x), max(i, x));
        *mm.entry(key).or_insert(0) += 1;
        if mm[&key] >= 2 {
            ps.push(key);
        }
    }

    for day in 0.. {
        if ps.len() == 0 {
            ans = day;
            break;
        }

        // dbg!(&ps);

        let mut next = vec![];

        for &(i, j) in ps.iter() {
            for &k in [i, j].iter() {
                cur[k] += 1;
                if cur[k] < n - 1 {
                    let x = a[k][cur[k]];
                    let key = (min(k, x), max(k, x));
                    *mm.entry(key).or_insert(0) += 1;
                    if mm[&key] >= 2 {
                        next.push(key);
                    }
                }
            }
        }

        ps = next;
    }

    if cur.iter().all(|&p| p == n - 1) {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


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

//#define int long long

using namespace std;

const int maxn = 1e6+5;
bool vis[maxn];

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

    for (int i = 0; i < maxn; i++) vis[i] = false;

    int n;
    cin >> n;
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        pq.emplace(-x);
    }
    int res = 0;
    while (!pq.empty()) {
        int p = pq.top();
        int cnt = 0;
        while (!pq.empty() && pq.top() == p) {
            pq.pop();
            cnt++;
        }
        p = -p;
        if (!vis[p]) {
            for (int i = p; i < maxn; i += p) vis[i] = true;
            if (cnt == 1) res++;
        }
    }
    cout << res << '\n';
}
/*

 */


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
long long f(int x){
  long long ans = 0;
  long long number = 1;
  int digit = 1;
  while (1){
    if (number * 10 <= x){
      ans += digit * number * 9;
      digit++;
      number *= 10;
    } else {
      ans += digit * (x - number + 1);
      break;
    }
  }
  return ans;
}
int digit(int x){
  int tv = 0;
  int fv = 1000000000;
  while (fv - tv > 1){
    int mid = (tv + fv) / 2;
    if (f(mid - 1) < x){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  x -= f(tv - 1);
  string S = to_string(tv);
  return S[x - 1] - '0';
}
int main(){
  while (1){
    int N, K;
    cin >> N >> K;
    if (N == 0 && K == 0){
      break;
    }
    for (int i = 0; i < K; i++){
      cout << digit(N + i);
    }
    cout << endl;
  }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int H, W, K;
string S[300];
int dp[300][300];
int ans[300][300];

int main() {
	cin >> H >> W >> K;
	REP(i, H) cin >> S[i];
	
	int mmidx[300] {}; // i行目が位置する圧縮後idx
	vector<string> cs;
	
	int lp = -1;
	REP(i, H) {
		bool f = true;
		REP(j, W) if (S[i][j] == '#') f = false;
		
		if (!f) {
			cs.push_back(S[i]);
			lp++;
		}
		if (lp == -1) mmidx[i] = 0;
		else mmidx[i] = lp;
	}
	
	int cnt = 0;
	REP(i, cs.size()) {
		lp = -1;
		REP(j, W) {
			dp[i][j] = cnt;
			if (cs[i][j] == '#') {
				lp = j;
				cnt++;
			}
		}
		FOR(j, lp + 1, W) dp[i][j] = cnt - 1;
	}
	
	REP(i, H) REP(j, W) ans[i][j] = dp[mmidx[i]][j];
	REP(i, H) REP(j, W) printf("%d%c", ans[i][j] + 1, j == W - 1 ? '\n' : ' ');
	
	
	return 0;
}


Measured memory_bytes: 1792
#include <bitset>
#include <iostream>

using ull = unsigned long long;

int main() {
    int n, k;
    std::cin >> n >> k;

    for (ull d = 0; d < (ull)(1 << n); ++d) {
        if (std::bitset<18>(d).count() != (unsigned)k) continue;
        std::cout << d << ':';
        for (int i = 0; i < n; ++i)
            if (d & (1 << i)) std::cout << ' ' << i;
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3108
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if((1<=a<=100)&&(1<=b<=100)&&(1<=c<=100))
{
if((b-a)==(c-b))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    Yes(s[0] == s[2]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int a,b;
  cin>>a>>b;
  cout<<6-a-b;
}

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

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

int main(void){

	int N; cin >> N;
	int flag[101] = {0};
	rep(i, N){
		int d;
		cin >> d;
		flag[d] = 1;
	}

	int ans = 0;
	rep(i, 101){
		ans += flag[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 2000
int a[MAX_N],b[MAX_N],c[MAX_N],m,t,x;
vector<int> G[MAX_N];
void init(){
  t=x=0;
  memset(a,0,sizeof(a));
  memset(b,0,sizeof(b));
  memset(c,0,sizeof(c));
  for(int i=0;i<MAX_N;i++) G[i].clear();
}
void dfs(int d){
  int v=t,p=++x;
  b[d]=p;
  for(int i=0;(int)G[p].size()<a[v];i++){
    t++;
    if(a[t]>0){
      G[p].push_back(x+1);
      G[x+1].push_back(p);
      dfs(d+1);
    }else if(a[t]<0){
      G[p].push_back(b[d+a[t]]);
      G[b[d+a[t]]].push_back(p);
    }else break;
  }
}
int main(){
  int n;cin>>n;
  while(n--){
    init();
    for(int i=0;;i++){
      cin>>a[i];
      if(!a[i]){
	m=i;
	break;
      }
    }
    dfs(0);
    for(int i=1;i<=x;i++){
      if(G[i].size()==0) break;
      cout<<i<<" ";
      sort(G[i].begin(),G[i].end());
      for(int j=0;j<(int)G[i].size();j++)
	cout<<G[i][j]<<" \n"[j==(int)G[i].size()-1];
    }
  }
  return 0;
}

Measured memory_bytes: 3176
//Date: 18-08-2020 //Author: Rishabh Paul

#include<bits/stdc++.h>
using namespace std;

// long long solve() {
// 	int n;
// 	char c;
// 	scanf("%d\n", &n);
// 	map<int ,int> f;
// 	f[0] = 1;
// 	int s = 0;
// 	long long ans = 0LL;
// 	for (int i = 0; i < n; i++) {
// 		scanf("%c", &c);
// 		s += (c - '0') - 1;
// 		ans += f[s]++;
// 	}
// 	return ans;
// }

// int main () {
// 	int t;
// 	scanf("%d", &t);
// 	while(t--) {
// 		printf("%lld\n", solve());
// 	}
// 	return 0;
// }


int main () {
	string s;
	cin >> s;
	if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
		cout << 0 << "\n"; return 0;
	}
	if (s[1] == 'R') {
		if (s[0] == 'R' && s[2] == 'R') {
			cout << 3 << "\n"; return 0;
		}
		if (s[0] == 'R' || s[2] == 'R') {
			cout << 2 << "\n"; return 0;
		}
		cout << 1 << "\n"; return 0;
	}
	cout << 1 << "\n"; return 0;
}


Measured memory_bytes: 3588
A, B = map(int, raw_input().split())

num=0

for x in range(A,B+1):
 c1=x/10000
 c2=x/1000
 c3=x/100
 c4=x/10
 c5=x
 a1=c1
 a2=c2-c1*10
 a3=c3-c2*10
 a4=c4-c3*10
 a5=c5-c4*10
 if a1==a5 and a2==a4:
  num=num+1

print num

Measured memory_bytes: 5508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  rep2(i, 1, 10000){
    int aa = i * 0.08;
    int bb = i * 0.1;
    if(aa == a && bb == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

mkv vin(int n){
    mkv v;
    fo(i,n){
        int t;cin>>t;v.pb(t);
    }
    return v;
}

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

}

int main()
{
  //  fastio();
  //  test
    solve();
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	prime := make([]int, 1000001)
	prime[0], prime[1] = -1, -1
	for i := 2; i < 1000001; i++ {
		if prime[i] != -1 {
			prime[i] = 1 // i means "prime"
			for j := i+i; j < 1000001; j += i {
				prime[j] = -1 // -1 means "not prime"
			}
		}
	}
	for scanner.Scan() {
		ret := 0
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		for i := 1; i <= a/2; i++ {
			if prime[i] == 1 && prime[a-i] == 1 {
				ret++
			}
		}
		fmt.Println(ret)
	}
}


Measured memory_bytes: 9316
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, a[2000][2000] = {}, b, k, sum = 0, d=1, w, h,typ=0;
	long long dp[200005] = {}, memo[200005] = {};
	string str,str2;
	cin >> str >> str2;
	
	if (str < str2) {
		cout << "<";
	}
	else if (str > str2) {
		cout << ">";
	}
	else {
		cout << "=";
	}

}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int start = max(a, c), end = min(b, d);
  cout << max(0, end - start) << '\n';
  return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ok := true
	for i := 0; i < N; i++ {
		var A int
		fmt.Scan(&A)
		if A%2 == 0 {
			if A%3 != 0 && A%5 != 0 {
				ok = false
			}
		}
	}
	if ok {
		fmt.Println("APPROVED")
	} else {
		fmt.Println("DENIED")
	}
}


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

namespace _0610
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for(int i = 0; i < n[0]; i++)
            { string str = Console.ReadLine();
                int Cloud = -1;
                for(int j = 0; j < n[1]; j++)
                {
                    if (j != 0) { Console.Write(" "); }
                    if (str[j] == 'c') { Cloud = 0; }
                    else if (Cloud != -1) { Cloud++; }
                    Console.Write(Cloud);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9604
def warshall_floyd(g):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                g[i][j] = min(g[i][j], g[i][k] + g[k][j])

n = int(input())
s = [[int(i) for i in list(input())] for _ in range(n)]
graph = [[float("inf")]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if s[i][j] == 1:
            graph[i][j] = 1
        if i == j:
            graph[i][j] = 0

warshall_floyd(graph)
d = 0
#print(graph)
for i in range(n-1):
    for j in range(i+1,n):
        if graph[i][j] != float("inf"):
            if d < graph[i][j]:
                start = i
                end = j
                d = graph[i][j]

v = [[] for _ in range(d+1)]
for i in range(n):
    l = graph[start]
    v[l[i]].append(i)
#print(v)
#print(start,end)

for l in v:
    m = len(l)
    for i in range(m-1):
        for j in range(i+1,m):
            if s[l[i]][l[j]] == 1:
                print(-1)
                quit()
print(d+1)

Measured memory_bytes: 57180
N = int(input())
A = list(map(int, input().split()))
B = ()
for i in range(N):
    if A[i]%2 == 0:
        B = B + (A[i],)

for i in range(len(B)):
    if (B[i]%3 != 0) and (B[i]%5 != 0):
        print("DENIED")
        exit()

print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;
constexpr ll A_I_MAX = 1000000000;

ll N;
ll a[N_MAX];

void input() {
	scanf("%lld", &N);
	rep(i, N) scanf("%lld", a + i);
}

void solve() {
	if([&]{
		rep(i,N){
			if(a[i]){
				return false;
			}
		}
		return true;
	}()){
		p("Yes");return;
	}

	if(N%3){
		p("No");return;
	}

	map<ll,ll> m;
	rep(i,N){
		m[a[i]]++;
	}
	if(m.size()==2){
		for(auto a:m){
			if((a.first==0 && a.second==N/3) || (a.first!=0 && a.second==2*N/3 )){

			}else{
				p("No");return;
			}
		}
	}else if(m.size()==3){
		vector<ll> b;
		for(auto a:m){
			if(a.second!=N/3){
				p("No");return;
			}
			b.push_back(a.first);
		}

		if(b[0]==(b[1]^b[2]) || b[1]==(b[0]^b[2]) || b[2]==(b[1]^b[0])){

		}else{
			p("No");return;
		}
	}else{
		p("No");return;
	}

	p("Yes");
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  string s; cin >> s;
  int first = stoi(s.substr(0,2));
  int last = stoi(s.substr(2,2));
  if (first > 12 && last > 12) {
    cout<<"NA"<<endl;
  } else if (first > 12 && last <= 12) {
    if (last == 0) {
      cout<<"NA"<<endl;
    } else {
      cout<<"YYMM"<<endl;
    }
  } else if (first <=12 && last > 12) {
    if (first == 0) {
      cout<<"NA"<<endl;
    }else{
      cout<<"MMYY"<<endl;
    }
  } else if (first <= 12 && last <= 12) {
    if (last == 0 && first == 0) {
      cout<<"NA"<<endl;
    } else if (last == 0) {
      cout<<"MMYY"<<endl;
    } else if (first == 0) {
      cout<<"YYMM"<<endl;
    } else {
      cout << "AMBIGUOUS"<<endl;
    }
  }
}


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

void main_()
{
    string S;
    cin >> S;
    auto remove_size = S.size() - 7;

    for (auto i = 0; i < S.size() - remove_size + 1; ++i) {
        auto s = S.substr(0, i) + S.substr(i + remove_size);
        if (s == "keyence") {
            cout << "YES\n";
            return;
        }
    }

    cout << "NO\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s,t,ans;
  
  cin >> n >> s >> t;
  
    for(int i=0;i<n;i++){
    ans = ans + s.at(i) + t.at(i);
    }
           
    
  cout << ans << endl;
               
}

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

ll dp[1000005][2]={};
//dp[i][0] i桁目までぴったり
//dp[i][1] i桁目で+1枚払う

int main(){
  string n;
  cin>>n;
  dp[0][1]=1;
  for(int i=1;i<=n.size();i++){
    int now=(int)(n[i-1]-'0');
    dp[i][0]=min(dp[i-1][0]+now,dp[i-1][1]+10-now);
    dp[i][1]=min(dp[i-1][0]+now+1,dp[i-1][1]+(10-now-1));
  }
  cout<<dp[n.size()][0]<<endl;
}

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

signed main(){
    int N;
    cin>>N;
    vector<int>vec(N,0);
    REP(i,N-1){
        int a;cin>>a;
        vec[a-1]++;
    }
    REP(i,N){
        cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll c;
  cin >> c;
  ll d;
  cin >> d;
  cout<<max({a*c,a*d,b*c,b*d})<<endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();


        int ans = N / X;
        if (N % X != 0) {
            ans++;
        }
        System.out.println(ans * T);

    }
}


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

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

Measured memory_bytes: 256
#include<iostream>

int main(){
    long long unsigned int A = 100;
    long long unsigned int X;
    long long unsigned int year=0;
    std::cin >> X;
    while(1){
        if(X <= A) break;
        A += A/100;
        year++;
    }
    std::cout << year << "\n";
    return 0;
}

Measured memory_bytes: 3200
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=110;
const ll mod=1e9+7;

ll dp[maxn][maxn],a[maxn];

ll tavan(ll a,ll b){
    ll an=1;
    while(b>0){
	if(b%2) an=(an*a)%mod;
	a=(a*a)%mod;
	b/=2;
    }
    return an;
}

int main(){
    ll n;cin>>n;
    FOR(i,1,n){
	cin>>a[i];
    }
    a[0]=1;
    dp[0][0]=1;
    FOR(i,1,n){
	FOR(j,0,n){
	    if(a[j]<=a[i]){
		if(a[j]>=a[i-1]){
		    dp[i][j]=((2*dp[i-1][i-1])*tavan(2,max(ll(0),a[i]-a[j])))%mod;
		}
		else{
		    dp[i][j]=((dp[i-1][j]+dp[i-1][((a[i]>=a[i-1])?(i-1):(i))])*tavan(2,max(ll(0),a[i]-a[i-1])))%mod;
		}
	    }
	}
    }
    cout<<dp[n][0];
}


Measured memory_bytes: 384
// Code by H~$~C
#include <bits/stdc++.h>
using namespace std;
#define epoch_time chrono::steady_clock::now().time_since_epoch().count()
static mt19937 __gen(epoch_time);
#define random_shuffle(begin, end) shuffle(begin, end, __gen)
#define fi first
#define se second
#define x1 x1_19260817
#define y1 y1_19260817
#define j1 j1_19260817
#define x0 x0_19260817
#define y0 y0_19260817
#define j0 j0_19260817
#define left left_19260817
#define right right_19260817
#define rank rank_19260817
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
constexpr int inf = 0x3f3f3f3f;
constexpr ll lnf = 0x3f3f3f3f3f3f3f3f;

string s;
int n;

void dfs(int x) {
  if (x == n + 1) {
    cout << s.substr(1) << endl;
    return;
  }
  char l = 'a';
  char mx = 0;
  for (char ch: s) mx = max<char>(mx, ch);
  char r = mx + 1;
  for (char i = l; i <= r; ++i) {
    s += i;
    dfs(x + 1);
    s.pop_back();
  }
}

signed main() {
  cin >> n;
  s.push_back('a' - 1);
  dfs(1);
  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
int game,n,i,j,team[100];
int a,b,c,d,ban[100];
scanf("%d",&n);
for(i=0;i<n;i++){
team[i]=0;
ban[i]=1;
}
game=n*(n-1)/2;
for(i=0;i<game;i++){
scanf("%d %d %d %d",&a,&b,&c,&d);
if(c>d){
team[a-1]+=3;
}
else if(c==d){
team[a-1]+=1;
team[b-1]+=1;
}
else{
team[b-1]+=3;
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(team[i]<team[j]){
ban[i]++;
}
}
printf("%d\n",ban[i]);
}
return 0;
}

Measured memory_bytes: 600
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char* argv[]) {
	int n, a;
	set<int> s;
	bool ans = true;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (s.find(a) != s.end()) {
			ans = false;
		}
		s.insert(a);
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> A;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        if(A[a] == 0){
            A[a]++;
        }else{
            A.erase(a);
        }
    }

    cout << A.size() << endl;


    return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s;
    cin >> s;
    char x = s[s.size() - 1];
    if (x == '2' || x == '4' || x == '5' || x == '7' || x == '9')
        cout << "hon\n";
    else if (x == '0' || x == '1' || x == '6' || x == '8')
        cout << "pon\n";
    else
        cout << "bon\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

typedef long long int ll;

int main(){
	int arr[3][3];
	set<int> s;
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			cin >> arr[i][j];
		}
	}
	int n;cin >> n;
	while(n--){
		int t;cin >> t;
		s.insert(t);
	}
	set<int> t;
	int dr = 0;
	int dl = 0;
	int r = 0;
	int c = 0;
	for(int i = 0;i < 3;i++){
		if(s.count(arr[i][i]) != 0)dl++;
		if(s.count(arr[i][3 - i - 1]) != 0)dr++;
	}
	if(dr == 3 || dl == 3)return cout << "Yes", 0;
	for(int i = 0;i < 3;i++){
		r = 0;
		c = 0;
		for(int j = 0;j < 3;j++){
			if(s.count(arr[i][j]) != 0)r++;
			if(s.count(arr[j][i]) != 0)c++;
			if(r == 3 || c == 3)return cout << "Yes", 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    char S7[S.size()*2];
    for(int i = 0;i < S.size()* 2;i++){
        if(i < S.size()) S7[i] = S[i];
        else S7[i] = S[i - S.size()];
    }
    bool frag = 0;
    for(int i = 0;i < S.size();i++){
        bool frag7 = 1;
        for(int j = 0;j < S.size();j++){
            if(T[j] != S7[j+i]) {
                frag7 = 0;
                break;
            } 
        }
        if(frag7) frag = 1;
    }
    if(frag) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 256