akhauriyash/Code-Regression huggingface dataset:
/**
	Language: C++
	Author  : 21
**/

#include <bits/stdc++.h>

using namespace std;

#define FastIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define Debug(v) cerr << '\n' << #v << ":\t" << v << '\n'

typedef long double ld;
typedef long long ll;

int main() {
	FastIO();
	int x;
	cin >> x;
	int ul = sqrt(x);
	int A = 0, B = 0;
	bool f = false;
	for (int d = 1, e; d <= ul; ++d) {
		if (x % d == 0) {
			for (int a = 1000, b; a >= 0; --a) {
				b = a - d;
				if (ll(powl(a, 5) - powl(b, 5)) == ll(x)) {
					A = a;
					B = b;
					f = true;
					break;
				}
			}
			if (f) break;
			if (d != (e = x/d)) {
				for (int a = 1000, b; a >= 0; --a) {
				b = a - e;
				if (ll(powl(a, 5) - powl(b, 5)) == ll(x)) {
					A = a;
					B = b;
					f = true;
					break;
				}
			}
			}
		}
		if (f) break;
	}
	cout << A << ' ' << B;
	cout << '\n';
	return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	ll h,w;
	cin>>h>>w;
	char arr[h+2][w+2];
	for(int i=0;i<h+2;i++)
		for(int j=0;j<w+2;j++)
			arr[i][j]='#';
	for(int i=1;i<h+1;i++)
		for(int j=1;j<w+1;j++)
			cin>>arr[i][j];
	for(int i=0;i<h+2;i++)
	{
		for(int j=0;j<w+2;j++)
			cout<<arr[i][j];
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    cout<<fixed<<setprecision(10);
    int n, k;
    cin>>n>>k;

    vector<int> p(n);
    for(auto& it : p) cin>>it;

    vector<ld> pref(n+1);
    pref[0] = 0;
    pref[1] = (p[0]+1)/2.0;
    for(int i = 2; i<=n; ++i)
    {
        pref[i] = pref[i-1]+(p[i-1]+1)/2.0;
    }

    ld ans = -1;
    for(int i = 0; i<=n-k; ++i)
    {
        ans = max(ans, pref[i+k]-pref[i]);
    }
    cout<<ans<<endl;
}


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

int main(){
    long double A,B,H,M,angle,rad,ans;
    long double pi = 3.141592653589793;
    cin >> A >> B >> H >> M;
    angle = abs(030.0 * H - 5.5 * M);
    rad = pi * (angle / 180.0); 
    ans = A * A + B * B - 2.0 * A * B * cos(rad);
    ans = sqrt(ans);
    cout << setprecision(11)<< ans << endl;
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    long long mod = 998244353;
    long long dp[n + 2], pref[n + 2];
    dp[0] = 0, dp[1] = 1;
    pref[0] = 0, pref[1] = 1;
    vector<int>l(k + 2), r(k + 2);
    for(int i = 1; i <= k; i++){
        cin >> l[i] >> r[i];
    }
    for(int i = 2; i <= n; i++){
        dp[i] = 0;
        for(int j = 1; j <= k; j++){
            if(i >= l[j]){
                dp[i] = (dp[i] + pref[i - l[j]]) % mod;
            }
            if(i > r[j]){
                dp[i] = (dp[i] - pref[i - r[j] - 1] + mod) % mod;
            }
        }
        pref[i] = (pref[i - 1] + dp[i]) % mod;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 6728
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;


int main(){
	int n;
	double x[3];
	double y[3];
	double p, q, r;

	cin >> n;
	while (n--){
		for (int i = 0; i < 3; i++) cin >> x[i] >> y[i];

		double a = y[0] - y[2];
		double b = y[0] - y[1];
		double c = x[0] - x[2];
		double d = x[0] - x[1];
		double e = pow(y[0], 2) - pow(y[1], 2) + pow(x[0], 2) - pow(x[1], 2);
		double f = pow(y[0], 2) - pow(y[2], 2) + pow(x[0], 2) - pow(x[2], 2);

		p = ((a*e) - (b*f)) / (2 * a*d - 2 * b*c);
		q = ((c*e) - (d*f)) / (2 * c*b - 2 * d*a);
		r = sqrt(pow(p - x[0], 2) + pow(q - y[0], 2));

		printf("%.3lf %.3lf %.3lf\n", p, q, r);
	}

	return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

void check(ll x) { assert(x >= 0); assert(x <= (ll)1e9); }

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll s;
    cin >> s;
    cout << 0 << " " << 0 << " ";

    ll l = 1;
    ll r = (ll)2e9;
    while (l + 1 < r) {
        ll mid = (l + r) / 2;
        ll a = mid / 2;
        ll b = mid - a;
        if (a * b >= s) {
            r = mid;
        } else {
            l = mid;
        }
    }
    ll a = r / 2;
    ll b = r - a;
    ll c = a * b - s;


    cout << a << " " << 1 << " " << c << " " << b;
    cout << endl;

    check(a);
    check(b);
    check(c);
    assert(abs(a * b - 1 * c) == s);

    return 0;
}


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

int main(void)
{
    int H,W;
    while(true)
    {
        cin >> H >> W;
        if(H == 0 && W == 0)break;
        for(int i = 0 ; i < H ; i++)
        {
            if(i == 0 || i == H-1)
            {
                for(int j = 0 ; j < W ; j++)cout << "#";
                cout << endl;
            }
            else
            {
                cout << "#";
                for(int j = 0 ; j < W -2 ; j++)cout << ".";
                cout << "#" << endl;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import collections
from functools import lru_cache


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    arr.sort()
    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = arr[i], arr[j], arr[k]

                if len(set([a, b, c])) == 3 and a+b > c:
                    ans += 1

    return ans


N = readInt()
arr = readList()

print(solve(N, arr))


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s;
int ans,val;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='I'){val++;}
        else val--;
        ans = max(ans,val);
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
   
typedef struct point{
  double x;
  double y;
} point;
   
double distance(point p1,point p2){
  double temp;
  temp=(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
  return sqrt(temp);
}
   
int main(void){
  point p1,p2;
  double d;
   
  scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
  d=distance(p1,p2);
  printf("%.5f\n",d);
   
  return 0;
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll x,a;cin>>x>>a;
	if(x<a) cout<<0<<endl;
	else cout<<10<<endl;











	
}

Measured memory_bytes: 764
N, A, B, C, D = map(int, input().split())
S = input()
change = S[max(A,B)-2:min(C,D)+1]
S = S[min(A,B)-1:max(C,D)]

if S.count('##') > 0:
    print('No')
else:
    if change.count('...') > 0:
        print('Yes')
    elif C < D:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}

$A = $data[0][0];
$B = $data[0][1];
$C = $data[0][2];
$K = $data[0][3];

$ans = 0;

if ($A < $K) {
    $ans += $A * 1;
    $K -= $A;
} else {
    $ans += $K * 1;
    $K -= $K;
}

if ($B < $K) {
    $ans += $B * 0;
    $K -= $B;
} else {
    $ans += $K * 0;
    $K -= $K;
}

if ($C < $K) {
    $ans += $C * -1;
    $K -= $C;
} else {
    $ans += $K * -1;
    $K -= $K;
}

printf('%d', $ans);



Measured memory_bytes: 16240
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int a, b;
    cin>>a>>b;
    int c = a + b;
    if(c%2==0){
        cout<<c/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }








    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int dp[100001];
bool recStack[100001];
int maxPath(vector<int>G[],int N,int src)
{
    if(dp[src]!=-1)
    return dp[src]+1;
    int curr_max=0;
    recStack[src]=1;
 for(int v:G[src])
 {
     if(!recStack[v])
      {
      curr_max=max(curr_max,maxPath(G,N,v));
      }
 }
 recStack[src]=0;
 dp[src]=curr_max;
 return curr_max+1;
}

int main() {
    int N,E,u,v,i;
    cin>>N>>E;
    vector<int>G[N+1];
    while(E--)
    {
        cin>>u>>v;
        G[u].pb(v);
    }
    memset(dp,-1,sizeof(dp));
    memset(recStack,0,sizeof(recStack));
        
        
     int mx=INT_MIN,cnt;
   
   for(i=1;i<=N;i++)
   {
       if(dp[i]==-1)
       maxPath(G,N,i);
   }
   
   for(i=1;i<=N;i++)
    {
 //   cout<<dp[i]<<" ";
    mx=max(mx,dp[i]);
       
    }
    
  cout<<mx;
	return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    cout << fixed << setprecision(10) << (double)(n - n / 2) / (double)n;

    return 0;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=c-a;
    int y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int k, t, tmp;
    vector<int> a;
    cin >> k >> t;

    rep(i, t){
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(all(a));

    int res = a[a.size()-1] - 1 - (k - a[a.size()-1]);

    cout << max(res, 0) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String a = scan.next();
        String b = scan.next();
        String cnt;
        
        if( a.charAt(0) == 'H' && b.charAt(0) == 'D' )cnt = "D";
        else if( a.charAt(0) == 'D' && b.charAt(0) == 'H' )cnt = "D";
        else cnt = "H";
        
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 20948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC174D
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var N = RI();
            char[] ca = Console.ReadLine().ToArray();

            int nProc = 0;

            int wi = -1;
            int ri = N;
            while (true)
            {
                wi++;
                if (wi == ri)
                {
                    goto LOOP;
                }
                while (ca[wi] == 'R')
                {
                    wi++;
                    if (wi == ri)
                    {
                        goto LOOP;
                    }
                }

                ri--;
                if (wi == ri)
                {
                    goto LOOP;
                }
                while (ca[ri] == 'W')
                {
                    ri--;
                    if (wi == ri)
                    {
                        goto LOOP;
                    }
                }


                ++nProc;
            }
            LOOP:
            Console.WriteLine(nProc);

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 29564
#include<iostream>
#include<cstdio>

using namespace std;

const int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
long long b,a,h,w,ans;
char str[401][401];
bool vis[401][401];

void dfs(int x,int y){
	vis[x][y]=true;
	if(str[x][y]=='#')++b;else ++a;
	for(int i=0;i<4;++i){
		int xx=x+dir[i][0],yy=y+dir[i][1];
		if(xx>0&&yy>0&&xx<=h&&yy<=w&&!vis[xx][yy]&&str[xx][yy]!=str[x][y])dfs(xx,yy);
	}
}

int main(){
	scanf("%lld%lld",&h,&w);
	for(int i=1;i<=h;++i)scanf("%s",str[i]+1);
	for(int i=1;i<=h;++i)for(int j=1;j<=w;++j)if(!vis[i][j])b=a=0,dfs(i,j),ans+=b*a;
	printf("%lld",ans);
}

Measured memory_bytes: 8064
def solve(string):
    n, s = string.split()
    num_e = s.count("E")
    count_e = 0
    count_w = 0
    ans = int(n)
    for _s in s:
        tmp = count_w
        if _s == "E":
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

int main()
{
    string S = "";
    string T = "";

    cin >> S;
    cin >> T;

    vector<string> result;
    //find T
    for (int i = 0; i < S.size() - T.size() + 1; i++)
    {
        bool ok = true;
        for (int j = 0;ok && j < T.size(); j++)
        {
            if (S[i + j] != '?' && S[i + j] != T[j])
                ok = false;
        }
        if (ok)
        {
            string temp = "";
            for (int j = 0; j < S.size(); j++)
            {
                if (i <= j && j < i + T.size())
                {
                    temp += T[j - i];
                }
                else
                {
                    if (S[j] == '?')
                    {
                        temp += 'a';
                    }
                    else
                    {
                        temp += S[j];
                    }
                }
            }
            result.push_back(temp);
        }
    }
    if (result.size() == 0)
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        sort(result.begin(), result.end());
        cout << result[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,a,s=0,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<m;i++)s+=N[hout()];
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 1716
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

M, D = map(int, input().split())
ans = 0
for i in range(1, M+1):
    for j in range(2, D+1):
        s, t = j//10, j%10
        if s >= 2 and t >= 2 and i == s * t:
            ans += 1
print(ans)

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a , b ;
    cin >> a >> b ;

    if ( a > b )
        swap ( a , b ) ;

    while ( b -- )
        cout << a ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N, K; cin >> N >> K;
    string S; cin >> S;

    // 塊ごとに個数を保存する
    vector<int> T;
    // 幸せな人の数
    int ans = 0;

    // 今の属性を保存する
    char ns = S[0];
    int th = 0;
    for (int i = 1; i < N; ++i) {
        if (S[i] == ns) {
            // nsと一緒なら
            th += 1;
            ans += 1;
        } else {
            // nsと違うなら
            T.push_back(th);
            ns = S[i];
            th = 0;
        }
    }
    T.push_back(th);

    // cout << ans << endl;

    // rep(i, T.size()) cout << T[i] << " ";
    // cout << endl;
    // 始めの塊の数
    int ds = int(T.size());
    // 操作した回数
    int c = 0;
    while (ds > 1 && c < K) {
        if (ds == 2) {
            ds -= 1;
            ans += 1;
            c += 1;
        } else {
            ds -= 2;
            ans += 2;
            c += 1;
        }
    }
    cout << ans << endl;

    return 0;
}

/* 
6 1
RRRRRR
*/

Measured memory_bytes: 1020
#include <bits/stdc++.h> 
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}

const int mod = 1000000007;
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}


int main() {
    int n,d,x;
    cin >> n;
    cin >> d >> x;   
    vector <int> a(n+1);
    rep(i,1,n+1) {
        cin >> a[i];
    }
    int sum =0;
    rep (i,1,n+1) {
        for(int j =0; j <d;j += a[i]) {
            sum += 1;
        }
    }
    cout << sum + x << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <math.h>
using namespace std;
struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define ff first
#define ss second 
#define pp pair
#define ULRED 1000000007
#define MS(x,y) (x-y>0?x-y:y-x) 
#define MX(x,y) x>y?x:y
#define MN(x,y) x>y?y:x
#define MXPTR2(a,b,x,y) (x>y?a:b)
#define MXPTR3(a,b,c,x,y,z) (x>y?(x>z?a:c):(y>z?b:c))
#define MX3(a,b,c) (a>b?(a>c?a:c):(b>c?b:c))
#define AEQ(a,b,c) (a==b?1:(a==c?3:(c==b?2:-1)))
/*------------------------------------------------------------------*/

int main()
{
	FAST_IO
	ll n, w;
	cin >> n >> w;
	vector<vector<ll>>  dp(n + 1, vector<ll>(w + 1, 0));
	vector<ll> wt(n + 1, 0);
	vector<ll> val(n + 1, 0);
	for (ll i = 1; i < n + 1; i++)
	{
		cin >> wt[i] >> val[i];
	}
	for (ll i = 1; i < n + 1; i++)
	{
		for (ll j =1; j < w + 1; j++)
		{
			if (j < wt[i])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(val[i] + dp[i - 1][j - wt[i]], dp[i - 1][j]);
		}
	}
	/*
	for (ll i = 1; i < n + 1; i++)
	{
		for (ll j =1; j < w + 1; j++)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/

	cout << dp[n][w] << endl;
	return 0;

}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > s(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            x--;
            s[i].push_back(x);
        }
    }

    vector<int> p(m);
    for (int i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        int hoge = 0;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int k : s[j]) {
                cnt += ((i & (1 << k)) > 0);
            }
            hoge += (cnt % 2 == p[j]);
        }
        ans += (hoge == m);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

const ll mod = 998244353, p18 = (ll) 1e18 % mod;
const int mg = 1 << 9;
int n, m, g[100100];
ll p[100100], r[mg];
vector<int> e[100100];

void solve() {
  cin >> m;
  for (int i = 0; i < n; i++)
    e[i].clear();
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b, a--, b--;
    if (a > b)
      swap(a, b);
    e[a].push_back(b);
  }
  ll s[mg], nr[mg];
  for (int i = 0; i < mg; i++)
    s[i] = nr[i] = 0;
  for (int i = n - 1; i >= 0; i--) {
    sort(e[i].begin(), e[i].end(), [&](int a, int b){return g[a] < g[b];});
    reverse(e[i].begin(), e[i].end());
    g[i] = 0;
    while (!e[i].empty() && g[e[i].back()] == g[i]) {
      g[i]++;
      while (!e[i].empty() && g[e[i].back()] < g[i])
        e[i].pop_back();
    }
    s[g[i]] += p[i + 1];
  }
  for (int i = 0; i < mg; i++)
    s[i] %= mod;
  for (int i = 0; i < mg; i++)
    for (int j = 0; j < mg; j++)
      nr[i ^ j] = (nr[i ^ j] + s[i] * r[j]) % mod;
  for (int i = 0; i < mg; i++)
    r[i] = nr[i];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  p[0] = 1;
  for (int i = 1; i <= n; i++)
    p[i] = (p[i - 1] * p18) % mod;
  r[0] = 1;
  solve();
  solve();
  solve();
  cout << r[0] << "\n";
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int z,i;
    cin>>z;
    for(i=1;i<=9;i++)
    {
        if(z%i==0&&(z/i)<=9)
        {
            cout<<"Yes";
            return 0;
        }
    }cout<<"No";
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




Measured memory_bytes: 256
from collections import deque
from collections import defaultdict
from copy import copy
N = int(input())
XY = list(sorted([tuple(map(int, input().split())) for _ in range(N)]))
PQ = []
for i in range(N-1):
    for j in range(i, N):
        PQ.append((XY[j][0]-XY[i][0], XY[j][1]-XY[i][1]))
PQ = list(set(PQ))
ans = N
for p, q in PQ:
    tmp1 = 1
    T = deque(copy(XY))
    x, y = T.popleft()
    cnt = 1
    while cnt < N:
        tmp2 = 1
        for s, t in T:
            if s - p == x and t - q == y:
                tmp2 = 0
                break
        if tmp2:
            x, y = T.popleft()
        else:
            T.remove((s, t))
            x, y = s, t
        tmp1 += tmp2
        cnt += 1      
    ans = min(ans, tmp1)
print(ans)


        


    


Measured memory_bytes: 42864
#                               #
    # author : samars_diary #
    # 18-09-2020 │ 18:46:42 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=lii()
    print(1+a.index(0))

for _ in range(1):
    solve()

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

int main(void) {
    int n; cin >> n;
    bool flag = false;
    vector<int> renga(n);
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        renga[i] = a;
        if(a==1) flag = true;
    }
    if(!flag) {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 1;
    int barst = 0;
    for(int i = 0; i < n; ++i) {
        if(renga[i] == cnt) {
            cnt++; 
        }else{
            barst++;
        }
    }

    cout << barst << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int x,t;
  string s;
  cin >> x >> t;
  if ( t < x) cout << x-t << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, a, b);
    Cout((n-a+1)*(n-b+1));
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp62 {
    class Program {
        static int len;

        static void Main(string[] args) {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            len = S.Length;

            string doubleString = S + S;

            if (doubleString.IndexOf(T) >= 0) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }



        }

    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	ll asum=0, bsum = 0;
	vector<ll>a(N), b(N);
	for (int i = 0; i < N; ++i)cin >> a[i], asum += a[i];
	for (int i = 0; i < N; ++i)cin >> b[i], bsum += b[i];
	if (asum < bsum) {
		cout << -1 << endl;
	}
	else {
		vector<ll>plus;
		ll sum = 0;
		int num = 0;
		for (int i = 0; i < N; ++i) {
			ll dif = a[i] - b[i];
			if (dif < 0)sum -= dif, num++;
			else plus.push_back(dif);
		}
		if (num == 0)cout << 0 << endl;
		else {
			sort(plus.begin(), plus.end(), greater<ll>());
			int p = 0;
			while (!sum <= 0) {
				sum -= plus[p];
				++num;
				++p;
				if (sum <= 0)break;
			}
			cout << num << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2936
import java.util.Random;
import java.util.Scanner;

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

        String str = scanner.nextLine();

        for (int i = 0; i < str.length(); ++i) {
            char c = str.charAt(i);
            //もし小文字ならば
            if (c >= 'A' && c <= 'Z') {
                System.out.print((char)(c - ('A' - 'a')));
            //もし大文字ならば
            } else if (c >= 'a' && c <= 'z') {
                System.out.print((char)(c - ('a' - 'A')));
            } else {
                System.out.print(c);
            }
        }
        System.out.println();
    }
}



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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int solve(int D,int G,vi& p,vi& c) {
    int P = 1 << D;
    int best = INT_MAX;
    rep(pat, P){
        int _G = G;
        int bonus = 0, solved = 0;
        vi rest(D, 0);
        for (int b=0,m=1; b<D; ++b,m<<=1) {
            int u = 100 * (b+1);
            if (pat & m) {
                _G -= (u * p[b] + c[b]);
                solved += p[b];
                rest[b] = 0;
            } else {
                rest[b] = p[b];
            }
        }
        if (_G > 0) {
            for (int b=D-1; b>=0; --b) {
                int u = 100 * (b+1);
                int k = min((_G + u-1) / u, rest[b]);
                _G -= u*k;
                solved += k;
                if (_G <= 0) break;
            }
        }
#ifdef DEBUG
        fprintf(stderr, "pat=%d solved=%d\n", pat, solved);
#endif
        best = min(best, solved);
    }
    return best;
}

int main() {
    int D,G; cin >> D >> G;
    vi p(D), c(D);
    rep(i,D) cin >> p[i] >> c[i];
    cout << solve(D,G,p,c) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []c = sc.next().toCharArray();
		
		int k = Integer.parseInt(sc.next());
		
		int n = c.length;
		long dp[][] = new long [n+1][k+1];
		
		//Arrayfill(n,k,dp);
		
		dp[0][0] = 1;
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j <= k ; j++) {
				if(dp[i][j] == 0) {
					continue;
				}
				
				if(j == k) {
					dp[i+1][j] += dp[i][j];
				}
				else if(i == n-1) {
					dp[i+1][j+1] += dp[i][j] * (int)(c[n-i-1] -'0'-1);
				}
				else {
					dp[i+1][j+1] += dp[i][j] * 9;
					dp[i+1][j] += dp[i][j]; 
				}
			}
		}
		
		//DEBUG(n,k,dp);
		long ans = dp[n][k];
		
		long [][][]dp1 = new long [n+1][k+1][2];
		
		dp1[1][1][0] = 1;

		
		for(int i = 1; i < n ; i++) {
			for(int j = 1 ; j <= k ; j++) {
				for(int l = 0 ; l <= 1 ; l++) {
					if(dp1[i][j][l] == 0) {
						continue;
					}
					int p = (int)(c[i] - '0');
					if(j == k) {
						dp1[i+1][j][l] += dp1[i][j][l];
					}
					else if(l == 0) {
						if(p == 0) {
							dp1[i+1][j][0] += dp1[i][j][0];
						}
						else {
						dp1[i+1][j+1][1] += dp1[i][j][0] * (p-1);
						dp1[i+1][j][1] += dp1[i][j][0];
						dp1[i+1][j+1][0] += dp1[i][j][0];
						}
					}
					else {
						dp1[i+1][j+1][1] += dp1[i][j][1] * 9; 
						dp1[i+1][j][1] += dp1[i][j][1];
					}
				}
			}
		}
		
		//System.out.println(dp1[n][k][0] +" "+ dp1[n][k][1]);
		//debug1(n,k,dp1);
		ans += dp1[n][k][0] + dp1[n][k][1];
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
n,m,k=map(int,input().split())
factorials=[]
current=1
for i in range(n):
  factorials.append(current)
  current=((i+1)*current)%998244353
inverselist=[]
for i in range(n):
  inverselist.append(pow(factorials[i],998244351,998244353))
ans=0
for i in range(0,k+1):
  ans=(ans+m*pow(m-1,n-i-1,998244353)*factorials[n-1]*inverselist[i]*inverselist[n-1-i])%998244353
print(ans)

Measured memory_bytes: 86016
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const long long MOD = 1000000007;

ll N;
string C;

signed main(){
    cin >> N >> C;
    ll r = 0, w = 0;
    REP(i, N){
        if(C[i] == 'R') r++;
        else w++;
    }
    ll ans = 0;
    REP(i, r){
        if(C[i] == 'W') ans++;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll psum[300005];
const int INF=1e9+7;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    map<ll,ll>m;
    m[0]++;
    psum[0]=0;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll c;
        cin>>c;
        sum=sum+c-1;
        sum=sum%k;
        if(sum<0) sum+=k;
        psum[i]=sum;
        //cout<<i<<' '<<psum[i]<<'\n';
        m[sum]++;
        if(i>=k) m[psum[i-k]]--;
        ans=ans+m[sum]-1;
        //cout<<ans<<'\n';
    }

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


Measured memory_bytes: 14336
n=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)

ans=a[0]
ch=1

for i in range(1,n):
  if ch==n-1:
    break
  else:
    ans+=a[i]
    ch+=1
    
  if ch==n-1:
    break
  else:
    ans+=a[i]
    ch+=1
    
print(ans)

Measured memory_bytes: 31500
#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;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int dx[4] = {0, 0, 1, -1};
    int dy[4] = {1, -1, 0, 0};
    char a[h][w];
    vector<vector<int> > dist(h, vector<int>(w, -1));
    queue<pair<int, int> > q;
    rep (i, h) {
        rep (j, w) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                q.push(make_pair(i, j));
                dist[i][j] = 0;
            }
        }
    }
    int res = 0;
    while (!q.empty()) {
        int x, y;
        x = q.front().first, y = q.front().second;
        q.pop();
        rep (i, 4) {
            int nx, ny;
            nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y] + 1;
            q.push(make_pair(nx, ny));
            res = max(res, dist[nx][ny]);
        }
    }
    cout << res << endl;
    
    return 0;
}



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

Sum = 0
for i in range(N):
  o = (i+1)//10000
  a = (i+1)%10000//1000
  b = (i+1)%1000//100
  c = (i+1)%100//10
  d = (i+1)%10
  e= o+a+b+c+d
  if e >= A and e <= B:
    Sum = Sum + (i+1)

print(Sum)

Measured memory_bytes: 9132
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	
	int ans = c - a + b;
	if (ans > 0)
	{
		std::cout << ans << std::endl;
	}
	else
	{
		std::cout << 0 << std::endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int G[MAX][MAX],d[MAX],f[MAX],color[MAX],time,n,S[MAX],top;

int next(int x){
  int i;
  for(i=1;i<=n;i++){
	if(G[x][i]==1 && color[i]==WHITE)return i;
  }
  return 0;
}

void push(int x){
  S[top++]=x;
}

int  pop(){
  return S[top--];
}

void visit(int r){
  int i;
  push(r);
  color[r]=GRAY;
  d[r]=++time;

  while(top!=0){
	int u=S[top-1],v;
	v=next(u);
	if(v!=0){
  	if(color[v]==WHITE){
    push(v);
    color[v]=GRAY;
    d[v]=++time;
  	}
	}
	else {
  	pop();
  	color[u]=BLACK;
  	f[u]=++time;
	}
  }
}


void dfs(){
  int i;
  for(i=1;i<=n;i++){
	if(color[i]==WHITE)visit(i);
  }
}


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

  for(i=0;i<n;i++){
	scanf("%d %d",&u,&k);
	for(j=0;j<k;j++){
  	int v;
  	scanf("%d",&v);
  	G[u][v]=1;
	}
  }
  dfs();
  for(i=1;i<=n;i++){
	printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(void){
    char B;
    cin >> B;
    
    if(B == 'a' || B == 'i' || B == 'u' || B == 'e' || B == 'o'){
        
        cout << "vowel" << endl;
        
    }
    
    else{
        
        cout << "consonant" << endl;
        
    }
    
}

Measured memory_bytes: 256
# coding=utf-8

from collections import deque

N, Q = map(int, input().split())
Que = [deque([]) for i in range(N)]

for j in range(Q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        Que[query[1]].append(query[2])
    elif query[0] == 1:
        if Que[query[1]]:
            print(Que[query[1]][0])
    elif query[0] == 2:
        if Que[query[1]]:
            Que[query[1]].popleft()



Measured memory_bytes: 14544