akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<map<int, int>> bit_cnt(60);
    rep(i, n){
        ll a;
        cin >> a;
        rep(j, 60){
            if(a & 1)bit_cnt[j][1]++;
            else bit_cnt[j][0]++;

            a = a >> 1;
        }
    }

    
    ll res = 0;

    rep(i, 60){
        res += mpow(2, i) * bit_cnt[i][0] % MOD * bit_cnt[i][1] % MOD;
        res %= MOD;
    }
    cout << res << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

bool check(vector<string>& A, vector<string>& B,int a,int b) {
	int N = A.size(), M = B.size();
	if (a + M - 1 >= N || b + M - 1 >= N) return false;	
	bool res = true;
	for (int i = 0; i < M&&res; i++) {
		for (int j = 0; j < M; j++) {		
			if (A[a + i][b + j] != B[i][j]) {
				res = false;
				break;
			}
		}
	}
	return res;
}
int main() {
	int N, M; cin >> N >> M;
	vector<string> A(N), B(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	
	bool flag = false;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			
		}
	}
	for (int i = 0; i < N && !flag; i++) {
		for (int j = 0; j < N; j++) {
			if (check(A, B, i, j)) {
				flag = true;
				break;
			}
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int n, mx;
string s;
int main() {
	int i, j, k;
	cin >> n >> s;
	for(i=1; i<n; i++) {
		for(j=k=0; j+i<n; j++) {
			if(s[j] == s[j+i]) k++, mx = max(mx, min(i, k));
			else k = 0;
		}
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc133/tasks/abc133_d
// math, implementation
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    const long n = readln.chomp.to!long;
    const long[] as = 0~readln.split.map!(to!long).array;

    long[] ms = new long[n+1];

    const long water = sum(as);
    long dams = 0;

    for(int i = 2; i <= n-1; i += 2)
        dams += as[i];

    ms[1] = water - 2 * dams;
    for(int i = 1; i < n; i++)
        ms[i+1] = 2 * as[i] - ms[i];

    for(int i = 1; i <= n; i++)
        writef("%d ", ms[i]);
    writeln;
}



Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

int n;
int a[110];

bool dp[100010][110];
bool done[100010][110]={false};

bool func(int i,int j) {
	if (done[i][j]) return dp[i][j];
	if (i<a[j]) {
		done[i][j]=true;
		return dp[i][j]=false;
	}
	bool ok = true;
	rep(l,n) {
		if (func(i-a[j],l)) {
			ok = false;
			break;
		}
	}
	done[i][j]=true;
	return dp[i][j]=ok;
}

int main(int argc, char const *argv[])
{
	int k;cin>>n>>k;

	rep(i,n) cin>>a[i];

	bool fir = false;

	rep(i,n) {
		fir|=func(k,i);
		// if (func(k,i)) cout<<"t"<<endl;
		// else cout<<"f"<<endl;
	}

	if (fir) cout<<"First"<<endl;
	else cout<<"Second"<<endl;

	return 0;
}

Measured memory_bytes: 26368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

vector<double> dijkstra(vector<vector<pair<int,double>>>& graph,int s){
    int n=(int)graph.size();
    priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> pq;
    vector<double> dist(n,1e10);
    dist[s]=0;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            double w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                pq.push({dist[u],u});
            }
        }
    }
    return dist;
}

int main(){
    int sx,sy,gx,gy,n;
    cin>>sx>>sy>>gx>>gy>>n;
    double x[n+2],y[n+2],r[n+2];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>r[i];
    }
    x[n]=sx,y[n]=sy,r[n]=0;
    x[n+1]=gx,y[n+1]=gy,r[n+1]=0;
    vector<vector<pair<int,double>>> g(n+2);
    for(int i=0;i<n+2;i++){
        for(int j=0;j<n+2;j++){
            double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            g[i].push_back({j,max(0.0,d-r[i]-r[j])});
            g[j].push_back({i,max(0.0,d-r[i]-r[j])});
        }
    }
    vector<double> d=dijkstra(g,n);
    cout<<fixed<<setprecision(10)<<d[n+1]<<endl;
}

Measured memory_bytes: 37616
num = int(input())

def prime(x):
    if x ==2 or x == 3:
        return True
    
    elif x < 2 or x % 2 == 0:
        return False
    
    
    elif x >3:
        i = 3
        while i <= int(x**0.5)+1:
            if x % i ==0:
                return False
                break
            i = i+2
        return True

count = 0
for i in range(num):
    j = int(input())
    if prime(j) == True:
        count +=1



print(count)


Measured memory_bytes: 5676
#include <iostream>
#include<bits/stdc++.h>
#define base 950527
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> res;
ll lh,ns,nt,LH,tmp=1,n,s[200005],t[200005],K[200005],S[200005],T[200005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    for(int i=0;i<n;i++){
        cin>>T[i];
    }
    for(int i=0;i<n;i++){
        K[i]=S[i]^T[0];
    }
    for(int i=0;i<n;i++){
        s[i]=S[i]^S[(i+1)%n];
        t[i]=T[i]^T[(i+1)%n];
        //cout<<s[i]<<endl;
    }
    //cin>>s>>t;
    ns=n;
    nt=n;
    for(int i=0;i<nt;i++){
        lh=lh*base+s[i];
        LH=LH*base+t[i];
        tmp*=base;
    }
    if(lh==LH)res.push_back({0,K[0]});
    for(int i=0;i<ns-1;i++){
        lh=lh*base-tmp*s[i];
        lh+=s[i];
        //cout<<LH<<" "<<lh<<" "<<i<<endl;
        if(LH==lh)res.push_back({i+1,K[i+1]});
    }
    sort(res.begin(),res.end());
    for(auto x:res){
        cout<<x.first<<" "<<x.second<<endl;
    }
}


Measured memory_bytes: 14572
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,k.split("+"))))
s=input()
n=len(s)
print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
 
 
 int  main() {
      int n;
      cin>>n;
      int a[n];
      int cnt[n+1]={0};
      for(int i=0;i<(n-1);i++){
          cin>>a[i];
          cnt[a[i]]++;
      }
      
      for(int i=1;i<=n;i++){
          cout<<cnt[i]<<endl;
      }
      
      
    
    return 0;
}

Measured memory_bytes: 5240
use proconio::input;

fn main() {
    input! {
        n: u32,
    }
    print_yes_or_no(solve(n));
}

fn solve(mut n: u32) -> bool {
    while n > 0 {
        if n % 10 == 7 {
            return true
        }
        n /= 10;
    }
    false
}

fn print_yes_or_no(yes: bool) {
    println!("{}", if yes { "Yes" } else { "No" });
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

int read()
{
	int k = 1;
	int x = 0;
	char c = getchar();
	while (c > '9' || c < '0') 
		if (c == '-') c = getchar(), k = -1;
		else c = getchar();
	while (c >= '0' && c <= '9')
		x = (x << 1) + (x << 3) + (c ^ 48),
		c = getchar();
	return k * x;
}

int n, a, b, u;
int x[3333];
int h[3333];
int y[3333];
int cx, cy, H;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) u = i;
	}
	for (int xi = 0; xi <= 100; ++xi)
	{
		for (int yi = 0; yi <= 100; ++yi)
		{
			cx = xi, cy = yi;
			H = h[u] + abs(x[u] - cx) + abs(y[u] - cy);
			for (int i = 1; i <= n; ++i)
			{
				if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) break;
				if (i == n)
				{
					cout << cx << " " << cy << " " << H;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n),c(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    const ll INF = INT64_MAX>>2;
    ll ans = -INF;
    rep(i,n) {
        vector<ll> p_max(1);
        p_max[0] = -INF;
        ll now = i;
        ll step = 0;
        ll point = 0;
        while(true) {
            step++;
            if(step > k) break;
            now = p[now];
            point += c[now];
            p_max.push_back(p_max[step-1]);
            chmax(p_max[step], point);            
            if(now == i) break;
        }
        if(step > k) {
            chmax(ans, p_max[k]);
            //cout << p_max[k] << endl;
        } else if(now == i) {
            if(point <= 0) {
                chmax(ans, p_max[step]);
                //cout << p_max[step] << endl;
            }
            else if(point > 0) {
                ll rot = k/step;
                ll rem = k%step;
                p_max[0] = 0;
                chmax(ans, (rot-1)*point+p_max[step]);
                chmax(ans, rot*point + p_max[rem]);
                chmax(ans, rot*point);
                //cout << max(rot*point + p_max[rem], rot*point) << endl;
            }
        }
        //cout << i << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3828
W, H, x, y, r = input().split()
W = int(W)
H = int(H)
x = int(x)
y = int(y)
r = int(r)

if x - r < 0:
    print("No")
elif x + r > W:
    print("No")
elif y - r < 0:
    print("No")
elif y + r > H:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,n,maxL=0; cin>>n>>maxL;
  long long sum=0;
  for(int i=0;i<n-1;i++){
    cin>>a;
    if(maxL>a) sum+=maxL-a;
    else maxL=a;
  }
  cout<<sum;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if (n==1) cout << 2 << '\n';
    else if (n==0||n==2) cout << 1 << '\n';
    else cout << 0 << '\n';
}


Measured memory_bytes: 3232
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int s[7];
int k;
string c;
void  f(int k)
{
    if(c[k]=='S')
    {
       int t=s[1];
       s[1]=s[3];
       s[3]=s[6];
       s[6]=s[2];
       s[2]=t;
    }
      if(c[k]=='N')
    {
       int t=s[3];
       s[3]=s[1];
       s[1]=s[2];
       s[2]=s[6];
       s[6]=t;
    }
        if(c[k]=='W')
    {
       int t=s[1];
       s[1]=s[5];
       s[5]=s[6];
       s[6]=s[4];
       s[4]=t;
    }
          if(c[k]=='E')
    {
       int t=s[1];
       s[1]=s[4];
       s[4]=s[6];
       s[6]=s[5];
       s[5]=t;
    }
}
int main()
{
   // for(int i=0;i<6;i++)

        cin>>s[1];
        cin>>s[2];
        cin>>s[5];
        cin>>s[4];
        cin>>s[3];
        cin>>s[6];

//  for(int i=1;i<=6;i++)  cout<<s[i]<<' ';
    cin>>c;
    for(int i=0;i<c.size();i++)
    {
        f(i);
    }
    cout<<s[1]<<endl;
    return 0;
}



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

int main(){
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }else if(r<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if H[i] == 0:
        continue

    while True:
        base = H[i]
        for j in range(i+1, N):
            # 花の高さが0なら初期のまま
            if H[j] <= 0:
                break

            # 次の花(j+1)が基準の花(j)以下か
            if base <= H[j]:
                H[j] -= 1
            else:
                break
        H[i] -= 1
        ans += 1

        if H[i] <= 0:
            break

ans += max(0, H[-1])
print(ans)


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

int main () {
  int N, M;
  cin >> N >> M;
  
  int ans[N]={}, a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--;
    b--;
    ans[a]++;
    ans[b]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n;
	cin >> n;
	int a[50], b[50], c[50];
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n - 1) {
		cin >> c[i];
	}
	int ans = 0;
	ans += b[a[0]];
	for (int i = 1; i < n; i++) {
		ans += b[a[i]];
		if (a[i] - a[i - 1] == 1) {
			ans += c[a[i - 1]];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let (x, y) = (io.read::<i64>(), io.read::<i64>());

    for a in 0..101 {
        let a = a as i64;
        let b = x - a;
        if a * 2 + b * 4 == y && b >= 0 {
            io.writeln("Yes");
            return;
        }
    }
    io.writeln("No");
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2128
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

        List<Dict> ret = new List<Dict>();
        for (int i = 0; i < N; i++)
        {
            List<int> ownerItem = new List<int>();
            bool header = true;
            foreach (var item in Console.ReadLine().Split(' '))
            {
                if (header)
                {
                    header = false;
                    continue;
                }

                int dictItem = int.Parse(item);
                if (ownerItem.Contains(dictItem))
                {
                    continue;
                }
                else
                {
                    ownerItem.Add(dictItem);
                }

                int index = ret.FindIndex(n => n.item == dictItem);
                if (index == -1)
                {
                    ret.Add(new Dict()
                    {
                        item = dictItem,
                        count = 1
                    });
                }
                else
                {
                    ret[index].count++;
                }
            }
        }

        Console.WriteLine(ret.FindAll(n => n.count == N).Count);
        Console.Read();
    }

    public class Dict
    {
        public int item;
        public int count = 0;
    }
}


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

const ll INF = 1LL << 50;

ll f(ll x, ll A, ll X) {
  return max(A - (x - X) * (x - X), 0LL);
}

ll diff(ll x, ll A, ll X) {
  ll y3 = f(x - 3, A, X), y2 = f(x - 2, A, X), y1 = f(x - 1, A, X), y0 = f(x - 0, A, X);
  ll v2 = y2 - y3, v1 = y1 - y2, v0 = y0 - y1;
  ll a1 = v1 - v2, a0 = v0 - v1;
  return a0 - a1;
}

ll ok(ll k, ll a, ll n, ll *sum) {
  ll l = -INF, r = INF;
  REP(i, 1, n + 1) {
    if(sum[i] < k) {
      ll s = k - sum[i];
      ll x1 = ceil(i - sqrt(a - s));
      ll x2 = floor(i + sqrt(a - s));
      l = max(l, x1);
      r = min(r, x2);
    }
  }
  return l <= r;
}

ll s[3000001];
ll *sum = s + 1000000;

int main(void) {
  ll N, M;
  while(cin >> N >> M, N && M) {
    vector<ll> A(M), X(M - 1);
    REP(i, 0, M - 1) cin >> A[i] >> X[i];
    cin >> A[M - 1];

    REP(i, 0, 3000001) s[i] = 0;
    REP(i, 0, M - 1) {
      ll x1 = X[i] - sqrt(A[i]);
      ll x2 = X[i] + sqrt(A[i]);
      set<ll> candidate;
      REP(k, 0, 5) {
        candidate.insert(x1 + k);
        candidate.insert(x2 + k);
      }
      for(ll x : candidate) {
        sum[x] += diff(x, A[i], X[i]);
      }
    }
    REP(k, 0, 3) REP(i, 0, 3000000) s[i + 1] += s[i];

    ll l = 0, h = INF;
    while(h - l > 1) {
      ll m = (l + h) / 2;
      if(ok(m, A[M - 1], N, sum)) l = m; else h = m;
    }
    cout << l << endl;
  }
}


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

using namespace std;

#define ll long long

int main (){
    int n ;
    cin >> n;
    int data [n] ;
    for (int i = 0 ; i < n ; i ++ ){
        cin >> data [i] ;
    }
    for (int i = 0 ; i < n ; i ++ )
        if (i < data[i]){
            cout << -1 ;
            return 0;
    }
    ll ans = 0;
    for (int i = 1 ; i < n ; i ++ ){
        if (data[i] != data[i-1] + 1){
            if (data[i] > data[i-1] + 1 ){
                cout << -1 ;
                return 0;
            }
            ans += data[i-1] ;
        }
    }
    ans += data [n-1];
    cout << ans ;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a[100];
double ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=1.0/a[i];
	}
	printf("%lf",1/ans);
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(100, 0);
    int maxi = -1;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        ++a[x];
        maxi = max(maxi, x);
    }
    bool db = true;
    if (maxi % 2 == 0)
    {
        for (int i = maxi; i > maxi / 2; --i)
        {
            if (a[i] < 2)
                db = false;
            a[i] -= 2;
        }
        if (a[maxi / 2] < 1)
            db = false;
        --a[maxi / 2];
        for (int i = 0; i < 100; ++i)
            if (a[i] > 0 && !(i >= maxi / 2 + 1 && i <= maxi))
                db = false;
    }
    else
    {
        for (int i = maxi; i >= maxi / 2 + 1; --i)
        {
            if (a[i] < 2)
                db = false;
            a[i] -= 2;
        }
        for (int i = 0; i < 100; ++i)
            if (a[i] > 0 && !(i >= maxi / 2 + 2 && i <= maxi))
                db = false;
    }
    if (db)
        cout << "Possible";
    else
        cout << "Impossible";
    return 0;
}


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

bool valid = true;
map<char, int> declar;
map< pair<char, int>, int> assign;

int number(const string& s, int& p)
{
	int ret = 0;
	while (isdigit(s[p])) {
		ret *= 10;
		ret += (s[p++] - '0');
	}
	return ret;
}

int expression(const string& s, int& p)
{
	if (isdigit(s[p])) {
		return number(s, p);
	} else {
		char array_name = s[p++];
		++p;
		int array_index = expression(s, p);

		map<char, int>::iterator it = declar.find(array_name);
		if (it != declar.end() && array_index < it->second) {
			++p;
			map< pair<char, int>, int>::iterator jt = assign.find(pair<char, int>(array_name, array_index));
			if (jt != assign.end())
				return jt->second;
			else
				valid = false;
		} else {
			valid = false;
		}
	}
}

void assignment(const string& s, int& p)
{
	char array_name = s[p++];
	++p;
	int array_index = expression(s, p);
	
	map<char, int>::iterator it = declar.find(array_name);
	if (it != declar.end() && array_index < it->second) {
		p += 2;
		int value = expression(s, p);
		assign[pair<char, int>(array_name, array_index)] = value;
	} else {
		valid = false;
	}
}

void declaration(const string& s, int& p)
{
	char array_name = s[p++];
	++p;
	int array_size = number(s, p);
	declar[array_name] = array_size;
}

int main()
{
	string s;
	while (cin >> s) {
		if (s == ".")
			break;

		int cnt = 1, ans = 0;
		valid = true;
		while (s != ".") {
			int p = 0;

			if (valid) {
				if (s.find_first_of("=") == string::npos)
					declaration(s, p);
				else
					assignment(s, p);
				if (!valid)
					ans = cnt;
			}

			cin >> s;
			++cnt;
		}

		declar.clear();
		assign.clear();
		cout << ans << endl;
	}
	return 0;
}

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

const long long mod = 1000000007;

int main()
{
    std::string s;
    long long D,n;
    std::cin >> s >> D;
    n = s.size();
    //dp[i][j][k] := i文字目まで見た時にmodDでkで、未満フラグがjの数

    std::vector<std::vector<std::vector<long long>>> dp(n + 10,std::vector<std::vector<long long>>(2,std::vector<long long>(D)));
    dp[0][0][0] = 1;
    
    for(long long i = 0; i < n; i++){
        
        for(long long j = 0; j < 2; j++){
            
            for(long long k = 0; k < D; k++){

                long long lim = (j ? 9 : s[i] - '0');

                for(long long d = 0; d <= lim; d++){

                    (dp[i + 1][j || d < lim][(d + k) % D] += dp[i][j][k]) %= mod;                    

                }
            }
        }
    }
    long long res = dp[n][0][0] + dp[n][1][0] - 1;
    if(res >= mod)res -= mod;
    if(res < 0)res += mod;
    std::cout << res << std::endl;


}


Measured memory_bytes: 17024
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;

    rep(i,s.size()){
        s[i] = (s[i]-'A' + n)%26 + 'A';
    }
    cout << s << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct Queue{
    char name[11];
    int time;
};


int main()
{

    int n, q;
    scanf("%d%d", &n, &q);

    int size = 2 * n; 
    struct Queue Queue[size];
    int pre = 0, rear = 0, cnt = 0;
    for( rear = 0; rear < n; ++rear )
        scanf("%s %d", Queue[rear].name, &Queue[rear].time);


    while( pre != rear ){
        if( Queue[pre].time <= q ){
            cnt += Queue[pre].time;
            printf("%s %d\n", Queue[pre].name, cnt);
        } else {
            cnt += q;
            Queue[pre].time -= q;
            Queue[rear] = Queue[pre];
            rear = (rear + 1) % size;
        }


        pre = (pre + 1) % size;
    }


    return 0;
}


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

using namespace std;





int main(){


	string s, t; cin >> s >> t;

	int cnt = 0;

	for(int i = 0; i < 3; i++){
		if(s[i] == t[i]) cnt++;
	}


	cout << cnt << endl;
	

	




	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int d[100000];
    for(int i=0;i<100000;i++){
        d[i]=0;
    }
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        d[a]++;
    }
    if(n&1){
        if(d[0]!=1){
            cout<<0<<endl;
            return 0;
        }
    }else{
        if(d[0]!=0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=1;i<n;i++){
        if((n^i)&1){
            if(d[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }else{
            if(d[i]!=0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    uint64_t res=1;
    for(int i=0;i<n/2;i++){
        res*=2;
        if(res>1000000007){
            res%=1000000007;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

	class AOJ0238{
		public AOJ0238() {
			while(true){
				int t = in.nextInt();
				if(t==0)break;
				int n = in.nextInt();
				int sum = 0;
				for(int i=0;i<n;i++){
					int a = in.nextInt(),b = in.nextInt();
					sum+=(b-a);
				}
				System.out.println(t<=sum? "OK":t-sum);
			}
		}
	}

}

Measured memory_bytes: 23608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<62)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size
#define T ((ll)(2e12))

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	ll a,b,n;
	cin >> a >> b;
	if(a>0){
		cout << "Positive" << endl;
	}else if(b<0){
		cout << (((b-a)%2)?"Positive":"Negative")<< endl;
	}else{
		cout << "Zero" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
		}
		int m = scanner.nextInt();
		int count = 0;
		while (m-- > 0) {
			int a = scanner.nextInt();
			int l = 0;
			int r = n - 1;
			while (l <= r) {
				int mid = (l + r) / 2;
				if (num[mid] > a) {
					r = mid - 1;
				} else if (num[mid] < a) {
					l = mid + 1;
				} else {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
}

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

int main() {
  int s; cin >> s;
  vector<int> a(1000000);
  a.at(0) = s;
  vector<int> cnt(10000000);
  for (int i = 1; i < 1000000; i++) {
    if (s % 2 == 0) {
      s = s / 2;
    }
    else if (s % 2 == 1) {
      s = 3 * s + 1;
    }
    a.at(i) = s;
  }
  int ans = -1;
  for(int i = 0; i < 1000000; i++) {
    int j = a.at(i);
    cnt.at(j)++;
    if (cnt.at(j) == 2) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}  

Measured memory_bytes: 43264
n = int(input())
a = []
for i in range(n):
    ai = int(input())
    a.append(ai)

a = sorted(a)

sum_1 = 0
sum_2 = 0
if len(a) % 2 == 1:
    for i in range(0, len(a)//2):
        sum_1 += a[-i-1] - a[i]
        sum_2 += a[-i-1] - a[i]
    for i in range(1, len(a)//2):
        sum_1 += a[-i] - a[i]
    for i in range(0, len(a)//2-1):
        sum_2 += a[-i-2] - a[i]
    sum_1 += a[len(a)//2]-a[0]
    sum_2 += a[-1]-a[len(a)//2]
    print(max(sum_1, sum_2))

else:
    for i in range(0, len(a)//2-1):
        sum_1 += a[-i-1] - a[i]
        sum_2 += a[-i-1] - a[i]
    for i in range(1, len(a)//2):
        sum_1 += a[-i] - a[i]
    for i in range(0, len(a)//2-1):
        sum_2 += a[-i-2] - a[i]
    sum_1 += a[-len(a)//2] - a[0]
    sum_2 += a[-1] - a[len(a)//2-1]
    print(max(sum_1, sum_2))


Measured memory_bytes: 8308
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int test=0;
    for(int i=0;i<s.length();i++)
        if(s[i]!=t[i])
            test++;
        cout<<test<<endl;

    return 0;   
}


 
 


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

int main() {
	uint32_t N;
	cin >> N;
	
	vector<vector<double>> dp(2, vector<double>(N+1, 1));	
	for(uint32_t i=1; i<=N; i++) {
		double p;
		cin >> p;
		
		double q = 1 - p;
		bool ic = i&1;
		bool ip = !ic;
		
		dp[ic][0] = dp[ip][0] * q;
		//cout << setprecision(3) << dp[ic][0] << " ";
		
		for(uint32_t j=1; j<i; j++) {
			dp[ic][j] = dp[ip][j-1] * p + dp[ip][j] * q;
			//cout << setprecision(3) << dp[ic][j] << " ";
		}

		dp[ic][i] = dp[ip][i-1] * p;
		//cout << setprecision(3) << dp[ic][i] << endl;
	}

	// N is odd
	double ans = accumulate(dp[1].begin() + N/2 + 1, dp[1].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

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

int main(){
	int A[2];
  	cin >> A[0] >> A[1] >> A[2];
  	sort(A,A+3);
  	int cont = 0;
  	//cout << A[0]<<":"<<A[1]<<":"<<A[2]<<endl;
  	//cout << A[0]%2<<":"<<A[1]%2<<endl;
  	if(A[0]%2==A[1]%2){
    	//何もしない
    }else{
    	A[1]++;
      	A[2]++;
      	cont++;
    }
  	//cout <<A[0]<<A[1]<< cont << endl;
	cont=(A[1]-A[0])/2+cont;
  	//cout << cont << endl;
  	cout<< (A[2]-A[1])+cont << endl;



}

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

int main() {
  int N, K, p = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
	if (p < K) {
      p *= 2;
    }
    else {
      p += K;
    }
  }
  cout << p;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
	int cnt=0;
	vi v(0);
	for(int i=1;i<=min(a,b);i++){
		if(a%i==0 && b%i==0){
			v.push_back(i);
		}
	}
	sort(all(v));
	reverse(all(v));
	cout<<v[c-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n,m;cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}
pair<vector<int>,vector<int>> doo(ll n)
{
    if(n==1) return {vector<int>(),vector<int>()};
    vector<int> a,b;
    tie(a,b) = doo(n/2);

    assert(SZ(a)==SZ(b));
    REP(i,SZ(a)) a[i]++,b[i]++;
    a.pb(1);b.pb(1);
    if(n&1)
    {
        REP(i,SZ(a)) a[i]++,b[i]++;
        a.insert(a.begin(),1);
        b.pb(1);
    }
    return {a,b};
}
int main()
{
    ll n;RI(n);
    vector<int> a,b;
    tie(a,b) = doo(n+1);
    a.insert(a.end(),ALL(b));
    PL(SZ(a));
    REP(i,SZ(a)) printf("%d%c",a[i]," \n"[i==SZ(a)-1]);
    return 0;
}




































/*End Of File*/




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    if (n == 1) {
        cout << 1 << endl;

        return 0;
    }

    int x, rem, ans = 0;

    int i, j, m;

    j = 0;

    for (i = 1; i <= n; i++) {
        x = i;
        rem = x % 2;
        m = 0;

        while (rem == 0) {
            x /= 2;
            rem = x % 2;
            m++;
        }

        if (j < m) {
            ans = i;
            j = m;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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


    System.out.println(a/b);
    System.out.println(a%b);
    System.out.println(String.format("%.5f",  1.0 * a / b));
  }
}



Measured memory_bytes: 26428
#include <stdio.h>
int main(void){
    // Your code here!
    char days[4];
    scanf("%s",days);
    if(days[0]=='M'){
        printf("6");
    }
    else if(days[2]=='E'){
        printf("5");
    }
    else if(days[0]=='W'){
        printf("4");
    }
    else if(days[1]=='H'){
        printf("3");
    }
    else if(days[0]=='F'){
        printf("2");
    }
    else if(days[1]=='A'){
        printf("1");
    }
    else if(days[0]=='S' && days[1]=='U'){
        printf("7");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;
typedef vector<PII> VPII;

// TEMPLATE DEFINITIONS END

LL n, k;

int convert_base(LL N, LL b){

    VI solution;
    while(N){

        solution.push_back(N % b);
        N /= b;
    }
    return solution.size();
}

// LL cnt_digits(LL x){
//     int cnt = 0;
//     while(x){
//         x /= 10;
//         cnt++;
//     }
//     return cnt;
// }

void read_input(){

    cin >> n >> k;
}

void solve(){
    cout << convert_base(n, k) << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
#define N 100005
int n,m,fa[N],cnt,head[N],dep[N],f[N],ans;
struct edge{int to,nxt;}e[N<<1];
void adde(int x,int y){e[++cnt].to=y;e[cnt].nxt=head[x];head[x]=cnt;}
void dfs(int u,int pr){
	f[u]=1;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		dfs(v,u);
		f[u]=max(f[u],f[v]+1);
	}
	if (f[u]>=m&&fa[u]!=1) ans++,f[u]=0;
}
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n){
		scanf("%d",&fa[i]);
		if (i>1) adde(fa[i],i);
	}
	if (fa[1]!=1) ans++,fa[1]=1;
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6912
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}


int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	set < int > s ;
	int n ;
	cin >> n ;
	while ( n-- ) {
		int x ;
		cin >> x ;
		s . insert ( x ) ; 
	}
	cout << ( int ) s . size ( ) << endl ;
	return 0 ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 0, now = 1, tp;
    cin >> n;
    vll a(n);
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    sort(all(a));
    tp = n - 1;
    if (++now <= n)
    {
        ans += a[tp];
        tp--;
    }
    while (now < n)
    {
        if (++now <= n)
        {
            ans += a[tp];
        }
        if (++now <= n)
        {
            ans += a[tp];
        }
        tp--;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4780
n,k,q = map(int,input().split())
a = [k] * n
b = [0] * n
for i in range(q):
    c = int(input())
    b[c-1] += 1
for j in range(n):
    z = k - (q - b[j])
    if z > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 5576