akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n, m, x;
    cin >> n >> m >> x;
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        if(a < x){
            cnt1++;
        }
        else{
            cnt2++;
        }
    }
    cout << min(cnt2, cnt1);
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

int w, h, n;
pint info[16];
int land[10][10], ans_land[10][10];
pint sign_pos[16];

bool can_put(int left, int top, int width, int height, int b)
{
	int right = left + width - 1;
	int bottom = top + height - 1;
	if (left < 0 || top < 0 || right >= w || bottom >= h)
		return false;

	for (int y = top; y <= bottom; ++y)
		for (int x = left; x <= right; ++x)
			if (land[y][x] != 0 && land[y][x] != b)
				return false;
	return true;
}
void put(int left, int top, int width, int height, int b)
{
	int right = left + width - 1;
	int bottom = top + height - 1;

	for (int y = top; y <= bottom; ++y)
		for (int x = left; x <= right; ++x)
			land[y][x] = b;
}
bool ok()
{
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			if (land[y][x] == 0)
				return false;
	return true;
}
int dfs(int depth)
{
	if (depth == n)
	{
		if (ok())
		{
			memcpy(ans_land, land, sizeof(ans_land));
			return 1;
		}
		else
			return 0;
	}

	int res = 0;

	int b = info[depth].second;
	int k = info[depth].first;
	int sx = sign_pos[b].first;
	int sy = sign_pos[b].second;
	for (int height = 1; height <= k; ++height)
	{
		if (k % height)
			continue;
		int width = k / height;
		for (int y = sy - height-1; y <= sy; ++y)
		{
			for (int x = sx - width-1; x <= sx; ++x)
			{
				if (can_put(x, y, width, height, b))
				{
					put(x, y, width, height, b);
					res += dfs(depth + 1);
					put(x, y, width, height, 0);
					land[sy][sx] = b;

					if (res > 1)
						return 2;
				}
			}
		}
	}

	return res;
}
int main()
{
	while (scanf("%d%d%d", &w, &h, &n), w|h|n)
	{
		memset(info, 0, sizeof(info));
		for (int i = 0; i < n; ++i)
		{
			int b, k;
			scanf("%d%d", &b, &k);
			info[i] = pint(k, b);
		}
		sort(info, info+n, greater<pint>());

		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				scanf("%d", &land[y][x]);
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				if (land[y][x])
					sign_pos[land[y][x]] = pint(x, y);

		if (dfs(0) == 1)
		{
			for (int y = 0; y < h; ++y)
			{
				for (int x = 0; x < w-1; ++x)
					printf("%d ", ans_land[y][x]);
				printf("%d\n", ans_land[y][w-1]);
			}
		}
		else
			puts("NA");
	}

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    string fast = s.substr(0,1);
    string secand = to_string(len - 2);
    string last = s.substr(len - 1,1);
    cout << fast << secand << last << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

long long two(long long H) {
    long long ans = 2; 
    while (true) {
        if (H < ans) {
            break;
        }
        ans *= 2;
    }
    return ans;
}

int main() {
    long long H;
    cin >> H;
    long long ans = two(H) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 3556
//2016.7.15
//ABC 067 (B)

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	sort(A.begin(), A.end());
  while(k>0){
    ans+=A[n-1];
    n--;
    k--;
  }

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


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

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, 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")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}



fn main() {
    input! {
        xs: chars,
    }
    let mut xs = xs;
    xs.sort();

    let ans = if (xs[0] == xs[1]) && (xs[2] == xs[3]) && (xs[0] != xs[2]) {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 4352
def main():
  n = int(input())
  #s = input()
  #s = input().split()
  #n,m = list(map(int,input().split()))
  a =  list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  
  lis = [0]*n
  for i in a:
    lis[i-1] += 1
    
  for i in range(n):
    print(lis[i])

if __name__ == '__main__':
  main()

Measured memory_bytes: 32368
#include<stdio.h>
#include<math.h>
int main(){
	int q;
	float x;
	while(scanf("%d",&q),q+1){
		x=q/2.;
		while(fabs(x*x*x-q)>=0.00001*q){
			x-=(x*x*x-q)/3/x/x;
		}
		printf("%f\n",x);
	}
	return 0;
}

Measured memory_bytes: 0
program palace
  implicit none
  integer :: n, t, a, h(1000) = 0
  read(*,*) n
  read(*,*) t, a
  read(*,*) h(1:n)
  write(*,'(i0)') minloc(abs(1000*a-(1000*t-6*h(1:n))))
end program palace

Measured memory_bytes: 384
package main

import "fmt"

func getRuneAt(s string, i int) rune {
	rs := []rune(s)
	return rs[i]
}

func main() {
	var N int
	fmt.Scan(&N)
	words := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&words[i])
	}
	res := true
	for i := 0; i < N; i++ {
		if i == 0 {
			continue
		} else {
			if getRuneAt(words[i-1], len(words[i-1])-1) != getRuneAt(words[i], 0) {
				res = false
				break
			}
			for j := 0; j < i; j++ {
				if words[i] == words[j] {
					res = false
					break
				}
			}
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s[]=String.valueOf(n).split("");
		int total=0;
		for(int i=0;i<s.length;i++){
			total+=Integer.parseInt(s[i]);
		}
		if(n%total==0){
			put("Yes");
		}else{
			put("No");
		}

}
	public static void put(String n){
		System.out.println(n);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int ans = 0;

int a(int b){
  
  for(int i=1;i<b;i++){
    ans += i;
  }
  return ans;
}

int main(){
   int n,m;
   cin >> n >> m;
   if(n>=2 || m>=2){
     a(n);
     a(m);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long ll;
int n,m,p[N],per[N],vis[N],ans[N],lop[N],cnt;
ll k,val[N],res[N];
int main() {
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i)
    scanf("%lld",&val[i]);
  scanf("%d%lld",&m,&k);
  for (int i = 1 ; i <= m ; ++ i)
    scanf("%d",&p[i]);
  for (int i = n ; i >= 1 ; -- i)
    val[i] = val[i] - val[i-1];
  for (int i = 1 ; i <= n ; ++ i)
    per[i] = i;
  for (int i = 1 ; i <= m ; ++ i)
    swap(per[p[i]],per[p[i]+1]);
  for (int i = 1 ; i <= n ; ++ i) {
    if (vis[i]) continue;
    cnt = 0;
    lop[++cnt] = i;
    int pos = per[i];
    while (pos != i) {
      vis[pos] = 1;
      lop[++cnt] = pos;
      pos = per[pos];
    }
    for (int j = 1 ; j <= cnt ; ++ j)
      ans[lop[j]] = lop[(j + k - 1) % cnt + 1];
  }
  for (int i = 1 ; i <= n ; ++ i)
    res[i] = val[ans[i]];
  for (int i = 1 ; i <= n ; ++ i)
    res[i] += res[i-1];
  for (int i = 1 ; i <= n ; ++ i)
    printf("%lld.0\n",res[i]);
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  int ans = 0;
  rep(i,s.size()){
    int j = s.size()-i-1;
    if(s[i] != s[j] && i<j) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ab=[[0,0] for _ in range(M)]
one=set()
n=set()
for i in range(M):
    ab[i][0],ab[i][1]=map(int,input().split())
    if ab[i][0]==1:
        one.add(ab[i][1])
    elif ab[i][1]==N:
        n.add(ab[i][0])
if one.isdisjoint(n):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

int main() {
  int N;
  scanf("%d", &N);
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 1; i < N; i++) {
    int count = 0;

    for (char c = 'a'; c <= 'z'; c++) {
      bool left = false;
      bool right = false;

      for (int j = 0; j < i; j++) {
        if (S[j] == c) {
          left = true;
          break;
        }
      }

      for (int j = i; j < N; j++) {
        if (S[j] == c) {
          right = true;
          break;
        }
      }

      if (left && right) count++;
    }

    if (ans < count) ans = count;
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static List<int>[] Sub;
    static int[] Salary;
    
    
    static void Main(string[] args){
        var NM  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        
        var N = NM[0];
        var M = NM[1];
        
        for(long gcd = (M/N);gcd >= 1;gcd--){
            var min = M-gcd*N;
            if(min%gcd == 0){
                Console.WriteLine(gcd);
                break;
            }
        }
        
    }
         
}


Measured memory_bytes: 13396
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int N;
    int a[1005];
    scanf("%d",&N);
    for(int i=1; i<=N; i++){
        scanf("%d",&a[i]);
    }
    sort(a + 1,a +  N + 1);
    printf("%d",a[N] - a[1]);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
vector<vector<char> >v;
int w, h;
int ans = 0;
void dfs(int x, int y) {
	if (x < 0 || h <= x)return;
	if (y < 0 || w <= y)return;

	if (v[x][y] == '#')return;

	if (v[x][y] == '.'||v[x][y]=='@') {
		ans++;
		v[x][y] = '#';
		dfs(x + 1, y);
		dfs(x - 1, y);
		dfs(x, y - 1);
		dfs(x, y + 1);
	}
	return;
}
int main() {
	while (cin >> w >> h, h) {
		ans = 0;
		int x, y;
		v = vector<vector<char> >(h, vector<char>(w));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> v[i][j];
				if (v[i][j] == '@') {
					x = i;
					y = j;
				}
			}
		}
		dfs(x, y);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        InvestMaster solver = new InvestMaster();
        solver.solve(1, in, out);
        out.close();
    }

    static class InvestMaster {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int MAX = (int) 1e5 + 10;
            int n = in.nextInt();
            int d = in.nextInt();
            int x = in.nextInt();
            int[][] p = new int[d][n];
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < n; j++) {
                    p[i][j] = in.nextInt();
                }
            }
            int[] dp = new int[MAX];
            for (int i = 0; i < d - 1; i++) {
                Arrays.fill(dp, 0);
                for (int j = 0; j < x + 1; j++) {
                    dp[j] = j;
                }
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < x + 1; k++) {
                        if (k - p[i][j] >= 0) {
                            dp[k] = Math.max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
                        }
                    }
                }
                int buf = 0;
                for (int j = 0; j < x + 1; j++) {
                    buf = Math.max(buf, dp[j]);
                }
                x = buf;
            }
            out.println(x);
        }

    }
}




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


main()
{
    long long n,a,b;
    long long ans=0;
    scanf("%lld %lld %lld",&n,&a,&b);
    long long nw;
    scanf("%lld",&nw);
    for(int i=1;i<n;i++)
    {
        long long po;
        scanf("%lld",&po);
        ans+=min(a*(po-nw),b);
        nw=po;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	vector<int> v;
	while(n--){
		int a,b;cin>>a;
		if(a==0){
			cin>>b;
			v.push_back(b);
		}
		if(a==1){
			cin>>b;
			cout<<v[b]<<endl;
		}
		if(a==2)v.pop_back();
	}
	return 0;
}



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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll N;
    cin >> N;
    ll A[N];
    ll B[N];
    rep(i, N) {
        cin >> A[i];
        B[i] = 0;
    }

    rep(i, N) {
        if (i % 2 == 0) {
            B[0] += A[i];
        } else {
            B[0] -= A[i];
        }
    }

    B[0] = B[0] / 2;
    rep(i, N - 1) { B[i + 1] = A[i] - B[i]; }
    rep(i, N) { B[i] *= 2; }
    rep(i, N) { cout << B[i] << " "; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2816
from sys import stdin

N, M = map(int, input().split())
*AB, = map(int, stdin.read().split())


def main():
    A = AB[::2]
    B = AB[1::2]
    Z = zip(A, B)
    Z = sorted(Z)
    num = 0
    yen = 0
    for a, b in Z:
        if M < num + b:
            yen += a * (M - num)
            break
        else:
            yen += a * b
            num += b
    print(yen)
    return


main()


Measured memory_bytes: 25836
#include <stdio.h>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    int N;

    cin>>N;

    if(N==3||N==5||N==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

cnt_r = 1
cnt_l = 0
for i in range(1, N):
    pre_direction = S[i-1]
    crnt_direction = S[i]
    if pre_direction == 'L' and crnt_direction == 'R':
        zero_l = [0] * (cnt_r-1)
        zero_r = [0] * (cnt_l-1)
        person_l = (cnt_r+1)//2 + (cnt_l//2)
        person_r = (cnt_l+1)//2 + (cnt_r)//2
        print(*(zero_l + [person_l, person_r] + zero_r), end=' ')
        cnt_r = 1
        cnt_l = 0
    elif crnt_direction == 'R':
        cnt_r += 1
    elif crnt_direction == 'L':
        cnt_l += 1

zero_l = [0] * (cnt_r-1)
zero_r = [0] * (cnt_l-1)
person_l = (cnt_r+1)//2 + (cnt_l//2)
person_r = (cnt_l+1)//2 + (cnt_r)//2
print(*(zero_l + [person_l, person_r] + zero_r))


Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define EPS                 0.00000001
#define LL_MAX              1e18
#define LL_MIN              -1e18
#define MAX                 0x3f3f3f3f
#define MIN                 -0x3f3f3f3f
#define MOD                 1000000007
#define DEBUG(x)            cout << '>' << #x << ':' << x << endl;
#define REP(i,n)            for(int i=0;i<(n);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--)
#define n1                  '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> pt;
typedef vector<pt> pol;

ll power(ll b, int e) {
    ll res = 1;
    for ( ; e>0; e/=2) {
        if (e&1) res = res*b % MOD;
        b = b*b % MOD;
    }
    return res;
}

inline void IOS() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

namespace short_dynamic_hull {
//*/
// WARNING: could overflow for values ~1e9, use __int128 instead
// WARNING: tested only with integer and rational types
const ll is_query = -(1LL<<62);
struct Line {
  ll m, b;
  mutable function<const Line*()> succ;
  bool operator<(const Line& rhs) const {
    if (rhs.b != is_query) return m < rhs.m;
    const Line* s = succ();
    if (!s) return 0;
    ll x = rhs.m;
    return b - s->b < (s->m - m) * x;
  }
};
// will maintain upper hull for maximum
struct HullDynamic : public multiset<Line> {
  bool bad(iterator y) {
    auto z = next(y);
    if (y == begin()) {
      if (z == end()) return 0;
      return y->m == z->m && y->b <= z->b;
    }
    auto x = prev(y);
    if (z == end()) return y->m == x->m && y->b <= x->b;
    // could overflow
    return (x->b - y->b)*(z->m - y->m) >= (y->b - z->b)*(y->m - x->m);
  }
  void insert_line(ll m, ll b) {
    m = -m; b = -b; // for lower hull
    auto y = insert({ m, b });
    y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
    if (bad(y)) { erase(y); return; }
    while (next(y) != end() && bad(next(y))) erase(next(y));
    while (y != begin() && bad(prev(y))) erase(prev(y));
  }
  ll eval(ll x) {
    auto l = *lower_bound((Line) { x, is_query });
    //return l.m * x + l.b; 
    return -(l.m * x + l.b); // for lower hull
  }
};
}

int main()
{
    IOS();
    ll n, c;
    cin >> n >> c;
    vector<ll> arr(n);
    REP(i, n) {
        cin >> arr[i];
    }
    vector<ll> dp(n, MAX);
    short_dynamic_hull::HullDynamic hull;
    dp[0] = 0;
    ll k = c + arr[1]*arr[1];
    hull.insert_line(-2*arr[0], arr[0]*arr[0]);
    FOR(i, 1, n-1) {
        dp[i] = hull.eval(arr[i]) + c + arr[i] * arr[i];
        hull.insert_line(-2*arr[i], dp[i] + arr[i] * arr[i]);
    }
    cout << dp[n-1] << n1;   
    return 0;
}

/*
dp[i] = min j<i  dp[j] + C + hi^2 + hj^2 - 2*hi*hj
      = hi^2  +  min j<i  (dp[j] + C + hj^2) - (2*hj)*hi

i=1:  y = -2*h1 * x + (C + h1^2)
i=2:  y = -2*h2 * x + (dp[2] + C + h2^2)

*/


Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int A, B, K; cin >> A >> B >> K;
    Int t = min(A, K);
    A -= t, K -= t;
    t = min(B, K);
    B -= t, K -= t;
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M, C  = tuple([int(x) for x in input().split(' ')])
B = np.array([int(x) for x in input().split(' ')])
A = np.array([[int(x) for x in input().split(' ')] for i in range(N)])

count = 0
for i in range(N):
    if sum(B*A[i]) + C > 0:
        count += 1
print(count) 

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

int main(void){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int>dict;
  for(int i=0;i<N;i++){
    if(A[i]%2==0) dict.push_back(A[i]);
  }
  int count=0;
  for(int i=0;i<dict.size();i++){
    if(dict[i]%3==0||dict[i]%5==0) count++;
  }
  if(count==dict.size()) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[A, B] = inpl()
if A <= 5:
    ans = 0
elif A>5 and A < 13:
    ans = B//2
else:
    ans = B

print(ans)

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

int m[30][2],a,b,c,l,root,ch[40];

void pre(int n){
  cout<<" "<<n;
  if(m[n][0]!=-1)pre(m[n][0]);
  if(m[n][1]!=-1)pre(m[n][1]);
}

void in(int n){

  if(m[n][0]!=-1)in(m[n][0]);
    cout<<" "<<n;
  if(m[n][1]!=-1)in(m[n][1]);
}

void pos(int n){
  if(m[n][0]!=-1)pos(m[n][0]);
  if(m[n][1]!=-1)pos(m[n][1]);
  cout<<" "<<n;
}

int main(){
  cin>>l;
  for(int i=0;i<=l;i++)ch[i]=0;
  for(int i=0;i<l;i++){
    cin>>a>>b>>c;
    m[a][0]=b;
    m[a][1]=c;
    ch[b]=1;
    ch[c]=1;
  }
  for(int i=0;i<l;i++)if(ch[i]==0)root=i;
  cout<<"Preorder"<<endl;
  pre(root);
  cout<<endl;
  cout<<"Inorder"<<endl;
  in(root);
  cout<<endl;
  cout<<"Postorder"<<endl;
  pos(root);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int AM[100][100];
int color[100], d[100], f[100], time;

void DFS();
void DFS_visit(int);

int main(){
  int i, j, u, k, v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      AM[i][j] = 0;
    }
  }

  for(i=0;i<n;i++)

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      AM[u][v] = 1;
    }
  }

  DFS();

  return 0;
}

void DFS(){
  int i;
  for(i = 0 ; i < n ; i++){
    color[i] = 0;
  }

  time = 0;

  for(i = 0 ; i < n ; i++){
    if(color[i] == 0) DFS_visit(i);
  }

  for(i = 0 ; i < n ; i++){
    printf("%d %d %d\n",i+1, d[i],f[i]);
  }
}

void DFS_visit(int x){
  int i;

  color[x] = 1;
  d[x] = ++time;
  for(i = 0 ; i < n ; i++){
    if(AM[x][i] ==  0) continue;
    if(color[i] == 0){
      DFS_visit(i);
    }
  }
  color[x] = 2;
  f[x] = ++time;
}



Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c){
	cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c&&c<=b){
	cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<=a&&a<=c){
	cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c&&c<=a){
	cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<=a&&a<=b){
	cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b&&b<=a){
	cout<<c<<" "<<b<<" "<<a<<endl;
	}
	
return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (char)('A' + a[0] - 'a');
  std::cout << (char)('A' + b[0] - 'a');
  std::cout << (char)('A' + c[0] - 'a');
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;


ll u, v, t;
vi *g;
ll dep[100005];
ll p[100005];

ll dfs(int V, int pV, int h){
  p[V] = pV;
  dep[V] = h;
  bool b = (V == u);
  for(auto k : g[V]){
    if(k == pV) continue;
    if(dfs(k, V, h+1)){
      if(h == dep[u]/2){
        t = k;
      }
      b = 1;
    }
  }
  return b;
}

ll dfs2(int V, int pV){
  ll ans = dep[V];
  for(auto k : g[V]){
    if(k == p[V]) continue;
    ans = max(ans, dfs2(k, V));
  }
  return ans;
}

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n; cin >> n >> u >> v;
    g = new vi[n+1];
    f(i, n-1){
      ll a, b; cin >> a >> b;
      g[a].pb(b);
      g[b].pb(a);
    }

    dfs(v, -1, 0);
    // DBG(dep[u])
    // DBG(t)
    // DBG(dep[t])
    ll k = dfs2(t, -1);
    cout << k - 1 << endl;

    return 0;
}


Measured memory_bytes: 13824
# -*- coding: utf-8 -*-

N, Y = map(int, input().split())

# kは全体-(i+j)で出せるのでループは2重でいい
for i in range(N+1):
    for j in range(N+1):
        k = N - (i + j)
        # kがマイナスになったらその先は周回する必要なし
        if k < 0:
            break
        # 条件を満たす値なら出力して終了
        if i * 10000 + j * 5000 + k * 1000 == Y:
            print(i, j, k)
            exit()
# 1つも候補がなかった場合
print(-1, -1, -1)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//Squid Multiplication
public class Main{

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

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			List<Long> even = new ArrayList<Long>(), odd = new ArrayList<Long>(), list = new ArrayList<Long>();
			for(int i=0;i<n*(n+1)/2;i++){
				long x = sc.nextLong();
				list.add(x);
				if(x%2==0)even.add(x);
				else odd.add(x);
			}
			Collections.sort(list);
			boolean con = true;
			for(int i=0;i<even.size()&&con;i++)for(int j=i+1;j<even.size()&&con;j++){
				long bi = even.get(i), bj = even.get(j), bk = odd.get(0);
				long g = gcd(bi, bk);
				bi/=g; bk/=g;
				g = gcd(bj, bk);
				bj/=g; bk/=g;
				double r = Math.sqrt(bi*bj/bk);
				long a0 = (long)r;
				if(a0==0)continue;
				long[] a = new long[n];
				boolean f = true;
				List<Long> l = new ArrayList<Long>();
				for(int x=0;x<n;x++){
					long y = even.get(x);
					if(y%a0!=0){
						f = false; break;
					}
					a[x]=even.get(x)/a0;
					l.add(a0*a[x]);
				}
				if(!f)continue;
				for(int x=0;x<n;x++)for(int y=x+1;y<n;y++)l.add(a[x]*a[y]);
				Collections.sort(l);
				boolean ok = true;
				for(int x=0;x<l.size();x++){
					long A = l.get(x), B = list.get(x);
					if(A!=B){
						ok = false; break;
					}
				}
				if(ok){
					Arrays.sort(a);
					System.out.println(a0);
					con = false;
					for(int x=0;x<n;x++)System.out.print(a[x]+(x==n-1?"\n":" "));
				}
			}
		}

	}

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

Measured memory_bytes: 0
(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

@g, @f = Hash.new{|h, k| h[k] = []}, Hash.new{|h, k| h[k] = []}
ABs.each{|a, b| @g[a] << b; @f[b] << a}

def bfs(a)
  q, p = [a], []
  until q.empty?
    b = q.shift
    @g[b].select{|x| p[x].nil?}.each do |c|
      p[c] = b
      q << c
    end
  end
  p
end

res, len = nil, N + 1
(1 .. N).each do |a|
  p = bfs(a)
  @f[a].each do |b|
    next unless p[b]
    r = [b]
    r.unshift(p[r[0]]) until r[0] == a
    l = r.size
    res, len = r, l if l < len
  end
end  
puts res.nil? ? -1 : len, res

Measured memory_bytes: 6140
s = input()
t = input()
s_length = len(s)
t_length = len(t)
dp = [[0] * (s_length + 1) for i in range(t_length + 1)]
for i in range(1, t_length + 1):
    for j in range(1, s_length + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if t[i - 1] == s[j - 1]:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + 1)
        # print(t[i-1],s[j-1])
        #print(dp)
    #print('---')

answer = ""

while s_length >= 0 and t_length >= 0:
    if dp[t_length][s_length] == dp[t_length - 1][s_length]:
        t_length -= 1
        continue
    elif dp[t_length][s_length] == dp[t_length][s_length-1]:
        s_length -= 1
        continue
    else:
        answer += s[s_length-1]
        s_length -= 1
        t_length -= 1
#print(dp[i][j])
print(answer[::-1])

Measured memory_bytes: 113628
import math
def divisor(n):
    ans = []
    sqr = int(math.sqrt(n))
    for x in range(1, sqr+1):
        if n % x == 0:
            ans.append(x)
            y = n//x
            if x != y:
                ans.append(y)
    ans.sort()
    return ans

x = int(input())
div = divisor(x)
flag = False
for i in div:
    if flag:
        break
    a = i // 2
    j = x // i
    b = a - i
    jj = a**4+a**3*b+a**2*b**2+a*b**3+b**4
    #print('a = {0}, b = {1}'.format(a, b))
    #print('i = {0},  j = {1}, jj = {2}'.format(i, j, jj))
    while(jj <= j):
        b = a - i
        jj = a**4+a**3*b+a**2*b**2+a*b**3+b**4
        #print('a = {0}, b = {1}'.format(a, b))
        #print('i = {0}, j = {1}, jj = {2}'.format(i, j, jj))
        if j == jj:
            print('{0} {1}'.format(a, b))
            flag = True
            break
        a += 1
    

Measured memory_bytes: 9136
def main():
    n = int(input())
    A = list(map(int,input().split()))
    A.sort()
    A_max = A[-1]
    g = []
    table = [True]*(A_max+1)
    for i,a in enumerate(A):
        if table[a]:
            temp = a
            while A_max >= temp:
                table[temp] = False
                temp+=a
            if i==n-1 or a!=A[i+1]:
                g.append(a)
    print(len(g))
main()

Measured memory_bytes: 110512
// 2016/05/28 Tazoe

#include <iostream>
#include <queue>
#include <string>
using namespace std;

// ????????????????????????
class Proc{
public:
	string nam;
	int tim;
	Proc(){  nam = "";  tim = 0;  }
};

int main()
{
	queue<Proc> Q;

	int n, q;
	cin >> n >> q;

	for(int i=0; i<n; i++){
		Proc P;
		cin >> P.nam >> P.tim;

		Q.push(P);
	}

	int total_tim = 0;

	while(!Q.empty()){
		Proc P = Q.front();  Q.pop();

		if(P.tim<=q){
			total_tim += P.tim;

			cout << P.nam << ' ' << total_tim << endl;
		}
		else{
			total_tim += q;
			P.tim -= q;

			Q.push(P);
		}
	}

	return 0;
}

Measured memory_bytes: 4404
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,M;
    llong a,b;
    cin >> N >> M;
    vector<vector<llong> > graph(N);
    for(int i=0; i<M; i++){
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    for(auto mid_node : graph[0]){
        for(auto goal_node:graph[mid_node]){
            if(N-1==goal_node){
                cout << "POSSIBLE" << endl;
                exit(0);
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 15532
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
int d, n;
bool used[20005][105][2];
int dp[20005][105][2];
//桁、和、最大値を取っているか
int solve(int i, int j, bool k) {
	if (i == n) {
		if (j == 0) return 1;
		return 0;
	}
	if (used[i][j][k]) return dp[i][j][k];
	int sum = 0;
	for (int z = 0; z <= (k ? ((int)s[i] - '0') : 9); z++) {
		sum += solve(i + 1, (j + z) % d, k&&z == (int)(s[i] - '0'));
		sum %= Mod;
	}
	used[i][j][k] = 1;
	return dp[i][j][k] = sum;
}
signed main() {
	cin >> s >> d;
	n = s.size();
	int ans = 0;
	for (int i = 0; i <= (int)(s[0] - '0'); i++) {
		ans += solve(1, i%d, i == (int)(s[0] - '0'));
		ans %= Mod;
	}
	cout << (ans - 1 + Mod) % Mod << endl;
}

Measured memory_bytes: 23552
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
	        String s = kb.readLine();
	        String p = kb.readLine();
	        
	        int slen = s.length();
	        int plen = p.length();
	        int j = 0;
			for( int i = 0; i<slen; i++ ) {
				if( p.charAt( 0 ) == s.charAt( i ) ) {
					int ij = i;
					for( j = 0; j<plen; j++ ) {
						if( slen <= i+j ) {
							ij = ( i+j ) - slen;
						} else {
							ij = i + j;
						}
						if( p.charAt( j ) != s.charAt( ij ) ) {
							break;
						}
					}
				}
				if( plen == j ) { break; }
			}
			
			if( plen == j ) {
				System.out.println( "Yes" );			
			} else {
				System.out.println( "No" );
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 17052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<3;i++)
		ans+=a[i]==b[i];
	cout<<ans;
}
int main()
{


	int t;
	// cin>>t;
	t = 1;
	while (t--) solve();


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 文字列の入力1
      String str1 = sc.nextLine();
      // 文字列の入力1
      String str2 = sc.nextLine();
      if(!str1.equals(str2)) {
        int count = 0;
        for(int i = 0;i<str1.length();i++) {
          if(str1.charAt(i)!= str2.charAt(i)) {
            count++;
          }
        }
        System.out.println(count);
      }else {
        System.out.println(0);
      }
  }
}

Measured memory_bytes: 42264
#include <bits/stdc++.h>
#include <random>
#include <unistd.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <ll> vi;
typedef vector <ll> vll;
typedef vector <ull> vull;
typedef vector <vll> vvll;
typedef long double ld;
typedef vector <ld> vld;
typedef pair <ll, ll> pii;
typedef pair <ll, ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef vector <vpii> vvpii;
typedef vector <bool> vbool;

#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define rforn(i, x, y) for (ll i = x; i >= y; --i)
#define add push_back
#define del pop_back
#define ins insert
#define ers erase
#define F first
#define S second
#define int ll
#define _ inline
#define sqr(x) ((x) * (x))
#define pw(x) (1LL << (x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rev(x) reverse(x)
#define sz(x) (int)(x).size()
#define rsz resize
#define cpy(x, T, c) copy(all(x), ostream_iterator <T>(cout, c))
#define mem(x, val) memset(x, val, sizeof(x))
_ ll gcd(ll a, ll b) { while (b) { a %= b, swap(a, b); } return a; }
_ ll lcm(ll a, ll b) { return a * b / max(1LL, gcd(a, b)); }

const ll INF = (ll)1e9 + 2017;
const ll MOD = (ll)1e9 + 7;
const ld EPS = 1e-10;
const ld PI = acos(-1.0);
mt19937 rnd((int)time(0));

const int N = 55;
vi gr[N];
bool used[N];
int tin[N], up[N], T, ans;

void dfs(int v, int p = -1)
{
    used[v] = 1;
    tin[v] = T++;
    up[v] = tin[v];
    for (int u : gr[v])
    {
        if (!used[u])
        {
            dfs(u, v);
            if (up[u] > tin[v])
            {
                ans++;
            }
            up[v] = min(up[v], up[u]);
        }
        else
        {
            if (u != p)
            {
                up[v] = min(up[v], tin[u]);
            }
        }
    }
}

void source()
{
    int n, m;
    cin >> n >> m;
    forn(i, 0, m)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        gr[u].add(v);
        gr[v].add(u);
    }
    dfs(0);
    cout << ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout.precision(10);
#ifdef _F1A4X_
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    source();
#ifdef _F1A4X_
    cerr << endl << endl << "\t" << (ld)clock() / CLOCKS_PER_SEC << " sec" << endl;
    sleep(INF);
#endif
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<cmath>

using namespace std;

int mod_num_counter[2030];

int main()
{
  //fill(mod_num_counter,mod_num_counter+2030,0);
  
  string s;
  cin >> s;
  
  if(s[1] == 'B')
  {
        cout << "ARC" << endl;
  }
  else
  {
            cout << "ABC" << endl;

  }
    
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#define no return cout << "NO\n", 0
using namespace std;
const int H = 405;
int f[H], d[H];
bool b[H], c[H];
int getf(int x)
{
	return f[x] == x ? x : f[x] = getf(f[x]);
}
int main()
{
	ios::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	for (int i = 0; i <= 2 * h; i++)
		f[i] = i;
	while (n--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int x = (c ? -c : a) + h, y = (d ? d : -b) + h;
		f[getf(x)] = getf(y);
		::d[x]++;
		::d[y]--;
		::b[x] = true;
	}
	for (int i = 0; i < h; i++)
		if (d[i] > 0)
			no;
	for (int i = h + 1; i <= 2 * h; i++)
		if (d[i] < 0)
			no;
	for (int i = 0; i <= 2 * h; i++)
	{
		b[getf(i)] |= b[i];
		if (d[i])
			c[f[i]] = true;
	}
	for (int i = 0; i <= 2 * h; i++)
		if (f[i] == i && !c[i] && b[i])
			no;
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 384
import sys
n, k = map(int, input().split())
T = [int(input()) for i in range(n)]
def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i
def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r
x=Allocation()
print(x)



Measured memory_bytes: 9564
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<memory.h>
#include<set>
#include<sstream>
#include<map>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
#define pb push_back
const int N = 1e5+19;
int n , v[N] , adjFreq[N] , cnt;
int main(){
 //   freopen("input.txt","r",stdin);
     scanf("%d",&n);
     for(int i=0;i<n;++i)
     {
     	scanf("%d",v+i);
     }
     for(int i=0;i<n;++i)
     {
     	if(i > 0 && v[i]==v[i-1]){++cnt ; ++i;}
     }
      cout<<cnt<<"\n";
   } 

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = (int)Math.max(Math.max(a+b , a*b), a-b);
		System.out.println(ans);
	}

}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, min(p[i], n-i));
    }
    cout << ans << endl;
    return 0;
}



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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<tuple<int, int, int>> vc;
    tuple<int, int, int> G;

    rep(i, n)
    {
        int x, y, h;
        cin >> x >> y >> h;
        vc.push_back(make_tuple(x, y, h));
        if (h > 0)
        {
            G = make_tuple(x, y, h);
        }
    }

    for (int cx = 0; cx < 101; cx++)
    {
        for (int cy = 0; cy < 101; cy++)
        {
            int H = get<2>(G) + abs(cx - get<0>(G)) + abs(cy - get<1>(G));
            bool ok = true;
            rep(i, n)
            {
                int h_temp = max(H - abs(cx - get<0>(vc[i])) - abs(cy - get<1>(vc[i])),0);
                if (h_temp != get<2>(vc[i]))
                {
                    ok = false;
                    break;
                }
            }
            if(ok)
            {
                cout << cx << ' '<< cy << ' '<< H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <cstdlib> 
#include <iostream>
using namespace std; 
int main()
{
    int i,h,w,j;
    char t;
    scanf("%d %d ",&h, &w);
    int  a[h+1][w+1];
    for(i=0;i<=w;i++)
    {
        a[0][i]=0;
    }
    for(j=0;j<=h;j++)
        {
            a[j][0]=0;
        }
        
        
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            
           scanf("%c",&t);
           
           if(t=='.')
           {a[i][j]=((a[i][j-1])+ (a[i-1][j]));}
           else
           {a[i][j]=0;}
           
             a[1][1]=1;
             a[i][j]=a[i][j]% 1000000007;
           
        }
        scanf("%c",&t);
    }
    
     printf("%d ",a[h][w]);
}


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

using namespace std;
#define gc getchar()
#define re register
inline int read()
{
    re int x(0);re char c(gc);
    while(c>'9'||c<'0')c=gc;
    while(c<='9'&&c>='0')x=x*10+c-48,c=gc;
    return x;
}

int n;
const int N=1e6+10;
void P(int x,int y){cout<<x<<" "<<y<<'\n';}

int main()
{
    n=read(); int m=1;
    while (m<n) m<<=1;
    if (n<3||m==n) {
        puts("No");
        return 0;
    }
    puts("Yes");
    P(1,n+2); P(n+2,3);
    P(3,n+1); P(n+1,2);
    P(2,n+3);
    for (int i=4;i<n;i+=2) {
        P(i,n+1); P(i,n+i+1);
        P(i+1,n+1); P(n+i,i+1);
    }
    if (!(n&1))
    {
        for (int i=2;i<n;++i) {
            if ((n^(i^1))<n) {
                int a=i;
                int b=n^i^1;
                P(n,a); P(n+n,b);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2816