akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// c++ cpp.cpp -o cpp.exe -std=c++14
// ./cpp.exe

int main() {
	vector<string> a;
	vector<int> stack;

	string input; getline(cin, input);
	stringstream ss(input);
	string buf;

	while (not ss.eof()) {
		ss >> buf;
		a.push_back(buf);
	}

	for (int i = 0; i < a.size(); i++) {
		if (a[i] == "+") {
			stack[stack.size() - 2] += stack.back();
			stack.pop_back();
		}
		else if (a[i] == "-") {
			stack[stack.size() - 2] -= stack.back();
			stack.pop_back();
		}
		else if (a[i] == "*") {
			stack[stack.size() - 2] *= stack.back();
			stack.pop_back();
		}
		else {
			stack.push_back(stoi(a[i]));
		}
	}

	cout << stack.back() << endl;
	return 0;
}



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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    for(ll i=0; i<N; i++){
        cin >> A[i];
        B[i] = A[i]-(i+1);
    }
    sort(B.begin(),B.end());
    size_t s = B.size();
    ll mid;
    if(s%2==0){
        mid = (B[s/2]+B[s/2-1])/2;
    }
    else {
        mid = B[s/2];
    }
    
    ll ans=0;
    for(ll i=0; i<N; i++){
        ans += abs(B[i]-mid);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long n; cin>>n;
	long long hi = 1e18;
	long long prod = 1;
	bool flag = false;
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		if(a[i] == 0){
			flag = true;
			break;
		}
	}
	if(flag){
		cout<<0;
		return 0;
	}
	for(int i = 0; i < n; i++){
		if(prod <= hi / a[i]){
			prod *= a[i];
		}
		else{
			prod = -1;
			break;
		}
	}
	if(prod > hi){
		prod = -1;
	}
	cout<<prod<<endl;
}

Measured memory_bytes: 4048
H,W,K = map(int,input().split())
c = []

for i in range(H):
    c.append(list(input()))

ans = 0
for a in range(2**H):
    for b in range(2**W):
        black=0
        for i in range(H):
            for j in range(W):
                if ((a >> i) & 1) and ((b >> j) & 1) and c[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)


Measured memory_bytes: 9196
#import sys
#input = sys.stdin.buffer.readline
import numpy as np

def main():
    H,W = map(int,input().split())
    S = np.array([list(input()) for _ in range(H)]) == '.'

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:]
    for i in range(H-1):
        down[-i-2,:] = (down[-i-1,:] + 1) * S[-i-1,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,-i-2] = (right[:,-i-1] + 1) * S[:,-i-1]
        
    print(((up+down+left+right)*S).max()+1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 217524
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [n,c,k] = nexts(3);
  var t = nexts(n);
  t.sort((a,b)=>a-b);
  var ans = 1, v = 1;
  var u = t[0];
  for(var i = 1; i < n; i++){
    if(u+k < t[i] || v === c){
      ans++;
      v = 1;
      u = t[i];
    }else v++;
  }
  return ans;
}

Measured memory_bytes: 42776
#include<iostream>
#include<vector>
#include<stack>
#include<cmath>

using namespace std;

#define NUM 1000000
int money, n;
int prime[NUM];
int dp[NUM+1] = {};

int cal(int cost[]) {
  int i, j;
  int ans;
  for(i = 0; i <= money; i++) {
    dp[i] = 0;
  }
  
  dp[0] = 1;
  // for(i = 0; i < n; i++) {
  //   dp[cost[i]] = 1;
  // }

  for(i = 1; i <= money; i++) {
    for(j = 0; j < n; j++) {
      if(i - cost[j] >= 0 && dp[i - cost[j]] == 1) {
	dp[i] = 1;
      }
    }
  }

  // for(i = 0; i <= 1000; i++) {
  //   cout << i << ' ' << dp[i] << endl; 
  // }
  
  for(ans = money; ans > 0; ans--) {
    if(dp[ans] == 1 && prime[ans] == 1) {
      cout << ans << endl;
      return 0;
    }
  }
  
  cout << "NA" << endl;
  return 1;
}
  
int main() {
  int i, j;
  int sq_num = (int)sqrt((double)NUM);

  for (i = 0; i < NUM; i++)
    prime[i] = 1;  
  prime[0] =  prime[1] = 0;    
  
  for (i = 1; i < sq_num; i++) {
    if (prime[i] == 1)         
      for (j = 2; i * j <= NUM; j++) {
	prime[j*i] = 0;
      }
  }
  
  while(cin >> n >> money, n != 0 || money != 0) {
    int cost[n + 1] = {};
    for(i = 0; i < n; i++) {
      cin >> cost[i];
    }
    
    cal(cost); 
  }
  
  return 0;
}
    
	    

Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace  std;
#define mp make_pair
#define pb push_back
const long double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
//#define For(i,0,n) for(int i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
	
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}
int b[6000][6000];
long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}
//long long freq[(long long)1e7*3]={};
int a[(int)1e5];
ll dp[(int)1e5];
int k;
ll mincost(int x, int n)
{
	if(x==n-1)
		return 0;
	if(dp[x]>-1)
		return dp[x];
	else
	{
		ll minim= (ll)1e16;
		for(int i=1;i<=k ;i++)
		{
			if(i+x>n-1)
				break;
			ll cur= mincost(x+i, n)+abs(a[x]-a[x+i]);
			if(cur<minim)
				minim=cur;
		}

		dp[x]=minim;
		return dp[x];	

	}
}
int main()
{
	//memset(ncandidate,0,sizeof(ncandidate));	
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 memset(dp,-1,sizeof(dp));
	int n;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		{
			cin>>a[i];
			//cout<<dp[i]<<'\n';
		}	
	cout<<mincost(0,n);

	 

	 	//	cerr<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
bool pairComparesecond(const p& firstElof, const p& secondElof)
{
    return firstElof.second > secondElof.second;
}

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

int main(){
	ll n;
	cin>>n;
	ll a[100010];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	ll x=a[0];
	rep(i,0,n){
		x=gcd(x,a[i]);
	}
	cout<<x<<endl;
	

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n;
cin >> n;
float a[n];
float s,ans;
for(int i=0;i<n;i++){
   cin >> a[i];
}

for(int i=0;i<n;i++){
   s += 1/a[i];
}

ans = 1/s;

cout << ans << endl;


////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k=0;
    char a[3];
    cin>>a;
    if(a[0]=='1') 
        k++;
    if(a[1]=='1') 
        k++;
    if(a[2]=='1') 
        k++;
    cout<<k<<endl;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())
n = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
q = deque(['0'])
cnt = 0
ans = []
while len(q):
    v = q.pop()
    # print(v, cnt)
    if k + 1 == cnt:
        print(ans[-1])
        # print(ans)
        exit()
    check = int(v[-1])

    # print(v, check)

    for plus in n:
        st = str(v) + str(plus)

        if str(st)[0] == '0' and str(st)[1] == '0':
            continue

        if len(st) > 12:
            continue

        if abs(check - plus) > 1 and len(st) != 2:
            # print(check, plus, str(v) + str(plus))
            continue
        cnt += 1
        if k + 1 == cnt:
            ans_show = ans[-1]
            for g in range(len(ans_show)):
                if g == 0 and ans_show[0] == '0':
                    pass
                else:
                    print(ans_show[g], end='')
            exit()
        # print(q)
        ans.append(str(v) + str(plus))
        q.appendleft(st)


Measured memory_bytes: 63708
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	int n;
	cin>>n;
	int maxa,maxb;
	
	int a,b;
	
	cin>>a>>b;
	
	maxa=a;
	maxb=b;
	
	for(int i=1;i<n;i++){
		cin>>a>>b;
		if(maxb<b){
			maxb=b;
			maxa=a;
		}
		else if(maxb==b){
			if(maxa>a)
				maxa=a;
		}
	}
	
	cout<<maxa<<" "<<maxb<<endl;
	



}

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



int main(){
    int n;
    scanf("%d",&n);
    for (int num = 0; num<n; num++){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if (a==b || a-1==b){
            for (int x = c; x<=d; x++){
                printf(x%2==1?"A":"B");
            }
            printf("\n");
            continue;
        }
        if (b-1==a){
            for (int x = c; x<=d; x++){
                printf(x%2==1?"B":"A");
            }
            printf("\n");
            continue;
        }

            int mx = (a-1)/(b+1)+1;
            if (b>a) mx = (b-1)/(a+1)+1;
            int len = a+b;
            int numb = len/(mx+1);
            /// max b in a space of k = k-k/(mx+1)
            /// point where switch -> k from the right, where (len-k)/(mx+1)+k-k/(mx+1)==b
            for (int x = c; x<=d; x++){
                int k = len-x+1;
                bool switched = (len-k)/(mx+1)+k-k/(mx+1)<=b && ((len-k+1)/(mx+1)+k-1-(k-1)/(mx+1)<=b||k==1);
                if (!switched){
                    printf(x%(mx+1)==0?"B":"A");
                }
                else{
                    printf(k%(mx+1)==0?"A":"B");
                }

            }
            printf("\n");
            continue;

    }

}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    int a=(sum+4*M-1)/(4*M);
    if(a<=A.at(i)){
      count++;
    }
  }
  if(count>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  ll K;
  cin >> s >> K;
  int N = s.size();
  int i = 0;
  while(K > 0) {
    int k = ('z'-s[i]+1)%26;
    if(i == N-1) {
      s[i] = 'a'+(int(s[i]-'a')+K)%26;
      K = 0;
    } else if(K >= k) {
      K -= k;
      s[i] = 'a';
    }
    i++;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3760
//
// Created by yamunaku on 2019/11/09.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct SegmentTree{
    ll ide = LINF;

    int n;
    vector<ll> node;

    SegmentTree(int sz){
        n = 1;
        while(n < sz) n <<= 1;
        node.resize(2 * n - 1, ide);
        // for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        // for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    ll get(int k){
        ll ans = ide;
        k += n - 1;
        ans = min(ans, node[k]);
        while(k){
            k = (k - 1) / 2;
            ans = min(ans, node[k]);
        }
      return ans;
    }

    void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
        if(r < 0)r = n;
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            node[k] = min(node[k], x);
            return;
        }
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
    }
};

struct edge{
    int l;
    int r;
    ll c;
};

int main(){
    // CFS;
    int n, m;
    cin >> n >> m;
    vector<edge> e(m);
    rep(i, m){
        cin >> e[i].l >> e[i].r >> e[i].c;
        e[i].l--, e[i].r;
    }
    sort(all(e), [](edge &l, edge &r){
        return l.l < r.l;
    });
    SegmentTree seg(n);
    seg.update(0, 1, 0);
    rep(i, m){
        ll x = seg.get(e[i].l);
        seg.update(e[i].l, e[i].r, x + e[i].c);
    }
    ll ans = seg.get(n-1);
    if(ans==LINF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
while 1:
    H,W=map(int,input().split())
    #0 0 ga input saretara owari
    if H==0 and W==0:
        break
    #loop
    #H ga tate, W ga yoko
    for i in range(H):
        #saisho to saigo no gyou ha subete '#'
        if i==0 or i==H-1:
            print('#'*W)
        #sore isgai no gyou ha hidari hashi to migi hashi ga '#' aida ha '.'
        else:
            print('#'+'.'*(W-2)+'#')
    #tugi no sikaku no maeni kaigyou
    print()
        
            



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
int main()
{
    long long int N;cin >> N;
    vector<long long int> vec;
    for(int a = 0;a < N*3;a++){
        long long int b;cin >> b;
        vec.push_back(b);
    }
    sort(vec.begin(),vec.end(),std::greater<int>());
    long long int s = 0;
    long long int ans = 0;
    for(int a = 0;a < N;a++){
        s++;
        ans += vec.at(s);
        //cout<<vec.at(s)<<endl;
        s++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6512
<?php

fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);

$answer = array(
  1 => 1,
  2 => 2,
  3 => 3,
);

unset($answer[$a]);
unset($answer[$b]);

foreach ($answer as $ans) {
  echo $ans;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
const int64_t MAX = (1LL << 62);
int64_t DP[1010][4100]; // i番目にbitのパターンとなる場合の最初コスト

void init()
{
  for (int i = 0; i < 1010; i++)
  {
    for (int j = 0; j < 4100; j++)
    {
      DP[i][j] = MAX;
    }
  }
  DP[0][0] = 0;
}

int main()
{
  int64_t N, M, a, b, c, ans = MAX;
  cin >> N >> M;
  init();
  vector<pair<int64_t, int64_t>> vp(M);
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    int bit = 0;
    for (int j = 0; j < b; j++)
    {
      cin >> c;
      bit |= (1 << (c - 1));
    }
    vp.at(i) = {a, bit};
  }
  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < (1 << N); j++)
    {
      DP[i + 1][j] = DP[i][j];
      if (DP[i][j] == MAX)
        continue;
      int nextj = (j | vp.at(i).second);
      DP[i][nextj] = min(DP[i][nextj], DP[i][j] + vp.at(i).first);
    }
  }
  int all = (0b111111111111 >> (12 - N));
  for (int i = 0; i < M; i++)
  {
    ans = min(ans, DP[i][all]);
  }
  cout << ((ans == MAX) ? -1 : ans) << endl;
}

Measured memory_bytes: 35984
import Control.Monad

drawFrame :: Int -> Int -> IO ()
drawFrame h w = do
    putStrLn $ replicate w '#'
    replicateM_ (h-2) $ do
        putChar '#'
        putStr $ replicate (w-2) '.'
        putStrLn "#"
    putStrLn $ replicate w '#'

main = getContents >>= mapM_ (\[h,w] -> do drawFrame h w; putStrLn "") .
    takeWhile (/= [0,0]) . map (map read . words) . lines

Measured memory_bytes: 3952
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

ll uniformity[8*NUM],partial[8*NUM];
ll N = 1;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		return sum;
	}
}

int main(){

	ll first_N,Q,command,left,right,value;
	scanf("%lld %lld",&first_N,&Q);

	init(first_N);

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	for(ll i = 0; i < Q; i++){
		scanf("%lld",&command);

		if(command == 0){
			scanf("%lld %lld %lld",&left,&right,&value);
			left--;
			add(left,right,value,0,0,N);
		}else{
			scanf("%lld %lld",&left,&right);
			left--;
			printf("%lld\n",getSum(left,right,0,0,N));
		}
	}

	return 0;
}



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

int main(){
	string s,t;
	cin>>s>>t;
	vector<int>start(26,-1);
	vector<int>goal(26,-1);
	for(int i=0;i<s.size();i++){
		int a=s[i]-'a';
		int b=t[i]-'a';

		if(start[a]!=-1||goal[b]!=-1){
			if(start[a]!=b||goal[b]!=a){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else {
			start[a]=b;
			goal[b]=a;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()

int inf = 1e18;
const int N = 4e5+5;

/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}*/
vi freq(N);
vi arr(N);
vi dp(N);
bool help(int mid)
{


}


int32_t main()
{
    io
    int tt=1;
    //cin>>t;
    while(tt--)
    {
      int m1,d1,m2,d2;
      cin>>m1>>d1>>m2>>d2;
      if(m1==m2)
      {
          cout<<0<<el;
      }
      else
        cout<<1<<el;
    }



        return 0;
}


Measured memory_bytes: 9600
N,M,X=map(int, raw_input().split())
cost=map(int, raw_input().split())

cost1=0
for i in range(X,N+1):
	if i in cost:
		cost1+=1


cost2=0
for i in range(X,-1,-1):
	if i in cost:
		cost2+=1

print min(cost1,cost2)

Measured memory_bytes: 2568
N = int(input())

def Div(x):
    y = int(x ** 0.5)
    count = 0
    for i in range(1,y+1):
        if x % i == 0:
            count += 2
    if y**2 == x:
        count += 1
    return count

if N == 1:
    print(0)
    exit()

res = 0
for i in range(2, N+1):
    if (i%2 == 1) and (Div(i) == 8):
        res += 1
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int a,b;
cin >> a >> b ;

int l[a];
rep(i,a)cin >> l[i];
sort(l,l+a);

int ans =0;
for(int i=a-1;a-b<=i;i--)ans +=l[i];

cout << ans << endl;

return 0;
}



Measured memory_bytes: 256
def gcd(a, b):
    if a < b: b, a = a, b
    if b == 0: return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


N = int(input())

ret = 1

for _ in range(N):
    ret = lcm(ret, int(input()))

print(ret)


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

int n, m;
ll x[100005];

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m;
    for(int i = 1; i <= m; i++){
    	cin>>x[i];
    }
    if(n >= m){
    	cout<<0<<endl;
    	return 0;
    }
    sort(x + 1, x + m + 1);
    ll ans = x[m] - x[1];
    for(int i = 1; i < m; i++){
    	x[i] -= x[i+1];
    }
	sort(x + 1, x + m);
	for(int i = 1; i < n; i++){
		ans += x[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
 
A = [x for x in A if "#" in x]
A = list(zip(*A)) 
A = [x for x in A if "#" in x]
A = list(zip(*A)) 
for x in A:
  print("".join(x))

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int x = 0; int y = 0;
	rep(i, s.length()) {
		if ('A' <= s[i] && s[i] <= 'M') {
			x++;
		}
		else if ('N' <= s[i] && s[i] <= 'Z') {
			x--;
		}
		else if ('a' <= s[i] && s[i] <= 'm') {
			y++;
		}
		else {
			y--;
		}
	}
	string ans;
	if (x > 0) {
		rep(i, x)ans.push_back('A');
	}
	else if (x < 0)rep(i, -x)ans.push_back('N');
	if (y > 0) {
		rep(i, y)ans.push_back('a');
	}
	else if (y < 0) {
		rep(i, -y)ans.push_back('n');
	}
	cout << ans.size() << endl;
	cout << ans << endl;
}

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



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

using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    int ma;
    int mi;
    ma=max(a,max(b,max(c,max(d,e))));
    mi=min(a,min(b,min(c,min(d,e))));
    if(ma-mi<=k){
        cout<<"Yay!"<<endl;
    }else{
    cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<vector<char>> s;
vector<vector<int>> sb;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

struct xydata {
    int x, y;
};

int bfs(int sx, int sy, int gx, int gy) {
    sb = vector<vector<int>>(h, vector<int>(w, 1000));
    xydata first;
    first.x = sx;
    first.y = sy;
    queue<xydata> que;
    que.push(first);
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            sb.at(i).at(j) = 1000;
        }
    }
    sb.at(first.y).at(first.x) = 0;

    while(!que.empty()) {
        xydata now = que.front();
        que.pop();
        if(now.x == gx && now.y == gy) {
            break;
        }
        for(int i = 0; i < 4; ++i) {
            xydata next;
            next.x = now.x+dx.at(i);
            next.y = now.y+dy.at(i);
            if(next.x >= 0 && next.x < w && next.y >= 0 && next.y < h) {
                if(s.at(next.y).at(next.x) == '.' && sb.at(next.y).at(next.x) == 1000) {
                    sb.at(next.y).at(next.x) = sb.at(now.y).at(now.x) + 1;
                    que.push(next);
                }
            }
        }
    }
    return sb.at(gy).at(gx);
}

int main() {
    cin >> h >> w;
    s = vector<vector<char>>(h, vector<char>(w, '.'));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> s.at(i).at(j);
        }
    }

    int maxlen = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s.at(i).at(j) == '.') {
                for(int k = 0; k < h; ++k) {
                    for(int l = 0; l < w; ++l) {
                        if(i == k && j == l) {
                        
                        }else {
                            if(s.at(k).at(l) == '.') {
                                // cout << j << i << l << k << " ";
                                int len = bfs(j, i, l, k);
                                // cout << len << endl;
                                maxlen = max(maxlen, len);
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << maxlen << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <cctype>

int main()
{
 char ch;

 while(1) {
  scanf("%c", &ch);
  if(islower(ch)) ch = toupper(ch);
  else if(isupper(ch)) ch = tolower(ch);

  printf("%c", ch);

  if(ch == '\n') break;
 }

 return 0;
}

Measured memory_bytes: 940
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/GCD(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC
 
 
int main(){
    fast;
    // test{
    //     ll n,s=0;cin>>n;
    //     vecll a(n);
    //     set <ll> se;
    //     for(auto &x:a){cin>>x;s+=x;se.insert(x);}
    //     vecll pra,prb;
    //     pra.pb(a[0]),prb.pb(s);
    //     for(int i=1;i<n;i++){
    //         pra.pb(a[i]+pra[i-1]);
    //         prb.pb(prb[i-1]-a[i-1]);
    //     }
    //     ll c=0,z=1;
    //     for(auto x:se){
    //         if(x!=z){c=1;break;}
    //         z++;
    //     }
    //     if(c)cout<<0<<endl;
    //     else{
    //         vecll ans;
    //         for(int i=0;i<n-1;i++){
    //             if(s-pra[i] == ((n-i)*(n-i-1))/2 and pra[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }   
    //         for(int i=n-1;i>=0;i--){
    //             if(s-prb[i] == ((n-i)*(n-i-1))/2 and prb[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }
    //         cout<<ans.size()<<endl;
    //         for(auto x:ans)cout<<x<<" "<<n-x<<endl;
    //     }
 
 
    // }
    string s;
    cin>>s;
    if(s[1]== '7' or s[0]== '7' or s[2]== '7')cout<<"Yes";
    else cout<<"No";
    //cout<<s[0];
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> s(n+1, 0);
    map<ll, ll> mp;
    ll ans = 0;
    mp[0]++;
    rep(i, 1, n+1){
        ll a; cin >> a;
        s[i] = s[i-1] + a;
        ans += mp[s[i] % m];
        mp[s[i] % m]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main() {
    int x;
    scanf("%d", &x);
    int y = 360;
    int xx = x;
    int count = 1;
    while(xx % y != 0) {
        xx += x;
        count++;
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 1736
N= int(input())

dict = {}
for count in range(N):
    tcount = 0
    S= str(input())
    
    if S in dict.keys():
        tcount = dict[S] + 1
        dict.pop(S)
        dict[S] = tcount
    else:
        dict[S] = 1

maxval = max(dict.values())

keys = [k for k, val in dict.items() if val == maxval]
keys.sort()

for count in range(len(keys)):
    print(keys[count])

Measured memory_bytes: 32096
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int A,B,K;

int main(int argc, char const *argv[])
{
    cin>>A>>B>>K;
for(int i=A;i<=B;i++){
    if(i<A+K||B-K<i){
        cout<<i<<endl;
    }
}

return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())
a = s // 100
b = s % 100
if 1 <= a <= 12:
    if 1 <= b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 9176
//ABC113B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	vector<double> x(n), diff(n);
	diff.at(0) = 100;
	for(int i=0;i<n;i++){
		cin >> h.at(i);
		x.at(i) = t - 0.006*h.at(i);
		diff.at(i) = abs(a-x.at(i));
	}
	sort(diff.begin(),diff.end());
	for(int i=0;i<n;i++){
		if(abs(a-x.at(i)) == diff.at(0)){
			cout << i+1;
		}
	}
}

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

//関数宣言
//int func(int x, int y);
void dictionary_withnum(int N, int L, char S[N][L], int A[N], int B[N])
{
 
  int i, j;
 
  /* 文字列の数 */
  int num = N;
 
  /* 文字列 */
  char tmp[L], tmpA, tmpB;
 
  for(i=1;i<num;i++){
    for(j=1;j<num;j++){
      if(strcmp(S[j-1], S[j])>0){
        strcpy(tmp, S[j-1]);
        strcpy(S[j-1], S[j]);
        strcpy(S[j], tmp);
        tmpA = A[j-1];
        A[j-1] = A[j];
        A[j] = tmpA;
        tmpB = B[j-1];
        B[j-1] = B[j];
        B[j] = tmpB;
      }
    }
  }
 
}

void dictionary_withnum2(int N, int L, char S[N][L], int A[N], int B[N])
{
 
  int i, j;
 
  /* 文字列の数 */
  int num = N;
 
  /* 文字列 */
  char tmp[L], tmpA, tmpB;
 
  for(i=1;i<num;i++){
    for(j=1;j<num;j++){
      if(strcmp(S[j-1], S[j])==0 && A[j-1] < A[j]){
        strcpy(tmp, S[j-1]);
        strcpy(S[j-1], S[j]);
        strcpy(S[j], tmp);
        tmpA = A[j-1];
        A[j-1] = A[j];
        A[j] = tmpA;
        tmpB = B[j-1];
        B[j-1] = B[j];
        B[j] = tmpB;
      }
    }
  }
 
}

int main(void){

  //スカラー入力
  int N;

  scanf("%d", &N);

  //配列入力
  char S[N][11];
  int P[N],T[N];

  for(int i=0; i<N; i++){
    scanf("%s %d", S[i], &P[i]);
    T[i] = i+1;
  }

  dictionary_withnum(N,11,S,P,T);
  dictionary_withnum2(N,11,S,P,T);

  for(int i=0; i<N; i++){
    printf("%d\n", T[i]);
  }


  return 0;
}



Measured memory_bytes: 128
from collections import Counter
n=int(input())
strings = []
for i in range(n):
    strings.append(input())
dic = {}
for string in strings:
    c = Counter(string)
    s = "".join([str(c[l]) for l in "abcdefghijklmnopqrstuvwxyz"])
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 0
res = 0
for k , v in dic.items():
    res += v * (v + 1)/2
print(int(res))

Measured memory_bytes: 26860
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

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

    vector<ll> A2(N);
    for (int i = 0; i < N-1; ++i) {
        A2[i] = A[i+1] - A[i];
    }
    A2[N-1] = K - A[N-1] + A[0];

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

    ll ans = 0;
    for (int i = 0; i < N - 1; ++i) {
        ans += A2[i];
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){
    int a,b,n;
    cin >> n;

    if(n==1){
        cout << "Hello World" << endl;
    } else {
        cin >> a;
        cin >> b;
        cout << a+b << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  vector<tuple<string,int,int>>v;
  for(int i=0; i<n; i++){
  string s; int p; cin >>s >>p; p*=-1;
  v.push_back(make_tuple(s,p,i+1));
  }
  sort(v.begin(),v.end());
  for(auto x:v) cout <<get<2>(x)<<'\n';
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	bool ok = false;
	for(int i = 0; i <= x && !ok; ++i)
		ok = (i * 2 + (x - i) * 4 == y);
	cout << (ok ? "Yes" : "No");
}


Measured memory_bytes: 3104
N,Q=map(int,input().split())
S=input()
LR=[]
for i in range(Q):
  LR.append(list(map(int,input().split())))
t=[0]*(N+1)
for i in range(N):
  if S[i:i+2]=='AC':
    t[i+1]=t[i]+1
  else:
    t[i+1]=t[i]
for i in range(Q):
  print(t[LR[i][1]-1]-t[LR[i][0]-1])

Measured memory_bytes: 30640
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n = ni()
a = list(li())
a.sort()
acc = list(accumulate(a))



ans = 0
for ai, acci in zip(a[-1:0:-1], acc[-2::-1]):
    if 2*acci >= ai:
        ans += 1
    else:
        break
        
        
print(ans+1)

Measured memory_bytes: 14472
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << min(a+b+1,c)+b << endl;
}


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

public class Program
{
	public static void Main()
	{
		var sum = _GetIntReadLine();
		var volume = Math.Pow(sum / 3f , 3);
		Console.WriteLine(volume);
	}

	private static int _GetCombinationNum(int iLeft , int iRight)
	{
		var left = Enumerable.Range(iLeft - iRight + 1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		var right = Enumerable.Range(1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		return left / right;
	}
	
	private static string		_GetReadLine()		  { return Console.ReadLine(); }
	private static int			_GetIntReadLine()	  { return int.Parse(_GetReadLine()); }
	private static List<string> _GetListReadLine()	  { return _GetReadLine().Split(' ').ToList(); }
	private static List<int>	_GetIntListReadLine() { return _GetListReadLine().Select(iText => int.Parse(iText)).ToList(); }
}

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

int main() {
  int N; string S, T;
  cin >> N >> S >> T;
  rep(i,N) {
    cout << S[i] << T[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var inputs = Console.ReadLine().Split(' ');

            var nums = Array.ConvertAll(inputs,int.Parse);
            var sum = 0L;
            int min, max;
            min = max = nums[0];
            Array.ForEach(nums, x =>
            {
                sum += x;
                if (min > x) { min = x; }
                if (max < x) { max = x; }
            });

            Console.WriteLine("{0} {1} {2}", min,max, sum);
        }
    }
}

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

class Main{

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			int num = Integer.parseInt(br.readLine());

			if(num == 0){
				break;
			}

			String[] token = br.readLine().split(" ");
			int[] point = new int[num];
			double sum = 0;

			for(int i = 0; i < num; i++){
				point[i] = Integer.parseInt(token[i]);
				sum += point[i];
			}

			double average = sum / num;
			sum = 0;

			for(int i = 0; i < num; i++){
				sum += Math.pow(point[i] - average, 2);
			}

			double dispersion = sum / num;
			double deviation = Math.sqrt(dispersion);

			sb.append(String.format("%.8f\n", deviation));

		}

		System.out.print(sb);

	}
}

Measured memory_bytes: 25356
import math
import statistics


N = int(input())
A = [int(i) for i in input().split()]
b = math.ceil(statistics.median([a-n for a,n in zip(A,range(1,N+1))]))
ans = [abs(a - b - n) for a,n in zip(A,range(1, N+1))]
print(sum(ans))


Measured memory_bytes: 27204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int md = 1e9 + 7;

int mul(int a, int b) {
  return ((ll)a * b) % md;
}

void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

int power(int a, ll b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int inv(int a) {
  return power(a, md - 2);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, q;
  cin >> n >> q;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector <pair <int, int>> op(q);
  for (int i = 0; i < q; ++i) {
    cin >> op[i].first >> op[i].second;
    --op[i].first, --op[i].second;
    if (op[i].first > op[i].second) swap(op[i].first, op[i].second);
  }
  vector <vector <vector <int>>> dp(n, vector <vector <int>> (n, vector <int> (2)));
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      dp[i][j][0] = 1;
    }
  }
  int coef = 1, icoef = 1;
  
  for (int t = q - 1; t >= 0; --t) {
    vector <pair <int&, int>> to_change;
    auto recalc = [&] (int i, int j, int f) {
      int new_dp = mul(coef, dp[i][j][f]);
      int go_i = i, go_j = j;
      if (i == op[t].first || i == op[t].second) go_i = op[t].first ^ op[t].second ^ i;
      if (j == op[t].first || j == op[t].second) go_j = op[t].first ^ op[t].second ^ j;
      int go_f = f;
      if (go_i > go_j) {
        swap(go_i, go_j);
        go_f ^= 1;
      }
      add(new_dp, mul(coef, dp[go_i][go_j][go_f]));
      to_change.push_back({dp[i][j][f], new_dp});
    };

    for (int i : {op[t].first, op[t].second}) {
      for (int j = i + 1; j < n; ++j) {
        for (int f = 0; f <= 1; ++f) {
          recalc(i, j, f);
        }
      } 
    }
    for (int j : {op[t].first, op[t].second}) {
      for (int i = j - 1; i >= 0; --i) {
        for (int f = 0; f <= 1; ++f) {
          recalc(i, j, f);
        }
      } 
    }
    icoef = mul(icoef, (md + 1) / 2); 
    coef = mul(coef, 2);

    for (auto p : to_change) {
      p.first = mul(p.second, icoef);
    }
  } 
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] > a[j]) {
        add(ans, mul(coef, dp[i][j][0]));
      } else if (a[i] < a[j]) {
        add(ans, mul(coef, dp[i][j][1]));
      }
    }
  }
  cout << ans << '\n';
}



Measured memory_bytes: 496100
N, K = map(int, input().split())
withSnacks = []
for x in range(K):
	nUmsnakes = int(input())
	snakes = list(map(int, input().split()))
	withSnacks.extend(snakes)
withSnacks = list(set(withSnacks))
count = 0
for x in range(1, N + 1):
	if not x in withSnacks:
		count += 1
 
print(count)

Measured memory_bytes: 9188
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <iostream>

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

class modint {
private:
  static constexpr long long int MOD = 1000000000 + 7; // (10 ** 9) + 7
  long long int x;

  static long long int sanitize(long long int n) {
    while (n < 0) {
      n += modint::MOD;
    }
    return n % modint::MOD;
  }

public:
  modint(long long int x) : x(sanitize(x)) {}
  modint() : x(0) {}

  modint &operator=(const modint &other) {
    this->x = other.x;
    return *this;
  }

  modint operator+(const modint &other) const {
    modint ret;
    ret.x = (this->x + other.x) % modint::MOD;
    return ret;
  }

  modint operator-(const modint &other) const {
    modint ret;
    ret.x = (this->x - other.x);
    if (x < 0) {
      ret.x += modint::MOD;
    }
    return ret;
  }

  modint operator*(const modint &other) const {
    modint ret;
    ret.x = (this->x * other.x) % modint::MOD;
    return ret;
  }

  modint &operator+=(const modint &other) {
    this->x = (this->x + other.x) % modint::MOD;
    return *this;
  }

  modint operator<<(const long long int shift) const {
    modint base = modint(2).pow(shift);
    return *this * base;
  }

  modint pow(long long int n) const {
    modint ret;
    ret.x = _pow(n);
    return ret;
  }

  friend std::ostream &operator<<(std::ostream &stream, const modint &value);

private:
  long long int _pow(long long int n) const {
    long long int a = this->x;
    long long res = 1;
    while (n > 0) {
      if (n & 1) {
        res = res * a % modint::MOD;
      }
      a = a * a % modint::MOD;
      n >>= 1;
    }
    return res;
  }
};

std::ostream &operator<<(std::ostream &stream, const modint &value) {
  return stream << value.x;
}


#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;



void solve() {
  int N;
  cin >> N;

  vector<int> v(N+1);
  v[0] = 3;

  modint ans = 1;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;

    ans = ans * v[a];
    v[a]--;
    v[a+1]++;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 3708
#include<iostream>
using namespace std;
 
int main(){
 
    int n;
 
    cin >> n;
 
    int p[n],t[n],count=0,tcount;
 
    for(int i=0;i<n;i++){
      cin >> p[i];
      t[i] = p[i];
      //count += p[i];
    }
 
    if(p[0] > p[1]){
      count += p[0] + p[1];
      p[1] = 0;
    }
    else{
      count += p[0]*2;
      p[1] -= p[0];
    }
 
    for(int i=1;i<n-1;i++){
      count += p[i] * 2;
      if(p[i] > p[i+1] ){
        p[i+1] = 0;
      }
      else{
        p[i+1] -= p[i];
      }
    }
 
    if(p[n-1] != 0){
      count += p[n-1];
    }
 
 
 
 
    tcount = t[0];
 
    for(int i=1;i<n-1;i++){
      tcount += t[i] * 2;
      if(t[i] > t[i+1] ){
        t[i+1] = 0;
      }
      else{
        t[i+1] -= t[i];
      }
    }
 
    if(t[n-1] != 0){
      tcount += t[n-1];
    }
 
 
 
    /*int maxp = max(p[0],p[1]);
 
    if(maxp == p[0]){
      count += p[0] + p[1];
      p[0] = p[1] = 0;
    }
    else{
      count += p[0] * 2;
      p[1] -= p[0];
    }
 
 
 
    maxp = max(p[n-2],p[n-1]);
 
    if(maxp == p[n-2]){
      count += p[n-2] * 2;
    }
    else{
      count += p[n-2] + p[n-1];
    }*/
 
    cout << min(count,tcount) << endl;
 
    return 0;
}

Measured memory_bytes: 3136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class AMultiplication1 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,b;
        in >> a >>b;
        out << a*b <<endl;
	}
};


int main() {
	AMultiplication1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,m;
		cin>>n>>m;
		ll x;
		cin>>x;
		ll a[n][m],c[n];
		FOR(i,0,n)
		{
			cin>>c[i];
			FOR(j,0,m)
			cin>>a[i][j];
		}
		ll k=po(2,n),ans=INF,o,ct,un[m];
		FOR(i,0,k)
		{
			o=i;
			FOR(j,0,m)
			un[j]=0;
			ct=0;
			int l=0;
			while(o)
			{
				if(o%2==1)
				{
					ct+=c[l];
					FOR(j,0,m)
					{
						un[j]+=a[l][j];
					}
				}
				o>>=1;
				l++;
			}
			bool f=1;
			FOR(j,0,m)
			{
//				cout<<un[j]<<' ';
				if(un[j]<x)
				{
					f=0;
					break;
				}
			}
//			cout<<'\n';
			if(f)
			{
				ans=min(ans,ct);
			}
		}	
		if(ans==INF)
		cout<<-1;
		else
		cout<<ans;	
	}
	return 0;
}


Measured memory_bytes: 3652