akhauriyash/Code-Regression huggingface dataset:
package main

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

type Int2DList [][]int
type IntList []int

func (a Int2DList) ChMax(i, j int, value int) bool {
	curV := a[i][j]
	if curV < value {
		a[i][j] = value
		return true
	}
	return false
}
func lib_MaxInt(values ...int) (max int, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	max = values[0]
	for _, value := range values {
		if max < value {
			max = value
		}
	}
	return
}
func lib_MustMaxInt(values ...int) (max int) {
	max, err := lib_MaxInt(values...)
	if err != nil {
		panic(err)
	}
	return max
}
func lib_NewInt2DList(length1, length2 int, initialValue int) Int2DList {
	ret := make([][]int, length1, length1)
	for i := 0; i < length1; i++ {
		ret[i] = lib_NewIntList(length2, initialValue)
	}
	return ret
}
func lib_NewIntList(length int, initialValue int) IntList {
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	tempN, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	N = int(tempN)
	var W int
	scanner.Scan()
	tempW, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	W = int(tempW)
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		tempw, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		w[i] = int(tempw)
		scanner.Scan()
		tempv, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		v[i] = int(tempv)
	}
	fmt.Println(solve(N, W, w, v))
}
func solve(N int, W int, w []int, v []int) int {
	list := lib_NewInt2DList(N+100, W+100, 0)
	for i := 0; i < N; i++ {
		for curW := 0; curW <= W; curW++ {
			list.ChMax(i+1, curW, list[i][curW])
			if newW := curW + w[i]; newW <= W {
				list.ChMax(i+1, newW, list[i][curW]+v[i])
			}
		}
	}
	return lib_MustMaxInt(list[N]...)
}


Measured memory_bytes: 162432
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] as = new int[n];
		
		for(int i=0; i<as.length; i++) {
			as[i] = sc.nextInt()-1;
		}
		sc.close();
		
		int count = 0;
		int light = 0;
		
		for(int i=0; i<as.length; i++) {
			count += 1;
			light = as[light];
			
			if(light == 1) {
				break;
			}
		}
		
		if(count == as.length) {
			System.out.println(-1);
		}else {
			System.out.println(count);
		}

	}

}


Measured memory_bytes: 50920
#include <cstdio>
using namespace std;
char s[10];
int main(){
	int i;
	
	scanf("%s", s);
	for(i=0; s[i]; i++){
		if(s[i]=='A' && s[i+1]=='C'){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
N, M = gets.split.map(&:to_i)
tmp = Hash.new { |k, v| k[v] = [] }
while line = gets
  a, b = line.chomp.split.map(&:to_i)
  tmp[a] << b
  tmp[b] << a
end
(1..N).each do |i|
  p tmp[i].count
end

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int ruijou(int);

int main(){
  char a;
  string data;
  int ans=0;

  while(getline(cin,data)){
    for(int i=0;;i++){
      int j;
      if(data[i]=='\0') break;
      if(data[i]=='-'){
        for(j=i+1;;j++){
          if(data[j]<'0' || data[j]>'9') break;
        }
        i=j;
        if(data[i]=='\0') break;
      }
      if(data[i] >= '0'&& data[i]<= '9'){
        string temp;
        temp+=data[i];
        for(j=i+1;;j++){
          if(data[j]<'0' || data[j]>'9') break;
          temp+=data[j];
        }
        i=j-1;
        int l;
        l=temp.size();
        for(j=0;j<l;j++){
          ans+=ruijou(l-j-1)*(temp[j]-'0');
        }
      }
    }
  }

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

int ruijou(int a){
  int i, sum=1;

  for(i=0;i<a;i++){
    sum*=10;
  }

  return sum;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N ;
    cin >> N ;
    int a[N] ;
    for(int i = 0; i < N ; i++)
      cin >> a[i] ;
    
    bool jud = true ;
    for(int j = 0; j < N ; j++){
        if(a[j]%2 == 0){
            if(a[j]%3 !=0){
                if(a[j]%5 !=0){
                jud =false ;
                }
            }
        }
    }

    if(jud == true){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
hitatistr = input()
count = 0
flag = "ok"
for i in hitatistr:
  if count % 2 == 0:
    if i != "h":
      flag = "ng"
      break
  else:
    if i != "i":
      flag = "ng"
  count = count + 1
if flag == "ok" and count >= 2 and count % 2 == 0:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<limits.h>
using namespace std;

int ans[100000];
int sum;
vector<int>rinsetu[100000];
bool used[100000];
bool S;
void DFS(int a) {
	used[a] = true;
	for (int i : rinsetu[a]) {
		if (!used[i]) {
			if (!S) {
				DFS(i);
				ans[sum] = i + 1;
				sum++;
			}
			else {
				ans[sum] = i + 1;
				sum++;
				DFS(i);
			}
			return;
		}
	}
}
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	for (int c = 0; c < b; c++) {
		int d, e; scanf("%d%d", &d, &e);
		d--; e--;
		rinsetu[d].push_back(e);
		rinsetu[e].push_back(d);
	}
	DFS(0);
	ans[sum] = 1;
	sum++;
	S = true;
	DFS(0);
	printf("%d\n", sum);
	for (int i = 0; i < sum; i++) {
		if (i)printf(" ");
		printf("%d", ans[i]);
	}
	puts("");
}

Measured memory_bytes: 8192
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            double L = double.Parse(Console.ReadLine());
            double tate = L/3.000000000000;
            double yoko = L/3.000000000000;

            double takasa = L - tate - yoko;

            double taiseki = tate * yoko * takasa;

            Console.WriteLine(string.Format("{0:f12}",taiseki));
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int k, s, x, y, cnt = 0;
    cin >> k;
    cin >> s;

    for (x = 0; x <= k; x++) {
        for (y = 0; y <= k; y++) {
                if(s-x-y >= 0 && s-x-y <= k)  
                    cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  string ans;
  while(N){
    N--;
    ans.pb('a' +  N % 26);
    N /= 26;
  }
  reverse(ans.begin() , ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> sina(110);
  for(int i = 0; i < N; i++){
cin >> sina[i];

  }
sort(sina.begin(), sina.end());
reverse(sina.begin(), sina.end());

int zen = 0;

for(int i = 0; i < N; i++){
zen += sina[i];
}
bool check = 1;
for(int i = 0; i < M; i++){
if(sina[i]*(4*M) < zen) check = 0;
}

if(check == 0) cout << "No" << endl;
else cout << "Yes" << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <bitset>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N;
    cin >> N;
    string s,t;
    cin >> s >> t;
    string ss,tt;
    int count=N,ans=INF; 
    while(1){
        ss = s.substr(N-count,count);
        tt = t.substr(0,count);
        if(ss == tt)break;
        count--;
    }
    cout << 2*N-count << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	fmt.Println(N / 3)
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 1772
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 30

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

#define VERTEX_MAX 100000
#define EDGE_MAX 500000
// [# of heads(: VERTEX_MAX)] + [# of elems( <= EDGE_MAX)]
#define POOL_MAX (VERTEX_MAX+EDGE_MAX+10)
#define WEIGH_MAX 0x3f3f3f3f

struct edge {
    int src;
    int dst;
    int cost;
};

int main(void) {
    int vs, es, start;
    get_int3(&vs, &es, &start);
    struct edge edges[EDGE_MAX];
    int i;
    for(i = 0; i < es; i++) {
        struct edge *e = &edges[i];
        get_int3(&e->src, &e->dst, &e->cost);
    }
    // initialization
    int min_dist[VERTEX_MAX];
    memset(min_dist, 0x3f, VERTEX_MAX*sizeof(int));
    min_dist[start] = 0;
    while(1) {
        int updated = 0;
        for(i = 0; i < es; i++) {
            struct edge *e = &edges[i];
            if(min_dist[e->src] == WEIGH_MAX) continue;
            int new = min_dist[e->src] + e->cost;
            if(new < min_dist[e->dst]) {
                min_dist[e->dst] = new;
                updated = 1;
            }
        }
        if(!updated) break;
    }
    for(i = 0; i < vs; i++) {
        if(min_dist[i] == WEIGH_MAX) {
            printf("INF\n");
        } else {
            printf("%d\n", min_dist[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 7844
#include "bits/stdc++.h"
using namespace std;
int ths[100020] = {};
int main() {
	int n;
	cin >> n;
	vector<vector<int>>s(100020);
	vector<tuple<int, int>>w;
	int numbers[100020] = {};
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		s[a].push_back(b);
		s[b].push_back(a);
		numbers[a]++;
		numbers[b]++;
		w.emplace_back(a, b);
	}
	int ans = 0;
	int bignumber = 0;
	for (int i = 1; i <= n; i++) {
		if (numbers[i] > ans) {
			bignumber = i;
			ans = numbers[i];
		}
	}
	queue<int> q;
	map<tuple<int,int>,int>k;
	int seen[100020] = {};
	seen[bignumber] = 0;
	q.push(bignumber);
	while (q.size()) {
		int t = q.front();
		q.pop();
		for (int c : s[t]) {
			if (seen[c] == 0) {
				
				q.push(c);
				seen[t]++;
   				if (seen[t] == ths[t]) {
					seen[t]++;
				}
				k[make_tuple(t, c)] = seen[t];
				ths[c] = seen[t];
			}
		}
	}
	cout << ans << endl;
	for (int i = 0; i < n - 1; i++) {
		int a = get<0>(w[i]);
		int b = get<1>(w[i]);
		if (k[make_tuple(a, b)]) {
			cout << k[make_tuple(a, b)] << endl;
		}
		else {
			cout << k[make_tuple(b, a)] << endl;
		}
	}
}

Measured memory_bytes: 14196
#include<bits/stdc++.h> 
#define ll long long
using namespace std;
char b[500010];	int len = 0;
struct node{
	int sum;	char x;
};
node a[500010];
int main() {
	scanf("%s", b);
	int n = strlen(b);
	a[len].x = b[0];	a[len].sum = 1;
	for (int i = 1; i < n; i++) {
		if (b[i] == a[len].x) a[len].sum++;
		else {
			a[++len].sum = 1;
			a[len].x = b[i];
		}
	}
	ll t = 0;	ll ans = 0;
	for (int i = 0; i <= len; i++) {
		if (a[i].x == '<') {
			ans = ans + 1ll*a[i].sum*(a[i].sum+1)/2;
			t = a[i].sum;
		}
		else {
			if (a[i].sum > t) {
				ans = ans - t;
				ans = ans + 1ll*(a[i].sum+1)*a[i].sum/2;
			}
			else{
				ans = ans + 1ll*(a[i].sum+1)*a[i].sum/2 - a[i].sum;
			}
			t = 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4480
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    ll h,n;
    cin>>h>>n;
    ll a[n],b[n];
    ifr(i,0,n) cin>>a[i]>>b[i];
    ll dp[n][h+1],pre;
    ifr(i,0,n) ifr(j,0,h+1) dp[i][j]=inf;
    ifr(i,1,h+1) dp[0][i] = ((i-1)/a[0] +1)*b[0];
    ifr(i,1,n) {
        ifr(j,1,h+1) {
            pre = inf;
            if(j-a[i]>=0) pre=dp[i][j-a[i]];
            if(pre==inf && j-a[i]>=0) pre=dp[i-1][j-a[i]];
            if(pre==inf) pre = (j-1)/a[i] * b[i];
            dp[i][j]=min(dp[i-1][j],pre+b[i]);
        }
    }
    cout<<dp[n-1][h]<<endl;
    return 0;
}

Measured memory_bytes: 78464
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,X,T;

LL ans = 0;

void solve(){
	LL takoyaki = 0;
	while(takoyaki<N){
		takoyaki += X;
		ans += T;
	}
}

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

    solve();

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

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

int main()
{
  vector<int> nums;
  char c;
  for (int i = 0; i < 4; i++) {
    cin >> c;
    nums.push_back(c - '0');
  }
  
  bitset<3> found_bit;
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> bit(tmp);
    int calc_result = nums.at(0);
    for (int i = 1; i < 4; i++) {
      if (bit.test(i - 1)) {
        calc_result += nums.at(i);
      } else {
        calc_result -= nums.at(i);
      }
    }
    if (calc_result == 7) {
      found_bit = bit;
    }
  }
  
  cout << nums.at(0);
  for (int i = 1; i < 4; i++) {
    if (found_bit.test(i - 1)) {
      cout << "+";
    } else {
      cout << "-";
    }
    cout << nums.at(i);
  }
  cout << "=7" << endl;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

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

    int N;
    cin >> N;
    vector<bool> isprime(N + 1, true);
    vector<int> prime;
    for (int i = 2; i <= N; i++) {
        if (isprime[i]) {
            for (int j = 2; i * j <= N; j++) {
                isprime[i * j] = false;
            }
        }
    }
    for (int i = 2; i <= N; i++) {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }
    const int n = prime.size();
    vector<int> ind(n, 0);
    for (int i = 0; i < n; i++) {
        const int p = prime[i];
        int num = N;
        while (num > 0) {
            ind[i] += num / p;
            num /= p;
        }
    }
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans = ans * (ind[i] + 1);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n,m;cin>>n>>m;
  int a[n];  //price
  int b[n];  //count

  vector<pair<int, int>> x;
  rep(i, n){
    int a,b;cin>>a>>b;
    dump(a,b);
    x.pb(mp(a,b));
  }
  sort(all(x));
  dump(x);

  int r = m;
  int res = 0;
  rep(i, n){
    int p = x[i].first;
    int c = x[i].second;
    if (r > c) {
      res += p*c;
      r -= c;
    }
    else{
      res += p*r;
      break;
    }
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2420
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	ll res = 0;
	ll now; cin >> now;
	rep(i, n - 1)
	{
		ll a; cin >> a;
		res += max(0LL, now - a);
		chmax(now, a);
	}
	cout << res << endl;
}

Measured memory_bytes: 3632
import math

def primefactor(n):
    r = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            r += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : r += [n]
    return r

N = int(input())
M = math.factorial(N)
D = 10**9+7

c = {}
for i in primefactor(M):
    if i in c:
        c[i] += 1
    else:
        c[i] = 2
ans = 1
for k, v in c.items():
    ans = (ans * v) % D
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> P;


struct unionfind {
    vector<ll> par;
    vector<ll> sizes;

    unionfind(ll n) : par(n),sizes(n,1){
        rep(i,0,n) par[i] = i;
    }

    ll root(ll x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x,ll y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(sizes[x] < sizes[y] ) swap(x,y);

        par[y] = x;
        sizes[x] += sizes[y];

        return;
    }

    bool same(ll x,ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return sizes[root(x)];
    }
};


int main(){
  ll n,m;
  cin >> n >> m;
  unionfind uf(n);

  P bridges[m];
  ll ans[m];

  ans[m-1] = n*(n-1)/2;

  rep(i,0,m){
    ll a,b;
    cin >> a >> b;

    bridges[m-i-1].fs = a-1;
    bridges[m-i-1].sc = b-1;
  }
  
  rep(i,0,m-1){

    if(uf.root(bridges[i].fs) == uf.root(bridges[i].sc)) ans[m-i-2] = ans[m-i-1];
    else ans[m-i-2] = max(ans[m-i-1] - uf.size(bridges[i].fs)*uf.size(bridges[i].sc) ,0LL);

    //cout << ans[m-i-1] << " " <<  uf.size(bridges[i].fs) << " " << uf.size(bridges[i].sc) << endl;

    uf.unite(bridges[i].fs,bridges[i].sc);

  }

  rep(i,0,m){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 5248
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

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

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	if N == 1 {
		fmt.Println("Hello World")
	} else {
		A, B := sc.nextInt(), sc.nextInt()
		fmt.Println(A + B)
	}
}


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

int main(){
  int n;
  cin >> n;
  int cnt1 = 0, cnt4 = 0;
  bool cnt2 = false;
  for(int i=0; i<n; ++i){
    int ai;
    cin >> ai;
    if(ai%4 == 0) ++cnt4;
    else if(ai%2 == 0) cnt2 = true;
    else ++cnt1;
  }
  if(cnt2) ++cnt1;
  if(cnt1 > cnt4+1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

i = 0
while i < K:
    if i%2 == 0:
        if A%2 == 1:
            A -= 1
        AtoB = int(A/2)
        A = A - AtoB 
        B = B + AtoB 
    else:    
        if B%2 == 1:
            B -= 1
        BtoA = int(B/2)
        A = A + BtoA 
        B = B - BtoA
    i += 1
print(str(A) + ' ' + str(B))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

const int MAX_N = 1e5 + 10 ;

char s[MAX_N] ;
bool com[MAX_N] ;
int len , cnt , num[MAX_N] , s1[MAX_N] , s2[MAX_N] ;

bool check(int x) {
	for (int i = 0 ; i < cnt ; ++i) com[i] = 0 ;

	for (int i = 0 ; i < cnt ; ++i) {
		int tmp ;

		tmp = s1[i] - num[i] ;
		if (s1[i] >= x && (tmp >= x || !tmp)) com[i] = 1 ;

		tmp = s2[i] - num[i] ;
		if (s2[i] >= x && (tmp >= x || !tmp)) com[i] = 1 ;
	}

	for (int i = 0 ; i < cnt ; ++i) {
		if (com[i]) continue ;

		if (s1[i] >= x) return 1 ;
		else break ;
	}

	for (int i = cnt - 1 ; i >= 0 ; --i) {
		if (com[i]) continue ;

		if (s2[i] >= x) return 1 ;
		else return 0 ;
	}

	return 1 ;
}

int main() {
	scanf("%s" , s) ;
	len = strlen(s) ;

	///

	char last = s[0] ; int sum = 0 ;
	for (int i = 0 ; i < len ; ++i)
		if (s[i] == last) ++sum ;
		else {
			last = s[i] ;
			num[cnt++] = sum ; sum = 1 ;
		}
	num[cnt++] = sum ;

	s1[0] = num[0] ; s2[cnt - 1] = num[cnt - 1] ;
	for (int i = 1 ; i < cnt ; ++i) s1[i] = s1[i - 1] + num[i] ;
	for (int i = cnt - 2 ; i >= 0 ; --i) s2[i] = s2[i + 1] + num[i] ;

	///

	int L = 1 , R = len + 1 ;
	while (L + 1 < R) {
		int mid = (L + R) >> 1 ;
		if (check(mid)) L = mid ;
		else R = mid ;
	}

	printf("%d\n" , L) ;

	return 0 ;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;

int n, m;

vector<bool> visited(50);
vector<vector<bool>> d(50, vector<bool>(50));

void dfs(int k) {
  visited[k] = true;
  for (int i = 0; i < n; i++) {
    if (d[k][i] == false) continue;
    if (visited[i] == true) continue;
    dfs(i);
  }
}

int main() {
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = true;
  }

  int ans = 0;

  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = d[b[i]][a[i]] = false;
    for (int j = 0; j < n; j++) {
      visited[j] = false;
    }
    dfs(0);
    bool bridge = false;
    for (int j = 0; j < n; j++) {
      if (visited[j] == false) bridge = true;
    }
    if (bridge) ans++;
    d[a[i]][b[i]] = d[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;


//ここから編集する


struct edge {
    int to;
    ll cost;
};
typedef pair<ll, int> P;

int V;
vector<edge> G[100005];
ll INF = 922337203685477580;
ll dd[100005];
void dijkstra(int s) {
    ll dd2[100005];


    priority_queue<P, vector<P>, greater<P>> que;
//    fill(d, d + V, INF);
    for(int i = 0; i <= V; i++){
        dd2[i] = INF;
    }
    dd2[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dd2[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (dd2[e.to] > dd2[v] + e.cost) {
                dd2[e.to] = dd2[v] + e.cost;
                que.push(P(dd2[e.to], e.to));
            }
        }
    }
    for(int i = 0; i <= V; i++){
        dd[i] = dd2[i];
    }

}

int main() {
    int n;
    cin >> n;
    V = n;
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edge e;
        e.to = a;
        e.cost = c;
        G[b].push_back(e);
        e.to = b;
        G[a].push_back(e);
    }
    int q, k;
    cin >> q >> k;
    dijkstra(k);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        ll ans;
        ans = dd[x] + dd[y];
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int n=0;
	string str;
	cin >> n;
	cin >> str;

	int suraCnt = 1;
	char checkStr = str[0];
	for (int i = 1; i < str.size(); ++i) {
		if (checkStr != str[i]) {
			checkStr = str[i];
			suraCnt++;
		}
	}

	cout << suraCnt;
	return 0;
}

Measured memory_bytes: 512
n, x, y = map(int, input().split())

result = [0 for _i in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        le = min([j-i, abs(i-x)+1+abs(j-y), abs(i-y)+abs(j-y)])
        result[le] += 1
for i in result[1:]:
    print(i)

Measured memory_bytes: 3444
/*
ID: kiwio
LANG: C++14
TASK: 
*/
 
#include <bits/stdc++.h>
using namespace std;
 
int n, x[200005], lo, hi, fake[200005];
 
int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);/*
#ifndef turtle
	ofstream cout (".out");
	ifstream cin (".in");
#endif*/
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> x[i];
		fake[i]=x[i];
	}
	sort(fake+1, fake+n+1);
	lo=fake[n/2];
	hi=fake[n/2+1];
	for (int i=1; i<=n; i++) {
		if (x[i]>lo) {
			cout << lo << endl;
		}
		else {
			cout << hi << endl;
		}
	}
 }

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

const int MOD = 1e9+7;

int dp[302][302][302];

void add(int& a, ll b) { a = (a + b) % MOD; }

int main(void) {
    int i, j, k, n, m;
    cin >> n >> m;
    dp[0][1][1] = 1;
    REP (i,m) REP (j,0,n) REP (k,0,n) {
        add(dp[i+1][j+1][k],(ll) dp[i][j][k] * (n-j));
        add(dp[i+1][j][k],(ll) dp[i][j][k] * (j-k));
        add(dp[i+1][j][j],(ll) dp[i][j][k] * k);
    }
    cout << dp[m][n][n] << endl;
    return 0;
}


Measured memory_bytes: 107136
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

string makeCode(string a){
    string ret;
    string s = "aiueo";
    ret+=a[0];
    rep(i,a.size() - 1){
        rep(j,5){
            if(a[i] == s[j]){
                ret+=a[i + 1];
                break;
            }
        }
    }
    return ret;
}

bool check(string a[55] ,int n){
    sort(a, a + n);
    rep(i,n - 1){
        if(a[i] == a[i + 1]) return false;
    }
    return true;
}

int main(){
    int n;
    while(cin >> n, n){
        string s[55];
        rep(i,n){
            string a;
            cin >> a;
            s[i] = makeCode(a);
        }
        string code[55];
        int ans = -1;
        range(i,1,55){
            rep(j,n){
                code[j] = s[j].substr(0, min(i, static_cast<int>(s[j].size())));
            }
            if(check(code, n)){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3156
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
    ll n ; cin >> n ;
    vll a(n) ;
    for(auto &i:a) cin >> i ;
    ll sum = 0 ;
    for(int i=0;i<n;i++) sum += a[i] ;
    ll ans = 0 ;
    sum %= mod ;
    for(int i=0;i<n;i++){
        ans += (sum-a[i]+mod)*a[i]%mod ;
        ans %= mod ;
    }
    cout << ans*500000004%mod << endl ;
}

Measured memory_bytes: 4836
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vi = vector <int>;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言等
ll p=0,q=0,r=0;
ll mod=1000000007;//1e9+7;

int main()
{
  ll n;
  cin>>n;
  p=1;
  rep(i,n)
  {
    p*=(i+1);
    p%=mod;
  }
  print(p)
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  int ma=0;
  int id=0;
  for(int i=0;i<n;++i){
    cin >> l[i];
    if(ma<l[i]){
      ma=l[i];
      id=i;
    }
  }
  int s=0;
  for(int i=0;i<n;++i){
    if(i!=id){
      s+=l[i];
    }
  }
  if(ma<s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
la = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    la[a] = max(la[a],h[b])
    la[b] = max(la[b],h[a])

ans = 0
    
for i in range(n):
    if la[i] < h[i]:
        ans += 1
        
print(ans)

Measured memory_bytes: 19988
#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 ll INF = 1LL << 60;

int main(void){
    int n; cin >> n;
    vector<int> p(n); 
    rep(i,n) cin >> p[i];
    int count = 0;
    for(int i=0; i<n; i++) {
        if(p[i]==i+1){
            int tmp = p[i];
            p[i] = p[i+1];
            p[i+1] = tmp;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


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


using namespace std;

int main() {
	int n;
	cin >> n;
	
	float ans;
	
	ans = ((float)((n+1)/2) / (float)n);
	
	cout << ans;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


void solve(){
	string n; cin>>n;
  int l = n.size();
  istringstream ss = istringstream(n);
  int num; ss>>num;
  ll ans = 0;
  rep(i,l-1){
    if(i%2==0) ans+=pow(10,i+1)-pow(10,i);
  }
  if(l%2==1) ans+=num-pow(10,l-1)+1;
  cout << ans << endl;
}


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


Measured memory_bytes: 256
from scipy.special import comb
import copy

MOD = 10**9+7
s = int(input())
cnt = 0
ans = 1

if s <= 2:
    print(0)
else :
    s = s-3
    while s >= 3:
        s -= 3
        cnt += 1
        if s > 0:
            ans += comb(s+cnt, cnt, exact=True)
            ans %= MOD
        else :
            ans += 1
    ans %= MOD
    print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 1;
  for (int i = 0; i < N; i++) {
    if (sum * 2 < sum + K) {
      sum = sum * 2;
    } else {
      sum = sum + K;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        

		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int a = Integer.parseInt(ss0[0]);
		int b = Integer.parseInt(ss0[1]);
		int c = Integer.parseInt(ss0[2]);
		int d = Integer.parseInt(ss0[3]);


        System.out.println(((a*b) > (c*d)) ? (a*b) : (c*d));


        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

Measured memory_bytes: 8276
from math import factorial as fa
n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k+1>=i:
        ans=fa(n-k+1)*fa(k-1)//(fa(i)*fa(n-k+1-i)*fa(i-1)*fa(k-i))
        ans%=10**9+7
        print(ans)
    else:
        print(0)

Measured memory_bytes: 3316
N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
ans = sum(S)
if ans%10 == 0:
    for i in S:
        if i%10 != 0:
            ans -= i
            print(ans)
            exit()
    print(0)
else:
    print(ans)


Measured memory_bytes: 38256
using System;

public class Bounding 
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);
        int N = Int32.Parse(input[0]);
        int X = Int32.Parse(input[1]);
        input = Console.ReadLine().Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);
        int[] L = new int[N];
        // 1回目の跳ねを考慮して初期化
        int D, count;
        D = 0;
        count = 1;
        for (int i = 0; i < N; i++) 
        {
            L[i] = Int32.Parse(input[i]);
        }
        for (int i = 0; i < N; i++)
        {
            D = D + L[i];
            if (D > X)  break;
            count++;
        }
        Console.WriteLine(count);
    }
}

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

int main() {
  while ( true ) {
    string t;
    string line;
    while ( getline( cin, line ) && line.size() ) {
      t += line;
    }
    getline( cin, line );
    if ( !line.size() ) break;
    string s = line;
    getline( cin, line );

    map <char, int> need;
    for ( string ::iterator it = s.begin(); it != s.end(); it++ ) {
      need[*it]++;
    }

    map <char, int> cnt;
    int left = 0, right = 0;
    int occ, OCC;

    occ = 0;
    OCC = need.size();

    vector <string> v;

    while ( left < t.size() ) {
      while ( right < t.size() && occ < OCC ) {
	char c = t[right++];
	if ( need[c] && need[c] == ++cnt[c] ) ++occ;
      }
      if ( occ != OCC ) break;
      while ( left < right ) {
	char c = t[left];
	if ( need[c] && need[c] == cnt[c] ) break;
	--cnt[c];
	left++;
      }
      if ( left == right ) break;
      v.push_back( t.substr( left, right - left ) );
      --cnt[t[left++]];
      --occ;
    }

    int mlen = 1<<24;
    for ( int i = 0; i < v.size(); i++ ) {
      mlen = min( mlen, (int)v[i].size() );
    }

    int answer1 = 0;
    string answer2 = "";
    for ( int i = 0; i < v.size(); i++ ) {
      if ( v[i].size() == mlen ) {
	if ( answer2.size() == 0 ) {
	  answer2 = v[i];
	}
	answer1++;
      }
    }

    cout << answer1 << endl;
    if ( answer1 > 0 ) cout << endl;
    for ( int i = 0; i < answer2.size(); i++ ) {
      cout << answer2[i];
      if ( (i + 1) % 72 == 0 ) cout << endl;
    }
    if ( answer2.size() > 0 && answer2.size() != 72 ) cout << endl;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n;
vll bounds;

int main() {
    fast_io; cout_precision;
    bounds.assign(4, 0);
    cin >> bounds[1] >> bounds[3] >> n;
    for (ll i = 0, x, y, a; i < n; i++) {
        cin >> x >> y >> a; a--;
        if (a == 0) {
            bounds[a] = max(bounds[a], x);
        } else if (a == 1) {
            bounds[a] = min(bounds[a], x);
        } else if (a == 2) {
            bounds[a] = max(bounds[a], y);
        } else if (a == 3) {
            bounds[a] = min(bounds[a], y);
        }
    }
    cout << max(bounds[1] - bounds[0], ll(0)) * max(bounds[3] - bounds[2], ll(0)) << endl;
}

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

using namespace std;

int main() {
    long c,sum=0;
    cin>>c;
    int number=1;
    for(int i=1;i<(c+1);i++){
        if(i%3!=0 && i%5!=0 ){
            sum=sum+i;
            
        }
        number++;
        
    }
    cout<<sum;
}

Measured memory_bytes: 3600
#include <iostream>

int main() {
    int n,x;
    std::cin>>n>>x;
    int m[n];
    int mini=1000;
    int s=0;
    for(int i=0;i<n;i++){
        std::cin>>m[i];
        s=s+m[i];
        if(m[i]<mini){
            mini=m[i];
        }
    }
    x=x-s;
    if(x>0){
        int rest_;
        rest_=x/mini;
        n=n+rest_;
    }
    std::cout<<n;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sum = 0;
		int[][] num = new int[2][2];
		for(int i = 0; i < num.length; i++)
			for(int j = 0; j < num[i].length;j++)
				num[i][j] = 0;
		for(int i = 0;i < s.length(); i++) {
			if(i % 2 == 0) {
				if(s.charAt(i) == '0')
					num[0][0]++;
				else
					num[0][1]++;
			}else {
				if(s.charAt(i) == '0')
					num[1][0]++;
				else
					num[1][1]++;
			}
		}
		System.out.println(Math.min(num[0][0] + num[1][1], num[0][1] + num[1][0]));
	}
}

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

int main() {
    int n;
    int taro = 0, hanako = 0;
    cin >> n;
    string p, q;
    for(int i = 0; i < n; i++){
        cin >> p >> q;
        if(p == q){
            taro++;
            hanako++;
        }
        else if(p > q){
            taro+=3;
        }
        else {
            hanako+=3;
        }
    }
    cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3164
const SEQ: [i32; 32] = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

fn main() {
    let k: usize = read();
    println!("{}", SEQ[k - 1]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352