akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int GetColor(int rate)
{
    return min(rate / 400, 8);
}

int main()
{
    int N;
    cin >> N;
    set<int> s;
    int wild = 0;
    int a;
    int color;
    REP(i, N)
    {
        cin >> a;
        color = GetColor(a);
        if (color == 8)
        {
            ++wild;
        }
        else
        {
            s.insert(color);
        }
    }
    int mi = max((int)s.size(), 1);
    int ma = (int)s.size() + wild;
    cout << mi << " " << ma << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(N - K):
        print("Yes" if A[i] < A[i + K] else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 31416
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var sList = Enumerable.Range(0, N).Select(_ => Console.ReadLine()).ToArray();
            var M = int.Parse(Console.ReadLine());
            var tList = Enumerable.Range(0, M).Select(_ => Console.ReadLine()).ToArray();

            var dict = new Dictionary<string, int>();

            foreach (var s in sList)
            {
                if (!dict.ContainsKey(s))
                {
                    dict.Add(s, 0);
                }

                dict[s]++;
            }
            foreach (var t in tList)
            {
                if (!dict.ContainsKey(t))
                {
                    dict.Add(t, 0);
                }

                dict[t]--;
            }

            var output = 0;
            foreach (var d in dict)
            {
                output = Math.Max(output, d.Value);
            }

            Console.WriteLine(output);
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13280
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define endl '\n'
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
long long int gcd(long long int x,long long int  y){
   if(y==0)return x;
   return gcd(y,x%y);
}
long long exp(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = exp(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int prime(long long x){
if(x%2==0)

    return 0;
else{
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)
            return 0;
    }
}
return 1;
}
//main
int main() {
IOS;
ll a,b,c,d,k,l,m,n,o,p,q;
cin>>a>>b>>c>>d;
k=a*c;
l=a*d;
m=b*c;
n=b*d;
o=max(k,l);
p=max(o,m);
q=max(p,n);
cout<<q;
return 0;
}

Measured memory_bytes: 3664
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	max := 0
	highest := make([]int, 0)
	index := make([]int, 0)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		if max < aa[i] {
			highest = append(highest, aa[i])
			index = append(index, i)
			max = aa[i]
		}
	}
	sort.Ints(aa)
	ss := make([]int64, n+1)
	for i := 0; i < n; i++ {
		ss[i+1] = ss[i] + int64(aa[i])
	}
	ans := make([]int64, n)
	prev := 0
	previ := -1
	for i := 0; i < len(highest); i++ {
		l := -1
		r := n
		for l+1 < r {
			m := l + (r-l)>>1
			if aa[m] < highest[i] {
				l = m
				continue
			}
			r = m
		}
		ans[index[i]] += int64(n-r) * int64(highest[i]-prev)
		ans[index[i]] += ss[r] - ss[previ+1] - int64(r-(previ+1))*int64(prev)
		prev = highest[i]
		previ = r
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, ans[i])
	}
}


Measured memory_bytes: 10496
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ans := 0
	a, b, c := 0, 0, 0
	for i := 0; i < n; i++ {
		s := scanString()
		ans += strings.Count(s, "AB")
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			c++
		} else if s[0] == 'B' {
			b++
		} else if s[len(s)-1] == 'A' {
			a++
		}
	}

	ans += max(0, c-1)
	ans += min(a, b)
	if c > 0 && a+b != 0 {
		ans++
	}
	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 1784
#include <stdio.h>
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
const int N=1e5+10;
int main(){
    int n,a[N];
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        int ans=0;
        for(int i=0;i<n;i++)for(int j=0;j<n-1;j++)if(a[j]>a[j+1]){
            swap(a[j],a[j+1]);
            ans++;
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 2748
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    int x[N];
    int max = A;
    for(int i = 0; i < N; i++){
        cin >> x[i];
        if(x[i] > max){
            max = x[i];
        }
    }


    ll dp[N+1][N+1][N*max+1] = {0};

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            for(int k = 0; k <= N*max; k++){
                if(i==0 && j == 0 && k==0){
                    dp[i][j][k] = 1;
                }else if(i > 0 && k < x[i-1]){
                    dp[i][j][k] = dp[i-1][j][k];
                }else if(i > 0 && j > 0 && k >= x[i-1]){
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
                }else{
                    dp[i][j][k] = 0;
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ans += dp[N][i][i*A];
    }

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


    


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int U = 1e5;
  vector<int> cnt(U + 1);
  for (auto &x : a) {
    cnt[x]++;
    if (x > 0) cnt[x-1]++;
    if (x < U) cnt[x+1]++;
  }
  int res = 0;
  for (int i = 0; i < U + 1; i++) res = max(res, cnt[i]);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 1024
import numpy as np

N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

array = []
for _ in range(N):
    row = [int(x) for x in input().split()]
    array.append(row)

A = np.array(array)
print(np.sum(A.dot(B) + C > 0))


Measured memory_bytes: 12544
n,m = map(int,input().split())
l = [0]*m
for i in range(n):
  a = list(map(int,input().split()))
  for i in range(1,a[0]+1):
    l[a[i]-1] += 1
count = 0
for i in l:
  if i == n:
    count += 1
print(count)

Measured memory_bytes: 38256
#include <iostream>

 

using namespace std;

 

int main() 
    {
       int a ,b , i;
       for ( i = 1 ; i <= 3000 ; i++)
       {
           cin  >> a >> b;
           if ( a == 0 && b == 0)
           break;
       
       //swap a & b
       if ( a > b )
      { cout << b << " " << a << endl;
       
          
      }
      else{
        cout << a << " " << b << endl;
      }
    }
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    ll ans = 0;
    ans += 1000*(n/500);
    n%=500;
    ans += (5*(n/5));
    cout << ans;

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define DIM (long long)200007
#define INF (long long)100000007

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

ll n,m,i,j,k,sum,f1,f2,v1,v2,res;
vector<ll> a[DIM];
ll dp[DIM];
ll used[DIM];

ll dfs(ll v){
    used[v]=1;
    dp[v]=1;
    ll nowres=1;
    for(ll to:a[v]){
        if(used[to]==1) {
            nowres=max(nowres,dp[to]+1);
            continue;
        }
        nowres=max(nowres,dfs(to)+1);
    }
    dp[v]=nowres;
    return dp[v];
}

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

    cin >> n >> m;
    for(i=1; i<=m; i++){
        cin >> v1 >> v2;
        a[v1].push_back(v2);
    }

    for(i=1; i<=n; i++){
        if(used[i]==0){
            res=max(dfs(i),res);
        }
    }
    cout << res-1 << endl;



    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;




int main(){
    int64_t x;
    cin>>x;
    for(int64_t a=-200;a<200;a++){
        for(int64_t b=-200;b<200;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<' '<<b;
                return 0;
            }
        }
    }

    
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;

int main()
{
	int a[10];
	for (int i = 0; i < 6; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < 5; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (a[j] - a[i] > a[5])
			{
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
	return 0;
}


Measured memory_bytes: 256
def read():
    return int(input())

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

n = read()
a = reads()
ans = a[0]
for i in range(n):
    ans = gcd(ans,a[i])
print(ans)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	ll ans=0;
	queue<ll>q;
	rep(i,n){
		if(a[i]%2){
			ans+=a[i]/2;
			a[i]=1;
		}
		else{
			ans+=max(0LL,a[i]/2-1);
			if(a[i]>=2)a[i]=2;
		}
		rep(j,a[i])q.emplace(i+1);
	}
	while(q.size()>1){
		int x=q.front();
		q.pop();
		int y=q.front();
		if(abs(y-x)<=1){
			++ans;
			q.pop();
		}
	}
	cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    ll S,W;
    cin >> S >> W;
    if(W >= S){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }

}

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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,k,i,a;
    string s;
    t = 1;
    while(t--) {
     a = 0;
	 cin >> n >> k >> s;
	 for(i = 0; i < n - 1; i++) {
	  if(s[i] == s[i + 1])
	   a++;
	 }
	 cout << min(n - 1, a + 2 * k) << endl;
    }
    return 0;
}



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

using namespace std;

ll n,k,a[111],md=1e9+7;
ll dp[111][100005];
ll pre[111][100005];

int main(){
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }

    dp[0][0]=1;
    for(ll i=0;i<=k;i++){
        pre[0][i]=1;
    }

    for(ll i=1;i<=n;i++){
        ll sum=0;
        for(ll j=0;j<=a[i];j++){
            dp[i][j]=pre[i-1][j];
            sum=(sum+dp[i][j])%md;
            pre[i][j]=sum;
        }
        for(ll j=a[i]+1;j<=k;j++){
            dp[i][j]=(2*md+pre[i-1][j]-pre[i-1][j-a[i]-1])%md;
            sum=(sum+dp[i][j])%md;
            pre[i][j]=sum;
        }
    }
    cout<<dp[n][k];
    return 0;
}


Measured memory_bytes: 160000
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

bool can(const string &k, const string &S)
{
	int offset = 0;
	for (auto c : k) {
		auto pos = S.find(c, offset);
		if (pos == string::npos) {
			return false;
		}
		offset = pos + 1;
	}
	return true;
}

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

	int ans = 0;

	for (int x = 0; x < 1000; ++x) {
		ostringstream oss;
		oss << setw(3) << setfill('0') << x;
		if (can(oss.str(), S)) {
			++ans;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        char[] S = scanner.next().toCharArray();

        for (int i = 0 ; i < S.length ; i++) {
            if ((i + 1) % 2 == 1) {
                if (S[i] == 'L') {
                    System.out.println("No");
                    return;
                }
            } else {
                if (S[i] == 'R') {
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 35632
#include<stdio.h>


int main(void)
{
	int i;
	double a,s;
	while(scanf("%lf",&a)!=EOF){
		s=a;
		for(i=2;i<11;i++){
			if(i % 2==0){
				a*=2;
				s+=a;
			}
			else { 
				a/=3;
				s+=a;
			}
		}
		printf("%lf\n",s);
	}
	return 0;
}

Measured memory_bytes: 1076
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >>c;

  if((b-a) == (c-b)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,X,Y;
	scan(N>>X>>Y);
	int dis[200001]={},rui[200001]={};
	rep(i,(Y-X+1)/2+1){
		if(i==0||i*2==Y-X+1){
			dis[i]=1;
		}
		else dis[i]=2;
	}
	rep(i,N){
		rui[i+1]=rui[i]+dis[i];
	}
	rep1(k,N-1){
		int ans=0;
		ans+=max(0,X-k-1)+max(0,N-Y-k);
		ans+=max(0,min({k-2,min(X+1,N-Y+2)-2,-k+N-(Y-X)+1}));
		debug(k);
		debug(max(0,X-k-1),max(0,N-Y-k));
		debug(max(0,min({k-2,min(X+1,N-Y+2)-2,-k+N-(Y-X)+1})));
		if(k<=(Y-X+1)/2){
			if(2*k==Y-X+1) ans+=(Y-X+1)/2;
			else ans+=Y-X+1;
		}
		ans+=rui[k]-rui[max(0,k-X+1)]+rui[k]-rui[max(0,k-N+Y)];
		debug(rui[k]-rui[max(0,k-X+1)]+rui[k]-rui[max(0,k-N+Y)]);
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 5164
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    int[] A=new int[N];
	    int w=1;
	    for (int i=0; i<N; i++) {
	    	A[i]=gi();
	    	if(A[i]%2==0) {
	    		w*=2;
	    	}
	    }

	    long a=(long)Math.pow(3, N)-w;
        System.out.println(a);
//	    if(max>s-max) {
//	    	System.out.println(s-max-1);
//	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define int long long

using namespace std;

const int N = 2e5 + 10;

int h[N];

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 1; i <= n; ++i) 
    {
        cin >> h[i];
        ++m[i - h[i]];
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        ans += m[i + h[i]];
    }
    cout << ans;
    return 0;
}


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

int main(){
	long N,K;
	cin >> N >> K;
	unsigned long long x=(N/K)*(N/K)*(N/K);
	if(K%2==0){
		x+=(2*N/K-N/K)*(2*N/K-N/K)*(2*N/K-N/K);
	}
	cout << x << endl;
}


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

    vector<int> d(N);

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

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

    int idxMax = d[N/2];
    int idxMin = d[N/2-1];

    cout << idxMax- idxMin << endl;
 
    return 0;
 
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long a, b, c;
    cin >> a >> b >> c;
    bool z = false;
    for(int i = 1; i <= b; i++){
        if((a*i)%b == c){
            z = true;
            break;
        }
    }
    if(z) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    N,K,C = map(int,input().split())
    S=input()

    dpt1=[0]*K
    dpt2=[0]*K
    pnt = 0
    for i in range(K):
        while S[pnt]=="x":
            pnt+=1
        dpt1[i]=pnt
        pnt += C+1

    pnt = N-1
    for i in range(K-1,-1,-1):
        while S[pnt] == "x":
            pnt -=1
        dpt2[i]=pnt
        pnt-=C+1

    for a,b in zip(dpt1,dpt2):
        if a == b:
            print(a+1)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 20516
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[[t,f,r,l,b,u]]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d,n):
        self.a[n]=[self.a[n][i] for i in self.direction[d]]
n=int(input())
for i in range(n):
    if i==0:
        t, f, r, l, b, u = map(int, input().split())
        dice = Dice(t, f, r, l, b, u)
    else:
        a = list(map(int, input().split()))
        dice.a.append(a)
s='SSSWEEE'
w='YYYY'
try:
    for u in range(n - 1):
        for t in range(u + 1, n):
            for j in s:
                for r in w:
                    if dice.a[t] == dice.a[u]:
                        raise Exception
                    dice.roll(r, t)
                dice.roll(j, t)
    else:
        print('Yes')
except Exception:
    print('No')


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

int main(){
	int s;
  	int cter = 0;
  	set<int> st;
  	cin >> s;
  	
 	while(1){
      	auto b = st.insert(s);
      	cter++;
      	if(b.second == false) break;
      	if(s%2 == 0) s = s/2;
      	else s = 3*s + 1;
    }
  	cout << cter << "\n";
	return 0;
}

Measured memory_bytes: 256
s = input()
ans = "Yes"

for i in range(len(s)):
    if (i+1) % 2 == 0 and s[i] in ["L", "U", "D"]:
        pass
    elif (i+1) % 2 != 0 and s[i] in ["R", "U", "D"]:
        pass
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 3060
get = input().split()
N = int(get[0])
K = int(get[1])
st = input()
S =[]
ans = ""
for i in range(N):
    S.append(st[i])
if S[K - 1].isupper():
    S[K - 1] = S[K - 1].lower()
else:
    S[K - 1] = S[K - 1].upper()
for i in range(N):
    ans += S[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define lol long long
template<class A,class B>inline bool chmax(A &a,const B &b){return(b>a&&(a=b,true));}
template<class A,class B>inline bool chmin(A &a,const B &b){return(b<a&&(a=b,true));}
using namespace std;
lol mod=1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >>n;
  int ans=0;
  vector<int> x(n),y(n);
  for(auto&&e:x) cin >>e;
  for(auto&&e:y) cin >>e;
  while(n--){
    if(x[n]-y[n]>0) ans+=x[n]-y[n];
  }
  cout <<ans<<'\n';
  return (0);
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

const int MAX = 101;
int X[MAX][MAX]; //??????????¨????
int used[MAX][MAX]; //????????????????????????????????????
int ans = 0;

int H, W;
void input()
{
	cin >> H >> W;
	if (H == 0 && W == 0) return;
	for (int i = 0; i < H; i++) {
		string ch;
		cin >> ch;
		for (int j = 0; j < W; j++) {
			//char ch;
			//scanf("%c", &ch);
			if (ch[j] == '@') //????????´
				X[i][j] = 1;
			if (ch[j] == '#') //??????
				X[i][j] = 2;
			if (ch[j] == '*') //?????????
				X[i][j] = 3;
		}
	}
	memset(used, 0, sizeof(used));
	ans = 0;
}

void dfs(int i, int j) //
{
	used[i][j] = ans + 1;  //test
	int same = X[i][j];
	//?????????
	if (j - 1 >= 0 && !used[i][j - 1] && X[i][j - 1] == same)
		dfs(i, j - 1);
	//?????????
	if (i - 1 >= 0 && !used[i - 1][j] && X[i - 1][j] == same)
		dfs(i - 1, j);
	//???
	if (!used[i][j + 1] && X[i][j + 1] == same)
		dfs(i, j + 1);
	//???
	if (!used[i + 1][j] && X[i + 1][j] == same)
		dfs(i + 1, j);
	return;
}

void solve()
{
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (!used[i][j]) {
				dfs(i, j);
				ans++;
			}
		}
	}

	cout << ans << endl;
}

int main()
{
	while (1) {
		input();
		if (H == 0 && W == 0) break;
		solve();
	}
	return 0;
}

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

const int maxn = 5050, INF = 1e9 + 10;
int pos[2][maxn], BIT[maxn], dp[maxn][maxn], n;

void Update(int idx, int val)
{
    for(int i = idx; i < maxn; i += i & -i)
        BIT[i] += val;
}

int Query(int idx)
{
    int ret = 0;
    for(int i = idx; i > 0; i -= i & -i)
        ret += BIT[i];
    return ret;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n; i++) {
        char c;
        int a;
        scanf(" %c %d", &c, &a);
        pos[c == 'B'][a] = i;
	}

	fill((int *) dp, (int *) dp + maxn * maxn, INF);

	dp[0][0] = 0;
	for(int i = 0; i <= n; i ++){
        for(int j = 0; j <= n; j ++){
            if(i + 1 <= n){
                int add = pos[0][i + 1] - 1 - Query(pos[0][i + 1]);
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + add);
            }
            if(j + 1 <= n){
                int add = pos[1][j + 1] - 1 - Query(pos[1][j + 1]);
                dp[i][j + 1]= min(dp[i][j + 1], dp[i][j] + add);
                Update(pos[1][j + 1], 1);
            }
        }
        for(int j = 1; j <= n; j ++)
            Update(pos[1][j], -1);
        if(i + 1 <= n)
            Update(pos[0][i + 1], 1);
	}

	printf("%d\n", dp[n][n]);
	return 0;
}


Measured memory_bytes: 99840
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s.size()==1)
	{
		cout<<"0\n";
		return 0;
	}
	int fans=10000,ans=0;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			ans++;
		}
	}
	ans++;
	if(ans==s.size())
	{
		cout<<"0\n";
		return 0;
	}
	for(char c='a';c<='z';c++)
	{
		string w=s;
		bool flag=false;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]==c)
			{
				flag=true;
				break;
			}
		}
		if(!flag)
		{
			continue;
		}
		int op=0;
		while(1)
		{
			string ww;
			int len=w.size();
			int cnt=0;
			op++;
			for(int i=0;i<len-1;i++)
			{
				if(w[i]==c||w[i+1]==c)
				{
					ww.insert(ww.end(),c);
					cnt++;
				}
				else
				{
					ww.insert(ww.end(),w[i]);
				}
			}
			if(cnt==ww.size())
			{
				fans=min(fans,op);
				break;
			}
			w=ww;
		}
	}
	cout<<fans<<"\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<30)

int H, A[MAX+1];

void maxHeapify(int i)
{
  int temp,largest,l,r;

  l = 2*i;
  r = 2*i+1;

  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;

  if( largest != i )// i の子の方が値が大きい場合
  {
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest); // 再帰的に呼び出し
  }
}

int extract()
{
  int maxv;
  if ( H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key)
{
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] )
  {
    swap (A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key)
{
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main()
{
  int key;
  char com[10];
  while ( 1 )
  {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n') break;
    if ( com[0] == 'i')
    {
      scanf("%d", &key);
      insert(key);
    }
    else
    {
      printf("%d\n", extract());
    }
  }
  return 0;
}



Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#define maxn 307
#define maxx 20007
#define SDOI2020 RP++ 
using namespace std;
int n,m;
string a,b,flag;
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	cin>>a;
	n = a.length() ;
	for(register int i = 1;i <= n;i++)
	{
		printf("x");
	} 
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

p = 1000000007

def calc(x):
    n = len(x)
    res = 0
    for i in range(0,n):
        res = res + x[i] * i
        res = res - x[i] * (n - i - 1)
    return res % p

n,m = readln()
x = readln()
y = readln()
print((calc(x) * calc(y)) % p)


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

using namespace std;

int main(void) {
    long m;
    cin >> m;
    long r = 0, t = 0;
    long a = 0;
    for(int i=0; i<m; i++) {
        long d,c;
        cin >> d >> c;
        t += d*c;
        a += c;
        while(t >= 10)
            r += t/10, t -= t/10*9;
    }
    cout << (a + r - 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
    cin>>n;
    int a1;
    vi v1,v2;
    int sum = 0;
    int ans = (n*(n-1))/2;
    loop(i,0,n)
    {
        cin>>a1;
        v1.pb(a1);
    }
    SORT(v1);
    loop(i,0,n)
    {
        if(v1[i]!=0)
        {
            int k = v1[i];
            loop(j,i+1,n)
            {
             v2.pb(k*v1[j]);
            }
        }
    }
    int b = v2.size();
    int h = min(b,ans);
    loop(i,0,h)
    sum += v2[i];
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
void solve(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if((i + 1) % 2 == 1){
            cout << s.at(i);
        }
    }
    cout << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 512
/**
 * B - Easy Linear Programming
 * https://atcoder.jp/contests/abc167/tasks/abc167_b
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // 1 が書かれたカードが A 枚、0 が書かれたカードが B 枚、 −1 が書かれたカードが C 枚あります。
    // これらのカードから、ちょうど K 枚を選んで取るとき、取ったカードに書かれた数の和として、 ありうる値の最大値はいくつですか。
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int score = 0;
    for (int i = K; i > 0; i--) {
        if (A > 0) {
            score++;
            A--;
        } else if (B > 0) {
            B--;
        } else {
            score--;
            C--;
        }
    }

    cout << score << endl;
}
 

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
  int a , b ,c;
  scanf("%d %d %d",&a,&b,&c);
  
  for(int i = 1; i <= b; i++){
    if((a*i)%b==c){
      printf("YES");
      return 0;
    }}

  printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define ll long long

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

    int ans = 0;
    int tmp = 0;

    for(int i = 0;i < N-1 && ans < N-i;++i){
        tmp = 0;
        for(int j = i+1;j < N;++j){
            if(H[j-1] < H[j]){
                break;
            }
            tmp++;
        }
        ans = max(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,m,x=0,y=0;
  char cell[10][10];
  cin >> n >> m;
  
  rep(i,0,10){
    rep(j,0,10){
      cell[i][j] = 'X';
    }
  }
  
  rep(i,0,n){
    rep(j,0,m){
      cin >> cell[i][j];
    }
  }
  
  while(1){
    if(cell[x+1][y] == '#'){
      cell[x][y] = '.';
      x++;
    }
    else if(cell[x][y+1] == '#'){
      cell[x][y] = '.';
      y++;
    }
    else{
      cell[n-1][m-1] = '.';
      break;
    }
  }
  
  rep(i,0,n){
    rep(j,0,m){
      if(cell[i][j] == '#'){
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  
  cout << "Possible" << endl;
  return 0;
  
}

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
al = [0]*m; bl = [0]*m
for i in range(m):
	a,b = list(map(int, input().split()))
	al[i] = a; bl[i] = b
n_road = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
	n_road[(al[i]-1)][(bl[i]-1)] += 1
	n_road[(bl[i]-1)][(al[i]-1)] += 1
for i in range(n):
	print(sum(n_road[i]))




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

int dist(const int& x1, const int& y1, const int& x2, const int& y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
int main(){
    int cx1, cy1, r1, cx2, cy2, r2;
    cin >> cx1 >> cy1 >> r1 >> cx2 >> cy2 >> r2;
    int rs = (r1+r2)*(r1+r2);
    int rd = (r1-r2)*(r1-r2);
    int d = dist(cx1, cy1, cx2, cy2);
    if(d > rs) cout << 4 << endl;
    else if(d == rs) cout << 3 << endl;
    else if(d < rs && d > rd) cout << 2 << endl;
    else if(d == rd) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3116
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    t = S()
    s = list(s)
    t = list(t)
    slen = len(s)
    tlen = len(t)
    ans = float("inf")

    for i in range(tlen):
        char = t[i]
        for j in range(i,slen-(tlen-i-1)):
            aaa = s[j]
            if aaa==char:
                rng = s[j:j+tlen-i]
                ex = t[i:]
                cnt = 0
                for x,y in zip(rng,ex):
                    if x == y:
                        cnt += 1
                ans = min(ans, tlen-cnt)
    if ans == float("inf"):
        ans = tlen
    print(ans)

main()            


Measured memory_bytes: 70164
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        double seki = 1;
        long wa = 0;
        double b[] = new double[n];
        double wawa = 0;
        for (int i = 0; i < n; i++) {
            b[i] = 1.0 / (1.0 * a[i]);
            seki *= 1.0 * a[i];
            wawa += b[i];
        }
        for (int i = 0; i < n; i++) {
            wa += seki / a[i];
        }

        System.out.println(1.0 / wawa);
        sc.close();
    }
}


Measured memory_bytes: 22996
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = input()
if len(n) == 1:
    print(n)
    exit()
allnine = True
for i in range(1, len(n)):
    if n[i] == '9':
        pass
    else:
        allnine = False
if n[0] == '9' and allnine:
    print(9 * len(n))
    exit()
if n[0] == '1' and allnine:
    print(1 + (len(n)-1) * 9)
    exit()
if n[0] != '1' and allnine:
    print(int(n[0]) + (len(n)-1) * 9)
    exit()
print(int(n[0]) + (len(n)-1) * 9 - 1)


Measured memory_bytes: 10416
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main()
{
	cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ld v = 0;
    for(int i = 0; i < n; i++)
    {
        v += (1.0/a[i]);
    }
    cout << fixed << setprecision(7) << 1.0 / v << "\n";
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

const int MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    ll total = 1;
    for (int i = 1; i<=N; ++i){
        total=total*10%MOD;
    }
    ll seki = 1;
    for(int i = 1; i<=N; ++i){
      seki = seki*8%MOD;
    }
    ll A = 1;
    for(int i = 1; i <=N; ++i){
      A = A*9%MOD;
    }
    cout << (2*MOD+(total % MOD) + (seki % MOD) - (A % MOD) - (A % MOD)) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3636
[H,W] = list(map(int,input().split()))
ls = []
for i in range(H):
  ls.append(input())
dp = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
  for j in range(W):
    if i == 0 and j == 0:
      dp[i][j] = 0
    elif i == 0:
      dp[i][j] = dp[i][j-1] + int(ls[i][j])
    elif j == 0:
      dp[i][j] = dp[i-1][j] + int(ls[i][j])
    else:
      dp[i][j] = min(dp[i-1][j],dp[i][j-1]) + int(ls[i][j])
print(dp[H-1][W-1])

Measured memory_bytes: 7804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextLine()) {
			int row = scan.nextInt();
			int col = scan.nextInt();
			
			if(row == 0 && col == 0) break;
			
			for(int i=0; i<row; i++) {
				for(int j=0; j<col; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}






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

int memo[31];

int main(){
	int n,ans;
	
	memo[0]=1;
	memo[1]=1;
	memo[2]=2;
	
	for(int i=3;i<31;i++){
		memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
	}
	
	while(cin>>n){
		if(n==0)break;
		cout<<memo[n]/(365*10)+1<<endl;
	}
	
	return 0;
}

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

int main(){
   int n,k,sum=0,kk=0;
   string s;
   cin>>n;
   cin>>k;
   cin>>s;
   for(int i=0;i<n-1;i++){
	   if(s[i]==s[i+1]){
		   
		   sum++;
	   }else{
		   kk++;
	   }
   }
   while(kk>0&&k>0){
	  sum+=2;
	  kk-=2;
	  k--; 
   }
   if(kk==-1)sum--;
   cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 512
import math

N = int(input())
x = [0] * N
y = [0] * N

for i in range(N):
    x[i], y[i] = map(int, input().split())

s = 0
for j in range(N):
    for k in range(N):
        if (j!=k):
            s += ((x[j] - x[k])**2 + (y[j] - y[k])**2)**(1/2)
if N==2:
    a = s / math.factorial(N)
else:
    a = s*(N-1)*math.factorial(N-2)/math.factorial(N)
print(a)

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
        int a[4], b[4], i, j, hit, blow;

        while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) {

                hit = blow = 0;
                for (i = 0; i < 4; i++) {
                        scanf("%d", &b[i]);
                        if (b[i] == a[i]) {
                               hit++;
                        }
                        if (b[i] == a[(i+1)%4] ||
                                b[i] == a[(i+2)%4] ||
                                b[i] == a[(i+3)%4]) {
                                blow++;
                        }
                }
                printf("%d %d\n", hit, blow);
        }
        return 0;
}

Measured memory_bytes: 0
n = int(input())
s = str(n)
l = len(s)
ans = 0
for i in range(1,l+1):
  if i%2 == 1:
    if i<l:
      ans += 9*10**(i-1)
    else:
      ans += n-(10**(i-1)-1)
print(ans)

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt();
	if (n == 3) {
		cout << "2 5 63\n";
		return 0;
	}
	if (n == 4) {
		cout << "2 5 20 63\n";
		return 0;
	}
	int cur = 0;
	while (n >= 8) {
		printf("%d %d %d %d ", cur + 2, cur + 3, cur + 4, cur + 6);
		cur += 6;
		n -= 4;
		printf("%d %d %d %d ", cur + 2, cur + 3, cur + 4, cur + 6);
		cur += 6;
		n -= 4;
	}
	if (n == 7) {
		printf("%d %d %d %d %d %d %d\n", cur + 2, cur + 3, cur + 4, cur + 6, cur + 8, cur + 9, cur + 10);
	} else if (n == 6) {
		printf("%d %d %d %d %d %d\n", cur + 2, cur + 3, cur + 4, cur + 8, cur + 9, cur + 10);
	} else if (n == 5) {
		printf("%d %d %d %d %d\n", cur + 2, cur + 3, cur + 4, cur + 6, cur + 9);
	} else if (n == 4) {
		printf("%d %d %d %d\n", cur + 2, cur + 4, cur + 8, cur + 10);
	} else if (n == 3) {
		printf("%d %d %d\n", cur + 2, cur + 4, cur + 6);
	} else if (n == 2) {
		printf("%d %d\n", cur + 2, cur + 4);
	} else if (n == 1) {
		printf("%d\n", cur + 6);
	} else {
		printf("\n");
	}

	return 0;
}

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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	char str[10]; cin >> str;
	int len = strlen(str);
	for (int i = 0; i < len; i++) cout << (char)('1' + '9' - str[i]);
	cout << "\n";
	
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

const ll mod = 1000000007; // faster if const

ll modpow(ll b, ll e) {
	ll ans = 1;
	for (; e; b = b * b % mod, e /= 2)
		if (e & 1) ans = ans * b % mod;
	return ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    ll n,k;cin>>n>>k;
    vector<ll>v(k+1,0);
    ll ans=0;
    repD(i,k,1){
        v[i]=modpow(k/i,n);
        for(int j=2*i;j<=k;j+=i) v[i]=(v[i]-v[j]+mod)%mod;
        ans=(ans+v[i]*i%mod)%mod;
    }
    cout<<ans;

	return 0;
}
 



Measured memory_bytes: 3928