akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

const int MAX_V = 2020;
const int MAX_LOG_V = 20;
vector<int> G[MAX_V];
int root;

int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p)dfs(G[v][i], v, d + 1);
	}
}

void init(int V) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < MAX_LOG_V; k++) {
		for (int v = 0; v < V; v++) {
			if (parent[k][v] < 0)parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) {
		swap(u, v);
	}
	for (int k = 0; k < MAX_LOG_V; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v)return u;
	for (int k = MAX_LOG_V - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
int dist(int a, int b) {
	int par = lca(a, b);
	return depth[a] + depth[b] - 2 * depth[par];
}


int N, K;
int A[100010], B[100010];
signed main() {
	cin >> N >> K;
	
	REP(i, N-1) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	root = 0;
	init(N);
	int ans = INF;
	if (K % 2 == 0) {
		REP(i, N) {
			int res = 0;
			REP(j, N) {
				if (j == i)continue;
				if (dist(i, j) > K / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	else {
		REP(i, N - 1) {
			int res = 0;
			int l = A[i], r = B[i];
			REP(j, N) {
				if (j == l || j == r)continue;
				int d = min(dist(l, j), dist(r, j));
				if (d > (K - 1) / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	print(ans);
	/*while (true) {
		int x, y; cin >> x >> y;
		pe(depth[x]); print(depth[y]);
		print(lca(x, y));
	}*/
}


Measured memory_bytes: 768
using System;
using System.Text;
using System.Linq;
 
class AtCoder
{
  	static void Main(){
      	int seki =0;
    	string[] tmp = Console.ReadLine().Split();
      	int m = int.Parse(tmp[0]);
      	int d = int.Parse(tmp[1]);
      	for(int cnt1=1;cnt1<=m;cnt1++){
          for(int cnt2=1;cnt2<=d;cnt2++){
            if(2<=(cnt2)%10 && 2<=(cnt2/10) &&  (((cnt2%10)*(cnt2/10))==cnt1) ){
              seki+=1;
            }

          }
        }
      Console.Write(seki.ToString());
    }
  
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  cout << ((v-w)*t-abs(a-b)>=0 ? "YES" : "NO") << newl;
  return 0;
}

Measured memory_bytes: 3640
S = input()

max_len = 0
cnt = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(S)):
    if S[i] in acgt:
        cnt += 1
        if max_len < cnt:
            max_len = cnt
    else:
        cnt = 0

print(max_len)



Measured memory_bytes: 3060
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }

int main() {
	FIO;
	string s;cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< vector<cat> > W(N, vector<cat>(N, 0));
	int seq[11] = {1, 2};
	for(int i = 2; i <= 10; i++) seq[i] = seq[i-1]+seq[i-2]+1;
	cat prod = 1;
	int n = N-1;
	while(n > 0) {
		for(int i = 0; i < n; i++) W[i][n] = W[n][i] = prod * seq[i];
		prod *= seq[n];
		n--;
	}
	if(N == 10) {
		W[1][2] = W[2][1] = 6;
		int P[10];
		for(int i = 0; i < 10; i++) P[i] = i;
		vector<cat> sum_c, sum_l;
		while(true) {
			if(P[0] < P[9]) {
				cat s = 0;
				int l = 0;
				for(int i = 0; i < 9; i++) {
					if(P[i]+P[i+1] == 1) l++;
					else s += W[P[i]][P[i+1]];
				}
				if(l == 0) sum_c.push_back(s);
				else sum_l.push_back(s);
			}
			if(!next_permutation(P, P+10)) break;
		}
		sort(begin(sum_c), end(sum_c));
		sort(begin(sum_l), end(sum_l));
		cat x = 1;
		while(true) {
			bool stop = true;
			int a = 0;
			for(int i = 0; i < (int)sum_c.size(); i++) {
				while(a < (int)sum_l.size() && sum_c[i]-x > sum_l[a]) a++;
				if(a == (int)sum_l.size()) break;
				if(sum_c[i]-x == sum_l[a]) {
					stop = false;
					break;
				}
			}
			if(stop) break;
			x++;
		}
		W[0][1] = W[1][0] = x;
	}
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++) cout << W[i][j] << ((j+1 == N) ? "\n" : " ");
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 19684
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: i,j,n,cnt(ichar('a'):ichar('z')),ans
    integer(int64),parameter:: md=1000000007
    character(100000):: s
    
    read*, n
    read*, s
    cnt(:) = 1
    do i=1,n
        cnt(ichar(s(i:i)))=cnt(ichar(s(i:i)))+1
    end do

    ans = 1
    do i=ichar('a'),ichar('z')
        ans=mod(ans*cnt(i),md)
    end do
    print'(i0)', ans-1
end program name

Measured memory_bytes: 700
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for(int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for(int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for(auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long N, long long K) {
    if(K == 1) {
        print(0);
    } else {
        print(N - K);
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = [e//400 for e in A]
from collections import Counter
D = Counter(A)
ans = 0
add = 0
for key,value in D.items():
    if key >= 8:
        add += value
    else:
        if value > 0:
            ans += 1
print(max(ans,1),ans+add)

Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int a=0,b=0,max=0;
  int c,d,e;
  scanf("%d",&a);
  scanf("%d",&b);
  c=a+a-1;
  d=a+b;
  e=b+b-1;
  max=c;
  if(max<e)
        max=e;
  if(max<d)
        max=d;
  if(max<0){
        printf("0");
     	return 0;
  }
  printf("%d",max);
 return 0;
        }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5+5, INF = 0x3f3f3f3f3f3f3f3f;

ll N, arr[MAXN];

ll cari(int b) {
	ll ret = 0;
	for (int i = 0; i < N; i++) ret += abs(arr[i]-b);
	return ret;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++) cin >> arr[i], arr[i] -= (i+1);
	sort(arr, arr+N);
	
	ll ans = INF;
	ans = min(ans, cari(arr[N/2]));
	ans = min(ans, cari(arr[(N+1)/2]));
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        m: usize, d: usize
    };
    let mut day = 0;
    for i in 1..m+1 {
        for j in 10..d+1 {
            let a = j / 10;
            let b = j % 10;
            if a >= 2 && b >= 2 && a * b == i {
                day += 1;
            }
        }
    }
    println!("{}", day);
}


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

int main() {
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int a = 0; a<10; a++) {
			for (int b = 0; b<10; b++) {
				for (int c = 0; c<10; c++) {
					for (int d = 0; d<10; d++) {
						if (a + b + c + d == n)ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
use std::io;
use std::str::FromStr;
fn main() {
	let stdin = io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    s.pop();
    let r = u32::from_str(&s).expect("e");
    if r < 1200 {
    	println!("ABC");
    } else if r < 2800 {
    	println!("ARC");
    } else {
    	println!("AGC");
    }
}


Measured memory_bytes: 4352
// while( !(succeed == try()) );

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 


// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{    
    string str;
    cin>>str;

    int n = str.size();

    int mx=0;
    int t = 0;
    loop(i,0,n)
    {
        if(str[i]=='R') t++;
        else t=0;

        mx = max(mx, t);
    }

    cout<<mx<<endl;
}

int32_t main(){

    ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //INP();
    int t=1;
    //cin>>t;
    
    while(t--) alpha();

    return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int M, N; cin >> M >> N;
	int MM = 0;
	rep(i, 0, M) {
		int cnt = 0;
		rep(j, 0, N) {
			int a; cin >> a; if (a)cnt++;
		}
		MM = max(MM, cnt);
	}
	cout << MM << endl;
	return 0;
}

Measured memory_bytes: 3068
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var X = int.Parse(Console.ReadLine());
            var current = 0;
            var t = 0;
            while (current < X)
            {
                current += ++t;
            }

            Console.WriteLine(t);
        }
    }
}


Measured memory_bytes: 27516
#include <iostream>
  
inline bool isRightTriangle(const u_int a, const u_int b, const u_int c){
    return (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b);
}
  
int main(){
    u_int n;
    std::cin >> n;
     
    for (u_int i = 0; i < n; ++i){
        u_int a, b, c;
        std::cin >> a >> b >> c;
        std::cout << (isRightTriangle(a, b, c) ? "YES" : "NO") << std::endl;
    }
  
    return 0;
}

Measured memory_bytes: 3068
package main

import(
	"fmt"
)

func main() {
	var n int
	var x int
	var y int
	var min int
	var max int

	fmt.Scan(&n)
	fmt.Scan(&x)
	fmt.Scan(&y)
	
	if x > y {
		max = y
	} else {
		max = x
	}

	if n - (x+y) > 0 {
		min = 0
	} else {
		min = (x+y) - n
	}

	fmt.Println(max, min)
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
    int n;
    double answer;
  

    scanf("%d",&n);
      double a[n];
    for(int i=0;i<n;i++){
        scanf("%lf",&a[n]);
        answer=answer+(1.0/a[n]);
    }

    printf("%lf",1/answer);
    


    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
ll n;
cin>>n;
if(n==1){
    cout<<0<<endl;
}else{
    ll ans=n*(n-1)/2;
    cout<<ans<<endl;
}

    return 0;
}


Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))
n = int(input())
a = inpl()
maximum = max(a)
diff = maximum/2
a.remove(maximum)
min_num = [abs(i - diff) for i in a]
min_num = a[min_num.index(min(min_num))]
print(maximum, min_num)

Measured memory_bytes: 14428
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}

int pw(int a, int b) {
    if (b == 0) return 1;
    if (b & 1) return mult(a, pw(a, b - 1));
    int res = pw(a, b / 2);
    return mult(res, res);
}

int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}

int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}

const int maxN = 1005;

int fact[maxN], invfact[maxN], inv[maxN];

void init() {
    inv[1] = invfact[1] = invfact[0] = fact[0] = fact[1] = 1;
    for (int i = 2; i < maxN; i++) {
        fact[i] = mult(fact[i - 1], i);
        inv[i] = mult(inv[mod % i], mod - mod / i);
        invfact[i] = mult(invfact[i - 1], inv[i]);
    }
}
int a[maxN];
const int maxK = 22;
int dp[maxK][maxN];
int cnk(int a, int b) {
    if (a < b || b < 0) return 0;
    return mult(fact[a], mult(invfact[a - b], invfact[b]));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    init();
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0; i + 1 <= k; i++) {
        for (int tot = 0; tot <= n; tot++) {
            for (int take = 0; take + tot <= n && take <= a[i + 1]; take++) {
                dp[i + 1][take + tot] = sum(dp[i + 1][take + tot], mult(dp[i][tot], mult(cnk(n - take, a[i + 1] - take), cnk(n - tot, take))));
            }
        }
    }
    cout << dp[k][n];
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, a;
map<int,int> mp;
int main(){
	cin >> n;
	rep(i,n){
		cin >> a;
		if(mp[a]++) return puts("NO")*0;
	}
	puts("YES");
}

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

int main() {
string S="Rainy";
cin >> S;
if(S=="Sunny"){
  cout << "Cloudy";
}else if(S=="Cloudy"){
  cout << "Rainy";
}else if(S=="Rainy"){
  cout << "Sunny";
}
	return 0;
}



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

int main(){
    string s;
    cin >> s;
    int a = 0, b = 0;
    string t = "01";
    for(int i = 0; i < s.length(); i++){
        if(t[i%2] != s[i])  a++;
        if(t[(i+1)%2] != s[i])  b++;
    }
    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX =200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
     maxv = max(maxv, R[i] - minv);
     minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


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

int main() {
  int x, a;
  cin >> x >> a;
  int ans = 0;
  if(x < a) ans = 0;
  else ans = 10;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
  cin>>n;
	set<string> s;
	for(int i=0;i<n;i++)
	{
		string a;
		cin>>a;
		s.insert(a);
	}
	cout<<s.size();
	}

Measured memory_bytes: 19224
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int K,X;
int main() {
    cin >> K >> X;
    for(int i=max(-100*10000,X-(K-1));i<=min(100*10000,X+(K-1));++i) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

	int N, a, b;
	cin >> N >> a >> b;
	cout << min(a, b) << ' ' << max(a+b-N, 0);
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

bool cmp(pi p1,pi p2)
{
    return (p1.second>p2.second);
}

int32_t main()
{
     fast;
    int n,k;
    cin>>n>>k;
    vpi v;
    for(int i=0;i<n;i++)
    {
        int t,d;
        cin>>t>>d;
        v.pb({t,d});
    }
    sort(v.begin(),v.end(),cmp);
    int type=0,cnt=0,res=0,ans=0;
    stack< int > st;
    map< int,int > mp;
    for(int i=0;i<n;i++)
    {
        if(cnt<k)
        {
            if(mp.count(v[i].first)==0)
            {
                type++;
                mp[v[i].first]++;
            }
            else
             st.push(v[i].second);
            res+=v[i].second;
            ans=max(ans,type*type+res);
            cnt++;
        }
        else
        {
            if(st.empty())
             break;
             if(mp.count(v[i].first)!=0)
              continue;
             mp[v[i].first]++;
             type++;
             res+=v[i].second;
             res-=st.top();
             st.pop();
             ans=max(ans,type*type+res);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

int tim(int b)
{
    return b * b * b * b * b;
}

// index が条件を満たすかどうか
bool isOK(int index, int key)
{
    if (tim(index) >= key)
        return true;
    else
        return false;
}

int solve(int key)
{
    int left = -1000; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 1000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;
        int tmp = tim(mid);
        if (tmp == key)
        {
            return mid;
        }
        if (tmp > key)
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    int a, b;
    b = -1000;
    while (1)
    {
        a = solve(X + tim(b));
        if (tim(a) - tim(b) == X)
        {
            cout << a << " " << b;
            break;
        }
        b++;
    }

    return 0;
}

Measured memory_bytes: 3632
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e1 + 5);

int n, k;
ll v[MAX_N];
ll acc_v[MAX_N];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(v[i]));
  }

  ans = -1;

  for (int f = 0; f <= n; ++f) {
    for (int b = 0; b <= n; ++b) {
      int f_ind = f;
      int b_ind = n + 1 - b;

      if (f_ind >= b_ind) continue;
      if (f + b > k) continue;

      ll whole = 0;
      vector<ll> negative;
      for (int i = 1; i <= f_ind; ++i) {
        whole += v[i];
        if (v[i] < 0) {
          negative.push_back(v[i]);
        }
      }

      for (int i = n; i >= b_ind; --i) {
        whole += v[i];
        if (v[i] < 0) {
          negative.push_back(v[i]);
        }
      }

      int remain = k - (f + b);

      sort(negative.begin(), negative.end());

      int size = min(remain, (int)(negative.size()));

      // printf("%d %d: %lld :", f_ind, b_ind, whole);
      //
      // for (auto e: negative) {
      //   printf("%lld ", e);
      // }
      // printf("\n");

      for (int i = 0; i < size; ++i) {
        whole -= negative[i];
      }

      ans = max(ans, whole);

    }
  }

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

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
    	String[] asaikoro = br.readLine().split(" ");
    	String[] bsaikoro = br.readLine().split(" ");
    	
    	int[] as = new int[6];
    	int[] bs = new int[6];
    	int a =  0;
    	
    	for (int i = 0; i < 6; i++)
    	{
    		as[i] = Integer.parseInt(asaikoro[i]);
    		bs[i] = Integer.parseInt(bsaikoro[i]);
    	}
    	
    	if ((as[0] == bs[2] || as[0] == bs[3]) && (as[5] == bs[2] || as[5] == bs[3]))
    	{
    		a = bs[1];
			bs[1] = bs[2];
			bs[2] = bs[4];
			bs[4] = bs[3];
			bs[3] = a;
    	}
    	
    	for (int i = 0; i < 3; i++) //????????¢????????¢????????£???????????????
		{
			if (as[0] ==bs[0] && as[5] ==bs[5])
				break;
			a = bs[0];
			bs[0] = bs[1];
			bs[1] = bs[5];
			bs[5] = bs[4];
			bs[4] = a;
		}
    	
    	for (int i = 0; i < 3; i++) //?¨??????¢????¨???¢????????£???????????????
		{
			if (as[1] ==bs[1] && as[4] ==bs[4])
				break;
			a = bs[1];
			bs[1] = bs[2];
			bs[2] = bs[4];
			bs[4] = bs[3];
			bs[3] = a;
		}
    	
    	if (as[0] == bs[0] && as[1] == bs[1] && as[2] == bs[2] && as[3] == bs[3] && as[4] == bs[4] && as[5] == bs[5])
    		System.out.println("Yes");
    	else
    		System.out.println("No");
	}
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
  string s;
  cin >> s;
  if(s=="AAA"||s=="BBB"){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            
            var N = cin.nextInt();
            var v = new int[N];
            for (int i = 0; i < N; i++)
            {
                v[i] = cin.nextInt();
            }

            Array.Sort(v);

            double mix = v[0];
            for (int i = 1; i < N; i++)
            {
                var item = v[i];
                mix = (mix + item) / 2.0;
            }           

            Console.WriteLine(mix);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 11220
a,b = map(int, input().split())

count = float('inf')
for i in range(int(a//0.08 -1), int((b+1)// 0.1 +1)):
    if i *0.08 >= a and i * 0.08 < (a+1) and i* 0.1 >= b and i* 0.1 < (b+1):
        if i <= count:
            count = i

if count == float('inf'):
    print(-1)
else:
    print(count)

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)
int fd(int n)
{
    n/=100;
    return n;
}

int ld(int n)
{
    n-=100*fd(n);
    return n;
}
int n,a,b;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    a=fd(n);
    b=ld(n);
    if(a<=12 and a>=1 and b<=12 and b>=1)
        cout<<"AMBIGUOUS";
    else if(a>12 and b<=12 and b>=1)
        cout<<"YYMM";
    else if(a>=1 and a<=12 and b>12)
        cout<<"MMYY";
    else if(a>=1 and a<=12)
        cout<<"MMYY";
    else if(b>=1 and b<=12)
        cout<<"YYMM";
    else
        cout<<"NA";
}


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  
  sort(L.begin(),L.end());
  
  int count=0;
  
  for(int i=N-1;i>1;i--){
    for(int j=0;j<i-1;j++){
      for(int k=j+1;k<i;k++){
        if(L[i]<L[j]+L[k]){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
}
  
  
    
  

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std;
#define MAX_N (50010)
#define MAX_M (22)
#define INF (MAX_N << 1)

int c[MAX_M];

int dp[MAX_N];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for ( int i = 0; i < m; i++ ) scanf("%d", &c[i]);
    for ( int i = 0; i <= n; i++ ) dp[i] = INF;

    dp[0] = 0;

    for ( int i = 0; i < m; i++ ) {
	int x = c[i];
	for ( int j = 0; j <= n; j++ ) {
	    if ( j - x >= 0 && dp[j - x] != INF ) {
		dp[j] = min( dp[j], dp[j - x] + 1 );
	    }
	}
    }

    printf("%d\n", dp[n]);

    return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>
int main()
{
	char arr[200010] = { 0 };
	int sum = 0;
	int len;
	int i;
	scanf("%s", &arr);

	len = strlen(arr);
	for (i = 0; i < len; i++)
	{
		sum += arr[i] - '0';
	}
	if (sum % 9 == 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
inline int read()
{
    int data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    return f * data;
}
int h[maxn], ans[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int n = read(), k = read();
    for (int i = 1; i <= n; ++i)
        h[i] = read();
    for (int i = 2; i <= n; ++i)
    {
        ans[i] = INF;
        for (int j = 1; j <= k; ++j)
        {
            if (i > j)
                ans[i] = min(ans[i - j] + abs(h[i] - h[i - j]), ans[i]);
        }
    }
    printf("%d", ans[n]);
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}


Measured memory_bytes: 4516
a = input()
x = input().split()
y = 0
d = 0
a = int(a)

x = [int(s) for s in x]

for i in range(0,a):
  y = x[i] + y

m = y / a

for i in range(0,a):
  d = (round(m) - x[i])**2 + d
  
print(d)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{

	static void Print(int[][] x) {
		for(int i=0;i<3;i++) {
			for(int j=0;j<10;j++) {
				System.out.print(" "+x[i][j]);
			}
			System.out.println("");
		}
	}


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1[][] = new int[3][10];
		int a2[][] = new int[3][10];
		int a3[][] = new int[3][10];
		int a4[][] = new int[3][10];
		int n = sc.nextInt();

		for(int i=0;i<n;i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int count = sc.nextInt();

			if(b==1)a1[f-1][r-1]+=count;
			else if(b==2)a2[f-1][r-1]+=count;
			else if(b==3)a3[f-1][r-1]+=count;
			else if(b==4)a4[f-1][r-1]+=count;
			else System.out.println("E");
		}

		Print(a1);
		System.out.println("####################");
		Print(a2);
		System.out.println("####################");
		Print(a3);
		System.out.println("####################");
		Print(a4);

		sc.close();
	}
}



Measured memory_bytes: 29812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int n; cin >> n && n; )
	{
		int target, ans = 0;
		vint v(n);
		
		rep(i, n) cin >> v[i];
		
		cin >> target;
		
		for(int lb = 0, ub = n - 1; lb <= ub; ans++)
		{
			int mid = (ub + lb) / 2;
			if(v[mid] <  target) lb = mid + 1;
			if(v[mid] >  target) ub = mid - 1;
			if(v[mid] == target)
			{
				ans++;
				break;
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  vector<int> a(n);
  int mod = 1000000007;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
    sum = sum % mod;
  }

  ll ans = 0;

  // ### a[i] * a[j] の和
  //
  // i が固定 かつ 0-indexed の場合
  //   a[i] * a[i+1] + a[i] * a[i+2] + ... + a[i] * a[n-1]
  //   = a[i] * (a[i+1] + a[i+2] + ... + a[n-1])
  //
  // i について全探索する
  //
  for (int i = 0; i < n; i++) {
    // ### i=0 の場合
    //
    // sum = a[0] + a[1] + ... + a[n-1] である
    // sum - a[0] より sum は以下となる
    //
    //   sum = a[1] + ... + a[n-1]
    //
    // ans = ans + a[0] * sum から ans は以下となる
    //
    //   ans = 0 + a[0] * (a[1] + ... + a[n-1])
    //
    // ans = ans % mod より、i=0 の時の剰余の値を算出する
    // 剰余のため ans < mod となる
    //
    // ### i=1 の場合
    //
    // sum = a[1] + a[2] + ... + a[n-1] である
    // sum - a[1] より sum は以下となる
    //
    //   sum = a[2] + ... + a[n-1]
    //
    // ans = ans + a[1] * sum から ans は以下となる
    //
    //   ans = (i=0の時の剰余) + a[1] * (a[2] + ... + a[n-1])
    //
    // ans = ans % mod より、i=1 の時の剰余の値を算出する
    // 剰余のため ans < mod となる
    //
    // ### 具体的な入力例
    //
    // n = 3
    // a = [100, 100, 100]
    // mod = 107
    //
    // sum = 100 + 100 + 100 = 300
    //
    // i=0
    //   sum = 300 - 100 = 200
    //   ans = 0 + (100 * 200) = 20000
    //   ans = 20000 % 107 = 98
    // i=1
    //   sum = 200 - 100 = 100
    //   ans = 98 + (100 * 100) = 10098
    //   ans = 10098 % 107 = 40
    // i=2
    //   sum = 100 - 100 = 0
    //   ans = 40 + (100 * 0) = 40
    //   ans = 40 % 107 = 40
    //
    // Ai x Aj の総和
    //   (100 * 200) + (100 * 100) + (100 * 0) = 30000
    // mod(107)
    //   30000 % 107 = 40
    //
    // 総和に対して剰余を算出することと、
    // 総和の一部分に対して剰余を算出し、剰余をまた別の和に加え、その和から剰余を算出することは、
    // 同じ値を導出する。
    //
    //
    // ### 入力受取時に sum の剰余を予め算出する場合
    //
    // n = 3
    // a = [100, 100, 100]
    // mod = 107
    //
    // sum = 100 + 100 + 100 = 300
    // sum = sum % mod = 300 % 107 = 86
    //
    // i=0
    //   sum = 86 - 100 = -14
    //   sum = -14 + 107 = 93 (= 200 mod(107))
    //
    //   ans = 0 + (100 * 93) = 9300
    //   ans = 9300 % 107 = 98
    // i=1
    //   sum = 93 - 100 = -7
    //   sum = -7 + 107 = 100
    //
    //   ans = 98 + (100 * 100) = 10098
    //   ans = 10098 % 107 = 40
    // i=2
    //   sum = 100 - 100 = 0
    //
    //   ans = 40 + (100 * 0) = 40
    //   ans = 40 % 107 = 40
    //
    // 予め sum の mod(107) を算出することで、桁数の増加を抑える
    // sum がマイナスとなった場合、+107 することで、mod(107) の数に影響がないようにしつつプラスの数とする
    //
    // 例
    //   200 / 107 = 1
    //   200 % 107 = 93
    //   つまり 107 * 1 + 98
    //
    //   (200+107) / 107 = 2
    //   (200+107) % 107 = 93
    //   つまり 107 * 2 + 93
    //
    sum = sum - a.at(i);
    if (sum < 0) { sum += mod; }

    ans = ans + a.at(i) * sum;
    ans = ans % mod;
  }

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


Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
        }
    }
    // 横方向の和をとる
    vector<vector<int>> yoko(h, vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        int st = 0;
        for (int j = 0; j < w; j++)
        {
            if (grid[i][j] == '#')
            {
                for (int k = st; k < j; k++)
                {
                    yoko[i][k] = j - st;
                }
                yoko[i][j] = 0;
                st = j + 1;
            }
        }
        for (int k = st; k < w; k++)
        {
            yoko[i][k] = w - st;
        }
    }
    // 縦方向の和をとる
    vector<vector<int>> tate(h, vector<int>(w));
    for (int j = 0; j < w; j++)
    {
        int st = 0;
        for (int i = 0; i < h; i++)
        {
            if (grid[i][j] == '#')
            {
                for (int k = st; k < i; k++)
                {
                    tate[k][j] = i - st;
                }
                tate[i][j] = 0;
                st = i + 1;
            }
        }
        for (int k = st; k < h; k++)
        {
            tate[k][j] = h - st;
        }
    }
    // for (auto y : yoko)
    // {
    //     print(y);
    // }
    // cout << "===" << endl;
    // for (auto t : tate)
    // {
    //     print(t);
    // }
    int maxi = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            maxi = max(maxi, tate[i][j] + yoko[i][j]);
        }
    }
    if (maxi != 0)
    {
        cout << maxi - 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 38620
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
int main(){
    scanf("%ld", &n);
    if(n % 2 == 1){
        printf("0\n");
    }else{
        long ans = 0;
        ans += n/10;
        n /= 10;
        while(n > 0){
            n /= 5;
            ans += n;
        }
        printf("%ld\n", ans);
    }

}


Measured memory_bytes: 256