akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;


const int MAXN = 200005;
vll G[MAXN];
ll dob[60][MAXN];

int main() {
    ll N, K; cin >> N >> K;
    vll A(N);
    rep(i, N) {
        cin >> A[i];
        G[A[i]].pb(i);
    }
    rep(a, MAXN) {
        int n = G[a].size();
        if (n == 0) continue;
        rep(j, n) {
            if (j == n - 1) dob[0][G[a][j]] = G[a][0] + N  - G[a][j] + 1;
            else dob[0][G[a][j]] = G[a][j + 1] - G[a][j] + 1;
        }
    }

    rep(k, 59) {
        rep(i, N) {
            if (dob[k][i] == LINF) dob[k + 1][i] = LINF;
            ll tmp = dob[k][(dob[k][i] + i) % N] + dob[k][i];
            dob[k + 1][i] = min(tmp, LINF);
        }
    }

    ll t = 0;
    for (int k = 59; k >= 0; k--) {
        if (t + dob[k][t % N] <= N * K) t = t + dob[k][t % N];
    }

    if (t == N * K) {
        cout << endl;
        return 0;
    }

    t %= N;

    while (t < N) {
        if (t + dob[0][t] - 1 > N - 1) { //A[t]の次の文字がもうない場合
            cout << A[t] << " ";
            t++;
        }
        else t = t + dob[0][t];
    }

    return 0;
}

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

using ll = long long;
using namespace std;

std::vector<long long> divisor(long long n){
    std::vector<long long > res;
    for(long long i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            long long j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    std::sort(res.begin(),res.end());
    return res;
}

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i += 2){
        cnt += ((int)divisor(i).size() == 8);
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct{ dis, x, y, dir int }
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].dis < h[j].dis }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }
func (h *hp) push(v pair)        { heap.Push(h, v) }
func (h *hp) pop() pair          { return heap.Pop(h).(pair) }
func (h hp) empty() bool         { return len(h) == 0 }

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	type vec struct{ x, y int }
	dir4 := [...]vec{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, m, k, x, y, tx, ty, newD int
	Fscan(in, &n, &m, &k, &x, &y, &tx, &ty)
	g := make([][]byte, n)
	for i := range g {
		Fscan(in, &g[i])
	}

	const inf int = 1e18
	dist := make([][][4]int, n)
	for i := range dist {
		dist[i] = make([][4]int, m)
		for j := range dist[i] {
			for k := range dist[i][j] {
				dist[i][j][k] = inf
			}
		}
	}
	dist[x-1][y-1] = [4]int{}
	h := hp{{0, x - 1, y - 1, 0}}
	for !h.empty() {
		p := h.pop()
		d, x, y, dir := p.dis, p.x, p.y, p.dir
		if dist[x][y][dir] < d {
			continue
		}
		for i, di := range dir4 {
			if xx, yy := x+di.x, y+di.y; 0 <= xx && xx < n && 0 <= yy && yy < m && g[xx][yy] == '.' {
				if i == dir {
					newD = d + 1
				} else if d == 0 {
					newD = 1
				} else {
					newD = ((d-1)/k+1)*k + 1
				}
				if newD < dist[xx][yy][i] {
					dist[xx][yy][i] = newD
					h.push(pair{newD, xx, yy, i})
				}
			}
		}
	}
	ans := inf
	for _, d := range dist[tx-1][ty-1] {
		if d < ans {
			ans = d
		}
	}
	if ans < inf {
		ans = (ans-1)/k + 1
	} else {
		ans = -1
	}
	Fprint(out, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 102588
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin
namespace IO{
	
cs int RLEN=1<<20|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline ll readll(){
	char ch=gc();
	ll res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	return top;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}

}
using IO::read;
using IO::readll;
using IO::readstring;
using IO::readchar;
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=200005;
struct pt{
	ll x,y;
	pt(ll _x=0,ll _y=0):x(_x),y(_y){}
	friend inline pt operator -(cs pt &a,cs pt &b){
		return pt(a.x-b.x,a.y-b.y);
	}
	friend inline ll operator *(cs pt &a,cs pt &b){
		return a.x*b.y-a.y*b.x;
	}
}q[N];
int n,top,b[N];
ll a[N],tmp[N],c[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(int i=1;i<=n;i++)a[i]=readll();
	for(int i=1;i<=n;i++)b[i]=read();
	int ps=1,m=0;
	for(int i=2;i<=n;i++)if(a[i]>a[ps])ps=i;
	for(int i=ps;i<=n;i++)tmp[m++]=a[i];
	for(int i=1;i<ps;i++)tmp[m++]=a[i];
	tmp[m]=tmp[0];
	for(int i=0;i<=n;i++)a[i]=tmp[i];
	m=0;
	for(int i=ps;i<=n;i++)tmp[m++]=b[i];
	for(int i=1;i<ps;i++)tmp[m++]=b[i];
	tmp[m]=tmp[0];
	for(int i=0;i<=n;i++)b[i]=tmp[i];
	for(int i=2;i<=n;i++)c[i]=2ll*(c[i-1]+b[i-1])-c[i-2];
	for(int i=0;i<=n;i++){
		pt now=pt(i,a[i]-c[i]);
		while(top>=2&&(q[top]-q[top-1])*(now-q[top-1])>=0)top--;
		q[++top]=now;
	}
	ll res=0;
	for(int i=2;i<=top;i++){
		int d=q[i].x-q[i-1].x;
		res+=q[i-1].y*(d+1)+q[i].y*(d-1);
	}
	for(int i=0;i<n;i++)res+=2*c[i];
	printf("%.15lf\n",0.5*res/n);return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	h1=h1*60+m1;
	h2=h2*60+m2;
	int ans=max(h2-h1-k,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
(defrecord Pair [^int y ^int x])
(def ^:const D-Y-X
  (list
    (Pair. -1 -1) (Pair. -1 0) (Pair. -1 1)
    (Pair. 0 -1) (Pair. 0 1)
    (Pair. 1 -1) (Pair. 1 0) (Pair. 1 1)))

(defn get_H_W []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn set_Array [^"[[C" Array H W]
  (dotimes [h H]
    (->> (read-line)
      (char-array W)
      (aset Array h))))

(defn Minesweeper [^"[[C" Array H W]
  (doseq [x (range W)
          y (range H)
          :when (not= \# (aget ^"[C" (aget Array y) x))]
    (with-local-vars [counts (unchecked-int 0)]
      (doseq [d-y-x D-Y-X
              :let [dx (unchecked-add-int x (:x d-y-x))
                    dy (unchecked-add-int y (:y d-y-x))]
              :when (and
                      (<= 0 dx)
                      (< dx W)
                      (<= 0 dy)
                      (< dy H)
                      (= \# (aget ^"[C" (aget Array dy) dx)))]
        (var-set counts (unchecked-inc-int @counts)))
      (->> @counts
        (unchecked-add-int (unchecked-int \0))
        unchecked-char
        (aset ^"[C" (aget Array y) x)))))

(defn output [^"[[C" Array]
  (-> (areduce Array idx ret ""
        (str ret
          (apply str (aget Array idx))
          "\n"))
    print))

(let [[H W] (get_H_W)]
  (doto (make-array Character/TYPE H W)
    (set_Array H W)
    (Minesweeper H W)
    (output)))

Measured memory_bytes: 70796
n, m = map(int, input().split())

a = []
b = []

for i in range(n):
	a.append(list(map(int, input().split())))

for i in range(m):
	b.append(int(input()))

for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j] * b[j]
	print(ans)



Measured memory_bytes: 6012
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;


int K[201000];
int S[201000];
ll dp[2010][2010];
ll SUM[201000];

ll sum(int a, int b, int L) {
  int tmp = a;
  a = min(a, b);
  b = max(tmp, b);

  return (SUM[b] - SUM[a-1]) / L;
}

int main(){
  int N, M, L;
  cin >> N >> M >> L;
  REP(i, N) cin >> K[i];
  REP(i, M) cin >> S[i];
  REP(i, M) SUM[i+1] = SUM[i] + S[i];
  sort(K, K + N);
  
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }

  memset(dp, -1, sizeof(dp));
  dp[1][0] = sum(K[0], K[1], L);
  
  
  REP2(i, 1, N - 1){
    REP(j, N){
      if(dp[i][j] == -1) continue;
      ll t1 = dp[i][j] + sum(K[i+1], K[i], L);
      ll t2 = dp[i][j] + sum(K[i+1], K[j]  , L);
      
      if(dp[i+1][j] == -1 || dp[i+1][j] > t1){
        dp[i+1][j] = t1;
      }
      if(dp[i+1][i] == -1 || dp[i+1][i] > t2){
        dp[i+1][i] = t2;
      }
    }
  }

  ll ans = 1e15;
  REP(i, N - 1) if(dp[N-1][i] != -1){
    ans = min(dp[N-1][i] + sum(K[N-1], K[i], L), ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 33928
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<utility>
#include<queue>
#include<stdio.h>
//#include<sys/time.h>
#include<random>
#include<fstream>
#define INF 2000000000
using namespace std;
typedef std::pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
int n,ans,cnt;
signed main(){
	cin>>n;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(a==b)cnt++;
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
		if(ans>=3)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void)
{
    int i,j,k,l,m,imput;
    m=0;

    while(scanf("%d",&imput)!=EOF)
    {
        for(i=0;i<10;i++)
        {
            for(j=0;j<10;j++)
            {
                for(k=0;k<10;k++)
                {
                    for(l=0;l<10;l++)
                    {
                        if(i+j+k+l==imput)
                        {
                            m++;
                        }
                    }
                }
            }
        }
        printf("%d\n",m);
        m=0;
    }

     return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
const ll MOD=1000000007;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn = 1e3+1;
int prime [maxn];
void seive () {
  for (int i=2; i*i<=maxn ; ++i) {
    if (!prime[i]) {
      F (j,i*i,maxn,i) {
        prime[j]=1;
      }
    }
  }
}
int main()
{
  ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
  int n;
  cin>>n;
  seive();
  ll ans=1;
  F (i,2,n+1,1) {
    ll cnt=0;
    int j=1;
    if (!prime[i]) {
    while (pwr(i,j)<=n) {
      cnt+=n/pwr(i,j);
      ++j;
    }
    ++cnt;
    ans=(ans*cnt)%MOD;
  }
  }
 cout<<ans;
return 0;
}




Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct UnionFind {
  vector<int> c, s;
  UnionFind(size_t n) : c(n), s(n, 1) { iota(begin(c), end(c), 0); }
  int root(int i) { return c[i] == i ? i : (c[i] = root(c[i])); }
  bool same(int i, int j) { return root(i) == root(j); }
  void unite(int i, int j) {
    i = root(i); j = root(j);
    if (i != j) {
      if (s[i] > s[j]) { c[j] = i; s[i] += s[j]; }
      else { c[i] = j; s[j] += s[i]; }
    }
  }
  int size(int i) { return s[root(i)]; }
};

const i64 W = 100000;
i64 n;
using P = pair<i64, i64>;
vector<P> ps;
vector<vector<i64>> xp, yp;

int main() {
  cin >> n;
  init_n(xp, W + 1);
  init_n(yp, W + 1);

  UnionFind uf(n);
  for (i64 i = 0; i < n; ++i) {
    i64 x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
    if (!xp[x].empty()) uf.unite(xp[x].back(), i);
    xp[x].push_back(i);
    if (!yp[y].empty()) uf.unite(yp[y].back(), i);
    yp[y].push_back(i);
  }

  vector<set<i64>> sx(n), sy(n);
  for (i64 i = 0; i < n; ++i) {
    i64 r = uf.root(i);
    sx[r].insert(ps[i].first);
    sy[r].insert(ps[i].second);
  }

  vector<bool> done(n);
  i64 ans = 0;
  for (i64 i = 0; i < n; ++i) {
    i64 r = uf.root(i);
    if (!done[r]) {
      ans += sx[r].size() * sy[r].size() - uf.size(r);
      done[r] = true;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 24944
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
char s[200005];
int main(){
	scanf("%s",s+1);int len=strlen(s+1),tail=0,ans=0;
	for(int i=1;i<=len;++i){
		if(s[i]=='S') ++tail;
		else{
			if(tail) tail--,ans++;
		}
	}
	cout<<(len-2*ans);
	return 0;
}


Measured memory_bytes: 384
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();

    LL t,n,i,j,k,x,y,c,m;
    VS v;
    string str;
    cin >> n;
    REP(i, n){
        cin >> str;
        v.PB(str);
        sort(all(v[i]));
    }
    map<string, LL> mpp;
    REP(i, n){
        mpp[v[i]]++;
    }
    LL res = 0;
    for(auto num : mpp){
        res += ((num.ss) * (num.ss - 1) / 2);
    }
    cout << res;

    
}

Measured memory_bytes: 16628
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 12:39-

            int n = sc.nextInt();
            int cnt = 0;
            for (int i = 1; i <= n; i++) {
                cnt += String.valueOf(i).length() % 2;
            }

            out.println(cnt);

        }
    }

}


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

int solve(int a, int b, int c, int k) {
	int ans = a+b+c;
	if (k == 0) return ans;
	return max(ans, max(solve(2*a,b,c,k-1),max(solve(a,2*b,c,k-1),solve(a,b,2*c,k-1))));
}

int main () {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << solve(a,b,c,k) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
	LL h,num=1,sum = 0;
  	cin>>h;
  	while (h > 1){
    	h >>=1;
      	sum += num;
      	num <<= 1;
    }
  	sum += num;
  	cout<<sum<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++){
      cin >> s[i];
    }
    sort(s.begin(), s.end());
    int sum = 0;
    for (int i = 1; i < n - 1; i++){
      sum += s[i];
    }
    cout << sum / (n - 2) << endl;
  }
}


Measured memory_bytes: 3144
#include<stdio.h>

main(){
  int i,j,N,mini,A[100],count=0,swap;
  
  scanf("%d",&N);
  for(i=0 ; i<N ; i++) scanf("%d",&A[i]);
  
  for(i=0 ; i<N ; i++){
    mini = i;
    for(j=i ; j<N ; j++){
      if(A[j]<A[mini]){
	mini = j;
      }
    } 
    if(mini != i){
      swap = A[i];
      A[i] = A[mini];
      A[mini] = swap;
      count++;
      
    }
  }
  
  for(i=0 ; i<N ; i++){
    printf("%d",A[i]);
    if(i<N-1) printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

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

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<bool> H(h,false),W(w,false);
  rep(i,h)rep(j,w){
    if(a[i][j]=='#'){
      H[i]=true;W[j]=true;
    }
  }
  rep(i,h){
    if(H[i]){
      rep(j,w){
        if(W[j])cout<<a[i][j];
        if(j==w-1)cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int n; cin >> n;
	int a[n]; REP(i, n) cin >> a[i];

	int right = 0;
	long long sum = 0, xsum = 0;
	long long ans = 0;
	REP(left, n){
		while(right < n && sum + a[right] == (xsum ^ a[right]) ){
			sum += a[right];
			xsum ^= a[right];
			right++;
		}

		ans += right - left;

		if(left == right){
			right++;
		}else{
			sum -= a[left];
			xsum ^= a[left];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, M;
vector<int> G[101010];
int Time[101010];
int ans[101010];

void solve() {
    FOR (N + 10)
        Time[i] = -1;
    Time[0] = 0;

    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int now = que.front();
        que.pop();
        for (auto& nxt : G[now]) {
            if (Time[nxt] == -1) {
                Time[nxt] = Time[now] + 1;
                que.push(nxt);
            }
        }
    }

    FOR (N + 10) {
        ans[i] = -1;
    }

    FOR (i, 1, N) {
        for (auto& nxt : G[i]) {
            if (Time[i] - 1 == Time[nxt]) {
                ans[i] = nxt;
            }
        }
    }
    FOR (i, 1, N) {
        if (ans[i] == -1) {
            No();
            return;
        }
    }
    Yes();
    FOR (i, 1, N) {
        cout << ans[i] + 1 << endl;
    }
}

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

    cin >> N >> M;
    FOR (M) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        G[A].emplace_back(B);
        G[B].emplace_back(A);
    }

    solve();
    return 0;
}


Measured memory_bytes: 13832
N,X = map(int,input().split())
L = list(map(int,input().split()))

D = []
D.append(0)

for i in range(0,N):
  D.append(D[i]+L[i])

cnt = 0
for d in D:
  if d <= X:
    cnt += 1
    
print(cnt)

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

int main() {
  int N, M, X;
  std::cin >> N >> M >> X;

  std::vector<int> C(N);
  std::vector<std::vector<int>> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> C[i];
    A[i].resize(M);
    for (int j = 0; j < M; ++j) {
      std::cin >> A[i][j];
    }
  }

  bool res = false;
  int resCost = 1 << 30;
  for (int k = 0; k < (1 << N); ++k) {
    std::vector<int> bit(N, 0);
    for (int i = 0; i < N; ++i)
      if (k & (1 << i))
        bit[i] = 1;

    std::vector<long long> val(M, 0LL);
    int cost = 0;
    for (int i = 0; i < N; ++i) {
      if (bit[i] == 0)
        continue;
      cost += C[i];

      for (int j = 0; j < M; ++j)
        val[j] += A[i][j];
    }

    bool ok = true;
    for (int j = 0; j < M; ++j) {
      if (val[j] < X) {
        ok = false;
        break;
      }
    }

    if (ok) {
      res = true;
      if (cost < resCost)
        resCost = cost;
    }
  }

  if (!res)
    std::cout << "-1" << std::endl;
  else
    std::cout << resCost << std::endl;
}


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

int main(){
  int N; cin >> N;
  int x, y;
  vector<pair<int64_t, int64_t>> arm(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> x >> y;
    arm[i].first = x + y;
    arm[i].second = x - y;
  }
  sort(arm.begin(), arm.end());
  int ans = 0, t = -1e9;
  for(int i = 1; i <= N; i++){
    if(t <= arm[i].second){
      ans++;
      t = arm[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

vector<int> arr(500001), tree(3000000);

void build(int node, int start, int end){
	if(start == end){
		tree[node] = arr[start];
		return;
	}
	int mid = (start + end)/2;
	build(2*node, start, mid);
	build(2*node+1, mid+1, end);
	tree[node] = tree[2*node] | tree[2*node+1];
}

void update(int node, int start, int end, int idx, int val){
	if(start == end){
		arr[start] = val;
		tree[node] = arr[start];
		return;
	}
	int mid = (start + end)/2;
	if(idx <= mid)
		update(2*node, start, mid, idx, val);
	else
		update(2*node+1, mid+1, end, idx, val);
	tree[node] = tree[2*node] | tree[2*node+1];
}

int query(int node, int start, int end, int l, int r){
	if(start > end || start > r || end < l)
		return 0LL;
	if(start >= l && end <= r)
		return tree[node];
	int mid = (start + end)/2;
	return query(2*node, start, mid, l, r) | query(2*node+1, mid+1, end, l, r);
}

void solve(){
    int n; cin>>n;
    string s; cin>>s;
    for(int i=0;i<n;i++){
    	arr[i] = (1LL<<(int)(s[i]-'a'));
    }
    build(1, 0, n-1);
    int q; cin>>q;
    while(q--){
    	int type; cin>>type;
    	if(type == 1){
    		int idx; cin>>idx; --idx;
    		char ch; cin>>ch;
    		int val = (1LL<<(int)(ch-'a'));
    		update(1, 0, n-1, idx, val);
    	}
    	else{
    		int l, r; cin>>l>>r; --l; --r;
    		int val = query(1, 0, n-1, l, r);
    		int ans = 0;
    		for(int i=0;i<26;i++)
    			if(val&(1LL<<i))
    				ans++;
    		cout<<ans<<endl;
    	}
    }
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 28436
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
vector < string > S;

bool check(int A, int B) {
	REP(i,N) REP(j,N) {
		int px = (A + i) % N;
		int py = (B + j) % N;
		int nx = (py - A + N) % N;
		int ny = (px - B + N) % N;
		char a = S[i][j];
		char b = S[nx][ny];
		if (a != b) return false;
	}
	return true;
}

int main() {

    cin >> N;
    S.resize(N);
    for (auto &a : S) cin >> a;

    int ans = 0;
    REP(i,N) {
    	if (check(i, 0)) ans += N;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

// 素因数分解する
map<ll, int> prime_factor(ll n) {
	map<ll, int> ret;
	for (ll i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++ret[i]; n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

int main() {
	int n; cin >> n;
	vector<ll> A(n);
	vector<map<ll, int>> a(n);
	// lcmをとる
	map<ll, int> lcm;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
		a[i] = prime_factor(A[i]);
		for (auto& e : a[i])
			lcm[e.first] = max(lcm[e.first], e.second);
	}
	ll L = 1;
	for (auto& e : lcm)
		L = (L * modpow(e.first, e.second)) % mod;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += L * inverse(A[i]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll fac[200001];
ll nCr(ll n,ll r)
{
    ll num=fac[n];
    ll den=(fac[n-r]*fac[r])%mod;
    
    return (num*power(den,mod-2))%mod;
}

int main()
{
    fast();
    fac[0]=1;
    for(ll i=1;i<=100010;i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }
    ll n;
    cin>>n;
    vi a(n+1);
    cin>>a;
    
    vi ind(n+2,-1);
    ll ind1,ind2;
    for(ll i=0;i<=n;i++)
    {
        if(ind[a[i]]!=-1)
        {
            ind1=ind[a[i]];
            ind2=i;
            break;
        }
        else
        {
            ind[a[i]]=i;
        }
    }
    
    vi ans(n+1,0);
    for(ll i=0;i<=n;i++)
    {
        //len is i+1
        ans[i]=nCr(n+1,i+1);
        // The particular case: ind1 is taken while none of ind1+1,....ind2 has been taken
        
        ll num=n-(ind2-ind1);
        if(num>=i)
            ans[i]=(ans[i]+mod-nCr(num,i))%mod;
    }
    for(ll i=0;i<=n;i++)
    {
        cout<<ans[i]<<"\n";
    }
}


Measured memory_bytes: 6284
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def f(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))


Measured memory_bytes: 3060
N = int(input())
a = list(map(int,input().split(" ")))


def is_positive(sumval,modify):
	if sumval <= 0:
		modify += abs(sumval - 1)
		sumval = 1

	return sumval,modify

def is_negative(sumval,modify):
	if sumval >= 0:
		modify += abs(sumval + 1)
		sumval = (-1)


	return sumval,modify

pos_sum,pos_modi = is_negative(a[0],0)
neg_sum,neg_modi = is_positive(a[0],0)

for i in range(1,N):
	tmp_sum,tmp_modi = is_positive(pos_sum + a[i],pos_modi)
	pos_sum,pos_modi = is_negative(neg_sum + a[i],neg_modi)
	neg_sum = tmp_sum
	neg_modi = tmp_modi

print(min(pos_modi,neg_modi))


Measured memory_bytes: 14644
function main(input) {
    const nums = input.trim().split(/\s/).map(str=>Number(str));
    const res = nums[1] % nums[0] === 0 ? nums[1] + nums[0] : nums[1] - nums[0];
    console.log(res);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
# 初期入力
N= int(input())
S =input()


#
R_index=[]
G_index=[]
B_index=[]
for i,v in enumerate(S):
    if v =="R":
        R_index.append(i)
    if v =="G":
        G_index.append(i)
    if v =="B":
        B_index.append(i)

# 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK
R_B =[]
B_G =[]
count_ij_jk_onaji =0
for r in R_index:
    for g in G_index:
        if 0<=g-(r-g) and g-(r-g)<N  :
            #if S[g-(r-g)]=="B" and r<g:
            if S[g-(r-g)]=="B" :
                count_ij_jk_onaji +=1
               # print(r,g,g-(r-g),"B")
for b in B_index:
    for r in R_index:
        if 0<=r-(b-r) and r-(b-r)<N :
            #if S[r-(b-r)] == "G" and b<r:
            if S[r-(b-r)] == "G" :
                count_ij_jk_onaji +=1
                #print(r,b,r-(b-r),"G")
for g in G_index:
    for b in B_index:
        if 0<=b-(g-b) and b-(g-b)<N :
            #if S[b-(g-b)] =="R" and g<b:
            if S[b-(g-b)] =="R":
                count_ij_jk_onaji +=1
                #print(b,g,b-(g-b),"R")

            
#3つとも異なる文字=all
kotae_all = len(R_index) * len(G_index) * len(B_index) 
print(kotae_all -count_ij_jk_onaji)

Measured memory_bytes: 9252
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    a = 14;
  }
  if (b == 1) {
    b = 14;
  }
  if (a == b) {
    D("Draw");
  } else if (a > b) {
    D("Alice");
  } else {
    D("Bob");
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
template<class T,class U>void cinpb(T &v, U n) { rep(i, n){cill(a);v.pb(a);} }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    function<int64(int64, int64)> gcd = [&gcd](int64 x, int64 y){
        return !y ? x : gcd(y, x % y);
    };
    function<int64(int64, int64)> lcm = [&gcd](int64 x, int64 y){
        return x * y / gcd(x, y);
    };
    cill(n);
    cill(m);
    LL vl[n+1];
    LL lc = 1;
    rep(i, n){
        cill(a);vl[i]=a/2;lc = lcm(lc, vl[i]);
        if (lc > m){
            co(0);
            return 0;
        }
    }
    rep(i, n){
        if (lc / vl[i] % 2 == 0){
            co(0);
            return 0;
        }
    }
    LL ans = (m / lc + 1) / 2;
    co(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n;cin>>n;
	v a(n);in(a,n);
	map<int,int>freq;
	int ans=0;
	f(i,n)	
	{
		ans+=freq[i-a[i]];
		freq[a[i]+i]++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int mod = 1000000007;

int fact[200005];

int multiply(int a, int b){
	return int((1LL*a*b)%mod);
}

int pw(int x,int y){
	int r=1;
	while(1){
		if(y&1)r=multiply(r,x);
		if(y>>=1)x=multiply(x,x);else
			break;
	}
	return r;
}

int inv(int x){
	return pw(x,mod-2);
}

int C(int a, int b){
	return multiply(fact[a + b], multiply(inv(fact[a]), inv(fact[b])));
}

int main(){

	//freopen("1.in", "r", stdin);freopen("1.out", "w", stdout);

	fact[0] = 1;
	for(int i = 1; i < 200005; ++i){
		fact[i] = multiply(fact[i - 1], i);
		//cout << i << " " ;
	}
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int res = 0;
	for(int i = b + 1; i <= w; ++i){
		res = (res + multiply(C(h - a - 1, i - 1), C(a - 1, w - i))) % mod;
	}
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    long a;
    int b,c;
    scanf("%ld %d %d",&a,&b,&c);
    int k;
    for(k=1;k<=100000;k++){
        if((a*k-c)%b==0){
            printf("YES\n");
            return 0;
        }    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException{
		ArrayList<String> listClass = new ArrayList<String>(0);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		while((input = br.readLine()) != null){
			double weight = Double.parseDouble(input);
			listClass.add(getWeightClass(weight));
		}
		
		for(String str : listClass){
			System.out.println(str);
		}
	}
	
	public static String getWeightClass(double weight){
		if(weight > 91.0){
			return "heavy";
		}
		else if(weight > 81.0){
			return "light heavy";
		}
		else if(weight > 75.0){
			return "middle";
		}
		else if(weight > 69.0){
			return "light middle";
		}
		else if(weight > 64.0){
			return "welter";
		}
		else if(weight > 60.0){
			return "light welter";
		}
		else if(weight > 57.0){
			return "light";
		}
		else if(weight > 54.0){
			return "feather";
		}
		else if(weight > 51.0){
			return "bantam";
		}
		else if(weight > 48.0){
			return "fly";
		}
		else{
			return "light fly";
		}
	}
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  if(n!=1&&m!=1) cout << (n-2)*(m-2) << endl;
  else if(n==m) cout << 1 << endl;
  else cout << max(n,m)-2 << endl;
  return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W,K;
    cin >> H >> W >> K;
    string s[310];
    rep(i,0,H) cin >> s[i];
    ll ans[310][310] = {};
    bool exists[310] = {};
    vector<ll> pos[310];
    rep(i,0,H) pos[i].push_back(-1);
    rep(h,0,H){
        rep(w,0,W){
            if(s[h][w] == '#') exists[h] = true;
            if(s[h][w] == '#') pos[h].push_back(w);
        }
    }
    ll color = 1;
    rep(h,0,H){
        if(not exists[h]) continue;
        ll sz = pos[h].size();
        rep(i,0,sz-1){
            rep(j,pos[h][i]+1, pos[h][i+1]+1){
                ans[h][j] = color;
            }
            color++;
        }
        rep(j,pos[h][sz-1]+1, W) ans[h][j] = color-1;
    }
    rep(h,0,H){
        if(exists[h]){
            rrep(i,h-1,0){
                if(not exists[i]){
                    rep(w,0,W) ans[i][w] = ans[i+1][w];
                }

            }
            rep(i,h+1,H){
                if(not exists[i]){
                    rep(w,0,W) ans[i][w] = ans[i-1][w];
                }
            }
            break;
        }
    }
    rep(h,0,H){
        rep(w,0,W){
            cout << ans[h][w] << " \n"[w==W-1];
        }
    }



    

}

Measured memory_bytes: 2816
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    def ch(s):
        t=s[::-1]
        if s==t:
            return True
        else:
            return False
        
    S=input()
    N=len(S)
    
    if ch(S) and ch(S[:(N-1)//2]) and ch(S[(N+3)//2-1:]):
        print("Yes")
    else:
        print("No")
        

          
main()

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct RU
{
    using t1 = int;
    using t2 = int;
    static t2 id2() { return -1; }
    static t1 op2(const t1 &l, const t2 &r) { return r == id2() ? l : r; }
    static t2 op3(const t2 &l, const t2 &r) { return r == id2() ? l : r; }
};

template <typename M>
class lazy_segment_tree
{
    using T1 = typename M::t1;
    using T2 = typename M::t2;
    const int h, n;
    vector<T1> data;
    vector<T2> lazy;
    void push(int node)
    {
        if (lazy[node] == M::id2())
            return;
        lazy[node << 1] = M::op3(lazy[node << 1], lazy[node]);
        lazy[(node << 1) | 1] = M::op3(lazy[(node << 1) | 1], lazy[node]);
        lazy[node] = M::id2();
    }

  public:
    lazy_segment_tree(int n_, T1 v1)
        : h(ceil(log2(n_))), n(1 << h), data(n_, v1), lazy(n << 1, M::id2()) {}
    lazy_segment_tree(const vector<T1> &data_)
        : h(ceil(log2(data_.size()))), n(1 << h), data(data_), lazy(n << 1, M::id2()) {}
    void update(int l, int r, T2 val)
    {
        l += n, r += n;
        for (int i = h; i > 0; i--)
            push(l >> i), push(r >> i);
        r++;
        while (l < r)
        {
            if (l & 1)
                lazy[l] = M::op3(lazy[l], val), l++;
            if (r & 1)
                r--, lazy[r] = M::op3(lazy[r], val);
            l >>= 1;
            r >>= 1;
        }
    }
    T1 find(int p)
    {
        T1 res = data[p];
        p += n;
        while (p)
            res = M::op2(res, lazy[p]), p >>= 1;
        return res;
    }
};

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

    int n, q;
    cin >> n >> q;
    lazy_segment_tree<RU> st(111111, (1LL << 31) - 1);
    for (int i = 0; i < q; i++)
    {
        ll com;
        cin >> com;
        if (com)
        {
            int idx;
            cin >> idx;
            cout << st.find(idx) << endl;
        }
        else
        {
            int s, t, x;
            cin >> s >> t >> x;
            st.update(s, t, x);
        }
    }
}



Measured memory_bytes: 4432