akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        m:usize,
        k:i64,
        a:[i64;n],
        b:[i64;m],
    }
    let cum_a = CumulativeSum::from_vec(&a);
    let cum_b = CumulativeSum::from_vec(&b);
    let cand = cum_a
        .cum
        .iter()
        .take_while(|&&x| x <= k)
        .enumerate()
        .map(|(i, &x)| {
            let b_num = cum_b.cum.upper_bound(&(k - x));
            i + b_num - 1
        })
        .max();
    let ans = match cand {
        Some(x) => x,
        None => 0,
    };
    println!("{}", ans);
}

struct CumulativeSum<T: num::Num + Copy> {
    cum: Vec<T>,
}
impl<T: num::Num + Copy> std::iter::FromIterator<T> for CumulativeSum<T> {
    fn from_iter<R>(iter: R) -> Self
    where
        R: IntoIterator<Item = T>,
    {
        CumulativeSum {
            cum: (std::iter::once(T::zero()).chain(iter))
                .scan(T::zero(), |acc, x| {
                    *acc = *acc + x;
                    Some(*acc)
                })
                .collect(),
        }
    }
}
impl<T: num::Num + Copy> CumulativeSum<T> {
    fn from_iter<R>(iter: R) -> Self
    where
        R: IntoIterator<Item = T>,
    {
        CumulativeSum {
            cum: (std::iter::once(T::zero()).chain(iter))
                .scan(T::zero(), |acc, x| {
                    *acc = *acc + x;
                    Some(*acc)
                })
                .collect(),
        }
    }
    pub fn from_vec(v: &Vec<T>) -> Self {
        Self::from_iter(v.iter().copied())
    }
    pub fn query(&self, a: usize, b: usize) -> T {
        self.cum[b] - self.cum[a]
    }
}

pub fn meguru_binary_search<T, F>(ok: T, no: T, is_valid: F, error: T) -> T
where
    T: num::PrimInt,
    F: Fn(T) -> bool,
{
    itertools::iterate((ok, no), |&(temp_ok, temp_no)| {
        let mid = (temp_ok + temp_no) / T::from(2).unwrap();
        if is_valid(mid) {
            (mid, temp_no)
        } else {
            (temp_ok, mid)
        }
    })
    .find(|&(temp_ok, temp_no)| temp_ok + error >= temp_no && temp_no + error >= temp_ok)
    .unwrap()
    .0
}
pub trait LowerUpperBound<T: Ord> {
    fn lower_bound(&self, value: &T) -> usize;
    fn upper_bound(&self, value: &T) -> usize;
}
impl<T> LowerUpperBound<T> for [T]
where
    T: Ord,
{
    fn lower_bound(&self, value: &T) -> usize {
        meguru_binary_search(self.len() as i64, -1, |x| self[x as usize] >= *value, 1) as usize
    }
    fn upper_bound(&self, value: &T) -> usize {
        meguru_binary_search(self.len() as i64, -1, |x| self[x as usize] > *value, 1) as usize
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n){
    cin >> l[i];
  }
  sort(l.begin(),l.end());

  int ans = 0;

  for(int i=0;i<n-2;++i){
    for(int j=i+1;j<n-1;++j){
      int k = j+1;
      while((l[i]+l[j]>l[k]) and (k<n)){
        ans++;
        k++;
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m;
	cin >> n >> m;
	ll num = min(n,m/2);
	m -= num * 2;
	cout << num + m / 4 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;



ll n,m,s,t;
ll dista[100002],distb[100002];
vector<P> machia[100002],machib[100002];
priority_queue<P,vector<P>,greater<P>> quea,queb;
ll mini[100002];

int main(){
  cin>>n>>m>>s>>t;
  rep1(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    machia[u].push_back(make_pair(a,v));
    machia[v].push_back(make_pair(a,u));
    machib[u].push_back(make_pair(b,v));
    machib[v].push_back(make_pair(b,u));
  }
  rep1(i,n){
    dista[i]=longinf;
    distb[i]=longinf;
  }
  dista[s]=0;
  rep0(i,machia[s].size()){
    quea.push(machia[s][i]);
    dista[machia[s][i].second]=machia[s][i].first;
  }
  while(quea.size()){
    P p=quea.top();
    quea.pop();
    if(p.first>dista[p.second]) continue;
    for(int i=0;i<machia[p.second].size();i++){
      if(machia[p.second][i].first+dista[p.second]<dista[machia[p.second][i].second]){
        dista[machia[p.second][i].second]=machia[p.second][i].first+dista[p.second];
        quea.push({dista[machia[p.second][i].second],machia[p.second][i].second});
      }
    }
  }
   distb[t]=0;
  rep0(i,machib[t].size()){
    queb.push(machib[t][i]);
    distb[machib[t][i].second]=machib[t][i].first;
  }
  while(queb.size()){
    P p=queb.top();
    queb.pop();
    if(p.first>distb[p.second]) continue;
    for(int i=0;i<machib[p.second].size();i++){
      if(machib[p.second][i].first+distb[p.second]<distb[machib[p.second][i].second]){
        distb[machib[p.second][i].second]=machib[p.second][i].first+distb[p.second];
        queb.push({distb[machib[p.second][i].second],machib[p.second][i].second});
      }
    }
  }
  ll shozikin=1e15;
  mini[n]=dista[n]+distb[n];
  for(int i=n-1;i>=1;i--){
    mini[i]=min(mini[i+1],dista[i]+distb[i]);
  }
  rep1(i,n){
    printf("%ld\n",shozikin-mini[i]);
  }
    return 0;
}


Measured memory_bytes: 20216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int a=0;
    int z=0;
    for(int i=0;i<=n;i++)
    if(s[i]=='A')
    {
    a=i;
    break;
    }
    for(int i=n-1;n>=i;i--)
    if(s[i]=='Z')
    {
    z=i;
    break;
    }
    cout<<(z-a)+1<<endl;
    return 0;
}
 
 

Measured memory_bytes: 3720
#include<map>
#include<cstdio>
#include<queue>
#include<bitset>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
# define Type template<typename T>
# define ll long long
# define ull unsigned ll
# define read read1<int>()
Type inline T read1(){
    T t=0;
    char k;
    bool fl=0;
    do k=getchar(),(k=='-')&&(fl=1);while('0'>k||k>'9');
    while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
    return fl?-t:t;
}
int s,h[100005],m;
bool f[100005];
int main(){
    s=read;m=read;
    for(int i=1;i<=s;++i)h[i]=read;
    for(int i=1;i<=m;++i){
        int u=read,v=read;
        if(h[u]>=h[v])f[v]=1;
        if(h[v]>=h[u])f[u]=1;
    }
    int ans=0;
    for(int i=1;i<=s;++i)
        if(!f[i])++ans;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4236
#include<iostream>
#include<cmath>
using namespace std;
main()
{
    int a,b,c,d,e,f,x,y,z;
    cin>>a>>b>>c;
    d=abs(a-b);
    e=abs(a-c);
    f=abs(b-c);
    x=d+e;
    y=d+f;
    z=e+f;
    if(x<=y && x<=z)cout<<x<<endl;
    else if(y<=x && y<=z)cout<<y<<endl;
    else if(z<=x && z<=y)cout<<z<<endl;
    return 0;




}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    
    long double k=sqrt(x*y-0.75)-x+0.5;
    cout<<(ll)(x-1+k+(x*y-1)/(x+k))-(x!=y)<<endl;
  }
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int x[100][100];
int y[100][100];
int loop[100][100];

int check(int yy,int xx, int a){
  if(loop[yy][xx] == a) return 1;
  if(loop[yy][xx] == 0){
    loop[yy][xx] = a;
    return check(y[yy][xx],x[yy][xx],a);
  }
  return 0;
}

int main(){
  int n;
  while(n = getInt()){
    int ans = 0;
    int tmp = 1;

    REP(i,n) REP(j,n){
      x[i][j] = getInt();
      y[i][j] = getInt();
      loop[i][j] = 0;
    }

    REP(i,n) REP(j,n) if(loop[i][j] == 0){
      ans += check(i,j,tmp++);
    }

    print(ans);
  }
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());
    vector<int> cnt_Li(1001);
    for (int i = 0; i < N; i++)
    {
        cnt_Li.at(L.at(i))++;
    }
    vector<int> cnt_shorter(1001);
    int acc = 0;
    for (int l = 0; l < 1001; l++)
    {
        acc += cnt_Li.at(l);
        cnt_shorter.at(l) = acc;
    }

    int res = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            res += cnt_shorter.at(min(1000, L.at(i) + L.at(j) - 1)) - (j + 1);
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  int M = max(max(A, B), C);

  int ans = 0;
  if ((3 * M - A - B - C) % 2 == 0) {
    ans = (3 * M - A - B - C) / 2;
  } else {
    ans = (3 * (M + 1) - A - B - C) / 2;
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, S: "List[str]"):
    L = 'ABC'
    ll = []
    def rec(i, a, b, c):
        #print(a, b, c, ll)
        if i == N:
            return ll
        s = S[i]
        vals = [a, b, c]
        if s == 'AB':
            u, v = 0, 1
        if s == 'BC':
            u, v = 1, 2
        if s == 'AC':
            u, v = 0, 2

        if vals[u] == 0 and vals[v] == 0:
            if len(ll) > 0:
                ll.pop()
            return False
        elif vals[u] == 1 and vals[v] == 1:
            ll.append(L[u])
            vals[u] += 1
            vals[v] -= 1
            tmp = rec(i + 1, vals[0], vals[1], vals[2])
            if tmp:
                return tmp
            else:
                ll.append(L[v])
                vals[u] -= 2
                vals[v] += 2
                return rec(i + 1, vals[0], vals[1], vals[2])
        elif vals[u] == 0 or (vals[v] > 1 and vals[u] == 1):
            ll.append(L[u])
            vals[u] += 1
            vals[v] -= 1
            return rec(i + 1, vals[0], vals[1], vals[2])
        else:
            ll.append(L[v])
            vals[u] -= 1
            vals[v] += 1
            return rec(i + 1, vals[0], vals[1], vals[2])

    ret = rec(0, A, B, C)
    if ret:
        print('Yes')
        for c in ret:
            print(c)
        '''
        vals = [A, B, C]
        for i in range(N):
            x = S[i]
            c = ret[i]
            for d in x:
                k = L.find(d)
                if d == c:
                    vals[k] += 1
                else:
                    vals[k] -= 1
            print(x, c)
            print(vals)
        '''
    else:
        print('No')

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, A, B, C, s)

if __name__ == '__main__':
    main()


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
string s;
  cin>>s;
  s.insert(s.begin()+4,' ');
  ce(s)
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = N << 1;

int h[N], e[M], ne[M], idx;
int q[N], n;
int temp[N], g;
int res[N];

void add(int a, int b) {
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

int b_s(int l, int r, int x) {
	while(l < r) {
		int mid = l + r >> 1;
		if(q[temp[mid]] >= x) r = mid;
		else l = mid + 1;
	}
	return l;
}

void dfs(int u, int fa) {
	for(int i = h[u]; i != -1; i = ne[i]) {
		int v = e[i];
		if(v == fa) continue;
		
		int flag = 0, prep = 0, prev = 0;
		if(q[temp[g]] < q[v]) {
			flag = 1;
			temp[++g] = v;
		}
		else if(q[v] <= q[temp[g]]) {
			int t = b_s(1, g, q[v]);
			flag = 2, prep = t, prev = temp[t];
			temp[t] = v; 
		}
		res[v] = g;
		dfs(v, u);
		if(flag == 1) temp[g--] = 0;
		else if(flag == 2) {
			temp[prep] = prev;
		}
	}
}

void solve() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &q[i]);
	
	for(int i = 1; i < n; i++) {
		int a, b; scanf("%d%d", &a, &b);
		add(a, b), add(b, a); 
	}
	
	res[1] = 1;
	temp[++g] = 1;
	dfs(1, 0);
	for(int i = 1; i <= n; i++) printf("%d\n", res[i]);
}

int main()
{
	int T = 1;
	//scanf("%d", &T);
	
	while(T--) {
		memset(h, -1, sizeof h); idx = 0;
		solve();
	}
}

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


int main() {
	int N, K;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int l, r;
		cin >> l >> r;
		ans += (r - l + 1);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  long long n,t; cin >>n>>t;
  vector<long long>a(n);
  for(long long i=0;i<n;i++)cin>>a[i];
  long long sum=0;
  long long tmp=t;
  for(long long i=1;i<n;i++){
    if(a[i]>a[i-1]+t){
      sum+=t;
    }else{
      sum+=a[i]-a[i-1];
    }
  }
  cout<<sum+t<<endl;
  return 0;
}

Measured memory_bytes: 1792
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

string N;
int K;
int DP[110][2][5];

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

	cin >> N >> K;

	DP[0][0][0] = 1;
	rep(i, 0, SZ(N))
	{
		rep(j, 0, 10)
		{
			if (j > N[i] - '0')
			{
				DP[i + 1][1][1] += DP[i][1][0];
				DP[i + 1][1][2] += DP[i][1][1];
				DP[i + 1][1][3] += DP[i][1][2];
			}
			else if (j == N[i] - '0')
			{
				if (j == 0)
				{
					DP[i + 1][1][0] += DP[i][1][0];
					DP[i + 1][1][1] += DP[i][1][1];
					DP[i + 1][1][2] += DP[i][1][2];
					DP[i + 1][1][3] += DP[i][1][3];
					DP[i + 1][0][0] += DP[i][0][0];
					DP[i + 1][0][1] += DP[i][0][1];
					DP[i + 1][0][2] += DP[i][0][2];
					DP[i + 1][0][3] += DP[i][0][3];
				}
				else
				{
					DP[i + 1][1][1] += DP[i][1][0];
					DP[i + 1][1][2] += DP[i][1][1];
					DP[i + 1][1][3] += DP[i][1][2];
					DP[i + 1][0][1] += DP[i][0][0];
					DP[i + 1][0][2] += DP[i][0][1];
					DP[i + 1][0][3] += DP[i][0][2];
				}
			}
			else
			{
				if (j == 0)
				{
					DP[i + 1][1][0] += DP[i][1][0];
					DP[i + 1][1][1] += DP[i][1][1];
					DP[i + 1][1][2] += DP[i][1][2];
					DP[i + 1][1][3] += DP[i][1][3];
					DP[i + 1][1][0] += DP[i][0][0];
					DP[i + 1][1][1] += DP[i][0][1];
					DP[i + 1][1][2] += DP[i][0][2];
					DP[i + 1][1][3] += DP[i][0][3];
				}
				else
				{
					DP[i + 1][1][1] += DP[i][1][0];
					DP[i + 1][1][2] += DP[i][1][1];
					DP[i + 1][1][3] += DP[i][1][2];
					DP[i + 1][1][1] += DP[i][0][0];
					DP[i + 1][1][2] += DP[i][0][1];
					DP[i + 1][1][3] += DP[i][0][2];
				}
			}
		}
	}

	cout << DP[SZ(N)][0][K] + DP[SZ(N)][1][K] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int ll;
int prime(ll n)
{
    for (int i = 2; (ll)i * i <= n; i++)
    {
        if (n % i == 0)
            return 0;
    }
    return 1;
}
int main()
{
    ll n;
    cin >> n;
  
        ll a, b;
        int temp = sqrt(n);
        for (int i = temp; i >= 1; i--)
        {
            if (n % i == 0)
            {
                a = i;
                b = n / i;
                break;
            }
        }
        cout << a + b - 2 << endl;
    
    return 0;
}


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

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

    int n, count = 0;
    string s;
    cin >> n >> s;
    rep(i, n - 2)
    {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C')
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool flg[101];
int main()
{
    int x, n;
    cin >> x >> n;
    int a;
    for (register int i = 0; i < n; i++)
    {
        cin >> a;
        flg[a] = true;
    }
    int diff = 0;
    while (true)
    {
        if (!flg[x - diff])
        {
            cout << x - diff << endl;
            return 0;
        }
        if (!flg[x + diff])
        {
            cout << x + diff << endl;
            return 0;
        }
        diff++;
    }
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	a := nextLine()
	r := rune(a[0])

	if unicode.IsUpper(r) {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}
}


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

signed main(void)
{
	int n, cnt;
	cin >> n;
	vector<int> a(n);
	cnt = 0;
	rep(i, n) 
	{
		cin >> a[i];
		if (a[i] % 2 != 0)
			cnt++;
	}
	if (cnt % 2 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl; 
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, p[10], q[10];
    vector<int> r;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) cin >> q[i];
    for (int i = 0; i < n; i++) r.push_back(i + 1);

    int x = 0, y = 0;
    bool ok;
    do {
        ok = 1;
        for (int i = 0; i < n; i++) {
            if (r[i] != p[i]) {
                ok = 0;
                break;
            }
        }
        if (ok) break;
        x++;
    } while (next_permutation(all(r)));
    sort(all(r));
    do {
        ok = 1;
        for (int i = 0; i < n; i++) {
            if (r[i] != q[i]) {
                ok = 0;
                break;
            }
        }
        if (ok) break;
        y++;
    } while (next_permutation(all(r)));
    
    cout << abs(x - y) << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
int L[N], R[N], n, mark[N], ans[N];
int head[N], nex[N<<1], to[N<<1], size;
void add(int u, int v){
    nex[++size] = head[u];
    to[size] = v;
    head[u] = size;
}
void dfs(int u, int fa){
    for(int i = head[u];i;i = nex[i]){
        int v = to[i];
        if(v == fa)continue;
        dfs(v, u);
        if(mark[v] == -1)continue;
        if(mark[u] == -1)mark[u] = mark[v] ^ 1;
        else{
            if((mark[v] ^ 1) != mark[u]){
                puts("No");
                exit(0);
            }
        }
        L[u] = max(L[u], L[v] - 1);
        R[u] = min(R[u], R[v] + 1);
    }
    if(L[u] > R[u]){
        puts("No");
        exit(0);
    }
    if(ans[u] != ans[0]){
        if(mark[u] == -1)mark[u] = ans[u] & 1;
        if(L[u] > ans[u] || R[u] < ans[u] || (ans[u] & 1) != mark[u]){
            puts("No");
            exit(0);
        }
        L[u] = R[u] = ans[u];
    }
}
void get(int u, int fa){
    //printf("u=%d ans[u]=%d ans0=%d\n", u, ans[u], ans[0]);
    if(ans[u] == ans[0]){
        if(ans[fa] + 1 >= L[u] && ans[fa] + 1 <= R[u])ans[u] = ans[fa] + 1;
        else if(ans[fa] - 1 >= L[u] && ans[fa] - 1 <= R[u]) ans[u] = ans[fa] - 1;
        else {
            puts("No"); exit(0);
        }
        //printf("u=%d ans=%d\n", u, ans[u]);
    }
    //puts("XBX");
    for(int i = head[u];i;i = nex[i]){
        int v = to[i];
        //printf("u=%d v=%d fa=%d\n", u, v, fa);
        if(v == fa)continue;
        get(v, u);
    }
}
int main(){
  //  freopen("arc063e.in", "r", stdin);
    cin>>n;
    int u, v;
    for(int i = 1;i < n; i++){
        scanf("%d%d", &u, &v);
        add(u, v); add(v, u);
    }
    int k;
    scanf("%d", &k);
    memset(L, -127, sizeof(L));
    memset(R, 127, sizeof(R));
    memset(ans, -127, sizeof(ans));
    memset(mark, -1, sizeof(mark));
    for(int i = 1;i <= k; i++){
        scanf("%d", &u);
        scanf("%d", &ans[u]);
        mark[u] = ans[u] & 1;
    }
    dfs(u, u);
    get(u, u);
    puts("Yes");
    for(int i = 1;i <= n; i++){
        //printf("i=%d L=%d R=%d ans=%d mark=%d\n", i, L[i], R[i], ans[i], mark[i]);
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(){
	 int a,b;

	cin >> a >> b ;

	int x = a+b;
	int y = x%2;
	int z = x/2;

	if (y == 0){
		cout << z << endl;
	}
	else{
		cout << z+1<< endl;
	}

	}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
tmp=[a[0]]
ans=1000
for i in range(n):
  if type(tmp[-1])==int:
    if a[i]>tmp[-1]:
      tmp[-1]=[tmp[-1],a[i]]
    else:
      tmp[-1]=a[i]
  else:
    if a[i]<tmp[-1][1]:
      tmp.append(a[i])
    else:
      tmp[-1][1]=a[i]
if type(tmp[-1])==int:
  tmp.pop(-1)
for i in tmp:
  ans+=(ans//i[0])*(i[1]-i[0])
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define int long long
using namespace std;

template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};

using modint=ModInt<1000000007>;
vector<modint> fact(1000000+10);
modint nCr(int n,int r){
	return fact[n]/(fact[r]*fact[n-r]);
}

signed main(){
	fact[0]=1;
	for(int i=1;i<1000000+1;i++){
		fact[i]=i;
		fact[i]*=fact[i-1];
	}

	int X,Y;
	cin>>X>>Y;
	int n=-X+2*Y,m=2*X-Y;
	modint ans=0;
	if(n<0 || m<0 || n%3!=0 || m%3!=0)ans=0;
	else{
		n/=3;m/=3;
		ans=nCr(n+m,n);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
s = gets.chomp.split("")
long = s.size
ans = 0
arr = []
(0..long-1).each do |i|
    j = 0
    count = 0
    while true
        #p j
        #p long -1
        if s[i] == s[j]
            count += 1
        end
        if j >= 3
            arr << count
             break
        end
        j += 1
    end
end
ans = 0
    (1..3).each do |i|
      if arr[i] == arr[i-1] && arr.inject(:+) == 8
        ans += 1
      end

    
    end
    if ans >= 3
        puts "Yes"
    else
        puts "No"
    end

Measured memory_bytes: 14288
//lyt

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#define pi acos(-1.0)

using namespace std;


int main()
{
    char s[20]="CODEFESTIVAL2016";
    char g[20];
    scanf("%s",g);
    int ans=0;
    for(int i=0;i<16;i++)
        if(s[i]!=g[i])
        ans++;
    printf("%d\n",ans);
    
    return 0;
}

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

int main(void) {
	
	int A, B, C;
	cin >> A >> B >> C;
	int M = A;
	
	if(M < B) {
		M = B;
	}
	if(M < C) {
		M = C;
	}
	
	int d = (M - A)+(M - B)+(M - C);
	int ans;
	if(d%2) {
		ans = d/2 + 2;
	} else {
		ans = d/2;
	}

	cout << ans;
	
	return 0;
}

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

using namespace std;

long long int gcd(int a, int b)
{
  if (a < b) 
  {
    int tmp;
    tmp = a;
    a   = b;
    b   = tmp;
  }

  int r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}


long long int lcm(long long int a, long long int b)
{
  return a * b / gcd(a, b);
}

void snack()
{
  long long int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << "\n";
}


bool is_prime(int n)
{
  if (n <= 1) return false;
  if (n == 2) return true;

  if (n % 2 == 0)return false;

  for (int i = 3; i * i <= n; i += 2)
  {
    if (n % i == 0) return false;
  }

  return true;
}


void next_prime()
{
  int x;
  cin >> x;

  int prime = x;
  while (!is_prime(prime)) prime++;

  cout << prime << "\n";
}


int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0; i--) fact *= i;
  return fact;
}


int calc_order(int n, vector<int> x)
{
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    cnt += (x[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (x[j] > x[i]) x[j]--;
    }
  }
  return cnt;
}


void count_order()
{
  int n;
  cin >> n;

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

  int p_cnt = 0, q_cnt = 0;
  p_cnt = calc_order(n, p);
  q_cnt = calc_order(n, q);

  cout << abs(p_cnt - q_cnt);
}




int main()
{
  snack();
  //next_prime();
  //count_order();
}


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

int main()
{
    string s;
    cin >> s;
    int c = 0;
    for(int i=0; i<3; i++)
    {
        if(s[i] == '1') c++;
    }
    cout << c << endl;
    return 0;
}


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

void solve(std::string S)
{
    if (S == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;

int n,w;
int dp[3001][3001];
pair<int,int> indexx[3001][3001];

void solve(){
    string a,b;
    cin >> a;
    cin >> b;

    for(int i = 0;i <= a.length();i++){
        for(int j = 0;j <= b.length();j++){
            dp[i][j] = 0;
            indexx[i][j] = make_pair(-1,-1);
        }
    }
    for(int i = 0;i < a.length();i++){
        for(int j = 0;j < b.length();j++){
            if(a[i] == b[j]){
                dp[i+1][j+1] = dp[i][j]+1;
                indexx[i+1][j+1] = make_pair(i,j);
            }
            else{
                if(dp[i][j+1] > dp[i+1][j]){
                    dp[i+1][j+1] = dp[i][j+1];
                    indexx[i+1][j+1] = indexx[i][j+1];
                }
                else{
                    dp[i+1][j+1] = dp[i+1][j];
                    indexx[i+1][j+1] = indexx[i+1][j];
                }
            }
        }
    }
    string ans = "";
    pair<int,int> rev = indexx[a.length()][b.length()];
    while(rev.first >= 0){
        ans = a[rev.first] + ans;
        rev = indexx[rev.first][rev.second];
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 105856
#include<iostream>
using namespace std;
int main()
{
	int n,d,x;
	int re,a;
	while(cin>>n>>d>>x)
	{
		re=0;
		while(n--)
		{
			cin>>a;
			int i=1;
			while(i<=d)
			{
				re++;
				i+=a;
			 } 
		}
		cout<<re+x<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  int n,l;
  int u=0;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    u += l+i;
  }
  if(l>0){
    cout << u-l << endl;
  }
  else if(l+n-1>0){
    cout << u << endl;
  }
  else cout <<u-(n+l-1) << endl; 
}

Measured memory_bytes: 384
using System;
class aoj{
	static void Main(){
		string []a=Console.ReadLine().Split(' ');
		int b=int.Parse(a[0]);
		int c=int.Parse(a[1]);
		if(b<c){
			Console.WriteLine("a < b");
		}
		else if(b>c){
			Console.WriteLine("a > b");
		}
		else{
			Console.WriteLine("a == b");
		}
	}
}

Measured memory_bytes: 8820
(let ((n (read))
      (ans 0))
     (loop for i from 1 upto n
           do (if (or (and (< 0 i) (< i 10)) (and (< 99 i) (< i 1000)) (and (< 9999 i) (< i 100000))) (incf ans)))
     (princ ans))

Measured memory_bytes: 10856
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    int x=a[0]*10+a[1]+a[2],y=a[0]*10+a[2]+a[1];
    cout << (x>=y?x:y) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N];
ll sum[N],dp[N][3];
void setdp(int x,int y,ll v)
{
    if(y==x/2) dp[x][1]=max(dp[x][1],v);
    else if(y==x/2-1) dp[x][0]=max(dp[x][0],v);
    else if(y==x/2+1) dp[x][2]=max(dp[x][2],v);
}
ll getdp(int x,int y)
{
    if(y==x/2) return dp[x][1];
    else if(y==x/2-1) return dp[x][0];
    else if(y==x/2+1) return dp[x][2];
    return -inf;
}
int main()
{
    memset(dp,-inf,sizeof(dp));
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=-inf;
    setdp(0,0,0);
    setdp(1,1,a[1]);
    setdp(1,0,0);
    for(int i=2;i<=n;i++)
        for(int j=i/2-1;j<=i/2+1;j++)
        setdp(i,j,getdp(i-2,j-1)+a[i]),setdp(i,j,getdp(i-1,j));
    printf("%lld\n",getdp(n,n/2));
}


Measured memory_bytes: 9228
//omajinai c++ atcoder
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<cmath>
#include<iomanip>
#include<type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
#define yes() printf("Yes\n")
#define no() printf("No\n")
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    int sum=0;
    rep(i,m){
        cin>>a[i];
    sum+=a[i];
    }

    if(n-sum>=0){
        cout<<n-sum;
    }
    else{
        cout<<-1;

    }
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    
    vector<pair<ll,ll>> a(n);
    
    rep(i, n) cin >> a[i].first >> a[i].second;
    
    sort(a.begin(),a.end());
    
    ll i = 0;
    ll j = 0;
    ll cnt = 0;
    ll ans = 0;
    
    while(true){
        ans += a[i].first;
        j++;
        cnt++;
        if(cnt == m) break;
        if(j<a[i].second)continue;
        else{
            i++;
            j = 0;
        }
        
    }
    cout << ans;
    
    
}


Measured memory_bytes: 1792
import numpy as np
l,r = map(int, input().split())
if ((l//2019)<(r//2019)):
  print(0)
else:
  arr1 = np.array(range(l,r+1))
  arr2 = np.array(range(l,r+1)).reshape(r-l+1,1)
  arr = arr1*arr2%2019 + (np.identity(r-l+1)*2019)
  print(int(np.min(arr)))

Measured memory_bytes: 107788
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int K, S;
  ci(K, S);
  int a = 0;
  rep(i, K + 1){
    rep(j, K + 1){
      if(S <= i + j + K && i + j <= S){
        a++;
      }
    }
  }
  co(a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int q=0,a,b,d=0;
  string c;
  cin>>a>>c;
  for(int i=0;i<a;i++){
	if(c[i]=='I') q++;
    else q--;
    d=max(d,q);
  }
  cout<<d<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
	string a;
    cin >> a;
    string b = "Good";

    rep(i,3){
        if(a[i] == a[i+1]){
            b = "Bad";
        } 
    }

    cout << b <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){

    int n,a,b,c,d,i;
    int a2,c2,price_x,price_y;

      scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);

      if(n%a==0) a2 = n/a;
      else a2 = n/a+1;
      price_x = a2*b;

      if(n%c==0) c2=n/c;
      else c2=n/c+1;
      price_y = c2*d;

      if(price_x < price_y) printf("%d\n",price_x);
      else printf("%d\n",price_y);

     return 0;

}
        


Measured memory_bytes: 2108
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
typedef long long int LL;
typedef unsigned long long int ULL;
int main()
{
    fast;
    int i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a;
        rep(i,n)
        {
           vp(a,x);
        }
        sort(all(a));
        cout<<a[n-1]-a[0]<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string set = "abcdefghijklmnopqrstuvwxyz";
    string ret;
    cin >> n;
    --n;
    while (n >= 26)
    {
        ret += set[n % 26];
        n /= 26;
        --n;
    }
    ret += set[n];
    reverse(all(ret));
    cout << ret << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

int main() {
    int N;
    cin >> N;
    vector<Bint> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    Bint ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= A[i];
        if (ans > (Bint)1e18) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6496
#include <iostream>
using namespace std;
int main()
{
	int n, a, s, i;
	while (cin >> n && n)
	{
		for (i = s = 0; i < (int)((double)n/4.0+0.5); i++)
		{
			cin >> a;
			s += a;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci A(N);
    REP(i,N) cin >> A[i];
    int ans = 0;
    for(int i = 0; i < N-1; i++) {
        for(int j = i+1; j < N; j++) {
            chmax(ans,abs(A[i]-A[j]));
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
int N, M, S[2010], T[2010];
int dp[2010][2010], SUM[2010][2010];
void solve()
{
    FOR(i, 0, N + 1)
    {
        SUM[i][0] = 1;
    }
    FOR(i, 0, M + 1)
    {
        SUM[0][i] = 1;
    }
    FOR(i, 1, N + 1)
    {
        FOR(j, 1, M + 1)
        {
            if (S[i] == T[j]) {
                dp[i][j] = SUM[i - 1][j - 1];
            }
            SUM[i][j] = SUM[i][j - 1] + SUM[i - 1][j] - SUM[i - 1][j - 1] + dp[i][j];
            SUM[i][j] %= MOD;
        }
    }
    int ans;
    ans = (SUM[N][M] + MOD) % MOD;
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(i, 1, N + 1)
    {
        cin >> S[i];
    }
    FOR(i, 1, M + 1)
    {
        cin >> T[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 63104
def read_data():
  n=input()
  x=[]
  for i in range(10):
    x.append(map(int,raw_input().split()))
  return n, x

def is_area3(x,y):
  if x>7 or y>5: return False
  for dx in [0,1,2,1,0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
      
def is_area2(x,y):
  if x>7 or y>7: return False
  for dy in [0,1,2]:
    A = P[y+dy][x:x+3]
    if A.count(0)>0: return False
  return True

def is_area1(x,y):
  if x>8 or y>7: return False
  for dx in [0, 1, 0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True

def ink(x,y,s,m):
  global P
  for dy,dx in [[0,0],[1,0],[-1,0],[0,1],[0,-1]]:
    P[y+dy][x+dx]+=m
  if s==1: return
  for dy,dx in [[1,1],[1,-1],[-1,1],[-1,-1]]:
    P[y+dy][x+dx]+=m
  if s==2: return
  for dy,dx in [[2,0],[-2,0],[0,2],[0,-2]]:
    P[y+dy][x+dx]+=m
  return

drops, P = read_data()
M=[]
i=-1
step =3
while i<99:
  i+=1
  y = i / 10
  x = i % 10
  if P[y][x]==0: continue

  if step==3:
    while is_area3(x,y):
      M.append([x,y,3])
      ink(x,y+2,3,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 2

  if step==2:
    while is_area2(x,y):
      M.append([x,y,2])
      ink(x+1,y+1,2,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 1

  if step==1:
    while is_area1(x,y):
      M.append([x,y,1])
      ink(x,y+1,1,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 0

  dx=0
  dy=1
  if step==0 and len(M)>0:
    x,y,tmp = M.pop()
    if tmp==3: dy=2
    elif tmp==2: dx=1
    ink(x+dx,y+dy,tmp,1)
    i = y*10+x-1
    step = tmp-1
  else: break
if drops <=12 and len(M)==drops:
  for x,y,s in M:
    dx=0
    dy=1
    if s==3: dy=2
    elif s==2: dx=1
    print x+dx,y+dy,s

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

int main(){
  int a, b;
  cin >> a;
  cin >> b;
  
  if((a * b) % 2 == 0){
  	cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int a , b , x;
  cin >> a >> b >> x;
  if(a == 0) {
    cout << (b/x) + 1 << '\n';
    return 0;
  } 
  a--;
  int ans = (b / x ) - (a / x);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cstring>
using namespace std;

const int MAX_N = 100;
int values[MAX_N];

int main(){
	int n;
	while(scanf("%d", &n), n != 0){
		// target: 探す値, ans: 探索が終わるまでの比較回数
		int target, ans = 0;
		// 二分探索の範囲
		int l = -1, r = n;
		
		memset(values, 0, sizeof(values));
		for (int i = 0; i < n; i++) {
			scanf("%d", &values[i]);
		}
		scanf("%d", &target);
		
		while(r - l > 1) {
			ans++;
			int m = (l + r) / 2;
			if (values[m] == target) break;
			else if (values[m] < target) l = m;
			else r = m;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1028