akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, c;
    cin >> n >> c;
    vll x(n), v(n);
    rep(i, n){
        cin >> x[i] >> v[i];
    }
    
    ll ans = 0;
    ll rval = 0;
    ll rd = 0;
    rep(i, n){
        rval += v[i];
        rd = x[i];
        chmax(ans, rval-rd);
    }
    ll lval = 0;
    ll ld = 0;
    repb(i, n){
        lval += v[i];
        ld = c-x[i];
        chmax(ans, lval-ld);
    }
    
    lval = 0;
    rval = 0;
    ld = 0;
    rd = 0;
    // 右折り返さないコスト
    vll rc1(n);
    // 右折り返すコスト
    vll rc2(n);
    rep(i, n){
        rval += v[i];
        rd = x[i];
        rc1[i] = rval-rd;
        rc2[i] = rval-2*rd;
    }
    // 左折り返さないコスト
    vll lc1(n);
    // 左折り返すコスト
    vll lc2(n);
    repb(i, n){
        lval += v[i];
        ld = c-x[i];
        lc1[i] = lval-ld;
        lc2[i] = lval-2*ld;
    }
    
    vll lc1m(n);
    vll rc1m(n);
    vll lc2m(n);
    vll rc2m(n);
    ll tmp = 0;
    repb(i, n){
        chmax(tmp, lc1[i]);
        lc1m[i] = tmp;
    }
    tmp = 0;
    repb(i, n){
        chmax(tmp, lc2[i]);
        lc2m[i] = tmp;
    }
    tmp = 0;
    rep(i, n){
        chmax(tmp, rc1[i]);
        rc1m[i] = tmp;
    }
    tmp = 0;
    rep(i, n){
        chmax(tmp, rc2[i]);
        rc2m[i] = tmp;
    }
    rep(i, n-1){
        chmax(ans, rc1m[i]+lc2m[i+1]);
        chmax(ans, rc2m[i]+lc1m[i+1]);
    }
    dump(lc1);
    dump(lc1m);
    dump(lc2);
    dump(lc2m);
    dump(rc1);
    dump(rc1m);
    dump(rc2);
    dump(rc2m);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int cnt=0;
    if (a==b) cnt++;
    if (a==c) cnt++;
    if (c==b) cnt++;
    if (cnt==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    bool tranp[4][13];
    for(int i=0;i<4;++i)
        for(int j=0;j<13;++j)
            tranp[i][j] = false;
    int n;
    std::cin >> n;
    for (int i=0;i<n;++i) {
        std::string egara;
        int num;
        std::cin >> egara >> num;
        if (egara == "S") tranp[0][num-1] = true;
        if (egara == "H") tranp[1][num-1] = true;
        if (egara == "C") tranp[2][num-1] = true;
        if (egara == "D") tranp[3][num-1] = true;
    }

    for (int i=0;i<4;++i)
        for (int j=0;j<13;++j)
            if (!tranp[i][j]) {
                if (i == 0) std::cout << "S " << j+1 << std::endl;
                if (i == 1) std::cout << "H " << j+1 << std::endl;
                if (i == 2) std::cout << "C " << j+1 << std::endl;
                if (i == 3) std::cout << "D " << j+1 << std::endl;
            }
                
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

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

    int x = 0 ;
    int xMax = 0 ;
    for( int i = 0 ; i < N ; i ++){
      switch ( S.charAt( i ) ){
        case 'I':
        x ++ ;
        if( x > xMax ){
          xMax = x;
        }
        break;
        case 'D':
        x -- ;
        break;
      }
    }
    System.out.println( xMax );
  }
}


Measured memory_bytes: 22604
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int P=1e9+7,N=90;
typedef long long ll;
int T;ll n,m,f[N+10];
vector<pair<ll,ll> > g[N+10];
int main(){
    scanf("%d",&T);
    f[0]=1;f[1]=1;
    rep(i,2,N) f[i]=f[i-1]+f[i-2];
    g[1]={mp(1,2),mp(1,3),mp(1,4)};
    rep(i,1,N-1) for(auto p:g[i]){
        ll x=p.se,y=p.fi+p.se;
        while(y<=f[i+3]+f[i]) g[i+1].emplace_back(x,y),y+=x;
    }
    while(T--){
        scanf("%lld%lld",&n,&m);if(n>m) swap(n,m);
        int t=1;
        while(f[t+1]<=n&&f[t+2]<=m) ++t;
        printf("%d ",t);
        if(t==1){printf("%lld\n",n%P*(m%P)%P);continue;}--t;
        ll ans=0;
        for(auto p:g[t]){
            if(p.se<=n) ans+=(m-p.fi)/p.se%P;
            if(p.se<=m) ans+=(n-p.fi)/p.se%P;
        }
        printf("%lld\n",ans%P);
    }
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h> 
using namespace std;
int main() 
{ 
  int i,n;
  cin>>n;
  string s;
  set<string> s2;
  for(i=0;i<n;i++){
      cin>>s;
      s2.insert(s);
  }
  cout<<s2.size()<<endl;
	return 0;
} 


Measured memory_bytes: 19152
a_1 = gets.chomp.split(' ').map(&:to_i)
a_2 = gets.chomp.split(' ').map(&:to_i)
a_3 = gets.chomp.split(' ').map(&:to_i)
arr = a_1.concat(a_2.concat(a_3)).map!{|i| [i,0]}
n = gets.to_i
b_arr = []
n.times do
  b_arr.push(gets.to_i)
end
arr.each do |coe|
  b_arr.each do |num|
    if coe[0] == num
      coe[1] = 1
      break
    end
  end
end

if arr[0][1]*arr[1][1]*arr[2][1] + arr[3][1]*arr[4][1]*arr[5][1] + arr[6][1]*arr[7][1]*arr[8][1] + arr[0][1]*arr[3][1]*arr[6][1] + arr[1][1]*arr[4][1]*arr[7][1] + arr[2][1]*arr[5][1]*arr[8][1] + arr[0][1]*arr[4][1]*arr[8][1] + arr[2][1]*arr[4][1]*arr[6][1] > 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14320
import qualified Data.ByteString.Char8 as C
import Data.List ( group, sort, length, sortOn )
import Data.Maybe ( fromJust )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,k] <- readInts
  as    <- readInts
  print $ f n k as

f :: Int -> Int -> [Int] -> Int
f n k as = g as'' (l-k) 0
  where
    as'  = group $ sort as
    l    = length as'
    as'' = map length $ sortOn length as'

g :: [Int] -> Int -> Int -> Int
g _      k x 
  | k <= 0   = x
g (b:bs) k x = g bs (k-1) (x+b) 

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

int main(){
  int n;
  cin >> n;
  vector<int>l(2*n);
  for(int i=0; i<2*n; i++)cin >> l[i];
  sort(l.begin(), l.end());
  int ret=0;
  for(int i=0; i<n; i++)ret+=l[2*i];
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
string s,t;
ll ans=0;
cin >> s >> t;
for (ll i = 0; i < s.size(); i++){
    if (s[i] != t[i]) ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 3832
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local H, W = read.nn()
if H == 1 or W == 1 then
    print(1)
else
    print(H*W//2 + H*W%2)
end

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int N,M,sum=0;
  cin>>N>>M;
  vector<ll> vec(M);
  for(ll i=1;i<=M;i++){
    cin>>vec.at(i-1);
    sum+=vec.at(i-1);
  }
  if(sum>N){cout<<-1<<endl;}
  else{cout<<N-sum<<endl;}
}

Measured memory_bytes: 3676
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , k ;

int main ( ){
  scanf("%d %d",&n,&k);

  for ( int i = 0 ; i < n; i++ )scanf("%d",a+i);
   n -= k ;
  printf("%d", ( (n+(k-2)) /(k-1) ) + 1 );

return 0 ;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    map<string, int> mp;
    rep (i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int maxi = 0;
    for (auto const& entry: mp) {
        maxi = max(maxi, entry.second);
    }
    for (auto const& entry: mp) {
        if (entry.second == maxi) cout << entry.first << endl;
    }
    
    return 0;
}



Measured memory_bytes: 23808
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
best_score = {"r": P, "s": R, "p": S}
ans = 0
# Initially, plus best scores till K.
# Because anything is OK till K count.
for i in range(K):
  ans += best_score[T[i]]
# After K count
for i in range(K, N):
  # Check i - K count.
  if T[i - K] == T[i]:
    # draw
    T[i] = ""
    continue
  ans += best_score[T[i]]
print(ans)

Measured memory_bytes: 4084
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
r = 0
(0..a).each do |c_500|
  (0..b).each do |c_100|
    (0..c).each do |c_50|
      r+= 1 if x == c_500 * 500 + c_100 * 100 + c_50 * 50
    end
  end
end
puts r


Measured memory_bytes: 1788
import java.util.Scanner;

/**
 * Rectangle
 */
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26064
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "DENIED" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<string> A(N);
    rep(i,N) cin>>A[i];
    map<string,ll> mp;
    rep(i,N){
        ++mp[A[i]];
    }
    vector<string> ans;
    ll ma=0;
    for(auto x: mp){
        ll fi=x.second; string stri=x.first;
        if(maxi(ma,fi)) ans.clear();
        if(ma==fi) ans.emplace_back(stri);
    }
    SORT(ans);
    for(auto x: ans){
        cout<< x <<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 27120
#include<bits/stdc++.h>
#define N 1<<11
using namespace std;
int H,W,L[N][N],R[N][N],U[N][N],D[N][N],ans;
char G[N][N];
int main(){
  cin>>H>>W;
  for(int i=1;i<=H;i++)cin>>(G[i]+1);
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
  if(G[i][j]=='.')U[i][j]=U[i-1][j]+1,L[i][j]=L[i][j-1]+1;
  for(int i=H;i;i--)for(int j=W;j;j--)
  if(G[i][j]=='.')D[i][j]=D[i+1][j]+1,R[i][j]=R[i][j+1]+1;
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
  if(G[i][j]=='.')ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
  cout<<ans<<endl;
}


Measured memory_bytes: 69888
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n+2,0);
    rep(i,n)cin >> a[i+1];
    vector<ll> one(n+1), two(n);
    rep(i,n+1)one[i] = abs(a[i+1] - a[i]);
    rep(i,n)two[i] = abs(a[i+2] - a[i]);
    ll all = 0;
    rep(i,n+1)all += one[i];
    rep(i,n){
        ll temp = all;
        temp -= one[i] + one[i+1];
        temp += two[i];
        cout << temp << "\n";
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll bn(ll a, ll n)
{
	ll r = 1;
	for(; n > 0; n >>= 1ll)
	{
		if(n & 1)
			r = (r * a) % MOD;
		a = (a * a) % MOD;
	}
	return r;
}
int p[N*10], c[N*10], ded[N*10], a[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
		
	}
	p[1] = 1;
	for(int i = 2; i * i <= 1000000; i ++)
		for(int j = i; j * i <= 1000000; j ++)
			p[i*j] = 1;
	vi v;
	for(int i = 2; i <= 1000000; i ++)
		if(!p[i])
			v.pb(i);
	for(int ii = 1; ii <= n; ii ++)
	{
		int i = a[ii];
		int x = i;
		while(x > 1)
		{
			if(!p[x])
			{
				c[x] = max(c[x], 1);
				break;
			}
			for(auto it : v)
			{
				if(x % it == 0)
				{
					int f = 0;
					while(x % it == 0)
						x /= it, f ++;
					c[it] = max(c[it], f);
					break;
				}
			}
		}
	}
	ll res = 1;
	for(int i = 1; i <= 1000000; i ++)
	{
		if(!c[i])
			continue;
		ll q = bn(i, c[i]);
		res = (q * res) % MOD;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		ll q = (res * bn(a[i], MOD - 2));
		ans = (ans + q) % MOD;
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 13048
import std.stdio, std.algorithm, std.conv, std.array, std.string;

bool[10^^5+1] PRM = true;
int[10^^5+1] BIT;

void main()
{
    PRM[0] = PRM[1] = false;
    foreach (i; 3..10^^5+1) {
        if (i & 1) {
            if (PRM[i]) {
                auto n = 2;
                auto j = i * n;
                while (j < 10^^5+1) {
                    PRM[j] = false;
                    j = i * (n++);
                }
            }
        } else {
            PRM[i] = false;
        }
    }

    foreach (n; 3..10^^5+1) {
        if (PRM[n] && PRM[(n+1)/2]) {
            for (auto x = n; x <= 10^^5; x += x & -x) {
                BIT[x] += 1;
            }
        }
    }

    int sum(int a) {
        int ret;
        for (auto x = a; x > 0; x -= x & -x) {
            ret += BIT[x];
        }
        return ret;
    }

    auto q = readln.chomp.to!int;
    foreach (_; 0..q) {
        auto lr = readln.split.to!(int[]);
        writeln(sum(lr[1]) - sum(lr[0]-1));
    }
}

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

using namespace std;


int main(void)
{
	const long long p = 998244353;
	int n, s;
	cin >> n >> s;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long d[n+1][s+1];
	for (int j = 0; j <= s; j++) {
		if (a[0] == j)
			d[1][j] = 1;
		else
			d[1][j] = 0;
	}
	d[1][0] = 2;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= s; j++) {
			long long v = 0;
			v += d[i-1][j]*2;
			v %= p;
			if (j-a[i-1] >= 0) {
				v += d[i-1][j-a[i-1]];
				v %= p;
			}
			d[i][j] = v;
		}
	}

	/*
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= s; j++) {
			cout << d[i][j] << " ";
		}
		cout << endl;
	}
	*/


	cout << d[n][s] << endl;

	return 0;
}

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

int main() {
  double r;
  cin >> r;
  cout << setprecision(6) << r * 2 * M_PI << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N), S(N+1);
  rep(i, N) {
    cin >> A[i];
  }
  rep(i, K) {
    bool fin = true;
    rep(j, N+1) {
      S[j] = 0;
    }
    rep(j, N) {
      S[max(0LL,j-A[j])] ++;
      S[min(N,j+A[j]+1)] --;
    }
    int val = 0;
    rep(j, N) {
      val += S[j];
      A[j] = val;
      if(val != N) fin = false;
    }
    if(fin) break;
  }

  rep(i, N) {
    cout << A[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 6368
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 100 + 10 ;

int n , ar [ 3 ] [ N ] , dp [ 3 ] [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	cin >> n ;
	for ( int i = 1 ; i <= 2 ; i ++ )
		for ( int j = 1 ; j <= n ; j ++  )
			cin >> ar [ i ] [ j ] ; 
	for ( int i = 1 ; i <= 2 ; i ++ ) {
		for ( int j = 1 ; j <= n ; j ++ )
			dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j - 1 ] ) + ar [ i ] [ j ] ; 
	}

	cout << dp [ 2 ] [ n ] ; 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextInt
    val B = sc.nextInt
    "%d".format((A - 1) * (B - 1))
  }
}


Measured memory_bytes: 27048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,K;
    cin >> A >> B >> K;
    int Min = min(A,B);
    int i,ans,count = 0;

    for(i=Min;i>=1;i--){
        if(A % i == 0 && B % i == 0){
            count ++;
        }
        if(count == K){
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long a,b,c;
    cin>>a>>b>>c;
    if ((b*c)<a)
    {
    	cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

// ==========Start Here==============

struct cmp{
	bool operator()(pii a, pii b) {
		return a.ff >= b.ff ; 
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 	
 	int n , m ; 
 	cin >> n >> m ; 
 	vt<int> a(n) ; 
 	read(a) ; 
 	set< pii> s ; 
 	rep(i,0,n) {
 		s.insert({a[i],i+1}) ; 
 	}
 	//cout << s.size() << endl ;
 	while(m--) {
 		//cout << 1 << endl ;
 		pii tmp = *s.rbegin() ; 
 		s.erase(tmp) ; 
 		s.insert(mp(tmp.ff/2 , tmp.ss)) ; 
 	}
 	ll ans = 0 ; 
 	for(pii x : s) {
 		ans += x.ff ; 
 		//cout << ans << endl ;
 	}
 	cout << ans ; 


 	return 0 ; 
 	
}

Measured memory_bytes: 8328
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
using i64 = long long;
using namespace std;

const int maxn = 100;
const int maxw = 1e5;
i64 dp[maxw + 1] = {0};
i64 w[maxn];
i64 v[maxn];

int main() {
  int n, W;
  cin >> n >> W;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  dp[0] = 0; // max value when weight is x
  for (int i = 0; i < n; i++) {
    for (int j = W; j >= w[i]; j--) {
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  sort(dp, dp + (W + 1));
  cout << dp[W] << endl;
}

Measured memory_bytes: 1024
N = str(input())
if N=="SAT":
  print("1")
elif N=="FRI":
  print("2")
elif N=="THU":
  print("3")
elif N=="WED":
  print("4")
elif N=="TUE":
  print("5")
elif N=="MON":
  print("6")
else:
  print("7")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    float gyaku[100],sum = 0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>gyaku[i];
        gyaku[i] = 1 / gyaku[i];
        sum+=gyaku[i];
    }
    cout<< 1 / sum;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)

void printVec(std::vector<int> &vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}







int main() {

	int n,q;
	cin >> n;
	vector<int>a(n);
	vector<int>d(200000);
	ll sum = 0;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		d[a[i]]++;
		sum = sum + a[i];
	}
	
	cin >> q;
	vector<int>b(q);
	vector<int>c(q);
	
	for (int i = 0;i < q;i++) {
		cin >> b[i] >> c[i];
		int tmp = d[b[i]];
		d[c[i]] = d[c[i]] + tmp;
		d[b[i]] = 0;
		sum = sum + (c[i] - b[i])*tmp;
		cout << sum << endl;
	}


	
	
	return 0;
}


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int N;
    double num=0;
    cin >> N;

    REP(i,N){
        if((i+1)%2==1){
            num++;
        }
    }
    cout << num/N << endl;
    return 0;
}

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

using namespace std;

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

  vector<pair<int64_t, int64_t> > ab(n);
  for(int64_t i = 0;
      i < n;
      ++i)
    {
      cin >> ab[i].first >> ab[i].second;
    }

  sort(ab.begin(), ab.end());

  int64_t ans = 0;
  map<int64_t, int64_t> pque;
  int64_t cnt = 0;
  for(int64_t i = 1;
      i <= m;
      ++i)
    {
      for(;
          ab[cnt].first == i;
          ++cnt)
        {
          auto itr = pque.find(ab[cnt].second);
          if(itr == pque.end())
            {
              pque.insert(make_pair(ab[cnt].second,1));
            }
          else
            {
              ++itr->second;
            }
        }
      if(!pque.empty())
        {
          auto itr = pque.rbegin();
          ans += itr->first;
          --itr->second;
          if(itr->second == 0)
            {
              pque.erase(itr->first);
            }
        }
    }

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


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> l(n * 2);
  rep(i, 0, n * 2) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  rep(i, 1, n * 2) {
    ans += min(l[i], l[i - 1]);
    i++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;

     signed main(){
       string s;int K;
       cin>>s>>K;
       vector<int> c;
       c.push_back(0);int t=0;
       for(auto&&i :s){
          if(i=='0')c.push_back(0);
          else {c[c.size()-1]++;t++;}
       }
       int dp[c.size()+1][t+1][301];
       for(int i=0;i<=t;i++)fill(dp[0][i],dp[0][i]+301,0);
       dp[0][0][0]=1;int o=0;
       for(int i=1;i<=c.size();i++){
          o+=c[i-1];
             for(int j=0;j<=t;j++)fill(dp[i][j],dp[i][j]+301,0);
          for(int j=0;j<=t;j++)for(int k=0;k<301;k++)for(int j2=0;j2<=j;j2++)if(k-max(j-j2-c[i-1],0ll)>=0&&j>=o)dp[i][j][k]=(dp[i][j][k]+dp[i-1][j2][k-max(j-j2-c[i-1],0ll)])%MOD;
       }
   int ans=0;
   for(int i=0;i<=min(K,300ll);i++){ans=(ans+dp[c.size()][t][i])%MOD;}//cerr<<dp[c.size()][t][i]<<endl;}
   
cout<<ans<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 57604
import fractions
from functools import reduce

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

mod = 10 ** 9 + 7
n = int(input())
numList = list(map(int, input().split()))

# lcmTotal = 1
# for i in numList:
#   lcmTotal = lcm_base(lcmTotal, i)

lcmTotal = lcm_list(numList)

result = 0
for targetNum in numList:
  result += lcmTotal // targetNum

print(result % mod)


Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

int main(void) {
    
    
    vector<int> v(3, 0);
    int n1 = 0;
    int n2;
    int m = INT_MAX;
    
    for (int i = 0; i < 3; ++i) {
        
        cin >> v[i];
        
    }
    
    for (int i = 0; i < 3; ++i) {
        
        n2 = (n1 + 1) % 3;
        
        m = min(m, v[n1] + v[n2]);
        
        ++n1;
        
    }
    
    cout << m;
    
    return 0;
    
}

















Measured memory_bytes: 256
n = int(input())
A = list(input().split())


def f():

    for i in range(n):
        a = int(A[i])
        if(a == 0):
            return 0

    ans = 1

    for i in range(n):
        a = int(A[i])
        if(a == 0):
            return 0
        elif(ans*a > 1000000000000000000):

            return -1
        ans *= a

    return ans


print(f())


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

const int INF = 1000000;

int dp[105][105][2];

const int dx[2]={1,0};
const int dy[2]={0,1};

int main(){
	int h,w;
	cin >> h >> w;
	char field[105][105];
	
	rep(i,h){
		rep(j,w){
			cin >> field[i][j];
		}
	}
	
	rep(i,h){
		rep(j,w){
			rep(k,2){
				dp[i][j][k] = INF;
			}
		}
	}
	
	//dp初期条件
	if(field[0][0] == '.'){
		dp[0][0][0] = 0;
	}else{
		dp[0][0][1] = 1;
	}
	
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			for (int k = 0; k < 2; ++k) {
				int ny = i + dy[k];
				int nx = j + dx[k];
				if(ny >= h || nx >= w) continue;
				if(field[ny][nx] == '#'){
					dp[ny][nx][1] = min(dp[i][j][1], dp[ny][nx][1]);
					dp[ny][nx][1] = min(dp[ny][nx][1], dp[i][j][0] + 1);
				}
				if(field[ny][nx] == '.'){
					dp[ny][nx][0] = min(dp[ny][nx][0], dp[i][j][1]);
					dp[ny][nx][0] = min(dp[ny][nx][0], dp[i][j][0]);
				}
			}
		}
	}
	
	int ans = min(dp[h-1][w-1][0], dp[h-1][w-1][1]);
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define pb push_back
#define lim 2750131
#define size 201
using namespace std;
bool flag;
char s[size][size];
void bfs(ll source,ll dist[],ll n)
{ll i;
	queue<ll> q;
	q.push(source);
    dist[source]=0;
	while(!q.empty()){
		ll x=q.front();
		q.pop();

		loop(i,0,n)
		{
			if(s[x][i]-48)
			{
				if(dist[i]==-1)
					{dist[i]=dist[x]+1; 
						q.push(i);}
						else if(dist[i]%2==dist[x]%2)
							flag=false;
			}
		}
	}
}

int main()
{ll i,n;
	cin>>n;
	ll dist[n+1];
	loop(i,0,n) cin>>s[i];
    loop(i,0,n)
    dist[i]=-1;

    flag=true;
    bfs(0,dist,n);
    if(!flag)
    	{cout<<-1<<endl;
    		return 0;}

    		ll mx=-1,j;
           
    		//loop(i,0,n){ if(dist[i]>mx){mx=dist[i]; p=i; }dist[i]=-1;}
    		loop(i,0,n)
    		{
    		    loop(j,0,n) dist[j]=-1;
    		    bfs(i,dist,n);
    		    loop(j,0,n) mx=max(mx,dist[j]);
    		}

    		cout<<mx+1<<endl;
    		return 0; 

}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if ((a <= b) && (a <= c)) {
        cout << a << " ";
        if (b <= c)
            cout << b << " " << c << endl;
        else 
            cout << c << " " << b << endl;
    }else if ((b <= a) && (b <= c)) {
            cout << b << " ";
            if (a <= c)
                cout << a << " " << c << endl;
            else 
                cout << c << " " << a << endl;
    }else if ((c <= a) && (c <= b)) {
            cout << c << " ";
            if (a <= b)
                cout << a << " " << b << endl;
            else 
                cout << b << " " << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
int main()
{
    int n;
    int A[101];
    int k = 0, cnt = 0, i, tmp;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    while(k < n)
    {
        for(i = n - 1; i > k; i--)
        {
            if(A[i - 1] > A[i])
            {
                tmp = A[i - 1];
                A[i - 1] = A[i];
                A[i] = tmp;
                cnt++;
            }
        }
        k++;
    }
    for(i = 0; i < n; i++)
    {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2144
def ints():
  return [int(x) for x in input().split()]
def ii():
  return int(input())

import math

N, K = ints()
A = list(sorted(ints()))
F = list(reversed(sorted(ints())))
AF = [A[i]*F[i] for i in range(N)]

afmax = max(AF)

def can(seiseki):
  k = K
  for i in range(N):
    af = AF[i]
    if af>seiseki:
      k -= math.ceil((af-seiseki)/F[i])
      if k<0:
        return False
  return k>=0

l = -1
r = afmax
while r-l>1:
  m = (l+r)//2
  if can(m):
    r = m
  else:
    l = m
print(r)



Measured memory_bytes: 122544
s = list(input())


for i in range(len(s)-1):
	if s[i] == s[i+1]:
		print('{} {}'.format(i+1, i+2))
		break
	if i + 2 != len(s):
		if s[i] == s[i+2]:
			print('{} {}'.format(i+1, i+3))
			break
else:
	print("-1 -1")


Measured memory_bytes: 3956
@@=0..<>;/ (.*) /,$
$`[$1]=$$1[$`]=$'-$<for@M=<>;for$i(@@){//,map$$_[$']-=$-=$$_[$']-$$_[$i]-$$i[$']-$<,@@for@@}print~~grep/ .* /*$
$`[$&]<$'-$<,@M

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    long long a, b; cin >> a >> b;

    for(long long i = a; i >= 2; i--){
        if(a % i == 0){
            if(b % i == 0){
                b /= i;
                i = 2;
            }
        }
    }cout << a * b;
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#include<iomanip>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));

int main(){
	char arr[1010];
	ll k;
	cin>>arr;
	cin>>k;
	ll n=strlen(arr);
	if(k==1){
		cout<<(n-1)*9+arr[0]-'0';
	}
	else if(k==2){
		ll sum=0;
		for(ll i=1;i<n;i++){
			if(arr[i]!='0'){
				sum+=(arr[i]-'0'+9*(n-i-1));
				break;
			}
		}
		sum+=(arr[0]-'1')*9*(n-1);
		for(ll i=1;i<n-1;i++){
			for(ll j=i+1;j<n;j++){
				sum+=9*9;
			}
		}
		cout<<sum<<endl;
	}
	else{
		ll sum=0;
		for(ll i=1;i<n;i++){
			if(arr[i]!='0'){
				for(ll j=i+1;j<n;j++){
					if(arr[j]!='0'){
						sum+=(arr[j]-'0'+9*(n-j-1));
						break;
					}
				}
				sum+=(arr[i]-'1')*9*(n-i-1);
				for(ll j=i+1;j<n-1;j++){
					for(ll z=j+1;z<n;z++){
						sum+=9*9;
					}
				}
				break;
			}
		}
		for(ll i=1;i<n-1;i++){
			for(ll j=i+1;j<n;j++){
				sum+=(arr[0]-'1')*9*9;
			}
		}
		for(ll i=1;i<n-2;i++){
			for(ll j=i+1;j<n-1;j++){
				for(ll z=j+1;z<n;z++){
					sum+=9*9*9;
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
constexpr int INF = 1'000'000'000;
int h, n;
std::vector<int> dp;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> h >> n;
    dp.resize(h + 1, INF);
    dp[h] = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        std::cin >> a >> b;
        for (int j = h - 1; j >= 0; --j)
            dp[j] = std::min(dp[j], dp[std::min(j + a, h)] + b);
    }
    std::cout << dp[0] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=15;
const int MAXR=2000000;
int f[MAXN]={0,4,-4,1,-1};
int r[MAXN]={1},dp[MAXR];
queue<int>T[10];
int h(int a[]){
	int ret=0;
	for(int i=1;i<=8;i++){
		int cnt=0;
		for(int j=i+1;j<=8;j++)
			if(a[i]>a[j])cnt++;
		ret+=cnt*r[9-i];
	}
	return ret;
}
void Insert(int a[]){
	for(int i=1;i<=8;i++)
		T[i].push(a[i]);
}
void Read(int a[]){
	for(int i=1;i<=8;i++)
		a[i]=T[i].front(),T[i].pop();
}
void Init(){
	for(int i=0;i<=8;i++)
		while(!T[i].empty())
			T[i].pop();
	int a[MAXN]={0,0,1,2,3,4,5,6,7};
	memset(dp,0X3F,sizeof(dp));
	for(int i=1;i<=9;i++)r[i]=r[i-1]*i;
	Insert(a);dp[h(a)]=0;
	while(!T[1].empty()){
		int start;Read(a);
		for(int i=1;i<=8;i++)
			if(!a[i]){
				start=i;
				break;
			}
		int u=dp[h(a)];
		for(int i=1;i<=4;i++){
			int w=f[i]+start;
			if(w>=1&&w<=8&&(w!=5||f[i]!=1)&&(w!=4||f[i]!=-1)){
				swap(a[start],a[w]);
				if(dp[h(a)]>u+1){
					dp[h(a)]=u+1;
					Insert(a);
				}
				swap(a[start],a[w]);
			}
		}
	}
}
int main(){
	Init();int a[MAXN]={0};
	while(~scanf("%d",&a[1])){
		for(int i=2;i<=8;i++)
			scanf("%d",&a[i]);
		printf("%d\n",dp[h(a)]);
	}
}


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


template<class T>
inline void chmin(T& a, T b) {
	if (a > b) {
		a = b;
	}
}

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

	// Nについて、どの金額が適用できるか絞る
	vector<int> costs = {1};
	int x = 6;
	while (x <= N) {
		costs.push_back(x);
		x *= 6;
	}
	x = 9;
	while (x <= N) {
		costs.push_back(x);
		x *= 9;
	}

	// 初期化
	const int INF = 1 << 30;
	vector<int> dp(N+1, INF);
	dp.at(0) = 0;

	// 更新
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < costs.size(); j++) {
			if (i + costs.at(j) <= N) {
				chmin(dp.at(i + costs.at(j)), dp.at(i) + 1);
			}
		}
	}

	// 出力
	cout << dp.at(N) << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

bool isPrime(int n)
{
    for(int i = 3; i * i <= n; i += 2)
        if(n % i == 0) return false;
    return true;
}

int main()
{
    int n;
    cin >> n;

    if(n != 2){
        if(n % 2 == 0) ++n;
        while(!isPrime(n)) n += 2;
    }

    cout << n;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int X, Y;
    bool ans = true;

    std::cin >> X >> Y;

    for(int i = 0; i <= X && ans; i++) {
        int tatle = 2 * i, bard = 4 * (X - i);

        if(tatle + bard == Y) {
            ans = false;
        }
    }

    if(ans) {
        std::cout << "No" << std::endl;
    }
    else {
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3584
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;
ll n  , m  , visited[maxN] , dp[maxN];
vector<ll>adj[maxN];
void dfs(ll u){
	visited[u]=1; 
	dp[u]=0;
	for(auto v: adj[u]){
		if(!visited[v])
			dfs(v);
		dp[u]=max(dp[u] , 1+dp[v]);
	}

}
void solve(){
	ll ans=0;
	cin>> n >> m ;
	for(ll i=0 , u , v ; i<m ; i++){
		cin>>u >> v ;
		adj[u].pb(v);
	}
	for(ll i=1;i<=n ;i++){
		if(!visited[i]){
			dfs(i);
		}
	}
	
	for(ll i=1;i<=n ;i++){
		ans=max(ans , dp[i]);
	}
	cout<<ans<<endl;
}
int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 15644
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,p,c=0,a,ans;
	cin>>n>>p;
	rep(i,n){
		cin>>a;
		c=(c||((a%2)?1:0));
	}
	if(c==0)ans=(p==0)?pow(2,n):0;
	else ans=pow(2,n-1);
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll L, R, d;
    cin >> L >> R >> d;

    int n = R/d;
    int cnt = 0;
    rep (i, n) {
        int b = (i+1)*d;
        if (b >= L) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3636
n = int(input())
b = []
a = input().split()
if n % 2 == 0:
    m = n // 2
    for i in range(m):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i])
else:
    m = n // 2
    for i in range(m+1):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i+1])
s = ""
for k in b:
    s += k + " "
print(s)


Measured memory_bytes: 25544
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	int n;
  	vector<int> v;
  	cin >> n;
  	for(int i = 0; i < n; i++){
	  int x;
	  cin >> x;
	  v.push_back(x);	
    }
    vector<int> copy = v;
    sort(all(copy));
    int ret = copy[n - 2];
    auto val =  *max_element(all(v));
    for(int i = 0; i < n; i++){
	   if (v[i] == val) cout << ret << endl;
	   else cout << val << endl;
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 4848