akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __ll128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}

vector<ll> v(1000,0);

pair<pair<ll,ll> , pair<ll,ll> > arr[1000]; // a b c d
ll n,m,q;

ll ans = -oo;

ll score(){
    ll cnt=0;
    for(ll i=0;i<q;i++){
        if( v[arr[i].first.second] - v[arr[i].first.first] == arr[i].second.first ){
            cnt+= arr[i].second.second;
        }
    }
    return cnt;
}

void rec(ll j, int last){
    if(j==n+1){
        ans = max(ans , score());
        return;
    }
    for(ll i=last;i<=m;i++){
        v[j] = i ;
        rec(j+1,i);
    }
}


void __sol(){
    cin >> n >> m >> q;
    forr(i,q) cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second.first >> arr[i].second.second;
    rec(0,1);
    cout << ans;

}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3632
from itertools import combinations
N,M = map(int,raw_input().split())
lab = [map(float,raw_input().split()) for _ in range(N)]
ans = max(sum((a[i]-b[i])**2 for i in range(3) for a,b in combinations(ele,2)) for ele in combinations(lab,M))
print "%.7f"%ans

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

int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,n){
    a[i] = 0;
  }
  int tmp1,tmp2;
  rep(i,m){
   	cin >> tmp1 >> tmp2;
    a[tmp1-1]++;
    a[tmp2-1]++;
  }
  rep(i,n){
    cout << a[i] << endl;
  } 
  return 0;
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  for(int i=0;i<s.length();++i){
    if(i == 5 || i==13){
      cout << ' ';
    }
    else cout << s[i];
  }
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;cin>>n;
    if(n%1000==0)
        cout<<0<<endl;
    else
    {
        ll x=n/1000;
        x++;
        cout<<(x*1000)-n<<endl;
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            string s;
            cin>>s;
            if (s=="snuke") {
                cout<<(char)('A'+j-1)<<i<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
inputLine=input()
N = int(inputLine.split(" ")[0])
M = int(inputLine.split(" ")[1])

inputLine=input()
A = inputLine.split(" ")

for i in range(len(A)):
    A[i] = int(A[i])

result = N - sum(A)

if result < 0:
    print(-1)
else:
    print(result)















Measured memory_bytes: 9684
n = gets.to_i
ar = gets.chomp.split.map(&:to_i)
ans = 0
i = 0
(n - 2).times{
  i += 1
  if (ar[i] < ar[i + 1] && ar[i] > ar[i - 1]) || (ar[i] > ar[i + 1] && ar[i] < ar[i - 1])
    ans += 1
  end
}
puts ans


Measured memory_bytes: 1788
import math
a,b,C=map(int,input().split())
c=math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(C)))
s=(a+b+c)/2
S=math.sqrt(s*(s-a)*(s-b)*(s-c))
L=a+b+c
h=2*S/a
print(f"{S:.5f}\n{L:.5f}\n{h:.5f}")


Measured memory_bytes: 5724
import java.util.Arrays;
import java.util.Scanner;

//Elevator
public class Main{

	int[] d;
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), W = sc.nextInt(), K = 0;
		int[] w = new int[15], f = new int[15], s = new int[n+1];
		for(int i=1;i<=n;i++){
			int k = sc.nextInt();
			while(k--!=0){
				w[K] = sc.nextInt(); s[i]+=1<<K; f[K++] = i;
			}
		}
		int[] sum = new int[1<<K];
		boolean[] valid = new boolean[1<<K];
		for(int S=0;S<1<<K;S++){
			for(int j=0;j<K;j++)if(((S>>j)&1)>0){
				sum[S]+=w[j];
			}
			valid[S] = sum[S]<=W;
		}
		int[] min = new int[1<<K];
		Arrays.fill(min, K);
		min[0] = 0;
		for(int S=1;S<1<<K;S++){
			int res = K, sub = S;
			do{
				if(valid[sub]){
					res = Math.min(res, min[S-sub]+1);
				}
				sub = (sub-1)&S;
			}while(sub!=S);
			min[S] = res;
		}
		int res = f[K-1]-m;
		for(int i=f[K-1];i>1;i--){
			res+=2*(min[s[i]]-1)+1;
			s[i-1]|=s[i];
		}
		System.out.println(Math.max(res, 0));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

vector <vector <int> > edge;
ll ans = 0;
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    edge.resize(n);
    int a, b;
    for (int i = 1; i < n; i++) {
        cin >> a >> b;
        --a, --b;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    for (int i = 0; i < n; i++) {
        ans += (i + 1ll) * 1ll * (n - i);
        for (int j : edge[i]) {
            if (j > i) continue;
            ans -= (j + 1ll) * 1ll * (n - i);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 15088
n = int(input())
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
s = input()
for i in range(n):
    string = z_algo(s[i:])
    for j in range(len(string)):
        if j  >= string[j]:
            ans = max(ans, string[j])
print(ans)

Measured memory_bytes: 48860
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
int p[N],a[N],b[N];
struct node{int l,r,mid,mn;}s[N<<2];
void build(int di,int l,int r)
{
    s[di].l=l,s[di].r=r,s[di].mid=l+r>>1,s[di].mn=1e9;
    if(l==r)return;
    build(di<<1,l,s[di].mid),build(di<<1|1,s[di].mid+1,r);
}
void ins(int di,int x,int v)
{
    if(s[di].l==s[di].r){s[di].mn=v;return;}
    if(x<=s[di].mid)ins(di<<1,x,v);
    else ins(di<<1|1,x,v);
    s[di].mn=min(s[di<<1].mn,s[di<<1|1].mn);
}
int qry(int di,int l,int r)
{
    if(l<=s[di].l&&s[di].r<=r)return s[di].mn;
    else if(r<=s[di].mid)return qry(di<<1,l,r);
    else if(l>s[di].mid)return qry(di<<1|1,l,r);
    return min(qry(di<<1,l,r),qry(di<<1|1,l,r));
}
struct edge{int to,nxt;}e[N<<1];
int head[N],tot=1;
void adde(int x,int y){e[tot]=(edge){y,head[x]};head[x]=tot++;}
priority_queue<int>q;
int n,rd[N];
void topo()
{
    for(int i=1;i<=n;i++)
        for(int j=head[i];j;j=e[j].nxt)rd[e[j].to]++;
    for(int i=1;i<=n;i++)if(!rd[i])q.push(i);
    int tt=0;
    while(!q.empty())
    {
        int u=q.top();q.pop(),b[++tt]=u;
        for(int i=head[u];i;i=e[i].nxt)
            if(!(--rd[e[i].to]))q.push(e[i].to);
    }
}
int main()
{
    int k;scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){int x;scanf("%d",&x),a[x]=i;}
    for(int i=1;i<=n/2;i++)swap(a[i],a[n-i+1]);
    build(1,1,n);
    for(int i=n;i>=1;i--)
    {
        int x=qry(1,max(1,a[i]-k+1),a[i]);
        if(x>=1&&x<=n)adde(a[i],a[x]);
        x=qry(1,a[i],min(n,a[i]+k-1));
        if(x>=1&&x<=n)adde(a[i],a[x]);
        ins(1,a[i],i);
    }
    topo();
    for(int i=1;i<=n/2;i++)swap(b[i],b[n-i+1]);
    for(int i=1;i<=n;i++)p[b[i]]=i;
    for(int i=1;i<=n;i++)printf("%d\n",p[i]);
}

Measured memory_bytes: 50816
/* 

	CODE TEMPLATE APRATIM

*/

#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define veci vector<ll>
#define it map<string, vv>::iterator
#define MOD 1000000007
#define N (ll)3e+5
#define test int T;cin>>T;while(T--)
#define nl "\n"
#define FULL(iii) iii.begin(),iii.end()
#define setbit(_) __builtin_popcount(_)
#define INF 9223372036854775807 
#define TOUPR(str) transform(str.begin(), str.end(),str.begin(), ::toupper)
#define TOLWR(str) transform(str.begin(), str.end(),str.begin(), ::tolower)
#define pb push_back
#define len(s) s.length()
#define pb push_back
#define eb emplace_back
#define S second
#define F first
#define len(s) s.length()
#define coutp cout<<setprecision(15)
#define pow(a,b) (ll)(pow(a,b)+0.5)
#define bin(x) stoull(x,0,2)
#define lld long double 
int main()
{
	ll n,d,c=0,a,b;
	cin>>n>>d;
	while(n--)
	{
		cin>>a>>b;
		if(d*d>=a*a+b*b)
		c++;
	}
	cout<<c;
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, h;
vector<int> a, b;


bool f(int m){
    int sum = 0;
    rep(i, 0, n){
        if(b[i] < a[0]) continue;
        sum += b[i];
        m--;
        if(m == 0) break;
    }
    sum += m * a[0];
    return sum >= h;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> h;
    a.resize(n); b.resize(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    int l = 0, r = 1e9 + 10;
    rep(i, 0, 100){
        int mid = (l + r) / 2;
        if(f(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int>a(5);
  for(int i=0;i<5;i++){
    cin >> a.at(i);
  }
  int ans=0;
  for(int i=0;i<5;i++){
    if(a.at(i)==0){
      ans=i+1;
    }
  }
  cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		String[] b = new String [1000];
		for(int i = 0;i < a;i++){
			String str = br.readLine();
			int j = 0;
			for(int Len = 1;Len < str.length();Len++){
				String str2 = str.substring(0,Len);
				String str3 = str.substring(Len,str.length());
				StringBuilder str4 = new StringBuilder(str2);
				str4.reverse();
				String rev = new String(str4);
				StringBuilder str5 = new StringBuilder(str3);
				str5.reverse();
				String rev2 = new String(str5);
				b[j] = str2 + str3;
				b[j+1] = str2 + rev2;
				b[j+2] = rev + str3;
				b[j+3] = rev + rev2;
				StringBuilder rev3 = new StringBuilder(b[j]);
				rev3.reverse();
				b[j+4] = new String(rev3);
				StringBuilder rev4 = new StringBuilder(b[j+1]);
				rev4.reverse();
				b[j+5] = new String(rev4);
				StringBuilder rev5 = new StringBuilder(b[j+2]);
				rev5.reverse();
				b[j+6] = new String(rev5);
				StringBuilder rev6 = new StringBuilder(b[j+3]);
				rev6.reverse();
				b[j+7] = new String(rev6);
				j = j + 8;
			}
			HashSet<String> set= new HashSet<String>();
			for(int k = 0;k < (str.length() - 1) * 8;k++){
				set.add(b[k]);
			}
			Iterator it = set.iterator();
			System.out.println(set.size());
		}
	}
}

Measured memory_bytes: 62028
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll t;
    cin>>t;
    string s;
    cin>>s;
    int a=0,b=0;
    rep(i, s.size()) {
        if(s[i] == 'R') a++;
        else b++;
    }
    if (a > b) pr("Yes");
    else pr("No");
    return 0;
}



Measured memory_bytes: 384
// https://atcoder.jp/contests/abc141/tasks/abc141_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, m: usize,
        a: [i64; n]
    };


    let mut bh = BinaryHeap::new();
    for i in 0..n {
        bh.push(a[i]);
    }
    let mut total = 0;
    let mut m = m;
    while let Some(w) = bh.pop() {
        if m >= 1 {
            m -= 1;
            bh.push(w / 2);
        } else {
            total += w;
        }
    }
    println!("{}", total);
}


Measured memory_bytes: 8444
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld  long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N=2e5+2;
int n, a[N], b[N];
vector<int> v;
int main()
{
    IO
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        cin>>b[i];
    sort(b,b+n,greater<int>());
    for(int i=0; i<n; i++)
        if(a[i]==b[i])
            v.push_back(i);
    int j=0;
    for(auto i : v)
    {
        while(j<n && (a[j]==b[i] || b[j]==a[i]))
            j++;
        if(j==n)
            return cout<<"No", 0;
        swap(b[j],b[i]);
    }
    cout<<"Yes\n";
    for(int i=0; i<n; i++)
        cout<<b[i]<<" ";
}


Measured memory_bytes: 5832
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let d = util::get();
    let digits = format!("{}", d).len();

    let tmp = (max(2, digits)..digits * 2 + 1)
        .map(|l| {
            search(l, Vec::new(), 0, d)
                .into_iter()
                .map(|v| {
                         v.iter()
                             .enumerate()
                             .map(|(i, &x)| if i == 0 { 9 - x.abs() } else { 10 - x.abs() })
                             .fold(1, |acc, x| acc * x) *
                         if l % 2 == 1 { 10 } else { 1 }
                     })
                .sum::<isize>()
        })
        .sum::<isize>();
    println!("{:?}", tmp);
}

fn search(l: usize, cur: Vec<isize>, memo: isize, d: isize) -> Vec<Vec<isize>> {
    let base = 10usize.pow(l as u32 - 1 - cur.len() as u32) as isize -
               10usize.pow(cur.len() as u32) as isize;

    if cur.len() == l / 2 - 1 {
        (-9..10)
            .filter(|x| memo + base * x == d)
            .map(|k| {
                     let mut v = cur.clone();
                     v.push(k);
                     v
                 })
            .collect()
    } else {
        (-9..10)
            .map(|x| (x, memo + base * x))
            .filter(|&(_, x)| (d - x).abs() < base)
            .map(|(k, x)| {
                     let mut v = cur.clone();
                     v.push(k);
                     search(l, v, x, d)
                 })
            .fold(Vec::new(), |mut acc, mut v| {
                acc.append(&mut v);
                acc
            })
    }
}


Measured memory_bytes: 4352
def f(x,l,r,v):
    if 0<=x<=l:
        return v+(l-x)
    if l<=x<=r:
        return v
    if r<=x:
        return v+x-r
def speed(t):
    num=10**9
    for l,r,v in table:
        num=min(num,f(t,l,r,v))
    return num
N=int(input())
T=[int(i) for i in input().split()]
V=[int(i) for i in input().split()]
X=[0]*(N+1)
for i in range(1,N+1):
    X[i]=X[i-1]+T[i-1]
table=[(X[i] , X[i+1],V[i]) for i in range(N)]
table.append((0,0,0))
table.append((X[-1],X[-1],0))
#print(table)
s=speed(0)
meter=0
for i in range(1,2*X[-1]+1):
    t=speed(i*0.5)
    meter+=(s+t)*(0.25)
    s=t
print(meter)


Measured memory_bytes: 43372
#include <iostream>
using namespace std;
int main(void){
    string s;
    string ans="Yes";
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0&&s[i]=='L'){
            ans="No";
        }else if(i%2==1&&s[i]=='R'){
            ans="No";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n; cin>>n;
	vector<int> v[n];
	pair<int,int> p[n-1];
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		p[i]={x,y};
		v[x].pb(y);
		v[y].pb(x);
	}
	map<pair<int,int>,int> m;
	int a[n]={0};
	int b[n]={0};
	queue<int> q;
	q.push(0);
	b[0]=1;
	int ans=0;
	while(q.size()>0){
		int x=q.front();
		int y=a[x];
		q.pop();
		int z=0;
		for(int i=0;i<v[x].size();i++){
			if(b[v[x][i]]==0){
				q.push(v[x][i]);
				b[v[x][i]]=1;
				z++; if(y==z) z++;
				m[{x,v[x][i]}]=z;
				m[{v[x][i],x}]=z;
				a[v[x][i]]=z;
				ans=max(z,ans);
			}
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<n-1;i++){
		cout<<m[p[i]]<<endl;
	}
}

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

int main() {
  size_t N;
  std::cin >> N;

  std::vector<int32_t> v;
  for (size_t i = 0; i < N; i++) {
    int32_t n;
    std::cin >> n;
    v.emplace_back(n);
  }

  int32_t highest = v[0];
  int32_t result = 0;
  for (const auto& h : v) {
    if (highest <= h) {
      result++;
      highest = h;
    }
  }

  std::cout << result << std::endl;

  return 0;
}

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

int main(){
    long long a,b,x,p,q;
    cin>>a>>b>>x;
    int cnt=0;
    /*
    for(long long i=a;i<=b;i++){
        if(i%x==0)cnt++;

    }
    cout<<cnt<<"\n";

    */

   /* if(a%x==0){
        int p=a/x + 1;
    }
    else */

    if(a%x==0){
        p = (a/x) - 1 ;
    }
    else
        p=(a/x);

     q = b/x;

    cout<<q-p<<"\n" ;


    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  string ans;
  ans = S[0];
  ans += S[1];
  ans += S[2];
  cout << ans << endl;
}


Measured memory_bytes: 3600
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (char c: n) sum += (c - '0');
    cout << (sum % 9 ? "No\n" : "Yes\n");
    return 0;
}


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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double pi = 3.141592653589793238;
  double C = 2.0 * pi * abs(H * 1.0 / 12 - 11.0 * M / 720);
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(C));
  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll p[n];
    rep(i, 0, n){
        cin >> p[i];
    }

    map<ll, ll> flag;
    ll ans = 0;

    rep(i, 0, n){
        if(flag.count(p[i] - 1)){
            flag[p[i]] = flag[p[i] - 1] + 1;
        }else{
            flag[p[i]] = 1;
        }
        ans = max(ans,flag[p[i]]);
    }

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



Measured memory_bytes: 14336
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (z >= 0 && z <= K) ans++; 
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int f(int a,int b) {
	if (a%b == 0)return a / b;
	else return (a + (b - a%b)) / b;
}
int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i<n; i++) {
		int p; cin >> p;
	}
	cout << f((n - k), k - 1) + 1 << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,k;
    string s;
    cin >> n >> s >> k;
    char c = s.at(k-1);
    string res = "";
    rep(i,n){
        if(s.at(i)==c){
            res.push_back(c);
        }else{
            res.push_back('*');
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
program ABC148D
    integer N
    integer,allocatable,dimension(:)::A
    integer::num
    read*,N
    allocate(A(N))
    read*,A
    num=1
    do i=1,N
        if(A(i)==num)then
            num=num+1
        endif
    end do
    print"(i0)",merge(N-num+1,-1,num/=1)
    contains
end program

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    ll n;
    cin >> n;
    ll a = 1;
    ll mod = 1e9 + 7;
    while (n > 1) {
        a = (a * n) % mod;
        --n;
    }
    cout << a << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	double sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}

	sort(A.begin(), A.end(), greater<int>());

	if ((sum / (4 * M)) <= (double)A[M-1]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, p;
    seika s;
    cin >> n >> p >> s;
    i64 ans = 0;
    if (p == 2)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 2 == 0)
            {
                ans += i + 1;
            }
        }
    }
    else if (p == 5)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 5 == 0)
            {
                ans += i + 1;
            }
        }
    }
    else
    {
        map<int, i64> mp;
        i64 cur = 0, k = 1;
        mp[0]++;
        reverse(s.begin(), s.end());
        for (int i = 0; i < n; i++)
        {
            cur += (s[i] - '0') * k;
            cur %= p;
            ans += mp[cur];
            mp[cur]++;
            k = k * 10 % p;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


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

int main() {
  string s; cin>>s;
  int n=s.size();

  int ans=0;
  int gcnt=0;
  int pcnt=0;
  rep(i, n) {
    if (s[i]=='g'&&pcnt<gcnt) {
      pcnt++;
      ans++;
    }
    else if (s[i]=='g'&&pcnt>=gcnt) gcnt++;
    else if (s[i]=='p'&&pcnt<gcnt) pcnt++;
    else {
      gcnt++;
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<long,long>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll a,b;
	string tmp;
	cin >> a >> tmp;
	tmp=tmp[0]+tmp.substr(2,2);
	b = stoll(tmp);
	cout << a*b/100 << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ll a,b,n;
   cin>>a>>b>>n;
   ll con;
   if(n<b)
   con=(ll)a*n/b;
   else if(n==b)
    con=(ll)a*(n-1)/b;
   else con=(ll)a*(b-1)/b;
   cout<<con;
   return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[MAX+1];
int head = 1, tail, n;

void enqueue(P x);
P dequeue(void);
int isEmpty(void);
int isFull(void);

int main(){
  int elaps = 0, c, t = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  tail = i;

  for(i = 1; i <= MAX; i++){
    if(tail == head) break;

    t = Q[i].t - q;

    if(t  > 0){

      Q[i].t = t;
      elaps += q;
      u = dequeue();
      enqueue(u);
    }
    else if(t <= 0){

      elaps += Q[i].t;
      u = dequeue();
      printf("%s %d\n",u.name,elaps);
    }
  } 
  return 0;
}

void enqueue(P x){
  if(isFull() == 1){
    exit(1);
  }else{
    Q[tail] = x;
    tail++;
  }
}

P dequeue(){
  if(isEmpty() == 1){
    exit(1);
  }else{
    head++;
    return Q[head-1];
  }
}

int isEmpty(){
  if(head == tail) return 1;
  else return 2;
}

int isFull(){
  if(head == ((tail+1)%MAX)) return 1;
  else return 2;
}

Measured memory_bytes: 21072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;
const int N=1e3+5;

int n;
int a[3][N];
int prefix[N],suffix[N];

int ans;

int score(int col)
{
    int res=0;
    res=prefix[col] + suffix[col];

    return res;
}

int main()
{
    int i,j;

    scanf("%d", &n);
    for(i=1;i<=2;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    for(i=1;i<=n;i++)
    {
        prefix[i] = prefix[i-1] + a[1][i];
    }
    for(i=n;i>=1;i--)
    {
        suffix[i] = suffix[i+1] + a[2][i    ];
    }

    for(i=1;i<=n;i++)
    {
        ans=max(ans,score(i));
    }

    printf("%d\n", ans);


    return 0;
}

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

using namespace std;

int main() {

  int l, r;
  cin >> l >> r;

  int max = r;
  if (r > l + 4200)
    max = l + 4200;

  vector<int> v(max - l + 1, 2018);

  int tmp;

  for (int i = 0; i < max - l + 1; i++) {
    v[i] = i + l % 2019;
  }

  int ans = 2018;

  for (int i = 0; i < max - l; i++) {
    for (int j = i + 1; j < max - l + 1; j++) {
      tmp = (v[i] * v[j]) % 2019;
      if (tmp < ans)
        ans = tmp;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll MOD =1e9 + 7;



int main(){
	int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<(char)(((s[i]-'A'+n)%26)+'A');
    }
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.next());
    int[][] abc = new int[n][3];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        abc[i][j] = Integer.parseInt(scanner.next());
      }
    }
    int l, m;
    int[][] dp = new int[n][3];
    dp[0] = abc[0];
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        l = (j + 1) % 3;
        m = (j + 2) % 3;
        dp[i][j] = Math.max(dp[i - 1][l] + abc[i][j], dp[i - 1][m] + abc[i][j]);
      }
    }
    Arrays.sort(dp[n - 1]);
    System.out.println(dp[n - 1][2]);
  }
}


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


int main() {
    int n,k;
    cin >> n >> k;
    map<int,int>mp;
    rep(i,n){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    vector<int> v;
    for(auto it = mp.begin();it!=mp.end();it++){
        v.push_back(it->second);
    }
    sort(v.begin(), v.end(), less<int>());

    int ans = 0;
    int d = v.size() - k;
    rep(i,d){
        ans += v[i];
    }

    cout << ans << endl;

    
    return 0;
}  

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.000000001
#define ld long double
#define inf 5e18
#define N 2000005
#define K 17


int fact[N],ifact[N];

ll fastexpom(ll a,ll b,ll m)
{
    ll res=1;
    a = a % m;
    while(b>0)
    {
        if(b % 2 == 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b/=2;
    }
    return res;
}
ll modinv(ll a, ll m=1000000007)
{
  return fastexpom(a,m-2,m);
}
void preprocess()
{
    fact[0] = 1;
    ifact[0] = 1;
    for(int i = 1;i < N;i++)
    {
        fact[i] = (fact[i-1] * i)%mod;
        
    }
    ifact[N - 1] = modinv(fact[N - 1], mod);
    for(int i  = N - 2;i >= 1;i--)
    {
        ifact[i] = (ifact[i + 1] * (i + 1)) % mod;
        // assert(ifact[i] == modinv(fact[i], mod));
    }
}
int nCr(int n,int r)
{
    if(n == 0 and r == 0)
        return 1;
    if(r > n or r < 0 or n == 0)
        return 0;
    int ans = (fact[n] * ifact[n-r])%mod;
    ans = (ans * ifact[r])%mod;
    return ans;
}


int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int k;
    string s;
    cin >> k >> s;
    int n = s.length();
    preprocess();
    int ans = 0;
    for(int i = n;i <= n + k;i++)
    {
        int  lans = fastexpom(26, n + k - i, mod);
        lans = (lans * ((nCr(i - 1, n - 1) * fastexpom(25, i - n, mod)) % mod)) %mod;
        // assert(lans >= 0);
        ans = (ans + lans)  % mod;
    }
    cout << ans;
    return 0;
    
}   

Measured memory_bytes: 35684
#include<bits/stdc++.h>
using namespace std;
int n;
int find_p(int x) {
	int tmp=x;
	while(tmp>=10) tmp/=10;
	return tmp;
}
int ans=0,c[20][20];
int main()
{
	memset(c,0,sizeof(c));
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		int j=find_p(i),k=i%10;
		c[j][k]++;
	}
	for(int i=0;i<=9;++i)
		for(int j=0;j<=9;++j)
			ans+=c[i][j]*c[j][i];
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[17]:


N,x = map(int, input().split())
a = list(map(int, input().split()))


# In[18]:


a_sum = sum(a)
if a_sum == x:
    print(N)
elif a_sum < x:
    print(N-1)
else:
    for i in range(N):
        if x < sum(sorted(a, reverse=False)[:i+1]):
            print(i)
            break


# In[ ]:






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

int N,A,B;

int main(){
    cin >> N >> A >> B;
    int ans=0;
    for(int i=1; i<=N; i++){
        int total = i/10000 + i/1000%10 + i/100%10 + i/10%10 + i%10;
        if(A <= total && total <= B)  ans += i;
    }
    cout << ans << endl;
}


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

int main(){
  int n, m, i, j;
  int flag = 0;
  char a[51][51], b[51][51];
  cin >> n >> m;
  for ( i = 0; i < n; i++ ){
    for ( j = 0; j < n; j++ ){
      cin >> a[i][j];
    }
  }
  for ( i = 0; i < m; i++ ){
    for ( j = 0; j < m; j++ ){
      cin >> b[i][j];
    }
  }
  
  for ( int shiftx = 0; shiftx <= n - m; shiftx++ ){
    for ( int shifty = 0; shifty <= n - m; shifty++ ){
      flag = 0;
      for ( i = 0; i < m; i++ ){
        for ( j = 0; j < m; j++ ){
          if ( a[i + shiftx][j + shifty] != b[i][j] ){
            flag = 1;
            break;
          }
        }
        if ( flag == 1 ) break;
      }
      if(flag == 0)break;
    }
    if(flag == 0)break;
  }
  
  if ( flag == 1 ){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

typedef long long ll;

#define Canuc80k cin.tie(0); cout.tie(0);
#define I_am ios_base::sync_with_stdio(false);
#define REP(i,a,b) for (int i = a; i < b; i ++)
#define FOR(i,a,b) for (int i = a; i <= b; i ++)
#define FORD(i,a,b) for (int i = a; i >= b; i --)

const int N = 1e6 + 1;
const int M = 1e9 + 7;

string str;

int main() {
    I_am Canuc80k;

    cin >> str;
    if (str == "ABC") cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3640
n = int(input())
ls = [list(map(int, input().split())) for _ in range(n)]
x, y = ls[0]
for a, b in ls[1:]:
    k = max((x + a - 1) // a, (y + b - 1) // b)
    x, y = k * a, k * b
print(x + y)

Measured memory_bytes: 3188
n,m=map(int,input().split())
ans_1=[]
ans_2=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        ans_1.append(b)
    if b==n:
        ans_2.append(a)
if set(ans_1)&set(ans_2)!=set():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 21844
s = list(input())
n = len(s)
n_dash = int((n-1)*0.5)
pre = 1
for i in range(n):
    if s[i] == s[n-i-1]:
        pass
    else:
        pre = 0
        break
if pre == 0:
    result = 'No'
else:
    for j in range(n_dash):
        if s[j] == s[n_dash-j-1]:
            result = 'Yes'
        else:
            result = 'No'
            break
print(result)

Measured memory_bytes: 3064
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int a,b,c,d,ans;
	cin>>a>>b>>c>>d;
  	ans=min(b,d)-max(a,c);
  	if(ans<0)ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;

  for(int i=0; i<sz(S); i++) {
    if ( i % 2 ==  0 ) {
      if ( !(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') ) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    else {
      if ( !(S[i] == 'L' || S[i] == 'U' || S[i] == 'D') ) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

void f(){int a,b,c;
    cin>>a>>b>>c;
    if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
    cout<<"YES"<<endl;
    }
      else{
      cout<<"NO"<<endl;
      }
}
int main(){
	int n,i;
	cin>>n;
	for(i=0;i<n;++i){
	f();
	}
    return 0;
}

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

#define all(a)  (a).begin(),(a).end()

int main()
{
    int k,t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++)
    {
        cin >> a[i];
    }

    sort(all(a));
    reverse(all(a));

    int ans = max(a[0] - 1 - (k - a[0]) ,0);

    cout << ans << endl;
}

Measured memory_bytes: 3524
//2020-06-02
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x << " = { " << x << " }\n"
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int n;
    ll x[M];
    ll sum = 1;
    cin >> n;
    bool iszero = 0, isflow = 0;
    loop(i, 0, n)
    {
        cin >> x[i];
        if (x[i] == 0)
            iszero = 1;
    }
    if(iszero){cout<<"0\n";return 0;}

    for (int i = 0; i < n; i++)
    {
        if (x[i] <= 1000000000000000000 / sum)
        {
            // This condition is equivalent to prod*a[i] <=10ˆ18
            sum *= x[i];
        }
        else
        {
            printf("-1\n");
            return 0;
        }
    }
        cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4448
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;
ll left[200000], right[200000];
ll cnt[200000];

int main() {
  std::cin >> S;

  ll N = S.size();
  ll prv = -1;

  rep( i, N ) {
    if( S[i] == 'R' )
      right[i] = i, prv = i;
    else
      right[i] = prv;
  }

  prv = -1;
  repd( i, N ) {
    if( S[i] == 'L' )
      left[i] = i, prv = i;
    else
      left[i] = prv;
  }

  rep( i, N ) {
    if( S[i] == 'R' ) {
      ll L = left[i];
      ll s = L-i;

      ++cnt[L-(s&1)];
    } else {
      ll R = right[i];
      ll s = i-R;

      ++cnt[R+(s&1)];
    }
  }

  rep( i, N )
    std::cout << cnt[i] << (i==N-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 6020