akhauriyash/Code-Regression huggingface dataset:
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) $f[] = ints();
for ($i = 0; $i < $n; ++$i) $p[] = ints();
$ans = PHP_INT_MIN;
// bit全探索
for ($i = 0; $i < 2 ** 10; ++$i) {
    $cnt = array_fill(0, $n, 0);
    $open = 0;
    for ($j = 0; $j < 10; ++$j) {
        if (($i >> $j) & 1) $open++;
        for ($k = 0; $k < $n; ++$k) {
            if (($i >> $j) & 1 & $f[$k][$j]) {
                $cnt[$k]++;
            }
        }
    }
    if ($open < 1) continue;
    $psum = 0;
    for ($k = 0; $k < $n; ++$k) $psum += $p[$k][$cnt[$k]];
    $ans = max($ans, $psum);
}
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

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

    int ans = 0;
    for(int i=0; i<n; ++i) ans += b[i];

    for(int i=0; i<n-1; ++i){
        if(a[i]+1 == a[i+1]) ans += c[a[i]];
    }

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

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k,d=0,a=1;
  cin >> n >> k;
  while (n >= a){	
	a = a * k;
	++d;
  }
  cout << d << "\n";
return 0;
}


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

using namespace std;

int main(){
    int w, h , x, y;
    cin >> w >> h >> x >> y;

    cout << (w*(h/2.0)) << " ";
    if(x*2 == w && y*2 == h){
        cout << 1 << endl;
    }else{
        cout  << 0 << endl;
    }
}

Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

typedef long long i64;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)

int h,w;

int m[2005][2005];
int r[2005][2005];
int l[2005][2005];
int u[2005][2005];
int d[2005][2005];

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

        cin >> h >> w;
        REP(i,h) {
                string s;
                cin >> s;
                REP(j,w)
                        m[i][j] = s[j] == '.' ? 0 : 1;
        }


        REP(i,h) {
                REP(j,w) {
                        if (m[i][j]) {
                                u[i][j] = 0;
                                l[i][j] = 0;
                        } else {
                                u[i][j] = i > 0 ? u[i-1][j] + 1 : 1;
                                l[i][j] = j > 0 ? l[i][j-1] + 1 : 1;
                        }
                }
        }
        REP(i,h) {
                REP(j,w) {
                        if (m[h-i-1][w-j-1]) {
                                d[h-i-1][w-j-1] = 0;
                                r[h-i-1][w-j-1] = 0;
                        } else {
                                d[h-i-1][w-j-1] = h-i < h ? d[h-i][w-j-1] + 1 : 1;
                                r[h-i-1][w-j-1] = w-j < w ? r[h-i-1][w-j] + 1 : 1;
                        }
                }
        }

        int m = 0;
        REP(i,h) {
                REP(j,w) {
                        m = max(m, r[i][j] + d[i][j] + u[i][j] + l[i][j] -3);
                }
        }
        cout << m << endl;


        return 0;
}


Measured memory_bytes: 78720
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var ans = 0
    for (i in 0..a) {
        for (j in 0..b) {
            for (k in 0..c) {
                if (500 * i + 100 * j + 50 * k == x) ans++
            }
        }
    }
    println(ans)
}

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


int main(){
    int N;
    cin>>N;
    vector<int> V(N+1);
    for(int i=0;i<N;i++) cin>>V[i];
    int64_t ans=0;
    for(int i=0;i<N;i++){
        if(V[i+1]-V[i]>1||V[0]){
            ans=-1;
            break;
        }else if(V[i+1]<=V[i]){
            ans+=V[i];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r)for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r)for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k)for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
   upll : (a<b)なら-1, (a=b)なら0, (a>b)なら1
 downll : (a<b)なら1, (a=b)なら0, (a>b)なら-1

 const void* a : 型を縛らずにconstをつける(=変数aが読み込み専用の変数であることを明示する)
        (ll*)a : 変数aがconst long long *型であると明示する
*/
// int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
// int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
// void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
// void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

int main(){
    ll a, b, x; cin >> a >> b >> x;
    cout << b/x - (a == 0 ? -1 : (a-1)/x) << endl;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

A,B,C = II()
print(max(0,C-(A-B)))

Measured memory_bytes: 38384
package main

import (
	"fmt"
	"sort"
)

type Entry struct {
	name  string
	value int
}
type List []Entry

func (l List) Len() int {
	return len(l)
}

func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l List) Less(i, j int) bool {
	return (l[i].value < l[j].value)
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ar := make(map[string]int, n)
	for i:=0; i<n; i++ {
		var v string
		fmt.Scan(&v)
		ar[v]++
	}

	al := List{}
	for k, v := range ar {
		e := Entry{k, v}
		al = append(al, e)
	}

	leng := len(al)

	if leng <= k {
		fmt.Println(0)
		return
	}

	sort.Sort(al)
	cnt := 0
	for len(al) > k {
		cnt += al[0].value
		al = al[1:]
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 34176
n=int(input())
if n==1:
  print(1)
  exit()
a=list(map(int,input().split()))
ans=1
if a[0]<a[1]:flag=1
elif a[0]>a[1]:flag=-1
else:flag=0
for i in range(1,n-1):
  if flag==1 and a[i]>a[i+1]:
    ans+=1
    flag=0
  elif flag==-1 and a[i]<a[i+1]:
    ans+=1
    flag=0
  else:
    if a[i]>a[i+1]:flag=-1
    elif a[i]<a[i+1]:flag=1
print(ans)

Measured memory_bytes: 20140
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) if (s[i] == t[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
t_hp,t_at,a_hp,a_at=map(int,input().split())
while(t_hp > 0 and a_hp > 0):
  a_hp -= t_at
  if a_hp <= 0:
    print("Yes")
    break
  t_hp -= a_at
  if t_hp <= 0:
         print("No")
         break

Measured memory_bytes: 9164
open Hashtbl
let w = read_line ()
let h = create 100
let _ = String.iter (fun c -> if mem h c then replace h c @@ find h c + 1 else add h c 1) w;
  iter (fun _ c -> if c mod 2 = 1 then (print_endline "No"; exit 0)) h; print_endline "Yes"

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a, b, c, t;
    scanf("%d %d %d",&a,&b,&c);
    t=max(max(a,b),c);
    if(t==a) t=2*t-b-c;
    else if(t==b) t=2*t-a-c;
    else if(t==c) t=2*t-b-a;
    if(t%2) t+=3;
    t=t/2;
    printf("%d\n",t);
}


Measured memory_bytes: 128
#include<stdio.h>

 int main(){
   typedef struct{
     int number;
     char type;
   }TRAMP;
   int datanum,i,j,minj,flag;
   TRAMP card[36];
   TRAMP b_card[36];
   TRAMP temp;
   scanf("%d",&datanum);

   for(i=0;i<datanum;i++){
     scanf(" %c",&card[i].type);
     scanf("%d",&card[i].number);
     b_card[i] =card[i];
   }
   for(i=0;i<datanum;i++)
     for(j=datanum-1;j>=i+1;j--){
       if(card[j].number < card[j-1].number){
	 temp = card[j];
	 card[j] = card[j-1];
	 card[j-1] = temp;
       }
     }
   for(i=0;i<datanum;i++){
     if(i == datanum-1){
       printf("%c%d\n",card[i].type,card[i].number);
       break;
     }
     printf("%c%d ",card[i].type,card[i].number);
   }
   printf("Stable\n");

   for(i=0;i<datanum;i++){
     minj = i;
     flag = 0;
     for(j = i;j<datanum;j++){
       if(b_card[j].number < b_card[minj].number){
	 minj = j;
	 flag = 1;
       }
     }
       if(flag == 1){
	 temp = b_card[i];
	 b_card[i] = b_card[minj];
	 b_card[minj] = temp;
       }
   }
     flag = 0;
     for(i=0;i<datanum;i++){
       if(i == datanum -1) {
	 printf("%c%d\n",b_card[i].type,b_card[i].number);
	 break;
       }
       printf("%c%d ",b_card[i].type,b_card[i].number);
       if(card[i].type != b_card[i].type || card[i].number != card[i].number)flag=1;
     }
     if(flag == 1)printf("Not stable\n");
     else printf("Stable\n");     

     return  0;


 }



Measured memory_bytes: 2104
# -*- coding: utf-8 -*-

def pleaseConform(caps):
    start = 0
    intervals = []
    for i in range(1, len(caps)):
        if caps[start] != caps[i]:
            intervals.append((start, i-1, caps[start]))
            start = i
    intervals.append((start, len(caps)-1, caps[start]))
    return intervals

n = input()
cap1 = input().split()

go = pleaseConform(cap1)

ans = 0

for t in go:
    ans += (t[1]-t[0]+1)//2

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MX = 1e5+5;

LL n;
int main(){
    cin >> n;
    LL m = n * (n-1) / 2;
    cout << m << "\n";
}

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

typedef long long ll;

ll N;
vector<int> ans;
int mem = 0;

int main()
{
    scanf("%lld",&N);

    for(int i = 40; i > 0; i--)
    {
        mem = i;
        if(N >= (ll)pow(2,i) - 1)break;
    }

    for(int i = 1; i <= mem; i++)ans.push_back(i);

    N -= (ll)pow(2,mem) - 1;

    for(int i = mem - 1; i >= 0; i--)
    {
        if(N < (ll)pow(2,i))continue;
        mem++;
        ans.insert(ans.begin() + i,mem);
        N -= (ll)pow(2,i);
    }
    printf("%d\n",2 * mem);
    for(int i = 0; i < ans.size(); i++)
    {
        printf("%d ",ans[i]);
    }
    for(int i = 1; i <= mem; i++)
    {
        printf("%d",i);
        if(i != mem)printf(" ");
    }printf("\n");

    return 0;

}


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		Random rand=new Random();
		double a=scan.nextInt();
		double b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		double ansa=a*b/2;//対角線を通れば二分の一になるため(soutomokagiran)
		int ansb=0;
		if(c==a/2&&d==b/2) {
			ansb=1;
		}
		System.out.println(ansa+" "+ansb);
	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
  int n;
  cin >>n;
  int a;
  if (n%2==1) a =(n+1)/2;
  else a=n/2;
  cout << fixed <<setprecision(10);
  cout << (double)a/n<<endl; 
}


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

int main()
{
    std::string s;
    std::cin >> s;

    std::vector<int> num_chidren(s.length(), 0);

    for (int direction = 0; direction < 2; direction++) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == 'R') {
                count++;
            } else {
                num_chidren[i - 1] += (count + 1) / 2;
                num_chidren[i] += count / 2;
                count = 0;
            }
        }

        std::reverse(num_chidren.begin(), num_chidren.end());
        std::reverse(s.begin(), s.end());

        for (int i = 0; i < s.length(); i++) {
            s[i] = (s[i] == 'R') ? 'L' : 'R';
        }
    }

    for (int i = 0; i < s.length(); i++) {
        printf("%d%c", num_chidren[i], i == s.length() - 1 ? '\n' : ' ');
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, x;
int s[200];
ll dp[201][100001];

int main() {
    cin >> n >> x;
    rep(i,n) cin >> s[i];
    sort(s,s+n,greater<int>());
    dp[0][x] = 1;
    rep(i,n) {
        rep(j,x+1) dp[i+1][j] = (dp[i][j] * (n-i-1))%MOD;
        rep(j,x+1) {
            dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j])%MOD;
        }
    }
    ll ans = 0;
    rep(j,x+1) {
        ans = (ans + dp[n][j]*j) % MOD;
    }
    cout << ans << endl;
}



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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
//#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 1000000007;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (a1 < b1) {
        swap(a1, b1);
        swap(a2, b2);
    }
    ll da = t1 * a1 + t2 * a2, db = t1 * b1 + t2 * b2;
    //cout << t1 * (a1 - b1) << ' ' << db - da << endl;
    if (da > db) {
        cout << 0;
    } else if (da == db) {
        cout << "infinity";
    } else {
        cout << 2 * (t1 * (a1 - b1) / (db - da)) - ((t1 * (a1 - b1)) % (db - da) == 0) + 1;
    }
    return 0;
}


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

signed main(){
	int ans = 0;
	int n,a[100000];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i]--;
	}
	for(int i = 0;i < n;i++){
		if(a[a[i]] == i) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

int main()
{
  long long n;
  scanf("%lld", &n);
  long long a[100000], b[100000];
  long long sum = 0;
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
    sum += a[i];
  }
  std::vector<long long> dif;
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld", b + i);
    sum -= b[i];
    if (a[i] - b[i] >= 0) dif.emplace_back(a[i] - b[i]);
  }
  std::sort(dif.begin(), dif.end());
  if (sum < 0)
  {
    puts("-1");
    return 0;
  }
  long long same = 0;
  for (int i = 0; i < dif.size(); ++i)
  {
    if (sum - dif[i] >= 0)
    {
      ++same;
      sum -= dif[i];
    }
  }
  printf("%lld\n", n - same);
  return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B; cin >> A >> B;
  int ans = 0;
  REP(i,A,B+1){
    bool ok = true;
    if(i>=10000){
      ok &= (i/10000==i%10) && ((i/1000)%10==(i/10)%10);
    }else if(i>=1000){
      ok &= (i/1000==i%10) && ((i/100)%10 == (i/10)%10);
    }else if(i>=100){
      ok &= (i/100==i%10);
    }else if(i>=10){
      ok &= (i/10==i%10);
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

const int MAXN = 1e5+5;
int n, a[MAXN], b[MAXN];

vector<ii> count_(int *a, int n){
	map<int, int> mp;
	FOR(i,0,n) mp[a[i]]++;
	vector<ii> ret;
	for(auto it : mp){
		ret.emplace_back(it.snd, it.fst);
	}
	sort(all(ret));
	reverse(all(ret));
	return ret;
}

int main(){
	scan(n);
	n/=2;
	FOR(i,0,n) scan(a[i], b[i]);

	vector<ii> va = count_(a, n);
	vector<ii> vb = count_(b, n);

	int ans = -1;
	if(va.size() == 1){
		int xa = va[0].snd;
		if(vb.size() == 1){
			int xb = vb[0].snd;
			if(xa == xb) ans = n;
			else ans = 0;
		}else{
			int xb1 = vb[0].snd, c1 = vb[0].fst, c2 = vb[1].fst;
			if(xa == xb1){
				ans = n-c2;
			}else{
				ans = n-c1;
			}
		}
	}else{
		int xa1 = va[0].snd, c1 = va[0].fst, c2 = va[1].fst;
		if(vb.size() == 1){
			int xb = vb[0].snd;
			if(xa1 == xb) ans = n-c2;
			else ans = n-c1;
		}else{
			int xb1 = vb[0].snd, cb1 = vb[0].fst, cb2 = vb[1].fst;
			if(xa1 == xb1){
				ans = min(n-c2 + n-cb1, n-c1 + n-cb2);
			}else{
				ans = n-c1 + n-cb1;
			}

		}
	}
	printf("%d\n",ans);

}


Measured memory_bytes: 4088
#include <cstdio>
#include <cstdlib>

int _sort(const void *a,const void *b){
	return *(int *)a - *(int *)b;
}

int main(){
	int N,K,l[50];
	scanf("%d %d\n",&N,&K);
	for(int i = 0;i < N;i++){
		scanf("%d ",&l[i]);
	}
	qsort(l,N,sizeof(int),_sort);
	int ans = 0;
	for(int i = N - 1;i >= N - K;i--) ans += l[i];
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
   int a, b, c;
   
   scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);
	
	if(a<b){
		if(b<c){
		printf("Yes\n");}
		else{
		   printf("No\n");}}
		else{
			printf("No\n");}
      
   return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin >> q;
  vector<int> A;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int x;
      cin >> x;
      A.push_back(x);
    }
    if (t == 1){
      int p;
      cin >> p;
      cout << A[p] << endl;
    }
    if (t == 2){
      A.pop_back();
    }
  }
}


Measured memory_bytes: 3932
#include <cstdio>
#include <cstring>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
  int n;
  cin >> n;
  if(n>=1200)
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}




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

int main()
{
	int n;
	cin >> n;
	int a[n];
	long s = (long)pow(3,n);
	int b[n];
	int cnt = 0;
	rep(i, n)
	{ 
		cin >> a[i];
		if (a[i] % 2 == 0)
			cnt++;
	}
	int j,k,l;
	int i = 1;

	printf("%ld",s - (long)pow(2, cnt));
	return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>
#include <unordered_map>

using namespace std;

typedef long long ll;

const int MAXN = 262150;
const ll MOD = 1000000007;

int n;
int p[MAXN];

ll ans;
ll val1[MAXN];
ll val2[MAXN];
ll sum[MAXN];

pair<int,ll> mdf[MAXN][18];
pair<int,ll> qry[MAXN][18];

int main()
{
	scanf("%d",&n);
	for (int i = 0;i < (1 << (n - 1));i++)
	{
		scanf("%d",&p[i]);
		p[i]--;
	}
	for (int L = 0;L < n - 1;L++)
	{
		for (int i = 0;i < (1 << (n - 1));i++)
		{
			int u = i + (1 << (n - 1)),v = p[i] + (1 << (n - 1));
			ll vu = 1,vv = 1;
			for (int j = u;j >= 1;j >>= 1)
			{
				(vu *= j) %= MOD;
				val1[j] = vu;
			}
			for (int j = v;j >= 1;j >>= 1)
			{
				(vv *= j) %= MOD;
				val2[j] = vv;
			}
			for (int j = u,l = 0;j >= 1;j >>= 1,l++)
				if (l == L)
					for (int k = v,r = 0;k >= 1;k >>= 1,r++)
						mdf[u][r] = make_pair(k,val1[j] * val2[k] % MOD);
		}
		for (int i = 0;i < (1 << (n - 1));i++)
		{
			int u = i + (1 << (n - 1)),v = p[i] + (1 << (n - 1));
			ll vu = 1,vv = 1;
			for (int j = u;j >= 1;j >>= 1)
			{
				(vu *= j) %= MOD;
				val1[j] = vu;
			}
			for (int j = v;j >= 1;j >>= 1)
			{
				(vv *= j) %= MOD;
				val2[j] = vv;
			}
			for (int j = u,l = 0;j >= 2;j >>= 1,l++)
				if (l == L)
					for (int k = v,r = 0;k >= 2;k >>= 1,r++)
						qry[u ^ (1 << L)][r] = make_pair(k ^ 1,val1[j >> 1] * val2[k >> 1] % MOD);
		}
		for (int i = (1 << (n - 1 - L));i < (1 << (n - L));i++)
		{
			for (int j = i << L;j < (i << L) + (1 << L);j++)
				for (int k = 0;k < n;k++)
					(sum[mdf[j][k].first] += mdf[j][k].second) %= MOD;
			for (int j = i << L;j < (i << L) + (1 << L);j++)
				for (int k = 0;k < n;k++)
					(ans += sum[qry[j][k].first] * qry[j][k].second) %= MOD;
			for (int j = i << L;j < (i << L) + (1 << L);j++)
				for (int k = 0;k < n;k++)
					sum[mdf[j][k].first] = 0;
		}
	}
	printf("%lld\n",ans * ((MOD + 1) / 2) % MOD);
	return 0;
}

Measured memory_bytes: 84184
#include <iostream>

using namespace std;

int
main()
{
    int a, b, c, x, y, ans, tmp;
    cin >> a >> b >> c >> x >> y;
    ans = a * x + b * y;
    tmp = max(x, y) * 2 * c;
    if (tmp < ans)
        ans = tmp;
    if (x < y)
        tmp = x * 2 * c + (y - x) * b;
    else
        tmp = y * 2 * c + (x - y) * a;
    if (tmp < ans)
        ans = tmp;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h[] =new int[n];
		for(int i=0;i<n;i++){
			h[i]=sc.nextInt();
		}
		int dp[]= new int[n];
		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		for (int i=2;i<n ;i++ ) {
			dp[i]=Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),dp[i-2]+Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 49968
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  ll sum = 0;
  REP(i,s.size()){
    int x = s[i] - '0';
    //cout << x << endl;
    sum += x;
  }

  if(sum%=9) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

int main()
{
	int i,q,c,a,n,k;
	cin >> q;
	for (i=0;i<q;i++) {
		k=0;
		cin >> c >> a >> n;
		for (;c>0 && a>0 && n>0;k++) { c--; a--; n--;}
		for (;c>1 && a>0;k++) {c-=2; a--;}
		for (;c>2;k++) c-=3;
		cout << k << endl;
	} 
	return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        int taro = 0;
        int hanako = 0;
        for (int i = 0; i < n; i++) {
            String str1 = sc.next();
            String str2 = sc.next();
            int result = str1.compareTo(str2);
            if(result == 0) {
                taro++;
                hanako++;
            }else if(result < 0){
                hanako += 3;
            }else{
                taro += 3;
            }
        }
        sc.close();

        System.out.println(taro +" "+hanako);
    }

}

Measured memory_bytes: 20888
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int s1,s2,b;
	while(cin >> s1 >> s2 >> b){
		if(s1 == 0 && s2 == 0 && b == 0) break;
		
		if(s1 >= s2) swap(s1,s2);
		if(s2 >= 	b) swap(s2,b);
		int n;
		cin >> n;
		for(int i = 0; i < n; i++){
			int r;
			cin >> r;
		 if(sqrt(s1*s1 + s2*s2) >= r*2) cout << "NA" << endl;
			else cout << "OK" << endl;
		}
	}
}

Measured memory_bytes: 1156
#include <iostream>

typedef long long ll;
using namespace std;

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

    ll ans = k;
    for (int i = 0; i < n - 1; i++){
        ans *= k - 1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
    int n;
    cin >> n;
    vi a(n + 2);
    a[0] = INT_MAX;
    rep(i, 1, n + 1)
    {
        cin >> a[i];
    }
    a[n + 1] = INT_MIN;
    int ans = 1000;
    int c;
    rep(i, 2, n + 1)
    {
        if (a[i] <= a[i - 1])
        {

            continue;
        }
        else
        {
            c = ans / a[i - 1];
            ans = (ans % a[i - 1]);
            ans = ans + c * a[i];
            c = 0;
        }
    }
    cout << ans << endl;
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int k;
        cin>>k;
        queue<long long>q;
        vector<long long>ans;
        for(int i=1;i<=9;i++){
            q.push(i);
            ans.push_back(i);
        }
        if(k<=ans.size()){
            cout<<ans[k-1];
            return 0;
        }
        while(1){
            if(k<=ans.size()){
                cout<<ans[k-1];
                return 0;
            }
            long long x=q.front();
            q.pop();
            for(int i=-1;i<=1;i++){
                int y=x%10;
                if(y+i<0 || y+i>9)
                    continue;
                long long nx=(x*10)+(y+i);
                ans.push_back(nx);
                q.push(nx);
            }
        }

        return 0;
    }


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

sum = 0
if A >= B:
    sum += A
    A = A-1
    if A >= B:
        sum += A
        print(sum)
    else:
        sum += B
        print(sum)
else:
    sum += B
    B = B-1
    if B >= A:
        sum += B
        print(sum)
    else:
        sum += A
        print(sum)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int         int long long
    
using namespace std;

signed main()
{	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int test=1;
    //cin>>test;
    while(test--){
        int n,a;
        cin>>n;
        set<int> s;
        for(int i=0;i<n;i++) {
        	cin>>a;
        	s.insert(a);
        }
        if(s.size()==n) cout<<"YES";
        else cout<<"NO";
    }
    return 0;
}       

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  cout<<min((n+a-1)/a*b,(n+c-1)/c*d)<<endl;
  return 0;
}



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

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var blueTexts = new List<string>();
		for (var i = 0; i < n; ++i) {
			blueTexts.Add(Console.ReadLine());
		}

		var m = int.Parse(Console.ReadLine());
		var redTexts = new List<string>();
		for (var i = 0; i < m; ++i) {
			redTexts.Add(Console.ReadLine());
		}

		var max = 0;
		blueTexts.ForEach(target =>
		{
			var count = blueTexts.Count(blueText => blueText == target);
			count -= redTexts.Count(redText => redText == target);

			max = Math.Max(count, max);
		});

		Console.WriteLine(max);
		Console.ReadKey();
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<long long> M(6, 0);
    vector<long long> Run(5);
    ll minR = 100000000000000001;
    int mindex = 0;
    rep(i, 0, 5){
        cin >> Run[i];
        if (minR > Run[i]){
            minR = Run[i];
            mindex = i;
        }
    }
    ll ans = 0;
    if (N%minR){
        ans += N/minR+1;
    } else {
        ans += N/minR;
    }
    ans += 4;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
const int N = 1e5 + 5;
int an[N];
ll ans = 0;
int n, q, a, b, c;
int main() {
	n = read();
	for_int(i, 1, n) {
		a = read();
		an[a]++;
		ans += a;
	}
	q = read();
	while (q--) {
		b = read(); c = read();
		ans -= (ll)b * an[b];
		ans += (ll)c * an[b];
		cout << ans << endl;
		an[c] += an[b];
		an[b] = 0;
	}
	return 0;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n,x;
    cin>>n;
    vi v1,v2;
    rep(i,0,n)
    {
        cin>>x;
        v1.pb(x);
    }
    rep(i,0,n)
    {
        cin>>x;
        v2.pb(x);

    }
    vi v;
    ll a=-1,b=-1;
    rep(i,0,n)
    {
        v.pb(i+1);
    }
    ll cur=0;
    do { 
        if(v==v1)
        {
            a=cur;
        }
        if(v==v2)
        {
            b=cur;
        }
        cur++;
    } while (next_permutation(all(v)));
    cout<<abs(a-b)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res


N = int(input())
res = divisor(N)
ans = 0
for d in res:
    m = d - 1
    if m == 0:
        continue
    if N % m == N // m:
        ans += m

print(ans)

Measured memory_bytes: 3296
#include<stdio.h>

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int lt[n];
	for(int i=0; i<n; i++){
		scanf("%d", &lt[i]);
	}
	int c = n - k;
	for(int i=0; i<c; i++){
		if(lt[i]<lt[i+k]){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
	return 0;
}

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

int main(){
    int n,m,ans;

    while(cin>>n>>m){
        if(!n&&!m)break;
        bool prime[7368801]={};
        int cnt=0;
        for(int i=n;;i++){
            if(prime[i]==false){
                cnt++;
                if(cnt==m+1){
                    ans=i;
                    break;
                }
                int tmp=i;
                while(tmp<=7368800){
                    prime[tmp]=true;
                    tmp+=i;
                }
            }
        }
        cout<<ans<<endl;
    }
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

int n;
cin>> n;

ll b[n+1], sum= 0;

for(int i= 0; i<n-1; i++)
{
    cin>> b[i];

    sum+= (i ==0? b[i] : min( b[i], b[i-1]));

}

sum += b[n-2];
cout<< sum ;
nl;

    return 0;
}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;cin>>n;
	vector<int> a(n),b(n),d(n);
	for(auto&& w:a)cin>>w;
	for(auto&& w:b)cin>>w;
	for(int i=0;i<n;i++)d[i]=a[i]-b[i];
	int ans;
	int sum=0,nsum=0,pcnt=0;
for(auto&& w:d){
	sum+=w;
	if (w<0)nsum-=w;
	if(w>0)pcnt++;
	}	
	sort(begin(d),end(d),greater<int>());
int tmp=0;	
for(int i=0;i<n;i++){tmp+=d[i];if(tmp>=nsum){ans=n-(pcnt-(i+1));break;}}
if (sum<0)ans=-1;
if (nsum==0)ans=0;
cout<<ans<<endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx = 1e5+5;
const int md = 1e9+7;

int dp[mx][2];
int n, vis[mx];
vector<int> g[mx];

int fun(int u, int c){
    int &ans = dp[u][c];
    if(ans != -1) return ans;

    vis[u] = 1; ans = 1;
    for(int v : g[u])
    if(!vis[v]){
        long long res = 0;
        res += fun(v, 0); res %= md;
        if(c == 0)
            res += fun(v, 1), res %= md;
        ans = (ans * res) % md;
    }vis[u] = 0; return ans;
}

int main(){

    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> n;
    memset(dp, -1, sizeof dp);
    for(int u, v, i=1; i<n; i++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }cout << (fun(1,0)+fun(1,1))%md << "\n";

    return 0;
}


Measured memory_bytes: 18576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int A,B,C;
  cin >> A >> B >> C;
  if((A<C&&C<B)||(B<C&&C<A))cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    FOR(b,1,N+1) {
        ll p = N/b;
        ans += p*max(0ll,b-K);
        ans += max(0ll,(N%b)-K+1);
    }
    if (K==0) ans-=N;
    cout << ans << endl;
}

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

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,8){
        string a = s.substr(0,i);
        string b = s.substr(n-7+i,7-i);
        string ans = a+b;
        //cerr << ans << endl;
        if(ans=="keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

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

	int n, k;
	cin >> n >> k;

	vi a(n);
	for (auto& i : a)
		cin >> i;

	vi dp(n, INT32_MAX);
	dp[0] = 0;
	for (int i = 1; i < n; ++i){
		int j0 = max(0, i - k);
		for (int j = j0; j <i; ++j){
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}

	cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main(){
  int flag=0,count=0,i;
  string in;
  cin >> in;
  for(i=0;in[i]!='\0';i++){
    if(in[i]=='A') flag=1;
    if(flag==1&&in[i]=='Z'){
      count++;
      flag=0;
    }
  }
  if(count==0) cout << -1;
  else{
    for(i=0;i<count;i++) cout << 'A' << 'Z';
  }
  cout << endl;
  return 0;
}

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

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3856
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>

using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define FOR(I,J,K) for(int I = J;I < K;I++)
#define WriteLine(n) cout << n << "\n"; 

	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		FOR(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}

	vector<int> SieveOfEratosthenes(int N) {
		vector<bool> memo(N + 1);
		vector<int> ret;
		memo[0] = true;
		memo[1] = true;
		for (int i = 2; i < N; i++) {
			if (memo[i])continue;
			ret.push_back(i);
			for (int b = 2; true; b++) {
				if (i*b <= N) {
					memo[i*b] = true;
				}
				else break;
			}
		}
		return ret;
	}

	vector<int> SpInput(int N) {
		vector<int> ret(N);
		FOR(i, N, 1) { cin >> ret[i]; }
		return ret;
	}
}

using namespace CsF;

string S;

int main() {
	cin >> S;
	int All_g = count(S.begin(), S.end(), 'p');
	//どちらも p <= g を満たすので
	cout << (S.size() / 2 - All_g) << endl;
	return 0;
}



Measured memory_bytes: 512
n = gets.to_i
as = gets.split(' ').map {|a| a.to_i }

num = 1
denom = as.first

as[1..-1].each do |a|
  num = num * a + denom
  denom *= a

  v = num.gcd(denom)
  denom /= v
  num /= v
end

puts denom / num.to_f



Measured memory_bytes: 1788