akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] str = (sc.nextLine()).split(" ");
			int n = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);
			int[][] v = new int[3][];
			int[] w = new int[n+1];
			int[][] a = new int[3][];
			
			for(int i = 0; i < 3; i++){
				v[i] = new int[n+1];
				a[i] = new int[m+1];
			}

			for(int i = 0; i < n; i++){
				String st = sc.nextLine();
				String[] s = (sc.nextLine()).split(" ");
				
				w[i] = Integer.parseInt(s[0]);
				v[0][i] = Integer.parseInt(s[1]);
				v[1][i] = Integer.parseInt(s[2]);
				v[2][i] = Integer.parseInt(s[3]);
			}
			
			for(int k = 0; k < 3; k++){
				for(int i = 0; i < n; i++){
					for(int j = 0; j <= m; j++){
						if(j >= w[i]){
							if(a[k][j] < a[k][j-w[i]]+v[k][i]){
								a[k][j] = a[k][j-w[i]]+v[k][i];
							}
						}
					}
				}
			}
			n = a[0][m];
			for(int i = 1; i < 3; i++){
				if(n < a[i][m]){
					n = a[i][m];
				}
			}
			
			System.out.println(Integer.toString(n));
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 13000
#include<iostream>

using namespace std;
#define N 500001
#define SENTINEL 999999998

//counter
int counter=0;

//Merge function
void Merge(int A[],int left,int mid,int right){
  
  int n1,n2,i,j;
  int L[N],R[N];

  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }

  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  //L[n1]=SENTINEL,R[n2]=SENTINEL
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;

  i=0;
  j=0;
  for(int k=left;k<right;k++){
    //counter++
    counter++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }

}
//MergeSort function
void MergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    MergeSort(A,left,mid);
    MergeSort(A,mid,right);
    Merge(A,left,mid,right);
  }

}


int main(){

  int num,i;
  int data[N];
  //load number
  cin >>num;
  //load data
  for(i=0;i<num;i++){
    cin >>data[i];
  }
  //execute merge sort
  MergeSort(data,0,num);
  //print
  for(i=0;i<num;i++){
    cout <<data[i];
    if(i!=num-1)cout <<" ";
  }
  cout <<endl;
  cout <<counter<<endl;
  return 0;

}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    map<int,int> mp;
    for(int i=0;i<n;i++){
        int x = i+1-a.at(i);
        // cout << x << endl;
        mp[x]++;
    }
    // cout << endl;

    ll cnt = 0;
    rep(i,n){
        int x = i+1+a.at(i);
        // cout << x << " " << mp[x] << endl;
        cnt += mp[x];
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 21132
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int n, k;
vector<vector<int>> g;
vector<int> a;
vector<int> height;

int h;
int ans;

void dfs(int v, int p) {
    if(g[v].size() == 1 && g[v][0] == p) {
        //葉
        height[v] = 0;
        h = 0;
        return;
    }
    for(auto nv: g[v]) {
        if(nv == p) continue;
        dfs(nv, v);
        chmax(height[v], h + 1);
    }
    h = height[v];
    if(h == k - 1) {
        if(a[v] != 0) {
            ++ans;
            h = -1;
        }
    }
}

void solve() {
	cin >> n >> k;
    g.assign(n, vector<int>());
    a.resize(n);
    rep(i, n) {
        cin >> a[i];
        --a[i];
        if(i != 0) g[i].push_back(a[i]);
        if(i != 0) g[a[i]].push_back(i);
    }
    if(k == 1) {
        int cnt = 0;
        rep(i, n) {
            if(a[i] != 0) ++cnt;
        }
        cout << cnt << endl;
        return;
    }
    ans = (a[0] != 0 ? 1 : 0);
    a[0] = 0;
    height.assign(n, -1);
    dfs(0, -1);
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 11264
import java.util.*;
import java.io.*;

public class Main {
    public static long sum(long[] array){
    	int l = array.length;
    	long ans = 0;
    	for(int i=0;i<l;i++) ans += array[i];
    	return ans;
    }
    
    public static void answer(boolean ans){
    	if(ans) System.out.println("Yes");
    	else System.out.println("No");
    	System.exit(0);
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        long[] b = new long[N];
        for(int n=0;n<N;n++) a[n]=sc.nextLong();
        for(int n=0;n<N;n++) b[n]=sc.nextLong();
        
        long opNum = sum(b)-sum(a);
        if(opNum<0) answer(false);
        
        long[] aOpNum = new long[N];
        long[] bOpNum = new long[N];
        for(int n=0;n<N;n++){
        	if(a[n]>=b[n]){
        		aOpNum[n]=0;
        		bOpNum[n]=a[n]-b[n];
        	}else{
        		aOpNum[n]=(a[n]+1-b[n])/2;
        		bOpNum[n]=(b[n]-a[n])%2;
        	}
        }
        answer(sum(aOpNum)<=opNum && sum(bOpNum)<=opNum);
        
    }
}

Measured memory_bytes: 42500
import qualified Data.ByteString.Char8 as BC
main = BC.getContents >>=
    mapM_ (print . _id) . filter ((>=25) . bmi) . map readStudent . BC.lines

data Student = St { _id :: Int, _weight :: Double, _height :: Double}

readStudent :: BC.ByteString -> Student
readStudent = (\(n:w:h:_) -> St (read n) (read w) (read h)) .
    map BC.unpack . BC.split ','

bmi :: Student -> Double
bmi (St _ w h) = w / h^2

Measured memory_bytes: 4056
<?php
$week = trim(fgets(STDIN));
$weeks = array(
    "SAT" => 1
    , "FRI" => 2
    , "THU" => 3
    , "WED" => 4
    , "TUE" => 5
    , "MON" => 6
    , "SUN" => 7
);
echo $weeks[$week];
?>

Measured memory_bytes: 3828
using System;
using System.Linq;
    class Program
    {
      	static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine().Split(' ').First());
            var ds = Console.ReadLine().Split(' ').ToList();
            for(var i =N; ;i++)
            {
                var stri = i.ToString();
                if(ds.All(d => !stri.Contains(d)))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }

Measured memory_bytes: 13268
T = input()
S = input()
N = len(S)


def match(x, y):
   #print(x,y)
    return all(x[i] == y[i] or y[i] == '?' for i in range(N))


for i in range(len(T)-N+1):
    if match(S, T[-N - i: -i] if i else T[-N:]):
        if i==0:
            print ((T[:-N]+S).replace('?','a'))
            exit(0)
        print((T[:-N-i]+S+T[-i:]).replace('?','a'))
        exit(0)
print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

typedef long long ll;
using namespace std;
const int mod = 1000000007;


int main() {

    int n; cin >> n;
    vector< vector<int> > Adj(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            v--;
            Adj[u][v] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != n-1) {
                cout << Adj[i][j] << ' ';
            }
            else {
                cout << Adj[i][j] << '\n';
            }
        }
    }

}



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

static class CodeJam
{
    static int[] Distances(List<int>[] nexts, int i)
    {
        const int INF = int.MaxValue / 2;
        int N = nexts.Length;
        var d = Enumerable.Repeat(INF, N).ToArray();
        d[i] = 0;
        var q = new Queue<int>();
        q.Enqueue(i);
        while (q.Count > 0)
        {
            int a = q.Dequeue();
            foreach (int b in nexts[a])
            {
                if (d[a] + 1 < d[b])
                {
                    d[b] = d[a] + 1;
                    q.Enqueue(b);
                }
            }
        }
        return d;
    }

    static bool Solve(int N, int[][] edges)
    {
        var nexts = new List<int>[N];
        for (int i = 0; i < N; ++i) { nexts[i] = new List<int>(); }
        foreach (var edge in edges)
        {
            int a = edge[0];
            int b = edge[1];
            nexts[a].Add(b);
            nexts[b].Add(a);
        }
        int[] d1 = Distances(nexts, 0);
        int j = 0;
        for (int i = 1; i < N; ++i)
        {
            if (d1[i] > d1[j]) { j = i; }
        }
        int[] d2 = Distances(nexts, j);
        int diameter = d2.Max();
        return diameter % 3 != 1;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var edges = new int[N - 1][];
        for (int i = 0; i < N - 1; ++i)
        {
            edges[i] = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) - 1);
        }
        Console.WriteLine(Solve(N, edges) ? "First" : "Second");
    }
}


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

int main() {
    string s;
    int K;
    cin >> s >> K;
    vector<string> subStrs;
    int n = s.size();
    for (int i=0; i<n; i++) {
        for (int j=1; j<=5; j++) {
            subStrs.push_back(s.substr(i, j));
        }
    }
    map<string, int> mp;
    rep(i, subStrs.size()) mp[subStrs[i]]++;
    int cnt = 1;
    for(auto p: mp) {
        if (cnt == K) {
            cout << p.first << endl;
            break;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

const int MOD = 1000000007;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k; cin >> n >> k;
    vector<vector<int>> es(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--; b--;
        es[a].push_back(b);
        es[b].push_back(a);
    }
    
    int64_t ans = k;
    queue<pair<int, int>> q;
    q.push({-1, 0});
    while (!q.empty()) {
        int from = q.front().first, now = q.front().second;
        q.pop();
        
        int num;
        if (from == -1) num = k - 1;
        else num = k - 2;
        
        for (int i : es[now]) {
            if (i == from) continue;
            else {
                ans = ans * num % MOD;
                num--;
                q.push({now, i});
            }
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6904
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main a = new Main();
        a.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int h = scan.nextInt();
        int w = scan.nextInt();
        int[][] map = new int[h][w];
        for (int i = 0; i < h; i++) {
            String line = scan.next();
            char[] data = line.toCharArray();
            for (int j = 0; j < w; j++) {
                if (data[j] == '#') {
                    map[i][j] = 1;
                }
            }
        }
        boolean found = false;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (map[i][j] == 1 && this.is_isolation(map, h, w, i, j)) {
                    found = true;
                    break;
                }
            }
        }
        System.out.println(found ? "No" : "Yes");
    }
    private boolean is_isolation(int[][] map, int h, int w, int i, int j) {
        if (0 <= i-1) {
            if (map[i-1][j] == 1) {
                return false;
            }
        }
        if (i+1 < h) {
            if (map[i+1][j] == 1) {
                return false;
            }
        }
        if (0 <= j-1) {
            if (map[i][j-1] == 1) {
                return false;
            }
        }
        if (j+1 < w) {
            if (map[i][j+1] == 1) {
                return false;
            }
        }
        return true;
    }

}


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

int main(){
    int N;
    cin >> N;
    vector<int> edges[100000];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<pair<int, int>> dp[100000];
    auto dfs = [&](auto&& dfs, int i, int p)->void{
        dp[i].emplace_back(0, i);
        for(int j : edges[i]) if(j != p){
            dfs(dfs, j, i);
            dp[i].emplace_back(dp[j][0].first+1, j);
        }
        sort(dp[i].rbegin(), dp[i].rend());
    };
    dfs(dfs, 0, -1);

    vector<int> ng(2*N+1);

    auto dfs2 = [&](auto&& dfs2, int i, int p, int u)->void{
        vector<int> vs(3);
        vs.push_back(u);
        for(auto& p : dp[i]) vs.push_back(p.first);
        sort(vs.rbegin(), vs.rend());
        int v1 = vs[0], v2 = vs[2];
        if(v2 > 0){
            if(v1 == v2){
                ng[v1+v2-1] = 1;
            }else{
                ng[v1+v2] = 1;
            }
        }
        for(int j : edges[i]) if(j != p){
            int u2 = u+1;
            for(int k=0; k<2; k++) if(dp[i][k].second != j) u2 = max(u2, dp[i][k].first+1);
            dfs2(dfs2, j, i, u2);
        }
    };
    dfs2(dfs2, 0, -1, 0);
    for(int i=2*N; i>0; i--) if(ng[i]) ng[i-1] = 1;
    ng[1] = ng[2] = 0;
    for(int i=1; i<=N; i++) cout << 1-ng[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 28596
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <stdio.h>

int main(void){
  int n,x,t;
  std::cin >> n >> x >> t;
  std::cout << (int)(n+x-1)/x*t;
  return 0;
}

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

//abc095_c
//解説参考
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	

	int z=max(x,y);
	int min=c*2*z;
	for(int i=z-1;i>=0;i--){
		int sum=c*2*i+a*max(0,x-i)+b*max(0,y-i);
		if(min>sum) min=sum;
	}
	
	
	cout<<min<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    ll n;
    cin>>n;
    vector<ll> a(n,0);
    for(int i=1;i<n;i++)
    {
        int temp;
        cin>>temp;
        a[temp-1]++;
    }
    for(int i=0;i<n;i++) cout<<a[i]<<endl;
    
    
    
} 

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

typedef long long int ll;

using namespace std;

void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

void find(vector <int> &a,ll n,int size,int i,int cur,int d,bool *flag)
{
    double y=(d/cur);
        ll temp=cur-1+ceil(y);
        if(temp<=n)
            *flag=1;
    while(i<size)
    {
        
        //cur*=a[i];
        find(a,n,size,i+1,cur*a[i],d,flag);
        //cur/=a[i];
        i++;
    }
}

int main()
{
    
   
    ll n;
    cin>>n;
    map <pair<int,int>,int> s;
    for(ll i=1;i<=n;i++)
    {
        ll x=i;
        ll rem=x%10;
        x/=10;
        int p2=rem;
        while(x!=0)
        {
            rem=x%10;
            x/=10;
        }
        s[make_pair(rem,p2)]+=1;
    }
    ll test=0;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            test+=(s[make_pair(i,j)]*s[make_pair(j,i)]);
        }
    }
    cout<<test<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let q: usize = sc.cin();
    let s: String = sc.cin();
    let cs: Vec<char> = s.chars().collect();

    let mut df = vec![0; n + 3];
    let mut ac = vec![0; n + 3];

    if n > 1 {
        for i in 0..(n-1) {
            if cs[i] == 'A' && cs[i+1] == 'C' {
                df[i] = 1;
            }
        }
    }
    {
        let mut a = 0;
        for i in 0..n+2 {
            a += df[i];
            ac[i+1] = a;
        }
    }
    // trace!(df);
    // trace!(ac);

    for _ in 0..q {
        let l: usize = sc.cin();
        let r: usize = sc.cin();
        let ans = ac[r - 1] - ac[l - 1];
        put!(ans);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4860
#include <stdio.h>
#include <stdlib.h>
int main(){
	int L,N,R=0;
	scanf("%d%d",&L,&N);
	for(;N--;){
		int a,b;
		scanf("%d%d",&a,&b);
		R+=a*b;
	}
	if(R==0){
		puts("0");
	}else{
		printf("1\n%d %d\n",R>0?-1:1,abs(R));
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int diffx = abs(sx - tx);
    int diffy = abs(sy - ty);

    string res = "";
    rep(i, diffx){
        res += 'R';
    }
    rep(i, diffy){
        res += 'U';
    }

    rep(i, diffx){
        res += 'L';
    }
    rep(i, diffy){
        res += 'D';
    }

    res += 'D';
    rep(i, diffx+1){
        res += 'R';
    }
    rep(i, diffy+1){
        res += 'U';
    }
    res += 'L';

    res += 'U';
    rep(i, diffx+1){
        res += 'L';
    }
    rep(i, diffy+1){
        res += 'D';
    }
    res += 'R';

    cout << res << endl;

    return 0;
}


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

int main() {
//	freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	int arr[2][103] = {0};
	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < n; ++j)
			cin >> arr[i][j];
	}
	int ans = INT_MIN;
	for (int i = 0; i < n; ++i)
	{
		int temp = 0;
		for (int j = 0; j < n-i; ++j)
		{
			temp += arr[0][j];
		}
		for (int j = n-i-1; j < n; ++j)
			temp += arr[1][j];
		ans = max(temp, ans);
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.rbegin(),a.rend());
  ll ans = 0;
  int t = n - 1;
  rep(i, n - 1){
    int lim = 2;
    if (i == 0)lim = 1;
    rep(j,lim){
      if (t > 0){
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 4020
function main(input) {
    var args = input.split(' ');
  	var a = Math.floor(args[0]);
  	var b = Math.floor(args[1]);
  	var res = 0;
    for(var i = 0; i < 2; i++){
   		if(a > b){
    		res += a;
            a--;
    	}else{
          	res += b;
            b--;
        }
    }
  	console.log(res);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
using static System.Console;

public class Hello
{
    public static void Main()
    {
        string l = ReadLine();
      	int N = int.Parse(l);
      	int C = 0;
      	l = ReadLine();
        int[] a = new int[N];
      	for (int i=0;i<N;i++){
         a[i] = int.Parse(l.Split()[i]) ;
        }
      
      	for (int i=1;i<N-1;i++){
        if (a[i-1]<a[i] && a[i]<a[i+1])C++;
        if (a[i-1]>a[i] && a[i]>a[i+1])C++;
        }
        WriteLine(C);

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> v;
    v.resize(n);
    for(int i=0;i<n;++i)  cin>>v[i];
    long long maxn=0;
    for(int i=1;i<n;++i)
    {
        long long m=0;
        for(int l=0,r=n-1;l+i<n-1;l+=i,r-=i)
        {
            if((n-1)%i==0&&l>=r) break;
            m+=0ll+v[l]+v[r];
            if(maxn<m) maxn=m;
        }
    }
    cout<<maxn;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    VE v;
    int a, b, c;
    cin >> a >> b >> c;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(all(v));
    cout << v[2] - v[0];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	bool prime[250000];
	for(int i=0;i<250000;i++){
		prime[i]=true;
	}
	prime[1]=false;
	for(int j=2;j<250000;j++){
		for(int k=j*2;k<250000;k+=j){
			prime[k]=false;
		}
	}
	int n;
	while(cin>>n){
		if(n==0) break;
		int count=0;
		for(int i=n+1;i<=2*n;i++){
			if(prime[i]==true) count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1404
#include <queue>
#include <map>
#include <functional>
#include <vector>
#include <iostream>
using namespace std;

using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<int> tbl[2][18];
    vector<int> p[2];
    const int INF = 1<<30;
    p[0].resize(n, INF);
    p[1].resize(n, INF);
    for (int i = 0; i < n; i++) cin >> p[i%2][i];
    for (int k = 0; k < 2; k++) {
        for (int e = 0; e < 18; e++) {
            tbl[k][e].resize(n);
            for (int i = 0; i + (1<<e) <= n; i++) {
                if (e == 0) tbl[k][0][i] = i;
                else {
                    int x = tbl[k][e-1][i], y = tbl[k][e-1][i + (1<<(e-1))];
                    tbl[k][e][i] = p[k][x] > p[k][y] ? y : x;
                }
            }
        }
    }
    function<int(int, int, int)> rmq = [&](int l, int r, int k) {
        int lb = 0, ub = 18;
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (1 << m <= r - l) lb = m;
            else ub = m;
        }
        int x = tbl[k][lb][l], y = tbl[k][lb][r-(1<<lb)];
        return p[k][x] > p[k][y] ? y : x;
    };
    map<P, vector<P> > mp;
    function<P(int, int)> solve = [&](int l, int r) {
        int b = l % 2, i = rmq(l, r, b), j = rmq(i, r, b^1);
        P p0 = {p[b][i], p[b^1][j]};
        if (l < i) { P q = solve(l, i); mp[p0].push_back(q); }
        if (i+1 < j) { P q = solve(i+1, j); mp[p0].push_back(q); }
        if (j+1 < r) { P q = solve(j+1, r); mp[p0].push_back(q); }
        return p0;
    };
    P p0 = solve(0, n);
    priority_queue<pair<int, P> > pq;
    auto get_val = [](P q) { return -q.first; };
    pq.push({get_val(p0), p0});
    while (!pq.empty()) {
        P p = pq.top().second;
        pq.pop();
        cout << p.first << ' ' << p.second << ' ';
        for (P q : mp[p]) pq.push({get_val(q), q});
    }
    cout << endl;
}


Measured memory_bytes: 60928
#include <stdio.h>

int main(void)
{
    int n;
    int start, end;
    int i, j;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d%d", &start, &end);
        if (start < end){
            for (j = start; j < end; j++){
                printf("%d ", j);
            }
            printf("%d\n", j);
        }
        else if (start <= 5){
            for (j = start; j > end; j--){
                printf("%d ", j);
            }
            printf("%d\n", j);
        }
        else {
            if (end <= 5){
                j = start;
                while (j != end){
                    printf("%d ", j);
                    if (j == 9){
                        j = 5;
                    }
                    else if (j >= 6){
                        j++;
                    }
                    else {
                        j--;
                    }
                }
                printf("%d\n", j);
            }
            else {
                for (j = start; j <= 9; j++){
                    printf("%d ", j);
                }
                for (j = 5; j >= 0; j--){
                    printf("%d ", j);
                }
                for (j = 1; j < end; j++){
                    printf("%d ", j);
                }
                printf("%d\n", j);
            }
        }
    }
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N, 0);
    for(int i=0; i<N; i++)
    {
        cin >> a[i];
    }
    
    long money = 1000;
    long kabu = 0;
    
    for(int i=1; i<N; i++)
    {
        if(a[i] > a[i-1])
        {
            //get kabu
            kabu = money / a[i-1];
            money -= kabu * a[i-1];
            
            //get money
            money += kabu * a[i];
        }
    }
    
    cout << money << endl;
}


Measured memory_bytes: 3568
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
a=0
for i in range(N):
    if p[i]!=q[i]:
        a+=1
    if a>2:
        print('NO')
        exit()
if a==0 or a==2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61816
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n;
    cin >> n;
    vector<LL> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    if (n == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    bool ok = true;
    for (int i = n - 1; i >= 1; i--) {
        LL current = h[i];
        LL prev = h[i - 1];
        if (current >= prev) {
            continue;
        } else if (current == prev - 1) {
            h[i - 1] -= 1;
        } else {
            ok = false;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846

int main()
{
  int a, b, h, m;
  cin>>a>>b>>h>>m;
  double hour_degree = h*30+m*0.5;
  double min_degree = m*6;
  double degree = abs(hour_degree-min_degree);
  double radian = (degree*pi)/180;

  double c = sqrt(a*a + b*b - 2*a*b*cos(radian));
  cout<<setprecision(20)<<c<<endl;

  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;

int64 nCr[575][575];

int64 f(int64 n, int64 r)
{
  if (r == 0 || n == r) return 1;
  if (nCr[n][r] >= 0) return nCr[n][r];
  return nCr[n][r] = f(n - 1, r - 1) + f(n - 1, r);
}

int main()
{
  memset(nCr, -1, sizeof(nCr));;
  int N, P;
  cin >> N >> P;
 
  vector< int > a(N);
  int o = 0;
  int e = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      e++;
    } else {
      o++;
    }
  }
  
  int64 ans = 0ll;
  for (int i = 0; i <= o; ++i) {
    if (i % 2 == P) {
      ans += f(o, i);
    }
  }
  ans <<= e;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
#define ll long long
int main()
{
	int a,b;
	cin>>a>>b;
	int flag=0;
	int t=0;
	int arr[1000];
	for(int i=1;i<=1500;i++)
	{
		int p=int(i*0.08);
		int q=int(i*0.1);
		if(p==a&&q==b)
		{
			flag=1;
			t=i;
			break;
		}
	}
	if(flag==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<t<<endl;	
	}
	return 0;
}

Measured memory_bytes: 256
N = str(input())
if  N[len(N)-1] == "3" :
  print("bon")
if N[len(N)-1] == "0" or N[len(N)-1] =="1" or N[len(N)-1] =="6" or N[len(N)-1] == "8": 
  print("pon")
elif N[len(N)-1]== "2" or N[len(N)-1] == "4" or N[len(N)-1] =="5" or N[len(N)-1] =="7" or N[len(N)-1] =="9":
  print("hon")
  



Measured memory_bytes: 9092
n, p = map(int, input().split())
s = input()
sum_cnt = 0
if p in {2, 5}:
    for r in range(n):
        if int(s[r]) % p == 0:
            sum_cnt += (r + 1)
else:
    modp_cnt = [0] * p
    modp_cnt[0] = 1
    subs_modp, pow = 0, 1
    for si in s[::-1]:
        subs_modp += ((int(si)*pow) % p)
        subs_modp %= p
        modp_cnt[subs_modp] += 1
        pow = (pow * 10) % p
        
    for cnt in modp_cnt:
        sum_cnt += cnt * (cnt - 1) // 2
print(sum_cnt)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

Measured memory_bytes: 256
def max_heapify(A, i):
    H = len(A) - 1
    l, r = i * 2 + 1, i * 2 + 2
    if l <= H and A[l] > A[i]:
            largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(A, largest)


def build_max_heap(A):
    for i in range(len(A) // 2, -1, -1):
        max_heapify(A, i)

input()
A = list(map(int, input().split()))
build_max_heap(A)
print('', *A)

Measured memory_bytes: 65840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mm[20][150],dp3[20][2][150];
ll n,sum=0,pro=1,ans=0;;
string s;
ll dfs(ll p,ll f,ll ss,ll m){
  if(dp3[p][f][ss].find(m)!=dp3[p][f][ss].end()) return dp3[p][f][ss][m];
  ll res=0;
  if(p==n) return f&&ss==0&&m==1;
  
  if(f){
    for(ll i=0;i<10;i++){
      if((i<=ss)&&(m%(i+1)==0)){
	res+=dfs(p+1,1,ss-i,m/(i+1));
      }
    }
  }else{
    for(ll i=0;i<s[p]-'0';i++){
      if((i<=ss)&&(m%(i+1)==0)){
	res+=dfs(p+1,1,ss-i,m/(i+1));
      }
    }
    ll i=s[p]-'0';
    if((i<=ss)&&(m%(i+1)==0)){
      res+=dfs(p+1,0,ss-i,m/(i+1));
    }
  }
  //if(p<3) cout<<p<<" "<<f<<" "<<ss<<" "<<m<<" "<<res<<endl;
  return dp3[p][f][ss][m]=res;
}
ll dfs2(ll p,ll ss,ll m){
  if(p==n) return (ss==0&&m<pro);
  if(mm[p][ss].find(m)!=mm[p][ss].end()) return mm[p][ss][m];
  ll res=0;
  for(ll i=0;i<10;i++){
    if(i<=ss) res+=dfs2(p+1,ss-i,m*(i+1));
  }
  return mm[p][ss][m]=res;
}
int main(){
  cin>>s;
  n=s.size();
  for(ll i=0;i<n;i++) sum+=s[i]-'0',pro*=(ll)(s[i]-'0'+1);
  ll dp[15][150]={};
  dp[0][0]=1;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<150;j++){
      for(ll k=0;k<10;k++){
	dp[i+1][j+k]+=dp[i][j];
      }
    }
  }
  for(ll j=0;j<sum;j++) ans+=dp[n][j];
  //cout<<ans<<endl;
  
  ans+=dfs(0,0,sum,pro);
  
  //cout<<ans<<endl;
  ans+=dfs2(0,sum,1);
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 28140
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;



int main() {

	long long int n;
	
	int r[100005] = {};

	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		r[x]++;
		r[x + 1]++;
		r[x + 2]++;
		ans = max(ans, max(r[x], max(r[x + 1], r[x + 2])));
	}
	cout << ans << endl;


	return 0;
	
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main() {
    cin >> N;
    auto divs = divisor<ll>(N);
    int k = divisor<ll>(N - 1).size();
    k--;
    for (auto i : divs) {
        if (i == 1) {
            continue;
        }
        if (i == N) {
            ans++;
            continue;
        }
        int n = N;
        while (n % i == 0) {
            n /= i;
        }
        if (n % i == 1) {
            ans++;
        }
    }
    cout << ans + k << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stacnice_task-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b emplace_back
////////////////////////////////???????????????CHECnice_task THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECnice_task THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e9, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll R=1e4;
const ll tx[4]={0,0,1,-1};
const ll ty[4]={1,-1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=200000;
vector<ll> lol1(2019,0);
vector<ll> lol2(2019,0);
signed main(){
    fast_io;
    string a;
    cin>>a;
    ll ans=0;
    ll n=len(a);
    for(ll i=0;i<n;i++){
        ll val=a[i]-'0';
        for(ll j=0;j<2019;j++){
            lol2[(j*10+val)%2019]+=lol1[j];
            //cout<<lol2[j]<<" ";
        }
       // cout<<endl;
        lol2[val]++;
        ans+=lol2[0];
        lol1=lol2;
        lol2.assign(2019,0);
    }
    cout<<ans;
    return 0;
}
/*
    если WA , то чекер говно, поэтому почекай 18 строчку
    чекай для t>1 (выводишь ли ты  с endl))
*/


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

struct N {
	int id,l, r, p;
	void pre();
	void in();
	void post();
};

int n, root;
N T[25];

void N::pre()
{
	cout<<' '<<id;
	if(l!=-1)T[l].pre();
	if(r!=-1)T[r].pre();
}

void N::in()
{
	if(l!=-1)T[l].in();
	cout<<' '<<id;
	if(r!=-1)T[r].in();
}

void N::post()
{
	if(l!=-1)T[l].post();
	if(r!=-1)T[r].post();
	cout<<' '<<id;
}

int main()
{
	memset(T,-1,sizeof(T));
	cin >>n;
	for(int i=0;i<n;i++){
		int id, l, r;
		cin>>id>>l>>r;
		T[id].id=id;
		T[id].l=l;
		T[id].r=r;
		T[l].p=id;
		T[r].p=id;
	}
	for(int i=0;i<n;i++){
		if(T[i].p==-1) {
			root=i;
			break;
		}
	}
	
	cout<<"Preorder"<<endl;
	T[root].pre();
	cout<<endl;
	
	cout<<"Inorder"<<endl;
	T[root].in();
	cout<<endl;
	
	cout<<"Postorder"<<endl;
	T[root].post();
	cout<<endl;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 51

void calc(int n,int p){
  int stone[SIZE] = {};
  int q = p;

  while(1){

    for(int i=0;i<n;i++){
      if(q > 0){
	stone[i]++;
	q--;
      }else{
	q += stone[i];
	stone[i] = 0;
      }

      if(stone[i]==p){
	printf("%d\n",i);
	return;
      }
    }

  }
  
}

int main(){
  int n,p;

  while(1){
    scanf("%d%d",&n,&p);
    if(n==0) break;
    calc(n,p);
  }
  
  return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int ans = 0;
	for (auto c : mp) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19228
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, key, l, largest, p, tmp;
  char com[20];
  do {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &key);
      A[++H] = key;
      for (i=H,p=i/2; p>0 && A[p]<A[i];i=p,p/=2) {
        tmp = A[p];
        A[p] = A[i];
        A[i] = tmp;
      }
    } else if (com[1]=='x') { // extract
      printf("%d\n", A[1]);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i*2;
        if (l < H && A[l] > A[i])        largest = l;
        else                             largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (com[2]!='d');
  return 0;
}


Measured memory_bytes: 5616
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if (a * b % 2)cout << "Odd" << endl;
	else cout << "Even" << endl;

	return 0;
}

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



int main() {
    int n;
    cin >> n;
    int dir = -1;
    int last;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i > 0) {
            if (dir == 0 && x > last) { ans++; dir = -1; }
            else if (dir == 1 && x < last) { ans++; dir = -1; }
            else if (x < last) dir = 0;
            else if (x > last) dir = 1;
        }
        last = x;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

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

    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }

    ll cnt = 0;

    for (ll b = k + 1; b <= n; b++) {
        ll cycle = n / b;
        ll reminder = n % b;
        ll r = reminder - k + 1;
        cnt = cnt + max((ll) 0, ((b - k) * cycle + (ll) max((ll) 0, r)));
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256