akhauriyash/Code-Regression huggingface dataset:
n=int(input())
s=str(n)
m=len(s)
ans=0
if n<=9:
    print(n)
    exit()
if n<=99:
    for i in range(1,n+1):
        for j in range(1,n+1):
            if str(i)[-1]=="0":
                continue
            if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]:
                ans+=1
    print(ans)
    exit()
y=int(s[1:m-1])
for i in range(1,n+1):
    a,b=str(i)[0],str(i)[-1]
    if b=="0":
        continue
    if a==b:
        ans+=1
    dig=1
    for j in range(m-2):
        ans+=dig
        dig*=10
    if int(b)==int(s[0]):
        if int(a)>int(s[-1]):
            ans+=y
        else:
            ans+=y+1
    elif int(b)<int(s[0]):
        ans+=dig
print(ans)

Measured memory_bytes: 3064
x=int(input())
if 400 <= x <= 599:
  print(8)
if 600 <= x <= 799:
  print(7)
if 800 <= x <= 999:
  print(6)
if 1000 <= x <= 1199:
  print(5)
if 1200 <= x <= 1399:
  print(4)
if 1400 <= x <= 1599:
  print(3)
if 1600 <= x <= 1799:
  print(2)
if 1800 <= x <= 1999:
  print(1)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include <cstdio>
#include <cmath>
#define int long long
using namespace std;
const int MaxN=1050;
const int MaxK=100050;
int n,k;
int a[MaxN],b[MaxN],c[MaxK],s[MaxN],sum,cnt,ans;
signed main(void)
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i],sum+=a[i];
	for(int i=1;i*i<=sum;++i)
		if(!(sum%i))
			c[++cnt]=i,c[++cnt]=sum/i;
	if(c[cnt]==c[cnt-1])
		cnt--;
	sort(c+1,c+cnt+1);
	for(int i=cnt;i;--i)
	{
		register int x=c[i];
		for(int i=1;i<=n;++i)
			b[i]=a[i]%x;
		sort(b+1,b+n+1);
		for(int i=1;i<=n;++i)
			s[i]=s[i-1]+b[i];
		for(int i=1;i<=n;++i)
			if(s[i]==(n-i)*x-(s[n]-s[i]))
			{
				if(k>=s[i])
				{
					cout<<x<<endl;
					return 0;
				}
				else
					break;
			}
	}
	puts("1");
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = N / (A+B) * A;

    if(N % (A+B) > 0){
        if(N % (A+B) >= A){
            ans += A;
        }else{
            ans += N % (A+B);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H,W,i,j,k,l;
    char a[100][101] = {'\0'};
    char *o[100];
    char *p;
    int is_removed = 0;

    scanf("%d %d", &H, &W);
    for(i=0;i<H;i++) {
        scanf("%s", a[i]);
        o[i] = a[i];
    }
    /* remove col */
    for(j=0,l=0;j<W;j++) {
        is_removed = 1;
        for(i=0;i<H;i++) {
            o[i][l] = o[i][j];
            if ('.' != o[i][l]) {
                is_removed = 0;
            }
        }
        if(is_removed == 0) l++;
    }

    /* remove row */
    for(i=0;i<H;i++) {
        p = o[i];
        for(j=0;j<l;j++,p++) {
            if('.' != *p) break;
        }
        if(j != l) {
            o[i][l] = '\0';
            printf("%s\n",o[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

dp = [[0]*3 for _ in range(N)]
for i in range(3):
    dp[0][i] = A[0][i]


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

print(max(dp[-1]))

Measured memory_bytes: 47264
from decimal import Decimal
N,K=map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i >=K:
        ans+=N-i+1
        break
    tmp = i
    t_k = 1
    while tmp < K:
        tmp = tmp*2
        t_k = t_k*2
    ans += Decimal(1/t_k)
print(Decimal(ans/N))

Measured memory_bytes: 69972
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int n,m,a;
  priority_queue<int> as;
  int count = 0;
  int sum = 0;

  cin >> n >> m;
  REP(i,n) {
    cin >> a;
    as.push(a);
    sum += a;
  }


  while (!as.empty()) {
    if(as.top() < (sum / (4.0 * m))) {
      break;
    }

    count++;
    as.pop();
  }

  cout << ((count >= m) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
divide_4, divide_2 = 0, 0
(0...n).each do |i|
  if arr[i] % 4 == 0
    divide_4 += 1
  elsif arr[i] % 2 == 0
    divide_2 += 1
  end
end

nn = n % 2 == 0 ? n : n - 1

if divide_4 >= nn / 2
  puts 'Yes'
else
  if nn - (2 * divide_4) <= divide_2
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 9476
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

//問題文をよく読む

func main() {
	N, K := nextInt(), nextInt()
	ans := 0
	A := make([]int, N)
	mod := int(1e9 + 7)
	revnums1st := 0
	revnums2nd := 0
	for i := range A {
		A[i] = nextInt()
	}
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			if A[i] > A[j] {
				revnums1st++
			}
		}
	}
	// ans = revnums1st * K
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			if A[i] > A[j] {
				revnums2nd++
			}
		}
	}
	c1 := (revnums1st * K) % mod
	c2 := revnums2nd * ((K * (K - 1) / 2) % mod)
	ans = (c1 + c2) % mod
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int x, a, b; cin >> x >> a >> b;
	cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
	return;
}

int main() {
	solve();
  return 0;
}

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

int main() {
	vector<int> x(4,0);
	vector<int> y(4,0);

	cin >> x[0] >> y[0] >> x[1] >> y[1];
	x[3] = x[0] + (-(y[1] - y[0])); 
	y[3] = y[0] + ( (x[1] - x[0]));
	
	x[2] = x[3] + (-(y[0] - y[3])); 
	y[2] = y[3] + ( (x[0] - x[3]));
	
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
	return 0;
}


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

int resum(int n){
    int sum = 0;
    while(n > 0){
        sum = sum + (n % 10);
        n = n / 10;
    }
    return sum;
}

int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    int sum = 0;
    int div;
    int total = 0;
    rep(i,n){
        sum = resum(i);
        if (sum >= a && sum <= b) total+=i;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
package main

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

func solve() {
	n, k, q := getInt(), getInt(), getInt()
	cntCorrects := make([]int, n)
	for i := 0; i < q; i++ {
		a := getInt() - 1
		cntCorrects[a]++
	}

	for _, c := range cntCorrects {
		d := (k + c) - q

		ans := "Yes"
		if d <= 0 {
			ans = "No"
		}
		fmt.Fprintln(wr, ans)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

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

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;

int dp[ARRAY_MAX];

int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	int maxi = 0;

	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] != s[i + 1])
		{
			dp[i + 2] = max(dp[i + 2], max(maxi, dp[i] + 1));
			maxi = max(dp[i + 2], maxi);
		}
		else
		{
			dp[i + 2] = max(dp[i + 2], max(maxi, dp[i]));
			maxi = max(dp[i + 2], maxi);
		}
	}

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






Measured memory_bytes: 3732
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; string s;
	cin >> n >> s;
	int ans = 0, x = 0;
	for (auto i : s)
	{
		if (i == 'I') x++;
		else x--;
		chmax(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
long long int n,a,b,c,i;

 
 
int main(void){
scanf("%d",&n);
b = 1;
for(i = 1;i <= n ;i++){

b = b * i;
b=b % (10*10*10*10*10*10*10*10*10 + 7);
}
c = b;
//b=b % (10*10*10*10*10*10*10*10*10 + 7);
printf("%lld",c);
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//????????????????????????????????????
		//????????????????¨????????????????

		//???????????§???????????????
		Scanner sc = new Scanner(System.in);
		String stOP = "";

		while(!("?".equals(stOP))){
			int A = sc.nextInt();
			stOP = sc.next();
			int B = sc.nextInt();
			int Ans = 0;


			if("+".equals(stOP)){
				Ans = A + B;
				System.out.println(Ans);
			}else if("-".equals(stOP)){
				Ans = A - B;
				System.out.println(Ans);
			}else if("*".equals(stOP)){
				Ans = A * B;
				System.out.println(Ans);
			}else if("/".equals(stOP)){
				Ans = A / B;
				System.out.println(Ans);
			}else if("?".equals(stOP)){
				break;
			}
		}
	}
}

Measured memory_bytes: 26184
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    int r;
    cin>>r;
    double c;
    c=2*(22.00/7)*r;
    cout<<fixed<<setprecision(12)<<c;
}

Measured memory_bytes: 3804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }
        int x = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == min) x++;
        }
        if (max - min > 1) {
            out.println("No");
            return;
        }
        if (max == min) {
            if (max == n - 1 || max <= n / 2) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        } else {
            if (max >= x + 1 && max <= x + (n - x) / 2) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 35940
def B():
    N = int(input())
    A = [int(x) for x in input().split()]

    S = []

    for i in range(N):
        if A[i] % 2 == 0:
            S.append(i)

    Ns = len(S)
    while True:
        for j in range(Ns):
            if A[S[j]] % 3 != 0 and A[S[j]] % 5 != 0:
                print('DENIED')
                return False
        print('APPROVED')
        break

B()        
        

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
/////递归
//long long binaryPow(long long a, long long b, long long m)
//{
//	if (b == 0) return 1;
//	else if (b % 2 == 1) return a * binaryPow(a, b - 1,m)%m;
//	else
//	{
//		long long temp = binaryPow(a, b / 2,m)%m;
//		return temp * temp%m;
//	}
//}
long long x[101],s[101],sum=0,t=0,r,f;
int main()
{
	long long n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i];
		t += x[i];
		sum += x[i] * x[i];
	}
	//cout << sum << endl;
	r = n - t * 2;
	for (int p = 2; p <=n* n; p++)
	{
		f = n * p * p - 2 * t * p;
		if (f < r) r = f;
	}
	cout << sum + r << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    V<ll> a(n);
    ll oddsum = 0, evensum = 0, mx = -inf;
    rep(i, n) {
        cin >> a[i];
        if(a[i] > 0) (i & 1 ? oddsum : evensum) += a[i];
        chmax(mx, a[i]);
    }
    ll ans;
    V<int> use;
    if(mx <= 0) {
        ans = mx;
        rep(i, n) {
            if(a[i] == mx) {
                use.push_back(i + 1);
                break;
            }
        }
    } else if(oddsum > evensum) {
        ans = oddsum;
        for(int i = 1; i < n; i += 2)
            if(a[i] > 0) use.push_back(i + 1);
    } else {
        ans = evensum;
        for(int i = 0; i < n; i += 2)
            if(a[i] > 0) use.push_back(i + 1);
    }
    V<int> ans2;
    while(use.back() < n) {
        ans2.push_back(n--);
    }
    FORR(i, (int)use.size() - 1) {
        while(use[i] != use[i + 1]) {
            ans2.push_back(use[i] + use[i + 1] >> 1);
            use[i + 1] -= 2;
        }
    }
    rep(i, use[0] - 1) ans2.push_back(1);

    cout << ans << endl;
    cout << ans2.size() << endl;
    for(int i : ans2)
        cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    if(N/10 == 9 or N%10 == 9){
        puts("Yes");
        return 0;
    }else{
        puts("No");
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000
int iprime(int);
int main(){
int n,i,array[N],count = 0,x;

scanf("%d\n",&n);

for(i = 0;i < n;i++){
scanf("%d",&array[i]);
}

for(i = 0;i < n;i++){
x = iprime(array[i]);
if(x == 1)
count++;
}

printf("%d\n",count);
  return 0;
}

 int iprime(int n){
int i = 3;
if(n == 2) return 1;
if(n < 2 || n % 2 == 0) return 0;

while (i <= sqrt(n)) {
  if(n % i == 0) return 0;
  i += 2;/* code */
}
return 1;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

struct DSU{
	vector<int> p,sz;
	DSU(int N){
		p.resize(N);
		sz.resize(N,1);
		for(int i = 0;i < N;i++)p[i] = i;
	}
	int par(int x){
		if(x == p[x])
			return x;
		return p[x] = par(p[x]);
	}
	bool mrg(int x,int y){
		x = par(x),y = par(y);
		if(x == y)
			return false;
		if(sz[x] < sz[y]){
			swap(x,y);
		}
		p[y] = p[x];
		sz[x] += sz[y];
		return true;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin>>N;
	vector<int> a(N),b(N),cpy;
	int Exor = 0;
	vector<int> all;
	for(int i = 0;i < N;i++) cin>>a[i],Exor ^= a[i],all.push_back(a[i]);
	all.push_back(Exor);
	
	for(int i = 0;i < N;i++) cin>>b[i];
	
	{ // determine NO
		cpy = b;
		sort(all.begin(),all.end());
		sort(cpy.begin(),cpy.end());
		bool can = true;
		for(int i = 0,j = 0;i < N && can;i++) {
			while(j < N + 1 && all[j] < cpy[i]) j++;
			if(j >= N + 1) can = false;
			if(j < N + 1 && all[j] > cpy[i]) can = false;
			j++;
		}
		if(!can) {
			cout<<"-1\n";
			return 0;
		}
	}
	
	all.clear();
	all.push_back(Exor);
	for(int i = 0;i < N;i++) {
		if(a[i] != b[i]) all.push_back(a[i]),all.push_back(b[i]);
	}
	
	sort(all.begin(),all.end());
	auto it = unique(all.begin(),all.end());
	all.erase(it,all.end());
	
	DSU dsu(all.size());
	int com = all.size();
	cerr<<com<<'\n';
	int diff = 0;
	for(int i = 0;i < N;i++) {
		if(a[i] == b[i]) continue;
		diff ++;
		auto x = lower_bound(all.begin(),all.end(),a[i]) - all.begin();
		auto y = lower_bound(all.begin(),all.end(),b[i]) - all.begin();
		assert(all[x] == a[i] && all[y] == b[i]);
		com -= dsu.mrg(x,y);
	}
	cerr<<com<<'\n';
	cout<<diff+(com-1)<<'\n';
	return 0;
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        if (N == 1)
        {
            Console.WriteLine("Hello World");
            return;
        }
        int A = cin.nextInt();
        int B = cin.nextInt();
        Console.WriteLine(A + B);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11092
import numpy as np
from numba import njit

(N, K) = map(int, input().split())
A = np.array(list(map(int, input().split())))

@njit
def solve(N,K,A):
    for j in range(0, K):
        B = np.zeros(N, dtype=np.int64)

        for i in range(0,N):
            f = max(0, i - A[i])
            t = min(N-1, i + A[i])
            #for j in range(max(0, f), min(N, t)+1):
            #    B[j] += 1
            B[f] += 1
            if t+1 < N:
                B[t+1] -= 1
        A = np.cumsum(B)
        if np.all(A == N):
            return A
        i += 1
    return A
    

print(" ".join(map(str, solve(N,K,A))))

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

vvi adj;
vi vis;
int dfs(int u){
    int sz = 1;
    vis[u] = 1;
    for (int v : adj[u]){
        if (vis[v] == 0){
            sz += dfs(v);
        }
    }
    return sz;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi arr(n), brr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 0; i < n; i++) cin >> brr[i];

    map<int, int> mmap;
    int xval = 0;
    for (int i = 0; i < n; i++){
        xval ^= arr[i];
        mmap[arr[i]]++;
    }
    mmap[xval]++;
    int oldval = xval;
    bool uniq = mmap[xval] == 1;

    xval = 0;
    for (int i = 0; i < n; i++){
        xval ^= brr[i];
        mmap[brr[i]]--;
    }
    mmap[xval]--;
    map<int, int> indx;
    int id=0;
    for (auto &it : mmap){
        if (it.Y != 0) {
            cout << -1 << endl;
            return 0;
        }
        indx[it.X] = id++;
    }

    arr.push_back(oldval);
    brr.push_back(xval);

    vis.assign(id, 0);
    adj.resize(id);

    int res = -1;
    for (int i = 0; i <= n; i++){
        if (arr[i] != brr[i] || i == n){
            adj[ indx[arr[i]] ].push_back( indx[brr[i]] );
            if (arr[i] == brr[i]) res += uniq;
            if (i < n) res++;
        }
    }

    for (int i = 0; i < id; i++){
        if (vis[i] == 0) {
            res += (dfs(i) > 1);
        }
    }

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


Measured memory_bytes: 19440
#include <stdio.h>


int main(){
  int n,v,i,j,k,A[100];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  for(i=1;i<=n-1;i++){
    v=A[i];
    j=i-1;
      while(j>=0 && A[j]>v){
	A[j+1]=A[j];
	j--;
	A[j+1]=v;
      }
      for(k=0;k<n;k++){
	printf("%d",A[k]);
	if(k!=n-1)printf(" ");
      }
      printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll h, w, m;
    cin >> h >> w >> m;

    vector<ll> y(m, 0), x(m, 0);
    for (int i = 0; i < m; i++)
    {
        cin >> y[i] >> x[i];
        y[i]--;
        x[i]--;
    }

    set<pair<int, int>> s;
    for (int i = 0; i < m; i++)
        s.insert(make_pair(y[i], x[i]));

    vector<pair<int, int>> sy(h), sx(w);
    for (int i = 0; i < h; i++)
        sy[i] = make_pair(0, i);
    for (int i = 0; i < w; i++)
        sx[i] = make_pair(0, i);

    for (int i = 0; i < m; i++)
    {
        sy[y[i]].first++;
        sx[x[i]].first++;
    }

    sort(sy.rbegin(), sy.rend());
    sort(sx.rbegin(), sx.rend());

    for (int i = 0; i < h; i++)
    {
        if (sy[i].first != sy[0].first)
            break;
        for (int j = 0; i < w; j++)
        {
            if (sx[j].first != sx[0].first)
                break;

            if (s.find(make_pair(sy[i].second, sx[j].second)) == s.end())
            {
                cout << (sy[0].first + sx[0].first) << endl;
                return 0;
            };
        }
    }

    cout << (sy[0].first + sx[0].first - 1) << endl;

    return 0;
}

Measured memory_bytes: 26340
unittest
{
	assert( [ "5", "3", "10000", "9000" ].parse.expand.solve == 48000 );
	assert( [ "2", "3", "10000", "9000" ].parse.expand.solve == 20000 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto k = input.front.to!( long );
	input.popFront;
	auto x = input.front.to!( long );
	input.popFront;
	auto y = input.front.to!( long );
	return tuple( n, k, x, y );
}

auto solve( long n, long k, long x, long y )
{
	if( n <= k ) return x * n;
	else         return x * k + y * ( n - k );
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]
sumS = sum(S)
T = list(filter(lambda x : x%10!=0, S))
T.sort()
if len(T)==0:
    print(0)
else:
    for t in T:
        if sumS%10!=0:
            break
        else:
            sumS -= t
    print(sumS)

Measured memory_bytes: 3060
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  val prim :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  let prim es =
    (*
     * プリム法のメインループ
     * es : 隣接リスト
     * vs : 訪れた頂点の集合
     * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
     * acc : 最小全域木に使うのが確定した辺を入れるやつ
     *)
    let rec prim acc vs q =
      match WMap.min_binding q with
      | exception Not_found -> acc
      | (w, []) -> prim acc vs (WMap.remove w q)
      | (w, (u, v) :: rest) ->
          ( if VSet.mem v vs
            (* vは既に訪れていた *)
            then prim acc vs
            (* vはまだ訪れていなかった *)
            else prim_aux ((u, v, w) :: acc) vs v ) (WMap.add w rest q)
    (* vを訪れ，vから伸びる辺をキューに追加してループを続行する *)
    and prim_aux acc vs v q =
      prim acc (VSet.add v vs) @@
      List.fold_left (fun q (u, w) ->
        WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) q (es v) in
    fun s -> prim_aux [] VSet.empty s WMap.empty
end

module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" (fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  G.prim (Array.get es) 0
  |> List.map (fun (_, _, w) -> w)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n")


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

typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;
const ll N=3e5 + 5;
ll n,arr[N];

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

    for(ll i=0;i<n;i++)
        cin>>arr[i];

    ll sfx[n];
    sfx[n-1]=1;
    for(ll i=n-2;i>=0;i--){
        if(arr[i]>=arr[i+1])
            sfx[i] = sfx[i+1] + 1;
        else
            sfx[i] = 1;
    }

    ll ans = *max_element(sfx,sfx+n) - 1;
    cout<<ans;

}



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

void fnInput(vector<int>& rvnOrder)
{
  int nOrderSiz;
  cin >> nOrderSiz;

  rvnOrder.resize(nOrderSiz + 1);
  for (int n = 1; n < rvnOrder.size(); n++)
  {
    int nOrder;
    cin >> nOrder;
    rvnOrder[nOrder] = n;
  }
}

int fnOrderCheck(const vector<int>& cnrvnOrder)
{
  for (int nOrder : cnrvnOrder)
    if (nOrder) cout << nOrder << " ";

  cout << endl;
}

int main()
{
  vector<int> vnOrder;

  fnInput(vnOrder);
  fnOrderCheck(vnOrder);

  return 0;
}

Measured memory_bytes: 1152
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    o = S()
    e = S()
    l = len(o)
    el = len(e)
    r = ''
    for i in range(l):
        r += o[i]
        if i < el:
            r += e[i]
    return r



print(main())


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

int main() {
	int n;cin>>n;
	vector<int> a,b;
	for(int i=0;i<n;i++){
		int k;cin>>k;
		a.push_back(k);
	}
	b=a;
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=0;i<n;i++){
		if(b.at(i)==a.at(0)){
			cout<<a.at(1)<<endl;
		}else{
			cout<<a.at(0)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3316
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string s;
    cin >> s;
    REP(i,3) if(s[i]=='1') ans++;
    cout << ans << endl;
}

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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int A=max(a-x,x-a),B=max(b-x,x-b);
  
  if(A<B){
  cout << "A" << endl;
  }
  else{
    cout << "B" << endl;
  }
}


Measured memory_bytes: 256
S = input()
l = 0
r = len(S)-1
cnt = 0
while l < r:
    if S[l] == S[r]:
        l += 1
        r -= 1
    elif S[l] == 'x':
        l += 1
        cnt += 1
    elif S[r] == 'x':
        r -= 1
        cnt += 1
    else:
        cnt = -1
        break
print(cnt)


Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n,k;
    cin>>n>>k;
    if(k==1) cout<<0<<endl;
    else cout<<n-k<<endl;
}

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

int main() {
  int K,N;
  int L = 0;
  cin >> K >> N;
  
  vector<int>dis(N);
  vector<int>space(N);
  
  for(int i = 0; i < N; i++) {
    cin >> dis.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (i != N-1)
      space.at(i) = dis.at(i+1) - dis.at(i); 
    
    else if (i == N-1)
      space.at(N-1) = dis.at (0) + K - dis.at(N-1);
  }
  for (int i = 0; i < N; i++) {
    if (space.at(i) > L) {
      L = space.at(i);
    }
  }
  cout << K - L << endl;
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int n,m,l,r,D;
vector<pair<int,int>> v[100001];
int d[100001];
bool ok=true;

void dfs(int node,int num){
    d[node]=num;
    for(int i=0;i<v[node].size();i++){
        if(d[v[node][i].first]==1e9+1) dfs(v[node][i].first,num+v[node][i].second);
        else if(d[v[node][i].first]!=num+v[node][i].second) ok=false;
    }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>l>>r>>D;
        v[l].push_back(make_pair(r,D));
        v[r].push_back(make_pair(l,-D));
    }
    for(int i=1;i<=n;i++)d[i]=1e9+1;
    for(int i=1;i<=n;i++){
        if(d[i]==1e9+1) dfs(i,0);
    }
    cout<<(ok?"Yes":"No");
    return 0;
}

Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, K; cin >> N >> K;
    vector<P> v;
    for (int i = 0; i < N; i++) {
        int t, d; cin >> t >> d; t--;
        v.push_back(P(t, d));
    }
    sort(v.begin(), v.end(), [](P p1, P p2) {
        return p1.second > p2.second;
    });

    ll res = 0;
    ll x = 0;
    vector<bool> check(N);
    priority_queue<int, vector<int>, greater<int>> que1;
    for (int i = 0; i < K; i++) {
        int& t = v[i].first;
        int& d = v[i].second;
        res += d;
        if (!check[t]) {
            x++;
            check[t] = true;
        }
        else que1.push(d);
    }
    ll ans = res + x * x;

    priority_queue<int> que2;
    for (int i = K; i < N; i++) {
        int& t = v[i].first;
        int& d = v[i].second;
        if (!check[t]) {
            que2.push(d);
            check[t] = true;
        }
    }

    while (!que1.empty() && !que2.empty()) {
        res -= que1.top(); que1.pop();
        res += que2.top(); que2.pop();
        x++;
        ans = max(ans, res + x * x);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1524
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    dp = []
    for i in arr:
        if not dp:
            dp.append(i)
        else:
            dp.append(dp[-1]+i)

    ans = float('inf')

    for i in range(n-1):
        left = dp[i]
        right = dp[-1]-dp[i]

        ans = min(ans,abs(left-right))

    print(ans)

main()


Measured memory_bytes: 26396
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int a, b;
	while (cin >> a >> b) {
		cout << to_string(a + b).size() << endl;
	}
}


Measured memory_bytes: 3104
W,a,b=map(int,input().split())
if b>a:
  if b-(a+W)<=0:
  	print(0)
  	exit()
  print(b-(a+W))
else:
  if a-(b+W)<=0:
  	print(0)
  	exit()
  print(a-(b+W))

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

using namespace std;

int main(){
	int a,b;
	char p;
	while(cin>>a>>p>>b){
	if(p=='+'){
		cout<<a+b<<endl;
	}
	if(p=='-'){
		cout<<a-b<<endl;
	}
	if(p=='/'){
		cout<<a/b<<endl;
	}
	if(p=='*'){
		cout<<a*b<<endl;
	}
	if(p=='?'){
		break;
	}
}
}


Measured memory_bytes: 3096
L,A,B,C,D = input(),input(),input(),input(),input()

if(A%C != 0):
    N = A/C + 1
else:
    N = A/C

if(B%D != 0):
    M = B/D + 1
else:
    M = B/D
if(M > N):
    print L - M
else:
    print L - N

Measured memory_bytes: 4204
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
#define loop(c, a, b) for(int c = a; c <= b; ++c)
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

int n,k;
bool flag[maxn];
int a,d;

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= k; i++){
		scanf("%d", &d);
		for(int i = 1; i <= d; i++){
			scanf("%d", &a);
			flag[a] = 1;
		}
	}
	int  ans = 0;
	for(int i = 1; i <= n; i++){
		if(!flag[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int L[N];
  int S=0;
  REP(i,N){
    cin>>L[i];
    S+=L[i];
  }
  bool f=true;
  REP(i,N){
    if(L[i]<S-L[i])continue;
    f=false;
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;

constexpr ll MOD = 1e9 + 7;

int main()
{
  ll n;
  cin >> n;
  string s;
  cin >> s;
  map<char, int> mp;
  for (int i = 0; i < n; ++i)
  {
    mp[s[i]]++;
  }
  ll ans = 1;
  for (auto x : mp)
  {
    ans *= x.second + 1;
    ans %= MOD;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
  
int main(void) {
  int i,j,n,rank;
  int card[4][14]={0};
  char sym,z;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c %c %d",&z,&sym,&rank);
    switch(sym){
    case 'S':card[0][rank]=rank; break;
    case 'H':card[1][rank]=rank; break;
    case 'C':card[2][rank]=rank; break;
    case 'D':card[3][rank]=rank;
    }
  }
  
  for(i=0;i<4;i++)
    for(j=1;j<=13;j++){
      if(card[i][j]==0)
    switch(i){
    case 0:printf("S %d\n",j); break;
    case 1:printf("H %d\n",j); break;
    case 2:printf("C %d\n",j); break;
    case 3:printf("D %d\n",j);
    }
    }
  return(0);
}

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

int main(){
  vector<int> count(4,0);
  int a,b;
  for(int i=0;i<3;i++){
    cin >> a >> b;
    a--;
    b--;
    count.at(a)++;
    count.at(b)++;
    if(count.at(a)>=3||count.at(b)>=3){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k,s;
    cin >> n >> k >> s;
    if(s!=INF){
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << s+1 << " ";
        cout << endl;
    }else{
        rep(i,k) cout << INF << " ";
        rep(i,n-k) cout << 1 << " ";
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll dp[100010];

int main() {
    ll N, K;
    cin >> N >> K;
    ll h[N];
    REP(i, 0, N) {
        cin >> h[i];
    }
    fill(dp, dp + 100010, inf);
    dp[0] = 0;
    REP(i, 0, N - 1) {
        REP(j, 1, min(K + 1, N - 1 - i + 1)) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    ll ans = dp[N - 1];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout<<"hon"<<endl;
    }
    else if(n==3){
        cout<<"bon"<<endl;
    }
    else{
        cout<<"pon"<<endl;
    }
	return;
}

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

Measured memory_bytes: 3652