akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int cnt[100010];

struct city{
  int city_no;
  int pref_no;
  int year;
  int id;
};

bool comp_year(city left, city right) {
  return left.year < right.year;
}

bool comp_city_no(city left, city right) {
  return left.city_no < right.city_no;
}

string zero_pad(int num) {
  string str = to_string(num);
  while(str.size() < 6) {
    str = "0" + str;
  }
  return str;
}

int main() {
  int N, M;
  cin >> N >> M;
  city ary[M];
  for (int i=0 ; i<M ; i++) {
    ary[i].city_no = i;
    cin >> ary[i].pref_no >> ary[i].year;
    ary[i].id = 0;
  }

  sort(ary, ary+M, comp_year);

  for (int i=0 ; i<M ; i++) {
    int pref_no = ary[i].pref_no;
    ary[i].id = ++cnt[pref_no];
  }

  sort(ary, ary+M, comp_city_no);

  for (int i=0 ; i<M ; i++) {
    cout << zero_pad(ary[i].pref_no) << zero_pad(ary[i].id) << endl;
  }
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
 
using namespace std;

using ll = long long;

vector<int> v, v1;

int main(){
	int n, m;
	while(cin >> n >> m){
		if(n == 0)return 0;
		vector<int> h, w;
		map<int, ll> mp1, mp2;
		for(int i = 0;i < n;i++){
			int a;cin >> a;
			h.push_back(a);
			//mp1[a]++;
		}
		for(int i = 0;i < m;i++){
			int a;cin >> a;
			w.push_back(a);
			//mp2[a]++;
		}
		vector<ll> ruiseki1, ruiseki2;
		ruiseki1.push_back(0);
		ruiseki2.push_back(0);
		for(int i = 0;i < n;i++)ruiseki1.push_back(ruiseki1.back() + h[i]);
		for(int i = 0;i < m;i++)ruiseki2.push_back(ruiseki2.back() + w[i]);
		for(int i = 0;i < n;i++){
			for(int j = i+1;j < n+1;j++){
				mp1[ruiseki1[j] - ruiseki1[i]]++;
			}
		}
		for(int i = 0;i < m;i++){
			for(int j = i+1;j < m+1;j++){
				mp2[ruiseki2[j] - ruiseki2[i]]++;
			}
		}
		ll ans = 0;
		for(auto a : mp1){
			if(a.first == 0)continue;
			ans += mp2[a.first] * a.second;
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 44564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
  int N, L;
  std::cin >> N >> L;
  
  std::vector<std::string> strs;
  for(int i=0; i<N; i++)
  {
    std::string str;
    std::cin >> str;
    strs.push_back(str);
  }

  std::sort(strs.begin(), strs.end());
  for(const auto& s: strs) { std::cout << s; }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<long long int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    while(v.size() > 1)
    {
        sort(v.begin(),v.end());
        for(int i = 1;i < v.size();i++)
        {
            v.at(i) %= v.at(0);
            if(v.at(i) == 0)
            {
                swap(v.at(i),v.at(v.size() - 1));
                v.pop_back();
                i -= 1;
            }
        }
    }
    cout << v.at(0);

    return 0;
}

Measured memory_bytes: 1400
import sys
import bisect
input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        check = bisect.bisect_left(l, l[i] + l[j])
        ans += max(0, check - j - 1)
print(ans)


Measured memory_bytes: 3188
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> S(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S[i+1] = S[i] + A[i];
    }

    int ret = INF;

    for (int i = 0; i < N-1; i++) {
        int left = S[i+1];
        int right = S[N] - left;
        ret = min(ret, abs(left - right));
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3328
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    n,k = na()
    ans = [i for i in range(n)]
    for _ in range(k):
        d = ni()
        As = na()
        for a in As:
            if a-1 in ans:
                ans.remove(a-1)
    print(len(ans))
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 67648
#include<bits/stdc++.h>
		#include<ext/pb_ds/assoc_container.hpp>
		#include<ext/pb_ds/tree_policy.hpp>
		#define int long long
		#define w(t) int t;cin>>t;while(t--)
		#define pb push_back
		#define mk make_pair
		#define ascSort(v) sort(v.begin(), v.end())
		#define descSort(v) sort(v.begin(), v.end(), greater<int>())
		#define ff first
		#define ss second
		#define pi pair<int,int>
		#define vi vector<int>
		#define umapi unordered_map<int,int>
		#define INF 1000000007
		const int m=998244353;
		using namespace std;
		using namespace __gnu_pbds;

		typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

		void FIO(){
			#ifndef ONLINE_JUDGE
				freopen("input.txt", "r", stdin);
				freopen("output.txt", "w", stdout);
			#endif
			ios_base::sync_with_stdio(false);
		    cin.tie(NULL);	
		}
		
		int32_t main(){
			
			//FIO();
			
				int x;cin>>x;
				cout<<(int)1-x<<"\n";
			
			

			

			return 0;
			
				
		}


					

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    char c; cin >> c;
    char v[5] = {'a', 'e', 'i', 'o', 'u'};
    bool vowel = false;
    rep(i,5) if(v[i]==c) vowel = true;
    if(vowel) cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

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

int n;
vector<ll> a;

ll solve(vector<ll> a,int sign){
    vector<ll> sum(a.size()+1);
	ll cnt=0;
	for (int i = 0; i < a.size(); i++) {
		if(sign==-1){
			if(sum[i]+a[i]<0)sum[i+1]=sum[i]+a[i];
			else {
				cnt+=abs(-1-sum[i]-a[i]);
				sum[i+1]=-1;
			}
			sign=1;
		}
		else {
			if(sum[i]+a[i]>0)sum[i+1]=sum[i]+a[i];
			else {
				cnt+=abs(1-sum[i]-a[i]);
				sum[i+1]=1;
			}
			sign=-1;
		}
	}
	return cnt;
}

int main(void)
{
	cin>>n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	ll ret=min(solve(a,1),solve(a,-1));
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3336
#include<stdio.h>

int main(){
int x,y;
scanf("%d%d",&x,&y);
if(((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)))puts("Yes");
else puts("No");
return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(3 * n);
    copy_n(istream_iterator<int64_t>(cin), 3 * n, A.begin());

    priority_queue<int64_t> mi;
    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> ma;
    int64_t s_ma = 0, s_mi = 0;
    for (int i = 0; i < n; i++){
        ma.push(A[i]);
        mi.push(A[3 * n - i - 1]);
        s_ma += A[i];
        s_mi += A[3 * n - i - 1];
    }

    vector<int64_t> ans(n + 1);
    ans[0] += s_ma;
    ans[n] -= s_mi;
    for (int i = 0; i < n; i++){
        s_ma += A[n + i];
        ma.push(A[n + i]);
        s_ma -= ma.top();
        ma.pop();
        ans[i + 1] += s_ma;

        s_mi += A[2 * n - i - 1];
        mi.push(A[2 * n - i - 1]);
        s_mi -= mi.top();
        mi.pop();
        ans[n - i - 1] -= s_mi;
    }

    cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 5100
<?php
  fscanf(STDIN, "%d%d", $n,$k);
  $h = explode(" ", trim(fgets(STDIN)));
  for ($i=0; $i<$n; $i++) $h[$i] = intval($h[$i]);
  $dp = array_fill(0,$n,10**9);
  $dp[0] = 0;
  for($i=0; $i<=$n; $i++){
      $k = min($k, $n-$i);
      for($j=1; $j<=$k; $j++){
          $dp[$i+$j] = min(abs($h[$i]-$h[$i+$j])+$dp[$i], $dp[$i+$j]);
      }
  }
//   print_r($dp);
  echo $dp[$n-1];


Measured memory_bytes: 16884
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = (1LL<<31)-1;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,ll)> P;
  ll n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(ll n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,ll b){return a;}):
    f(f),g(g),h(h),d1(d1),d0(d0),p(p){
    init(n_);
    if(n_==(ll)v.size()) build(n_,v);
  }
  void init(ll n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(ll n_, vector<T> v){
    for(ll i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(ll len,ll k){
    if(laz[k]==d0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=d0;
  }
  T update(ll a,ll b,E x,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(ll a,ll b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(ll a,ll b,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(ll a,ll b){
    return query(a,b,0,0,n);
  }
};
    auto F = [](ll a, ll b){return min(a,b);};
    auto G = [](ll a, ll b){return a+b;};
    auto H = G;
    SegmentTree<ll,ll> seg(MAX_N, F, G, H, INF, 0,vl(MAX_N,0));
int main() { cin >> n >> q; 
while(q--){
    cin >> x;
    if(x==0){
        cin >> a >> b >> c;
        seg.update(a, b + 1, c);
    }
    else{
        cin >> a >> b;
        cout << seg.query(a, b + 1)<<endl;
    }
}}




Measured memory_bytes: 27024
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n;
int x, ans;

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		ans += (x & 1) && (i & 1); 
	}
	printf("%d", ans);
}

Measured memory_bytes: 3752
s = input()
t = input()
ans = ""
for i in range(len(s)-len(t)+1):
    flag = 0
    for j in range(len(t)):
        if s[i+j]==t[j] or s[i+j]=="?":
            flag += 1
    if flag==len(t):
        tnp = ""
        for j in range(len(s)):
            if (s[j]!="?"):
                tnp += s[j]
            else:
                if (i<=j and j<i+len(t)):
                    tnp += t[j-i]
                else:
                    tnp += "a"
        ans = tnp
if (len(ans)>0):
    print(ans)
else:
    print("UNRESTORABLE")
        

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int d,t,s;
  cin>>d>>t>>s;
  if(t*s>=d)
    Yes;
  else
    No;
}

Measured memory_bytes: 3628
n = int(input())
s = [input() for i in range(n)]
ans = 0
for i in range(n):
    flag = True
    for x in range(n):
        for y in range(n):
            if s[(x-i)%n][y] != s[(y-i)%n][x]:
                flag = False
    if flag:
        ans += 1
print(ans*n)
                
                

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back

void solve();

int main() {
    // freopen("schools.in", "r", stdin);
    // freopen("schools.out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);
	int t;
	// cin >> t;
	t = 1;	
	while(t--) solve();
	return 0;
}

int n, m, dp[100005], ans;
vector<int> g[100005];

int dfs(int s) {
	if (dp[s] != -1) return dp[s];
	int res = 0;
	for (auto d : g[s]) {
		res = max(res, dfs(d) + 1);
	}
	return dp[s] = res;
}

void solve() {
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= m; ++i) {
		int t1, t2;
		cin >> t1 >> t2;
		g[t1].pb(t2);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) ans = max(ans, dfs(i));
	cout << ans << '\n';
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N - 1);
	for(int i = 0;i < N;i++) {
		cin >> A.at(i);
	}
	for(int i = 0;i < N;i++) {
		cin >> B.at(i);
	}
	for(int i = 0;i < N - 1;i++) {
		cin >> C.at(i);
	}
	int ret = 0;
	for(int i = 0;i < N - 1;i++) {
		ret += B.at(A.at(i) - 1);
		if(A.at(i) + 1 == A.at(i + 1)) {
			ret += C.at(A.at(i) - 1);
		}
	}
  	ret += B.at(A.at(N - 1) - 1);
	cout << ret << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 h,n;
    cin >> h >> n;
    REP(i,n){
        int32 a;
        cin >> a;
        h -= a;
        if(h <= 0){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == 5 && B == 5 && C == 7) cout << "YES" << endl;
  else if (A == 5 && B == 7 && C == 5) cout << "YES" << endl;
  else if (A == 7 && B == 5 && C == 5) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int n, k, h[100000], dp[100000];

int main(){
	scanf("%d %d", &n, &k);
	for (int i=0; i<n; i++) scanf("%d", &h[i]);
	dp[0]=0;
	for (int i=1; i<n; i++){
		dp[i]=INT_MAX;
		for (int j=1; j<=k; j++){
			if (i-j<0) break;
			dp[i]=min(dp[i], dp[i-j]+abs(h[i-j]-h[i]));
		}
	}
	printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

commands = [''] * N
ans = 0
for i, t in enumerate(T):
        if t == 'r':
                command = 'p'
                point = P
        elif t == 's':
                command = 'r'
                point = R
        elif t == 'p':
                command = 's'
                point = S
        if i-K >= 0 and commands[i-K] == command:
                command = ''
                point = 0
        ans += point
        commands[i] = command

print(ans)

Measured memory_bytes: 42992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    map<string,ll> mp;
    rep(i,N){
        cin >> S[i];
        mp[S[i]]++;
    }

    cout << mp.size() <<endl;
}

Measured memory_bytes: 25004
N, K = map(int, input().split())
cnt = 0
cnt2 = 0
for i in range(1,N+1):
    if i%K == 0:
        cnt += 1
if K%2 == 0:
    for i in range(1,N+1):
        if i%K == K/2:
            cnt2 += 1
ans = cnt**3 + cnt2**3
print(ans)


Measured memory_bytes: 3060
# coding: utf-8
# 54
m='abcdefghijklmnopqrstuvwxyz'
c=[]
A=[]
while True:
    try:
        a=input()
    except:
        break
    a = a.lower()
    for j in range(len(a)):
        K = ord(a[j])
        A.append(K)
    #print(A)
    #print(A.count(120))
for i in range(97,123):
        #print(i)
    k = A.count(i)
    c.append(k)
        #print(i,k)

for j in range(26):
    print(m[j],':',c[j])



Measured memory_bytes: 5580
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	LL ans = 0;
	rep(i, S.length())
	{
		for (int j = i; j < S.length(); ++j)
		{
			auto str = S.substr(i, j - i + 1);
			bool flag = true;
			for (char c : str)
			{
				if (c != 'A'&&c != 'T'&&c != 'G'&&c != 'C')
				{
					flag = false;
					break;
				}
			}
			if (flag) ans = std::max<LL>(ans, str.length());
		}
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int H[10000],W[10000],i,x,y;
   for(i=0;i<10000;i++)
   {
       scanf("%d %d",&H[i],&W[i]);
       if(H[i]==0&&W[i]==0)
        break;
   }
   for(i=0;i<10000;i++)
   {
       if(H[i]==0&&W[i]==0)
       {
           break;
       }

        for(x=0;x<H[i];x++)
        {
            for(y=0;y<W[i];y++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
   }
   return 0;
}



Measured memory_bytes: 2104
#include <map>
#include "iostream"
using namespace std;

int main(){
    long a;
    cin>>a;
    map<long , long> freq;
    int res=0;
    while(a--){
        int num;
        cin>>num;
        if(freq[num]==0){
            freq[num]=1;
            res++;
        }else{
            freq[num]=0;
            res--;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  string s;
  cin >> s;

  vector<int> t;
  if(s[0] != '1') t.push_back(0);
  int cnt = 1;
  for(int i=1;i<N;i++){
    if(s[i] == s[i-1]) cnt++;
    else {
      t.push_back(cnt);
      cnt = 1;
    }
  }
  t.push_back(cnt);
  if(s[N-1] != '1') t.push_back(0);

  /*for(int i=0;i<t.size();i++){
    cout << t[i] << endl;
  }*/

  int M = t.size();
  int sum[M+1];
  sum[0] = 0;
  for(int i=1;i<=M;i++) sum[i] = sum[i-1] + t[i-1];

  int ans = 0;
  for(int i=0;i<M;i+=2){
    int ind = i + 2 * K;
    if(ind >= M) ans = max(ans, sum[M] - sum[i]);
    else ans = max(ans, sum[ind+1] - sum[i]);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
//Postal Code

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int a,b;string s;cin>>a>>b>>s;
    map<int,bool> m{};
    rep(i,0,a){
        if('0'<=s[i]&&s[i]<='9')m[i]=true;
    }
    if(s[a]=='-')m[a]=true;
    rep(i,a+1,a+b+1){
        if('0'<=s[i]&&s[i]<='9')m[i]=true;
    }
    bool flag=true;
    rep(i,0,a+b+1){
        flag = flag&&m[i];
    }
    cout << (flag ? "Yes" : "No")<< endl;
    return 0;
}

Measured memory_bytes: 256
////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pii> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=3e5+5;
//vector<ll>Graph[maX],cost[maX];
map<ll,ll>check;
///check n=1;
///check corner case;
void solve()
{
    ll n,k,i,j,cc=0;
    cin>>n>>k;
    ll ara[n+1];
    for(i=1;i<=n;i++)cin>>ara[i];
    while(k--){
        vector<ll>sum(n+5);
        for(i=1;i<=n;i++){
            ll mn=max(1ll,i-ara[i]);
            ll mx=min(n+1,i+ara[i]+1);
            sum[mn]++;
            sum[mx]--;
        }
        cc=0;
        for(i=1;i<=n;i++){
            sum[i]+=sum[i-1];
        }

        for(i=1;i<=n;i++){
            if(sum[i]<n){
                cc=1;break;
            }
        }

        for(i=1;i<=n;i++)swap(ara[i],sum[i]);
        if(!cc)break;
    }
    for(i=1;i<=n;i++)cout<<ara[i]<<spc;
    cout<<edl;
}
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
int main()
{
    ll test;
   test=1;
    //scanf("%lld",&test);
    while(test--)solve();
return 0;
}
/*
6 8
1 2 3
1 3 7
2 4 7
3 4 2
3 5 3
5 4 5
5 6 11
4 6 3
*/


Measured memory_bytes: 6648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int a,b;
  while(1){
    cin>>a>>b;
    if(a==0&&b==0)break;
    int sum=a+b;
    char ans='A';
    rep(i,4){
      cin>>a>>b;
      if(sum<a+b){
        sum=a+b;
        ans='A'+i+1;
      }
    }
    cout<<ans<<" "<<sum<<endl;
  }
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;


int main()
{
	LL n;
	cin >> n;

	vector<LL> a(n);

	for (auto &e : a ) {
		cin >> e;
	}

	unordered_map<LL, LL> mp;

	LL cnt = 0;
	for (LL i = 0; i < n; ++i) {
		cnt += mp[i-a[i]];
		mp[i+a[i]]++;
	}
	cout << cnt << "\n";

}

Measured memory_bytes: 20056
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A,B,K;
    cin >> A >> B >> K;
    
    if (B-A+1 >= 2*K) {
        for (int i = A; i < A+K; i++) {
            cout << i << endl;
        }
        for (int i = K-1; i >= 0; i--) {
            cout << B - i << endl;
        }
    }else{
        for (int i = A; i <= B; i++) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		int count = 1;
		int[] land = new int[N+1];     
		for( int i=0; i<M; i++ ){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if( a[i]==1 ){
				land[count] = b[i];
				count++;
			}
			if( b[i]==N ){
				land[count] = a[i];
				count++;
			}           
		}       
		Arrays.sort(land);  
		for( int i=N-count+1; i<=N-1; i++ ){
			if( land[i]==land[i+1] ){
				System.out.println("POSSIBLE");
				break;
			}
			if( i==N-1 ){
				System.out.println("IMPOSSIBLE");
			}
		}
	}
}


Measured memory_bytes: 103636
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                 
                                        using namespace std;

int par[500100],ranks[500100],kosuu[500100];     

void shoki(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ranks[i]=0;
		kosuu[i]=1;
	}
}

int root(int x){
	return par[x]==x ? x : par[x]=root(par[x]);
}

bool same(int x,int y){
return root(x)==root(y);
}

void unite(int x,int y){
 x=root(x);
 y=root(y);
	int xx=kosuu[x],yy=kosuu[y];
 if(x==y) return;
	if(ranks[x]<ranks[y]){
		par[x]=y;
		kosuu[y]=yy+xx;
	}
 else {
	par[y]=x;
	if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
 	kosuu[x]=yy+xx;
 }
	return;
}

int gcd(int a1,int a2){
	if(a1<a2) return gcd(a2,a1);
	if(a2==1) return 1;
	if(a1%a2==0) return a2;
	return gcd(a2,a1%a2);
}


int rui2(int e,int r){
	if(r==0) return 1;
	if(r==1) return e%inf;
	if(r%2==1) return (e*rui2(e,r-1))%inf;
	int w=rui2(e,r/2)%inf;
	return (w*w)%inf;
}

int n;
int a[200030];
int b[200030];
int hajime[200030]={0},owari[200030]={0};
int imos[200030]={0};

int solve1(){
	for(int i=0;i<n;i++)hajime[a[i]]++,owari[b[i]]++;
	for(int i=1;i<=200000;i++)owari[i]+=owari[i-1];
	for(int i=200000;i>=0;i--)hajime[i]+=hajime[i+1];
	
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,n-owari[a[i]]-hajime[b[i]]);
	}
	return ans;
}
int solve2(){
	int ans=0;
	for(int i=0;i<n;i++)imos[a[i]]++,imos[b[i]]--;
	
	for(int i=1;i<=200000;i++){
		imos[i]+=imos[i-1];
		ans=max(imos[i],ans);
	}
	return ans;
//	cout<<ans<<endl;
}

            signed main(){
   cin>>n;
            	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
            	
            	cout<<solve1()<<" "<<solve2()<<endl;
            	return 0;
            }
             

Measured memory_bytes: 10908
def cin; gets.split.map(&:to_i) end

# exit if $0 != __FILE__

# n, *x = cin
# s = gets.chomp

# puts n

n, k = cin
vs = cin

max = -10**18
([n, k].min + 1).times do |deq|
  enq = k - deq
  (deq + 1).times do |ld|
    rd = deq - ld
    # p "#{ld}-#{rd} #{enq}"
    ar = ld == 0 ? [] : vs[0..(ld-1)]
    ar += rd == 0 ? [] : vs[(n-rd)..(n-1)]

    ar.sort!
    # p ar
    enq.times do
      break if ar.length == 0
      break if ar.first >= 0
      ar.shift
    end

    sc = ar.inject(:+) || 0
    max = sc if sc > max
  end
end

p max


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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; ++i) {
    cin >> b[i];
    b[i]--;
  }

  vector<int> ans;

  while (b.size() > 0) {
    int z = -1;
    for (int i = 0; i < b.size(); ++i) {
      if (b[i] == i) z = b[i];
    }

    if (z == -1) {
      cout << -1;
      return 0;
    }

    ans.insert(ans.begin(), z);
    b.erase(b.begin()+z);
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i]+1 << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <stdlib.h>

using namespace std;

int count_inversions(int n, vector<pair<double, int > > p) {

    int res = 0;
    vector<int> s(n+1, 0);
    for(int k=0; k < n; k++) {
        int c = 0;
        int u = p[k].second;
        while(u > 0) {
            c += s[u];
            u -= u & (-u);
        }
        u = p[k].second;
        while(u <= n) {
            s[u]++;
            u += u & (-u);
        }
        res += k - c;
    }

    return res;
}

double find_median(int n, vector<int> a, vector<int> b, vector<int> c) {
    int m = n * (n - 1) / 2, target_inversions;

    if (m % 2 == 1)
        target_inversions = (m - 1) / 2;
    else
        target_inversions = m / 2 - 1;

    vector<pair<double, int> > slope(n);
    for(int i=0; i < n; i++) {
        slope[i] = {-a[i] * 1.0 / b[i], i};
    }
    sort(slope.begin(), slope.end());

    vector<pair<double, int> > p(n);

    double inf = 1e9;
    double sa = -inf, sb = inf, s;
    int n_steps = 300;

    for(int step=0; step < n_steps; step++) {
        s = (sa+sb) / 2;
        for(int i=0; i < n; i++) {
            int j = slope[i].second;
            p[i] = {(-a[j] * s + c[j]) / b[j], i + 1};
        }
        sort(p.rbegin(), p.rend());

        int c = count_inversions(n, p);

        if (c > target_inversions) {
            sb = s;
        }
        else {
            sa = s;
        }
    }
    return sa;
}

double find_median_exhaustive(int n, vector<int> a, vector<int> b, vector<int> c) {
    int m = n * (n - 1) / 2, p;

    if (m % 2 == 1)
        p = (m - 1) / 2;
    else
        p = m / 2 - 1;
    vector<double> t(m);

    int k=0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            double d, dx, dy;
            d  = a[i] * b[j] - a[j] * b[i];
            dx = c[i] * b[j] - c[j] * b[i];
            dy = a[i] * c[j] - a[j] * c[i];
            t[k] = dx / d;

            // cout << "\t" << k << "\t" << t[k] << endl;

            k += 1;

        }
    }

    // for(int k=0; k<m; k++) {
    //     cout << "\t" << k << "\t" << t[k] << endl;
    // }
    // cout << endl;

    sort(t.begin(), t.end());
    return t[p];
}



int solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i] >> c[i];

    double x, y;
    x = find_median(n, a, b, c);

    y = find_median(n, b, a, c);
    // y = find_median_exhaustive(n, b, a, c);

    cout.precision(12);
    cout << x << " " << y << endl;
    return 0;
}

int check() {

    srand (1);

    int n_steps = 10;
    for(int step = 0; step < n_steps ; step ++) {

        int n = 10000;
        int n_max = 100000 ;
        vector<int> a(n), b(n), c(n);
        for(int i=0; i<n; i++) a[i] = rand() % (2 * n_max) - n_max;
        for(int i=0; i<n; i++) b[i] = rand() % (2 * n_max) - n_max;
        for(int i=0; i<n; i++) c[i] = rand() % (2 * n_max) - n_max;
        double x = find_median(n, a, b, c);
        double y = find_median(n, a, b, c);
        cout << x << " " << y << " " << x - y << endl;
    }
}

int main() {
    solve();
    // check();
}


Measured memory_bytes: 3236
def main():
    n, m = map(int, input().split())
    if m == 0:
        print(0, 0)
        return
    ps_list = [list(input().split()) for _ in range(m)]
    ps_list.sort(key=lambda x: x[0])
    now_p = ps_list[0][0]
    not_now_ac_flag = True
    ac_ans = 0
    now_wa = 0
    wa_ans = 0
    for p, s in ps_list:
        if p != now_p:
            now_p = p
            if not not_now_ac_flag:
                wa_ans += now_wa
            not_now_ac_flag = True
            now_wa = 0
        if s == "AC" and not_now_ac_flag:
            ac_ans += 1
            not_now_ac_flag = False
        if s == "WA" and not_now_ac_flag:
            now_wa += 1
    if not not_now_ac_flag:
        wa_ans += now_wa
    print(ac_ans, wa_ans)
main()

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> PY(N, vector<int>());
    vector<int> P(M, 0), Y(M, 0);
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> Y[i];
        PY[P[i] - 1].push_back(Y[i]);
    }
    for (int i = 0; i < N; i++)
    {
        sort(PY[i].begin(), PY[i].end());
    }
    for (int i = 0; i < M; i++)
    {
        stringstream ans1, ans2;
        ans1 << setw(6) << setfill('0') << to_string(P[i]);
        ans2 << setw(6) << setfill('0') << to_string(lower_bound(PY[P[i] - 1].begin(), PY[P[i] - 1].end(), Y[i]) - PY[P[i] - 1].begin() + 1);
        cout << ans1.str() << ans2.str() << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
def calc(p, q)
  rems = []
  place = []
  begin
    rems  << p
    place << p * 10 / q
    p = p * 10 % q
    return place.join if p.zero?
  end until (idx = rems.find_index(p))
  result = (st = place.join) + "\n"
  result + " " * idx + "^" * (st.length - idx)
end

$<.readlines.map {|l| l.split.map(&:to_i)}.each do |p, q|
  puts calc(p % q, q)
end


Measured memory_bytes: 9004
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if((a+b) > (c+d)) cout << "Left" << endl;
    else if((a+b) < (c+d)) cout << "Right" << endl;
        else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char a[101];
  scanf("%s",a);
  for(int i=0;i<101;i++){
    if(a[i]=='C')for(int j=i+1;j<101;j++){
      if(a[j]=='F'){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] == a[i]) a[i] = -1, cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include<iostream>
// #include<iomanip>
// #include<set>
// #include<vector>
// #include<map>
// #include<queue>
// #include<stack>
// #include<algorithm>
// #include<math.h>
using namespace std; 

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 

const int nax=2e5+5; 
const int offset=1e5+2; 
int tr[nax<<2]; 

void up(int p, int l, int r, int i){
	if(i<l || i> r) return;
	if(l==r){
		tr[p]+=1; 
		return;
	}
	int m=(l+r)>>1; 
	up(p<<1, l,m,i); 
	up(p<<1|1, m+1, r, i); 
	tr[p]=tr[p<<1]+tr[p<<1|1]; 
}
int qq(int p, int l, int r, int i, int j){
	if(r<i || l>j) return 0; 
	else if ( i<= l && r <= j) return tr[p]; 
	int m=(l+r)>>1; 
	return qq(p<<1, l,m,i,j)+ qq(p<<1|1, m+1, r, i,j); 
}

void solve(){
	int n; cin>>n; 
	vector<int> a(n); 
	for(int i=0;i<n;i++){
		cin>>a[i]; 
	}
	int lo=0, hi=mod; 
	ll amt=1ll* n*(n+1)/2; 
	while((hi-lo)>1){
		int x=(hi+lo)/2; 
		memset(tr,0,sizeof(tr));  
		vector<int> v, pre(n+1); 
		v.push_back(0); 
		up(1,0,nax-1,0+offset); 
		ll cnt=0; 
		for(int i=0;i<n;i++){
			if(a[i]<=x) v.push_back(1); 
			else v.push_back(-1); 
			pre[i+1]+=pre[i]+v[i+1]; 
			cnt+=qq(1,0,nax-1,0,pre[i+1]-1+offset); 
			up(1,0,nax-1,pre[i+1]+offset); 
		}
		if(cnt > amt/2){
			hi=x; 	
		}
		else {
			lo=x; 
		}
	}
	cout<<hi<<endl; 
}


int main(){
	// clock_t beg=clock(); 
	fast_io; 
    cout << fixed << setprecision(13); 
	solve(); 	
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

ll ap[1900];

int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,v;
    cin>>n>>v;
    if(v%n){
      cout<<(v-n);
    }else{
      cout<<n+v;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long p=1000003;
long long Fact[p];
long long inv(long long a) {
    long long b = p, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}
long long exponen(long long a,long long b){
    if (b==0){
        return 1;
    }
    else if(b%2==0){
        return exponen((a*a)%p,b/2);
    }
    else{
        return (a*exponen((a*a)%p,b/2))%p;
    }
}
long long fact(long long i){
    if (0<=i && i<p){
        return Fact[i];
    }
    else{
        return 0;
    }
}
long long solve(long long x,long long d,long long n){
    if (x==0){
        return 0;
    }
    if (d==0){
        return exponen(x,n);
    }
    long long a=(x*inv(d))%p;
    long long check=(-a)%p;
    if (0<=check && check<n){
        return 0;
    }
    return (exponen(d,n)*(fact(n-1+a)*inv(fact(a-1)))%p)%p;
}
int main(void){
    Fact[0]=1;
    for(int i=0;i<p-1;i++){
        Fact[i+1]=((i+1)*Fact[i])%p;
    }
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        long long xi,di,ni;
        cin>>xi>>di>>ni;
        cout<<solve(xi,di,ni)<<endl;
    }

}


Measured memory_bytes: 8832
/**
 *  Kaiwen Zhou,
 *  CUHK
**/
#include <bits/stdc++.h>
using namespace std;
#define INS ios::sync_with_stdio(false);cin.tie(0);
#define INF 2100000000

int N, A, B, C;
vector<int> l;

int DFS(int depth, int a, int b, int c) {
    if(depth == N) {
        if(min({a, b, c}) > 0)
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else
            return INF;
    }
    int res0 = DFS(depth + 1, a, b, c);
    int res1 = DFS(depth + 1, a + l[depth], b, c) + 10;
    int res2 = DFS(depth + 1, a, b + l[depth], c) + 10;
    int res3 = DFS(depth + 1, a, b, c + l[depth]) + 10;
    return min({res0, res1, res2, res3});
}

int main(void) {
    INS;
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i ++) {
        int l_i;
        cin >> l_i;
        l.push_back(l_i);
    }

    cout << DFS(0, 0, 0, 0) << '\n';
    return 0;
}


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

#define ll long long
#define mx 1000005

int main()
{
   int n,sum=0;
   cin>>n;

   int a[n],c[n];
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=0;i<n;i++){
    int val;
    cin>>val;
    sum+=val;
   }

   for(int i=0;i<n-1;i++)cin>>c[i];

   for(int i=1;i<n;i++)
   {
       if(a[i-1]+1==a[i])
       {
           sum+=c[a[i-1]-1];
       }
       //cout<<sum<<endl;
   }

   cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

#define MAX_ 2000000
int inv_list[MAX_]; //inv_list[i-1] = inverse of i
int fac[MAX_];
int finv[MAX_];
void nCk_init() {
  inv_list[0] = fac[0] = finv[0] = 1;
  for (int i = 0; i < MAX_ - 1; i++) {
    inv_list[i + 1] = MOD - ((inv_list[(MOD % (i + 2)) - 1] * (MOD / (i + 2))) % MOD);
    fac[i + 1]      = (fac[i] * (i + 2)) % MOD;
    finv[i + 1]     = (finv[i] * inv_list[i + 1]) % MOD;
  }
}
int nCk(int n, int k) {
  if (n == k or k == 0) return 1;
  return (fac[n - 1] * ((finv[k - 1] * finv[n - k - 1]) % MOD)) % MOD;
}

class FStrivore {
public:
  static void solve(istream &cin, ostream &cout) {
    int K;
    string S;
    cin >> K >> S;
    nCk_init();
    int ans = 0;
    rep(i, K + 1) {
      ans += ((nCk(S.size() + i - 1, S.size() - 1) * bpm(25, i)) % MOD * bpm(26, K - i)) % MOD;
    }
    cout << mod(ans, MOD) << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  FStrivore solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 51236
import Control.Applicative( (<$>))
import Data.ByteString.Char8( readInt, getLine, words	)
import qualified Data.ByteString.Char8 as C8
import Data.Maybe( fromJust)
import Data.List( sortBy)

main = do
    let
	readBS2Int = fst . fromJust . readInt
	readLine2Ints = map readBS2Int . C8.words <$> C8.getLine

    n_ <- readLn::IO Int
    as_ <- readLine2Ints
    let
	desc = sortBy (flip compare) as_

	collect::Int->Int->[Int]->Integer
	collect 0 0 []	= 0
	collect 0 0 [a]	= 0
	collect 0 0 (a1:tl@(a2:as))
	  | a1==a2	    = collect a1 0 as
	  | otherwise	    = collect 0 0 tl
	collect l 0 [] = 0
	collect l 0 [a] = 0
	collect l 0 (a1:tl@(a2:as))
	  | a1==a2	    = fromIntegral l* fromIntegral a2
	  | otherwise	    = collect l 0 tl
    
    print $ collect 0 0 desc

Measured memory_bytes: 16636