akhauriyash/Code-Regression huggingface dataset:
# N,X,Y = (int(i) for i in input().split())
#
#
# NUM = [0] * (N-1)
#
# for i in range(1,N):
#     for j in range(i+1,N+1):
#         num = min(abs(i-j), abs(X-i)+1+abs(Y-j), abs(Y-i) + 1 + abs(X-j))
#         if (num < N):
#             NUM[num-1] += 1
#
#
# for i in range(len(NUM)):
#     print(NUM[i])


def main():
    N,X,Y = (int(i) for i in input().split())


    NUM = [0] * (N-1)

    for i in range(1,N):
        for j in range(i+1,N+1):
            num = min(abs(i-j), abs(X-i)+1+abs(Y-j), abs(Y-i) + 1 + abs(X-j))
            if (num < N):
                NUM[num-1] += 1


    for i in range(len(NUM)):
        print(NUM[i])
    # n, x, y = (int(i) for i in input().split())
    # num_list = [0] * (n - 1)
    # 
    # for i in range(1, n):
    #     for j in range(i + 1, n + 1):
    #         num = min(abs(i - j), abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j))
    #         if (num < n):
    #             num_list[num - 1] += 1
    # 
    # for i in range(len(num_list)):
    #     print(num_list[i])
        
        
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
N, K = map(int, input().split())

MOD = 10**9 + 7

dp = [[0] * (N + 1) for i in range(N + 1)]
for i in range(N + 1):
    dp[i][0] = 1
    dp[i][i] = 1
for i in range(2, N + 1):
    for j in range(1, i):
        dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD


for i in range(1, K + 1):
    print((dp[K - 1][i - 1] * dp[N - K + 1][N - K - i + 1]) % MOD)



Measured memory_bytes: 75100
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}
int jishojun(string s,string t){ //辞書順で、sが大きければ0を、同じなら1を、tが大きければ2を返す
	int ssize=s.size();
	int tsize=t.size();
	int x=min(ssize,tsize);
	rep(i,x){
		if(s[i]<t[i]) return 2;
		else if(s[i]>t[i]) return 0;
	}
	if(ssize<tsize) return 2;
	else if(ssize == tsize) return 1;
	else return 0;
}

int main(){
	
	string s1,t1;
	cin>>s1>>t1;
	string s,t;
	rep(i,26){
		char x='a'+i;
		rep(j,s1.size()){
			if(x == s1[j]){
				s.push_back(s1[j]);
			}
		}
	}
	rrep(i,26){
		char x='a'+i;
		rep(j,t1.size()){
			if(x == t1[j]){
				t.push_back(t1[j]);
			}
		}
	}
	if(jishojun(s,t) == 2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

//线性查找元素时增加标记到末尾可减少比较次数
//不增加标记：判断是否到达序列末尾，判断是否找到元素 
// 增加标记：判断是否在末尾之前找到元素 ，末尾元素和目标元素值相同 

bool linearSearch(int a[], int key, int n)
{
	a[n] = key;
	int i = 0;
	while (a[i] != key) i++;//找到元素和遍历到末尾的结束条件相同
	return i == (n); 
}

int main()
{
	int a[10000 + 1];
	int n = 0;
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];
	int q = 0;
	std::cin >> q;
	int sum = 0;
	for (int i = 0; i < q; ++i) {
		int t = 0;
		std::cin >> t;
		if (!linearSearch(a, t, n))
		sum++;
	}
	std::cout << sum << std::endl;
	return 0;
}


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

using namespace std;

#define MAXN 2010

bitset<2000010> f;

typedef int x;
x a[MAXN],n,sum;

x main(){
    scanf("%d",&n);
    for(x i = 1;i <= n;i++){scanf("%d",a+i),sum+=a[i];}
    f[0] = 1;
    for(x i = n;i>=1;--i)f |= f<<a[i];
    for(x i = (sum+1)>>1;i <= sum;i++){
        if(f[i]){
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int x,y; cin>>x>>y;
  bool ok=false;
  for(int i=0;i<=x;i++) {
    int j = x-i;
    if (i * 2 + j * 4 == y) ok=true;
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
using namespace std;
std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
namespace Sakurajima_Mai{
	#define si(a) scanf("%d",&a)
	#define sl(a) scanf("%lld",&a)
	#define sd(a) scanf("%lf",&a)
	#define ss(a) scanf("%s",a)
	#define ms(a) memset(a,0,sizeof(a))
	#define reg register
	#define repi(i,a,b) for(reg int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
	#define repd(i,a,b) for(reg int i=a,bbb=b;i>=bbb;--i)
	#define reps(s) for(reg int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
	#define ce(i,r) i==r?'\n':' '
	#define pb push_back 
	#define all(x) x.begin(),x.end()
	#define gmn(a,b) a=min(a,b)
	#define gmx(a,b) a=max(a,b)
	#define fi first
	#define se second
	#define pr(x) cout<<#x<<": "<<x<<endl
	typedef long long ll;
	typedef unsigned long long ull;
	typedef double db;
	const int infi=2e9;
	const ll infl=4e18;
	inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
	}
	inline ll ql(){
		ll f=0;int fu=1; char c=getchar();
	    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
	    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
	    return f*fu;
	}
	inline db qd(){
	    char c=getchar();int flag=1;double ans=0;
	    while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
	    if(c=='-') flag=-1,c=getchar();
	    while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
	    if(c=='.'){c=getchar();for(register int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
	    return ans*flag;
	}
	inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
}
using namespace Sakurajima_Mai;
int main()
{
	string s="ACL";
	int k=qi();
	repi(i,1,k) cout<<s;
	puts("");
	return 0;
}

Measured memory_bytes: 3552
/**
 * Created by hiramekun at 19:43 on 2019-10-25.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

// ceil(x/y)
ll my_ceil(ll x, ll y) {
    return ll(ceil(double(x) / y));
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll k;
    cin >> k;
    vl a(k);
    cin >> a;
    reverse(all(a));

    ll low = 2, high = 2;
    for (ll i = 0; i < k; ++i) {
        low = my_ceil(low, a[i]) * a[i];
        high = (high / a[i]) * a[i];
        if (low > high) {
            cout << -1 << '\n';
            return;
        }
        high += a[i] - 1;
    }
    cout << low << ' ' << high << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
  int N, M;
  
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int max = 0;
  for (int i = 0; i < N; i++) {
    string u = s.at(i);
    
    int sum = 1;
    for (int j = i + 1; j < N; j++) {
      if (s.at(j) == u) {
        sum++;
      }
    }
    
    for (int j = 0; j < M; j++) {
      if (t.at(j) == u) {
        sum--;
      }
    }
    
    if (sum > max) {
      max = sum;
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// kort0n氏.
// https://atcoder.jp/contests/abc149/submissions/9221939
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1000000007;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
vector<LL> paths[205000], children[205000];
LL parent[205000], SIZE[205000];
LL N, ans;

void dfs(int now){
    SIZE[now] = 1;
    for(auto to : paths[now]) {
        if(to == parent[now]) continue;
        parent[to] = now;
        children[now].pb(to);
        dfs(to);
        SIZE[now] += SIZE[to];
    }
}

LL mPow(LL a, LL b){
    if(b == 0) return 1 % MOD;
    LL ret = mPow(a, b / 2);
    ret = ret * ret % MOD;
    if(b & 1) ret = ret * a % MOD;
    return ret;
}

LL inv(LL a){
    return mPow(a, MOD - 2);
}

void f(int now){
    for(auto to : children[now]) f(to);
    vector<LL> v;
    for(auto to : children[now]) v.pb(SIZE[to]);
    if(parent[now] != 0) v.pb(N - SIZE[now]);
    LL val = 0;
    for(auto a : v) val += mPow(2, a);
    val -= v.size() - 1;
    val = mPow(2, N - 1) - val;
    val %= MOD;
    val += MOD;
    val %= MOD;
    ans += val;
}

int main(){
    scanf("%lld", &N);
    repx(i, 1, N){
        LL a, b;
        scanf("%lld %lld", &a, &b);
        paths[a].pb(b);
        paths[b].pb(a);
    }
    dfs(1);
    f(1);
    ans %= MOD;
    printf("%lld\n", (ans * mPow(inv(2), N)) % MOD);
    return 0;
}

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

using namespace std;
int a[100][100];
int main()
{
	int i,j,n,m;
	string st[100];
	cin >> n >> m;
	for(i=0; i<n; i++)
		cin >> st[i];
	for(i=0; i<n; i++)
		for(j=0; j<m; j++)
		{
			if(st[i][j]!='#')
			{
				if(i>0 && st[i-1][j]=='#') a[i][j]++;
				if(i>0 && j>0 && st[i-1][j-1]=='#') a[i][j]++;
				if(i>0 && j<m-1 && st[i-1][j+1]=='#') a[i][j]++;
				if(j>0 && st[i][j-1]=='#') a[i][j]++;
				if(j<m-1 && st[i][j+1]=='#') a[i][j]++;
				if(i<n-1 && st[i+1][j]=='#') a[i][j]++;
				if(i<n-1 && j>0 && st[i+1][j-1]=='#') a[i][j]++;
				if(i<n-1 && j<m-1 && st[i+1][j+1]=='#') a[i][j]++;
				
			}
		}
	for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			if(st[i][j]=='#') cout<< "#";
			else cout << a[i][j];
		}
		cout << "\n";
	}
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

X, Y, A, B, C = map(int, input().split())
cand = []
p = list(map(int, (input().split())))
p.sort(reverse=True)
cand.extend(p[:X])
q = list(map(int, (input().split())))
q.sort(reverse=True)
cand.extend(q[:Y])
r = list(map(int, (input().split())))
cand.extend(r)
cand.sort(reverse=True)
ans = sum(cand[:X+Y])
print(ans)

Measured memory_bytes: 25520
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int x;cin>>x;
    if(x>=1800) cout<<1;
    else if(x>=1600) cout<<2;
    else if(x>=1400) cout<<3;
    else if(x>=1200) cout<<4;
    else if(x>=1000) cout<<5;
    else if(x>=800) cout<<6;
    else if(x>=600) cout<<7;
    else cout<<8;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
 
int main() {
 
  int i,j,k,v,n,A[100];
 
   
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=n;i++) {
  	v = A[i];
  	j = i-1;
  		for(k=0;k <=n-1;k++){
  			if(k<n-1) printf("%d ",A[k]);
  			else printf("%d",A[k]);
  		}
  	printf("\n");
  	while(j >=0 && A[j] > v) {
  		A[j+1] = A[j];
  		j--;
  	}
  	A[j+1] = v;
  }
  return 0;
}


Measured memory_bytes: 2100
<?php
list($k) = ints();
$mod = $cnt = 0;
while (true) {
    $mod = ($mod * 10 + 7) % $k;
    ++$cnt;
    if (isset($f[$mod])) exit('-1'); // ループするので終了
    else $f[$mod] = true;
    if ($mod === 0) break;
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 57736
import sys
read = sys.stdin.buffer.read

def main():
    import numpy as np
    import math
    *ns, = map(int, read().split())
    n, s = ns[0], ns[1:]
    s = np.array(s).reshape([len(s)//2,2])
    ds = np.array([])
    for i in range(n):
        for j in range(i+1, n):
            xyi, xyj = s[i], s[j]
            ds = np.append(ds, ((xyi[0]-xyj[0])**2+(xyi[1]-xyj[1])**2)**0.5)
    p = math.factorial(n)
    p2 = p*(n-1)//len(ds)
    print(sum(ds*p2)/p)

if __name__ == "__main__":
    main()


Measured memory_bytes: 12508
#include <cstring>
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
const int INF = 1e9+7;

LL ans;
int n, k;

int main(){
	scanf("%d%d", &n, &k);
	if (k==0){
		for (int b=1; b<=n; ++b)
			ans+=n/b*b+n%b;
		printf("%lld\n", ans);
		return 0;
	}
	for (int b=k+1; b<=n; ++b){
		ans+=b-k;
		for (int i=1; (i+1)*b<=n; ++i)
			ans+=b-k;
		if (n%b!=0 && n>b) ans+=max(0, n%b-k+1);
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;

  int x = 0;
  int cm = 0;
  for (auto &c : s) {
    if (c == 'S') ++x;
    else {
      --x;
      chmin(cm, x);
    }
  }

  int ans = 0;
  ans += -cm;
  ans += x - cm;
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3688
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    string s = readln.chomp;
    string t = readln.chomp;
    int ans;
    foreach(i; 0..3) ans += s[i] == t[i];
    writeln(ans);
}


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

typedef long long ll;

const ll INF = 100100100100100100;

int main() {
    ll N;
    cin >> N;
    ll A, B;
    ll ans = INF;
    for (ll i=1;i*i<=N;i++){
        if (N%i==0){
            A = i;
            B = N/i;
            ans = min(ans,(A - 1)+(B - 1)); 
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
use std::process::exit;

fn main() {
    input! {
        n: Chars
    };
    for &c in n.iter() {
        if c == '7' {
            println!("Yes");
            exit(0);
        }
    }
    println!("No");
}


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

H = list(map(int,input().split()))

for i in range(N-1,0,-1):
    if 2 <= H[i-1] - H[i]:
        print('No')
        exit()
    else:
        if (H[i-1] - 1) == H[i]:
            H[i-1] -= 1
print('Yes')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int m;
  cin >> n >> m;
  int i,j;
  long a[n];
  long b[m];
  long c[m];
  int chk = 0;
  vector<pair<long,long>> p(m);
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<m;i++) {
    cin >> b[i] >> c[i];
    p[i] = make_pair(c[i],b[i]);
  }
  sort(p.begin(),p.end(),greater<>());
  int tmp;
  sort(a,a+n);
  int tmp2 = 0;
    for(i=0;i<m;i++){
      chk = 1;
      tmp = p[i].second;
      for(j=tmp2;j<n;j++){
        if(a[j]<p[i].first && tmp>0){
          a[j] = p[i].first;
          tmp--;
          tmp2 = j+1;
          chk = 0;
        }else break;
      }
      if(chk==1)break;
      
      
    }
    long ans = 0;
    for(i=0;i<n;i++){
      ans += a[i];
    }
    cout << ans;



}


Measured memory_bytes: 4096
n=int(input())
s=input()
alpha2num=lambda c: ord(c) - ord("A")+1
num2alpha=lambda c: chr(c+64)

char=list(s)
for i in range(len(char)):
	alphabet=alpha2num(char[i])+n
	
	if alphabet>26:
		numalpha=num2alpha(alphabet-26)
	else:
		numalpha=num2alpha(alphabet)
	
	char[i]=numalpha

mapchar=map(str,char)
ret="".join(char)
print(ret)

Measured memory_bytes: 3064
#include <stdio.h>
    #include <iostream>
    using namespace std;
     
    int main(){
        int N;
        scanf("%d", &N);
        int t, x, y;
        int t_pre = 0, x_pre = 0, y_pre = 0;
        for(int i = 0; i < N;i++){
            scanf("%d %d %d", &t, &x, &y);
            if(!((t - t_pre >= abs(x - x_pre)+ abs(y -y_pre)) && ((t - t_pre - (x-x_pre)  - (y-y_pre)) % 2 == 0))){
                printf("No");
                return 0;
            }
            t_pre = t;
            x_pre = x;
            y_pre = y;
        }
        printf("Yes");
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <iostream>
//#include <cmath>
//#include <cstdio>
using namespace std;
char s;
long long q,p,n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>s;
        if(s=='I')   p++;
        if(s=='D')   p--;
        q=max(q,p);
    }
    cout<<q<<endl;
    return 0;
}

Measured memory_bytes: 256
//BINARY_BOY!!
//THINK TWICE CODE ONCE { TRUE }
// #####   ###  ##   #   ###   #####   #   #  #####	 ####   #   #
// #    #   #   # #  #  #   #  #    #   # #   #	#	#	 #   # #	
// #####    #   #  # #  #####  #####     #    #####	#	 #	  #	
// #    #   #   #   ##  #   #  #   #     #    #	#	#	 #    #
// #####   ###  #    #  #   #  #    #    #    #####	 ####	  #
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 10000 + 5;
vector < pair < int  , pair < int , int > > > v ;
int parent [ MAXN ];
int n , m, sum = 0, num [ MAXN ];
bool cmd(pair < int , pair<int , int> > p1 , pair < int , pair<int , int> > p2 )
{
	return p1.first < p2.first;
}
int getroot(int a )
{
	if(parent [ a ] == a)
		return a;
	return getroot (parent [ a ]);	
}
int main() {
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin >> n >> m;
	for(int i = 0 ; i < m ; i++)
	{
		int a , b, c;
		cin >> a >> b >> c;
		v.push_back(make_pair(c , make_pair(a , b)));
	}
	sort(v.begin() , v.end() , cmd);
	for(int i = 0 ; i < n ; i++)
	{
		parent [ i ] = i;
	}	
	for(int i = 0 , j = 0 ; i < v.size() && j < n - 1; i++)
	{
		int ga = getroot(v[ i ].second.first), gb = getroot(v[ i ].second.second);
		if(ga != gb )
		{
			sum += v [ i ].first;
			j++;
			if(num [ ga ] < num [ gb ])
			{
				parent [ ga ] = gb;
				num [ gb ]++;
			}
			else
			{
				parent [ gb ] = ga;
				num [ ga ]++;
			}	
		}
	}
	cout << sum << endl;	
}	

Measured memory_bytes: 4468
function main(input){
    var A = parseInt(input.split("\n")[0].split(" ")[0]);
    var B = parseInt(input.split("\n")[0].split(" ")[1]);
    
    if(A == 1) A = 14;
    if(B == 1) B = 14;
    
    if(A == B) {
        console.log("Draw");
    } else if(A > B) {
        console.log("Alice")
    } else {
        console.log("Bob")
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			long b = scanner.nextLong(), n = scanner.nextLong();
			if (Math.min(b, n) <= a) {
				System.out.println(LongStream.rangeClosed(1, Math.min(b, n)).map(i -> fn(a, b, i)).max().getAsLong());
			} else {
				System.out.println(LongStream.rangeClosed(Math.min(n, b) - a, Math.min(n, b)).map(i -> fn(a, b, i))
						.max().getAsLong());
			}
		}
	}

	/**
	 * floor(Ax/B)−A*floor(x/B) を計算する
	 * 
	 * @param a A
	 * @param b B
	 * @param x x
	 * @return floor(Ax/B)−A*floor(x/B) を計算する
	 */
	private static long fn(int a, long b, long x) {
		return a * x / b - a * (x / b);
	}
}


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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  bool hantei=true;
  int countC=0;
  
  if(S.at(0)!='A') hantei=false;
  if(S.at(1)=='C' || S.at(N-1)=='C') hantei=false;
  for(int i=1; i<N; i++){
    char s=S.at(i);
    int num=(int)s;
    if(s=='C') countC++;
    else if(num<97 || num>122) hantei=false;
  }
  if(countC!=1) hantei=false;
 
  if(hantei) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}


Measured memory_bytes: 256
/* 
 * alds1_3d.cpp ????????????
 */
#include <iostream>
#include <list>
#include <string>
#include <stack>
#include <utility>
#include <cstdio>
#include <cstring>

using namespace std;

int main(void) {

    string map;
    cin >> map;

    int *waters = new int[map.size() + 2];
    memset(waters, 0, sizeof(int)*map.size() + 2);

    int total = 0, water_num = 0;
    stack<int> geo;
    for (int i = 1; i < map.size() + 1; ++i) {
        switch (map[i - 1]) {
            case '\\':
                geo.push(i);
                break;
            case '/':
                if (! geo.empty()) {
                    int max = i - geo.top();
                    total += max;
                    ++water_num;
                    bool succ = false;
                    for (int j = geo.top(), area = max; j < i; ++j) {
                        if (waters[j]) {
                            if (!succ) {
                                succ = true;
                                --water_num;
                            }
                            max = waters[j] = max > waters[j] + area
                                            ? max
                                            : waters[j] + area;
                        }
                        else {
                            area = waters[j] = max;
                            succ =false;
                        }
                    }
                    geo.pop();
                }
                break;
        }
    }

    printf("%d\n", total);
    printf("%d", water_num);
    for (int i = 1; i < map.size() + 2; ++i) {
        if ( (!waters[i]) && waters[i - 1]) {
            printf(" %d", waters[i - 1]);
        }
    }
    printf("\n");

    delete[] waters;
    return 0;
}

Measured memory_bytes: 1380
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int A, B, C, X;
int ans = 0;
int bai = 1;

int main()
{
	
	IN >> A >> B >> C >> X;

	LEP(a, A + 1)
	{
		LEP(b, B + 1)
		{
			LEP(c, C + 1)
			{
				if (a * 500 + b * 100 + c * 50 == X)
					ans++;
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int a[42] = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,1001};
	for (int b = 0; b < 42; b++){
		if (x < a[b]){
			cout << a[b-1] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input().replace("s","R").replace("p","S").replace("r","P")

ans=0

def win(type):
  if type=="R":
    return R
  elif type=="S":
    return S
  elif type=="P":
    return P
  return 0

yaku=set(["R","S","P"])
def rest(a,b):
  re=yaku-set([a,b])
  for c in re:
    return c

def restRand(a):
  re=yaku-set([a])
  for c in re:
    return c

me=[""]*len(T)
for i in range(len(T)):
  if i-K<0:
    ans+=win(T[i])
    me[i]=T[i]
  else:
    if me[i-K]==T[i]:
      # 勝つ手は出せない
      # 残り二つのうち、K回あとに勝負がある場合、K回あとに勝てる手以外を出す
      if i+K<len(T):
        me[i]=rest(T[i],T[i+K])
      else:
        me[i]=restRand(T[i])
    else:
      # 勝つ手を出せる
      ans+=win(T[i])
      me[i]=T[i]

print(ans)


Measured memory_bytes: 4084
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;

int selectionSort(int a[], int n)
{
    int cnt = 0;
    rep(i, n-1) {
        int *minpos = min_element(a+i, a+n);
        if (a+i != minpos) {
            ++cnt;
            swap(a[i], *minpos);
        }
    }
    return cnt;
}

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

   int n;
   int a[102];
   cin >> n;
   rep(i, n) cin>>a[i];
   int cnt = selectionSort(a, n);

   rep(i, n) cout << a[i] << (i+1 < n ? ' ' :'\n');
   outl(cnt);
}




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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  rep(i, n - 1) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 4036
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n,a;
	cin >> n >> a;
	int x=n%500;
	if(a>=x){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
int arr[(int)10e5+2]={0};
int p[(int)10e5];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string n;
    cin>>n;
    if ((n[0]=='9')||(n[1]=='9'))cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
// D - Replacing.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <unordered_map>

int main()
{
    std::unordered_map<int, int> nums;
    int n_c;
    std::cin >> n_c;

    unsigned long long sum = 0;
    for (int i = 0; i < n_c; i++)
    {
        int q;
        std::cin >> q;
        nums[q]++;
        sum += q;
    }

    int o_c;
    std::cin >> o_c;
    for (int o = 0; o < o_c; o++)
    {
        int a, b;
        std::cin >> a >> b;

        sum += (unsigned long long)nums[a] * b - (unsigned long long)nums[a] * a;
        nums[b] += nums[a];
        nums[a] = 0;

        std::cout << sum << "\n";
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 7104
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e6 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n , m , s , t ;
vector<pll> G[N] ;
map<pll , ll> we ;
ll ds[N] , dt[N]  , dps[N] , dpt[N];
inline ll sum(ll a , ll b) {
	return (a + b ) % Mod ;
}
inline ll mul(ll a,  ll b) {
	return (a * b) % Mod ;
}
inline ll C2(ll x) {
	return mul(x , x ) ;
}
inline ll sub(ll a, ll b) {
	return (a - b + Mod) % Mod ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n >> m >> s >> t;
    vector<pll> E ;
    for (int i = 0 ; i <m ; i  ++) {
    	ll v , u , w ;
    	cin >> v >> u >> w ;
    	G[v].pb({u , w}) ;
    	G[u].pb({v , w}) ;
    	E.pb({v , u}) ;
    	we[{v , u}] = we[{u , v}] = w ;
	}
	memset(ds , 63 , sizeof(ds)) ;
	memset(dt , 63 , sizeof(dt)) ;
	ds[s] = 0 ;
	dt[t] = 0 ;
	dps[s] = 1 ;
	dpt[t] = 1 ;
	set<pll> S ;
	for (int i = 1 ; i <= n ; i ++) S.insert({ds[i] , i}) ;
	while (S.size()) {
		auto x = *S.begin() ;
		S.erase(x) ;
		ll d = x.F ,v = x.S ;
		for (auto u : G[v]) {
			if (ds[u.F] > d + u.S) {
				S.erase({ds[u.F] , u.F}) ;
				ds[u.F] = d + u.S;
				dps[u.F] = dps[v] ;
				S.insert({ds[u.F] , u.F}) ;
				continue ;
			}
			if (ds[u.F] == d + u.S) {
				dps[u.F] += dps[v] ;
				dps[u.F] %= Mod ;
			} 
		}
	}
	for (int i = 1 ; i <= n ; i ++) S.insert({dt[i] , i}) ;
	while (S.size()) {
		auto x = *S.begin() ;
		S.erase(x) ;
		ll d = x.F , v = x.S ;
		for (auto u : G[v]) {
			if (dt[u.F] > d + u.S) {
				S.erase({dt[u.F] , u.F}) ;
				dt[u.F] = d + u.S ;
				dpt[u.F] = dpt[v] ;
				S.insert({dt[u.F] , u.F}) ;
				continue ;
			}
			if (dt[u.F] == d + u.S) {
				dpt[u.F] += dpt[v] ;
				dpt[u.F] %= Mod ;
			} 
		}
	}
	ll ans = C2(dpt[s]) ;
	//cout << ans << endl;
	ll SP = dt[s] ;
	for (int i= 1 ; i <= n ; i ++) {
		if (ds[i]  + dt[i] == SP && ds[i] * 2 == SP && dt[i] * 2 == SP) ans = sub(ans , C2(mul(dpt[i] , dps[i]))) ;
	}
	for (auto x : E) {
		if (ds[x.F] * 2  < SP && dt[x.S] * 2 < SP && ds[x.F] + we[{x.F , x.S}] + dt[x.S] == SP) {
			ans = sub(ans , C2(mul(dps[x.F] , dpt[x.S]))) ;
			//continue ;
		}
		if (ds[x.S] * 2  < SP && dt[x.F] * 2 < SP && ds[x.S] + we[{x.F , x.S}] + dt[x.F] == SP) {
			ans = sub(ans , C2(mul(dpt[x.F] , dps[x.S]))) ; 
		}
	}
	cout << ans << endl;
    return (0) ;
}

Measured memory_bytes: 129132
# Segment Tree
class Segment:
    def __init__(self, N, init_val):
        self.N0 = 2**(N-1).bit_length()
        # 0-indexedで管理
        self.dat = [identity_element]*(2*self.N0)
        # 値を代入
        for i in range(N):
            self.dat[i+self.N0-1]=init_val[i]    
        # 構築
        for i in range(self.N0-2,-1,-1) :
            self.dat[i]=segfunc(self.dat[2*i+1],self.dat[2*i+2]) 

    # k番目の要素の値をxに変更
    def update(self, k, x):
        k += self.N0-1
        self.dat[k] = x
        while k >= 0:
            k = (k-1)//2
            self.dat[k] = segfunc(self.dat[2*k+1], self.dat[2*k+2])

    # 区間[l, r)のsegfuncを求める
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = identity_element
        # 区間を列挙しながらsegfuncを求める
        while L < R:
            if R & 1:
                R -= 1
                s = segfunc(s, self.dat[R-1])
            if L & 1:
                s = segfunc(s, self.dat[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

# segfunc : min, +, *, xor, gcd
# identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0)

from fractions import gcd
def segfunc(x,y):
    return gcd(x,y) # 変える
identity_element = 0 # 変える

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

h = Segment(n, a)
ans = 0
for i in range(n):
    ans=max(ans,gcd(h.query(0,i), h.query(i+1,n)))
print(ans)

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

void solve(string s){
	int answer=0,current=0;

	for(int i=0;(unsigned)i<s.size();i++){
		if(s[i] == 'R')
			current++;
		else{
			answer = max(current, answer);
			current = 0;
		}

	}
	answer = max(current, answer);
	cout<<answer;
}


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

	int t=1;

	string s;
	while(t--){
		cin>>s;
		solve(s);
	}

	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=370;
const int M=30;

int D,ans,T,d,q;
int s[N][M],lst[M],c[M],t[N];

int calc(){
	ans=0;
	for (int i=1;i<=26;i++) lst[i]=0;
	for (int i=1;i<=D;i++){
		ans+=s[i][t[i]];
		lst[t[i]]=i;
		for (int j=1;j<=26;j++) ans-=c[j]*(i-lst[j]);
	}
	return ans;
}

int main(){
	scanf("%d",&D);
	for (int i=1;i<=26;i++) scanf("%d",&c[i]);
	for (int i=1;i<=D;i++)
		for (int j=1;j<=26;j++) scanf("%d",&s[i][j]);
	for (int i=1;i<=D;i++) scanf("%d",&t[i]);
	scanf("%d",&T);
	while (T--){
		scanf("%d%d",&d,&q);
		t[d]=q;
		printf("%d\n",calc());
	}
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

void add_mod(ll& val, ll add_val) {
	val = (val + add_val) % 100000007;
}

int main (int argc, char* argv[]) {
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (i & 1) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				continue;
			}
		} else {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				continue;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 using namespace std;
 
 int main(){
    long long i;
    long long N;
    long long A[120000];
    long long min;
    long long ans = 0;
    long long cnt = 0;

    cin >> N;
    for (i=0; i<N; i++){
        cin >> A[i];
    }

    min = abs(A[0]);

    for (i=0; i<N; i++){
        ans = ans + abs(A[i]);
        if (A[i] < 0)
            cnt++;
        if (min > abs(A[i]))
            min = abs(A[i]); 
    }

    if (cnt%2 != 0)
        ans = ans - min*2;

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



Measured memory_bytes: 1024
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if x + y + z == S and 0 <= z <= K:
            #print('{} {} {}'.format(x,y,z))
            count += 1

print(count)


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

int main() {
	int x, y;

	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;

		if (x > y)cout << y << " " << x << endl;
		else cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
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;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int n;
    cin>>n;
    vector<int> d(n);
    REP(i,n) cin>>d[i];

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

    int sa = d[ n/2 ] - d[ n/2 - 1];
    cout<<sa<<endl;

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

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

const int MAXN = 55;

int N, K;
int a[MAXN];
int lo[MAXN], hi[MAXN];
int freq[MAXN];

void load() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
}

void bye() {
	puts("-1");
	exit(0);
}

void output(const unordered_set <int> &omit) {
	for (int i = 0; i < N; i++)
		if (!omit.count(i))
			printf("%d ", i + 1);
}

void solve() {
	int rest = K;
	for (int i = 0; i < N; i++) {
		lo[i] = max(K + 1 - a[i], 0);
		hi[i] = min(a[i], (K + 1) / 2);
		if (lo[i] > hi[i])
			bye();
		rest -= lo[i];
	}
	
	if (rest < 0)
		bye();
	
	for (int i = 0; i < N; i++) {
		int tmp = min(hi[i] - lo[i], rest);
		freq[i] = lo[i] + tmp;
		rest -= tmp;
	}
	
	if (rest > 0)
		bye();
		
	vector <int> seq;
	for (int i = 0; i < K; i++) {
		int most = -1;
		for (int j = 0; j < N; j++)
			if ((seq.empty() || j != seq.back()) && (most == -1 || freq[j] > freq[most]))
				most = j;
		assert(most != -1);
		seq.push_back(most);
		freq[most]--;
	}
	
	printf("%d\n", N + K * (N - 1));
	output({seq[0]});
	printf("%d ", seq[0] + 1);
	for (int i = 1; i < K; i++) {
		output({seq[i - 1], seq[i]});
		printf("%d ", seq[i] + 1);
	}
	output({seq[K - 1]});
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
pair<string,int> a[100];
int main(){
	int t=0,g;
	while(cin>>a[t].first>>a[t].second)t++;
	sort(a,a+t);
	string f,b=a[0].first;
	cout<<b<<endl<<a[0].second;
	for(int i=1;i<t;i++){
		bool n=0;
		f=a[i].first,g=a[i].second;
		if(i)if(f==b)n=1;
		if(n)cout<<" "<<g;
		else cout<<endl<<f<<endl<<g;
		b=f;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1228
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

/*
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,i,j,k;
    cin>>n>>m>>k;
    ll a[n],b[m];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<m;i++)
        cin>>b[i];
    ll f=0;
    i=0,j=0;
    ll z=0;
    while(1)
    {
        if(i==n && j==m)
            break;
        if(i<n && j<m)
        {
            if(a[i]<=b[j])
            {
                if(f+a[i]>k)
                    break;
                f=f+a[i];
                i++;
                z++;
            }
            else
            {
                if(f+b[j]>k)
                    break;
                f=f+b[j];
                j++;
                z++;
            }
        }
        else if(i<n && j>=m)
        {
            if(f+a[i]>k)
                break;
            else
            {
                f=f+a[i];
                i++;
                z++;
            }
        }
        else
        {
            if(f+b[j]>k)
                break;
            else
            {
                f=f+b[j];
                j++;
                z++;
            }
        }
    }
    cout<<z;
    return 0;

}
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j;
    cin>>n;
    ll f=0;
    for(i=1;i<=sqrt(n);i++)
    {

        f = f + i*(i+ n/i)*(n/i + 1 -i);
    }
    ll k =sqrt(n);
    f = f - k*(k+1)*(2*k+1)/6;
    cout<<f;
    return 0;

}


Measured memory_bytes: 3676
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// 最後に一番長い組みを残せば良い
int main()
{
  ll N, L; cin >> N >> L;
  ll a[N]; FOR(i,0,N) cin >> a[i];
  ll mx = 0, nocut = 0;
  FOR(i,0,N-1) {
    if(a[i]+a[i+1]>mx) {
      nocut = i + 1;
      mx = a[i] + a[i+1];
    }
  }
  if(mx >= L) {
    puts("Possible");
    FOR(i,1,N) {
      if(i != nocut) cout << i << endl;
      else break;
    }
    for(int i = N - 1; i >= 1; i--) {
      if(i != nocut) cout << i << endl;
      else break;
    }
    cout << nocut << endl;
  } else {
    puts("Impossible");
  }
  return 0;
}

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

using namespace std;

using ull = unsigned long long;
constexpr int MAX = 4000;
constexpr ull B = 100000007ULL;

vector<vector<int>> make(const string& str)
{
    int N = str.size();
    vector<vector<int>> cnt(N + 1, vector<int>(26));
    for (int i = 0; i < N; i++) {
        cnt[i + 1][str[i] - 'a']++;
        for (int j = 0; j < 26; j++) {
            cnt[i + 1][j] += cnt[i][j];
        }  
    }
    return cnt;
}

ull get_hash(int len, int s,
             const vector<vector<int>>& cnt)
{
    auto l = cnt[s];
    auto r = cnt[s + len];
    
    ull res = 1;
    for (int i = 0; i < 26; i++) {
        res = res * B + (r[i] - l[i]);
    }
    return res;
}

int main()
{
    string S, T;
    cin >> S >> T;
    
    if (S.size() < T.size()) swap(S, T);

    int s = S.size(), t = T.size();
    
    auto sc = make(S);
    auto tc = make(T);
    
    vector<ull> vec[MAX + 1];
    for (int i = s; i >= 1; i--) {
        for (int j = 0; j <= s - i; j++) {
            vec[i].emplace_back(get_hash(i, j, sc));
        }
        sort(vec[i].begin(), vec[i].end());
        vec[i].erase(unique(vec[i].begin(), vec[i].end()), vec[i].end());
    }    
    
    int res = 0;
    for (int i = t; i >= 1; i--) {
        for (int j = 0; j <= t - i; j++) {
            if (binary_search(vec[i].begin(), vec[i].end(), get_hash(i, j, tc))) {
                res = max(res, i);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78116
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int Q = scan.nextInt();
		long[]a = new long[N];
		long[]x = new long[Q];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextLong();
		}
		for(int i = 0; i < Q; i++) {
			x[i] = scan.nextLong();
		}
		scan.close();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < Q; i++) {
			long cnt = 0;
			long sum = 0;
			int right = 0;
			for(int left = 0; left < N; left++) {
				while(right < N && sum + a[right] <= x[i]) {
					sum += a[right];
					right++;
				}
				cnt += (right - left);
				if(left == right) {
					right++;
				}else {
					sum -= a[left];
				}
			}
			sb.append(cnt).append("\n");
		}
		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 69368
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H;
int main(){
    cin>>H;
    for(ll i=1;;i*=2){
        if(H<i){
            cout<<i-1<<endl;
            return 0;
        }
    }
    return 0;
}

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

typedef vector<int> vi; 
typedef pair<int,int> p;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pmod 1000000007
#define INF 1000000000000000000
#define pi atan(1)*4
#define modi 1000000

ll n;

void solve(){
	
	cin >> n;
	
	ll a,res = 0;
	
	for(ll i = 0; i < n; i++){
		cin >> a;
		
		if(i%2 == 0 && a%2 == 1) res++;
		
	}
	
	cout << res << endl;
}

int main(){
	
	ifstream fin ("text.in");
    ofstream fout ("text.out");   
	
	ll t = 1;
		
	while(t--) solve();
	
	return 0;
}

Measured memory_bytes: 3636