akhauriyash/Code-Regression huggingface dataset:
//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int dp[100005];
int h[100005];
int main(){
    memset(dp, 0, sizeof dp);

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i){
        cin >> h[i];
    }

    h[0] = INT_MAX;
    for(int i = 2; i <= n; ++i){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

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

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int mod2019(int l, int r)
{
    int ans = 2019;

    for(long long i = l; i < r; ++i)
        for(long long j = i + 1; j <= r; ++j) {
            ans = min(ans, static_cast<int>((i * j) % 2019));
            if(!ans) return ans;
        }

    return ans;
}

int main()
{
    int l, r;
    cin >> l >> r;

    cout << mod2019(l, r) << '\n';
}


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

using namespace std;

void Knuth_Morris_Pratt(string &T, string &P, vector<int> &res){
	vector<int> pat(P.size()+1);
	pat[0] = -1;
	
	for(int i = 0, j = -1; i < P.size(); i++){
		while(j >= 0 && P[i] != P[j]) j = pat[j];
		j++;
		if(P[i+1] == P[j]) pat[i+1] = pat[j];
		else pat[i+1] = j;
	}
	
	for(int i = 0, j = 0; i < T.size(); i++){
		while(j >= 0 && T[i] != P[j]) j = pat[j];
		j++;
		if(j == P.size()){
			res.push_back(i-P.size()+1);
			j = pat[P.size()];
		}
	}
}

signed main(){
	
	vector<int> ans;
	string T, P;
	
	cin>>T>>P;
	
	Knuth_Morris_Pratt(T,P,ans);
	
	for(int y : ans){
		cout<<y<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 8404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n,a,b; cin>>n>>a>>b;
    vector <int> x(n); 
    rep(i,n) cin>>x[i];
    int now = x[0];
    itn ans = 0;
    rep(i,n){
        int cost = 0;
        cost += min(a*abs(x[i] - now), b);
        //cout<<cost<<endl;
        now = x[i];
        ans += cost;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if (s[0] == t[0] && s.length() < t.length()) {
    	cout << "Yes";
    	return 0;
	}
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
	for (int i = 0 ; i < min(s.length(), t.length()) ; i++) {
		if (s[i] < t[i]) {
			cout << "Yes";
			return 0;
		}
	}
	reverse(t.begin(), t.end());
	for (int i = 0 ; i < min(s.length(), t.length()) ; i++) {
		if (s[i] < t[i]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3628
//
//AtCoder Beginner Contest 147
//A - Blackjack
//

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    int a1,a2,a3;

    cin >> a1 >> a2 >> a3;

    string result = "win";
    if(a1+a2+a3 >=22) result = "bust";

    cout << result << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;

int N, A[1 << 18];
pair<int, int> P[1 << 18];
int res[1 << 18];

pair<int, int> merge(const pair<int, int> &p1, const pair<int, int> &p2) {
	vector<int> v = {p1.first, p1.second, p2.first, p2.second};
	int idx1 = v[0];
	for (int idx : v) {
		if (A[idx] > A[idx1]) {
			idx1 = idx;
		}
	}
	int idx2 = -1;
	for (int idx : v) {
		if (idx != idx1 && (idx2 == -1 || A[idx] > A[idx2])) {
			idx2 = idx;
		}
	}
	return {idx1, idx2};
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < 1 << N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 1; i < 1 << N; i++) {
		int bitCnt = __builtin_popcount(i);
		if (bitCnt == 1) {
			P[i] = {0, i};
			res[i] = max(res[i - 1], A[0] + A[i]);
			printf("%d\n", res[i]);
		} else {
			pair<int, int> p = {0, i};
			for (int j = 0; j < N; j++) {
				if (i & (1 << j)) {
					p = merge(p, P[i ^ (1 << j)]);
				}
			}
			P[i] = p;
			res[i] = max(res[i - 1], A[p.first] + A[p.second]);
			printf("%d\n", res[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>
int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int a[M],b[M],c[N],num;
  for(int i=0;i<N;i++){
    c[i]=0;
  }
  for(int i=0;i<M;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  for(int i=0;i<M;i++){
    num=a[i]-1;
    c[num]++;
    num=b[i]-1;
    c[num]++;
  }
  for(int i=0;i<N;i++){
    printf("%d\n",c[i]);
  }
  return 0;
}

Measured memory_bytes: 128
main = do
    s <- getLine
    t <- getLine
    putStrLn $ if elem t $ makeStrLst (s ++ s) $ length s
                  then "Yes"
                  else "No"

makeStrLst :: String -> Int -> [String]
makeStrLst ss n = if (length ss) > n
                     then take n ss : makeStrLst (tail ss) n
                     else []

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main()
{
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	/*sxsy to txty1*/
	for(int i=0;i<tx-sx;i++)
		cout << "R";
	
	for(int j=0;j<ty-sy;j++)
		cout << "U";
	
	/*txty to sxsy1*/
	for(int k=0;k<tx-sx;k++)
		cout << "L";
	
	for(int l=0;l<ty-sy;l++)
		cout << "D";
	
	/*sxsy to txty2*/
	cout << "D";
	for(int m=0;m<tx-sx+1;m++)
		cout << "R";
	
	for(int n=0;n<ty-sy+1;n++)
		cout << "U";
	
	cout << "L";
	
	/*txty to sxsy2*/
	cout << "U";
	for(int o=0;o<tx-sx+1;o++)
		cout << "L";
	
	for(int p=0;p<ty-sy+1;p++)
		cout << "D";
	
	cout << "R";
	return 0;
}

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

int main() {
	string s;
	cin>>s;
	int q;
	cin>>q;
	//deque型の利用
	deque<char> ds(s.size());
	rep(i,s.size())ds[i]=s[i];
	bool hanten=false;
	rep(i,q){
		int t;
		cin>>t;
		if(t==1)hanten=!hanten;
		else{
			int f;
			char c;
			cin>>f>>c;
			if((f==1&&hanten==false)||(f==2&&hanten==true))ds.push_front(c);
			else ds.push_back(c);
		}
	}
	
	if(hanten)reverse(ds.begin(),ds.end());
	
	for(auto c:ds)cout<<c;
	cout<<endl;//この書き方も覚えておく
}

Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep_zero(i, n) for(int i=0; i<n; i++)
#define rep(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    string s; cin>>s;
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
//By Tushar Gautam
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin>>n;
    if(n>999) cout<<"ABD";
    else cout<<"ABC";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int m;
	cin >> m;
	cout << 48 - m << endl;
	return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, p;
    string s;
    cin >> n >> p >> s;
    
    if(10%p == 0) {  // p = 2, 5
        ll ans = 0;
        rep(i, n) {
            if((s[i] - '0')%p == 0) {
                ans += i+1;
            }
        }
        out(ans);
        re0;
    }
    
    vl rui(n+1);
    ll ten = 1;
    for(ll i = n-1; i >= 0; i--) {
        ll x = (s[i] - '0')*ten%p;
        rui[i] = (rui[i+1] + x)%p;
        ten *= 10;
        ten %= p;
    }

    vl cnt(p);
    ll ans = 0;
    for(ll i = n; i >= 0; i--) {
        ans += cnt[rui[i]];
        cnt[rui[i]]++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
vector<int> prime;
void seive(int x){
    vector<bool> isprime(x,true);
    for(int p=2;p*p<=x;p++){
        if(isprime[p]){
            for(int i=p*p;i<=x;i+=p) isprime[i]=false;
        }
    }
    for(int i=2;i<=x;i++) prime.push_back(i);
}
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
/*------------------------------------------------------------
------------------------------------------------------------*/
int main(void){
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  
  vector<int> A(N,0);
  
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int work;
      cin >> work;
      A.at(work-1)++;
    }
  }
  
  int ans = 0;
  for(int i=0;i<N;i++){
    if(A.at(i) == 0){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s: Vec<char> = sc.chars();
    let red = s.into_iter().filter(|&c| c == 'R').count();
    if red > n - red {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import scala.io.StdIn.{readLine, readInt};
import scala.reflect.ClassTag;
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val graph = new Array[List[(Int, Int)]](n); // (cost, index)
        (0 until n).foreach { i =>
            graph(i) = readLine.trim.split(" ").map(_.toInt).zipWithIndex.filter(_._1 != -1).toList
        }
        println(mst(graph).sum);
    }
    
    def mst(graph: Array[List[(Int, Int)]]): Array[Int] = {
        val len = graph.length;
        val dist = new Array[Int](len).map( i => -1);
        implicit val ord = Ordering.by((e: (Int, Int)) => e._1).reverse;
        val pq = new PriorityQueue(10000);
        pq.enqueue((0, 0));
        def go(): Unit = {
            pq.dequeueOption match {
                case None => ();
                case Some((minCost, minIdx)) => {
                    if (dist(minIdx) == -1) {
                        dist(minIdx) = minCost;
                        graph(minIdx).foreach { e => pq.enqueue(e)}
                    }
                    go;
                }
            }
        }
        go;
        dist;
    }
}

class PriorityQueue[A](size: Int)(implicit m: ClassTag[A], ord: Ordering[A]) {
    import ord._;
    private[this] val pq = m.newArray(size);
    private[this] var ptr = 0;
    
    def enqueue(e: A): Unit = {
        def go(curr: Int): Unit = {
            val parent = if (curr % 2 == 1) (curr - 1) / 2 else (curr - 2) / 2;
            if (parent >= 0 && pq(curr) > pq (parent)) {
                swap(curr, parent);
                go(parent);
            }
        }
        pq(ptr) = e;
        go(ptr);
        ptr += 1;
    }
    def dequeue(): A = {
        if (ptr == 0) {
            throw new NoSuchElementException("value is not found");
        } else if (ptr == 1) {
            ptr = 0;
            pq(0);
        } else {
            ptr -= 1;
            val ret = pq(0);
            pq(0) = pq(ptr);
            heapify(0);
            ret;
        }
    }
    
    def dequeueOption(): Option[A] = {
        try {
            Option(dequeue());
        } catch {
            case e: Exception => None;
        }
    }
    
    private def heapify(curr: Int): Unit = {
        val left = curr * 2 + 1;
        val right = curr * 2 + 2;
        if (right < ptr) {
            val maxIdx = max(curr, left, right);
            if (curr != maxIdx) {
                swap(curr, maxIdx);
                heapify(maxIdx);
            }
        } else if (left < ptr) {
            if (pq(left) > pq(curr)) swap(curr, left);
        }
    }
    
    private def max(a: Int, b: Int, c: Int): Int = {
        if (pq(a) > pq(b)) {
            if (pq(a) > pq(c)) a else c;
        } else {
            if (pq(b) > pq(c)) b else c;
        }
    }
    
    private def swap(a: Int, b: Int): Unit = {
        val tmp = pq(a);
        pq(a) = pq(b);
        pq(b) = tmp;
    }
}


Measured memory_bytes: 62100
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string a;
    cin >> a;

    int n = a.size();

    int ans = 0;

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

    int s = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] != 0) {
            ans = max(ans, s + (a[i] - '0' - 1) + 9 * (n - i - 1));
        }

        s += a[i] - '0';
    }

    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    int sumA[N+1] = {}; rep(i, N) sumA[i+1] = sumA[i] + A[i];
    int sumB[N+1] = {}; rep(i, N) sumB[i+1] = sumB[i] + B[i];
    int ans = 0;
    for(int i = 1; i <= N; i++){
        ans = max(ans, sumA[i] + sumB[N]-sumB[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int g_dis;
int ng;
int n;
pair<int, int> p[50]; //???????????????

void dfs(int i, int d, int k){
    if(k > 3) return;
//    show(t)
//        show(i)
    int c = i == 0 ? 0 : p[i - 1].first;
    int t = i == 0 ? 0 : p[i - 1].second;
    if(g_dis < d) return;
    if(i == n){
        g_dis = min(g_dis, d + c);
        return;
    }

    //show(p[i].second)
    //show(dist * (k + 1))
    //show(c * (k + 1) + p[i].first)

    int dist = abs(p[i].first - c);
    ng = max(ng, i);
    if(p[i].second >= t + dist * (k + 1)) dfs(i + 1, d + dist, k + 1);
    if(p[i].second >= t + c * (k + 1) + p[i].first) dfs(i + 1, d + c + p[i].first, 1);
}

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

    while(cin >> n,n){
        g_dis = 1e8;
        ng = 0;
        rep(i,n) cin >> p[i].first >> p[i].second;
        dfs(0,0,0);
        if(g_dis == 1e8) cout << "NG " << ng + 1 << endl;
        else cout << "OK " << g_dis << endl;
    }
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String args[]) {
		//変数の宣言
		int a[]=new int[100];
		int b[]=new int[100];
		String op[]=new String[100];
		int result=0;
		int i=1;
		//入力
		//System.out.print("Please input a op b:");
		sc = new Scanner(System.in);
		for(;;) {
		a[i]=sc.nextInt();
		op[i]=sc.next();
		b[i]=sc.nextInt();
		if(op[i].equals("?")) {
			break;
		}
		i++;
		}
	    //識別と出力
		i=1;
		for(;;) {
			if(op[i].equals("?")) {
				break;
			}
			if(op[i].equals("+")) {
	    		result=a[i]+b[i];
	    	}else if(op[i].equals("-")) {
	    		result=a[i]-b[i];
	    	}else if(op[i].equals("*")) {
	    		result=a[i]*b[i];
	    	}else if(op[i].equals("/")) {
	    		result=a[i]/b[i];
	    	}else {
	    		System.out.println();
	    	}
			i++;
			System.out.println(result);
			result=0;
		}
	}
}



Measured memory_bytes: 26256
fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let s: String = std::io::Read::bytes(stdin.lock()).by_ref()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse::<T>().ok().expect("error")
}

fn main() {
    let n: u32 = input();
    println!("{}",
        if n % 2 == 0 {
            n
        } else {
            n * 2
        }
    );
}


Measured memory_bytes: 4352
line = input()
n = int(input())

for _ in range(n):
    x = list(map(str, input().split()))
    a, b = int(x[1]), int(x[2])
    if x[0] == "print":
        print(line[a:b+1])
    elif x[0] == "reverse":
        line = line[:a] + line[a:b+1][::-1] + line[b+1:]
    else:
        line = line[:a] + x[3] + line[b+1:]


    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  vector<int> arr_shiro(int(n + 1), 0);
  vector<int> arr_kuro(int(n + 1), 0);

  int shiro = 0;
  int kuro = 0;


  for (int i = 0; i < n; i++) {
    string t(1, s[i]);
    arr_shiro[i] = shiro;
    arr_kuro[i] = kuro;
    if (t == ".") {
      shiro += 1;
    } else {
      kuro += 1;
    }
  }
  arr_shiro[n] = shiro;
  arr_kuro[n] = kuro;

  int diff_min = 2 * 10e5 + 1;
  for (int i = 0; i < (n+1); i++) {
    int diff = 0;
    diff += arr_kuro[i];
    diff += (shiro - arr_shiro[i]);

    if (diff < diff_min) {
      diff_min = diff;
    }
  }

  cout << diff_min << endl;

  return 0;
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int sum=0;
	for(int i=0;i<n;i++)
		if(a[i]!=b[i])
			sum++;
	if(sum>2)
		cout<<"NO";
	else
		cout<<"YES";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

#define maxn 110
int n;
int a[2 * maxn];
int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n;
	enum(i, 1, 2 * n)
		cin >> a[i];
	sort(a + 1, a + 2 * n + 1);
	int ans = 0;
	for(int i = 1; i <= 2 * n; i += 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def insertion_sort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print_list_split_whitespace(a)


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])

print_list_split_whitespace(a)
insertion_sort(a, n)


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    map<int,int> A;
    bool t = true;
    rep(i,N) {
        int a;
        cin >> a;
        A[a]++;
        if (a!=0) t = false;
    }
    if (t) {
        cout << "Yes" << endl;
    }
    else {
        if (A.size()==3) {
            t = true;
            int tmp = 0;
            for (auto a:A) {
                tmp ^= a.first;
                if (a.second*3!=N) t = false;
            }            
            if (tmp!=0) t = false;
            if (t) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if (A.size()==2) {
            int tmp = 0;
            t = true;
            for (auto a:A) {
                if (a.second*3==N) {
                    tmp^=a.first;
                }
                else if (a.second*3==N*2){
                    tmp^=a.first;
                    tmp^=a.first;
                }
                else {
                    t = false;
                }
            }
            if (tmp!=0) t = false;
            if (t) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }

}



Measured memory_bytes: 7116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int count = scn.nextInt();
		int taroScore = 0;
		int hanakoScore = 0;
		for (int i = 0; i < count; i++) {
			String taroData = scn.next();
			String hanakoData = scn.next();
			int result = taroData.compareTo(hanakoData);
			if (result > 0) {
				taroScore = taroScore + 3;
			} else if (result < 0) {
				hanakoScore = hanakoScore + 3;
			} else if (result == 0) {
				taroScore = taroScore + 1;
				hanakoScore = hanakoScore + 1;
			}
		}
		System.out.println(taroScore + " " + hanakoScore);
	}
}



Measured memory_bytes: 29960
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W = map(int, input().split())
    l = [list(input()) for i in range(H)]
    cl = [[0] * W for i in range(H)]
    for h in range(H):
        for w in range(W):
            if l[h][w] == '#':
                cl[h][w]='#'
                for j, k in ([1,-1],[1, 0],[1,1], [-1,-1],[-1, 0],[-1,1], [0, 1], [0, -1]):
                    nh, nw = h + j, w + k
                    if nh < 0 or nh >= H or \
                            nw < 0 or nw >= W:
                        continue
                    else:
                        if cl[nh][nw]!='#':
                            cl[nh][nw]+=1
    for x in cl:
        print(*x,sep='')
resolve()

Measured memory_bytes: 44528
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 val[MAXN],lim,pre[MAXN];
vector<int> son[MAXN];
vector<pair<int64,int64> > v[MAXN];
vector<pair<int64,int64> > tmp,ano;
bool flag = 0;
void dfs(int u) {
    if(flag) return;
    v[u].clear();
    if(son[u].size() == 0) {v[u].pb(mp(0,0));return;}
    dfs(son[u][0]);dfs(son[u][1]);
    int a = son[u][0],b = son[u][1];
    if(v[a].size() > v[b].size()) swap(a,b);
    tmp.clear();ano.clear();
    for(auto t : v[a]) {
	tmp.pb(mp(t.fi,t.se));tmp.pb(mp(t.se,t.fi));
    }
    sort(tmp.begin(),tmp.end());
    for(auto t : v[b]) {
	    ano.pb(mp(t.fi,t.se));ano.pb(mp(t.se,t.fi));
    }
    sort(ano.begin(),ano.end());
    int r = ano.size() - 1;
    pre[0] = ano[0].se;
    for(int i = 1 ; i < ano.size() ; ++i) pre[i] = min(pre[i - 1],ano[i].se);
    for(auto t : tmp) {
	while(r >= 0 && ano[r].fi + val[b] + t.fi + val[a] > lim) --r;
	if(r >= 0) {
	    v[u].pb(mp(pre[r] + val[b],t.se + val[a]));
	}
    }
    if(!v[u].size()) flag = 1;
    return;
}
bool check(int64 mid) {
    lim = mid;
    flag = 0;dfs(1);
    if(flag) return false;
    return true;
}
void Solve() {
    read(N);
    int a;
    for(int i = 1 ; i < N ; ++i) {
	read(a);
	son[a].pb(i + 1);read(val[i + 1]);
    }
    int64 L = 0,R = 1e16;
    while(L < R) {
	int64 mid = (L + R) >> 1;
	if(check(mid)) {
	    R = mid;
	}
	else L = mid + 1;
    }
    out(L);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 39208
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w; cin >> n >> w;
    int MAX = 1e5 + 1;
    int dp[n+1][MAX]; 
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j < MAX; ++j)
            dp[i][j] = inf;
    }
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;
    int value[n], weight[n];
    for (int i = 0; i < n; ++i) cin >> weight[i] >> value[i];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < MAX; ++j)
        {
            if (dp[i][j] == inf) continue;
            dp[i+1][j+value[i]] = min(dp[i+1][j+value[i]], dp[i][j] + weight[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    int ans;
    for (int i = MAX-1; i >= 0; --i)
    {
        if (dp[n][i] <= w) 
        {
            ans = i;
            break;
        }
    }
    cout << ans;
    return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a;
        ld b;
        cin>>a>>b;
        ld res=(ld)a*b;
        cout<< (int)res<<endl;
    }
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a=='A'){
		cout<<"T"<<endl;
	}
	else if(a=='T'){
		cout<<"A"<<endl;
	}
	else if(a=='C'){
		cout<<"G"<<endl;
	}
	else{
		cout<<"C"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{	int a,b;
	cin>>a>>b;
	a%=2;
	b%=2;
	if(a==1&&b==1)cout<<"Odd";
	else if(a==2&&b==2)cout<<"Even";
	else cout<<"Even";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	unsigned long long N, K;
	string S;
	cin >> N >> K;
	cin >> S;

	auto right = 0;
	auto val = 0;
	auto num = 0;
	auto oldStand = S[0] != '0';
	vector<int> index;

	for (auto left = 0; left < N;)
	{
		while (right < N)
		{
			auto stand = S[right] == '0';
			if (oldStand != stand)
			{
				if (stand)
				{
					++num;
					if (num > K)
					{
						num = K;
						break;
					}
				}
				oldStand = stand;
			}
			++right;
		}

		val = max(val, right - left);
		
		if (S[left] == '0')
		{
			for (; left < N && S[left] == '0'; ++left);
		}
		else
		{
			for (; left < N && S[left] == '1'; ++left);
			for (; left < N && S[left] == '0'; ++left);
		}
		--num;
		if (right < left)
		{
			right = left;
			oldStand = true;
		}
	}

	cout << val << endl;

	return 0;
}


Measured memory_bytes: 512
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int a[4][13],n,i,j,k,x;
  char m;
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      a[i][j]=0;
    }
  }

  scanf("%d",&n);

  for(k=0;k<2*n;k++){
    scanf("%c %d",&m,&x);
    if(m=='S')a[0][x-1]=1;
    else if(m=='H')a[1][x-1]=1;
    else if(m=='C')a[2][x-1]=1;
    else if(m=='D')a[3][x-1]=1;
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(a[i][j]==0){
	if(i==0)printf("S %d\n",j+1);
	else if(i==1)printf("H %d\n",j+1);
	else if(i==2)printf("C %d\n",j+1);
	else if(i==3)printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

class UnionFind {
  std::vector<intmax_t> tree;

public:
  UnionFind(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t W, H;
  scanf("%zu %zu", &W, &H);

  std::vector<std::pair<intmax_t, size_t>> es;
  for (size_t j=0; j<W; ++j) {
    intmax_t p;
    scanf("%jd", &p);
    es.emplace_back(p, j);
  }

  for (size_t i=0; i<H; ++i) {
    intmax_t q;
    scanf("%jd", &q);
    es.emplace_back(q, W+i);
  }

  std::sort(es.begin(), es.end());
  size_t a=W+1, b=H+1;
  intmax_t res=0;
  UnionFind uf(a+b);
  for (const auto &e: es) {
    if (uf.connected(e.second, e.second+1))
      continue;

    uf.unite(e.second, e.second+1);
    if (e.second < W) {
      res += e.first*b;
      --a;
    } else {
      res += e.first*a;
      --b;
    }
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 6512
import bisect
import sys
from bisect import bisect_left
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]

def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return

main()


Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;
typedef long long ll;

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

    vector<vector<int>> p(n, vector<int>(2));
    for(int i=0; i<n; i++){
        cin >> p[i][0] >> p[i][1];
    }

    vector<vector<double>> d(n, vector<double>(n,0));
    double ans=0;
    int needNum = n-1, cntD = 0;
    for(int i=0; i<n;i++){
        for(int j=i+1; j<n; j++){
            if(i!=j){
                d[i][j] = sqrt(pow(p[i][0] -p[j][0], 2)+ pow(p[i][1] -p[j][1], 2));
                ans += needNum*(d[i][j]);
                cntD++;
            }
        }
    }

    ans = ans / cntD;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] imp = Console.ReadLine().ToArray();
            int L = imp.Length;
            Console.Write(imp[0]);
            Console.Write(L - 2);
            Console.Write(imp[L - 1]);
        }
    }
}


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

int main() {
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    
    while(true) {
        if (y < x) {
            break;
        }
        
        y >>= 1;
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
vec = []
for i in range(n):
    vec += [list(map(int, input().split()))]
vec += [vec[0]]
Sum = 0
def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]
for a, b in zip(vec[0:-1],vec[1:]):
    Sum += cross(a,b)/2
print(f'{abs(Sum):.1f}')


Measured memory_bytes: 5632
#include<iostream>
using namespace std;
bool CheckPalind(int num){
  int digit[5];
  for(int i=0;i<5;i++){digit[i]=num%10;num/=10;}
  if(digit[0]==digit[4] && digit[1]==digit[3]) return true;
  else return false;
}
int main(){
  int cnt=0;
  int a, b;cin>>a>>b;
  for(int s=a;s<=b;s++){if(CheckPalind(s))cnt++;}
  cout<<cnt<<endl;
}


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

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

int main() {
  int64_t A,B,gc;
  int64_t cnt = 1;
  cin >> A >> B;
  if(A >= B) gc = gcd(A,B);
  else if(A < B) gc = gcd(B,A);
  int64_t tmp=gc;
  for(int64_t i=2;i*i < tmp;i++){

    if(tmp % i == 0){
      cnt++;
      while(tmp%i==0){
        tmp /= i;
      }
    }
  }
  if(tmp != 1) cnt++;
  
  cout << cnt <<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class AStrings {
public:
    void solve(std::istream& in, std::ostream& out) {
        string S, T;
        in >> S >> T;
        out << T << S << "\n";
    }
};


int main() {
    AStrings solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("");
  var output = 0;
  for(var i = 0; i < input.length; i++){
    (input.slice(i,i+1) == "+") ? output++ : output--;
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<=d || (abs(a-b)<=d&&abs(c-b)<=d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int[] B = new int[N];
        for (int i = 0; i < N; i++)
        {
            int p = (N - 1) - i * 2;
            if (p < 0)
            {
                p = -p - 1;
            }
            B[i] = A[p];
        }
        Console.WriteLine(string.Join(" ", B));
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 42268
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val scanner = new Scanner(in)
    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val Array(d, n) = scanner.nextLine().split(" ").map(_.toInt)

      val x = Math.pow(100.toDouble, d.toDouble).toInt

      output.println(x * n + (if (n == 100) x else 0))
    }

  }

}


Measured memory_bytes: 25896
import collections

h,w=list(map(int,input().split()))
a=[input() for _ in range(h)]
#a[h][w]
direction=[[-1,0],[1,0],[0,-1],[0,1]]
visited=[[-1]*w for _ in range(h)]
q=collections.deque()

#全ての黒マスをキューに入れる
for hi in range(h):
  for wi in range(w):
    if a[hi][wi]=="#":
      q.append([hi,wi])
      visited[hi][wi]=0

while len(q)>0:
  ch,cw=q.popleft()
  for d in direction:
    nh=ch+d[0]
    nw=cw+d[1]
    #端からはみでない、まだ見てない白マス
    if nh>=0 and nw>=0 and nh<h and nw<w and visited[nh][nw]==-1:
      q.append([nh,nw])
      visited[nh][nw]=visited[ch][cw]+1

ans=0
for hi in range(h):
  tmp=max(visited[hi])
  if tmp > ans:
    ans=tmp
print(ans)


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

int main()
{
    int n,max=1e9+1,k;
    cin>>n>>k;
    
    int a[n];
    vector<int> dp(n,max);
    for(int i=0;i<n;i++)
    cin>>a[i];
    dp[0]=0;
    //dp[1]=abs(a[1]-a[0]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
        if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
      //  cout<<dp[i]<<" ";
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
using Printf

function f(a,b,θ)
    c = b*tan(θ)
    if c > a
        return (1+(c-a)/c)*b*a*a/2
    else
        return c*b*a/2
    end
end

function solve()
    A,B,X = parse.(Float32,split(readline()))
    lo = .0; hi = π/2
    for _ in 1:100
        θ = (lo+hi)/2
        f(A,B,θ) <= X ? lo=θ : hi=θ
    end
    @printf("%.9f\n", rad2deg(π/2-lo))
end
solve()

Measured memory_bytes: 210028