akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


int dis(uint a, uint b, uint N) {
	uint C = a ^ b;
	int n = 0;
	for (int i = 0; i < N; ++i) {
		if (((C >> i) & 1LL) != 0) {
			++n;
		}
	}
	return n;
}

uint eraseBit(uint x, int n) {
	x &= (~(1 << n));
	uint tmp0 = (x & ((1LL << n) - 1));
	uint tmp1 = (x & ~((1LL << n) - 1));
	tmp1 >>= 1;
	return tmp1 | tmp0;
}

uint insertBit(uint x, int n, uint b) {
	uint tmp0 = (x & ((1LL << n) - 1));
	uint tmp1 = (x & ~((1LL << n) - 1));
	tmp1 <<= 1;
	if (b != 0) {
		tmp0 |= (1LL << n);
	}
	return tmp1 | tmp0;
}

uint bit(uint x, int n) {
	return (x >> n) & 1;
}

std::vector<uint> impl(uint A, uint B, int N) {
	std::vector<uint> res(1 << N);
	if (N == 1) {
		return { A,B };
	}
	int id = -1;
	for (int i = 0; i < N; ++i) {
		if (bit(A, i) != bit(B, i)) {
			id = i;
			break;
		}
	}
	assert(id != -1);
	uint Abit = bit(A, id);
	uint Bbit = bit(B, id);
	uint A1 = eraseBit(A, id);
	uint B1 = eraseBit(B, id);
	uint C = A1 ^ 1;
	auto res0 = impl(A1, C, N - 1);
	auto res1 = impl(C, B1, N - 1);
	for (int i = 0; i < (1LL << (N - 1)); ++i) {
		res[i] = insertBit(res0[i], id, Abit);
		res[i + (1LL << (N - 1))] = insertBit(res1[i], id, Bbit);
	}
	return res;
}


signed main() {
	ios::sync_with_stdio(false);
	LOAD(uint, N);
	LOAD(uint, A);
	LOAD(uint, B);
	auto n = dis(A, B, N);
	if (n % 2 == 0) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	auto res = impl(A, B, N);
	for (int i = 0; i < (1LL << N); ++i) {
		cout << res[i];
		if (i == (1LL << N) - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return 0;
}
#endif


Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextLong();
        var B = sc.nextLong();
        var C = sc.nextInt();
        var D = sc.nextInt();

        var c = (B / C) - ((A - 1) / C);
        var d = (B / D) - ((A - 1) / D);
        var lcm = Lcm(C, D);
        var cnt = (B / lcm) - ((A - 1) / lcm);
        WriteLine((B-A+1) - (c + d - cnt));
    }

    public long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }

    public long Gcd(long a, long b) {
        if (a < b)
            return Gcd(b, a);
        while (b != 0) {
            var tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }
}

class Combination {
    static int mod = 1000000007;

    public static long Calc(int a, int b) {
        if (b > a - b) return Calc(a, a - b);

        long ansMul = 1;
        long ansDiv = 1;
        for (int i = 0; i < b; i++) {
            ansMul *= (a - i);
            ansDiv *= (i + 1);
            ansMul %= mod;
            ansDiv %= mod;
        }
        return ansMul * ModPow(ansDiv, mod - 2) % mod;
    }

    private static long ModPow(long a, int p) {
        if (p == 0) return 1;
        if (p % 2 == 0) {
            long half = ModPow(a, p / 2);
            return half * half % mod;
        } else {
            return a * ModPow(a, p - 1) % mod;
        }
    }
}

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;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>

using namespace std;

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

	int cnt = 0;
	int a = 0;
	int b = 0;

	bool flag = 1;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		int idx = s.find("AB");

		if (s.at(0) == 'B')
			b++;
		if (s.at(s.size() - 1) == 'A')
			a++;

		if ((s.at(0) == 'B') ^ (s.at(s.size() - 1) == 'A'))
			flag = 0;

		while (idx != string::npos)
		{
			cnt++;
			s = s.substr(idx + 2);
			idx = s.find("AB");
		}

	}

	cout << cnt + max(min(a,b) - flag, 0)<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
 
template <class T> T& chmin(T& a, T b){return (a > b) ? a = b : a;}
template <class T> T& chmax(T& a, T b){return (a < b) ? a = b : a;}
 
using lli = long long int;
 
std::vector<int> A;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    bool flag = true;
    int prev = -1;
    REP(i, n){
        if(prev > A[i]){ flag = false; break; }
        else if(prev == A[i]) prev = A[i];
        else prev = A[i] - 1;
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 768
// atcoder/abc174/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  str s;
  while (cin >> n >> s) {
    str t;
    t += string(count(s.begin(), s.end(), 'R'), 'R');
    t += string(count(s.begin(), s.end(), 'W'), 'W');
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
      cnt += (s[i] != t[i]);
    }
    cout << cnt/2 << endl;
  }

  return 0;
}


Measured memory_bytes: 3944
#include <stdio.h>

int return_ways(int N, int X)
{
    int i, j, k;
    int l = 0;

    for (i = 1; i <= N; i++)
    {
        for (j = 1; j <= N; j++)
        {
            for (k = 1; k <= N; k++)
            {
                int a = i + j + k;
                if (i != j && i != k && j != k && a == X) //i + j + kがxと一致し、i,j,kが全て違う数字であるとき
                {
                    if (i < j && j < k)
                        l++;
                }
            }
        }
    }
    return l;
}

int main(void)
{
    int n, x;

    while (1)
    {
        scanf("%d %d", &n, &x);

        if (n == 0 && x == 0)
        {
            break;
        }
        printf("%d\n", return_ways(n, x));
    }

    return 0;
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void) {
	int n,l,g;
	cin >> n >> l;
	g=l+n-1;
	int s = (l+g)*n/2;
	if(l<=0 && g>=0) cout << s << endl;
	else if(l>0) cout << s-l << endl;
	else cout << s-g << endl;
}


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

ll N, K;

ll power(ll x, ll n) {
  if (n == 0) {
    return 1;
  } else if (n > 0 && n % 2 == 0) {
    return ((power(x, n / 2)) * (power(x, n / 2)));
  } else if (n > 0 && n % 2 != 0) {
    return ((power(x, (n - 1) / 2)) * (power(x, (n - 1) / 2)) * x);
  } else {
    return -1;
  }
}

double p(int n) {
  ll cnt = 0, tmp = n;
  double res = 1;
  while (tmp < K) {
    tmp *= 2;
    res /= 2;
  }
  return res;
}

void solve() {
  double res = 0;
  for (int i = 1; i <= N; i++) {
    res += p(i);
  }
  cout << fixed << setprecision(10) << res / N << "\n";
}

int main() {
  cin >> N >> K;

  solve();
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := read()
	answer := ""
	for _, r := range n {
		answer += convertBoth(string(r), "1", "9")
	}
	fmt.Println(answer)
}

func convertBoth(s, a, b string) string {
	switch s {
	case a:
		return b
	case b:
		return a
	default:
		return s
	}
}

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


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void){
	int N, i, ans, sum = 1;
	scanf("%d", &N);
	int a[N];
	
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
		if(a[i] % 2 == 0)
			sum *= 2;
	}


printf("%d",(int)pow(3, N) - sum);
return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve(){
    int n;
    cin >> n;
    vec v(n);
    int a = 0;
    fo(i,n){
        cin >> v[i];
        a = (a ^ v[i]);
    }
    fo(i,n){
        cout << (a ^ v[i]) << " ";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    // 
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0; i < s.size(); ++i)
        cnt += s[i] != t[i];
    cout << cnt << "\n";
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3880
module Main where

import qualified Data.Map as Map
import Data.List
import Control.Monad

main :: IO ()
main = do
    n  <- read <$> getLine
    rs <- replicateM n $ do
        [x, y] <- map read . words <$> getLine
        return (x, y)
    bs <- replicateM n $ do
        [x, y] <- map read . words <$> getLine
        return (x, y)
    print $ solve (sortBy (flip compare) rs) bs

solve :: [(Int, Int)] -> [(Int, Int)] -> Int
solve [] _ = 0
solve rs bs =
    let (x, y) : rs' = rs
        bCand        = filter (\(a, b) -> x < a && y < b) bs
        compSnd p q = snd p `compare` snd q
    in  if null bCand
            then solve rs' bs
            else (1 +) $ solve rs' $ delete (minimumBy compSnd bCand) bs


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int cnt = 0;
	unordered_set<string> s;
	string str;
	for(int i=0;i<n;i++){
	   cin>>str;
	   if(s.find(str)==s.end()){
	       s.insert(str);
	       cnt++;
	   }
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 17732
import java.util.*;

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

		int n = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; ++i)
			x[i] = sc.nextInt();

		long all = 0;
		for (int i = 0; i < n; ++i)
			all += x[i];
		SegmentTree seg = new SegmentTree(n + 1);
		for (int i = 0; i < n; ++i) {
			long pre = seg.query(0, x[i]);
			seg.set(x[i], pre + x[i]);
		}
		long fix = seg.query(0, n + 1);
		System.out.println(all - fix);
	}

	static class SegmentTree {
		int n = 1;
		long[] val;

		public SegmentTree(int n) {
			while (this.n < n)
				this.n *= 2;
			val = new long[2 * this.n - 1];
		}

		void set(int k, long l) {
			k += n - 1;
			val[k] = l;
			while (k > 0) {
				k = (k - 1) / 2;
				val[k] = Math.max(val[2 * k + 1], val[2 * k + 2]);
			}
		}

		long query(int a, int b) {
			return query(a, b, 0, n, 0);
		}

		long query(int a, int b, int l, int r, int k) {
			if (r <= a || b <= l)
				return 0;
			else if (a <= l && r <= b) {
				return val[k];
			} else {
				long vl = query(a, b, l, (l + r) / 2, 2 * k + 1);
				long vr = query(a, b, (l + r) / 2, r, 2 * k + 2);
				return Math.max(vl, vr);
			}
		}
	}
}

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


namespace Library
{
    public class Miscelleneous
    {
        public static void print(object j){Console.WriteLine(j.ToString());}
        public static void print(string s){Console.WriteLine(s);}
        public static int[] cins(){
            string s=Console.ReadLine();
            if(string.IsNullOrEmpty(s))return new int[]{};
            string[] ss = s.Split(' ');
            int[] Res=new int[ss.Length];
            for(int i=0;i<ss.Length;i++){
                Res[i]=int.Parse(ss[i]);
                }
                return Res;
        }
        static bool[] cup=new bool[]{true,false,false};
        
        public static void Main(){
            string[] ss;
            string s;
            while(true){
                s=Console.ReadLine();
                if(string.IsNullOrEmpty(s))break;
                ss=s.Split(',');
                swap(ss[0][0]-65,ss[1][0]-65);
            }
            print((char)(Array.IndexOf(cup,true)+65));
        }
        
        static void swap(int a, int b){
            bool c=cup[a];
            cup[a]=cup[b];
            cup[b]=c;
        }
        
    }
}

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	if(n*500>=k){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
def dot3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy)
def cross3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def dist2(A, B):
    ax, ay = A; bx, by = B
    return (ax - bx) ** 2 + (ay - by) ** 2
def is_intersection(P0, P1, Q0, Q1):
    C0 = cross3(P0, P1, Q0)
    C1 = cross3(P0, P1, Q1)
    D0 = cross3(Q0, Q1, P0)
    D1 = cross3(Q0, Q1, P1)
    if C0 == C1 == 0:
        E0 = dot3(P0, P1, Q0)
        E1 = dot3(P0, P1, Q1)
        if not E0 < E1:
            E0, E1 = E1, E0
        return E0 <= dist2(P0, P1) and 0 <= E1
    return C0 * C1 <= 0 and D0 * D1 <= 0
for q in range(int(input())):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    print(+is_intersection((x0, y0), (x1, y1), (x2, y2), (x3, y3)))

Measured memory_bytes: 5628
#include <stdio.h>
int main(void){
	int x,y,num[100];
    scanf("%d\n",&x);
    for(int i = 0;i<x;i++){
		y = x-1-i;
		if(i ==(x-1)) scanf("%d",&num[y]);
	    else scanf("%d ",&num[y]);
	}
	for(int j = 0;j<x;j++){
		if(j == (x-1)) printf("%d\n",num[j]);
		else printf("%d ",num[j]);
	}
return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	ll v = 0;
	ll ans = 0;

	while(v < x) {
		ans++;
		v += ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int n,t;cin>>n>>t;
   vector<int>v(n);
   for(auto &x:v)cin>>x;
   vector<int>v2(n),v3(n-1);
   int maxm=INT_MIN;
   for(int i=n-1;i>=0;--i)
   {
     v2[i]=maxm;
     maxm=max(maxm,v[i]);
   }
   for(int i=0;i<n-1;++i)
   {
     v3[i]=v2[i]-v[i];
   }
   int maxelement=*max_element(all(v3));
   cout<<count(all(v3),maxelement);
   
}



Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

def judge(x):
    if N-P<=x<=N-1:
        return True
    if A[x]+M<A[N-P]:
        return False
    
    cnt = 0
    
    for i in range(N-P+1):
        if i==x:
            continue
        
        cnt += min(M, A[x]+M-A[i])
    
    return cnt>=M*(V-P)

def binary_search():
    l, r = 0, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

print(N-binary_search())

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

int main(){
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='9'){
      cout<<"Yes"<<endl;
      break;
    }
    if(i==a.size()-1)
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int k;
LL a[MaxN + 5];

int main()
{
	while(scanf("%d", &k) != EOF)
	{
		for(int i = 1; i <= k; i++) scanf("%lld", &a[i]);
		LL L = 2, R = 2;
		for(int i = k; i >= 1; i--) {
			L = (L + a[i] - 1) / a[i] * a[i];
			R = (R / a[i]) * a[i] + a[i] - 1;
		}
		if(L > R) printf("-1\n");
		else printf("%lld %lld\n", L, R);
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int size = S.size();
    if (S[0] != 'A')
    {
        cout << "WA" << endl;
        return 0;
    }
    int count = 0;
    rep(0, i, size)
    {
        if (S[i] < 'a')
        {
            count++;
        }
    }
    if (count != 2)
    {
        cout << "WA" << endl;
        return 0;
    }
    rep(2, i, size - 1)
    {
        if (S[i] == 'C')
        {
            cout << "AC" << endl;
            return 0;
        }
    }
    cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int dp[100001];

vint topological_sort(vvint G, vint indegree, int V) {
    queue<int> q;
    rep(i, V) if (indegree[i] == 0) q.push(i);

    vint tp;
    while(!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto u : G[v]) {
            indegree[u]--;
            if (!indegree[u]) {
                q.push(u);
                dp[u] = max(dp[u], dp[v]+1);
            }
        }

        tp.push_back(v);
    }

    return tp;
}

int main() {
    int v, e;
    cin >> v >> e;

    vvint edge(v);
    vint indeg(v, 0);
    rep(i, e) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        edge[s].push_back(t);
        indeg[t]++;
    }

    topological_sort(edge, indeg, v);
    
    int ans = 0;
    rep(i, v) ans = max(ans, dp[i]);

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

Measured memory_bytes: 13056
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;

int n;
vector<vector<pair<int,ll>>>g(100001);
vector<int> color(100001,0);
void dfs(int x, int c) {
	color[x] = c;

	for (int i = 0; i < g[x].size(); i++) {
		if (color[g[x][i].first] == 0 && g[x][i].second%2==0 ) dfs(g[x][i].first,c);
		if (color[g[x][i].first] == 0 && g[x][i].second % 2 == 1) dfs(g[x][i].first, -c);
	}
	
}

int main() {
	cin >> n;
	rep(n - 1) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].push_back(make_pair(b, c));
		g[b].push_back(make_pair(a, c));
		
	}
	
	
		dfs(0, 1);
	
	rep(n) {
		if (color[i] == 1)cout << 1 << endl;
		else cout << 0 << endl;
	}
	
	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a;i<=b;i++){
    int key = i;
    if (key%10 == key/10000){
      if (key/10-key/100*10 == key/1000-key/10000*10){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

const long long mod=1000000007ll;

void ad(long long &a,long long b){a+=b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}

long long inv[4000010],P[4000010],rP[4000010];

long long Ch(int i,int j)
{
  return P[i]*rP[j]%mod*rP[i-j]%mod;
}

int main()
{
  inv[1]=1;
  for(int i=2;i<=2000*2000;i++){
    inv[i]=(mod-mod/i)*inv[mod%i]%mod;
  }
  P[0]=rP[0]=1;
  for(int i=1;i<=2000*2000;i++){
    P[i]=i*P[i-1]%mod;
    rP[i]=inv[i]*rP[i-1]%mod;
  }
  int n,k;
  scanf("%d%d",&n,&k);
  if(k==1){
    printf("%lld\n",1);
    return 0;
  }
  static long long dp[2001][2001]={0};
  dp[0][0]=1ll;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(i+1<=n){
	ad(dp[i+1][j],dp[i][j]);
      }
      if(j+1<=i){
	ad(dp[i][j+1],Ch(n*k-i-(k-1)*j-1,k-2)*dp[i][j]%mod);
      }
      //printf("%d %d %lld %d %d\n",i,j,dp[i][j],n*k-i-(k-2)*j-1,k-2);
    }
  }
  long long A=dp[n][n];
  for(int i=1;i<=n;i++){
    ml(A,i);
  }
  printf("%lld\n",A);
  return 0;
}


Measured memory_bytes: 116480
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

N,P=map(int, sys.stdin.readline().split())
S=sys.stdin.readline().strip()
S=S[::-1]

ans=0
if P in (2,5):
    len_S=len(S)
    for i,x in enumerate(S):
        x=int(x)
        if x%P==0:
            ans+=(len_S-i)
    print ans
else:
    L=[0] 
    val=0
    for i,x in enumerate(S):
        x=int(x)
        val+=pow(10,i,P)*x
        L.append(val%P)

    C=defaultdict(lambda: 0)
    for x in L:
        ans+=C[x]
        C[x]+=1
    print ans


Measured memory_bytes: 40860
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int H = (int) (Math.pow(10,7)+5);
	        int[] m = new int[H];
	        for(int i=1;i<H;i++) {
        		for(int j=i;j<H;j=j+i) {
        			m[j]++;
        		}
	        }
	        
	        int N = sc.nextInt();
	        long ans=0;
	        for(int i=1;i<=N;i++) {
	        	ans=ans+(long)(i*(long)m[i]);
	        }
	        System.out.println(ans);
		 }
	}

Measured memory_bytes: 75548
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

int main() {
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s; cin >> s;

	rep(i, b + 1, d) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, a + 1, c) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}

	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		bool three = false;
		repe(i, b, d) {
			if (s[i - 1] == '.' && s[i] == '.'  && s[i + 1] == '.') {
				three = true;
			}
		}

		cout << (three ? "Yes" : "No") << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 640
use std::vec::Vec;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let w: Vec<i64> = read_vec();
    let mut v: Vec<i64> = vec![0; n+1];

    for i in 0..n {
      v[i+1] = w[i] + v[i];
    }

    let sum = w.iter().fold(0, |sum, acc| sum + acc);
    let mut res = 1_000_000_0;
    for i in 0..n {
      if (sum - 2 * v[i]).abs() < res {
        res = (sum - 2 * v[i]).abs()
      }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	string S;
	cin >> S;
	int hand = 0, rock = 0, cnt = 0;
	for (ll i = 0; i < S.size(); i++) {
		if (hand < rock) {
			if (S[i] == 'g') { hand++; cnt++; }
			else { hand++;}
		}
		else if (hand == rock) {
			if (S[i] == 'g') { rock++; }
			else { rock++; cnt--; }
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

using Ki = vector<vector<int>>;
using Vi = vector<int>;

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

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int count=1;
    int ans=0;
    rep(i,n){
        if(a[i]==count){
            count++;
        }
        else{
            ans++;
        }
    }
    if(ans==n){
        cout<<-1<<endl;
    }
    else{
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1792
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  readln;
  auto a = readln.chomp.split.map!(to!int).array.sort();
  writeln(a[$-1]-a[0]);
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<pair<int,string>>v;
    int n,m,a,i;
    string b;
    cin>>n>>m;
    int cnt[n+10];
    memset(cnt,0,sizeof(cnt));
    for(i=0;i<m;i++)
    {
      cin>>a>>b;
      v.push_back(make_pair(a,b));
    }
//    sort(v.begin(),v.end());
//    for(i=0;i<m;i++)
//    {
//      cout<<v[i].first<<" "<<v[i].second<<endl;
//    }
    int ac=0,wa[n+10]={0},judge=0;
    for(i=0;i<m;i++)
    {
      if(v[i].second=="WA"&&cnt[v[i].first]==0)
      {
        wa[v[i].first]++;
      }
      else if(v[i].second=="AC"&&cnt[v[i].first]==0)
      {
        ac++;
        judge+=wa[v[i].first];
        cnt[v[i].first]=1;
      }
    }
    cout<<ac<<" "<<judge<<endl;
    return 0;
}

Measured memory_bytes: 7280
#include <iostream>
#include <algorithm>

using namespace std;

const long long int INF=1e16;

int main() {
    long long int H, W;
    cin >> H >> W;

    long long int ans=INF, Sx, Sn;
    Sx = max(H/3, max((H-H/3)/2, (H-H/3)-(H-H/3)/2))*W;
    Sn = min(H/3, max((H-H/3)/2, (H-H/3)-(H-H/3)/2))*W;
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;
    
    Sx = max(W/3, max((W-W/3)/2, (W-W/3)-(W-W/3)/2))*H;
    Sn = min(W/3, max((W-W/3)/2, (W-W/3)-(W-W/3)/2))*H;
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;

    Sx = max(H/2, (long long int)1)*W;
    Sn = min(W/2, W-W/2)*(H-H/2);
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;
    
    Sx = max(W/2, (long long int)1)*H;
    Sn = min(H/2, H-H/2)*(W-W/2);
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;

    Sx = max(H/3*W, max(W/2, W-W/2)*(H-H/3));
    Sn = min(H/3*W, min(W/2, W-W/2)*(H-H/3));
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;
    
    Sx = max((H/3+1)*W, max(W/2, W-W/2)*(H-H/3-1));
    Sn = min((H/3+1)*W, min(W/2, W-W/2)*(H-H/3-1));
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;

    Sx = max(W/3*H, max(H/2, H-H/2)*(W-W/3));
    Sn = min(W/3*H, min(H/2, H-H/2)*(W-W/3));
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;

    Sx = max((W/3+1)*H, max(H/2, H-H/2)*(W-W/3-1));
    Sn = min((W/3+1)*H, min(H/2, H-H/2)*(W-W/3-1));
    ans = min(ans, Sx-Sn);
    // cout << Sx << ", " << Sn << endl;
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3600
using System;
 
public class test{
  static void Main (string[] args)
  {
    var first = 0;
    var second = 0;
    var therd = 0;
    var height = 0;
    for(int i = 0; i < 10; i++)
    {
        height = int.Parse(Console.ReadLine());
        if(height >= first)
        {
            therd = second;
            second = first;
            first = height;
        }
        else if(height >= second)
        {
            therd = second;
            second = height;
        }
        else if(height >= therd)
        {
            therd = height;
        }
    }
    
        Console.Write("{0}\n",first);
        Console.Write("{0}\n",second);
        Console.Write("{0}\n",therd);
        
  } 
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int x; cin>>n>>x;
    int sum=0;
    int w[n],v[n];
    rep(i,0,n-1){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    vector<int> dp(sum+1,INF);
    dp[0]=0;
    rep(i,0,n-1){
        rep1(j,sum-v[i],0){
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    rep(i,0,sum){
        if(dp[i]<=x){
            ans=i;
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;

#define MAXN 100100
int N, M;
vector<vi> G(MAXN);
int dp[MAXN];

int dfs(int v) {
    if(dp[v] != -1) {
        return dp[v];
    }
    dp[v] = 0;
    for(auto &i : G[v]) {
        dp[v] = max(dfs(i) + 1, dp[v]);
    }
    return dp[v];
}

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d%d", &N, &M);

    for(int i = 0; i < M; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].pb(b);
    }
    
    
    int len = 0;
    for(int i = 1; i <= N; ++i) {
        len = max(dfs(i), len);
    }
    printf("%d\n", len);

    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  int n = 0;
  cin >> A >> B;
 
  for (int i = A;  i <= B; i++) {
  	int r = i % 10;
    int w = i / 10 % 10;
    int y = i / 1000 % 10;
    int x = i / 10000;
    if (x == r && y == w) n++;
  }
  cout << n << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);
    rep(i, D) cin >> T[i];
    vector<ll> last(26, 0);

    ll sum = 0;
    rep(d, D) {
        ll t = T[d];
        sum += S[d][t - 1];
        last[t - 1] = d + 1;
        rep(i, 26) {
            sum -= C[i] * ((d + 1)  - last[i]);
        }
        cout << sum << '\n';
    }
}

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


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30;

int H, W;
vector<string> C;
vector<vector<int>> score;
queue<P> q;
int ans = INF;
int white = 0;

vector<int> dy = {-1, 1, 0, 0};
vector<int> dx = {0, 0, -1, 1};

void bfs(){
    while(!q.empty()){
        P p = q.front();
        q.pop();
        int y = p.first;
        int x = p.second;
        if(P(y,x)==P((H-1),(W-1))){
            ans=score[y][x];
            return;
        }
        for(int i=0; i<4; i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny>=0 && ny<H && nx>=0 && nx<W && score[ny][nx]==INF && C[ny][nx]=='.'){
                score[ny][nx] = score[y][x]+1;
                q.push(P(ny, nx));
            }
        }
    }
    return;
}


int main() {
    cin >> H >> W;
    C.resize(H);
    for(string &s:C){
        s.resize(W);
        cin >> s;
        for(char &c:s) if(c=='.') white++;
    }
    score.resize(H);
    for(vector<int> &v:score) v.resize(W, INF);

    q.push(P(0,0));
    score[0][0] = 0;
    bfs();

    if(ans==INF) cout << -1 << endl;
    else cout << white-ans-1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int a = saori.saori_hayami();
		System.out.println(n*n - a);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
  vector<int> n(4);
  for (int i=0; i<4; i++) cin >> n[i];
  sort(n.begin(), n.end());
  string ans = "YES";
  if (n[0] != 1 || n[1] != 4 || n[2] != 7 || n[3] != 9) ans = "NO";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = 0
f = 0
for i in range(n):
    if a[i] == 0:
        b = 1
    else:
        if a[i] < 0:
            f += 1
    a[i] = abs(a[i])
m = min(a)
if b == 1 or f % 2 == 0:
    ans = sum(a)
else:
    ans = sum(a) - 2*m
print(ans)

Measured memory_bytes: 64752
# N = 食数
# x = 今までに払った金額
# y = 値引きされた金額

N = int (input ())

x = int(800 * N)

# （気付き）int を付けない場合→小数点以下も表示される
y = int(N / 15)* 200

print( x - y )




Measured memory_bytes: 9084
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// pair<int,int>ert(x==y); gives run time when false
using namespace std;
int main()
{
    CIN;
    int n, k;
    cin >> n >> k;
    vi v(n);
    rep(i, 0, n)
    {
        cin >> v[i];
    }
    // idx | how many
    bool dp[k + 1][2];
    rep(j, 0, k + 1)
    {
        rep(ii, 0, 2)
        {
            dp[j][ii] = 0;
        }
    }
    per(i, k, -1)
    {
        rep(ii, 0, 2)
        {
            rep(j, 0, n)
            {
                if (i + v[j] > k)
                {
                    break;
                }
                dp[i][ii] = max((int)dp[i][ii], 1 - dp[i + v[j]][1 - ii]);
            }
        }
    }
    if(dp[0][0]){
        cout << "First";
    }else{
        cout << "Second";
    }
    //cout << dp[0][0];
}

Measured memory_bytes: 512