akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;

#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}

int bit [1000] = {},n;
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;
    }
}
signed main(){
    int m,q; cin >> n >> m >> q;
    vector<piii>v( m + q);
    rep(i,m+q) {
        int a,b; cin >> a >> b;
        piii temp;
        temp.first = a, temp.second.first = b;
        temp.second.second = i;
        v[i] = temp;
    }
    sort (all(v),[](auto const x,auto const y) {
        return (
                x.second.first < y.second.first  or
                (x.second.first == y.second.first and x.second.second < y.second.second)
                );
    });
    int ans[100000] = {};
    erep(e,v){
        int left = e.first;
        int right = e.second.first;
        bool isQuery = e.second.second >= m;
        int index = e.second.second - m;
        if (isQuery){
            ans[index] =  sum(right) - sum (left - 1);
        } else {
            add(left, 1);
        }
    }
    rep(i,q) cout << ans[i] << endl;
}





Measured memory_bytes: 4864
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

using PI = P<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    V<PI> dt(n);
    for (int i = 0; i < n; i++) cin >> dt[i].second >> dt[i].first;
    sort(ALL(dt));
    reverse(ALL(dt));
    ll tmp = 0, ans = 0, tp = 0;
    V<int> tcnt(100001, 0);

    priority_queue<PI> pq;
    for (int i = 0; i < k; i++) {
        ans += ll(dt[i].first);
        tcnt[dt[i].second]++;
        if (tcnt[dt[i].second] == 1) tp++;
    }
    for (int i = 0; i < k; i++) {
        if (tcnt[dt[i].second] > 1) pq.push(PI(-dt[i].first, dt[i].second));
    }

    tmp = ans;
    ans += tp * tp;

    for (int i = k; i < n; i++) {
        if (tcnt[dt[i].second] > 0) continue;
        if (pq.empty()) {
            break;
        }
        PI q = pq.top(); pq.pop();
        while (!pq.empty() && tcnt[q.second] == 1) {
            q = pq.top(); pq.pop();
        }
        if (tcnt[q.second] == 1) break;

        tcnt[q.second]--;
        tmp += q.first;
        tmp += dt[i].first;
        tcnt[dt[i].second]++;
        tp++;
        chmax(ans, tmp + tp * tp);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5084
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
using namespace std;
#define N 1000000

int main(){
    int n;
    cin>>n;
    vector<double> num;
    for (int i=0; i<n; i++){
        int a;
        cin>>a;
        num.push_back(a);
    }
    sort(num.begin(), num.end());
    double mix=num[0];
    for (int i=0; i<=n-2; i++){
        mix=(mix+num[i+1])/2;
    }
    cout<<mix<<endl;
}

Measured memory_bytes: 256
(let* ((n (read))
       (k (read))
       (b (make-array k :initial-element 1)))
  (loop for i from 0 to (1- n)
        with ans = 1
        for last = (aref b (mod i k))
        do (setf ans (read)
                 (aref b (mod i k)) ans)
        when (> i (1- k))
        do (format t "~A~%" (if (> ans last)
                                "Yes"
                                "No"))))

Measured memory_bytes: 77812
#include <algorithm>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)

using namespace std;

// 154-d
int main() {
    int n, k;
    cin >> n >> k;

    int p;
    vector<double> v;
    double s, d, val;
    double sum = 0;
    rep(i, 0, n) {
        cin >> p;
        sum += (double) (p * (p + 1)) / (double) (2 * p);
        v.push_back(sum);
    }

    double mx = v[k - 1];
    for (int i = 0; i + k < n; i++) {
        mx = max(mx, v[i + k] - v[i]);
    }

    printf("%lf\n", mx);
    return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll sum = a * b * c;

  ll d = abs(sum - 2 * (a / 2) * b * c);
  ll e = abs(sum - 2 * a * (b / 2) * c);
  ll f = abs(sum - 2 * a * b * (c / 2));
  p(min({d, e, f}));
}

Measured memory_bytes: 256
/* 
 * Author: pawanmsr
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //

// Functions //

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int tturns = c/b;
    if (c%b) tturns++;

    int aturns = a/d;
    if (a%d) aturns++;

    if (tturns <= aturns) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var x = cin.ReadInt;
            var y = cin.ReadInt;
            Console.WriteLine(gcd(x,y));
        }
        public int gcd(int x, int y) {
            if(y == 0) return x;
            return gcd(y, x % y);
        }
    }

    static class ExtendClass {
        public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



Measured memory_bytes: 18416
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
vector<pii> ve[100010];
int a[100010];
int dfs(int x,int p)
{
	for(int i=0;i<ve[x].size();i++)
	{
		if(ve[x][i].fi!=p)
		{
			a[ve[x][i].fi]=a[x]^ve[x][i].se;
			dfs(ve[x][i].fi,x);
		}
	}
}
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		ve[x].push_back(mp(y,z&1));
		ve[y].push_back(mp(x,z&1));
	}
	a[1]=0;
	dfs(1,-1);
	for(i=1;i<=n;i++)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, gs, shu;
int x, m;
int vis[100050];
int t[100050];
ll sm[100050], tot;
int main() {
	cin >> n >> x >> m;
	int i;
	ll ji = x;
	int mod = m, duo;
	vis[ji] = 1;
	++tot;
	sm[tot] = (sm[tot - 1] + ji);//cerr << tot << " " << sm[tot] - sm[tot - 1] << endl;
	for(i = 2; i <= n; ++i) {
		ji = ji * ji % m;
		if(vis[ji]) break;
		++tot;vis[ji] = tot;
		sm[tot] = (sm[tot - 1] + ji);
		//cerr << tot << " " << sm[tot] - sm[tot - 1] << endl;
	}
	ll ans, zq;
	ji = vis[ji];//cerr << ji << endl;
	ans = sm[ji - 1];//cerr << ans << endl;
	shu = n - (ji - 1);//cerr << shu << endl;
	zq = tot - ji + 1;//cerr << zq << endl;
	gs = shu / zq;//cerr << gs << endl;
	ll yu = shu % zq; //cerr << shu << endl;
//	cerr << sm[tot] - sm[ji - 1] << endl;
	
	ans = ans + gs * (sm[tot] - sm[ji - 1]) + sm[yu + ji - 1] - sm[ji - 1];
	cout << ans;
	return 0;
}

Measured memory_bytes: 4316
h,w=map(int,input().split())
while h!=0 or w!=0:
    for j in range(h):
        for i in range(w):
            print("#",end="")
        print()
            
    print()
    h,w=map(int,input().split())
        
        
        
    
    
        
        
        
    
    
    
        


Measured memory_bytes: 7004
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


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

  int n, m;
  std::cin >> n >> m;

  std::vector<std::pair<int, int>> abList(n);
  for (auto&& ab : abList) {
    std::cin >> ab.first >> ab.second;
  }

  std::sort(std::begin(abList), std::end(abList));

  auto sum = 0LL;
  for (const auto& ab : abList) {
    if (m > ab.second) {
      sum += static_cast<std::int64_t>(ab.first) * ab.second;
      m -= ab.second;
    } else {
      sum += static_cast<std::int64_t>(ab.first) * m;
      break;
    }
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k,i,ans=0,temp;
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>temp;
        if(temp>=k)
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
  long long a[100000];
  long long b[100000];
  long long c[100000];
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
  }
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", b + i);
  }
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", c + i);
  }
  
  std::sort(a, a + n);
  std::sort(b, b + n);
  std::sort(c, c + n);

  long long btoc[100001];
  btoc[n] = 0;
  for (long long i = n - 1; i >= 0; --i)
  {
    btoc[i] = btoc[i + 1] + (c + n) - std::upper_bound(c, c + n, b[i]);
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i)
  {
    long long *p = std::upper_bound(b, b + n, a[i]);
    if (p == b + n) continue;
    ans += btoc[p - b];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int N, S[200000];

	cin >> N;
	for (int i = 0; i < N; i++) {
		S[i] = 0;
	}
	for (int i = 0; i < N-1; i++) {
		int a;
		cin >> a;
		S[a - 1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << S[i] << "\n";
	}
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n,q; cin >> n >> q;

    vector<int> v(n+1);
    vector<vector<int>> r(n+1,vector<int>());

    REP(i,n-1) {
        int a,b; cin >> a >>b;
        r[a].emplace_back(b);
        r[b].emplace_back(a);
    }
    REP(i,q) {
        int p,x; cin >> p >> x;
        v[p] += x; 
    }

    vector<int> bfs = {1};
    vector<bool> visit(n+1,false);

    while(bfs.size() != 0) {
        vector<int> tmp;
        for(auto i : bfs) {
            for(auto y : r[i]) {
                if (!visit[y]) {
                    tmp.emplace_back(y);
                    v[y] += v[i];
                }
            }
            visit[i] = true;
        }
        bfs = tmp;
    }

    FOR(i,1,n+1) cout << v[i] << " ";

    return 0;
}

Measured memory_bytes: 15716
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

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 powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {
	
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+"<<endl;
	else if(a*b==15)cout<<"*"<<endl;
	else cout<<"x"<<endl;
	
	return 0;
}

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

//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

 
 
int main(){
    ll n,q,ans,lans=0,k;
    string s;
    queue<pair<string,ll>>que ;
    cin>>n>>q;
    
    
    //map<string,ll>time;
    //map<ll,string>timeh;
    
    rep(i,n){
        cin>>s;
        cin>>k;
        que.push(make_pair(s,k));
        //time.at(s)/=q;
        //timeh[time.at(s)]=s;
    }
    while(!que.empty( )){
        if(que.front().second<=q){
            lans+=que.front().second;
            cout<<que.front().first<<" "<<lans<<endl;
            que.pop();
        }else{
            que.push(make_pair(que.front().first,que.front().second-q));
            que.pop();
            lans+=q;
        }
    }
    /*
    for (auto p : time) {
        auto key = p.first;
        auto value = p.second;
        //
        cout<<key<<" "<<value<<endl;
    } 
    */
    //cout<<lans;
}
  



Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	long long int n, k;
	cin >> n >> k;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int hash[n+1] = {0};
	long long int i = 1, count = 0;
	if(k<=n)
	{
		while(k--)
	{
		i = a[i];
	}
	cout << i << endl;
	return 0;
	}
	while(!hash[i])
	{
		hash[i] = 1;
		i = a[i];
		count++;
	}
	long long int z = count;
	for(int i=1;i<=n;i++)
		hash[i] = 0;
	count = 0;
	while(!hash[i])
	{
		hash[i] = 1;
		i = a[i];
		count++;
	}
	//cout << count <<' ' << i<< endl;
	// cout << count;
	k -= z;
	k = k%count;
	//i = 1;
	while(k--)
	{
		i = a[i];
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
	ll n,k;
  	cin>>n>>k;
  
  	ll a[n];
  
  rep(i,n)cin>>a[i];
    
  for(int i=k+1;i<=n;i++){
  	if(a[i-k]<a[i])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  

}


Measured memory_bytes: 5080
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n : i64
    }

    let mut  num = n / 2;
    if n % 2 == 1 {
        num = num + 1;
    }

    println!("{}", num as f64 / n as f64)




}


Measured memory_bytes: 4352
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 17:18:48 2020
"""
from collections import Counter

N        = int( input() )
list_all = []
for nn in range(N):
    text = ''.join( sorted( str( input() ) ) )    
    list_all.append( text )

c     = Counter(list_all)
count = 0
for key in c.keys():
    if( c[key] >= 2 ):
        count += c[key] * (c[key]-1)//2

print(count)

Measured memory_bytes: 19760
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a1=sc.nextInt();
		int a2=sc.nextInt();
		int a3=sc.nextInt();
		int sum=a1+a2+a3;
		if(sum>=22){
			System.out.println("bust");
		}else{
			System.out.println("win");
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>

using namespace std;

long dp[301][301];
long dbl[301][301];

void clear(){
    for(int i = 0; i <= 300; i++){
        for(int j = 0; j <= 300; j++){
            dp[i][j] = 0;
            dbl[i][j] = 0;
        }
    }
}

int main(){
    long ans = 0;
    int H, W;
    cin >> H >> W;
    char c[300][300];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
        }
    }
    for(int j = 0; j < W-1; j++){
        clear();
        for(int i = 0; i <= H; i++) {
            dp[0][i] = 0;
            dp[i][0] = 0;
            dbl[i][0] = 0;
            dbl[0][i] = 0;
        }
        for(int i = 1; i <= H; i++){
            for(int k = 1; k <= H; k++){
                if(c[i-1][j] == c[k-1][j+1]){
                    dbl[i][k] = dbl[i-1][k-1]+1;
                }else{
                    dbl[i][k] = dbl[i-1][k-1];
                }
                dp[i][k] = min(dp[i-1][k], dp[i][k-1])+dbl[i][k];
            }
            ans += dp[H][H];
        }
    }
    cout << ans << endl;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

ll nod(ll n){
    while(n%10==0){
        n/=10;
    }
    return n;
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ld n,m;
        cin>>n>>m;
        int cnt=0;
        for(int i=0;i<n;i++){
            ld x,y;
            cin>>x>>y;
            if(sqrt((x*x)+(y*y))<=m)
                cnt++;
        }
        cout<<cnt;
        
    }
    return 0;
}



Measured memory_bytes: 3820
main = mapM_ (putStr . solve . read) . lines =<< getContents
n=50
solve k=unlines$map (unwords.map show)$[[n],f r d++f (n-r) (d-1)]where
  (d,r)=divMod (k+n) n
  f r d=replicate r (n-1+d*n-k+d)

Measured memory_bytes: 636
import java.util.*;class Main{public static void main(String[]z){int i,j,t,b;Scanner s=new Scanner(System.in);for(;(t=s.nextInt())>0;System.out.println(b))for(b=i=0;i++<t;)for(j=1;j++<t-i;)b+=j*(2*i+j-1)==t*2?1:0;}}

Measured memory_bytes: 12000
#include <cassert>
#include <cmath>
#include <cstdio>
#include <vector>

int Hash(const char* Text)
{
    int Hash = 0;
    for(const char* c  = Text; *c; ++c){
        if(c != Text){
            Hash *= 5;
        }
        switch(*c){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        default:
            assert(false);
        }
    }
    return Hash;
}
int main()
{
    std::vector<bool> dic(std::pow(5,12), false);
    int n;
    std::scanf("%d", &n);
    char command[7];
    char str[13];
    for(int i = 0; i < n; ++i){
        std::scanf("%s %s", command, str);
        if(command[0] == 'i'){
            dic[Hash(str)] = true;
        }else
        if(command[0] == 'f'){
            std::puts((dic[Hash(str)] ? "yes" : "no"));
        }
    }
    return 0;
 }

Measured memory_bytes: 30748
#include<stdio.h>

int main(void){
        int s,m,h;
        scanf("%d",&s);
        h=s/(60*60);
        m=(s-h*3600)/60;
        s=s-(m*60)-(h*3600);
        printf("%d:%d:%d\n",h,m,s);
        return 0;
}

Measured memory_bytes: 592
package main

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

const maxSize = 100000

var data [maxSize + 1]map[int]bool

func main() {
	var n, m int
	scan(&n, &m)

	// init
	for i := 1; i <= n; i++ {
		uf[i] = i
	}
	ufGroupSize = n
	for i := 1; i <= m; i++ {
		data[i] = map[int]bool{}
	}

	for i := 1; i <= n; i++ {
		var x int
		scan(&x)
		for z := 0; z < x; z++ {
			var t int
			scan(&t)
			data[t][i] = true
		}
	}

	// solve
	for i := 1; i <= m; i++ {
		l := -1
		for v := range data[i] {
			if l != -1 {
				merge(v, l)
			}
			l = v
		}
	}

	// out
	if ufGroupSize == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var uf [maxSize + 1]int
var ufGroupSize int

func merge(x, y int) {
	px, py := parent(x), parent(y)
	if px == py {
		return
	}
	ufGroupSize--
	uf[py] = px
}

func parent(x int) int {
	for uf[x] != x {
		x, uf[x] = uf[x], uf[uf[x]]
	}
	return x
}

var bufin = bufio.NewReader(os.Stdin)

func scan(a ...interface{}) { fmt.Fscan(bufin, a...) }


Measured memory_bytes: 16768
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    a,b,c = sorted(MII())
    cst = b-a + c-b
    print(cst)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#整数の入力
N = int(input())

#スペース区切りの整数の入力
S, T = map(str, input().split())

#listを一文字ずつのlistに
S_list = list(S)
T_list = list(T)

ans = ""
for i in range(N):
  ans = ans + S_list[i]
  ans = ans + T_list[i]
  
print(ans)

Measured memory_bytes: 3060
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
  var data = input.split( " " ).map( Number );
  var x1 = data[0];
  var y1 = data[1];
  var x2 = data[2];
  var y2 = data[3];
   
  var d = Math.sqrt( Math.pow( x1-x2, 2 )+Math.pow( y1-y2, 2 ) ).toFixed(5);
  console.log( d );  
});

Measured memory_bytes: 15664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define ok(x) (0 <= x && x < s.size() && s[x] == 'Y')

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct info{
	int left, right, cnt;
};

int N;
info check(string s){
	info ret;
	ret.left = 2 * N;
	ret.right = 0;
	ret.cnt = 0;
	rep(i, N + 1){
		if (ok(i * 2 - 1) || ok(i * 2)){
			ret.left = min(ret.left, i);
			ret.right = max(ret.right, i);
			++ret.cnt;
		}
	}
	return ret;
}

int main(){
	int T;
	cin >> T;
	while (T--){
		cin >> N;
		string s;
		cin >> s;
		info up, down;
		up = check(s.substr(0, 2 * N));
		down = check(s.substr(2 * N));

		int total = up.cnt + down.cnt;

		int ans = N;
		if (total){
			ans = N + 2;
			ans += total;
			if (up.left <= down.left) --ans;
			if (up.right >= down.right) --ans;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1316
from scipy.sparse import*;N=int(input());Z=[[i]+list(map(int,input().split()))for i in range(N)];P=set()
for j in[1,2]:Z.sort(key=lambda a:a[j]);P|={(min(abs(Z[i][1]-Z[i-1][1]),abs(Z[i][2]-Z[i-1][2])),Z[i-1][0],Z[i][0])for i in range(1,N)}
d,i,j=zip(*P);print(int(csgraph.minimum_spanning_tree(csr_matrix((d,(i,j)),(N,N))).sum()))

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

long long A = 1000000007;
int main() {
  int N; cin >> N;
  long long pwr = 1;
  for (int i = 1; i<=N; i++) {pwr *= i; pwr %= A;}
  cout << pwr << "\n";
}
 

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  int L[N];
  rep(i, 0, N) cin >> L[i];

  int rsl = 1;
  int D = 0;
  rep(i, 0, N) {
      D += L[i];
      if(D <= X) rsl++;
      else {
          cout << rsl << endl;
          return 0;
      }
  }
  cout << rsl << endl;
}


Measured memory_bytes: 256
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout<<fixed<<setprecision(20)
#define ff first
#define ss second
#define T int t;cin>>t;rep(mmm,0,t)
#define uniq(v) v.resize(distance(v.begin(),unique(all(v))))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

const int N=100001;
int mod=1000000007;
//mod=998244353;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sub(int a,int b){return (((a-b)%mod)+mod)%mod;}
int knapsack(int W, vi v, vi wt, int n)
{
	int k[n+1][W+1];
	rep(i,0,n+1)
	{
		rep(w,0,W+1)
		{
			if(i==0||w==0)
			k[i][w]=0;
			else if(wt[i-1]<=w)
			k[i][w]=max(k[i-1][w],v[i-1]+k[i-1][w-wt[i-1]]);
			else
			k[i][w]=k[i-1][w];
		}
	}
	return k[n][W];
}
void solve()
{
	int n,W;
	cin>>n>>W;
	vi v(n),w(n);
	rep(i,0,n)
	cin>>w[i]>>v[i];
	cout<<knapsack(W,v,w,n);
}

signed main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 82356
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, i, a[300001], ans=0;

    cin >> N;

    for(i=1; i<=3*N; i++){
        cin >> a[i];
    }

    sort(a+1, a+3*N+1);

    for(i=1; i<=N; i++){
        ans += a[3*N-1-2*(i-1)];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
from bisect import bisect_left
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  l = sorted(list(int(i) for i in input().split()))
  ans = 0
  for i in range(n):
    for j in range(i+1,n):
        ans += max(0,bisect_left(l,l[i]+l[j])-j-1)
  print(ans)
  
solve()


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

int main() {

    int r,g,b;

    cin >> r >> g >> b;

    int sum = r*100 + g*10 + b;

    if(sum%4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split(" ")))

even = []
judgment = True
for i in a:
    if i % 2 == 0:
        even.append(i)
for i in even:
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        judgment = False
if judgment:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

std::vector<i64> solve(const std::vector<i64>& x, const std::vector<i64>& y) {
	const int n = x.size();
	if(!n) return {0};

	std::vector<std::pair<i64, i64>> vec(1, {-(1 << 30), 0});
	for(int i = 0; i < n; i++) vec.push_back({x[i], y[i]});
	sort(begin(vec), end(vec));
	
	auto dp = make_v<i64>(n + 2, n + 1);
	for(int i = 0; i < n + 2; i++) for(int j = 0; j < n + 1; j++) dp[i][j] = 1LL << 60; dp[0][0] = 0;
	for(int i = 1; i < n + 1; i++) {
		auto nxt = dp;
		for(int j = 0; j < i; j++) { // (j, i)
			for(int k = 0; k < n; k++) {
				i64 cost = 0;
				const i64 L = vec[j].first, R = vec[i].first;
				for(int l = j + 1; l < i; l++) {
					i64 X = vec[l].first, Y = vec[l].second;
					
					cost += std::min({std::abs(L - X), std::abs(R - X), std::abs(0 - X)}) * Y;
				}
				nxt[i][k + 1] = std::min(nxt[i][k + 1], dp[j][k] + cost);
			}
		}

		nxt.swap(dp);
	}

	std::vector<i64> ret(n + 1, 1LL << 60);
	for(int k = 1; k < n + 1; k++) {
		for(int i = 0; i < n + 1; i++) {
			i64 cost = 0;
			const i64 L = vec[i].first, R = 0;
			for(int l = i + 1; l < n + 1; l++) {
				i64 X = vec[l].first, Y = vec[l].second;
				cost += std::min({std::abs(L - X), std::abs(R - X), std::abs(0 - X)}) * Y;
			}
			
			ret[k] = std::min(ret[k], dp[i][k] + cost);
		}
	}
	
	ret[0] = 0;
	for(int i = 0; i < n; i++) ret[0] += std::abs(x[i] * y[i]);
	return ret;
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n), b(n), c(n);
	for(int i = 0; i < n; i++) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);

	std::vector<i64> ans(n + 1, 1LL << 60);
	for(int i = 0; i < (1 << n); i++) {
		std::vector<i64> x, y, z, w, test;
		for(int k = 0; k < n; k++) {
			if(i >> k & 1) {
				x.push_back(a[k]);
				y.push_back(c[k]);
			} else {
				z.push_back(b[k]);
				w.push_back(c[k]);
			}
		}
		auto X = solve(x, y);
		auto Y = solve(z, w);

		for(int j = 0; j < X.size(); j++) {
			for(int k = 0; k < Y.size(); k++) {
				if(j + k < n + 1) ans[j + k] = std::min(ans[j + k], X[j] + Y[k]);
			}
		}
	}

	for(int i = 1; i < n + 1; i++) ans[i] = std::min(ans[i], ans[i - 1]);
	
	for(auto v: ans) printf("%lld\n", v);
	return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }

    long long Ans = 0;

    for (int i = 0; i < N; i++)
    {
        int j = N - i - 1;
        if ((A[j] + Ans) % B[j] != 0)
            Ans += B[j] - ((A[j] + Ans) % B[j]);
    }

    cout << Ans << endl;
}

Measured memory_bytes: 1024
a,b,c = map(int,input().split())
matrix1 = []
matrix2 = []
matrix3 = [[0 for i in range(c)]for j in range(a)]
for i in range(a):
    matrix1.append(list(map(int,input().split())))
for i in range(b):
    matrix2.append(list(map(int,input().split())))
    
for i in range(a):
    for j in range(c):
        for k in range(b):
            matrix3[i][j]+=matrix1[i][k]*matrix2[k][j]

for i in range(a):
    print(' '.join(map(str,matrix3[i])))


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

int main() {
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   if(abs(a - c) <= d ||(abs(a - b) <= d && abs(b - c) <= d)){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }

}

Measured memory_bytes: 256
N =int(input())
A = [a%4 for a in list(map(int,input().split()))]
c0 = A.count(0)
c1 = A.count(1)
c2 = A.count(2)
c3 = A.count(3)
if c2>=2:
  if c1+c3<=c0:
    print("Yes")
  else:
    print("No")
else:
  if c1+c2+c3-1<=c0:
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 14252
class segment_tree:
    __slots__ = ["op_M", "e_M","N","N0","dat"]
    def __init__(self, N, operator_M, e_M):
        self.op_M = operator_M
        self.e_M = e_M
        self.N = N
        self.N0 = 1<<(N-1).bit_length()
        self.dat = [self.e_M]*(2*self.N0)
    
    # 長さNの配列 initial で初期化
    def build(self, initial):
        self.dat[self.N0:self.N0+len(initial)] = initial[:]
        for k in range(self.N0-1,0,-1):
            self.dat[k] = self.op_M(self.dat[2*k], self.dat[2*k+1])

    # a_k の値を x に更新
    def update(self,k,x):
        k += self.N0
        self.dat[k] = x
        k >>= 1
        while k:
            self.dat[k] = self.op_M(self.dat[2*k], self.dat[2*k+1])
            k >>= 1

    # 区間[L,R]をopでまとめる
    def query(self,L,R):
        L += self.N0; R += self.N0 + 1 
        sl = sr = self.e_M
        while L < R:
            if R & 1:
                R -= 1
                sr = self.op_M(self.dat[R],sr)
            if L & 1:
                sl = self.op_M(sl,self.dat[L])
                L += 1
            L >>= 1; R >>= 1
        return self.op_M(sl,sr)

    def get(self, k): #k番目の値を取得。query[k,k]と同じ
        return self.dat[k+self.N0]
    
    """
    f(x_l*...*x_{r-1}) が True になる最大の r 
    つまり TTTTFFFF となるとき、F となる最小の添え字
    存在しない場合 n が返る
    f(e_M) = True でないと壊れる
    """
    def max_right(self,l,f):
        if l == self.N: return self.N;
        l += self.N0
        sm = self.e_M
        while True:
            while l&1==0:
                l >>= 1
            
            if not f(self.op_M(sm,self.dat[l])):
                while l < self.N0:
                    l *= 2
                    if f(self.op_M(sm,self.dat[l])):
                        sm = self.op_M(sm,self.dat[l])
                        l += 1
                return l - self.N0

            sm = self.op_M(sm,self.dat[l])
            l += 1
            if (l & -l) == l: break
        
        return self.N

    """
    f(x_l*...*x_{r-1}) が True になる最小の l
    つまり FFFFTTTT となるとき、T となる最小の添え字
    存在しない場合 r が返る
    f(e_M) = True でないと壊れる
    """
    def min_left(self,r,f):
        if r == 0: return 0
        r += self.N0
        sm = self.e_M
        
        while True:
            r -= 1
            while r > 1 and r&1:
                r >>= 1

            if not f(self.op_M(self.dat[r],sm)):
                while r < self.N0:
                    r = r*2 + 1
                    if f(self.op_M(self.dat[r],sm)):
                        sm = self.op_M(self.dat[r],sm)
                        r -= 1
                return r + 1 - self.N0

            sm = self.op_M(self.dat[r],sm)
            if (r & -r) == r: break

        return 0




        
###########################################
import sys
readline = sys.stdin.readline

n,q = map(int, readline().split())
*a, = map(int, readline().split())

seg = segment_tree(n,max,0)
seg.build(a)

for _ in range(q):
    idx,p,v = map(int, readline().split())
    if idx==1:
        seg.update(p-1,v)
    elif idx==2:
        print(seg.query(p-1,v-1))
    else:
        print(seg.max_right(p-1,lambda x: x < v)+1)


Measured memory_bytes: 101632
string = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
ans = 100
for a in alpha:
    tmp = 0
    ans_tmp = 0
    for s in string:
        if s == a:
            ans_tmp = max(ans_tmp, tmp)
            tmp = 0
        else:
            tmp += 1
    ans_tmp = max(ans_tmp, tmp)
    ans = min(ans, ans_tmp)
print(ans)

Measured memory_bytes: 3060
// ABC64-C-cpp.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a = vector<int>(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	bool c[8];
	for (size_t i = 0; i < 8; i++)
	{
		c[i] = false;
	}
	int count = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (a[i] < 400) c[0] = true;
		if (400 <= a[i] && a[i] < 800) c[1] = true;
		if (800 <= a[i] && a[i]< 1200) c[2] = true;
		if (1200 <= a[i] && a[i]< 1600) c[3] = true;
		if (1600 <= a[i] && a[i]< 2000) c[4] = true;
		if (2000 <= a[i] && a[i]< 2400) c[5] = true;
		if (2400 <= a[i] && a[i]< 2800) c[6] = true;
		if (2800 <= a[i] && a[i]< 3200) c[7] = true;
		if (3200 <= a[i]) count++;
	}
	int m = 0;
	for (size_t i = 0; i < 8; i++)
	{
		if (c[i]) m++;
	}
	cout << (m > 0 ? m : 1) << " " << m + count << endl;
    return 0;
}



Measured memory_bytes: 504
import Data.List (group)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  print $ f n m

f :: Int -> Int -> Int
f n m = m `div` minimum (filter (n <=) (factors m))

factors :: Integral a => a -> [a]
factors = map product . sequence . map (scanl (*) 1) . group . primeFactors

primeFactors :: Integral a => a -> [a]
primeFactors = primeFactors' primes
  where
    primeFactors' pps@(p:ps) n
      | n < 2              = []
      | n < p ^ (2 :: Int) = [n]  -- stop early
      | n `mod` p == 0     = p : primeFactors' pps (n `div` p)
      | otherwise          = primeFactors' ps n
    primeFactors' _ _ = error "`primes` is a infinite list"

primes :: Integral a => [a]
primes = 2 : filter (\n -> head (primeFactors n) == n) [3, 5 ..]


Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll N,X;
    cin >> N >> X;
    vll x(N);
    cin >> x;
    x.pb(X);
    sort(x.begin(),x.end());
    ll ans = x[1]-x[0];
    REP(i,N){
        ll tmp = x[i+1]-x[i];
        ans = __gcd(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4732
use std::error::Error;
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::str::{self, FromStr};

fn exec() {
    let mut sc = Scanner::new(io::stdin());
    let (n, m): (usize, usize) = (sc.ne(), sc.ne());
    let mut a = Vec::new();
    use std::collections::VecDeque;
    for _ in 0..n {
        let b: VecDeque<usize> = (0..m).map(|_| sc.ne::<usize>() - 1).collect();
        a.push(b);
    }
    let mut ans = n * 10;
    let mut used = vec![false; m];
    for _ in 0..m {
        let mut cnt = vec![0; m];
        for i in 0..n {
            if let Some(&x) = a[i].front() {
                cnt[x] += 1;
            }
        }
        let ma = *cnt.iter().max().unwrap();
        ans = std::cmp::min(ans, ma);
        for j in 0..m {
            if cnt[j] == ma {
                used[j] = true;
                break;
            }
        }
        for i in 0..n {
            while let Some(&x) = a[i].front() {
                if used[x] == false {
                    break;
                }
                a[i].pop_front();
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
pub struct Scanner<R> {
    bufread: BufReader<R>,
    id: usize,
    buf: Vec<u8>,
}
impl<R: Read> Scanner<R> {
    pub fn new(resource: R) -> Scanner<R> {
        Scanner {
            bufread: BufReader::new(resource),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.bufread.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    pub fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.is_empty() {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert_ne!(self.buf[l], b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!(
                    "parse error, {:?}",
                    String::from_utf8(self.buf[l..r].to_owned())
                )
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    pub fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
#include<iostream>
#include<cstring>
#define MaxNum 10000100
using namespace std;
bool e[MaxNum];
int p[MaxNum],tn,mu[MaxNum],n;
void Mobius()
{
  e[1]=1;mu[1]=1;
  for (int i=2;i<=n;i++){
    if (!e[i]){p[++tn]=i;mu[i]=-1;}
    for (int j=1;j<=tn;j++){
      if (p[j]*i>n)break;
      mu[p[j]*i]=i%p[j]==0 ? 0 : -mu[i];
      e[p[j]*i]=1;
      if (i%p[j]==0)break;
    }
  }
}
int main()
{
  cin>>n; 
  // Mobius();
  // for(int i=2;i<=n;++i)
  //     mu[i]+=mu[i-1];
  //   for(int i=1;i<=n;++i)
  //  printf("%d: %d\n",i,mu[i]);
  // return 0;
  if(n%1000==0) cout<<0;
  else cout<<1000-n%1000<<endl;
}//Time:O(n)

Measured memory_bytes: 3584