akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	int A[200010]; 
	cin >> N; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	int C[200010] = {}; // 文字
	int L[200010] = {}; // 長さ
	int ok = N; int ng = 0; 
	while(ok - ng > 1){
		C[0] = 0; L[0] = A[0]; 
		bool possible = true; 
		int mid = (ok + ng) / 2; 
		int it = 0; 
		for(int i = 1; i < N; i++){
			if(A[i] > A[i-1]){
				if(C[it] == 0) L[it] += A[i] - A[i-1]; 
				else{
					it++; C[it] = 0; L[it] = A[i] - A[i-1]; 
				}
			}
			else if(A[i] == A[i-1]){
				if(L[it] == 1) C[it] ++; 
				else{
					L[it]--; it++; L[it] = 1; C[it] = C[it-1] + 1; 
				} 
				if(C[it] >= mid){
					int del = 0; 
					while(C[it] >= mid - 1){
						del += L[it]; it--; 
						if(it < 0){
							possible = false; break; 
						}
					}
					if(L[it] == 1){
						C[it]++; it++; L[it] = del; C[it] = 0; 
					}
					else{
						L[it]--; it++; C[it] = C[it-1] + 1; 
						L[it] = 1; it++; C[it] = 0; L[it] = del; 
					}
				}
			}
			else if(A[i] < A[i-1]){
				int dec = A[i-1] - A[i]; 
				while(it >= 0 && dec >= 0){
					dec -= L[it]; it--; 
				}
				it++; dec += L[it]; 
				if(dec + 1 == L[it]){
					C[it] ++; L[it] = 1;  
				}
				else{
					L[it] -= dec + 1; it++; 
					L[it] = 1; C[it] = C[it-1] + 1;
				}
				if(C[it] >= mid){
					int del = 0; 
					while(C[it] >= mid - 1){
						del += L[it]; it--; 
						if(it < 0){
							possible = false; break; 
						}
					}
					if(L[it] == 1){
						C[it]++; it++; L[it] = del; C[it] = 0; 
					}
					else{
						L[it]--; it++; C[it] = C[it-1] + 1; 
						L[it] = 1; it++; C[it] = 0; L[it] = del; 
					}
				}
			}
		}
		if(possible) ok = mid; 
		else ng = mid; 
	}
	cout << ok << endl; 
}

Measured memory_bytes: 2560
def main():
    N = int(input())
    a_s = list(map(int,input().split()))
    a_s.sort()
    a_s.reverse()
    Alice,Bob = 0,0
    for i,a in enumerate(a_s):
        if i % 2 == 0:
            Alice += a
        else:
            Bob += a
            
    print(Alice-Bob)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll a,b;
	cin>>a>>b;
	if(a>=10||b>=10)cout<<-1<<endl;
	else cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
def examB():
    N = I(); P = [I() for _ in range(N)]
    d = defaultdict(int)
    for i in range(N):
        d[P[i]] = d[P[i]-1]+1
    ans = N-max(d.values())
    d = defaultdict(int)
    for i in range(N-1,-1,-1):
        d[P[i]] = d[P[i]+1]+1
    ans = min(ans,N-max(d.values()))
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //


// --------- library end - //



int main(){

  ll N = il();
  vector<pll> xys(N);

  ll maximumxplusy = -INF;
  ll minimumxplusy = INF;

  ll maximumxminusy = -INF;
  ll minimumxminusy = INF;

  rep(i, N){
    ll x, y;
    cin >> x >> y;
    xys[i] = m_p(x, y);

    chmax(maximumxplusy, x+y);
    chmax(maximumxminusy, x-y);
    chmin(minimumxplusy, x+y);
    chmin(minimumxminusy, x-y);
  }

  ll ans = -INF;
  chmax(ans, maximumxplusy - minimumxplusy);
  chmax(ans, maximumxminusy - minimumxminusy);

  cout << ans << endk;



}



Measured memory_bytes: 6440
#002
N = int(input())
T = [int(i) for i in input().split(" ")]
M = int(input())
P=[i for i in range(M)]
X=[i for i in range(M)]
for i in range(M):
    P[i],X[i]= [int(j) for j in input().split(" ")]
for i in range(M):
    temp = T[P[i]-1]
    T[P[i]-1]=X[i]
    print(sum(T))
    T[P[i]-1] = temp

Measured memory_bytes: 3064
N = gets.chomp.to_i
a = gets.chomp.split(' ').map{ |e| e.to_i }

allNums = 3**N
onlyOddNums = 1
a.each do |num|
  if num % 2 == 0
    onlyOddNums *= 2
  end
end

puts allNums - onlyOddNums

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}


const int maxn = 1e5+5, mod = 1e9+7;

int add(int a, int b){return (a+b)%mod;}
int mul(ll a, ll b){return (a*b)%ll(mod);}
int n, x, y, dp[maxn][2];
vector<int> vs[maxn];

int dfs(int v, int p, bool col){
	if (dp[v][col] != -1) return dp[v][col];
	int ret = dp[v][col];
	ret = 1;
	for(int e: vs[v]) if (e != p){
		int t = dfs(e, v, 1);
		if (col) t = add(t, dfs(e, v, 0));
		ret = mul(ret, t);
	}
	return dp[v][col] = ret;
}

int main(){
	memset(dp,-1, sizeof(dp));
	scanf("%d", &n);
	for(int i = 0; i<n-1; i++){
		scanf("%d %d", &x, &y);
		vs[--x].push_back(--y);
		vs[y].push_back(x);
	}
	dfs(0, -1, 1);
	dfs(0, -1, 0);
	printf("%d\n", add(dp[0][0], dp[0][1]));
	return 0;
}


Measured memory_bytes: 14848
N,A,B,C,D=map(int,input().split())
S=input()

if C<D:
  if B<C:
    d=0
    if "##" in S[A-1:D]:
      d=1
    print("Yes" if d==0 else "No")
  else:
    d=0
    if "##" in S[A-1:C]:
      d=1
    if "##" in S[B-1:D]:
      d=1
    print("Yes" if d==0 else "No") 
else:
  d=0
  if "##" in S[A-1:C]:
    d=1
  if "..." not in S[B-2:D+1]:
    d=1
  print("Yes" if d==0 else "No") 

Measured memory_bytes: 40560
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  if(2*a<=b){
  out(a+((b-2*a)/4));
  }
  else{
  out(b/2);
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int n;
long long t=1;
int main()
{
	auto lcm=[](long long a,long long b){
		return a/__gcd(a,b)*b;
	};
	cin>>n;
	for (int i=0;i<n;++i)
	{
		long long x;
		cin>>x;
		t=lcm(t,x);
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars,
    }
    let mut s = s;
    let mut ss = String::new();
    for i in 0..n {
        if i + 1 == k {
            if s[i] == 'A' {
                ss.push('a');
             } else if s[i]=='C' 
             {ss.push('c');} else {
                 ss.push('b');
             }
        } else {
            ss.push(s[i]);
        }
    }
    println!("{}", ss);
}

Measured memory_bytes: 4352
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i < N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    elif i*i == N:
        divisor.append(i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i < (N-1):
        if (N - 1)% i == 0:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    elif i*i == (N-1):
        yakusuuu.append(i)
    else:
        break

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

M = N

for K in divisor:
    #print(K)
    while M % K == 0:
        M = M//K

    

    if M == 1:
        ans += 1
        
    else:
        M =  M % K
        if M == 1:
            ans += 1 
    
    M = N
        




print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define usi unsigned short int
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

const int MIN = 1e3 + 2;
const int MXN = 1e6 + 3;
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 15;
const double EPS = 1e-9;

int n;
set <int> s;
int x;

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> x;
		s.insert(x);
	}                                
	if ((n - (int)s.size()) % 2){
		cout << (int)s.size() - 1;
	}
	else {
		cout << (int)s.size();
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 100000000000000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

int main(){
  ll N;cin >> N;
  vector<ll> A(N),sum(N+1,0);
  rep(i,N){
    cin >> A[i];
    sum[i+1] = A[i] + sum[i];
  }
  ll ans = INF,mid = 0,left = 0,right = 0;
  ll l = 1,r = N+1;
  while(r-l > 1){
    ll M = (r+l)/2;
    if(sum[M] > sum[N] - sum[M-1]){
      r = M;
    }else{
      l = M;
    }
  }
  mid = l;
  mid = 0;
  FOR(i,1,N){
    ll l = 1,r = mid + i;
    if(r <= 1) continue;
    while(r-l > 1){
      ll M = (r+l)/2;
      if(sum[M] > sum[mid+i] - sum[M-1]){
        r = M;
      }else{
        l = M;
      }
    }
    left = l;
    l = mid + i;r = N+1;
    if(l >= N) continue;
    while(r-l > 1){
      ll M = (r+l)/2;
       if(sum[M] - sum[mid+i] > sum[N] - sum[M-1]){
        r = M;
      }else{
        l = M;
      }
    }
    right = l;
    //cout << left << ' ' << mid + i << ' ' << right << endl;
    FOR(j,-2,3){
      FOR(k,-2,3){
        ll L = left+j;
        ll RI = right + k;
        ll MID = mid+i;
        if(1 <= L && L < MID && MID < RI && RI <= N){
          ll P,Q,R,S;
          //cout << L << ' ' << MID << ' ' << RI << endl;
          P = sum[L];Q = sum[MID] - sum[L];R = sum[RI] - sum[MID];S = sum[N] - sum[RI];
          //cout << P+Q+R+S << endl;
          ans = min(ans,max({P,Q,R,S})-min({P,Q,R,S}));
        }else{
          continue;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(){
	int n, a, b;
	
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	
	int train = n*a;
	int taxi = b;
	
	if(train>taxi){
		printf("%d\n", taxi);
	}
	else{
		printf("%d\n", train);	
	}
	
	
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int sum = 0;
int lm = 0;
int temp;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        lm = max(temp, lm);
        sum += temp;
    }
    if (sum - 2 * lm > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc011/tasks/agc011_b

fun main() {
    agc011b()
}

fun agc011b() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }.sorted()
    var survive = 1
    var creature = a[0]
    for (i in 0 until n - 1) {
        if (creature * 2 >= a[i + 1]) {
            survive++
        } else {
            survive = 1
        }
        creature += a[i + 1]
    }
    println(survive)
}


Measured memory_bytes: 59492
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> P;

int n, m, p, q, r;
vector<P> data[2][3];

void calc(int t, int a, int b){
  int pos = 2, cnt = 0, nex = 1 - t, id = 0;
  int c[2] = {a, b};
  
  for(int i=0;i<3;i++) data[nex][i].clear();
  for(int i=0;i<3;i++){
    for(int j=0;j<data[t][i].size();j++){
      if(id == 2) data[nex][pos].push_back(data[t][i][j]);
      else{
        int val = cnt + data[t][i][j].second - data[t][i][j].first + 1;
        if(id == 0 && c[0] < val && c[1] < val){
          data[nex][pos].push_back(P(data[t][i][j].first, data[t][i][j].second - (val - c[id])));
          pos--;
          id++;
          data[nex][pos].push_back(P(data[t][i][j].second - (val - c[id-1]) + 1, data[t][i][j].second - (val - c[id])));
          pos--;
          id++;
          data[nex][pos].push_back(P(data[t][i][j].second - (val - c[id-1]) + 1, data[t][i][j].second));
        }else if(val < c[id]){
          data[nex][pos].push_back(data[t][i][j]);
        }else if(val == c[id]){
          data[nex][pos].push_back(data[t][i][j]);
          pos--;
          id++;
        }else if(val > c[id]){
          int tmp = val - c[id];
          data[nex][pos].push_back(P(data[t][i][j].first, data[t][i][j].second - tmp));
          pos--;
          id++;
          data[nex][pos].push_back(P(data[t][i][j].second - tmp + 1, data[t][i][j].second));
        }
      }
      cnt += data[t][i][j].second - data[t][i][j].first + 1;
    }
  }
}

main(){
  while(cin >> n && n){
    for(int i=0;i<2;i++) for(int j=0;j<3;j++) data[i][j].clear();
    cin >> m >> p >> q >> r;
    data[0][0].push_back(P(1, n));
    for(int i=0;i<m;i++){
      int a, b;
      cin >> a >> b;
      calc(i%2, a, b);
    }
    int ans = 0;
    int cnt = 0;
    for(int i=0;i<3;i++){
      for(int j=0;j<data[m%2][i].size();j++){
        P tmp = data[m%2][i][j];
        int len = tmp.second - tmp.first + 1;
        if(cnt <= p && q <= cnt + len){
          int v1 = tmp.first + (p - cnt - 1);
          int v2 = r - (v1 - 1);
          ans += max(0, min(v2, q - p + 1));
        }else if(p <= cnt && cnt + len <= q){
          int v1 = tmp.first - 1;
          int v2 = r - v1;
          ans += max(0, min(v2, len));
        }else if(cnt <= p && p <= cnt + len){
          int v1 = tmp.first + (p - cnt - 1); 
          int v2 = r - (v1 - 1);
          ans += max(0, min(v2, len - (p - cnt - 1)));
        }else if(cnt <= q && q <= cnt + len){
          int v1 = tmp.first - 1;
          int v2 = r - v1;
          ans += max(0, min(v2, q - cnt));
        }
        cnt += len;
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long

using namespace std;


int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    bool flag = false;
    for(int i = 1; i < N; i++){
        if(S[i] != S[i - 1]){
            ans++;
        }
    }
        
    
    cout << ans  + 1<< endl;
}

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

bool dp[10200];

int main() {
    double a, b, x, X, th;
    cin >> a >> b >> x;

    X = x / (a * a);
    if (X < b/2) th = a * b * b / (2 * x);
    else th = 2 * (a * a * b - x) / (a * a * a);

    cout << fixed << setprecision(7) << atan(th) / M_PI * 180 << endl;

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

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


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        int time = 0;
        long value = 100;

        while(X > value){
            value = (long)(value*1.01);
            time++;
        }

        System.out.println(time);
    }
}


Measured memory_bytes: 35744
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
b = sorted(a,reverse=True)
if b[0]==b[1]:
	e = 0
else:
	e = 1
c = b[0]
d = b[1]
if e == 0:
	for j in range(n):
		print(c)
else:
	for j in range(n):
		if(a[j] == c):
			print(d)
		else:
			print(c)

Measured memory_bytes: 14112
def main():
    import collections

    n = int(input())
    s = list(input())

    cnt_s = []

    for i in range(n):
        cnt_l = collections.Counter(s[:i])
        cnt_r = collections.Counter(s[i:])
        cnt = 0
        for key in dict(collections.Counter(cnt_l)):
            if key in dict(collections.Counter(cnt_r)):
                cnt += 1
        cnt_s.append(cnt)

    print(max(cnt_s))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c && a % 2 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    while(true)
    {
        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
        {
            cout << ans << endl;
            return 0;
        }
        ll x = (a+b)/2;
        ll y = (b+c)/2;
        ll z = (c+a)/2;
        a = x;
        b = y;
        c = z;
        ans++;
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
pii b[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)b[i]=pii(a[i],i);
  sort(b,b+n);
  int e2o,o2e;
  e2o=o2e=0;
  REP(i,n){
    if(i%2==0 && b[i].second%2==1){
      e2o++;
    }else if(i%2==1 && b[i].second%2==0){
      o2e++;
    }
  }
  assert(e2o==o2e);
  printf("%d\n",e2o);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int n;
  cin >> n;
  vector <vector <int64_t>> v(n, vector <int64_t>(3));
  rep(i, n) {
    rep(j, 3) {
      cin >> v.at(i).at(j);
    }
  }
  vector <vector <int64_t>> dp((int)pow(10, 5)+10, vector <int64_t>(3, 0));
  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (j != k) {
          chmax(dp.at(i+1).at(k), dp.at(i).at(j) + v.at(i).at(k));
        }
      }
    }
  }
  int64_t ans = 0;
  rep(i, 3) {
    chmax(ans, dp.at(n).at(i));
  }
  cout << ans << endl;
}

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

ll Q;
multiset<ll> all;
ll com, x, y;
ll ans, cnt;
int main(){
    cin >> Q;
    cin >> com >> x >> y;
    all.insert(x);
    ans = y;
    cnt++;
    auto mid = all.begin();
    for(int i = 0; i < Q - 1; i++){
        cin >> com;
        if(com == 1){
            cin >> x >> y;
            if(x >= *mid && cnt % 2 == 0){
                all.insert(x);
                mid++;
                ans += x - *mid;
            }
            else if(x < *mid && cnt % 2 == 1){
                all.insert(x);
                ans += *mid - x;
                mid--;
            }
            else if(x < *mid && cnt % 2 == 0){
                all.insert(x);
                ans += *mid - x;
            }
            else{
                ans += x - *mid;
                all.insert(x);
            }
            cnt++;
            ans += y;
        }else cout << *mid << " " << ans << endl;
    }
}


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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#define N_MAX 25
#define NIL -1
using namespace std;
//thik&solve easy 

int n;

class node{
public:
	int parent;
	int left_chld;
	int right_chld;
};

node BT[N_MAX+1];


void preorder(int u){
	int pos;
	cout <<" " <<u;

	if(BT[u].left_chld != NIL){
		pos = BT[u].left_chld;
		preorder(pos);
	}

	if(BT[u].right_chld != NIL){
		pos = BT[u].right_chld;
		preorder(pos);
	}
	
	return;
}

void inorder(int u){
	int pos;

	if(BT[u].left_chld != NIL){
		pos = BT[u].left_chld;
		inorder(pos);
	}
	cout <<" " <<u;

	if(BT[u].right_chld != NIL){
		pos = BT[u].right_chld;
		inorder(pos);
	}
	
	return;
}

void postorder(int u){
	int pos;

	if(BT[u].left_chld != NIL){
		pos = BT[u].left_chld;
		postorder(pos);
	}

	if(BT[u].right_chld != NIL){
		pos = BT[u].right_chld;
		postorder(pos);
	}
	cout <<" " <<u;
	
	return;
}

int main(){
	//初期化
	for(int i=0;i<N_MAX;i++){
		BT[i].parent = BT[i].left_chld = BT[i].right_chld = NIL;
	}
	//

	int id_tmp;
	int lchld_tmp;
	int rchld_tmp;
	int root;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%d",&id_tmp);
		scanf("%d",&lchld_tmp);
		scanf("%d",&rchld_tmp);

		BT[id_tmp].left_chld = lchld_tmp;
		BT[id_tmp].right_chld = rchld_tmp;

		BT[lchld_tmp].parent = BT[rchld_tmp].parent = id_tmp;
	}

	for(int i=0;i<n;i++){
		if(BT[i].parent == NIL){
			root = i;
			break;
		}
	}

	cout <<"Preorder" <<endl;
	preorder(root);
	cout <<endl;

	cout <<"Inorder" <<endl;
	inorder(root);
	cout <<endl;

	cout <<"Postorder" <<endl;
	postorder(root);
	cout <<endl;

}

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

int main(void){
  while(true){
    int n, r;
    cin >> n >> r;
    if(n == 0)
      break;

    vector<int> hana(n);
    for(int i=0; i<n; i++)
      hana[i] = n-i;

    for(int i=0; i<r; i++){
      int p, c;
      cin >> p >> c;

      vector<int> temp(p-1);
      for(int j=0; j<p-1; j++)
	temp[j] = hana[j];
      for(int j=0; j<c; j++)
	hana[j] = hana[j+p-1];
      for(int j=0; j<p-1; j++)
	hana[j+c] = temp[j];
    }

    cout << hana[0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3032
#include<stdio.h>

char s[52];

int main(void)
{
    int n,k,i;
  	scanf("%d %d",&n,&k);
    scanf("%s",&s[1]);
  	if(s[k]=='A')
      	s[k]='a';
  	else if(s[k]=='B')
      	s[k]='b';
  	else if(s[k]=='C')
      	s[k]='c';
  	for(i=1;i<=n;i++)
      	printf("%c",s[i]);
  	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int n;
int a[100005];
int l[100005], r[100005];

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

int main(void)
{
	cin >> n;
	for(int i = 1; i<= n; i++ ) cin >> a[i];
	
	for(int i = 1; i <= n; i++) l[i] = gcd(l[i-1], a[i]);
	for(int i = n; i >= 1; i--) r[i] = gcd(r[i+1], a[i]);
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, gcd(l[i-1], r[i+1]));
	}
	cout << ans << endl;
	return 0;
}


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

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int n;
	cin>>n;
	int mp[10][10];
	memset(mp , 0 , sizeof mp);

	for(int i = 1 ; i <= n ; ++i){

		string x = to_string(i);

		int a = x[0] - '0';
		reverse(x.begin(),x.end());

		int b = x[0] - '0';

		mp[a][b]++;
	}
	int ans = 0;
	for(int i = 1 ; i <= 9 ; ++i){

		for(int j = 1 ; j <= 9 ; ++j)
			ans += mp[i][j]*mp[j][i];
	}

	cout<<ans<<endl;
}


signed main(){
    
    int t;
    t = 1;
    //cin>>t;
    while(t--)
        solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  string s;
  cin>>s;
  int w;
  cin>>w;
  for(int i=0;i <s.size(); i+=w) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
// CODE FESTIVAL 2016 qual C
// E - 順列辞書 / Encyclopedia of Permutations

#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX_N 500000
#define MOD 1000000007LL
#define MAX_BIT_IDX MAX_N
using namespace std;

typedef long long int ll;


template <typename T>
class BIT {
public:
  T b[MAX_BIT_IDX + 1];
  int n;
private:
public:
  void init(int num);
  T sum(int i);
  void add(int i, T x);
private:
};

template <typename T>
void BIT<T>::init(int num) {
  n = num;
  for (int i = 0; i <= n; i++) {
    b[i] = 0;
  }
  return;
}

template <typename T>
T BIT<T>::sum(int i) {
  T s = 0;

  for (; i > 0; i -= i & -i) {
    s += b[i];
  }
  return s;
}

template <typename T>
void BIT<T>::add(int i, T x) {
  for (; i <= n; i += i & -i) {
    b[i] += x;
  }
  return;
}


int N, K;
int P[MAX_N];
int cnt_less[MAX_N + 1];
ll sum_unused, sum_cnt_more;
ll fac[MAX_N + 1];
BIT<int> bit;
ll ans;

int main() {

  ll t1, t2, cur_k;
  ll inv2 = (MOD + 1) / 2;

  scanf("%d", &N);
  fill(cnt_less, cnt_less + N, 1); cnt_less[0] = 0;
  fac[0] = 1;
  for (int i = 1; i <= N; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
  }
  bit.init(N);

  sum_unused = (ll)N * (N + 1) / 2 % MOD;
  for (int i = 0; i < N; i++) {
    scanf("%d", &P[i]);
    if (P[i] == 0) {
      K++;
    } else {
      cnt_less[P[i]] = 0;
      sum_unused = (sum_unused - P[i] + MOD) % MOD;
    }
  }
  for (int i = 1; i <= N; i++) {
    cnt_less[i] += cnt_less[i - 1];
  }

  cur_k = 0;
  sum_cnt_more = 0;
  ans = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] == 0) {
      t1 = (sum_unused * fac[K - 1] - fac[K] + MOD) % MOD;
      t2 = (sum_cnt_more * fac[K - 1] % MOD + cur_k * fac[K] % MOD * inv2 % MOD) % MOD;
      cur_k++;
    } else {
      t1 = (P[i] - 1) * fac[K] % MOD;
      t2 = ((ll)bit.sum(P[i]) * fac[K] % MOD + cur_k * cnt_less[P[i] - 1] % MOD * fac[max(K - 1, 0)] % MOD) % MOD;
      sum_cnt_more = (sum_cnt_more + K - cnt_less[P[i]]) % MOD;
      bit.add(P[i], 1);
    }
    ans = (ans + (t1 - t2 + MOD) % MOD * fac[N - 1 - i]) % MOD;
  }
  ans = (ans + fac[K]) % MOD;

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

  return 0;

}




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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int h, a;
    cin >> h >> a;

    int sum = 0;
    for (int i = 0; i < a; i++) {
        int tp;
        cin >> tp;

        sum += tp;
    }
    if (sum >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N;
Int A[500];
Int sum[500];
Int dp[500][500];

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        cin>>A[i];
        if(i > 0)
            sum[i] = sum[i-1]+A[i];
        else
            sum[i] = A[i];
        dp[i][i] = A[i];
    }

    for(int len = 2;len <= N;len++) {
        for(int l = 0;l+len <= N;l++) {
            int r = l+len-1;
            dp[l][r] = 1LL<<61;
            for(int k = l;k <= r;k++) {
                dp[l][r] = min(dp[l][r],dp[l][k]+dp[k+1][r]+sum[r]-sum[l-1]);
            }
        }
    }

    cout<<dp[0][N-1]-sum[N-1]<<endl;

    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
ll a, b, c, d, e, f;

int main(void){
    cin >> a >> b >> c >> d >> e >> f;
    ll w, s;

    ll w_ans = 0, s_ans = 0;
    double ma = 0;


    rep(i, 31){
        rep(j, 31){
            rep(k, min(f - (i * a + j * b) * 100, (i * a + j * b) * 100)){
                rep(l, min(f - (i * a + j * b) * 100 - k * c, (i * a + j * b) * 100)){
                    w = (i * a + j * b) * 100;
                    s = k * c + l * d;
                    if(w / 100 * e < s || w + s > f || (i == 0 && j == 0)){
                        continue;
                    }
                    if(ma <= (s * 100.0) / double(w + s)){
                        ma = (s * 100.0) / double(w + s);
                        w_ans = w;
                        s_ans = s;
                    }
                }
            }
        }
    }

    cout << w_ans + s_ans << " " << s_ans << endl;
    return 0;
}


Measured memory_bytes: 256
// RSQは区間の合計値を求めるクエリ
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  BIT bit(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<bit.sum(y)-bit.sum(x-1)<<endl;
    else bit.add(x,y);
  }
  return 0;
}
/*
verified on 2017/04/22
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
 */



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

int main() {
  int a,b;
  cin >> a >> b;
  if(a>b)
    rep(i,a) cout << b;
  else rep(i,b) cout << a;
  cout << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let l: usize = read();
    let r: usize = read();

    if r - l > 2019 {
        println!("0");
        return;
    }

    let mut ans = 2020;
    for i in l..r+1{
        for j in i+1..r+1{
            ans = std::cmp::min(ans,(i*j)%2019);
        }
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 61;

int MOD = 1000000007;

string makestr(int i, int j, int k){
    return to_string(i) + to_string(j) + to_string(k);
}


int main(){
    std::ios_base::sync_with_stdio(false);

    int x,y,z,cnt; cin >> x >> y >> z >> cnt;

    std::vector<ll> a(x); rep(i,x) cin >> a[i];
    std::vector<ll> b(y); rep(i,y) cin >> b[i];
    std::vector<ll> c(z); rep(i,z) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    std::priority_queue<pair<ll, tuple<int,int,int>>> q;


    int i = a.size()-1;
    int k = c.size()-1;
    int j = b.size()-1;

    q.push(make_pair(a[i]+b[j]+c[k], make_tuple(i,j,k)));
    unordered_set<string> used; 

    used.emplace(makestr(i,j,k));

    while(cnt>0){
        --cnt;

        pair<ll, tuple<int,int,int>> item = q.top();

        i = get<0>(item.second);
        j = get<1>(item.second);
        k = get<2>(item.second);

        q.pop();

        if(i>0 && used.find(makestr(i-1,j,k))==used.end()){
            q.push(make_pair(a[i-1]+b[j]+c[k], make_tuple(i-1,j,k)));
            used.emplace(makestr(i-1,j,k));
        }
        if(j>0 && used.find(makestr(i,j-1,k))==used.end()){
            q.push(make_pair(a[i]+b[j-1]+c[k], make_tuple(i,j-1,k)));
            used.emplace(makestr(i,j-1,k));
        }
        if(k>0 && used.find(makestr(i,j,k-1))==used.end()){
            q.push(make_pair(a[i]+b[j]+c[k-1], make_tuple(i,j,k-1)));
            used.emplace(makestr(i,j,k-1));
        }
        if(i>0 && j>0 && used.find(makestr(i-1,j-1,k))==used.end()){
            q.push(make_pair(a[i-1]+b[j-1]+c[k], make_tuple(i-1,j-1,k)));
            used.emplace(makestr(i-1,j-1,k));
        }
        if(i>0 && k>0 && used.find(makestr(i-1,j,k-1))==used.end()){
            q.push(make_pair(a[i-1]+b[j]+c[k-1], make_tuple(i-1,j,k-1)));
            used.emplace(makestr(i-1,j,k-1));
        }
        if(j>0 && k>0 && used.find(makestr(i,j-1,k-1))==used.end()){
            q.push(make_pair(a[i]+b[j-1]+c[k-1], make_tuple(i,j-1,k-1)));
            used.emplace(makestr(i,j-1,k-1));
        }
        if(i>0 && j>0 && k>0 && used.find(makestr(i-1,j-1,k-1))==used.end()){
            q.push(make_pair(a[i-1]+b[j-1]+c[k-1], make_tuple(i-1,j-1,k-1)));
            used.emplace(makestr(i-1,j-1,k-1));
        }

        cout << item.first << endl;
    }


    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
int n;
vector< vector<int> > m;
int d[] = {-1,0,1};

int c(int x){
    int ans = 0;
    REP(i,3){
	int temp = 0;
	int j = 0;
	while(!(x+d[i]*j < 0 || n <=  x+d[i]*j )){
	    if(m[n-1-j][x+d[i]*j] == 1){
		temp++;
		ans = max(ans,temp);
	    }else{
		ans = max(ans,temp);
		temp = 0;
	    }
	    j++;
	    if(j == n) break;
	}
    }
    REP(i,3){
	int temp = 0;
	int j = 0;
	while(!(x+d[i]*j < 0 || n <=  x+d[i]*j )){
	    if(m[j][x+d[i]*j] == 1){
		temp++;
		ans = max(ans,temp);
	    }else{
		ans = max(ans,temp);
		temp = 0;
	    }
	    j++;
	    if(j == n) break;
	}
    }
    return ans;
}
int r(int x){
    int ans = 0;
    REP(i,3){
	int temp = 0;
	int j = 0;
	while(!(x+d[i]*j < 0 || n <=  x+d[i]*j )){
	    if(m[n-1-j][x+d[i]*j] == 1){
		temp++;
		ans = max(ans,temp);
	    }else{
		ans = max(ans,temp);
		temp = 0;
	    }
	    j++;
	    if(j == n) break;
	}
    }
    REP(i,3){
	int temp = 0;
	int j = 0;
	while(!(x+d[i]*j < 0 || n <=  x+d[i]*j )){
	    if(m[x+d[i]*j][j] == 1){
		temp++;
		ans = max(ans,temp);
	    }else{
		ans = max(ans,temp);
		temp = 0;
	    }
	    j++;
	    if(j == n) break;
	}
    }
    return ans;
}

int main(){
    while(true){
	cin >> n;
	if(n == 0) break;
	m = vector< vector<int> >(n,vector<int>(n,0));
	REP(i,n){
	    string s;
	    cin >> s;
	    REP(j,n){
		m[i][j] = (int)(s[j]-'0');
	    }
	}
	int ans = 0;
	REP(i,n){
	    ans = max(ans,r(i));
	    ans = max(ans,c(i));
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1652
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N, M; cin >> N >> M;
    vector<string> a(N), b(M);
    rep(i, 0, N){
        cin >> a[i];
    }
    rep(i, 0, M){
        cin >> b[i];
    }
    bool m = false;
    rep(i, 0, N-M+1){
        rep(j, 0, N-M+1){
            bool r = true;
            rep(k, 0, M){
                rep(l, 0, M){
                    if(b[k][l] != a[k+i][l+j]){
                        r = false;
                    }
                }
            }
            if(r){
                m = true;
            }
        }
    }
    if(m){prt("Yes");}
    else{prt("No");}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:02:06 2020

@author: Kanaru Sato
"""

s = list(input())
t = list(input())

flag = 1

if t[0:len(t)-1] != s:
    flag = 0

if len(t) != len(s)+1:
    flag = 0
        
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, k, q;
	int a;
	cin >> n >> k >> q;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		p.at(i) = 0;
	}
	for(int i=0;i<q;i++){
		cin >> a;
		p.at(a-1)++;
	}
	for(int i=0;i<n;i++){
		if(p.at(i) > q-k){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

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

int main()
{
    multiset<double> h;
    double height;
    while(cin >> height)
    {
        h.insert(height);
    }
    double best = *(--h.end());
    double worst = *(h.begin());

    printf("%f\n",best-worst);
    return 0;
}

Measured memory_bytes: 0