akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

ll fac(ll n){
    if(n == 0) return 1;
    ll tmp = 1;
    for (int i = 1; i <= n; ++i) {
        tmp *= i;
    }
    return tmp;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < n-2; ++i) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
int main()
{
  ll n,m;
  cin>>n>>m;vector<ii>v;ll c,d;
  f(i,1,n+1)
  {
      cin>>c>>d;
      v.pb(mp(c,d));
  }
  ll a[n+1][m+1];
  memset(a,0,sizeof(a));
  f(i,1,n+1)
  {
      f(j,1,m+1)
      {
          if(v[i-1].F<=j)
          {
              //cout<<v[i-1].S+a[i-1][j-v[i-1].F]<<" ";
              a[i][j]=max((ll)(v[i-1].S+a[i-1][j-v[i-1].F]),a[i-1][j]);
          }
          else
            a[i][j]=a[i-1][j];
      }
  }
  cout<<a[n][m];
  


    return 0;

}


Measured memory_bytes: 79104
use std::cmp::min;


fn main() {
    let (n, k) = read_tuple::<usize>();
    let an: Vec<i64> = read_vec();

    let mut ans = i64::max_value();
    for i in 0..(1<<n) {
        if i % 2 != 1 || ((i as usize).count_ones() as usize) < k {
            continue;
        }

        let mut an = an.clone();
        let mut max_height = an[0];
        let mut cost = 0;
        for j in 1..n {
            if i & (1 << j) == (1 << j) {
                if an[j] <= max_height {
                    cost += max_height - an[j] + 1;
                    an[j] = max_height + 1;
                    max_height += 1;
                } else {
                    // an[j] > max_height
                    max_height = an[j];
                }
            } else {
                if max_height < an[j] {
                    cost = i64::max_value();
                    break;
                }
            }
        }

        ans = min(ans, cost);
    }

    println!("{}", ans);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>
using namespace std;
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
//#define viadj[n+1] vector<int>adj[n+1] 
#define sortA(arr)   sort(arr.begin(),arr.end())
#define sortC(arr,n)   sort(arr,arr+n,comparefunc())
#define search(arr,c)  binary_search(arr.begin(),arr,end(),c)
#define pb   push_back
#define ll long long
 
/*struct node{
     int b;long sum;
     string name;
}
 
 
bool comparefunction(node c,node d){
   if(c.b!=d.b)
   return c.b>d.b;
     
}*/
 
 // 
 
  /* void dfs(int v) {
    visited[v] = true;
 
    
    for (int u : adj[v]) {
       if (!visited[u])
            dfs(u);
    }
   
    
}*/
 
 int  gcd(int a,int b)
 {
       // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a%b, b); 
    return gcd(a, b%a); 
 }
   
 
     
 
 
 
 
int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
   
    int check1=0,check2=0,check3=0;
    int counti=0;
    long double pi=3.141592653589793;
    ll sum=0,count=0,n,m,t,k,a,b,c,d;
  //  cin>>t;
    //while(counti!=t)
    {
        string str;
      cin>>str;
      if(str[1]=='B')
      cout<<"ARC";
      else
      cout<<"ABC";
     
      //  counti++;
    }
 
}
 
 

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n = 0;
    int k = 0;
    vector<int> h;
    cin >> n >> k;
    if ( n <= k){
        cout << 0 << endl;
    }else {
        for(int i=0;i<n;i++){
            int t;
            cin >> t;
            h.emplace_back(t);
        }
        sort(h.begin(), h.end());
        for(int i=0;i<k;i++){
            h.pop_back();
        }
        long long int ans = 0;
        for (int i=0;i<h.size();i++){
            ans += h[i];
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define vi vector<double>//double.
#define vvi vector<vi >
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi p(n+1);
	for(int i=1;i<=n;++i) cin>>p[i];
	
	vvi dp(n+1,vi(n+1,0));//dp[i][j].i枚ある中でj枚表になる確率.
	dp[1][0]=1-p[1];
	dp[1][1]=p[1];
	for(int i=2;i<=n;++i){
		for(int j=0;j<=i;++j){
			if(j==0) dp[i][j]=dp[i-1][0]*(1-p[i]);
			else dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
		}
	}
	
	double ans=0;
	for(int i=n/2+1;i<=n;++i){
		ans+=dp[n][i];
	}
	
	printf("%.10f",ans);
}//解答参考.

Measured memory_bytes: 70656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

ll n,a,b;

int main(void){
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max((ll)0,a+b-n)<<endl;
	return 0;
}

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

int main(){
    int H;
    int N;
    cin >> H >> N; 
    vector<int> A(N); 
    rep(i,N) cin >> A.at(i);
    int damage = 0;

    rep(i, N) damage += A.at(i);

    if (H <= damage)
    {
         cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;

}


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

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int[] h = new int[N+1];
		int[] dp = new int[N+1];
		int INF = Integer.MAX_VALUE / 2;
		Arrays.fill(dp, INF);
		dp[1] = 0;
		
		for(int i = 1; i <= N; i++)
			h[i] = sc.nextInt();
		
		for(int i = 1; i <= N; i++){
			if(i+1 <= N)
				dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(h[i] - h[i+1]));
			if(i+2 <= N)
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(h[i] - h[i+2]));
		}
		
		System.out.println(dp[N]);
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23220
#include <bits/stdc++.h>
using namespace std;
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
int INF = 2147483647, MOD = 1e9 + 7;
double EPS = 1e-15, PI = acos(-1);
int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1}, dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1};
struct SegmentTree{
    int n;
    vector<int> t1, t2;
    SegmentTree(int size){
        n = 2;
        while(n < size) n *= 2;
        t1.resize(2 * n - 1, INF);
        t2.resize(2 * n - 1, -1);
    }
    void check(int k){
        if(t2[k] < 0) return;
        if(k * 2 + 1 < n * 2 - 1){
            t2[k * 2 + 1] = t2[k];
            t2[k * 2 + 2] = t2[k];
        }
        t1[k] = t2[k];
        t2[k] = -1;
    }
    int update(int a, int b, int x, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        check(k);
        if(r <= a || b <= l) return t1[k];
        if(a <= l && r <= b) return t2[k] = x;
        check(k);
        t1[k] = min(
            update(a, b, x, k * 2 + 1, l, (l + r) / 2),
            update(a, b, x, k * 2 + 2, (l + r) / 2, r)
        );
        return t1[k];
    }
    int query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        check(k);
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return t1[k];
        return min(
            query(a, b, k * 2 + 1, l, (l + r) / 2),
            query(a, b, k * 2 + 2, (l + r) / 2, r)
        );
    }
};
// main
signed main() {
    int n, q, res = 0;
    cin>>n>>q;
    SegmentTree t(n);
    int a, l, r, x;
    rep(i, q){
        cin>>a>>l>>r;
        if(!a) cin>>x, t.update(l, r + 1, x);
        else cout<<t.query(l, r + 1)<<endl;
    }
}



Measured memory_bytes: 4932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,l,k,i,j,kk,arr[200009];
    scanf("%lld %lld",&n,&m);
    kk=0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&arr[i]);
    }
    sort(arr,arr+n);
  for(i=n-1-m;i>=0;i--)
    kk+=arr[i];
  printf("%lld\n",kk);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	int a,b,c;
	cin>>a>>b>>c;
	int dd=a-b,aa=0;
	cout<<max(aa,c-dd);
}

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

int main() {
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    if (c[0][0]-c[0][1] == c[1][0]-c[1][1] && c[2][0]-c[2][1] == c[1][0]-c[1][1]) {
        if (c[0][2]-c[0][1] == c[1][2]-c[1][1] && c[2][2]-c[2][1] == c[1][2]-c[1][1]) {
            if (c[0][0]-c[1][0] == c[0][1]-c[1][1] && c[0][2]-c[1][2] == c[0][1]-c[1][1]) {
                if (c[2][0]-c[1][0] == c[2][1]-c[1][1] && c[2][2]-c[1][2] == c[2][1]-c[1][1]) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main()
{
    int x,n; cin >> x >> n;
    vector<int> p(n); rep(i, n) cin >> p[i];
    int ans = 1000;
    if(n==0){
        cout << x << endl;
        return 0;
    }
    int mn = 1000;
    rep(i,102){
        bool flg = true;
        rep(j,n) if(i == p[j]) flg = false;
        if(!flg) continue;
        if(mn > abs(x-i)){
            ans = i;
            mn = abs(x-i);
        }
    }
    cout << ans << endl;
}

/*
g++ c.cpp
./a.out

oj d https://atcoder.jp/contests/abc170/tasks/abc170_c
oj t
*/


Measured memory_bytes: 3596
import java.util.Scanner;

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

        // Union Find Tree
        UnionFindTree uft = new UnionFindTree(n);

        for (int i = 0; i < m; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            // Put `a` and `b` into the same group
            uft.unite(a, b);
        }
        
        // Number of members of the largest group
        int max = 0;
        for (int i = 0; i < n; ++i) {
            max = Math.max(max, uft.size(i));
        }

        System.out.println(max);
    }
}

class UnionFindTree {
    int size;
    // ancestors[i] is the ancestor node of `i`
    int ancestors[];
    // Number of members of the group
    int counts[];

    public UnionFindTree(int size) {
        this.size = size;
        this.ancestors = new int[this.size];
        this.counts = new int[this.size];

        for (int i = 0; i < this.size; ++i) {
            // initialize a parent of `i` as `i`
            this.ancestors[i] = i;
            this.counts[i] = 1;
        }
    }

    // Put node `a` and node `b` in the same group
    public void unite(int a, int b) {
        int root_a = this.root(a);
        int root_b = this.root(b);

        // already in the same group
        if (root_a == root_b) {
            return;
        }
        else if (this.counts[root_a] > this.counts[root_b]) {
            this.ancestors[root_b] = this.ancestors[root_a];
            this.counts[root_a] += this.counts[root_b];
        }
        else {
            this.ancestors[root_a] = this.ancestors[root_b];
            this.counts[root_b] += this.counts[root_a];
        }
    }

    // Check if `a` and `b` are in the same group
    public boolean same(int a, int b) {
        int root_a = this.root(a);
        int root_b = this.root(b);

        // `a` and `b` are in the same group if the root of `a` == the root of `b`
        return root_a == root_b;
    }

    // Get a root node of `a`
    public int root(int a) {
        // `a` is the root node
        if (this.ancestors[a] == a) {
            return a;
        }

        // Replace the parent of `a` into the root of `a`
        int root = this.root(this.ancestors[a]);
        this.ancestors[a] = root;
        this.counts[a] = this.counts[root];

        return root;
    }

    public int size(int a) {
        int root = this.root(a);
        return this.counts[root];
    }
}



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

int main() {
  int N;
  cin >> N;
  int a[3 * N];
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }
  sort(a, a + 3 * N, greater<int>());
  int64_t sum = 0;
  for(int i = 0; i < 2 * N; i++) {
    if (i % 2 == 1) {
      sum += a[i];
    }
  }
  cout << sum << endl;
}


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

/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ld, ld>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

//const ll md = 1e9 + 7;//998244353;
const int xn = 2e5 + 10;
const int xm = -20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int Md = 998244353;
const int TM = 3;
const int Base = 257;

ll n, ans, res = 1, num[xn], part[xn];

int main(){
    InTheNameOfGod;
    
    cin >> n;
    for (int i = 0; i <= n; ++ i) cin >> num[i];
    if (n == 0){
    	if (num[0] == 1) kill(1);
    	else kill(-1);
	}
    for (int i = n; i >= 0; -- i) part[i] = part[i + 1] + num[i];
    for (int i = 0; i <= n; ++ i){
    	if (i) res = (res - num[i - 1]) * 2;
    	if (res <= 0) kill(-1);
    	ans += res;
    	if (res <= part[i] && (res - num[i]) * 2 >= part[i + 1] && i < n){
    		for (int j = i + 1; j <= n; ++ j) ans += part[j];
    		kill(ans);
		}
	}
	kill(-1);
	
    return 0;
}


Measured memory_bytes: 5184
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
typedef unsigned int uint;
using namespace std;

int main(){
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    string str;
    set<string> s;
    cin>>str;
    s.insert(str);
    for(int j=0;j<(int)str.size()-1;j++){
      string s1=str.substr(0,j+1);
      string s2=str.substr(j+1);
      string s1r=s1;
      string s2r=s2;
      reverse(s1r.begin(),s1r.end());
      reverse(s2r.begin(),s2r.end());
      s.insert(s1+s2r);
      s.insert(s1r+s2);
      s.insert(s1r+s2r);
      s.insert(s2+s1);
      s.insert(s2r+s1);
      s.insert(s2+s1r);
      s.insert(s2r+s1r);
    }
    cout<<s.size()<<endl;

  }

  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N; cin >> N;
  vector<ll> leaf(N+1); rep(i,N+1) cin >> leaf[i];
  if(N==0){
    if(leaf[0]!=1) {
      cout << -1 << endl;
      return 0;
    }
    else{
      cout << 1 << endl;
      return 0;
    }
  }
  if(leaf[0]!=0 || leaf[N]==0){
    cout << -1 << endl;
    return 0;
  }
  vector<ll> leaves(N+2,0);
  rep(i,N+1) leaves[i+1] = leaves[i] + leaf[i];
  vector<ll> node(N+1,0);
  node[0]=1;
  for(ll i=1;i<N+1;i++){
    node[i] = min(node[i-1]*2-leaf[i], leaves[N+1]-leaves[i+1]);
    if(i!=N && node[i]<=0){
      cout << -1 << endl;
      return 0;
    }
    if(i==N && node[i]!=0){
      cout << -1 << endl;
      return 0;
    }
    if(N==1){
      if(node[i]>0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  ll ans = 0;
  rep(i,N+1) ans += (leaf[i]+node[i]);
  //rep(i,N+1) cout << node[i] << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5624
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int K = in.nextInt();
      int[] x = new int[N];
      
      for (int i = 0; i < x.length; ++i) {
        x[i] = in.nextInt();
      }

      int left = 0;
      int right = left + K - 1;
      int time = 0;
      int minTime = Integer.MAX_VALUE;
      while (right < x.length) {
        if (x[right] <= 0) {
          time = Math.abs(x[left]);
        } else if (0 <= x[left]) {
          time = x[right];
        } else {
          time = Math.min(Math.abs(x[left]), x[right]) * 2 + Math.max(Math.abs(x[left]), x[right]);
        }
        
        minTime = Math.min(minTime, time);
        ++left;
        ++right;
      }

      System.out.println(minTime);
    }
  }
}

Measured memory_bytes: 51304
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
int main(){
	int n,k;
	while(cin>>n&&n){
		int ans=0;
		bool f=false;
		for(int i=0;i<n;i++){
			cin>>k;
			if(k>1)f=true;
			ans+=min(1,k);
		}
		if(f)cout<<ans+1<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;

int n,m;
int fie[101];
int dist[101];
char data[5]={'#','A','B','C','D',};

int main(void){
	while(1){
		scanf("%d %d",&m,&n);
		if(n+m==0)break;
		memset(fie,0,sizeof(fie));
		for(int i=0;i<n;i++){
			string a;
			cin >> a;
			if(a[0]=='A'){
				for(int j=0;j<m;j++){
					if(fie[j]==0){
						fie[j]=1;
						break;
					}
				}
			}
			if(a[0]=='B'){
				int j;
				for(j=m-1;j>=0;j--){
					if(j>0 && fie[j-1]==1)continue;
					if(j<m-1 && fie[j+1]==1)continue;
					if(fie[j]==0){
						fie[j]=2;
						break;
					}
				}
				if(j==-1){
					for(int j=0;j<m;j++){
						if(fie[j]==0){
							fie[j]=2;
							break;
						}
					}
				}
			}
			if(a[0]=='C'){
				if(i==0){
					fie[m/2]=3;
				}else{
					for(int j=0;j<m;j++){
						if(fie[j]!=0){
							if(j<m-1 && fie[j+1]==0){
								fie[j+1]=3;
								break;
							}
							if(j>0 && fie[j-1]==0){
								fie[j-1]=3;
								break;
							}
						}
					}
				}
			}
			if(a[0]=='D'){
				if(i==0){
					fie[0]=4;
				}else{
					for(int j=0;j<m;j++)dist[j]=101;
					for(int j=0;j<m;j++){
						if(fie[j]!=0){
							for(int k=0;k<m;k++){
								dist[k]=min(dist[k],abs(k-j));
							}
						}
					}
					int lll=0;
					for(int j=0;j<m;j++){
						if(dist[j]>dist[lll])lll=j;
					}
					fie[lll]=4;
				}
			}
		}
		for(int i=0;i<m;i++){
			printf("%c",data[fie[i]]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
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);
    }
};
// for pair in unordered_map
struct hash_pair {
    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);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
    lli n;
    cin>>n;
    vll A(n);
    umap<lli, lli, custom_hash> mp;
    loop(i, 0, n)
        cin>>A[i];
    loop(i, 0, n){
        lli temp = A[i];
        // cin>>temp;
        if(mp[temp] == 0)
            mp[temp]++;
        else{
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<"YES\n";
    return 0;
}   
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
    }

    sort(a, a + n);
    long long ret = 0;
    for (int i=0; i<n; i++)
        ret += abs(a[i] - a[n / 2]);
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 4436
fn main() {
    use std::io;
    let mut input = String::new();
    let _ = io::stdin().read_line(&mut input);
    let input_num = input.trim().parse::<usize>().unwrap();

    let mut ret = 1;
    for i in 0..input_num {
        ret = ret * (i + 1);
        ret = ret % (1000000000 + 7);
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define pb(x) push_back(x)  
#define rep(i,n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define len(p) (sizeof(p)/sizeof(*p))
#define debug(x) cerr << #x << ": " << x << '\n'; 
// #define int long long
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
template <class T> void print(T x){ cout << x << '\n'; }
template <class T> void print(T *x, size_t l){ rep(i,l){cout << *(x+i) << ' ';} cout << '\n'; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << " "; } return s; }
 
signed main(void){
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n){ cin >> a[i]; }

    // int d[200001];
    map<int, int> d;
    // memset(d, 0, 200001 * sizeof(int));
    rep(i, n){
        d[a[i]]++;
    }
    vector<int> s;
    for (auto it = d.begin(); it != d.end(); it++){
        s.pb(it->second);
    }
    sort(all(s));

    // for (auto it = s.begin(); it != s.end(); it++){ cout << *it << endl;}
    if( s.size() <= k) cout << 0 << endl;
    else {
        int count = 0;
        for(int i = 0; i < (s.size() - k); i++){
            count += s[i];
        }
        cout << count << endl;
    }

}



Measured memory_bytes: 11516
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int a[100001],n,k,i,j,cnt,ans,used;
	while(1){
		scanf("%d %d",&n,&k);
		if(!n)break;
		MEMSET(a);
		cnt=ans=used=0;
		rep(i,k)
			scanf("%d",&a[i]);
		sort(a,k);
		
		for(i=a[0]?0:1;i<k;i++){
			if(a[i]+1==a[i+1])
				cnt++;
			else if(!a[0]&&a[i]+2==a[i+1]&&!used){
				used=1;
				cnt+=2;
			}
			else{
				ans=max(ans,cnt);
				cnt=0;
				if(used){
					used=0;
					i--;
				}
			}
		}
		print(ans+1);
	}
	return 0;
}

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

ifstream in("test.in");
ofstream out("test.out");

const int DIM = 4e5 + 5;

int cnt[30];

int main(void) {
    srand(unsigned(time(0)));
    
    string str;
    cin >> str;
    
    long long ans = 0;
    for (int i = 1; i <= str.length(); ++i) {
        ans += (i - 1) - cnt[str[i - 1] - 'a'];
        cnt[str[i - 1] - 'a']++;
    }
    
    cout << ans + 1;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){

    int a, b, c;
    cin >> a >> b >> c;

    if (a>b) swap (a, b);
    if (b>c) swap (b, c);
    if (a>b) swap (a, b);

    cout << a << " " << b << " " << c << endl;

    return 0;

}



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

typedef long long ll;
const ll mod =1e9+7;
const int maxn = 1e5+5;
ll a[maxn];
ll b[maxn];

ll C[maxn];
ll inv[maxn];

int n,k;
void getinv()
{
	inv[1] = 1;
	for (int i = 2; i <= n; ++i) inv[i] = (long long)(mod-mod/i) * inv[mod%i]%mod;	
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
	if(b==0) 
	{
		x=1;y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}


void getC()
{
	memset(C,0,sizeof(C));
	C[n-k+1] = 1;
	ll beg = k-1, end = 1;
	for(int i=n-k;i>=1;i--)
	{
		ll x=0,y=0;
		beg++;
		exgcd(end,mod,x,y);
		C[i] = C[i+1]%mod*beg%mod*x%mod;
		C[i] = (C[i]%mod+mod)%mod;
		end++;
	}

}

bool cmp(ll a,ll b)
{
	return a>b;
}
int main()
{
	while(cin>>n>>k)
	{
		memset(b,0,sizeof(b));
		
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		sort(a+1,a+1+n,cmp);
		getC();
		ll ans = 0;
		for(int i=1;i<=n;i++)
		{
			b[i] = (C[i]%mod - C[n+1-i]%mod)%mod;
		}
		for(int i=1;i<=n;i++)
		{
			ans = (ans%mod + a[i]*b[i]%mod)%mod;
		}
		
		cout<<ans<<"\n";
	}
 } 
 
 /*
 10 5
 1000000000 999999999 999999998 999999997 999999996 123456789 111111111 9 8 7
 */

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws NumberFormatException, IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int num = Integer.parseInt(br.readLine());
    int cnt = 0;

    int a[] = new int[num];
    int b = 1;

    for (int i = 0; i < a.length; i++) {
      a[i] = Integer.parseInt(br.readLine());
    }

    for (int i = 0; i < a.length + 1; i++) {
      b = getLight(a, b);
      cnt++;

      if (b == 2) {
        break;
      }
    }

    if (cnt > a.length) {
      cnt = -1;
    }

    System.out.println(cnt);
  }

  public static int getLight(int a[], int num) {
    return a[num - 1];
  }

}


Measured memory_bytes: 30804
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if (A + B >= C) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

	

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	db pi = 3.141592653589793238463;
	int r;
	cin >> r;
	cout << setprecision(20) << 2 * r * pi;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>;
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int n;
vector<string> s;

bool check(int y, int x){
  string s1,s2;
  for(int i = 0; i < n; ++i){
    s1 += s[y+i].substr(x+i, n-i);
    for(int j = i; j < n; ++j){
      s1 += s[y+j][x+i];
      s2 += s[y+j][x+i];
    }
    s2 += s[y+i].substr(x+i, n-i);
  }
  if(s1==s2){return true;}
  //cout << s1 <<" " << s2 << endl;
  return false;
}

int main() {
  cin >>n;
  vector<string> a(n);
  for(int i = 0; i < n; ++i){
    cin >>a[i];
  }
  
  s.resize(2*n);
  for(int i = 0; i < 2*n; ++i){
    s[i]=a[i%n] + a[i%n];
  }
  for(int i = 0; i < 2*n; ++i){
    //cout << s[i] << endl;
  }
  
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < 1; ++j){
      if(check(i,j)){
        ++ans;
      }
    }
  }
  cout << ans* n << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

char P[510][510];

void solve(){
	int n; scanf("%d", &n);
	rep(i, n)scanf("%s", P[i]);
	int ok = 0;
	rep(i, n)rep(j, n)if(P[i][j] == '#')ok = 1;
	if(ok == 0)puts("-1");
	else{
		int cc[510] = {};
		rep(i, n)rep(j, n){
			if(P[i][j] == '#')cc[j] = 1;
		}
		int ans = 1e9;
		rep(i, n){
			int cnt = 0;
			rep(j, n)if(P[i][j] == '.')cnt++;
			if(cc[i] == 0)cnt++;
			ans = min(ans, cnt);
		}
		rep(j, n)rep(i, n)if(P[i][j] == '.'){
			ans++; break;
		}
		printf("%d\n", ans);
	}
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(void){
	int x,y;
	cin>>x>>y;
	if(x==2||y==2) cout<<"No"<<endl;
	else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)
			&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))cout<<"Yes"<<endl;
	else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
s_l = list(input())
n = len(s_l)

# 公式解説参照
dp_dict = {0:1}
t = 0
for i in range(n):
    a = int(s_l[-(i+1)])
    t = (t + a*(pow(10,i,2019)))%2019
    dp_dict[t] = dp_dict.get(t,0) + 1

ans = 0
for val in dp_dict.values():
    ans += val*(val-1)//2

print(ans)


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


int main(){
	int N,M;cin>>N>>M;
	vector<int> nos(M);
	for(auto &x: nos) cin>>x;
	sort(nos.begin(),nos.end());
	vector<int> diff;
	for(int i=1;i<nos.size();i++) diff.push_back(nos[i] - nos[i-1]);
	sort(diff.rbegin(),diff.rend());
	int total = nos[M-1] - nos[0];
	N -= 1;
	for(int i=0;i<min((int)diff.size(),N);i++) total -= diff[i];
	cout<<total<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
	string s;
	int ans = 700;

	cin >> s;

	rep(i, 3) if (s[i] == 'o') ans += 100;

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,d;
    scanf("%lld %lld",&n,&d);
    long long x[n],y[n];
    for(long long i=0;i<n;i++)scanf("%lld %lld",&x[i],&y[i]);
    d=d*d;
    long long e=0;
    for(long long i=0;i<n;i++){
        if(x[i]*x[i]+y[i]*y[i]<=d)e++;
    }
    printf("%lld",e);
    return 0;
}

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

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

  int sum = 0;
  for(int i = 0; i < n.length(); i++){
    sum += n[i] - '0';
  }

  sum % 9 == 0 ? cout << "Yes" << endl : cout << "No" << endl; 
return 0;
}


Measured memory_bytes: 3724
n = int(input())
a = list(map(int,input().split()))
a[:0] = [0]
a.append(0)
s = int()
for i in range(n+1):
  s += abs(a[i]-a[i+1])
for j in range(1,n+1):
  print(s-abs(a[j-1]-a[j])-abs(a[j]-a[j+1])+abs(a[j-1]-a[j+1]))

  
  
  


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

using namespace std;

int main() {

	int a,b,c;
	int counter1 = 0;
	int counter2 = 0;
	char d;
	while (cin >> a >> d >> b >> d >> c) {
		if (c * c == a * a + b * b) {
			counter1++;
		} else if (c < a + b && a == b){
			counter2++;
		}
	}

	cout << counter1 << endl << counter2 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  set<string> s;
  char tail;
  for(int i = 0; i < n; i++){
    string word; cin >> word;
    if(i == 0){
      tail = word.at(word.size() - 1);
      s.insert(word);
    }
    else{
      if(s.count(word) or tail != word.at(0)){
        cout << "No";
        return 0;
      }
      s.insert(word);
      tail = word.at(word.size() - 1);
    }
  }
  cout << "Yes";
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  double a, b, x;
  cin >> a >> b >> x;
  
  double height = x / a / a;
  double res;
  if (height * 2 > b) {
    double t = ((b - height) * 2) / a;
    res = rad_to_deg(atan(t));
  } else {
    double width = x / a / b * 2;
    double t = b / width;
    res = rad_to_deg(atan(t));
  }

  printf("%.8f\n", res);

}

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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    int h,w;
    
    int2(h,w);
    
    char arr[h][w];
    int dp[h][w];
    
    fors(i,0,h){
		fors(j,0,w){
			
			cin>>arr[i][j];
		}
	}
	
	dp[0][0] = 1;
	
	fors(i,1,w){
		if(arr[0][i] == '#'){
			dp[0][i] = -1;
		}
		else{
			dp[0][i] = dp[0][i-1];
		}
	}
	
	fors(i,1,h){
		if(arr[i][0] == '#'){
			dp[i][0] = -1;
		}
		else dp[i][0] = dp[i-1][0];
	}
	
	fors(i,1,h){
		fors(j,1,w){
			if(i==0 and j==0) continue;
			else{
				if(arr[i][j]=='#') dp[i][j]=-1;
				else{
					if(dp[i-1][j]==-1) dp[i][j] = dp[i][j-1];
					else if(dp[i][j-1] == -1) dp[i][j] = dp[i-1][j];
					else{
						dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod1;
					}
				}
			}
		}
	}
	
	cout<<max(0,dp[h-1][w-1]);
	
    return 0;
}


Measured memory_bytes: 5120