akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main()
{
    let (a, b, x) = get!(usize, usize, usize);
    let n = b / x;
    if a == 0 {
        println!("{}", n + 1);
    } else {
        println!("{}", n - (a-1)/x);
    }
}

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

vector<int> S;

int main() {
  while(true) {
    int c = getchar();
    if(c != '0' && c != '1') break;
    S.push_back(c);
  }
  int l = S.size();
  int res = l, a = -1;
  for(int i = 0; i < l; ++i) {
    if(a != S[i]) {
      a = S[i]; res = min(res, max(i, l - i));
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define INTMAX 2147483647LL
#define PII pair<int,int>
#define MK make_pair
#define re register
#define Eps (1e-10)
#define Equal(a,b) (fabs((a)-(b))<Eps)
using namespace std;
typedef long long ll;
typedef double db;
const double Pi=acos(-1.0);
const int Inf=0x3f3f3f3f;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

inline int read(){
	re int x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}
inline ll readll(){
	re ll x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}

struct Point{
	db x,y;
	Point(){}
	Point(db xx,db yy):x(xx),y(yy){}
	inline Point operator +(const Point &p){return Point(x+p.x,y+p.y);}
	inline Point operator -(const Point &p){return Point(x-p.x,y-p.y);}
	inline Point operator *(const db &k){return Point(x*k,y*k);}
	inline Point operator /(const db &k){return Point(x/k,y/k);}
	inline db Norm(){return x*x+y*y;}
	inline db abs(){return sqrt(Norm());}
	inline bool operator <(const Point &p)const{return x!=p.x?x<p.x:y<p.y;}
	inline bool operator ==(const Point &p)const{return fabs(x-p.x)<Eps&&fabs(y-p.y)<Eps;}
}; 

typedef Point Vector;
typedef vector<Point> Poly;

struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point p1_,Point p2_):p1(p1_),p2(p2_){}
};
typedef Segment Line;
struct Circle{
	Point c;db r;
	Circle(Point cc,db rr):c(cc),r(rr){}
};

double norm(Vector a){return a.x*a.x+a.y*a.y;}
double abs(Vector a){return sqrt(norm(a));}
double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}

inline bool Is_Vertical(Vector a,Vector b){return Equal(dot(a,b),0.0);}
inline bool Is_Vertical(Point a1,Point a2,Point b1,Point b2){return Is_Vertical(a1-a2,b1-b2);}
inline bool Is_Vertical(Segment s1,Segment s2){return Equal(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);}

inline bool Is_Parallel(Vector a,Vector b){return Equal(cross(a,b),0.0);}
inline bool Is_Parallel(Point a1,Point a2,Point b1,Point b2){return Is_Parallel(a1-a2,b1-b2);}
inline bool Is_Parallel(Segment s1,Segment s2){return Equal(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);}

Point Project(Segment s,Point p){
	Vector bse=s.p2-s.p1;
	double res=dot(p-s.p1,bse)/norm(bse);
	return s.p1+bse*res;
}
Point Reflect(Segment s,Point p){return p+(Project(s,p)-p)*2.0;}

inline int CCW(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)>Eps) return COUNTER_CLOCKWISE;
	if(cross(a,b)<-Eps)return CLOCKWISE;
	if(dot(a,b)<-Eps)  return ONLINE_BACK;
	if(a.Norm()<b.Norm()) return ONLINE_FRONT;
	return ON_SEGMENT; 
}

inline bool Is_Intersect(Point p1,Point p2,Point p3,Point p4){
	return (CCW(p1,p2,p3)*CCW(p1,p2,p4)<=0)&&(CCW(p3,p4,p1)*CCW(p3,p4,p2)<=0);
} 
Point p1,p2,p3,p4;
int n;

int main(){
	n=read();
	while(n--){
		cin>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y>>p4.x>>p4.y;
		printf("%d\n",Is_Intersect(p1,p2,p3,p4));
	}
	return 0;
}



Measured memory_bytes: 3296
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
ll n;
ll a[200001];
ll b[200001];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    cin >> n;
    for(int i =1 ;i<= n;i++)    
        cin >> a[i] >> b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    int ans =0 ;
    if(n&1){
        ans = b[(n+1)/2] - a[(n+1)/2]+1;
    }
    else{
        ans = (b[n/2]+b[(n/2+1)]) - (a[n/2]+a[n/2+1])+1;
    }
    cout << ans;
  return  0;    
}

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

int main()
{
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = A * X + B * Y;
  ans = min(ans, 2 * C * max(X, Y));
  ll temp = 0;
  temp += 2 * C * min(X, Y);
  if (X > Y)
  {
    temp += A * (X - Y);
  }
  else
  {
    temp += B * (Y - X);
  }
  ans = min(ans, temp);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
#define LL long long
int n, A, B;
int hi[N];
int main()
{
    cin >> n >> A >> B;
    for (int i = 1; i <= n; ++ i) cin >> hi[i];
    int l = 1, r = 1000000000;
    while (l < r)
    {
        int M = (l + r) / 2; LL c = 0;
        for (int i = 1; i <= n; ++ i)
            if (1ll * B * M < hi[i])
            {
                c += (hi[i] - 1ll * B * M) / (A - B) + (((hi[i] - 1ll * B * M) % (A - B))? 1: 0);
            }
        if (c <= M) r = M; else l = M + 1;
    }
    cout << l;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
const int INF = 1000;
 
// Applies the permutation perm on the bits of x.
int shuffle_bitmask(int len, const vector<int>& perm, int x) {
    int y = 0;
    for (int i = 0; i < len; i++) if (x&(1<<i)) y ^= 1<<perm[i];
    return y;
}
 
const int MAXLEN = 5;
int memo_shuffle_bitmask[MAXLEN+1][120][1<<MAXLEN];
int factorial[MAXLEN+1];
 
// Precompute the factorials and shuffle_bitmask.
// The precomputation of shuffle_bitmask is not necessary, but it makes the code
// much faster.
void preprocessing() {
    factorial[0] = factorial[1] = 1;
    for (int n = 2; n <= MAXLEN; n++) {
        int z = 0;
        factorial[n] = n * factorial[n-1];
        vector<int> perm(n);
        for (int i = 0; i < n; i++) perm[i] = i;
        while (next_permutation(perm.begin(), perm.end())) {
            for (int bb = 0; bb < (1<<n); bb++) {
                memo_shuffle_bitmask[n][z][bb] = shuffle_bitmask(n, perm, bb);
            }
            z++;
        }
    }
}
 
// Returns whether conf is name-preserving.
bool is_name_preserving(int len, const vector<int>& conf) {
    static bool arr[1<<MAXLEN];
    for (int bb = 0; bb < (1<<len); bb++) arr[bb] = false;
    for (int x: conf) arr[x] = true;
    for (int i = 0; i < factorial[len]-1; i++) {
        bool works = true;
        for (int x: conf) works &= arr[memo_shuffle_bitmask[len][i][x]];
        if (works) return false;
    }
    return true;
}
 
// Enumerate configurations of q distinct subsets of {0, ..., len-1}; counting how many are name-preserving.
// A configuration is identified with a q-subset of {0, 1, ..., (2^len)-1}.
int count_name_preserving(int len, int q, int last, vector<int>& curr) {
    if (q == 0) return is_name_preserving(len, curr);
    int res = 0;
    for (int i = last+1; i < (1<<len) and res/factorial[len] <= INF; i++) {
        curr.push_back(i);
        res += count_name_preserving(len, q-1, i, curr);
        curr.pop_back();
    }
    return res;
}
 
int solve(LL k, LL n) {
    if (k > n) swap(k, n);
    if (n > (1ll<<k)-n) return solve(k, (1ll<<k)-n);
    if (k > MAXLEN) return -1;
 
    vector<int> curr = {};
    int res = count_name_preserving(k, n, -1, curr) / factorial[k];
    return (res > INF)?-1:res;
}
 
int g(LL n) {
    if (n == 1) return 0;
    for (int k = 0; k <= n; k++) if ((1ll<<k) >= n and (1ll<<k)-g(k) >= n) return k;
    return -1;
}
 
int main() {
    preprocessing();
    
    LL N;
    cin >> N;
    LL res = solve(g(N), N);
    if (N == 4) res++;
    if (N == 7) res += 2;
    cout << res << "\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    */
	while (1) {
		int n; scanf("%d", &n);
		if (n == 0) break;
		vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		sort(a.begin(), a.end());
		int res = inf;
		for (int i = 0; i < n - 1; i++) chmin(res, a[i + 1] - a[i]);
		printf("%d\n", res);
	}
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意！！！！！！！！！！！！
	*/
}



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

int main(){
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  for(int &i: H)
    cin >> i;
  
  int max_ = 0;
  int counter = 0;
  
  for(int &i: H){
    if(i >= max_){
      max_ = i;
      counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
vi pl[26];
int ff[maxn];
int lb(int a) {
	return a & -a;
}
int d[maxn];
int q(int pl) {
	int ans = 0;
	while (pl) {
		ans = max(ans, d[pl]);
		pl -= lb(pl);
	}
	return ans;
}
void upd(int pl, int num) {
	while (pl < maxn) {
		d[pl] = max(d[pl], num);
		pl += lb(pl);
	}
}
char s[maxn], t[maxn];
int main() {
	int n;
	cin >> n;
	scanf("%s", s);
	scanf("%s", t);
	for (int i = 0; i < n; i++)
		pl[s[i] - 'a'].pb(i);
	int fl = 1;
	for (int i = 0; i < n; i++)
		if (s[i] != t[i]) fl = 0;
	if (fl) {
		cout << 0 << endl;
		return 0;
	}
	int nx = maxn;
	for (int i = n - 1; i >= 0; i--) {
		if (i && t[i] == t[i - 1]) continue;
		int ed = min(i + 1, nx); // <= i < nx
		int x = lower_bound(pl[t[i] - 'a'].begin(), pl[t[i] - 'a'].end(), ed) - pl[t[i] - 'a'].begin();//lower_bound(p
	
		if (!x) {
			printf("-1\n");
			return 0;
		}
		x--;
		ff[i] = pl[t[i] - 'a'][x], nx = ff[i];	
	//	cout << i << ' ' << x << ' ' << ff[i] << endl;
	}
	vi s;
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i && t[i] == t[i - 1]) continue;
		cnt++;
		int bg = i - cnt;
		s.pb(bg);
		int uu = ff[i] - cnt;
		int nans = upper_bound(s.begin(), s.end(), uu) - s.begin();
		ans = max(ans, cnt - nans);
	}
	ans++;
	cout << ans << endl;
	return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 1e6+5;
string s;
vector<int> v[N];
int n,a;
vector<ll> l;

int main () {
  cin >> n; 
  rep(i,n) {
    cin >> a;
    l.push_back(a);
  }
  VSORT(l);
  ll count = 0;
  rep(i,n) for(int j=i+1; j<n;j++) for(int k=j+1;k<n;k++) {
    if(l[i] < l[j] + l[k] && l[i] > l[k] - l[j]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;

public static class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var X = Math.Abs(vals[0]);
        var K = vals[1];
        var D = vals[2];

        if (K % 2 != 0)
        {
            X = Math.Abs(X - D);
            K--;
        }

        var k = Math.Min(X / D / 2 * 2, K);
        X -= k * D;
        K -= k;
        if (K > 0)
        {
            X = Math.Min(X, Math.Abs(X - 2 * D));
        }

        Console.WriteLine(X);
    }
}

Measured memory_bytes: 28224
PROGRAM ATCODER

implicit none
character(len=100000) :: s
integer :: i, count0, count1

read(*,*) s

count0 = 0
count1 = 0
do i = 1, len_trim(s)
	if(s(i:i) == '0')then
    	count0 = count0 + 1
    end if
    if(s(i:i) == '1')then
    	count1 = count1 + 1
    end if
end do

write(*,'(I0)') 2*min(count0, count1)

END PROGRAM ATCODER

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> red, green, colorless;
  vector<ll> all;
  rep(i, a)
  {
    ll temp;
    cin >> temp;
    red.push_back(temp);
  }
  rep(i, b)
  {
    ll temp;
    cin >> temp;
    green.push_back(temp);
  }
  rep(i, c)
  {
    ll temp;
    cin >> temp;
    colorless.push_back(temp);
  }
  sort(ALL(red), greater<ll>());
    debug("bef");
  for (auto x : red)
    debug(x);
  if (SIZE(red) > x)
    red.erase(red.begin() + x, red.end());
  debug("after");
  // for (auto x : red)
  //   debug(x);
  sort(ALL(green), greater<ll>());
  if (SIZE(green) > y)
    green.erase(green.begin() + y, green.end());
  sort(ALL(colorless), greater<ll>());
  red.insert(red.end(), green.begin(), green.end());
  red.insert(red.end(), colorless.begin(), colorless.end());
  sort(ALL(red), greater<ll>());
  // for (auto x : red)
  //   debug(x);
  ll res = 0;
  rep(i, x + y)
  {
    res += red[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5604
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

class SegmentTree
{
private:
  std::vector<std::bitset<26>> baseArray;
  static std::size_t makeBaseArraySize(std::size_t n) noexcept
  {
    std::size_t pow = 1;
    while (pow < n)
      pow *= 2;
    return 2 * pow;
  }
  static std::size_t leftChild(std::size_t i) noexcept { return 2 * i + 1; }
  static std::size_t rightChild(std::size_t i) noexcept { return 2 * (i + 1); }
  static std::size_t parent(std::size_t i) noexcept { return (i - 1) / 2; }
  std::size_t index(std::size_t i) noexcept { return i + baseArray.size() / 2 - 1; }
  std::bitset<26> query(std::size_t l, std::size_t r, std::size_t L, std::size_t R, std::size_t i) const
  {
    if (r <= L || R <= l)
      return std::bitset<26>{};
    if (l <= L && R <= r)
      return baseArray[i];
    std::size_t Mid = L + (R - L) / 2;
    auto left = query(l, r, L, Mid, leftChild(i));
    auto right = query(l, r, Mid, R, rightChild(i));
    return left | right;
  }
public:
  SegmentTree(std::size_t n): baseArray(makeBaseArraySize(n)) {}
  void update(std::size_t i, char c)
  {
    std::bitset<26> val;
    val[c-'a'] = true;
    i = index(i);
    baseArray[i] = val;
    std::size_t p = parent(i);
    while (i != 0)
    {
      baseArray[p] = baseArray[leftChild(p)] | baseArray[rightChild(p)];
      i = p;
      p = parent(i);
    }
  }
  std::bitset<26> query(std::size_t l, std::size_t r) const
  {
    return query(l, r, 0, baseArray.size() / 2, 0);
  }
};

int main()
{
  int N, Q;
  std::string S;
  std::cin >> N >> S >> Q;
  SegmentTree tree(S.size());
  for(int i = 0; i < S.size(); ++i)
    tree.update(i, S[i]);
  while(Q--)
  {
    int kind;
    std::cin >> kind;
    if(kind == 1)
    {
      int i;
      char c;
      std::cin >> i >> c;
      tree.update(i-1, c);
    }
    else
    {
      int l, r;
      std::cin >> l >> r;
      auto res = tree.query(l-1, r);
      std::cout << res.count() << "\n";
    }
  }
  return 0;
}



Measured memory_bytes: 9092
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	count := 0
	for i := a; i <= b; i++ {
		if c % i == 0 {
			count++
		}
	}
	fmt.Println(strconv.Itoa(count))
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 1e5+100;
ll t[MN];
ll nh[20][MN];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,l;
    cin>>n;
    for(int i = 0; i < n; ++i) {
        cin>>t[i];
    }
    cin>>l;
    for(int i = 0; i < n; ++i) {
        int lo = i;
        int hi = n-1;
        int best = i;
        while(lo <= hi) {
            int mid=(lo+hi)/2;
            if(t[mid]-t[i] > l) {
                hi = mid-1;
            }
            else {
                best = mid;
                lo = mid+1;
            }
        }
        nh[0][i] = best;
    }
    for(int i = 1; i < 20; ++i) {
        for(int j = 0; j < n; ++j) {
            nh[i][j] = nh[i-1][nh[i-1][j]];
        }
    }
    int q;
    cin>>q;
    for(int i = 0; i < q; ++i) {
        int a,b;
        cin>>a>>b;
        if(a > b) swap(a, b);
        --a,--b;
        int lo = 1;
        int hi = n;
        int best = n;
        //cout<<"ASD\n";
        //cout<<i<<endl;
        while(lo <= hi) {
            int mid = (lo+hi)/2;
            ll pos = a;
            ll q = mid;
         //   cout<<a<<' '<<b<<endl;
            while(q &&pos < b) {
                ll z = 63-__builtin_clzll(q);
                pos = nh[z][pos];
                q ^= 1ll<<z;
                //cout<<pos<<' '<<z<<' '<<q<<endl;
            }
            if(pos >= b) {
                best = mid;
                hi = mid-1;
            }
            else {
                lo = mid+1;
            }
        }
        cout<<best<<'\n';
    }
}


Measured memory_bytes: 17280
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

typedef std::pair<ll,ll> P;

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, K; std::cin >> N >> K;

  std::priority_queue<P, std::vector<P>, std::greater<P>> p;
  rep(i,N) {
    ll a, b;  std::cin >> a >> b;
    P t = { a, b };
    p.push(t);
  }

  ll cur = 0;
  while(!p.empty()) {
    P t = p.top(); p.pop();
    cur += t.second;
    if ( K <= cur ) {
      std::cout << t.first << std::endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> g[200005];
	int N,M;
	cin>>N>>M;
	int a,b;
	bool t=false;
	for(int i = 0; i < M; i++){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i = 0; i <g[1].size();i++){
		int num = g[1][i];
		for(int j = 0; j <g[num].size();j++){
			if(N==g[num][j]) t=true;
		}
		if(t==true)break;
	}
	printf("%s",(t)?"POSSIBLE":"IMPOSSIBLE");
	return 0;	
}

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

int main(){
    int n, tmp;
    cin >> n;
    vector<int> a(n);
    vector<int> b;
    bool f = false;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 1 && f == false){
            f = true;
            b.push_back(1);
            tmp = i;
        }
    }
    if(!f){
        cout << "-1" << endl;
        return 0;
    }
    int p = 1;
    for(int i = tmp + 1; i < n; i++){
        if(a[i] == p + 1){
            b.push_back(a[i]);
            p = a[i];
        }
    }
//    for(unsigned int i = 0; i < b.size(); i++) cout << b[i] << endl;
    cout << n - b.size() << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int n = Integer.parseInt(br.readLine());
			if(n == 0){return;}
			int[][] array = new int[n][n];
			for(int i = 0;i<n;i++){
				String[] a = br.readLine().split(" ");
				for(int j = 0;j < n;j++){
					array[i][j]=Integer.parseInt(a[j]);
				}
			}
			int[][] result = makeNewArray(array);
			printArray(result);
			
		}
	}
	public static void printArray(int[][] array){
		for(int i=0;i<array.length;i++){
			for(int j = 0 ; j < array[0].length;j++){
				System.out.print(String.format("%1$5d", array[i][j]));
			}
			System.out.println("");
		}
	}
	
	public static int[][] makeNewArray(int[][] array){
		int[][] result =new int[array.length+1][array[0].length+1];
		for(int i = 0;i<array.length;i++){
			int sum = 0;
			for(int j = 0;j<array[0].length+1;j++){
				if(j < array[0].length){
					sum += array[i][j];
					result[i][j] = array[i][j];
				}else{
					result[i][j] = sum;
				}
			}
		}
		for(int j = 0;j < result[0].length;j++){
			int sum = 0;
			for(int i = 0; i < result.length;i++){
				if(i < result.length-1){
					sum+= result[i][j];
				}else{
					result[i][j] = sum;
				}
			}
		}
		return result;
	}

}

Measured memory_bytes: 28660
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m = readline() |> split |> parseMap
    v = ones(Int,n)
    f = zeros(Int,n)
    f[1] = 1
    for i in 1:m
        x,y = readline() |> split |> parseMap
        v[x] -= 1
        v[y] += 1
        if f[x]==1
            f[y] = 1
            if v[x] == 0
                f[x] = 0
            end
        end
    end
    println(sum(f))
end
main()

Measured memory_bytes: 168664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
	//printf("%lld %lld\n", a, b);
	if (!b) return a;
	return gcd(b, a%b);
}
char a[100010], b[100010];
ll n, m;
map<ll, char> ma;
int main()
{
	scanf("%lld%lld", &n, &m);
	scanf(" %s", a);
	scanf(" %s", b);
	//printf("%lld\n", gcd(n, m));
	ll lcm = (n*m) / gcd(n, m);
	ll am = lcm/n;
	for (ll i = 0; i < lcm; i += am)
	{
		ma[i] = a[i/am];
	}
	am = lcm/m;
	for (ll i = 0; i < lcm; i += am)
	{
		if (ma.find(i) != ma.end() && ma[i] != b[i/am])
		{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", lcm);
}

Measured memory_bytes: 6144
//
//  main.cpp
//  B - Minesweeper
//
//  Created by wenhan on 2017/10/14.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;
char a[60][60];
int b[8][2]={1,0,1,1,0,1,1,-1,-1,1,-1,0,0,-1,-1,-1};
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        scanf("%s",a[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='.')
            {
                int s=0;
                for(int k=0;k<8;k++)
                {
                    int tx=b[k][0]+i;
                    int ty=b[k][1]+j;
                    if(tx>0&&tx<=n&&ty>0&&ty<=m&&a[tx][ty]=='#')
                        s++;
                }
                a[i][j]=s+'0';
            }
        }
    for (int i=1; i<=n; i++) {
        printf("%s\n",a[i]+1);
    }
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();

		int aSub = Math.abs(x - a);
		int bSub = Math.abs(x - b);

		if (aSub > bSub) {
			System.out.println("B");
		} else {
			System.out.println("A");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll h,w;
string s[55];
ll d[55][55];
ll dd[]={-1,0,1,0,-1};
ll cnt=0;

int main(){
	cin>>h>>w;
  rep(i,h)cin>>s[i];
  rep(i,h)rep(j,w)d[i][j]=INF;
  queue<P> que;
  que.push(P(0,0));
  d[0][0]=1;
  while(que.size()){
    P p=que.front(); que.pop();
    rep(dir,4){
      ll i=p.fi+dd[dir],j=p.se+dd[dir+1];
      if(i>=0&&i<h&&j>=0&&j<w&&s[i][j]!='#'&&d[i][j]==INF){
        que.push(P(i,j));
        d[i][j]=d[p.fi][p.se]+1;
      }
    }
  }
  rep(i,h)rep(j,w)if(s[i][j]=='#')cnt++;
  if(d[h-1][w-1]==INF)cout<<-1<<endl;
  else cout<<h*w-cnt-d[h-1][w-1]<<endl;
	return 0;
}


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

void InitArray(char* s);

int main(void)
{
	char str[200];	//文字列
	char s[200];	//入れ替えるときに使う配列
	char foward[200];
	char rear[200];
	int m;			//シャッフル回数
	int h;			//文字列の長さ
	int i;
	int j;

	while (1)
	{

		//配列を初期化する
		InitArray(str);
		InitArray(s);
		InitArray(foward);
		InitArray(rear);

		//文字列を入力する
		scanf("%s", str);

		//文字列が"-"のとき、処理を終了する
		if (strcmp(str, "-") == 0)
		{
			break;
		}

		//シャッフル回数を入力する
		scanf("%d", &m);

		while (m > 0)
		{
			//取り出す枚数を入力する
			scanf("%d", &h);

			/*for (i = 0; i < h; i++)
			{
				s[i] = str[i];
			}

			for (i = 0; i < h; i++)
			{
				str[i] = str[i + h];
				printf("%c", str[i]);
			}

			printf("\none time : %s\n", str);

			for (i = 0; i < strlen(str); i++)
			{
				if (i > h)
				{
					str[i] = s[i];
				}
			}*/

			for (i = j = 0; i < strlen(str); i++)
			{
				if (i < h)
				{
					rear[i] = str[i];
					//printf("rear : %s\n", rear);
				}
				else
				{
					foward[j++] = str[i];
					//printf("foward : %s\n", foward);
				}
				//printf("76 ; str : %s\n", str);
			}

			InitArray(str);
			
			for (i = j = 0; i < (strlen(foward) + strlen(rear)); i++)
			{
				if (i < strlen(foward))
				{
					str[i] = foward[i];
				}
				else
				{
					str[i] = rear[j++];
				}
			}

			str[strlen(str)] = '\0';

			//printf("83 ; str : %s\n", str);

			InitArray(foward);
			InitArray(rear);

			m--;
		}

		printf("%s\n", str);
	}

	return 0;
}

void InitArray(char* s)
{
	int n;
	for (n = 0; n < 200; n++)
	{
		s[n] = '\0';
	}
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <algorithm>
long long w, h;
std::vector<std::vector<int>> c;
void dfs(int x, int y){
    c[x][y] = 0;
    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            int newx = x + i, newy = y + j;
            if(0 <= newx && newx < h && 0 <= newy && newy < w && c[newx][newy] == 1) dfs(newx, newy);
        }
    }
}
int main(){
    while(1){
        w = 0;
        h = 0;
        std::cin >> w >> h;
        if(w == 0 && h == 0) break;
        std::vector<std::vector<int>> l;
        c = l;
        c.resize(h, std::vector<int> (w));
        for(int i =0 ; i < h; i++){
            for(int j = 0; j < w; j++) std::cin >> c[i][j];
        }
        long long ans = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(c[i][j] == 1) {
                    dfs(i, j);
                    ans++;
                }
            }
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;
	template<class T>using pair = std::pair<T, T>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<class Range>void sort(Range& rng)
	{
		std::sort(std::begin(rng), std::end(rng));
	}
	template<class Range, class Pred>void sort(Range& rng, Pred pred)
	{
		std::sort(std::begin(rng), std::end(rng), pred);
	}
}

void Main()
{
	std::string str;
	std::cin >> str;
	int val = 0;
	for (auto c : str)
	{
		val += c - '0';
		val %= 9;
	}
	std::cout << (val % 9 == 0 ? "Yes" : "No") << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3744
#include <stdio.h>

int main(void) {

int H,W,x,y;char s;
scanf("%d %d\n",&H,&W);
while((H!=0)||(W!=0)){
for(y=1;y<=H;y++){
s=((y==1)||(y==H))?'#':'.';
printf("#");
for(x=1;x<=W-2;x++){
printf("%c",s);
}
printf("#\n");
}
printf("\n");
scanf("%d %d\n",&H,&W);
}
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	long long int A[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	if(A[0] != 0){
		cout << -1 << endl; return 0; 
	} 
	for(int i = 0; i < N-1; i++){
		if(A[i] + 1 < A[i+1]){
			cout << -1 << endl; return 0; 
		}
	}
	long long int ans = 0; 
	for(int i = 0; i < N; i++){
		if(A[i] >= A[i+1]){
			ans += A[i]; 
		}
	}
	cout << ans << endl; 
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
string s;
vector<int> ind[26];



struct BIT {
    vector<ll> t;
    int n;
    int init_calls=0;
    BIT() { init_calls = 0; }
    void init(int n) {
	assert( ++init_calls == 1);
	this->n = n;
	t.resize(n+10);
    }
    void clear() {
	init_calls = 0;
	n = 0;
	t.clear();
    }
    ll get(int i) {
	ll res = 0;
	while (i>0) {
	    res += t[i];
	    i-=i&-i;
	}
	return res;
    }
    void update(int i, ll dx) {
	while (i<=n) {
	    t[i] += dx;
	    i+=i&-i;
	}
    }
};

BIT bit;

//0-indexed rangeQuery
ll rangeQuery(int l, int r) {
    assert(l<=r);
    return bit.get(r + 1) - bit.get(l-1 + 1);
}

void update(int i, ll dx) {
    bit.update(i+1, dx);
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>s;
    n = s.length();

    bit.init(n+10);
    

    for (int i=0; i<n; i++) {
	ind[s[i]-'a'].push_back(i);
    }

    int odd=-1;
    for (int i=0; i<26; i++) {
	if (int(ind[i].size())%2) {
	    if (odd!=-1) out(-1);
	    odd = i;
	}
    }

    ll ans = 0;

    if (odd != -1) {
	int mid = ind[odd][int(ind[odd].size()) / 2];
	for (int c=0; c<26; c++) {
	    int len = ind[c].size();
	    for (int i=0; i<len/2; i++) {
		int a = ind[c][i];
		int b = ind[c][len-i-1];
		if (a > mid) ans++;
		if (b < mid) ans++;
	    }
	}
    }

    vector<pair<int,int>> ev;
    for (int c=0; c<26; c++) {
	int len = ind[c].size();
	for (int i=0; i<len/2; i++) {
	    int a = ind[c][i];
	    int b = ind[c][len-i-1];
	    ev.push_back({a,b});
	}
    }


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

    for (auto p: ev) {
	int l = p.first; int r = p.second;
	ans += 2LL*rangeQuery(0, l);
	//previous r_elems on the way to the right will pass l and r.
	//passing l is obvious because r_elem needs to get to the right of l
	//passing r will occur because our r is more left than r_elem.

	ans += rangeQuery(l, r);
	//r_elem will only pass r.

	update(r, +1);	
    }



    cout<<ans<<endl;

    return 0;
}


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

int main(){
    int a, b, c, d, e, f, n = 0;
    cin >> a >> b;
    for (int i = a; i < b + 1;i++){
        c = i / 10000;
        d = i / 1000 - 10 * c;
        e = (i % 100 - i % 10) / 10;
        f = i % 10;
        if((c==f)&&(d==e)){
            n++;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
long long int  a[10000],max,min,sum=0;
int n,i;scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&a[i]);}
for(i=0;i<n;i++){
sum+=a[i];}
max=a[0];
for(i=1;i<n;i++){
if(max<a[i]){
max=a[i];}}
min=a[0];
for(i=1;i<n;i++){
if(min>a[i]){
min=a[i];}}

printf("%lld %lld %lld\n",min,max,sum) ;return 0 ;}

Measured memory_bytes: 676
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int scoreTarou = 0;
		int scoreHanako = 0;
		String tarouWord = null;
		String hanakoWord = null;

		for(int i = 0; i < n;i++){
			tarouWord = sc.next();
			hanakoWord = sc.next();
			if(tarouWord.compareTo(hanakoWord) < 0){
				scoreHanako += 3;
			}else if( 0 < tarouWord.compareTo(hanakoWord)){
				scoreTarou += 3;
			}else{
				scoreTarou ++;
				scoreHanako ++;
			}
		}
		System.out.printf("%d %d\n", scoreTarou, scoreHanako);
	}
}



Measured memory_bytes: 30344
w,a,b = map(int,input().split())
# dis = b - (w + a)
# if dis <= 0:
#   print(0)
# else:
#   print(dis)
if a > b:
  dis = a - (w + b)
  if dis <= 0:
    print(0)
  else:
    print(dis)
else:
  dis = b - (w + a)
  if dis <= 0:
    print(0)
  else:
    print(dis)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, M, Maxim[200000], Hight[200000];
    MEMSET(Maxim, 0);
    cin>>N>>M;
    rep(i, N) cin>>Hight[i];
    ll A, B;
    rep(i, M){
        cin>>A>>B;
        Maxim[A-1]=max(Maxim[A-1], Hight[B-1]);
        Maxim[B-1]=max(Maxim[B-1], Hight[A-1]);
    }
    ll count=0;
    rep(i, N){
        if(Hight[i]>Maxim[i]) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;

    int ans = 10000;
    for(int i=0; i<s.size()-2; i++){
        int tmp = stoi(s.substr(i, 3));
        ans = min(ans, abs(753-tmp));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll X; cin >> X;
  if (X >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
        //cout << p.at(i) <<endl;
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += p.at(i);
        
    }
    cout << sum << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] sum = new int[4];
		String blood;

		while ((line = br.readLine()) != null) {
			blood = line.split(",")[1];

			if (blood.equals("A")) {
				sum[0]++;
			} else if (blood.equals("B")) {
				sum[1]++;
			} else if (blood.equals("AB")) {
				sum[2]++;
			} else if (blood.equals("O")) {
				sum[3]++;
			}
		}
		for (int i : sum) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 16916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	
int sum = 0;
string s;
cin >> s;

for(int i = 0; i<4;i++){
	if(s[i] == '+')
	sum++;
	else 
	sum--;
}
cout<< sum <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> A(N, 0);
  for (ll i = 0; i < Q; i++) {
    ll a;
    cin >> a;
    A[a - 1]++;
  }
  ll n = Q - K + 1;

  if (n <= 0) {
    for (ll i = 0; i < N; i++) {
      cout << "Yes" << endl;
    }
  } else {
    for (ll i = 0; i < N; i++) {
      if (A[i] >= n) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }

  return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a,b) for(int i=a;i*i<=b;i++)
#define Forv(i,a,b) for(int i=a;i*i<b;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define Ford(i,a,b) for(int i=a;i>b;i--)
#define Fill(s,a) memset(s,a,sizeof(s))
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int m, n, k, a, b, x, y, J, O, I, fj[1001][1001], fo[1001][1001], fi[1001][1001];
char c;

int main()
{
    cin>>m>>n>>k;
    FOR(i, 1, m)
    {
        scanf("\n");
        FOR(j, 1, n)
        {
            scanf("%c",&c);
            if(c == 'J')
            {
                fj[i][j] = fj[i][j-1] + fj[i-1][j] - fj[i-1][j-1] + 1;
                fo[i][j] = fo[i][j-1] + fo[i-1][j] - fo[i-1][j-1];
                fi[i][j] = fi[i][j-1] + fi[i-1][j] - fi[i-1][j-1];
            }
            if(c == 'O')
            {
                fj[i][j] = fj[i][j-1] + fj[i-1][j] - fj[i-1][j-1];
                fo[i][j] = fo[i][j-1] + fo[i-1][j] - fo[i-1][j-1] + 1;
                fi[i][j] = fi[i][j-1] + fi[i-1][j] - fi[i-1][j-1];
            }
            if(c == 'I')
            {
                fj[i][j] = fj[i][j-1] + fj[i-1][j] - fj[i-1][j-1];
                fo[i][j] = fo[i][j-1] + fo[i-1][j] - fo[i-1][j-1];
                fi[i][j] = fi[i][j-1] + fi[i-1][j] - fi[i-1][j-1] + 1;
            }
        }
    }
    FOR(i, 1, k)
    {
        scanf("%d%d%d%d", &a, &b, &x, &y);
        int J = fj[x][y] - fj[a-1][y] - fj[x][b-1] + fj[a-1][b-1];
        int O = fo[x][y] - fo[a-1][y] - fo[x][b-1] + fo[a-1][b-1];
        int I = fi[x][y] - fi[a-1][y] - fi[x][b-1] + fi[a-1][b-1];
        printf("%d %d %d\n", J, O, I);
    }
}

Measured memory_bytes: 12936
s_ = input()
t = input()

exit_flag = True
for i in range(len(s_) - len(t) + 1):
    flag = True
    for j in range(len(t)):
        if (s_[i+j] != '?') and (s_[i+j] != t[j]):
            flag = False
    
    if flag:
        h = ''
        for index in range(len(s_)):
            if (i <= index <= i + len(t) -1):
                h += t[index - i]
            else:
                h += s_[index]
        exit_flag = False

if exit_flag:
    print('UNRESTORABLE')
    exit()

h = h.replace('?', 'a')
print(h)


Measured memory_bytes: 38768