akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  ans += n / 11;
  n -= ans * 11;
  ans *= 2;
  n <= 6 ? ans += 1 : ans += 2;
  n == 0 ? ans-- : 1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int K;
    string S;
    cin>>K>>S;
    if(S.size()<=K)
    {
        cout<<S;
    }
    else
    {
        for (size_t i = 0; i < K; i++)
        {
            cout<<S[i];
        }
        cout<<"...";
    }
    
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = 1 << 30;

int main()
{
	float top = -1, bottom = INF;
	float in;
	while(cin >> in)
	{
		chmax(top, in);
		chmin(bottom, in);
	}
	
	cout << top - bottom << endl;
}

Measured memory_bytes: 0
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	N := 100010
	p := NewPrimes(N)
	sum := make([]int, N)
	for i := 1; i < N; i++ {
		if i%2 != 0 {
			sum[i] = sum[i-1]
			continue
		}
		var v int
		n := i - 1
		if p[n] && p[(n+1)/2] {
			v = 1
		}
		sum[i] = sum[i-1] + v
	}
	Q := readInt()
	for i := 0; i < Q; i++ {
		l := readInt()
		r := readInt()
		println(sum[r+1] - sum[l])
	}
}

func NewPrimes(n int) []bool {
	m := n + 1
	p := make([]bool, m)
	for i := 3; i < m; i += 2 {
		p[i] = true
	}
	p[2] = true
	for i := 3; i*i < m; i += 2 {
		if !p[i] {
			continue
		}
		for j := i + i; j < m; j += i {
			p[j] = false
		}
	}

	return p
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int i,j;
	int r,c;
	int a[101][101] = {0};

	scanf("%d %d", &r,&c);

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
				scanf("%d", &a[i][j]);
			}	
	}

	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
				a[i][c] += a[i][j];
			}	
	}

	for(j = 0; j < c; j++){
		for(i = 0; i < r; i++){
				a[r][j] += a[i][j];
			}	
	}

	for(i = 0; i < r; i++){
		a[r][c] += a[i][c];
	}

	for(i = 0; i <= r; i++){
		for(j = 0; j <= c; j++){
			printf("%d",a[i][j]);
			if(j != c){
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 652
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]
    
    if n >= m {
        print(0)
        return
    }

    let X = readWords { Int($0)! }.sorted()

    // 区間が得られる。
    // 問題を簡単にしてみる。
    // コマが1つなら答えは X[m-1] - X[0]
    // コマが複数あるなら、訪れない区間ができるのでそのうち一番広い区間を選択すれば良い。
    // コマが2つなら、訪れない区間は1つ。-> 全体から最も広い区間を1つ引く。
    // コマがn個なら、訪れない区間はn-1つ。 -> 全体から広い区間をn-1個引く。

    var distances = (1..<m).map { X[$0] - X[$0-1] }
    distances.sort(by: >)

    print(distances[(n-1)...].reduce(0, +))
}


main()

Measured memory_bytes: 18448
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)

for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

Measured memory_bytes: 7760
n,k=map(int,input().split())
x=[c for c in range(1,n+1)]
for i in range(1,k+1):
  d_i=int(input())
  s_i=input().split()
  for b in range(d_i):
    if int(s_i[b]) in x:
      x.remove(int(s_i[b]))
print(len(x))





Measured memory_bytes: 9192
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    vector<char>vc;
    for(char ch='A';ch<='Z';ch++)vc.p_b(ch);
    for(char ch='A';ch<='Z';ch++)vc.p_b(ch);
    string s,t;
    cin>>n>>s;
    ll l=s.size();
    FOR(i,l)
    {
        ll x=s[i]-'0'-17;
        ///cout<<x<<endl;
        x+=n;
        t+=vc[x];
    }
    cout<<t<<endl;
}
/*
5
4
3
2
3
4
4
3
3
4
2
3
*/


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

int main() {
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    if ((B/K)*K >= A) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
#define MAX_N 100000000
int main() {
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N - H + 1) * (N - W + 1) << endl;
  return 0;
}


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

inline int lowbit(int n){return n & (-n);}

const int moder = 1e9 + 7;
const int N = 300;

int n, m;
int power[N], fac[N], inv[N], mat[N][N], digit[N], dp[1 << 16];

int powermod(int a, int exp){
	int ret = 1;
	for ( ; exp; exp >>= 1){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
	}
	return ret;
}

int comb(int n, int m){
	if (n < m || m < 0){
		return 0;
	}
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[N - 1] = powermod(fac[N - 1], moder - 2);
	for (int i = N - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	power[0] = 1;
	for (int i = 1; i < N; ++ i){
		power[i] = 2 * power[i - 1] % moder;
	}
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		-- u, -- v;
		mat[u][v] = 1;
	}
	for (int i = 0; i < 1 << n; ++ i){
		if ((i >> 0 & 1) != (i >> 1 & 1)){
			continue;
		}
		int cnt = 0, x = i, y;
		for ( ; x; x -= lowbit(x)){
			digit[cnt ++] = lowbit(x);
		}
		if (i != 1 && i != 2){
			dp[i] = 1;
		}
		for (int j = 0; j < 1 << cnt; ++ j){
			x = 0;
			for (int k = 0; k < cnt; ++ k){
				if (j >> k & 1){
					x ^= digit[k];
				}
			}
			y = i ^ x;
			if ((x >> 0 & 1) != (x >> 1 & 1) || !x || !y){
				continue;
			}
			int ans = 1, cccnt = 0;
			for (int k = 0; k < n; ++ k){
				if (y >> k & 1){
					int ccnt = 0;
					for (int kk = 0; kk < n; ++ kk){
						if (x >> kk & 1){
							if (mat[k][kk]){
								++ ccnt;
							}
							if (mat[kk][k]){
								++ cccnt;
							}
						}
					}
					ans = 1ll * ans * (power[ccnt] - 1 + moder) % moder;
				}
			}
			dp[i] = (dp[i] + 1ll * ans * power[cccnt] % moder * dp[y]) % moder;
		}
	}
	return printf("%d\n", (power[m] - dp[(1 << n) - 1] + moder) % moder), 0;
}

Measured memory_bytes: 384
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans


'''
p = 10 ** 9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
'''


#a = list(map(int, input().split()))

n,a,b = list(map(int, input().split()))

p = 10 ** 9 + 7
N = 10 ** 5 * 5
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
        

di131072 = 1

for i in range(131072):
    di131072 *= 2
    di131072 %= p
    
q = n // 131072
r = n % 131072


ans = 1

for i in range(q):
    ans *= di131072
    ans %= p
for i in range(r):
    ans *=2
    ans %=p
    
fact2num = max(a,b)+2
fact2 = []
now = 1

for i in range(fact2num):
    now *= (n-i)
    now %= p
    fact2.append(now)
#print(fact2)
#print(factinv[0:4])

#print(ans)
    
ans -= 1
ans -= (fact2[a-1] * factinv[a])%p
#print((fact2[a-1] * factinv[a])%p)
ans -= (fact2[b-1] * factinv[b])%p
#print((fact2[b-1] * factinv[b])%p)
ans%=p

#print()
print(ans)
























Measured memory_bytes: 118632
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    input!{ l: usize, r: usize }
    let mut min = 10000;

    if r - l >= 2018 {
        min = 0;
    } else {
        'outer : for i in l..r+1 {
            for j in i+1..r+1 {
                let ii = i%2019;
                let jj = j%2019;
                if ii == 0 || jj == 0 {
                    min = 0;
                    // println!("i {} j {} min {}",i,j, min);
                    break 'outer;
                }
                let tmp = (ii*jj)%2019;
                if min > tmp {
                    min = tmp;
                }
                // println!("i {} j {} min {}",i,j, min);
            }
        }
    }
    println!("{}", min);
}

Measured memory_bytes: 4352
// Standard libraries
#include <stdio.h>
#include <stdlib.h>
#include <vector>

// Typedef
typedef long long int lld;

void impossible(){
    printf("0\n");
    exit(0);
}

const lld mod = 998244353;
lld pow(lld a, lld p){
    if(p==0) return 1;
    lld half = pow(a, p/2);
    if(p%2 == 0) return half*half % mod;
    else return half*half%mod * a%mod;
}

// Main
int main(int argc, char **argv){
#ifdef __McDic__ // Local testing I/O
    freopen("VScode/IO/input.txt", "r", stdin);
    freopen("VScode/IO/output.txt", "w", stdout);
#endif

    int n; scanf("%d", &n);
    std::vector<int> d(n); for(int i=0; i<n; i++) scanf("%d", &d[i]);

    if(d[0] != 0) impossible();
    std::vector<int> distances(n, 0);
    for(int i=0; i<n; i++){
        distances[d[i]]++;
        if(i>0 && d[i] == 0) impossible();
    }

    int maxdist = -1;
    for(int i = n-1; i>=0; i--) if(distances[i] != 0){
        maxdist = i;
        break;
    }
    for(int i=0; i<=maxdist; i++) if(distances[i] == 0) impossible();

    lld answer = 1;
    for(int i=1; i<=maxdist; i++) answer = answer * pow(distances[i-1], distances[i]) % mod;
    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int gcd(int x, int y) {
	if (y > x)swap(x, y);
	if (x % y == 0) return y;
	else return gcd(y, x % y);
}
int main() {
	long long a, b, c, d; cin >> a >> b >> c >> d;
	long long n = 0, m = 0, sum = 0, num = 0;
	n = (b / c) - (a / c);
	if (a % c == 0) { n++; }
	m = (b / d) - (a / d);
	if (a % d == 0) { m++; }
	sum = (b / (c * d / gcd(c, d))) - (a / (c * d / gcd(c, d)));
	if (a % (c * d / gcd(c, d)) == 0) { sum++; }
	num = n + m - sum;
	cout << b - a + 1 - num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a = {11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};
  int n;
  cin >> n;
  for (int i = 0; i<n; i++){
    cout << a[i];
    if (i!=n-1) cout << " ";
  }
}


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

#define ll long long
using namespace std; 
ll f[64][2][2][2][2];ll l,r;ll ans1=0;int l1[64],r1[64];ll mod=1e9+7;
ll dfs(int pos,int tl,int tr,int ts,int th){
	if(pos<0) return 1;ll &ans=f[pos][tl][tr][ts][th];
	if(ans) return ans;
	
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){int fs=ts,fl=tl,fr=tr,fh=th;
			if(!th&&i)if(i!=j)continue;
			if((j&i)!=j) continue;
			if(!tl&&l1[pos]>j) continue;
			if(!tr&&r1[pos]<i) continue;
			if(!ts&&j>i) continue;
			if(j<i) fs=1;if(j>l1[pos])fl=1;if(i<r1[pos])fr=1;if(j) fh=1;
			ans+=dfs(pos-1,fl,fr,fs,fh);
		}
	}ans%=mod;
	return ans;
}
int main(){
	cin>>l>>r;
	for(int i=63;i>=0;i--)
	{
		l1[i]=(bool)((1ll<<i)&l);r1[i]=(bool((1ll<<i)&r));
	}
cout<<dfs(63,0,0,0,0);
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int A, B;
    cin >> A >> B;

    int remain = A - 2 * B;
    if (remain < 0)
        remain = 0;

    cout << remain << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,n,m,H,W;
  n=0;
  m=0;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 || W==0)break;
    for(i=0;i<H;i++){
      if(i%2==0){
	for(j=0;j<W;j++){
	  if(j%2==0)printf("#");
	  else printf(".");
	}
      }
      else {
	for(j=0;j<W;j++){
	  if(j%2==0)printf(".");
	  else printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import heapq
n,m = map(int,input().split())
A = [-n for n in map(int,input().split())]
heapq.heapify(A)
while m >= 1:
    k = (-heapq.heappop(A))//2
    heapq.heappush(A, -k)
    m -= 1
print(-sum(A))

Measured memory_bytes: 14180
// 2014/06/16 Tazoe

#include <iostream>
using namespace std;

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}
		
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				for(int x=0; x<m; x++){
					if(C[j][x]>C[j][i]+C[i][x]){
						C[j][x]=C[j][i]+C[i][x];
					}
				}
			}
		}
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				for(int x=0; x<m; x++){
					if(T[j][x]>T[j][i]+T[i][x]){
						T[j][x]=T[j][i]+T[i][x];
					}
				}
			}
		}
		
		int k;
		cin>>k;
		
		int p;
		int q;
		int r;
		bool u[m];
		for(int i=0; i<k; i++){
			cin>>p>>q>>r;
			if(r==0){
				cout<<C[p-1][q-1]<<endl;
			}
			else{
				cout<<T[p-1][q-1]<<endl;
			}
		}
		


	}

	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> ans(n+1, 0);
    for (int i = 1; i <= 100; ++i) {
        for (int j = 1; j <= 100; ++j) {
            for (int k = 1; k <= 100; ++k) {
                int tmp = i*i + j*j + k*k + i*j + j*k +k*i;
                if (tmp <= n) {
                    ++ans[tmp];
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main(){
	int x,y,ans;
	cin >> x >> y;
	if(x==0){
		ans=abs(y);
		if(y<0)ans++;
	}else if(y==0){
		ans=abs(x);
		if(x>0)ans++;
	}else if(x*(-1)==y){
		ans=1;
	}else if(x>0 && y>0){
		if(x<y)ans=y-x;
		else ans=x-y+2;
	}else if(x<0 && y<0){
		if(x<y)ans=y-x;
		else ans=x-y+2;
	}else{
		ans=abs(abs(x)-abs(y))+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll mod = 1000000007;
  ll N;
  cin >> N;
  vector<ll> C(N);
  vector<vector<ll>> color(2 * 100000);
  for (ll i = 0; i < N; ++i) {
    ll c;
    cin >> c;
    C.at(i) = c - 1;
    color.at(c - 1).push_back(i);
  }
  vector<ll> dp(N + 1, 0);
  dp.at(0) = 1;
  for (ll i = 0; i < N; ++i) {
    dp.at(i + 1) = dp.at(i);
    ll index = lower_bound(color.at(C.at(i)).begin(), color.at(C.at(i)).end(), i) - color.at(C.at(i)).begin() - 1;
    if (index >= 0) {
      ll j = color.at(C.at(i)).at(index);
      if (i - j > 1) {
        // cout << i << ' ' << j << endl;
        dp.at(i + 1) = (dp.at(i + 1) + dp.at(j + 1)) % mod;
      }
    }
  }
  cout << dp.at(N) << endl;
  // for (ll i = 0; i < N + 1; ++i) {
  //   cout << dp.at(i) << ' ';
  // }
  // cout << endl;
}


Measured memory_bytes: 14336
A,B=map(int,input().split())
if A>B:
  if (A-B)%2==0:
    print(B+(A-B)//2)
  else:
    print("IMPOSSIBLE")
else:
  if (B-A)%2==0:
    print(A+(B-A)//2)
  else:
    print("IMPOSSIBLE")

Measured memory_bytes: 9144
#include<iostream>
#include<string.h>
#include<vector>
#include <algorithm>
using namespace std;

bool istri(int a,int b, int c)
{  
  if(a==b || b==c || c==a) return false;  
  if(c<a+b){return true;}
  return false;
}

int main()
{
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++)
    cin >> L[i];
  
  sort(L.begin(), L.end());
//  L.erase(std::unique(L.begin(), L.end()), L.end());

  #if 0
  N = L.size();  
  cout << N<<endl;
  for(int i=0;i<N;i++)
    cout << L[i] << ",";
  #endif
  
  long long count = 0;
  for(int i=0;i<N-2;i++)
  {
    for(int j=i+1;j<N-1;j++)
    {
      for(int k=j+1;k<N;k++)
      {
        if(istri(L[i],L[j],L[k]))
          count++;
      }
    }
  }
          
  cout << count ;
  return 0;
  
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

int main() {
	int n; cin >> n;
	double v;
	priority_queue<double, vector<double>, greater<double> > pq;
	for (int i = 0; i < n; ++i) {
		cin >> v;
		pq.push(v);
	}
	while (pq.size() != 1) {
		double x, y;
		x = pq.top(); pq.pop();
		y = pq.top(); pq.pop();
		pq.push((x + y) / 2);
	}
	printf("%.9f\n", pq.top());

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[a[i]-1] == i+1){
            cnt++;
        }
    }
    cout << cnt/2 << endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<int>B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }

  int a=0;
  if(N==2){
    a=2*B.at(0);
  }
  if(N>2){
    for (int i = 0; i < N-2; i++) {
      if(B.at(i+1)<B.at(i)){
        a+=B.at(i+1);
      }
    }
    for (int i = 0; i < N-2; i++) {
      if(B.at(i+1)>=B.at(i)){
        a+=B.at(i);
      }
    }
    a+=B.at(0)+B.at(N-2);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
void count(int a[],int b[],int n){
  int i,j,c;
  for(i=0;i<n;i++){
    c=0;
    for(j=0;j<n;j++){
      if(a[i]==a[j])
    c++;
    }
    b[i]=c;
  }
}
 
int main(void){
  int a[12],b[12],c[12],n,i;
  long long int ans;
  while(scanf("%d",&n),n){
    ans=0;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    for(i=0;i<n;i++)
      scanf("%d",&a[i]);
    memcpy(c,a,sizeof(a));
    while(1){
      count(a,b,n);
      if(memcmp(b,c,sizeof(int)*n)==0)break;
      else{
	ans++;
	memcpy(c,b,sizeof(b));
	memcpy(a,b,sizeof(b));
      }
    }
    printf("%lld\n",ans);
    for(i=0;i<n-1;i++)
      printf("%d ",b[i]);
    printf("%d\n",b[i]);
  }
  return 0;
}

Measured memory_bytes: 616
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xList = readLine()!!.split(' ').map(String::toInt).sorted()
    var min = Int.MAX_VALUE
    for (i in 1..100) {
        min = Math.min(min, xList.map { (it - i) * (it - i) }.sum())
    }
    println(min)
}

Measured memory_bytes: 38176
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k >= a) ans += a, k -= a;
    else ans += k, k = 0;
    if(k >= b) k -= b;
    else k = 0;
    if(k >= c) ans -= c;
    else ans -= k;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int cnt4 = 0, cnt_not_even = 0;
	rep(i, 0, N) {
		int a;
		cin >> a;
		if(a % 4 == 0) cnt4++;
		else if(a % 2 != 0) cnt_not_even++;
	}

	if(cnt_not_even == 0) cout << "Yes" << endl;
	else if(N == 3 and cnt4 > 0) cout << "Yes" << endl;
	else if(N / 2 <= cnt4) cout << "Yes" << endl;
	else if(cnt4 >= cnt_not_even) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE -1

void printBoard(void );
void putQueen(int );

int row[N],col[N];
int dpos[15],dneg[15];
int X[N][N];

int main(){
  int i,j,r,c,k;

  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++) X[i][j] = 0;
  }

  scanf("%d",&k);
  for(i=0; i<k; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }

  for(i=0 ; i<N ; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i=0 ; i<15 ; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }

  putQueen(0);

  return 0;
}



void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }
  for(j = 0; j < N; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}


void printBoard(){
  int i,j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>

#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	vector<int> a(5);
	bool f = true;

	for(int i = 0; i < 5; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	for(int i = 0; i < 5; i++){
		if(!f){
			cout << ' ';
		}
		cout << a[4-i];
		f = false;
	}
	cout << endl;


	return 0;
}

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

const int MOD = 1e5;

int main() {
    string s, t;
    cin >> s >> t;
    string ns = t.substr(0, s.size());
    if (s == ns) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
s = [0] + list(map(int,input().split())) + [0]
sum = 0

for i in range(len(s)):
    if i > 0 and i <= len(s)-1:
        sum += abs(s[i]-s[i-1])
    
        
for i in range(1,len(s)-1):
    a = abs(s[i]-s[i-1])
    b = abs(s[i]-s[i+1])
    c = abs(s[i-1]-s[i+1])
    print(sum - a - b + c)


Measured memory_bytes: 13920
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 220000
#define offset 
const ll MOD= 1e9+7;
int mapa[tam];
ll getsum(ll posi,ll posf )
{
    ll res=(posf*(posf+1)/2)-((posi*(posi-1))/2);
    return res;
}
int main()
{
    int n,k;
    cin>>n>>k;
    ll tot=0;
    forr(i,k,n+2)
    {

        tot+=getsum(n-i+1,n)-getsum(0,i-1)+1;
        //cout<<tot<<' '<<i<<endl;
    }
    cout<<tot%MOD<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll Mod=1e9+7;


vector<ll> inv,fact,invfact;
void Mod_build(int n=101010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}

int main(){
  int i,j;
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  Mod_build();
  ll ans=0;
  for(i=0;i<n;i++){
    ans+=a[i]*comb(i,k-1)%Mod;
    ans%=Mod;
    ans+=(Mod-a[i])*comb(n-i-1,k-1)%Mod;
    ans%=Mod;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	string s;
	cin>>s;
	ll res{},ans{};
	For(i,0,s.size())
	{
		if(s[i]=='R')res++;
		else ans=max(ans,res),res=0;
	}
	if(res>0)ans=max(ans,res);
	cout<<ans<<'\n';
	//system("pause");
	return 0;	
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll ctoi(const char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return -1;
  }
}

int main() {
  vector<vector<int>> dp(2, vector<int>(2019, 0));

  string S;
  cin >> S;
  ll ans = 0;
  REP(i, S.size()) {
    dp[1][ctoi(S[i])] += 1;
    REP(j, 2019) {
      ll nextj = (j * 10 + ctoi(S[i])) % 2019;
      dp[1][nextj] += dp[0][j];
      // if (nextj == 0 && dp[0][j] != 0) {
      //   cout << "nextj-" << nextj << endl;
      //   cout << "j-" << j << endl;
      // }
    }
    ans += dp[1][0];
    // cout << "ans" << ans << endl;
    REP(j, 2019) {
      dp[0][j] = dp[1][j];
      dp[1][j] = 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3740
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll n;
void mul(vector<vi>&a,vector<vi>b)
{
	vector<vi> temp(n,vi(n));
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			temp[i][j]=0;
			rep(k,0,n)
			temp[i][j]=(temp[i][j]+a[i][k]*b[k][j])%hell;
		}
	}
	a=temp;
}
vector<vi> expo(vector<vector<ll>> base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    vector<vi> ans(n,vi(n,0));
    rep(i,0,n)
    ans[i][i]=1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            mul(ans,base);
        }
        mul(base,base);
        exponent>>= 1;
    }
    return ans;
}
void solve()
{
	ll k;
	cin>>n>>k;
	vector<vector<ll>> v(n,vi(n));
	rep(i,0,n)
	{
		rep(j,0,n)
		cin>>v[j][i];
	}
	v = expo(v,k,hell);
	ll ans=0;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			ans=(ans+v[i][j])%hell;
		}
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 384
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    # 1を除く
    divisors.remove(1)
    return divisors

N = int(input())
ans = len(make_divisors(N-1))
N_divisors = make_divisors(N)
for divisor in N_divisors:
    x = N
    while x % divisor == 0:
        x /= divisor
    if x % divisor == 1:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
int main(){int H,W,h,w,i=1,j;scanf("%d%d%d%d",&H,&W,&h,&w);if(H%h||W%w)for(puts("Yes");i<=H;++i,puts(""))for(j=0;j<W;++j,printf("%d ",(i%h||j%w)?999:-999*(h*w-1)-1));else puts("No");return 0;}

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

using namespace std;

int main (){
	int a,c,k;
	string b;
	while(cin >> a >> b >> c){
		if(b == "?") break;
		if(b == "+") k = a + c;
		if(b == "-") k = a - c;
		if(b == "*") k = a * c;
		if(b == "/") k = a / c;
		cout << k << endl;
	}

return 0;
}

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

int main(){
    int times[3];
    for (int i=0;i<3;i++){
        cin>>times[i];
    }
    int minimum_time = 300;
    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            if (i!=j){
                int time_to_take = times[i] + times[j];
                if (time_to_take < minimum_time){
                    minimum_time = time_to_take;
                }
            }
        }
    }
    cout<<minimum_time<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

ll parent[100010];
ll num[100010];

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

void unite(ll a, ll b){
    a = root(a); b = root(b);
    if(a == b) return;
    parent[a] = b;
    ll new_val = num[a] + num[b];
    num[root(a)] = new_val;
    num[root(b)] = new_val;
}

bool same(ll a, ll b){
    return root(a) == root(b);
}

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll A[100010], B[100010];
    rep(i,0,M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    rep(i,0,N){
        parent[i] = i;
        num[i] = 1;
    }
    vector<ll> ans;
    ll v = N * (N-1) / 2;
    ans.push_back(v);
    rrep(i,M-1,0){
        if(same(A[i], B[i])){
            ans.push_back(v);
        }else{
            // print(num[A[i]] * num[B[i]]);
            v -= num[root(A[i])] * num[root(B[i])];
            unite(A[i], B[i]);
            ans.push_back(v);
        }
    }
    rrep(i,M-1,0){
        print(ans[i]);
    }
    

}


Measured memory_bytes: 5364
#include <stdio.h>
 
int main(int argc, char *argv[])
{
	int i, N;
	long long v = 1LL, t = 1LL, a = 1LL;
	scanf("%d", &N);
	for ( i = 0; i < N; i++ ){
		long long T, A, t_tmp, a_tmp;
		scanf("%lld %lld", &T, &A);
		if ( v%(T+A) != 0 ){
			v += T+A - v%(T+A);
		}
		t_tmp = v/(T+A) * T;
		a_tmp = v/(T+A) * A;
		if ( t > t_tmp ){
			if ( (t - t_tmp)%T == 0 ){
				v += (T+A)*(t-t_tmp)/T; 
			} else {
				v += (T+A)*((t-t_tmp)/T+1); 
			}
			a_tmp = v/(T+A) * A;
		}
		if ( a > a_tmp ){
			if ( (a - a_tmp)%A == 0 ){
				v += (T+A)*(a-a_tmp)/A; 
			} else {
				v += (T+A)*((a-a_tmp)/A+1); 
			}
		}
	  	t = v/(T+A) * T;
	   	a = v/(T+A) * A;
	}
    printf("%lld\n", v);
	return 0;
}


Measured memory_bytes: 128
def main():
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    ans = []
    for i in range(n-m+1):
        c = 0
        for j in range(m):
            if s[i+j] == '?' or s[i+j] == t[j]:
                c += 1
        if c == m:
            s_ = s[0:i] + t + s[i+m:]
            s_ = s_.replace('?', 'a')
            ans.append(s_)
    if len(ans)>0:
        print(sorted(ans)[0])
    else:
        print('UNRESTORABLE')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9072
#include<cstdio>
using namespace std;
const int MAX_R = 10;
const int MAX_C = 10000;
int field[MAX_R][MAX_C];
int _field[MAX_R][MAX_C];
int max(int a, int b){
  if(a > b)
    return a;
  else
    return b;
}
int pow(int a, int x){
  if(x <= 0)
    return 1;
  else
    return a * pow(a,x-1);
}
int solve(int r, int c){
  int res = 0;
  int cnt;
  for(int i = 0 ; i < c ; i++){
    cnt = 0;
    for(int j = 0 ; j < r ; j++){
      if(_field[j][i] == 0)
        cnt++;
    }
    res += max(cnt,r-cnt);
  }
  return res;
}
int ready(int x, int r, int c){
  for(int i = r-1 ; i >= 0 ; i--){
    if(x & 1 == 1){
      for(int j = 0 ; j < c ; j++){
        if(field[i][j] == 0)
          _field[i][j] = 1;
        else
          _field[i][j] = 0;
      }
    }
    else{
      for(int j = 0 ; j < c ; j++)
          _field[i][j] = field[i][j];
    }
    x >>= 1;
  }
  return solve(r,c);
}
int main(){
  int r,c;
  while(true){
    scanf("%d %d",&r,&c);
    if(r == 0 && c == 0)
      break;
    int lim = pow(2,r);
    for(int i = 0 ; i < r ; i++){
      for(int j = 0 ; j < c ; j++)
        scanf("%d",&field[i][j]);
    }
    int max = 0;
    for(int i = 0 ; i < lim ; i++){
      int res = ready(i,r,c);
      if(res > max)
        max = res;
    }
    printf("%d\n",max);
  }
}


Measured memory_bytes: 3516
# ABC115C - Christmas Eve
import sys
input = sys.stdin.readline

n, k = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, [input().rstrip() for _ in range(n)])))
ans = lst[k - 1] - lst[0]
for i, j in zip(lst, lst[k - 1 :]):
    ans = min(ans, j - i)
print(ans)

Measured memory_bytes: 14236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		StringBuilder sb = new StringBuilder();

		while(n > 0) {
			n--;
			sb.append((char)( 'a' + n % 26 ) );  // sb.append((char)( 97 + n % 26 ) );
			n = n / 26;
			//System.out.println(sb);
		}

		System.out.println(sb.reverse());

		sc.close();


	}
}

Measured memory_bytes: 35832
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

temp = [0] * N
temp_A = [0] * N
for i in range(N):
    temp[i] = T - H[i] *0.006
    temp_A[i] = A - temp[i]
    if temp_A[i] <= 0:
        temp_A[i] = - temp_A[i]

print(temp_A.index(min(temp_A)) + 1)

Measured memory_bytes: 3064