akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = RInt;
            var B = RInt;
            var C = new int[3];
            C[0] = A + B;
            C[1] = A - B;
            C[2] = A * B;

            Console.WriteLine(C.Max());
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>

#define max(a, b) (((a) > (b)) ? (a) : (b))

unsigned char calculate_maximum_allowance (unsigned char const *A, unsigned char const *B, unsigned char const *C)
{
	// return value of this function
	register unsigned char allowance;

	allowance =     (unsigned char)(10) * *A + *B + *C;
	allowance = max((unsigned char)(10) * *B + *C + *A, allowance);
	allowance = max((unsigned char)(10) * *C + *A + *B, allowance);

	return allowance;
}

int main (void)
{
	// variables for main process
	unsigned char A, B, C;
	int           rtvl_scanf;

	// STEP.01
	// read out the given string
	rtvl_scanf = scanf("%hhu %hhu %hhu", &A, &B, &C);

	// STEP.02
	// calcualte & output the points
	printf("%u\n", calculate_maximum_allowance(&A, &B, &C));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int t1,t2,t3;
    int flag=0;
    for(int i=0;i<=a;i++){
        t1 = i*2;
        t2 = (a-i)*4;
        t3 = t1+t2;
        if(t3==b){
            flag++;
        }
    }
    if(flag>0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int d;
	int menseki;
	while(scanf("%d",&d) !=EOF)
	{
		menseki = 0;
		for(int i = 0;i<600;i+=d)
		{
			menseki+=i*i*d;
		}
		printf("%d\n",menseki);

	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int inf = 999999;
int a[10000];
int main(){
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int cnt = 0;
    for (int i=1; i<n; i++) {
        if (a[i] == a[i-1]) {
            a[i] = inf; cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    COMinit();
    
	ll N,K;
	cin>>N>>K;


    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    vector<ll> B(N-1);
    for(ll i=0;i<N-1;i++){
        B[i]= A[i+1]-A[i];
    }
    ll ans = 0;
    ll tmp_a,tmp_b,tmp_n;

    for(ll i=0;i<N-1;i++){
        if(i+1>=K){
            tmp_a = COM(i+1,K);
        }else{
            tmp_a = 0;
        }
        if(N-i-1>=K){
            tmp_b = COM(N-i-1,K);
        }else{
            tmp_b= 0;
        }
        ans = (ans +B[i]*((COM(N,K)-tmp_a-tmp_b)%MOD)%MOD)%MOD;
    }
    if(ans<0){
        ans +=MOD;
    }
    cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 13824
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[300020] = {};
int main() {
	long long int n, m;
	cin >> n >> m;
	for (long long int i = m / n; i > 0; i--) {
		if (i == 1) {
			cout << 1;
			return 0;
		}
		if ((m - i * n) % i == 0) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int A[n];
    for(auto&i:A)cin>>i;
    vector<int>dp(n,INFINITY);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j:{i+1,i+2}){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(A[i]-A[j]));
            }
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

		long temp500 = x / 500;
		x = x % 500;
		long temp5 = x / 5;

		System.out.println(temp500 * 1000 + temp5 * 5);

	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
pii a[200005];
ll cnt[200005];
int rev[200005];
int main(){
	int n;
	while(~getI(n)){
		F(i,0,n){
			getI(a[i].f);
			a[i].s=i;
		}
		FE(i,1,n) cnt[i]=0;
		sort(a,a+n);
		a[n].f=0;
		a[n].s=n;
		ll len=1;
		FE(i,1,n){
			if(a[i].f!=a[i-1].f){
				cnt[a[i-1].f]=len;
				len=0;
			}
			len++;
		}
		ll tot=0;
		FE(i,1,n) tot+=cnt[i]*(cnt[i]-1);
		F(i,0,n) rev[a[i].s]=i;
		tot/=2;
		F(i,0,n){
			int now=a[rev[i]].f;
			ll ans=tot-(cnt[now]-1);
			printf("%lld\n",ans);
		}
	}
}


Measured memory_bytes: 6528
program multiplication_4
  implicit none
  integer(8), parameter :: m = 1000000007
  integer :: n, k, i, cnt = 0
  integer(8) :: a(200000, 2) = 0, x = 1
  integer(8) :: nega = -1, negap = 1, posi = -1, posip = 1
  read(*,*) n, k
  read(*,*) a(1:n, 1)
  if (n == k) then
    do i = 1, n
      x = modulo(x * a(i, 1), m)
    end do
    write(*,'(i0)') x
    stop
  end if
  call merge_sort(a(1:n, :))
  if (a(1, 1) < 0 .and. mod(k, 2) == 1) then
    do i = 1, k
      x = modulo(x * a(i, 1), m)
    end do
    write(*,'(i0)') x
    stop
  end if
  do i = 1, n
    if (a(i, 1) >= 0) then
      a(i, 2) = 1
    else
      a(i, 1) = -a(i, 1)
      a(i, 2) = -1
    end if
  end do
  call merge_sort(a(1:n, :))
  do i = 1, k
    x = mod(x * a(i, 1), m)
    if (a(i, 2) == -1) then
      cnt = cnt + 1
      nega = a(i, 1)
    else
      posi = a(i, 1)
    end if
  end do
  if (x == 0 .or. mod(cnt, 2) == 0) then
    write(*,'(i0)') x
    stop
  end if
  do i = k + 1, n
    if (a(i, 2) == -1) then
      posip = a(i, 1)
      exit
    end if
  end do
  do i = k + 1, n
    if (a(i, 2) == 1) then
      negap = a(i, 1)
      exit
    end if
  end do
  if (nega == -1) then
    x = modulo(x * mod(posip * inv(posi), m), m)
  else if (posi == -1) then
    x = modulo(x * mod(negap * inv(nega), m), m)
  else if (nega * posip >= posi * negap) then
    x = modulo(x * mod(posip * inv(posi), m), m)
  else
    x = modulo(x * mod(negap * inv(nega), m), m)
  end if
  write(*,'(i0)') x
contains
  subroutine merge_sort(a)
    integer(8), intent(inout) :: a(:, :)
    integer :: n, m, l, i, u
    n = size(a, 1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m / 2
        u = min(2 * i * l, n)
        call merger(a(2 * (i - 1) * l + 1:(2 * i - 1) * l, :), a((2 * i - 1) * l + 1:u, :))
      end do
      l = 2 * l
      m = (m + 1) / 2
    end do
  end
  subroutine merger(a1, a2)
    integer(8), intent(inout) :: a1(:, :), a2(:, :)
    integer(8) :: a(size(a1, 1) + size(a2, 1), size(a1, 2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1, 1)
    n2 = size(a2, 1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (a1(i1, 1) > a2(i2, 1) .or. &
      (a1(i1, 1) == a2(i2, 1) .and. a1(i1, 2) >= a2(i2, 2))) then
        a(i1 + i2 - 1, :) = a1(i1, :)
        i1 = i1 + 1
      else
        a(i1 + i2 - 1, :) = a2(i2, :)
        i2 = i2 + 1
       end if
    end do
    if (i1 <= n1) then
      a(i1 + i2 - 1:n1 + n2, :) = a1(i1:n1, :)
    else
      a(i1 + i2 - 1:n1 + n2, :) = a2(i2:n2, :)
    end if
    a1 = a(1:n1, :)
    a2 = a(n1 + 1:n1 + n2, :)
  end
  pure elemental integer(8) function inv(v) result(res)
    integer(8), intent(in) :: v
    integer(8) :: a, b, c, x, y, z
    a = mod(v, m)
    b = m
    c = 0
    res = 1
    do while (b /= 0)
      x = b
      y = mod(a, b)
      z = res - a / b * c
      res = c
      a = x
      b = y
      c = z
    end do
    res = modulo(res, m)
  end
end program multiplication_4

Measured memory_bytes: 10512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    while (1) {
        int id;
        long long int ids[4000],n,cost,amount;
        bool exist = false;
        vector<int> num;
        cin >> n;
        if (n==0) break;
        for(int i=0;i<4000;i++) ids[i]=-1;
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(ids[id]==-1){
                num.push_back(id);
                ids[id]=0;
            }
            ids[id]+=cost*amount;
        }
        for(int i=0;i<num.size();i++){
            if(ids[num[i]]>=1000000){
                cout << num[i] << endl;
                exist = true;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1268
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n1=0, n9=0, n7=0, n4=0;
    for (int i = 0; i < 4; i++) {
        int n;
        cin >> n;
        if (n == 1) n1++;
        if (n == 9) n9++;
        if (n == 7) n7++;
        if (n == 4) n4++;
    }

    if (n1 * n9 * n7 * n4 == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli dp[1001][1001];

int main(){
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,k;
    cin>>n>>k;
    string st;
    cin>>st;
    for(lli i=0;i<n;i++){if(i!=k-1)cout<<st[i];else cout<<char(int(st[i])+32);}




	return 0;
 }

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    long long n,m,res=0;

    cin>>n>>m;

    if(n==1 && m==1)
    {
        cout<<"1"<<endl;
        return 0;
    }

    if(n>2 && m>2)res+=(n-2)*(m-2);

    if(n==1)
    {
        if(m==1)cout<<"0"<<endl;
        else cout<<m-2<<endl;

        return 0;
    }
    if(m==1)
    {
        if(n==1)cout<<"0"<<endl;
        else cout<<n-2<<endl;

        return 0;
    }

    cout<<res<<endl;

    return 0;
}


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

int main() {
  int K;
  cin >> K;
  
  if (K == 1 || K == 2 || K == 3 || K == 5 || K == 7 || K == 11 || K == 13 || K == 15 || K == 17 || K == 19 || K == 23 || K == 29 || K == 31) {
    cout << 1 << endl;
  } else if (K == 4 || K == 6 || K == 9 || K == 10 || K == 14 || K == 21 || K == 22 || K == 25 || K == 26) {
    cout << 2 << endl;
  } else if (K == 8 || K == 12 || K == 18 || K == 20 || K == 27) {
    cout << 5 << endl;
  } else if (K == 16) {
    cout << 14 << endl;
  } else if (K == 24) {
    cout << 15 << endl;
  } else if (K == 32) {
    cout << 51 << endl;
  } else {
    cout << 4 << endl;
  }
}


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

int main() {
  ll X;
  cin >> X;

  vector<ll> list(1, 0);
  ll a = 1;
  ll r;
  vector<ll>::iterator itr;
  while (true) {
    ll a5 = pow(a, 5);
    list.push_back(a5);
    ll p = X / a5;
    if (p > 1) {
      a++;
      continue;
    }

    if (p == 1) {
      r = X % a5;
    }
    if (p == 0) {
      r = X % a5 - a5;
      // break;
    }
    itr = find(list.begin(), list.end(), abs(r));
    if (itr != list.end()) break;
    a++;
  }

  auto index = distance(list.begin(), itr);  // absolutely exists
  auto b = r > 0 ? -index : index;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 4068
local n, a, b = io.read("*n", "*n", "*n")
local r = 0
for i = 1, n do
  local s = 0
  local j = i
  while j > 0 do
    s = s + (j % 10)
    j = j // 10
  end
  if a <= s and s <= b then
    r = r + i
  end
end
return print(r)

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



int main() {
  ll n;
  cin>>n;
  ll cnt=0;
  for(ll i=1;i<=sqrt(n);i++){
    if (n%i==0) cnt=max(cnt,i);
  }
  ll ans;
  ans=cnt+n/cnt-2;
  cout<<ans;



}


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

int a[100],b[100];

int main()
{
    int i,n,s=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        s+=max(0,a[i]-b[i]);
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 1000

void ISort(int A[],int N);

int main(void) {
    int A[MAX];
    int N, i;
    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");

    ISort(A, N);
}

void ISort(int a[],int n) {
  for(int i=1; i<n; ++i) {

      int v = a[i];
      int j = i-1;

      while(j >= 0 && a[j] > v) {
          a[j+1] = a[j];
          j--;
      }
      a[j+1] = v;

      for(int p=0; p<n; p++) {
        printf("%d", a[p]);
        if(p != n-1)
          printf(" ");
      }
      printf("\n");
  }
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		sc.close();

		int max = Math.max(Math.max(A, B), C);
		int count = 0;
		if(max == A) {
			count = 10 * A + B + C;
		}else if(max == B) {
			count = 10 * B + C + A;
		}else if(max == C) {
			count = 10 * C + A + B;
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;
  string W;
  cin >> W;
  for(int A=0; A<W.size(); A++){
      if(W[A]=='a') a += 1; if(W[A]=='b') b += 1; if(W[A]=='c') c += 1;
      if(W[A]=='d') d += 1; if(W[A]=='e') e += 1; if(W[A]=='f') f += 1;
      if(W[A]=='g') g += 1; if(W[A]=='h') h += 1; if(W[A]=='i') i += 1;
      if(W[A]=='j') j += 1; if(W[A]=='k') k += 1; if(W[A]=='l') l += 1;
      if(W[A]=='m') m += 1; if(W[A]=='n') n += 1; if(W[A]=='o') o += 1;
      if(W[A]=='p') p += 1; if(W[A]=='q') q += 1; if(W[A]=='r') r += 1;
      if(W[A]=='s') s += 1; if(W[A]=='t') t += 1; if(W[A]=='u') u += 1;
      if(W[A]=='v') v += 1; if(W[A]=='w') w += 1; if(W[A]=='x') x += 1;
      if(W[A]=='y') y += 1; if(W[A]=='z') z += 1;
  }if(a%2 == 1 || b%2 == 1 || c%2 == 1 || d%2 == 1 || e%2 == 1 || f%2 == 1 || g%2 == 1 || h%2 == 1 ||
      i%2 == 1 || j%2 == 1 || k%2 == 1 || l%2 == 1 || m%2 == 1 || n%2 == 1 || o%2 == 1 || p%2 == 1 ||
      q%2 == 1 || r%2 == 1 || s%2 == 1 || t%2 == 1 || u%2 == 1 || w%2 == 1 || x%2 == 1 || y%2 == 1 || z%2 == 1){
      cout << "No" << endl;
  }else{
      cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int m,a,b;
		bool f=true;
		vector<pair<pair<int,int>,int> > info;
		for(int i = 0; i < n; i++){
			cin>>m>>a>>b;
			info.push_back(make_pair(make_pair(a,b),m));
		}
		sort(info.begin(),info.end());
		int sum=0;
		// ¡»Ý´ÉæÁÄélðÇ
		vector<int> vec;
		for(int i = 0; i < info.size(); i++){
			int w=info[i].second;
			pair<int,int> p = info[i].first;
			for(int j = 0; j < vec.size(); j++){
				int num=vec[j];
				if(info[num].first.second<=p.first){
					sum-=info[num].second;
					vec.erase(find(vec.begin(),vec.end(),num));
					j--;
				}
			}
			vec.push_back(i);
			sum+=w;
			if(sum>150){
				f=false;
				cout<<"NG"<<endl;
				break;
			}
		}
		if(f)
			cout<<"OK"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
# 文字列 hi が 1 個以上繋がってできる文字列を、 hitachi文字列 と定義します。
# 例えば、 hi や hihi などは hitachi文字列 であり、 ha や hii は hitachi文字列 ではありません。
# 文字列 S が与えられるので、 S が hitachi文字列 かどうかを判定してください。

s = gets.chomp
result = true

i = 0
while i < s.length
    if !(s[i] == "h" && s[i+1] == "i")
        result = false
        break
    end
    i += 2
end

if result
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll ans = 0;
    ll flag = 0;
    for(ll i=0;i<n;++i){
        if(a[i] <= b[i]){
            ans += a[i];
            b[i] -= a[i];
            if(a[i+1] <= b[i]){
                ans += a[i+1];
                a[i+1] = 0;
            }else{
                ans += b[i];
                a[i+1] -= b[i];
            }
        }else{
            ans += b[i];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 # 必須
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
if(c>0 and c<13 and d==0):
    print("MMYY")
if(c==0 and d>0 and d<13):
    print("YYMM")
if(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
if(c>0 and c<13 and d>12):
    print("MMYY")
if(c>12 and d>0 and d<13):
    print("YYMM")
if(c>12 and d>12):
    print("NA")
if(c>12 and d==0):
    print("NA")
if(c==0 and d>12):
    print("NA")

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int A;
  cin >> N; cin >> A;
  if(N%500 <= A) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float hight;
	float max, min;
	float ans;
	int count = 0;
	
	while (scanf("%f", &hight) != EOF){
		if (count == 0){
			max = min = hight;
			count++;
		}
		else {
			if (hight > max){
				max = hight;
			}
			if (hight < min){
				min = hight;
			}
		}
	}
	
	ans = max - min;
	
	printf("%.1f\n", ans);
	
	return (0);
}

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

int N, M;
signed main() {
    cin >> N >> M;
    vint A(N);
    priority_queue<int> pq;
    rep(i, N) { cin >> A[i], pq.push(A[i]); }
    rep(i, M) {
        int cur = pq.top();
        pq.pop();
        pq.push(cur / 2);
    }
    int ans = 0;
    rep(i, N) { ans += pq.top(), pq.pop(); }
    cout << ans << endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n;cin>>n;
    vector<int>h(n);
    rep(i,n){
        cin>>h[i];
    }

    int cnt=0,max=0;
    rep(i,n-1){
        if(h[i]>=h[i+1]){
            cnt++;
            if(cnt>max){
                max=cnt;
            }
        }
        else {
            if(cnt>max){
                max=cnt;
            }
            cnt=0;

        }
    }
    cout<<max<<endl;
}



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

int main(void) {
    int K, answer;
    cin >> K;
    if(K % 2 == 0) {
        answer = K * K / 4;
    } else {
        answer = (K - 1) * (K + 1) / 4;
    }   
    cout << answer << endl;

    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    map<char, lint> mp;
    rep(i, n){
        string s; cin >> s;
        mp[s[0]] += 1;
    }

    string t = "MARCH";
    lint res = 0;
    rep(i, 32){
        vector<lint> v;
        rep(l, 5){
            if(i & (1<<l)) v.push_back(mp[t[l]]);
        }
        if(v.size() != 3) continue;
        res += v[0] * v[1] * v[2];
    }
    out(res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int T;
    cin >> T;
    while(T--){
        array<int, 9> a, b;
        REP(i, a.size()) cin >> a[i];
        REP(i, b.size()) cin >> b[i];
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        const int MAX = 19 * 9;
        double dp[1 << 9][MAX + 1] = {};
        dp[0][0] = 1;
        for(int s = 0; s < (1 << 9); s++){
            int k = __builtin_popcount(s);
            for(int t = 0; t < MAX; t++){
                if(dp[s][t] == 0.0) continue;
                for(int i = 0; i < 9; i++) if(!(s >> i & 1)) {
                    int ns = s | (1 << i);
                    int nt = t + (a[k] <= b[i] ? a[k] + b[i] : 0);
                    dp[ns][nt] += dp[s][t] * 1.0 / (9 - k);
                }
            }
        }
        double win_a = 0.0;
        double win_b = 0.0;
        for(int j = 0; j <= MAX; j++){
            int i = MAX - j;
            if(i >= j) win_a += dp[(1 << 9) - 1][j];
            else       win_b += dp[(1 << 9) - 1][j];
        }
        printf("%.5f %.5f\n", win_a, win_b);
    }
    return 0;
}

Measured memory_bytes: 1880
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


  
int main() {
  int N;
  cin >> N;
  vp xy(N);
  rep(i,N) {
    cin >> xy[i].first >> xy[i].second;
  }
  double xl = -1010,xr = 1010;
  rep(xk,100) {
    double x1 = (xl*2+xr)/3;
    double yl1 = -1010,yr1 = 1010;
    rep(yk,100) {
      double y1 = (yl1*2+yr1)/3;
      double r1 = 0;
      rep(i,N) {
        r1 = max(r1,sqrt((x1-xy[i].first)*(x1-xy[i].first) + (y1-xy[i].second)*(y1-xy[i].second)));
      }
      double y2 = (yl1+yr1*2)/3;
      double r2 = 0;
      rep(i,N) {
        r2 = max(r2,sqrt((x1-xy[i].first)*(x1-xy[i].first) + (y2-xy[i].second)*(y2-xy[i].second)));
      }
      if(r1 < r2) {
        yr1 = y2;
      } else {
        yl1 = y1;
      }
    }
    double rr1 = 0;
    rep(i,N) {
      rr1 = max(rr1,sqrt((x1-xy[i].first)*(x1-xy[i].first) + (yl1-xy[i].second)*(yl1-xy[i].second)));
    }

    double x2 = (xl+xr*2)/3;
    double yl2 = -1010,yr2 = 1010;
    rep(yk,100) {
      double y1 = (yl2*2+yr2)/3;
      double r1 = 0;
      rep(i,N) {
        r1 = max(r1,sqrt((x2-xy[i].first)*(x2-xy[i].first) + (y1-xy[i].second)*(y1-xy[i].second)));
      }
      double y2 = (yl2+yr2*2)/3;
      double r2 = 0;
      rep(i,N) {
        r2 = max(r2,sqrt((x2-xy[i].first)*(x2-xy[i].first) + (y2-xy[i].second)*(y2-xy[i].second)));
      }
      if(r1 < r2) {
        yr2 = y2;
      } else {
        yl2 = y1;
      }
    }
    double rr2 = 0;
    rep(i,N) {
      rr2 = max(rr2,sqrt((x2-xy[i].first)*(x2-xy[i].first) + (yl2-xy[i].second)*(yl2-xy[i].second)));
    }
    if (rr1 < rr2) {
      xr = x2;
    } else {
      xl = x1;
    }
  }
  double ans = INF;
  double yl1 = -1010,yr1 = 1010;
  rep(yk,100) {
    double y1 = (yl1*2+yr1)/3;
    double r1 = 0;
    rep(i,N) {
      r1 = max(r1,sqrt((xl-xy[i].first)*(xl-xy[i].first) + (y1-xy[i].second)*(y1-xy[i].second)));
    }
    double y2 = (yl1+yr1*2)/3;
    double r2 = 0;
    rep(i,N) {
      r2 = max(r2,sqrt((xl-xy[i].first)*(xl-xy[i].first) + (y2-xy[i].second)*(y2-xy[i].second)));
    }
    
    if(r1 < r2) {
      yr1 = y2;
      ans = min(ans,r1);
    } else {
      yl1 = y1;
      ans = min(ans,r2);
    }
  }
  cout << setprecision(16) << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if (a > b)  a = b; }

int a[1000000][5];
int dp[1000000][5];

signed main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	rep(i, N) rep(j, 3) cin >> a[i][j];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	int ans = 0;
	rep(i, 3) chmax(ans, dp[N][i]);
	cout << ans << endl;
	return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    REP(i, N) {
        int a;
        cin >> a;
        X += 1 + (D - 1)/a;
    }
    cout << X << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
lli A, B;

void ReadInput()
{
    cin >> A >> B;
}

lli GCD(lli a, lli b)
{
    while(b != 0)
    {
        lli r = a % b;
        a = b;
        b = r;
    }
    return a;
}

void Solve()
{
    lli x = GCD(A, B);
    int ans = 1;
    for(int i = 2; 1LL * i * i <= x; ++i)
        if(x % i == 0)
        {
            ++ans;
            while(x % i == 0)
                x /= i;
        }
    if(x > 1) ++ans;
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
	int sum=0;
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	rep(i,a.size())sum+=a[i];
	
	
	vector<int> v(n);
	rep(i,n-1){
		v[i] = a[i+1]-a[i];
	}
	v[n-1]=a[0]-a[n-1];

	int t = n*(n+1)/2;
	if(sum%t!=0){
		cout<<"NO"<<endl;
		return 0;
	}
	
	int x = sum/t;
	
	
	rep(i,v.size()){
		v[i]-=x;
		v[i]=-1*v[i];
	}
	
	int times=0;
	rep(i,v.size()){
		if(v[i]<0||v[i]%n!=0){
			cout<<"NO"<<endl;
			return 0;
		}
		times+=v[i]/n;
	}
	if(times==x)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll A, B, N; cin >> A >> B >> N;
    ll l = min(N, B - 1);
    pt((A * l) / B - A * (l / B));
}

Measured memory_bytes: 3596
import heapq

N=int(input())
A=[]
B=[]
heapq.heapify(B)
for _ in range(N):
    a=int(input())
    A.append(a)
    heapq.heappush(B,-a)

X=-heapq.heappop(B)
Y=-heapq.heappop(B)

for i in range(N):
    if A[i]==X:
        print(Y)
    else:
        print(X)

Measured memory_bytes: 100740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define ar array
#define N 100005
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//list of functions: set.insert(val), *(set.find_by_order(order-1)), set.order_of_key(val)

using namespace __gnu_pbds;
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int prev = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += max(a[i], prev) - a[i];
        prev = max(prev, a[i]);
    }
    cout<<ans;
    return 0;
}


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

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<algorithm>
int v[1024*1024];
void Init(){memset(v,-1,sizeof(v));}
int Root(int x)
{
	return v[x]<0 ? x : v[x]=Root(v[x]);
}
void Link(int x, int y)
{
	x=Root(x);
	y=Root(y);
	if(x-y)
	{
		if(v[x]>v[y])std::swap(x,y);
		v[x]+=v[y];
		v[y]=x;
	}
}

const char FLOOR = '.';
char m[1024][1024];
int ID(int x, int y, int w)
{
	return y*w+x;
}
void UnionFloor(int x,int y,int w)
{
	const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	if(m[y][x]!=FLOOR)return;
	for(int i=0;i<4; ++i)
	{
		int ax = x+dx[i];
		int ay = y+dy[i];
		if(m[ay][ax]!=FLOOR)continue;
		Link(ID(x,y,w),ID(ax,ay,w));
	}
}
int main()
{
	int w,h,x,y,gx,gy;
	memset(m,0,sizeof(m));
	scanf("%d%d",&w,&h);
	for(y=1;y<=h;++y)
	{
		scanf("%s",&m[y][1]);
		char *p=strchr(&m[y][1],'t');
		if(p)
		{
			gx=p-m[y];
			gy=y;
			*p=FLOOR;
		}
	}
	Init();
	for(y=1;y<=h;++y)
		for(x=1;x<=w;++x)
			UnionFloor(x,y,w);
	if(Root(ID(1,1,w))==Root(ID(gx,gy,w)))
	{
		puts("0");
		return 0;
	}
	int N, res=-1;
	scanf("%d",&N);
	for(int i=0; i<N; ++i)
	{
		scanf("%d%d",&x,&y);
		++x,++y;	//1-org
		m[y][x]=FLOOR;
		UnionFloor(x,y,w);


		if(Root(ID(1,1,w))==Root(ID(gx,gy,w)))
		{
			res=i+1;
			break;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 6164
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

string s;
int main()
{
    double a,b,c,i,j,k,n,d;
    while(scanf("%lf%lf",&a,&b)==2)
    {
        c=0;
        if(a<=b)
        {
            k=0;
            for(i=1;i<=a&&i<b;i++)
            {
                j=i;
                k=1;
                while(j<b)
                {
                    j*=2;
                    k*=1.0/2;
                }
                c+=k*1.0/a;
            }
            if(a==b)
            {k=1.0/b;c+=k;}
        }
        else
        {
            for(i=1;i<b;i++)
            {
                j=i;
                k=1;
                while(j<b)
                {
                    j*=2;
                    k*=1.0/2;
                }
                c+=k*1.0/a;
            }
            d=(a-b+1)/a*1.0;
            c+=d;
        }
        printf("%.9lf\n",c);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,k,x,ans;
int32_t main(){
CODE_START;
cin>>n;
cin>>k;
for(ll i=0;i<n;i++)
{
    cin>>x;
    if(x>=k){
        ans++;
    }
}
cout<<ans<<endl;
}



Measured memory_bytes: 384
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

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

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x);
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(x);
    inn(a);
    if (x < a) out(0);
    else out(10);
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


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

#define FOR(x,y) for(int i=x; i<y; ++i)
#define FORR(x,y) for(int i=y-1; i>=x; i--)

typedef long long ll;

using namespace std;

int main() {
    ll N; cin >> N;
    ll n = N;
    ll ds = 0;
    while(n > 0){
        ds += n%10;
        n /= 10;
    }
    if(N%ds == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define N 500
int width[N][N];
char m[N][N+1];

int solve(int r,int c){
  rep(i,r){
    width[i][0]=m[i][0]=='.'?1:0;
    REP(j,1,c)width[i][j]=m[i][j]=='*'?0:width[i][j-1]+1;
  }
  int ret=0,minwidth;
  rep(j,c){
    rep(i,r){
      minwidth=width[i][j];
      ret=max(ret,minwidth);
      REP(k,i+1,r&&minwidth){
	minwidth=min(minwidth,width[k][j]);
	ret=max(ret,(k-i+1)*minwidth);
      }
    }
  }
  return ret;
}

main(){
  int r,c;
  while(cin>>r>>c && r){
    rep(i,r)cin>>m[i];
    cout << solve(r,c)<<endl;
  }
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    string t;
    cin>>t;
    int dp[s.size()+1][t.size()+1];
    for (int i=0;i<=t.size();i++) dp[0][i]=0;
    for (int i=1;i<=s.size();i++){
        dp[i][0]=0;
        for (int j=1;j<=t.size();j++){
            if(s[i-1]==t[j-1])
                dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j-1]);
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    int i=s.size();
    int j=t.size();
    while (i>0 or j>0){
        if(i>0 and j>0){
            if(dp[i-1][j]==dp[i][j]) i--;
            else if(dp[i][j-1]==dp[i][j]) j--;
            else{
                ans+=s[i-1];
                i--;
                j--;
            }
        }
        else if(i>0)
            i--;
        else 
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 35456
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int hour,mi,sec;
	while(cin>>hour>>mi>>sec){
		if(hour==-1&&mi==-1&&sec==-1){
			break;
		}
		int sum =hour*60*60+mi*60+sec;
		int sum1 =(hour*60*60+mi*60+sec);
		sum =2*60*60-sum;
		sum1=2*60*60-sum1;
		sum1 *=3;
		printf("%02d:%02d:%02d\n",sum/(60*60),(sum%(60*60)/60),sum%60);
		printf("%02d:%02d:%02d\n",sum1/(60*60),(sum1%(60*60)/60),sum1%60);

	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int ans,sum;
void count_sum(int i,int s,int n){
  if(s==sum && n==0){ans++;return ;}
  if(i==10 || n==0)return ;

  count_sum(i+1,s+i,n-1);
  count_sum(i+1,s,n);
}

int main(){
  int n;
  while(1){
    scanf("%d %d",&n,&sum);
    if(n==0 && sum==0)break;

    count_sum(0,0,n);
    printf("%d\n",ans);
    ans=0;
  }
  return 0;
}

Measured memory_bytes: 600
n = int(input())
a_arr = list(map(int,input().split()))
b_arr = [0]*n

for i in range(n):
    b_arr[0] += (-1)**(i%2)*a_arr[i]

for i in range(1,n):
    b_arr[i] = 2*a_arr[i-1] - b_arr[i-1]

print(*b_arr)

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 2e5 + 55;

int n, m;
bool to1[maxN], ton[maxN];

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

	cin >> n >> m;

	for(int i = 0; i < m; i++){
		int u, v;	cin >> u >> v;
		if(u == 1){
			to1[v] = true;
		}
		if(v == 1){
			to1[u] = true;
		}
		if(u == n){
			ton[v] = true;
		}
		if(v == n){
			ton[u] = true;
		}
	}

	for(int i = 2; i < n; i++){
		if(to1[i] && ton[i]){
			cout << "POSSIBLE\n";
			return 0;
		}
	}

	cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 640