akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "YES" : "NO"));}
//----------------------------------------------------------------

int main(void) {
  arr(a,3);
  sortall(a);
  prtok(a[0]==a[1] && a[0]==5 && a[2]==7);
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let mut map: HashMap<i64, bool> = HashMap::new();

    for _ in 0..n {
        let a: i64 = read();
        let mut current = map.entry(a).or_insert(false);
        *current = if *current { false } else { true }
    }

    let mut ans: i64 = 0;
    for (k, v) in &map {
        if *v {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
fn main() {
    let v = read_vec::<i32>();
    let (n, h) = (v[0], v[1]);
    let mut a: Vec<i32> = Vec::new();
    let mut b: Vec<i32> = Vec::new();
    for _ in 0..n {
        let v = read_vec::<i32>();
        a.push(v[0]);
        b.push(v[1]);
    }
    a.sort();
    a.reverse();
    b.sort();
    b.reverse();
    let amax = a.into_iter().max().unwrap();
    let up: Vec<i32> = b.into_iter().take_while(|&n| n > amax).collect();

    let mut count = 0;
    let mut sum = 0;
    for damage in up.into_iter() {
        sum += damage;
        count += 1;
        if sum >= h {
            println!("{}", count);
            return;
        }
    }

    println!("{}", ((h - sum) as f64 / (amax as f64)).ceil() as i32 + count);
}

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

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

Measured memory_bytes: 6396
a=input()
b=input()
list=[]
if len(a)-len(b)==0:
    for i in range(len(a)):
        list.append(a[i])
        list.append(b[i])
else:
    for i in range(len(a)-1):
        list.append(a[i])
        list.append(b[i])
    list.append(a[-1])
print("".join(list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
int SY,SX,TY,TX;
string S[101];

template<class V> class MaxFlow_Ford {
public:
	struct edge { int to,reve;V cap;};
	static const int MV = 20002;
	vector<edge> E[MV];
	int vis[MV];
	void add_edge(int x,int y,V cap,bool undir=false) {
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}
	V dfs(int from,int to,V cf) {
		V tf;
		if(from==to) return cf;
		vis[from]=1;
		FORR(e,E[from]) if(vis[e.to]==0 && e.cap>0 && (tf = dfs(e.to,to,min(cf,e.cap)))>0) {
			e.cap -= tf;
			E[e.to][e.reve].cap += tf;
			return tf;
		}
		return 0;
	}
	V maxflow(int from, int to) {
		V fl=0,tf;
		while(1) {
			ZERO(vis);
			if((tf = dfs(from,to,numeric_limits<V>::max()))==0) return fl;
			fl+=tf;
		}
	}
};

MaxFlow_Ford<int> mf;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) {
			if(S[y][x]=='S') SY=y,SX=x,S[y][x]='o';
			if(S[y][x]=='T') TY=y,TX=x,S[y][x]='o';
			if(S[y][x]=='o') mf.add_edge(y*100+x+10000,y*100+x,1);
		}
	}
	
	FOR(y,H) {
		int x2;
		FOR(x,W) FOR(x2,x) if(S[y][x]=='o' && S[y][x2]=='o') {
			mf.add_edge(y*100+x,y*100+x2+10000,100001);
			mf.add_edge(y*100+x2,y*100+x+10000,100001);
		}
	}
	FOR(x,W) {
		int y2;
		FOR(y,H) FOR(y2,y) if(S[y][x]=='o' && S[y2][x]=='o') {
			mf.add_edge(y*100+x,y2*100+x+10000,100001);
			mf.add_edge(y2*100+x,y*100+x+10000,100001);
		}
	}
	
	int ret=mf.maxflow(SY*100+SX,TY*100+TX+10000);
	if(ret>10000) ret=-1;
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 61952
#include<stdio.h>
int main(void) {
    int i;
    int n;
    int max;
    int min;
    long int sum = 0;
    int a[10000];
    scanf("%d", &n);
     
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    max = min = a[0];
    for(i = 0; i < n; i++) {
        if(a[i] > max) {
            max = a[i];
        } else if(a[i] < min) {
            min = a[i];
        }
        sum += a[i];
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); 
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    
    public static int[] generatePrimes(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, 2, n + 1, true);
		for (int i = 2; i * i <= n; i++)
			if (prime[i])
				for (int j = i * i; j <= n; j += i)
					prime[j] = false;
		int[] primes = new int[n + 1];
		int cnt = 0;
		for (int i = 0; i < prime.length; i++)
			if (prime[i])
				primes[cnt++] = i;
		return Arrays.copyOf(primes, cnt);
	}
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}	
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}		    
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}	    	  	
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}		
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}	
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}	    	
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}	    	
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}				
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        
        int a[] = new int[110];
        for(int i=1;i<10;i++)
        {
            for(int j=1;j<10;j++)
            {
                a[i*j]=1;
            }
        }
        int n = in.nextInt();
        if(a[n]==1) out.println("Yes");
        else out.println("No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22612
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> 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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
mod vig {
    pub trait S {
        fn binary_search(&mut self, key: i64);
        fn binary_search_index(&mut self, key: i64) -> i64;
    }
    impl S for Vec<i64> {
        fn binary_search(&mut self, key: i64) {
            let mut ng: i64 = -1;
            let mut ok: i64 = self.len() as i64;
            loop {
                if (ok - ng).abs() <= 1 {
                    break;
                }
                let mid = (ok + ng) / 2;
                if self[mid as usize] > key {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            self[ok as usize] = key;
        }
        fn binary_search_index(&mut self, key: i64) -> i64 {
            let mut ng: i64 = -1;
            let mut ok: i64 = self.len() as i64;
            loop {
                if (ok - ng).abs() <= 1 {
                    break;
                }
                let mid = (ok + ng) / 2;
                if self[mid as usize] >= key {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            ok
        }
    }
}

fn main() {
    input!{
        n:usize,
        mut a: [i64;n]
    }
    // println!("{:?}", a);
    let mut dp = vec![1<<50;n];
    a.reverse();
    for i in 0..n {
        vig::S::binary_search(&mut dp, a[i]);
    }
    // println!("{:?}", dp);
    let ans = vig::S::binary_search_index(&mut dp, 1<<50);
    println!("{}", ans);
}

Measured memory_bytes: 6524
n=int(input())
k=3
l=[]
for _ in range(n):
    l.append(list(map(int,input().split())))
dp=[l[0]]
for i,s in enumerate(l):
    if not i:continue
    t=[t for t in dp[-1]]
    d=[]
    for i in range(k):
        d.append(max(t[j]for j in range(k)if i!=j)+s[i])
    dp.append(d)
print(max(dp[-1]))

Measured memory_bytes: 81496
import sys
import numpy as np
from heapq import heappop, heappush
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 

 
H,W = map(int,readline().split())
grid = np.full((H+2,W+2),b'#',dtype='S1')
grid[1:-1,1:-1] = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W]
INF = 400
def shortest(grid, start, cost=0):
    dist = np.array([[INF for _ in range(W+2)] for _ in range(H+2)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    st = [(cost, start)]
    dist[start[0]][start[1]]=0
    while(st):
        c, [sx, sy] = heappop(st)
        for a, b in zip(dx, dy):
            x = sx + a
            y = sy + b
            if grid[x][y]==b'#':
              continue
            dxy = dist[sx][sy] + 1
            if dist[x][y] <= dxy:
                continue
            dist[x][y] = dxy
            heappush(st, (dist[x][y], [x, y]))
    return np.max(dist[dist<INF])

m=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if grid[i,j]==b'#':
      continue
    tm = shortest(grid, [i, j])
    if m < tm:
      m=tm
print(m)

Measured memory_bytes: 12420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N; cin >> N;
	int A, B; cin >> A >> B;
	int ans = 0;
	rep(i, 1, N + 1) {
		string a = to_string(i);
		int cnt = 0;
		rep(j, 0, a.size()) {
			cnt += a[j] - '0';
		}
		if (A <= cnt && cnt <= B)ans+=i;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <stack>
using namespace std;

void topoSort(int i, vector<int> adj[], stack<int> &s, bool visited[]) {
	visited[i] = 1;
	for (auto u: adj[i]) {
		if (!visited[u])
			topoSort(u, adj, s, visited);
	}
	s.push(i);
}

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

	vector<int> adj[n];
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
	}

	bool visited[n] = {0};
	stack<int> s;
	for (int i = 0 ; i < n; i++)
		if (!visited[i])
			topoSort(i, adj, s, visited);
	
	vector<int> a;
	while (!s.empty()) {
		a.push_back(s.top());
		s.pop();
	}
	int dp[n] = {INT_MIN};
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (auto u: adj[a[i]]) {
			if (dp[u] < dp[a[i]] + 1)
				dp[u] = dp[a[i]] + 1;
		}
	}
	cout << *max_element(dp, dp + n) << endl;
}


Measured memory_bytes: 9392
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
vector<ll> red_a,green_a,color_a;
int main() {
	ll x,y,n,m,r;
	cin>>x>>y>>n>>m>>r;
	for(int i=1;i<=n;i++)
	{
	    ll p;
	    cin>>p;
	    red_a.pb(p);
	}
	for(int i=1;i<=m;i++)
	{
	    ll p;
	    cin>>p;
	    green_a.pb(p);
	}
	for(int i=1;i<=r;i++)
	{
	    ll p;
	    cin>>p;
	    color_a.pb(p);
	}
	sort(color_a.begin(),color_a.end());
	sort(red_a.begin(),red_a.end());
	sort(green_a.begin(),green_a.end());
	reverse(red_a.begin(),red_a.end());
	reverse(green_a.begin(),green_a.end());
	while(red_a.size()>x)
	{
	    red_a.pop_back();
	}
	while(green_a.size()>y)
	{
	    green_a.pop_back();
	}
	while(!green_a.empty())
	{
	    red_a.pb(green_a.back());
	    green_a.pop_back();
	}
	multiset<ll> s;
	for(int i=0;i<red_a.size();i++)
	{
	    s.insert(red_a[i]);
	}
	while(!color_a.empty())
	{
	    ll val=color_a.back();
	    color_a.pop_back();
	    s.insert(val);
	    s.erase(s.begin());
	}
	ll ans=0;
	for(auto it=s.begin();it!=s.end();it++)
	{
	    ans+=(*it);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11632
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main(){
	string S;
	cin >> S;
	int ss = S.size();
	if (ss == 26) {
		if (S == "zyxwvutsrqponmlkjihgfedcba")cout << -1 << endl;
		else {
			string T;
			T += S[ss - 1];
			for (int i = ss - 2;i >= 0;i--) {
				T += S[i];
				sort(all(T));
				if (S[i] < S[i + 1]) {
					auto it = upper_bound(all(T), S[i]);
					
					for (int j = 0;j < i;j++)cout << S[j];
					cout << *it << endl;
					return 0;
				}
			}
		}
	}
	else {
		string T = S;
		sort(all(T));
		for (int i = 0;i < ss;i++) {
			if (T[i] != i + 97) {
				S += i + 97;
				cout << S << endl;
				return 0;
			}
		}
		S += S[ss - 1] + 1;
		cout << S << endl;
	}
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
year=195
from math import ceil
for i in range(n):
	y,m,d=map(int,input().split())
	ans=0
	ans+=(999-y)*year
	ans+=(333-y//3)*5
	if y%3==0:
		ans+=(10-m)*20
		ans+=(20-d)+1
	else:
		ans+=(10-m)*20
		ans-=ceil((10-m)/2)
		if m%2==0:
			ans+=(19-d)+1
		else:
			ans+=(20-d)+1
	print(ans)



Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n; cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }

  int q; cin >> q;
  int tmp;
  rep_i(i, q){
    cin >> tmp;
    vector<int>::iterator itr = lower_bound(nums.begin(), nums.end(), tmp);
    vector<int>::iterator itr2 = upper_bound(nums.begin(), nums.end(), tmp);
    cout << itr - nums.begin() << " " << itr2 - nums.begin() << endl;
  }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
int a[N];
int mn[N],mx[N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n+1)cin>>a[i];
    for(int i=n-1;i>=0;--i){
        mn[i]=(a[i+1]+mn[i+1])/2;
        mx[i]=a[i+1]+mx[i+1];
    }
    upn(mx[0],1-a[0]);
    for(int i=1;i<=n;++i){
        upn(mx[i],2*mx[i-1]-a[i]);
    }
    int ans=0;
    forn(i,n+1){
        if(mn[i]>mx[i]){
            cout<<"-1\n";
            return 0;
        }
        ans+=mx[i]+a[i];
    }
    cout<<ans<<'\n';



    return 0;
}


Measured memory_bytes: 6004
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), k = int.Parse(input[1]);
            
            long ans = 0;
            for (int i=1; i<=k; i++)
            {
                if ((2 * i) % k == 0 && n >= i)
                {
                    //Console.Error.WriteLine(i);
                    ans += (long)((n - i) / k + 1) * ((n - i) / k + 1) * ((n - i) / k + 1);
                } 
            }

            Console.WriteLine(ans);
            
            


            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9+233;
int n;
int a[maxn], b[maxn], q[maxn];

template<typename T>
inline void read(T &k)
{
    int f=1; k=0; char c=getchar();
    while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    k*=f;
}

int main()
{
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=1;i<=n;i++) read(b[i]);


    int cnt=0; ll sum1=0; int ans=0;
    for(int i=1;i<=n;i++)
        if(a[i]<b[i]) sum1+=a[i]-b[i], ans++;
        else q[++cnt]=a[i]-b[i];
        
    sort(q+1, q+1+cnt);

    if(sum1>=0) return puts("0"), 0;
    for(int i=cnt;i;i--)
    {
        sum1+=q[i]; ans++;
        if(sum1>=0) return printf("%d\n", ans), 0;
    }
    puts("-1");
}


Measured memory_bytes: 2944
#include<iostream>
 #include<vector>
 using namespace std;
 int a,b;
 int main(){
 cin>>a>>b;
 if(a==1)a=100;
 if(b==1)b=100;
  if(a>b){cout<<"Alice"<<endl;}else
  if(a<b){cout<<"Bob"<<endl;}else cout<<"Draw"<<endl;
 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

vector<vector<pii> > G, rG;
vector<vector<int> > I;
ll C[100100], rC[100100];
bool tmp[100100];
bool bridge[100100];
int lst[100100][3];
map<pii,pii> mul;
const ll INF = 1e15;

void shortest(vector<vector<pii> > g, ll *c, int s) {
	for(int i = 0; i < 100100; i++) {
		c[i] = INF;
	}
	c[s] = 0;
	priority_queue<pli> q;
	q.push(pli(0,s));
	while(q.size()) {
		pli a = q.top(); q.pop();
		if(c[a.se] < -a.fi) continue;
		for(int i = 0; i < g[a.se].size(); i++) {
			int v = g[a.se][i].fi;
			ll t = -a.fi + g[a.se][i].se;
			if(c[v] > t) {
				c[v] = t;
				q.push(pli(-t, v));
			}
		}
	}
}

void mkbridge() {
	ll sp = C[1];
	priority_queue<pli> q;
	q.push(pli(0,0));
	while(q.size()) {
		pli a = q.top(); q.pop();
		while(q.size() && q.top() == a) q.pop();
		if(tmp[a.se]) continue;
		tmp[a.se] = true;
		int id =-1;
		int src,dst;
		for(int i = 0; i < G[a.se].size(); i++) {
			int v = G[a.se][i].fi;
			if(sp == C[a.se] + G[a.se][i].se + rC[v]) {
				if(mul[pii(a.se,v)].fi == G[a.se][i].se && mul[pii(a.se,v)].se > 0) {
					mul[pii(a.se,v)].se = -mul[pii(a.se,v)].se;
					q.push(pli(-C[v], v));
					id = I[a.se][i];
					src=a.se;
					dst=v;
					//cout << a.se << " " << v << endl;
				}
			}
		}
		if(q.size() == 1 && id >= 0 && mul[pii(src,dst)].se == -1) {
			bridge[id] = true;
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	G.resize(n);
	rG.resize(n);
	I.resize(n);
	for(int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back(pii(b,c));
		rG[b].push_back(pii(a,c));
		I[a].push_back(i);
		lst[i][0] = a; lst[i][1] = b; lst[i][2] = c;

		if(mul.find(pii(a,b)) == mul.end())
			mul[pii(a,b)] = pii(c,1);
		else if(mul[pii(a,b)].fi == c)
			mul[pii(a,b)].se++;
		else if(mul[pii(a,b)].se > c)
			mul[pii(a,b)] = pii(c,1);
	}
	shortest(G,C,0);
	shortest(rG,rC,1);
	mkbridge();
	/*
	for(int i = 0; i < m; i++)
		cout << bridge[i] << " ";cout << endl;
	// */

	ll sp = C[1];
	for(int i = 0; i < m; i++) {
		int a, b, c;
		a = lst[i][0]; b = lst[i][1]; c = lst[i][2];
		if(C[b] + c + rC[a] < sp) {
			cout << "HAPPY" << endl;
		}
		else if(bridge[i] && C[b] + c + rC[a] > sp && sp != INF) {
			cout << "SAD" << endl;
		}
		else {
			cout << "SOSO" << endl;
		}
	}
}

Measured memory_bytes: 33500
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int l,r,d;
	cin >> l >> r >> d;
	int x = l/d;
	if(l%d == 0)
		x--;
	int y = r/d;
	cout << y - x;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
int A[100005], B[100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  ll ans = 0;
  int Bifmax = INF;
  int eq = 0;
  REP(i,N){
    cin >> A[i] >> B[i];
    ans += A[i];
    if(A[i] > B[i]){
      Bifmax = min(Bifmax, B[i]);
    }else if(A[i] == B[i]){
      eq++;
    }
  }
  if(eq == N) cout << 0 << endl;
  else cout << ans - Bifmax << endl;
  return 0;
}


Measured memory_bytes: 512
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
//¿ª O2£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡ 
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef long long LL;
typedef double db;
const int N=300+5;
ll f[N][N],sf[N][N],ssf[N][N],i,j,x,n,m,mo,c[N][N];
int main()
{
	scanf("%lld %lld %lld",&n,&m,&mo);
	fo(i,0,n+1) c[i][0]=1;
	fo(i,1,n+1) fo(j,1,i) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mo;
	f[1][0]=1;
	fo(i,0,n+1)
	{
		if (i)
			fo(j,0,m)
				fo(x,1,i-1)
					f[i][j]=(f[i][j]+(f[i-x][j]*ssf[x][j-1]+sf[i-x][j-1]*sf[x][j-1])%mo*c[i-2][x-1])%mo;
		fo(j,0,m) sf[i][j]=(sf[i][j-(j>0)]+f[i][j])%mo;
		fo(j,0,m) ssf[i][j]=(ssf[i][j-(j>0)]+sf[i][j])%mo;
	}
	printf("%lld\n",sf[n+1][m]);
}

Measured memory_bytes: 3072
n = gets.to_i
a = gets.split.map(&:to_i)
i = 1

a[0] < a[1] ? max = a[1]  : max = a[0]
a[0] < a[1] ? min = a[0]  : min = a[1]

while i < n
  if max < a[i]
    max = a[i]
  elsif min > a[i]
    min = a[i]
  end
  i += 1
end
puts max - min


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    auto edge = make_v(n, n, 0);
    REP(i, 0, n - 1) {
        edge[i][n - 1] = edge[n - 1][i] = 1;
    }
    int mx = (n - 1) * (n - 2) / 2;
    if (mx < k) {
        cout << -1 << endl;
        return 0;
    }
    for (int t = mx; t > k; t--) {
        bool update = false;
        REP(i, 0, n - 1) {
            REP(j, i + 1, n - 1) {
                if (edge[i][j] == 0) {
                    edge[i][j] = edge[j][i] = 1;
                    update = true;
                    break;
                }
            }
            if (update) break;
        }
        if (!update) {
            cout << -1 << endl;
        }
    }
    vector<int> a, b;
    REP(i, 0, n) {
        REP(j, i + 1, n) {
            if (edge[i][j] == 1) {
                a.push_back(i + 1);
                b.push_back(j + 1);
            }
        }
    }
    cout << a.size() << endl;
    REP(i, 0, a.size()) {
        cout << a[i] << " " << b[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
n = int(input())
s = input()
s2 = [int(v) for v in s]

cnt = 0

for i in range(0, 10):
    if i in s2:
        ad1 = s.find(str(i))
        for j in range(0, 10):
            if j in s2[ad1 + 1:]:
                ad2 = s.find(str(j), ad1 + 1)
                for k in range(0, 10):
                    if k in s2[ad2 + 1:]:
                        cnt += 1

print(cnt)


Measured memory_bytes: 3700
def main(n):

    prime = []
    if n < 2:
        prime.append((1,0))
    for p in range(2,int(n**0.5)):
        cnt = 0
        if p*p > n:
            break
        while n%p == 0:
            n //= p
            cnt += 1
        prime.append((p,cnt))
    if n > 1:
        prime.append((n,1))
    return prime
                    
n = int(input())    
pf = main(n)

ans = 0
for p, f in pf:
    cnt = 1
    while f >= cnt:
        f -= cnt
        ans += 1
        cnt += 1

print(ans)




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

int main()
{
        int N;
        cin >> N;
        long long A[5] = {0};
        for(int i = 0; i < N; i++)
        {
                string s;
                cin >> s;
                if(s[0] == 'M') ++A[0];
                else if(s[0] == 'A') ++A[1];
                else if(s[0] == 'R') ++A[2];
                else if(s[0] == 'C') ++A[3];
                else if(s[0] == 'H') ++A[4];
        }
        long long ans = 0;

        ans += A[0]*A[1]*A[2];
        ans += A[0]*A[1]*A[3];
        ans += A[0]*A[1]*A[4];

        ans += A[0]*A[2]*A[3];
        ans += A[0]*A[2]*A[4];

        ans += A[0]*A[3]*A[4];

        ans += A[1]*A[2]*A[3];
        ans += A[1]*A[2]*A[4];

        ans += A[1]*A[3]*A[4];

        ans += A[2]*A[3]*A[4];

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

//Library for input and output
// "strconv" //For conversion of strings to ints and vice versa
//i, err := strconv.Atoi("-42")
//s := strconv.Itoa(-42)
// "sort"

func main() {
	var N, W int
	fmt.Scan(&N, &W)
	w := make([]int, N+1)
	v := make([]int, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i <= N; i++ {
		for j := 0; j <= W; j++ {
			dp[i][j] = dp[i-1][j]
			if j >= w[i] {
				dp[i][j] = Max(dp[i-1][j], v[i]+dp[i-1][j-w[i]])
			}
		}
	}
	fmt.Println(dp[N][W])
}

// Reverse a string s
func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

// Abs returns the absolute value of x.
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

// Min returns the min of x and y
func Min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

// Max returns the min of x and y
func Max(x int, y int) int {
	if x < y {
		return y
	}
	return x
}


Measured memory_bytes: 83072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	string s;
	cin >> s;
	int count = 0;
	REP(i, s.size()) {
		if (s[i] == 'o') {
			count++;
		}
	}
	count += 15 - s.size();
	if (count >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
// #include <math.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b;
  cin >> a >> b;
  if(a==b) print("Draw");
  else if (b == 1) print("Bob");
  else if (a==1 || a > b) print("Alice");
  else print("Bob");
}


Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)cout << "Yay!";
	else cout << ":(";
	return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        string[] st = ReadLineStrArray();
        for (int i = 0;i < n; i++) {
            Console.Write(st[0].Substring(i,1) + st[1].Substring(i,1));
        }
        Console.WriteLine("");
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n,k;
  int sum = 0;
  cin >> n >> k;
  vector<int> point(n);
  for (int i = 0; i < n; i++) {
    cin >> point.at(i);
  }
  for (int i = 0; i < n; i++) {
    int l = max(point.at(i)-k,k-point.at(i)); 
    sum += min(point.at(i),l);
  }
  cout << sum*2 << endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    prec;
    int n,x;cin>>n;
    //string str;cin>>str;
    x=n/2;
    cout<<1.0*(n-x)/n;




    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

int main() {
  int N, A, B, num, sum, ans=0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    sum = 0;
    num = i;
    while (num != 0)
    {
      sum += num % 10;
      num /= 10;
    }
    if (A <= sum && sum <= B) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int i,j,k,l,n,m;
	char s[100][100];
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(i=0;i<n;i++)
		scanf("%s",&s[i]);
	
		for(j=0;j<m+2;j++)
		{
			printf("#");
		}
		printf("\n");
		for(i=0;i<n;i++)
		{
			printf("#");
			for(j=0;j<m;j++)
			
			printf("%c",s[i][j]);
			printf("#\n");
		}
		for(j=0;j<m+2;j++)
		{
			printf("#");
		}	
		printf("\n");	
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define int long long

using namespace std; 

const int maxn = 3e5; 

int n, m, v, k; 
int a[maxn + 5]; 
int lst[maxn + 5];
long long sum[maxn + 5];  

int chk(int x) {
  if (x <= k) {
    return 1; 
  }
  if (a[x] + m < a[k]) return 0; 
  if (n - x + 1 + k - 1 >= v) {
    if (a[x] + m >= a[k]) return 1; 
    else return 0; 
  }
  int P = v - (n - x + 1) - (k - 1);  
  ll T = 0; 
  for (int i = k; i < x; i++) {
    T += min(a[x] + m - a[i], m); 
  }
  if (1ll * P * m <= T) {
    return 1; 
  }
  return 0; 
}

signed main() {  
  scanf("%lld %lld %lld %lld", &n, &m, &v, &k); 
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]); 
  }  
  sort(a + 1, a + n + 1); 
  reverse(a + 1, a + n + 1); 
  int Lst = 0; a[0] = -1; 
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[Lst]) Lst = i; 
    lst[i] = Lst; 
    sum[i] = sum[i - 1] + a[i]; 
  }
  int ans = -1, l = 1, r = n; 
  while (l <= r) {
    int mid = (l + r) >> 1; 
    if (chk(mid)) {
      l = mid + 1; ans = mid; 
    }
    else {
      r = mid - 1; 
    }
  }
  cout << ans << '\n'; 
  return 0; 
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, d, r; };
    struct Edge { int i, n; };
    Graph(int n) : v(n, { -1, -1, -1 }), q(n), n(n), m(0) {}
    void add_edge(int i, int j) {
        e.push_back({ j, v[i].n });
        v[i].n = m;
        m++;
    }
    void bfs(int i0) {
        for (int i = 0; i < n; i++) {
            v[i].d = -1;
        }
        v[i0].d = 0;

        int j0 = 0, j1 = 0;
        q[j1++] = i0;

        while (j0 < j1) {
            int i = q[j0++];
            for (int j = v[i].n; j >= 0; j = e[j].n) {
                Edge &o = e[j];
                if (v[o.i].d >= 0) continue;

                v[o.i].d = v[i].d + 1;
                v[o.i].r = i;
                q[j1++] = o.i;
            }
        }
    }
    void solve() {
        bfs(0);
        cout << "Yes\n";

        for (int i = 1; i < n; i++) {
            cout << v[i].r + 1 << '\n';
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    vector<int> q;
    int n, m;
};

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

    int n, m;
    cin >> n >> m;

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.solve();

    return 0;
}

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

vi to[202000];
vi ans;

void dfs(int v, int p = -1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    ans.resize(n);
    
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    
    dfs(0);
    
    rep(i, n) {
        cout << ((i > 0) ? " " : "") << ans[i];
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

void test_case(){
	ll n, k; cin >> n >> k;
	for(int i = 0 ; i < n ; i++){
		cin >> to[0][i];
		to[0][i]--;
	}
	for(int i = 0 ; i < D-1 ; i++){
		for(int j = 0 ; j < n ; j++){
			to[i+1][j] = to[i][to[i][j]];
		}
	}
	
	int v = 0;
	for(int i = D-1 ; i >= 0 ; --i){
		ll l = 1ll<<i;
		if(l <= k){
			v = to[i][v];
			k-=l;
		}
	}
	cout<<v+1<<"\n";
	
	
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 50516
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  double p1i = 3.14159265358979323846;
  double ans=2*p1i;
  double r;
  cin>>r;
  ans=ans*r;
  cout<<ans<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 3836