akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N , A;
  	double B;
  
  	cin >> N >> A;
  
    B = N % 500;
//	cout << B << endl; 
	if (A >= B){
    	cout << "Yes" << endl;
    }
  	else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
extern crate proconio;
use proconio::input;

fn main() {
    input!{
        n: usize,
        p: [i32; n],
        q: [i32; n],
    };

    let mut fact: Vec<i32> = Vec::new();
    let mut num: i32 = 1;

    for i in 0..n {
        fact.push(num);
        num *= (i+1) as i32;
    }

    let mut ans_p = 0;
    let mut ans_q = 0;
    for i in 0..n-1 {
        let mut tp = 0;
        let mut tq = 0;
        for j in i..n {
            if p[i] > p[j] {
                tp += 1;
            }
        }
        for j in i..n {
            if q[i] > q[j] {
                tq += 1;
            }
        }
        ans_p += tp*fact[n-i-1];
        ans_q += tq*fact[n-i-1];
    }
    println!("{}", i32::abs(ans_p-ans_q));
  
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}

vector<int> solve(int Z){
	vector<int> t(D);
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			if(s[i][t[i]] + last[t[i]] * last[t[i]]/Z * c[t[i]] < s[i][j] + last[j] * last[j]/Z * c[j]) {
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
	}
	
	return t;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> t;
	
	
	cin>>D;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
	}
	
	int p = 0;
	
	for(int i = 1; i < 10; i++){
		vector<int> nt;
		
		nt = solve(i);
		int np = point(nt);
		
		if(p < np) {
			t = nt;
			p = np;
		}
	}
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3768
a=[]
for i in range(5):
  a.append(int(input()))

ans=0
s=a[0]%10
for i in range(1,5):
  if s>a[i]%10 and a[i]%10!=0:
    s=a[i]%10

for i in range(5):
  if a[i]%10 == 0:
    ans+=a[i]
  else:
    ans+= a[i]+(10-a[i]%10)
if s==0:
  print(ans)
else:
	print(ans-10+s)

Measured memory_bytes: 3064
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,i,b=-1,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<n;i++){
    a=N[hout()];
    if(a==b){
      printf("NO\n");
      return 0;
    }
    b=a;
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,e,sum,mn,mx,sum1;
    scanf("%lld",&n);
    long long a[n+3];
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    e=0;
    sum=0;
    sum1=1000;
    mn=a[1];
    mx=a[1];
    for(i=1;i<n;i++){
        if(e==0&&a[i]<a[i+1]){
           mx=a[i+1];
           e=1;
        }
        else if(e==1&&a[i+1]<a[i]){
           sum=(mx-mn)*(sum1/mn);
           sum1+=sum;
           sum=0;
           mn=a[i+1];
           mx=0;
           e=0;
        }
        else if(e==0){
            mn=a[i+1];
        }
        else if(e==1){
            mx=a[i+1];
        }
    }
    if(e==1){
       sum=(mx-mn)*(sum1/mn);
       sum1+=sum;
    }
    printf("%lld\n",sum1);
    return 0;
}


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

int main() {
  int a,p; cin >> a >> p;
  int ans = (a*3 + p) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product
h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0

for maskR in product([0,1], repeat=h):
    for maskC in product([0,1], repeat=w):
        b = 0
        for i in range(h):
            for j in range(w):
                if maskR[i]==1 and maskC[j]==1 and c[i][j]=="#":
                    b += 1
        if b == k:
            ans += 1
print(ans)

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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
int dp[3005][3005];
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int main() {
    input;
    int n, s;
    cin >> n >> s;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    // dp[i][j] = sum of left endpoints of subsequences with sum j that end at i 
    for(int i = 0; i < n; i++) {
        dp[i + 1][a[i]] = i + 1;

        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
            if(j + a[i] <= s) {            
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
        
    }
    for(int i = 1; i <= n; i++) {
        debug(dp[i][s]);
        dp[i][s] += dp[i - 1][s];
        dp[i][s] %= mod;
    }


    cout << dp[n][s];
}


Measured memory_bytes: 35456
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define itt vector<pll>::iterator
#define inf 2333333333333333333LL
#define mod 1000000007LL

vector<pll> v[233];

ll fib[233],t,n,m,ans;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	t=rd();fib[0]=fib[1]=1;
	for (ll i=2;i<=88;i++) fib[i]=fib[i-1]+fib[i-2];
	v[1].push_back(make_pair(1,2));
	v[1].push_back(make_pair(1,3));
	v[1].push_back(make_pair(1,4));
	for (ll i=1;i<85;i++)
	{
		for (itt it=v[i].begin();it!=v[i].end();it++)
		{
			ll x=(*it).first,y=(*it).second;
			x+=y;
			while (x<=fib[i+3]+fib[i])
			{
				v[i+1].push_back(make_pair(y,x));
				x+=y;
			}
		}
	}
	while (t--)
	{
		n=rd();m=rd();
		if (n>m) swap(n,m);
		ans=1;
		while (fib[ans+1]<=n&&fib[ans+2]<=m) ans++;
		printf("%lld ",ans);
		if (ans==1) { printf("%lld\n",n*m%mod);continue; }
		ll res=0;
		for (itt it=v[ans-1].begin();it!=v[ans-1].end();it++)
		{
			ll x=(*it).first,y=(*it).second;
			if (y<=n) (res+=(m-x)/y)%=mod;
			if (y<=m) (res+=(n-x)/y)%=mod;
		}
		printf("%lld\n",res);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

 ll ans = 0;
 ll N;
 cin >> N;
 ll l, r;
 for(int i = 0; i < N; i++){
   cin >> l >> r;
   ans += (r - l + 1); 
 } 

 cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//long long res(long long int);
long long int res(long long int n)
{
    if(n == 0) return 0;
    else return 2 * res(n / 2) + 1;
}

int main() {
	// your code goes here
    long long int n;
    cin >> n;
    cout << res(n);
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
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;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

fn main() {
    let s: String = read!(String);
    let c = s.chars().collect::<Vec<_>>();

    let mut ans = 0;
    let mut tmp = 0;
    for C in c {
        if C == 'A' || C == 'C' || C == 'G' || C == 'T' {
            tmp += 1;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
  string s;
  while(cin >> s, s != "0"){
    int l = s.length();
    int t[l+1][11], u = 0, ans = 0;
    for(int i = 0; i <= l; ++i) fill(t[i],t[i]+11,0);
    t[l][0] = 1;
    for(int i = l-1; i >= 0; --i){
      for(int j = 0; j < 11; ++j) t[i][j] = t[i+1][j];
      int k = s[i] - '0';
      if((l-i)%2 == 0) k = (11-k)%11;
      u += k;
      u %= 11;

      if(s[i] != '0') ans += t[i][u];
      ++t[i][u];
    }
    cout << ans << endl;
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] arr = str.split(" ");
			
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);
			int c = Integer.parseInt(arr[2]);
			
			if (a < b && b < c) System.out.println("Yes");
			else System.out.println("No");
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}

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

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, x, arr[100], pos = 0;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int i = 0; i < n; i++)
    {
        pos += arr[i];
        if (pos > x)
            return cout << i + 1 << '\n', 0;
    }
    cout << n + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final Long H = Long.parseLong(sc.next());
        final Long W = Long.parseLong(sc.next());
        long ans;
        if (H == 1 || W == 1) {
            ans = 1;
        } else if ((H * W) % 2 == 0) {
            ans = (H * W) / 2;
        } else {
            ans = ((H * W) / 2) + 1;
        }
        out.println(ans);

        out.flush();
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
/*doubling*/
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i], a[i]--;
  vector<vector<int>> to(62, vector<int>(n, 0));
  for (int i = 0; i < n; i++) to[0][i] = a[i];

  for (int i = 0; i < 61; i++) {
    for (int j = 0; j < n; j++) to[i + 1][j] = to[i][to[i][j]];
  }

  int cur = 0;

  for (int i = 61; i >= 0; i--) {
    ll len = (1LL << i);
    if (len <= k) {
      cur = to[i][cur];
      k -= len;
    } 
  }
  cout << cur + 1 << endl;
  return 0;
} 

Measured memory_bytes: 53392
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
ll f (ll b);
bool check(ll x1,ll tmp);
ll n,s;
int main(){
	scanf("%lld%lld",&n,&s);
	ll up=(ll)sqrt(n)+1;
	if(n<=s){
		if(n<s)
			printf("-1");
		else
			printf("%lld",n+1);
		return 0;
	}
	ll tag=0;
	for(ll i=2;i<=up;i++)
		if(f(i)==s){
			printf("%lld",i);
			return 0;
		}
	if(!tag){
		ll pp=n-s,upper=pp/up+1;
		for(ll x1=upper;x1>=1;x1--){
			/*if(x1==146){
				printf("5");
				check(x1,pp);
			}*/
				
			if((n-s)%x1==0 && check(x1,pp)==true){
				printf("%lld",pp/x1+1);
				return 0;
			}
		}
			
	}
	printf("-1");
	return 0;
}
bool check(ll x1,ll pp){
	ll b=pp/x1+1,x2=s-x1;
	if(x1<b && x2<b && x2>=0)
		return true;
	return false;
}
ll f(ll b){
	ll ret=0,tmp=n;
	while(tmp)
		ret+=tmp%b,tmp/=b;
	return ret;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n;
    cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i+=2){
        int num = 1;
        for(int j = 1; j <= i/2; j++){
            if(i%j == 0) num++;
        }
        if(num == 8) ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

//i*2^X>=K
//2^X>=
int main() {
	int N, M, t = 0, ans=0;
	cin >> N >> M;
	for (size_t i = 0; i < M; i++)
	{

		cin >> t;
		ans += t;
	}
	if (ans <= N)cout << N - ans;
	else cout << -1;
}

Measured memory_bytes: 3632
S = gets.chomp

pat = {
  'mer' => 'dreamer',
  'ser' => 'eraser',
  'm' => 'dream',
  'e' => 'erase',
}

ans = "YES"
while S != ""
  s = pat[S[-1] == 'r' ? S[-3, 3] : S[-1]]
  if s && S[-s.size, s.size] == s
    S.slice!(-s.size, s.size)
  else
    ans = "NO"
    break
  end
end
puts ans

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,ans=100000000,t;
	string a;
	cin>>a;
	for(i=2;i<a.size();i++){
		t=100*(a[i-2]-'0')+10*(a[i-1]-'0')+(a[i]-'0');
		ans=min(ans,abs(753-t));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    Ds = [list(map(int, input().split())) for _ in range(N)]
    ans = "No"
    count = 0
    maxcou = 0
    for i,j in Ds:
        if i == j:
            count += 1
            if count> maxcou:
                maxcou = count
        else:
            count = 0

    return "Yes" if maxcou>2 else "No"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9184
import sys
import numpy as np
from math import factorial, sqrt
from itertools import permutations
read = sys.stdin.read
readline = sys.stdin.readline

N = int(readline())
xy = np.array(read().split(), np.int64).reshape(N, 2)
distance = [[0.0] * N for _ in range(N)]

for i in range(N - 1):
    for j in range(i + 1, N):
        tmp = sqrt(np.sum((xy[i] - xy[j]) ** 2))
        distance[j][i] = tmp
        distance[i][j] = tmp

answer = 0
for i in permutations(range(N)):
    for j in range(N - 1):
        answer += distance[i[j]][i[j + 1]]

print(answer / factorial(N))

Measured memory_bytes: 21528
#include <iostream>
#include <cstdlib>

void gcd(int a, int b); 

int main(void) {
    int a;
    int b;
    std::cin >> a >> b;
    gcd(a, b);
    return EXIT_SUCCESS;
}

void gcd(int a, int b) {
    if (b == 0) {
        std::cout << a << std::endl;
        return;
    } else {
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;

int main(int argc, char* argv[]){

	int N;
	long long K;
	scanf("%d %lld", &N, &K);

	int A[N];
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	int now=1;
	int loop, loop_start, loop_point;
	int memory[N] = {0};
	memory[0] = 0;

	for(int i=1; i<N+5; i++){
		now = A[now-1];
//		printf("%d\n", now);
		if(memory[now-1] != 0){
			loop = i - memory[now-1];
			loop_start = memory[now-1];
			loop_point = now;
			break;
		}else{
			memory[now-1] = i;
		}
	}
//	printf("%d %d %d\n", loop, loop_start, loop_point);
	if(K > loop_start){
		long long mod_loop = (K - (long long)loop_start) % (long long) loop;
		now = loop_point;
		for(int i=0; i<mod_loop; i++){
			now = A[now-1];
		}
	}else{
		now = 1;
		for(int i=0; i<K; i++){
			now = A[now-1];
		}
	}
	printf("%d", now);


	return 0;
}







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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll d[200010];
ll MOD = 1e9+7;

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

	int n;cin>>n;
	vector<int> p(n), q(n);

	for(int i=0; i<n;i++){
		cin>>p[i];
	}
	for(int i=0; i<n;i++){
			cin>>q[i];
		}

	vector<int> a(n);

	for(int i=1; i<=n; i++){
		a[i-1] =i;
	}
	map<vector<int>,int> mp;
	do {

		mp[a] = mp.size();

	} while (next_permutation(a.begin(),a.end()));

	cout<<abs(mp[p]-mp[q])<<endl;

}




Measured memory_bytes: 5248
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n,sum;cin>>n>>sum,n|sum;){
		vi num(10);
		rep(i,10)
			num[i]=i;
		
		int counter=0;
		do{
			if(accumulate(num.begin(),num.begin()+n,0)==sum)
				counter++;
			reverse(n+allof(num));
		}while(next_permutation(allof(num)));
		
		int fact=1;
		rep(i,n)
			fact*=i+1;
		
		cout<<counter/fact<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define INF 210000000
#define int long long

signed main() {
		string s;
		cin >> s;
		int ans = 0;
		for(int i=1;i<s.size();i++){
				if(s[i] != s[i-1]) ans++;
		}
		cout << ans  << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n;cin>>n;
  vll a(n+2,0);
  ll sum=0;
  rep(i,0,n){
    cin>>a[i+1];
    
    sum+=abs(a[i+1]-a[i]);
    
  }
  
  sum+=abs(a[n+1]-a[n]);
  rep(i,1,n+1){
    cout<<sum-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
  }
	
}








Measured memory_bytes: 4004
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll k;
    cin >> k;
    print((k/2) * (k - k/2));
   
  return 0;
}

Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  ll N, K, Q;
  cin >> N >> K >> Q;

  vector<ll> win(N, 0);
  rep(i, Q) {
    ll A;
    cin >> A;
    win[A - 1]++;
  }

  rep(i, N) {
    out(K - Q + win[i] > 0 ? "Yes" : "No");
  }
}


Measured memory_bytes: 1408
import java.util.Scanner;

class Main {

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        long sum = 1;
        
        for (int i = 0; i < n - 1; i++) {
            sum = sum * (k - 1);
        }       
        sum = sum * k;
        System.out.println(sum);
    }
}


Measured memory_bytes: 21716
#include <cstdio>
#include <vector>

const int N = 100000;

int n;
std::vector<int> tree[N];

int dfs(int p, int u)
{
    int result = 0, zeros = 0;
    for (int v : tree[u]) {
        if (v == p) {
            continue;
        }
        int r = dfs(u, v);
        result += r;
        zeros += !r;
    }
    return result + std::max(zeros - 1, 0);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0, a, b; i < n - 1; ++ i) {
        scanf("%d%d", &a, &b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int r = 0;
    while (r < n && tree[r].size() < 3) {
        r ++;
    }
    if (r == n) {
        puts("1");
    } else {
        printf("%d\n", dfs(-1, r));
    }
}


Measured memory_bytes: 9088
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
void sol(void)
{
cin>>n;
ll total=power(10,n);
ll wz=power(9,n);
ll wn=power(9,n);
ll common=power(8,n);
total=total-wz-wn+common;
total+=mod;
total+=mod;
total%=mod;
cout<<total;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[200005],ans=1e18;
int main() {
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i],a[i]+=a[i-1];
	for (int k=2;k<=n-2;++k) {
		int l1=1,r1=k-1;
		while (l1<r1) {
			int m1=l1+r1>>1;
			if (a[m1]>=a[k]-a[m1]) r1=m1;
			else l1=m1+1;
		}
		if (max(a[l1],a[k]-a[l1])>max(a[l1-1],a[k]-a[l1-1])) --l1;
		int l2=k+1,r2=n-1;
		while (l2<r2) {
			int m2=l2+r2>>1;
			if (a[m2]-a[k]>=a[n]-a[m2]) r2=m2;
			else l2=m2+1;
		}
//		cerr << "l2 = " << l2 << endl;
		if (max(a[l2]-a[k],a[n]-a[l2])>max(a[l2-1]-a[k],a[n]-a[l2-1])) --l2;
//		if (k==3) printf("l1 = %d   l2 = %d\n",l1,l2);
		ll w=a[l1],x=a[k]-a[l1],y=a[l2]-a[k],z=a[n]-a[l2];
		ans=min(ans,
			max(max(max(max(max(llabs(w-x),llabs(w-y)),llabs(w-z)),llabs(x-y)),llabs(x-z)),llabs(y-z))
		);
	}
	cout<<ans;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    for (int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    ll low, high;
    ll ans;
    if (N%2==1){
        low = A[(N-1)/2];
        high = B[(N-1)/2];
        ans = high - low + 1;
    } else {
        low = A[N/2-1]+A[N/2];
        high = B[N/2-1]+B[N/2];
        ans = high - low + 1;
    }
    cout << ans << "\n";
}

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

int main()
{
	int a = 0, b = 0, c = 0, d = 0;

	cin >> a >> b >> c >> d;

	if(a + b > c + d)
		cout << "Left" << endl;
	else if(a + b < c + d)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況

int n, m; // 変数

int digit_sum(int x) {
    string s = to_string(x);
    int sum = 0;
    rep(i, (int)s.size()) {
        sum += s[i] - '0';
    }
    return sum;
}

int main() {
// input
    cin >> n;
    int s = digit_sum(n);
// solve
// output
    if (n % s == 0) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

#define ll long long

int main(){
    int n,sum,hp=0;
    cin >> n;
    sum = n/500;
    hp = sum*1000;
    n-= sum*500;
    sum = n/5;
    hp += sum*5;
    cout << hp;
}

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

int main(){
	string S;
	long K;
	cin >> S >> K;

	for(int i=0;i<K;i++) {
		if(S[i] != '1'){
			cout << S[i] << endl;
			return 0;
		}
	}
		cout << 1 << endl;
		return 0;

}


Measured memory_bytes: 384
import math
a, b, c, x, y = map(int, input().split())
# print(a, b, c, x, y)

ans = float('inf')
for nc in range(0, max(x, y) * 2 + 1, 2):
    na = x - math.floor(nc / 2)
    if na < 0:
        na = 0
    nb = y - math.floor(nc / 2)
    if nb < 0:
        nb = 0
    total = a * na + b * nb + c * nc
    if total < ans:
        ans = total
    # print(na, nb, nc, total)
print(ans)


Measured memory_bytes: 3060
"use strict";
const gcd = (x,y) => y ? gcd(y, x%y) : x;
const main = input => {
    const n = parseInt(input[0],10), a = input[1].split(' ');
    for(let i=0; i<n; i++) {
        a[i] = parseInt(a[i], 10);
    }
    let l = new Array(n+1), r = new Array(n+1),w = new Array(n);
    l[0] = 0, r[n] = 0;
    
    for(let i=1; i<n+1; i++) {
        l[i] = gcd(l[i-1], a[i-1]);
        r[n-i] = gcd(r[n+1-i],a[n-i]);
    }
    for(let i=0; i<n; i++) {
        w[i] = gcd(l[i], r[i+1]);
    }
    console.log(Math.max.apply(null, w));
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 20808
#include<stdio.h>

int main(void)
{
  int a,b,c;
  int temp;
  
  scanf("%d \n",&a);
  scanf("%d \n",&b);
  scanf("%d \n",&c);
  
  temp = a;
  a = b;
  b = temp;
  
  temp = a;
  a = c;
  c = temp;
  
  printf("%d %d %d \n",a,b,c);
  
  return 0;
}

Measured memory_bytes: 1704
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
x = na()

def dist(l, r):
    mn = min(abs(l), abs(r))
    mx = max(abs(l), abs(r))
    if l < 0 and r < 0:
        return mx
    elif l >= 0 and r >= 0:
        return mx
    else:
        return mn * 2 + mx

ans = inf
for i in range(n - k + 1):
    ans = min(ans, dist(x[i], x[i + k - 1]))

print(ans)

Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
int n,q,m,k,l,ans;
vi a,b;
ll llans;
vll lla,llb;
string s;

int func(ll x){
    int cnt = 0;
    while(x >0 && x%2==0){
        x /= 2;
        cnt++;
    }
    return cnt;
}

int main() {
    cin >> n;
    lla.resize(n);
    rep(i,n) cin >> lla[i];
    sort(ALL(lla));

    llans = 0;
    rep(j,n-1)rep(i,j){
        int last = IDX(lla,lower_bound(ALL(lla),lla[i] + lla[j]));
        // printf("i:%d j:%d Li:%lld Lj:%lld l:%d \n",i,j,lla[i],lla[j],last);
        if(last > j+1) llans += last - j - 1;
    }
    cout << llans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s,t="CODEFESTIVAL2016";
    int ans=0;
    cin>>s;
    for(int i=0;i<16;i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	long double a, b, c, ap, bp, cp;
	cin >> a >> b >> c;
	ap = sqrtl(a);
	bp = sqrtl(b);
	cp = sqrtl(c);
	if (a + b + ap * bp * 2 < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  
  string S; cin >> S;
  
  int64_t count = 0, ans = 0;
  
  for (int i = 0; i < S.size(); i++) {
    
    if (S.at(i) == 'W') {
      ans += i - count;
      count++;
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> d(n);
  for (i64 i = 0; i < n; i++)
    cin >> d[i];
  bool ans = true;
  for (i64 _ = 0; _ < 2; _++)
  {
    i64 m = 0;
    for (i64 i = 0; i < n - 1; i++)
      if (i * 10 <= m)
        m = max(m, i * 10 + d[i]);
    if (m < (n - 1) * 10)
      ans = false;
    reverse(d.begin(), d.end());
  }
  if (ans)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
  return 0;
}



Measured memory_bytes: 5196
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;

int main()
{
  long A, B, C;
  cin >> A >> B >> C;
  cout << A*B/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define int long long
signed main(){
        int n;
        while( scanf("%lld", &n) != EOF ){
                if(n==0) break;
                int max=-100001;
                int now=0;
                for(int i=0;i<n;i++){
                        int t;
                        scanf("%lld", &t);
                        if(now+t>t)now+=t;
                        else now = t;
                        if(now>max) max=now;
                }
                printf("%lld\n",max);
        }
        return 0;
}

Measured memory_bytes: 3180
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int t = 0;
		int x = 0;
		int y = 0;
		for (int i = 0; i < N; i++) {
			int ti = sc.nextInt();
			int zikan = t - ti;
			zikan = Math.abs(zikan);
			
			int xi = sc.nextInt();
			int yi = sc.nextInt();
			int kyori = Math.abs(x - xi) + Math.abs(y - yi);
			
			if (zikan - kyori < 0 || (zikan - kyori) % 2 != 0) {
				System.out.println("No");
				return;
			}
			
			
			t = ti;
			x = xi;
			y = yi;
		}
		
		System.out.println("Yes");
		
	}
}

Measured memory_bytes: 88328
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, M, C;
    cin>>N>>M>>C;

    vi b(M);
    REP(i,0,M){
        cin>>b[i];
    }

    ll ans = 0;
    REP(i,0,N){
        ll s = C;
        REP(j,0,M){
            int x;
            cin>>x;
            s += x * b[j];
        }
        ans += s > 0;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
//$ darklife_12
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve()              
{
    ll n,m,i,j,k;
    long long a[200005],b[200005];
    ll ans=0,res;
    bool flag=true;
    vector<int> v;
    string s1,s2;
    set<int> s;
    cin>>n;
    if(n>=30)cout<<"Yes";
    else cout<<"No";
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
       cout<<"\n";
    }
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func sum(nums []int) int {
	sum := 0
	for _, num := range nums {
		sum += num
	}
	return sum
}

func main() {
	n, x := readInt(), readInt()
	var m []int
	for i := 0; i < n; i++ {
		m = append(m, readInt())
	}
	sort.Ints(m)
	fmt.Println(((x - sum(m)) / m[0]) + n)
}


Measured memory_bytes: 640
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	bool fwin = false;
	for (size_t i = 0; i < N; i++)
	{
		int a;
		in >> a;
		fwin |= (a % 2 == 1);
	}
	if (fwin) {
		out << "first" << endl;
	}
	else {
		out << "second" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 200100;
long long n, k, a[N], ans, aib[N];
vector <long long> v;
map <long long, int> m;

long long lsb(long long k) {return k & (-k);}

long long que(long long pos) {
	// assert(pos > 0);
	long long ret = 0;
	for(; pos; pos -= lsb(pos))
		ret += aib[pos];
	return ret;
}

void upd(long long pos) {
	// assert(pos > 0);
	for(; pos < N; pos += lsb(pos))
		aib[pos]++;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for(long long i = 1; i <= n; i++)  {
		cin >> a[i];
		a[i] -= k;
	}

	for(int i = 1; i <= n; i++) a[i] += a[i - 1];
	for(int i = 1; i <= n; i++) v.push_back(a[i]);
	
	v.push_back(0);
	sort(v.begin(), v.end());

	for(int i = 0; i < v.size(); i++)
		m[v[i]] = i + 1;

	upd(m[0]);
	long long sum = 0;
	for(long long i = 1; i <= n; i++) {
		assert(m.count(a[i]));
		ans += que(m[a[i]]);
		upd(m[a[i]]);
	}

	cout << ans << '\n';

}	

	

Measured memory_bytes: 17392
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
template<class T> inline bool chmax(int a, int b, T c, T d) { return c > d ? a : b; }
template<class T> inline bool chmin(int a, int b, T c, T d) { return c > d ? a : b; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<ppr, Vppr, greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W, R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
//LL A[SIZE];
LL solve() {
	LL C;
	cin >>  N >> C >> K;
	VI A(N,0);
	LL ans=0,last = 0;
	REP(i, N) cin >> A[i];
	sort(ALL(A));
	EFOR(i,1,N) {
		if (i == N or i - last >= C or A[i] - A[last] > K) {
			ans++;
			last = i;
		}
	}
	cout << ans << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();


	//cin >> N;
	return 0;

}


Measured memory_bytes: 9216
#include <iostream>
using namespace std;
static const int SIZE = 8;

int board[SIZE][SIZE];
int queen[SIZE];
int undefined_queen[SIZE];
int check[8];

void board_status(int i, int j, int d){
  int k;
  
  for (k = 0; k < 8; k++) { 
    board[i][k] += d;             // 横
    board[k][j] += d;             // 縦
  }
  if (i > j) {
    for (k = 0; k < 8-(i-j); k++) {
      board[k+(i-j)][k] += d;   // 右下がり斜め
    }
  } else {
        for (k = 0; k < 8-(j-i); k++) {
          board[k][k+(j-i)] += d;   
        }
  }

  
  if (i+j < 8) {
    for (k = 0; k <= i+j; k++) {
      board[i+j-k][k] += d;     // 左下がり斜め
    }
  } else {
    for (k = i+j-8+1; k < 8; k++) {
      board[i+j-k][k] += d;     // 左下がり斜め方向（i+j >= Nのとき）
    }
  }
  
}


void setting(int u){
  
  if(u == 8){
    for(int i=0; i<SIZE; i++){
      for(int j=0; j<SIZE; j++){
        if(queen[i] == j) cout<<"Q";
        else cout<<".";
      }
      cout<<endl;
    }
    return;
  }

  if(check[u] == 1){
    setting(u+1);
  }
  
  for(int i=0; i<SIZE; i++){
    if(board[u][i] == 0){
      queen[u] = i;
      board_status(u,i,1);
      setting(u+1);
      board_status(u,i,-1);
    }
  }
}



int main(){

  int k;

  cin>>k;

  for(int i=0; i<SIZE; i++){
    queen[i] = -1;
  }

  for(int i=0; i<SIZE; i++){
    check[i] = 0;
  }

  for(int i=0; i<SIZE; i++){
    for(int j=0; j<SIZE; j++){
      board[i][j] = 0;
    }
  }

  for(int i=0; i<k; i++){
    int r,c;
    cin>>r>>c;
    queen[r] = c;
    check[r] = 1;
    board_status(r,c,1);
  }

  setting(0);

  
  return 0;
}




Measured memory_bytes: 3100
from itertools import product
from collections import deque
n = int(input())
s = deque(input())
R = []
G = []
B = []
i = 0
while s:
    x = s.popleft()
    if x == 'R':
        R.append(i)
    elif x == 'G':
        G.append(i)
    else:
        B.append(i*2)
    i += 1
ans = len(R)*len(G)*len(B)
# print(len(R))
# print(len(G))
# print(len(B))
# print(R)
# print(G)
# print(B)
B = set(B)
S = product(R, G)
for i, j in S:
    if i + j in B:
        ans -= 1
    if 4 * i - 2*j in B:
        ans -= 1
    if 4 * j - 2 * i in B:
        ans -= 1
print(ans)


Measured memory_bytes: 9688
import Data.List (intercalate)

draw :: Int -> Int -> IO ()
draw w h = drawEachLine w
  where drawEachLine n
          | n == w || n == 1 = drawFrame h >> drawEachLine (n - 1)
          | n > 1            = drawLine  h >> drawEachLine (n - 1)
          | otherwise        = putStrLn "" >> return ()
        drawFrame n = putStrLn $ intercalate "" (replicate n "#")
        drawLine  n = putStrLn $ "#" ++ (intercalate "" $ replicate (n - 2) ".") ++ "#"

main :: IO ()
main = do
    line <- getLine
    let [w, h] = map (\n -> read n :: Int) $ words line
    if w == 0 && h == 0 then
        return ()
    else do
        draw w h
        main


Measured memory_bytes: 3884
#include <iostream>

using namespace std;

int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int cnt=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
				for(int k=0;k<=c;k++){
					if(500*i+100*j+50*k==x){
						cnt++;
					}
			}
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
q=int(input())
m=10**9+7
for _ in range(q):
	x,y=sorted(map(int,input().split()))
	s=0
	i=j=1
	while j<=x and i+j<=y:
		i,j=j,i+j
		s+=1
	if x==1 or y<3:
		print(1,x*y%m)
	else:
		a=max(0,(y-j)//i+1)+max(0,(x-j)//i+1)
		i=j=1
		for c in range(s-1):
			k,l=j,i+j*2
			for _ in range(s-c-1):
				k,l=l,k+l
			if x>=k:
				a+=max(0,(y-l)//k+1)
			if y>=k:
				a+=max(0,(x-l)//k+1)
			i,j=j,i+j
		print(s,a % m)

Measured memory_bytes: 81496