akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

map<int,int> m;
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		int x;
		cin >> x;
		m[x - 1]++;
		m[x]++;
		m[x + 1]++;
	}
	int ans = 0;
	for(auto x : m){
		ans = max(ans, x.se);
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6272
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll n,k;
V weight;
bool judge(ll x){
    priority_queue<ll> q;
    rep(i,k){
        q.push(x);
    }
    rep(i,n){
        ll k=q.top();
        if(k<weight[i]){
            return false;
        }
        k-=weight[i];
        q.push(k);
    }
    return true;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<string> vec(n);
    rep(i,n)cin>>vec[i];
    rep(i,n){
        sort(all(vec[i]));
    }
    map<string,ll> mp;
    rep(i,n){
        mp[vec[i]]++;
    }
    ll res=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ll k=itr->second;
        if(k>=2){
            res+=(k)*(k-1)/2;
        }
    }
    cout<<res<<endl;
}


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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

namespace ns {
	int N;
	vector<int> left;
	vector<int> mid;

	vector<int> right(int lp, int mp, int w) {
		if (w <= 0) return vector<int>(0);
		int root = left[lp];
		FOR(i, 0, w) {
			if (mid[mp+i] == root) {
				int wl = i, wr = w-wl-1;
				vector<int> la = right(lp+1, mp, wl);
				vector<int> ra = right(lp+1+wl, mp+i+1, wr);
				vector<int> res;
				REP(j, la.size()) res.pb(la[j]);
				REP(j, ra.size()) res.pb(ra[j]);
				res.pb(root);
				return res;
			}
		}
		assert(false);
		return vector<int>();
	}

	void main() {
		std::ios::sync_with_stdio(false);
		std::cin.tie(0);
		cin >> N;
		left.resize(N); cin >> left;
		mid.resize(N); cin >> mid;
		vector<int> ans = right(0, 0, N);
		REP(i, N) {
			if (i) cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
}
int main() {
	ns::main();
}

Measured memory_bytes: 3204
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self, x, y):  # 同じグループか否か
        return self.find(x) == self.find(y)

    def roots(self):  # 根のリスト
        return [i for i, x in enumerate(self.parents) if x < 0]


n, m = map(int, input().split())
lang = [list(map(int, input().split()))[1:] for _ in range(n)]

uf = Unionfind(n + m)
for i, li in enumerate(lang):
    for lij in li:
        uf.union(i, lij - 1 + n)
bool = all(uf.same(0, i) for i in range(1, n))
print('YES' if bool else 'NO')


Measured memory_bytes: 91532
N = int(input(''))
A = input('')
a_n = A.split()
A_N = list(map(int, a_n))
num = 0 
for i in range(1,N):
    if A_N[i] >= A_N[i-1]:
        num += 0
    elif A_N[i] < A_N[i-1]:
        num += A_N[i-1] - A_N[i]
        A_N[i] = A_N[i-1]
print(num)

Measured memory_bytes: 33596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
ll n,a[N],b[N],c[N],s[N];
vector<P> g[N];
ll dep[N],siz[N];
void dfs(ll x,ll from,ll d){
    dep[x]=d;
    siz[x]=1;
    for(auto y:g[x])if(y.first!=from){
	dfs(y.first,x,d+1);
	siz[x]+=siz[y.first];
    }
}

ll dfs2(ll x,ll from,ll d){
    ll res=d;
    for(auto y:g[x])if(y.first!=from){
	res+=dfs2(y.first,x,d+c[y.second]);
    }
    return res;
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
	cin>>a[i]>>b[i];
	g[a[i]].push_back(make_pair(b[i],i));
	g[b[i]].push_back(make_pair(a[i],i));
    }
    dfs(1,0,0);
    //for(int i=1;i<=n;i++)cout<<i<<":"<<dep[i]<<" "<<siz[i]<<endl;
    for(int i=1;i<=n;i++)cin>>s[i];
    int pnt=-1;
    for(int i=0;i<n-1;i++){
	ll aa=a[i],bb=b[i];
	if(dep[aa]>dep[bb])swap(aa,bb);
	ll sb=siz[bb],sa=n-sb;
	if(sa==sb){pnt=i; continue;}
	//cout<<s[aa]<<" "<<s[bb]<<" "<<sa<<" "<<sb<<endl;
	c[i]=-(s[aa]-s[bb])/(sa-sb);
    }//cout<<pnt<<endl;
    if(~pnt){
	c[pnt]=0;
	ll res=dfs2(a[pnt],0,0);
	res=s[a[pnt]]-res;
	c[pnt]=res/(n/2);
    }
    for(int i=0;i<n-1;i++)cout<<c[i]<<endl;
    return 0;
}



Measured memory_bytes: 18816
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan2, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    ans = [0]*N
    p = 0

    for i in range(N):
        ans[i] = max(0, p - A[i])
        p = max(p, A[i])

    print(sum(ans))

if  __name__=='__main__':
    main()


Measured memory_bytes: 33396
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int n;
    cin>>n;
    bool ans=false;
    while(n>0)
    {
        if(n%10==7)
        {
            ans=true;
        }
        n=n/10;
    }
    if(ans)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3632
def main():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    skip = False
    for i, p in enumerate(P):
        if skip:
            skip = False
            continue
        if i == p-1:
            ans += 1
            skip = True
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53548
#include<iostream>
#include<iomanip>
#define PI 3.141592653589793
using namespace std;
int main(){
	double r;
	cin>>r;
	double s=PI*r*r;
	double l=2*PI*r;
	cout<<setprecision(100)<<s<<" ";
	cout<<setprecision(100)<<l<<"\n";
	return 0;
}


Measured memory_bytes: 3260
s=list(input())
count=0
i=0
j=len(s)-1
while j-i>=1:
    if s[i]==s[j]:
        i+=1
        j-=1
    elif s[i]=='x':
        count+=1
        i+=1
    elif s[j]=='x':
        count+=1
        j-=1
    else:
        print(-1)
        exit()
print(count)
    



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

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

    ll res = 0;
    for(int i=0; i<N; ++i) {
        int tmp = min(A[i], B[i]);
        res += tmp;
        B[i] -= tmp;
        tmp = min(A[i + 1], B[i]);
        res += tmp;
        A[i + 1] -= tmp;
    }
    cout << res << endl;
}

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

ll mod = 1000000000 + 7;
int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans=0;
    for(ll i=k; i<=n+1; i++){
        ll mn = (i-1)*i/2;
        ll mx = (n + n-i+1)*i/2;
        ans += mx - mn +1;
        ans = ans%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
N=int(input())
A=list(map(int,input().strip().split()))

h_sum=0
max_h=A[0]
for n in range(1,N):
    if A[n]<=A[n-1]:
        h_sum+=A[n-1]-A[n]
        A[n]=A[n-1]
    else:
        max_h=A[n]
print(h_sum)


Measured memory_bytes: 32056
def gcd(n,m):
    n,m = max(n,m),min(n,m)
    r = n % m
    while r > 0:
        n,m = m,r
        r = n % m
    return m
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in range(1,N):
    ans = gcd(ans,A[i])
print(ans)

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<vector<int>> a(n,vector<int>(n+1,0));
    for(int i=0;i<n;i++){
      for(int j=0;j<n+1;j++){
        cin >> a[i][j];
      }
    }
    vector<int> dp(1<<n,IINF);
    dp[0]=0;
    for(int i=1;i<(1<<n);i++){
      for(int j=0;j<n;j++){
        if(i&(1<<j)){
          int mint=a[j][0];
          for(int k=0;k<n;k++){
            if((i^(1<<j))&(1<<k)){
              mint=min(mint,a[j][k+1]);
            }
          }
          dp[i]=min(dp[i],dp[i^(1<<j)]+mint);
        }
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3388
N = int(input())
K = int(input())

def A(n):
    return n*2

def B(n):
    return n+K

ans = 1

for i in range(N):
    if A(ans) <= B(ans):
        ans = A(ans)
    else:
        ans = B(ans)
        
    
print(ans)


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

int main(){
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  long long int ans=1;
  for(int i=0;i<n;i++){
    if(a.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
    if(a.at(i)<=(1000000000000000000/ans)){
      ans*=a.at(i);
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4040
h, w = map(int, input().split())

ans_list = list()
# S_list = list()
# h1
for h1 in {h // 3, h // 3 + 1}:
    h_rest = h - h1
    if h1 <= 0 or h_rest <= 0:
        continue
    # h2
    h2 = h_rest >> 1
    if h2 != 0:
        S = [h1 * w, h2 * w, (h_rest - h2) * w]
        ans_list.append(max(S) - min(S))
        # S_list.append(S)

    # w2
    w2 = w >> 1
    if w2 != 0:
        S = [h1 * w, h_rest * w2, h_rest * (w - w2)]
        # S_list.append(S)
        ans_list.append(max(S) - min(S))


for w1 in {w // 3, w // 3 + 1}:
    w_rest = w - w1
    if w1 <= 0 or w_rest <= 0:
        continue
    # w2
    w2 = w_rest >> 1
    if w2 != 0:
        S = [h * w1, h * w2, h * (w_rest - w2)]
        ans_list.append(max(S) - min(S))
        # S_list.append(S)
    # h2
    h2 = h >> 1
    if h2 != 0:
        S = [h * w1, h2 * w_rest, (h - h2) * w_rest]
        ans_list.append(max(S) - min(S))
        # S_list.append(S)

# print(ans_list)
# print(S_list)
print(min(ans_list))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

ll power(ll x,ll n){
  if(n==0) return 1;
  ll res=power(x*x%mod,n/2);
  if(n&1) res=res*x%mod;
  return res;
}

int main(){
  int n;
  cin>>n;
  ll a=power(10,n);
  ll b=power(9,n);
  ll c=power(8,n);
  ll d=a-b-b+c;
  while(d<0) d+=mod;
  cout<<d<<endl;
}


Measured memory_bytes: 3620
def bubble_sort(item_list):
    length = len(item_list)
    count = 0

    for lp in range(length):
        for lp2 in range(length - lp - 1):
            if item_list[lp2] > item_list[lp2 + 1]:
                tmp = item_list[lp2]
                item_list[lp2] = item_list[lp2 + 1]
                item_list[lp2 + 1] = tmp
                count += 1

    return count


while True:

    input_count = int(input())

    if input_count == 0:
        break

    data = [int(input()) for _ in range(input_count)]

    result = bubble_sort(data)
    print(result)



Measured memory_bytes: 5600
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint A,B,C;
  cin>>A>>B>>C;
  cout<<B+min(C,A+B+1)<<endl;
  return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N; cin >> N;
    set<int> ans;
    if(N == 3) ans = set<int>{2,5,63};
    else if(N == 4) ans = set<int>{2,5,20,63};
    else if(N == 5) ans = set<int>{2,5,20,30,63};
    else{
        int sum = 0;
        FOR(i,1,30001){
            if(i%6==0||i%6==2||i%6==3||i%6==4){
                ans.insert(i);
                sum += i;
            }
            if(ans.size() == N) break;
        }
        int last = *ans.rbegin()+1;
        if(sum%6 == 2){
            ans.erase(8);
            while(last%6 != 0) last++;
            ans.insert(last);
        }
        else if(sum%6 == 3){
            ans.erase(9);
            while(last%6 != 0) last++;
            ans.insert(last);
        }
        else if(sum%6 == 5){
            ans.erase(9);
            while(last%6 != 4) last++;
            ans.insert(last);
        }
    }

    for(int n : ans){
        cout << n << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
//q087.cpp
//Sun Sep  6 17:01:43 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

//Union-Find木
int par[1000000]; //親。1個上の親でしか無いことに注意。グループの根はfindで呼び出す。
int treesize[1000000]; //木のサイズ

//n要素で初期化
void init(int n){
	for (int i=0;i<n;i++){
		par[i] = i;
		treesize[i] = 1;
	}
}

//木の根（親）を見つける。再帰することで、グループの根まで辿る。
int find (int x){
	if (par[x] == x){
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合の併合
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	} 
	if (treesize[x]>treesize[y]){
		par[y] = x;
		treesize[x] += treesize[y];
	}else{
		par[x] = y;
		treesize[y] += treesize[x];
	}
}

//xとyが同じグループに属するか判定
bool same(int x, int y){
	return find(x) == find(y);
}


int main(){
	ll n,m;
	cin >> n >> m;

	vector<ll> a(m,0);
	vector<ll> b(m,0);
	rep(i,m) cin >> a[i] >> b[i];

	init(n);

	vector<ll> ans(m,0);
	ll cur = n*(n-1)/2;
	for(ll i=m-1;i>=0;i--){
		ans[i]=cur;
		if (!same(a[i],b[i])){
			cur -= treesize[find(a[i])]*treesize[find(b[i])];
		}
		unite(a[i],b[i]);
	}

	rep(i,m){
		cout << ans[i] << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 6420
n = int(input())
s = [i for i in input()]
count = 0
total = 0
for p in s:
  if p == "A":
    count = 1
  elif count == 1 and p == "B":
    count = 2
  elif count == 2 and p == "C":
    count = 0
    total += 1
  else:
    count = 0
print(total)
    

Measured memory_bytes: 3060
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
trait AtCoder {
    fn repeat_(&self, n:usize) -> String;
}
impl AtCoder for str {
    fn repeat_(&self, n:usize) -> String {
        (0..n).map(|_| self.to_string()).collect::<String>()
    }
}
fn main() {
    input!{
        sx: i32,
        sy: i32,
        tx: i32,
        ty: i32
    }
    let difx = (tx - sx) as usize;
    let dify = (ty - sy) as usize;
    let ans = "U".repeat_(dify) + &"R".repeat_(difx + 1) + &"D".repeat_(dify + 1) + &"L".repeat_(difx + 1) + &"U".to_string() + &"L".to_string() + &"U".repeat_(dify + 1) + &"R".repeat_(difx + 1) + &"D".repeat_(dify + 1) + &"L".repeat_(difx);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n;
vector<vector<ll>> ans;
vector<ll> tmp;

void dfs(ll cur, ll maxi) {
  if (cur == n) {
    ans.push_back(tmp);
    return;
  }

  REP(i, maxi + 1) {
    tmp.push_back(i);
    if (i < maxi) {
      dfs(cur + 1, maxi);
    } else {
      dfs(cur + 1, maxi + 1);
    }
    tmp.pop_back();
  }
}

int main() {
  cin >> n;
  dfs(0LL, 0LL);
  sort(ALL(ans));
  REP(i, SZ(ans)) {
    REP(j, SZ(ans[i])) { cout << (char)(ans[i][j] + 'a'); }
    cout << endl;
  }
}

Measured memory_bytes: 15024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    char s;
    rep(i,3){
        cin >> s;
        if(s == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;

    ll res = 0;
    REP(i, 1, n + 1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        res += i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+13;
int n,q;
struct segment_tree
{
	int val[maxn<<3];
	int tip[maxn<<3];
	void up(int rt)
	{
		val[rt]=min(val[rt<<1],val[rt<<1|1]);
	}
    void build(int rt,int l,int r)
    {
    	tip[rt]=n+1;
    	if(l==r)
    	{
    		val[rt]=n;
    		return;
		}
		int mid=l+r>>1;
		build(rt<<1,l,mid);
		build(rt<<1|1,mid+1,r);
		up(rt);
	}
	void spread(int rt)
	{
		if(tip[rt]!=n+1)
		{
			val[rt<<1]=min(val[rt<<1],tip[rt]);
			tip[rt<<1]=min(tip[rt<<1],tip[rt]);
			val[rt<<1|1]=min(val[rt<<1|1],tip[rt]);
			tip[rt<<1|1]=min(tip[rt<<1|1],tip[rt]);
			tip[rt]=n+1;
		}
	}
	void modify(int rt,int l,int r,int now,int ll,int rr)
	{
		if(ll<=l&&r<=rr)
		{
			val[rt]=min(val[rt],now);
			tip[rt]=min(tip[rt],now);
			return;
		}
		spread(rt);
		int mid=l+r>>1;
		if(ll<=mid) modify(rt<<1,l,mid,now,ll,rr);
		if(rr>mid) modify(rt<<1|1,mid+1,r,now,ll,rr);
		up(rt);
	}
	int query(int rt,int l,int r,int x)
	{
		if(l==r)
		{
			return val[rt];
		}
		spread(rt);
		int mid=l+r>>1;
		int ans=0x3f3f3f3f;
		if(x<=mid) return query(rt<<1,l,mid,x);
		else return query(rt<<1|1,mid+1,r,x);
	}
}row,col;

int main()
{
	scanf("%d%d",&n,&q);
	int mr,mc;//列和行的最靠前 
	mr=mc=n;
	if(!q)
	{
		printf("%lld",1ll*(n-2)*(n-2));
		return 0;
	}
	row.build(1,1,n);
	col.build(1,1,n);
	ll ans=1ll*(n-2)*(n-2);
	while(q--)
	{
		int op,x;
		scanf("%d%d",&op,&x);
		if(op==1)
		{
			mc=min(mc,x);
			ans-=col.query(1,1,n,x)-2;
			row.modify(1,1,n,x,1,mr);
		}
		else
		{
			mr=min(mr,x);
			ans-=row.query(1,1,n,x)-2;
			col.modify(1,1,n,x,1,mc);
		}
	}
	printf("%lld",ans);
 } 

Measured memory_bytes: 11944
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>

const long long MAXN=1e5+10;
using namespace std;
typedef long long ll;

 int main() {
 	char s[30];
 	bool a[30]={0};
 	cin>>s;
 	for(int i=0;s[i]!='\0';i++){
 		if(a[s[i]-'a']){
 			printf("no");
 			return 0;
		 }
		 else {
		 	a[s[i]-'a']=1;
		 }
	}
	printf("yes");
 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll res = 0;
  vector<int> v;
  int n = int(s.size());

  rep(i, int(s.size())){
    if(s[i] == 'A') v.push_back(0);
    else if(i <= n-2 && s.substr(i, 2) == "BC") v.push_back(1), i++;
    else v.push_back(-1);
  }
  int index = 0;
  // rep(i, int(v.size())) if(v[i] == 0){
  //   index = i; break;
  // }

  for(int i = 0; i < int(v.size()); i++){
    if(v[i] == 1){
      res += index;
    }
    else if(v[i] == -1) index = 0;
    else if(v[i] == 0) index++;
    // cout << res <<endl;
  }
  cout << res << endl;
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    }
    else {
        cout << 10 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<ll> x(n), l(n);
	rep(i,n) cin >> x[i] >> l[i];
	vector<pair<ll, ll>> v(n);
	rep(i,n) {
		v[i].first = x[i] + l[i];
		v[i].second = x[i] - l[i];
	}
	sort(ALL(v));
	ll cur = -LINF;
	int ans = 0;
	rep(i,n) {
		if (cur <= v[i].second) {
			ans++;
			cur = v[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6424
N = int(input())
A = list(map(int, input().split()))
dp = [[-10**20 for i in range(3)] for j in range(N+1)]
dp[0][1] = 0
dp[1][1] = 0
dp[1][2] = A[0]

for i in range(1, N):
    if i % 2 == 0:
        dp[i+1][0] = max(dp[i-1][0]+A[i], dp[i][0])
        dp[i+1][1] = max(dp[i-1][1]+A[i], dp[i][1])
        dp[i+1][2] = dp[i-1][2]+A[i]
    else:
        dp[i+1][0] = max(dp[i-1][0]+A[i], dp[i][1])
        dp[i+1][1] = max(dp[i-1][1]+A[i], dp[i][2])
        dp[i+1][2] = dp[i-1][2]+A[i]
ans = dp[N][1]
print(ans)

Measured memory_bytes: 66360
w, a, b = map(int, input().split())
if a <= b <= a+w or a <= b+w <= a+w or b <= a <= b+w or b <= a+w <= b+w:
    print(0)
else:
    if a < b:
        print(b-a-w)
    else:
        print(a-b-w)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0;
  if(N<10)ans=N;
  else if(N<100)ans=9;
  else if(N<1000)ans=N-90;
  else if(N<10000)ans=909;
  else if(N<100000)ans=N-9090;
  else ans=90909;//N=100000
  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	a := io.NextInts(n)
	max := 0
	sum := 0
	for i := range a {
		if a[i] < max {
			sum += max - a[i]
		}
		if a[i] > max {
			max = a[i]
		}
	}
	io.Println(sum)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 14932
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		ArrayList<Integer> b = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			b.add(a[n - i - 1]);
		}
		int[] ans = new int[n];
		boolean canans = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < b.size(); j++) {
				if (b.get(j) == b.size() - j) {
					ans[i] = b.get(j);
					b.remove(j);
					break;
				} else if (j == b.size() - 1) {
					i = n;
					System.out.println("-1");
					canans = false;
				}
			}
		}
		if (canans) {
			for (int i = 0; i < n; i++) {
				System.out.println(ans[n - i - 1]);
			}
		}
	}
}

Measured memory_bytes: 23252
a,b=gets.split.map &:to_i
n,m=[],[]
a.times{x=gets.chomp;n<< x unless x.count("#")==0}
n=n.map{|r|r.split("")}.transpose
b.times{|i|m<< n[i]unless n[i].count("#")==0}
m.transpose.map{|z|puts z.join}

Measured memory_bytes: 2428
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::prelude::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

const MOD: isize = 1_000_000_007;

fn main() {
    let (N, X, Y): (usize, usize, usize) = (read(), read::<usize>() - 1, read::<usize>() - 1);
    // g[k] : 最短距離がkの(i,j)の個数
    let mut g: Vec<usize> = vec![0usize; N + 1];
    // // X < Y である

    // let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    // for i in 0..N - 1 {
    //     q.push_back((i + 1, 1));
    //     if (i == X) {
    //         q.push_back((Y, 1));
    //     }
    //     while let Some(x) = q.pop_front() {
    //         g[x.1] += 1;
    //         if x.0 < N - 1 {
    //             q.push_back((x.0 + 1, x.1 + 1));
    //         }
    //         if x.0 == X {
    //             q.push_back((Y, x.1 + 1));
    //         }
    //     }
    // }
    // for i in 1..N {
    //     println!("{}", g[i]);
    // }
    // ぜんてんもとめる
    let mut d = vec![vec![std::isize::MAX >> 2; N]; N];
    d[X][Y] = 1;
    let X = X as isize;
    let Y = Y as isize;
    for i in 0..N {
        for j in 0..N {
            d[i][j] = {
                let i = i as isize;
                let j = j as isize;
                min((j - i).abs(), (X - i).abs() + 1 + (Y - j).abs())
            }
        }
    }
    for i in 0..N {
        for j in i..N {
            g[d[i][j] as usize] += 1;
        }
    }
    for i in 1..N {
        println!("{}", g[i]);
    }
}
fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let next: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    next.parse().ok().unwrap()
}


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

int main() {
    int n;
    cin >> n;
    int N = n % 10;
    if (N == 3) cout << "bon" << endl;
    else if (N == 0 or N == 1 or N == 6 or N == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		sc.close();

		for(int i = 1; i <= 10; i++) {
			int answer = 0;

			answer = i*1000 - N;
			if(answer >= 0) {
				System.out.println(answer);
				break;
			}
		}
	}
}


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

int main() {
	int k = 0, n, a[4] = { 0 }, ans = 0;
	char s[3], cas[4][4] = {"AC","WA","TLE","RE"};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &s);
		for (int i = 0; i < 4; i++) {
			if (strcmp(cas[i], s) == 0)a[i]++;
		}
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",a[0],a[1],a[2],a[3]);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define ld double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define DOW(i, n) for(int i = n - 1; 0 <= i; --i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;

const int nax = 18;
const int inf = 111111111;

int n;
int a[nax];
int b[nax];
int dp[1 << nax][51];

int main() {
	scanf ("%d", &n);
	for (int i = 0; i < n; ++i) scanf ("%d", a + i);
	for (int i = 0; i < n; ++i) scanf ("%d", b + i);
	
	for (int mask = 0; mask < (1 << n); ++mask)
		for (int j = 0; j <= 50; ++j)
			dp[mask][j] = inf;
	
	dp[0][0] = 0;
	for (int mask = 1; mask < (1 << n); ++mask) {
		vector <int> all;
		for (int j = 0; j < n; ++j)	
			if ((mask >> j) & 1) all.pb(j);
		
		for (int j = 0; j < ss(all); ++j) {
			int B = all[j];
			int flip = (ss(all) - j - 1);
			int step = 0;
			step = all[j] - j;
			flip += step;
			flip %= 2;
			int ja = (flip == 0 ? a[all[j]] : b[all[j]]);
			
			for (int last = 0; last <= 50; ++last) 
				if(last <= ja)
					dp[mask][ja] = min(dp[mask][ja], dp[mask ^ (1 << B)][last] + step);
			//cout << mask << " " << ja << " " << dp[mask][ja] << " " << (mask ^ (1 << B)) <<  " " << step << endl;
		}
	}
	
	int ans = inf;
	int mask = (1 << n) - 1;
	for (int i = 0; i <= 50; ++i)
		ans = min(ans, dp[mask][i]);
	if (ans == inf) printf("-1");
	else printf("%d", ans);
			
	
	
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n],ans=0;
  for(int i=0; i<n; i++) cin >> a[i];
  int u[n];
  memset(u,0,sizeof(u));
  for(int i=0; i<n; i++) {
    if(u[i]) continue;
    int x=i;
    while(!u[x]) {
      u[x]=i+1;
      x=(a[x]+x)%n;
    }
    if(u[x]!=i+1) continue;
    int y=x;
    do {
      x=(a[x]+x)%n;
      ans++;
    } while(x!=y);
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
    int N, M; cin >> N >> M;
    vector<long long int> a(N, 0);
    vector<long long int> b(N, 0); 
    rep(i, N) cin >> a[i] >> b[i];
    vector<long long int> c(M, 0);
    vector<long long int> d(M, 0);
    rep(i, M) cin >> c[i] >> d[i];

    rep (i, M) cerr << d[i] << endl;
    rep(i, N) {
        int check = 1;
        long long int max = INT_MAX;
        rep(j, M) {
            long long int e = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if (max > e) {
                max = e;
                check = j+1;
            }
        }
        cout << check << endl;
    }
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
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)*} }; }
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: usize,
        B: usize,
        V: [u64; N],
    }
    let mut V = V;
    V.sort();
    V.reverse();

    let mut total = 0;
    for i in 0..A{
        total += V[i];
    }
    let ans1 = (total as f64)/(A as f64);

    let mut cnt0 = 0; // ==V[0]
    let mut cnt1 = 0; // ==V[A-1]
    let mut cnt2 = 0; // > V[A-1]
    for i in 0..N{
        if V[i]==V[0]{
            cnt0 += 1;
        }
        if V[i]==V[A-1]{
            cnt1 += 1;
        }
        if V[i] > V[A-1]{
            cnt2 += 1;
        }
    }

    let mut ans2 = 1;
    // V[0]==V[A]なら、V[0]と等しい要素を選ぶ方法を全探索
    if cnt0 > A{
        ans2 = 0;
        for i in A..(min(cnt0,B)+1){
            let mut tmp = 1;
            let c = cnt0;
            let r = i;
            for j in 0..r{
                tmp *= c-j;
                tmp /= j+1;
            }
            ans2 += tmp;
        }
    // そうでなければV[A-1]の要素を選ぶ方法を考慮
    }else{
        if cnt1+cnt2>A{
            let c = cnt1;
            let r = A-cnt2;
            for i in 0..r{
                ans2 *= c-i;
                ans2 /= i+1;
            }
        }
    }
    // print
    println!("{}", ans1);
    println!("{}", ans2);
}

Measured memory_bytes: 4352
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
from pprint import pprint
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def matpow(A, n):  # 2分累乗
	B = np.identity(len(A), dtype=object)
	while n > 0:
		if n & 1:
			B = B.dot(A)
			B %= mod
		A = A.dot(A)
		A %= mod
		n >>= 1
	return B

N, K = MAP()
a = np.array([LIST() for _ in range(N)], dtype=object)

print(matpow(a, K).sum()%mod)


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll n;
  cin>>n;
  vector<ll> a;
  rep(i, n){
    ll t;
    cin>>t;
    a.push_back(t);
  }
  ll l=0,r=0,lcount=0,rcount=0;
  rep(i, n){
    if(l>r){
      r+=a[n-1-rcount];
      rcount++;
    }else{
      l+=a[lcount];
      lcount++;
    }
  }
  cout<<abs(r-l);

  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL n,x,t;
    cin>>n>>x>>t;
    LL ans = ((n + x - 1) / x) * t;
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORN(i, n, s) for (int i = s; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACKN(a, n, s) \
  for (int i = s; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

int main() {
  int N;
  IN(N);
  int L[N];
  FOR(i, N) { IN(L[i]); }
  int longest = L[0];
  int sum = 0;
  FOR(i, N) {
    longest = max(L[i], longest);
    sum += L[i];
  }
  sum -= longest;
  if (longest < sum) {
    OUT("Yes");
  } else {
    OUT("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,i=0,j,c=0,k,a,b;
    cin >> k >> a >> b;
    while(1)
    {
        i++;
        if(a<=k*i && b>=k*i)
        {
            cout << "OK" << endl;
            return 0;
        }
       if(k*i>1000)
       {
           break;
       }
    }
    cout << "NG" << endl;

    return 0;

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



int main(){
  int n;
  cin>>n;
  vector<int> b(n),ans;
  rep(i,n){
    int k; cin >> k;
    k--;
    b[i] = k;
  } //0-index
  rep(i,n){
    if(b[i]>i){
      cout << -1 << endl;
      return 0;
    }
  }
  while(!b.empty()){
    int tmp;
    rep(i,b.size()){
      if(b[i]==i) tmp = i;
    }
    ans.push_back(tmp);
    b.erase(b.begin()+tmp);
  }
  rep(i,n){
    cout << ans[n-1-i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

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

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll n, m;
ll root[500000];
ll sz[500000];
vector<ll> ans;
vector<pii> v;
ll res = 0;

int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

void Merge(int a, int b)
{
    a = Root(a);
    b = Root(b);
    if (a == b) return;
    if (sz[a] <= sz[b])
    {
        res += sz[a] * sz[b];
        sz[b] += sz[a];
        root[a] = b;
    }
    else
    {
        res += sz[a] * sz[b];
        sz[a] += sz[b];
        root[b] = a;
    }
}

signed main()
{
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    S s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < s.size(); i++) 
    {
        if (s[i] == '0') cnt0++;
        else cnt1++;
    }
    cout << min(cnt0, cnt1) * 2;
}


Measured memory_bytes: 512