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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n,m, Q, a[101010], b[101010], x[101010];
void solve(){
	cin >> n >> m >> Q;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < Q; i++){
		cin >> x[i];
	}
	
	for(int i = 0; i < Q; i++){
		i64* pal = (upper_bound(a+1,a+n,x[i])-1);
		i64* par = (lower_bound(a,a+n,x[i]));
		i64* pbl = (upper_bound(b+1,b+m,x[i])-1);
		i64* pbr = (lower_bound(b,b+m,x[i]));
		i64 al = abs(x[i] - *pal);
		i64 ar = abs(*par - x[i]);
		i64 bl = abs(x[i] - *pbl);
		i64 br = abs(*pbr - x[i]);
		al += min(abs(*(upper_bound(b+1,b+m,*pal)-1)-*pal), abs(*pal-*lower_bound(b,b+m,*pal)));
		ar += min(abs(*(upper_bound(b+1,b+m,*par)-1)-*par), abs(*par-*lower_bound(b,b+m,*par)));
		bl += min(abs(*(upper_bound(a+1,a+n,*pbl)-1)-*pbl), abs(*pbl-*lower_bound(a,a+n,*pbl)));
		br += min(abs(*(upper_bound(a+1,a+n,*pbr)-1)-*pbr), abs(*pbr-*lower_bound(a,a+n,*pbr)));
		cout << min({al,ar,bl,br}) << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

static const double eps = 10e-9;

int main(){

	int n;
	while(~scanf("%d",&n)){
		double sum=0.0;
		for(int i=0;i<n;i++){
			double val;
			scanf("%lf",&val);
			sum += val/n;
		}

		printf("%.0lf\n",sum);
	}
}

Measured memory_bytes: 0
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    Edge = [[] for _ in range(N)]
    Par = [0 for _ in range(N)]
    Son = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        Edge[a-1].append(b-1)
        Edge[b-1].append(a-1)
    Dist = [0] * N
    DistType = [0, 0]
    q = deque()
    q.append((0, 0, 0)) #(now, pre, dist)
    modCount = [N // 3, N // 3, N // 3]
    if N % 3 == 1: modCount[1] += 1
    elif N % 3 == 2:
        modCount[1] += 1
        modCount[2] += 1
    modIndex = [0, 0, 0]
    search = deque()
    while q:
        nowNode, preNode, dist = q.popleft()
        Dist[nowNode] = dist
        Par[nowNode] = preNode
        Son[preNode].append(nowNode)
        search.append(nowNode)
        DistType[dist % 2] += 1
        for nextNode in Edge[nowNode]:
            if nextNode != preNode: q.append((nextNode, nowNode, dist + 1))
    Ans = [-1] * N
    if DistType[0] <= modCount[0]:
        for i, d in enumerate(Dist):
            if d % 2 == 0:
                Ans[i] = 3 * modIndex[0] + 3
                modIndex[0] += 1
            else:
                if modIndex[1] < modCount[1]:
                    Ans[i] = 3 * modIndex[1] + 1
                    modIndex[1] += 1
                elif modIndex[2] < modCount[2]:
                    Ans[i] = 3 * modIndex[2] + 2
                    modIndex[2] += 1
                else:
                    Ans[i] = 3 * modIndex[0] + 3
                    modIndex[0] += 1
    elif DistType[1] <= modCount[0]:
        for i, d in enumerate(Dist):
            if d % 2 == 1:
                Ans[i] = 3 * modIndex[0] + 3
                modIndex[0] += 1
            else:
                if modIndex[1] < modCount[1]:
                    Ans[i] = 3 * modIndex[1] + 1
                    modIndex[1] += 1
                elif modIndex[2] < modCount[2]:
                    Ans[i] = 3 * modIndex[2] + 2
                    modIndex[2] += 1
                else:
                    Ans[i] = 3 * modIndex[0] + 3
                    modIndex[0] += 1
    else:
        for i, d in enumerate(Dist):
            if d % 2 == 0:
                if modIndex[1] < modCount[1]:
                    Ans[i] = 3 * modIndex[1] + 1
                    modIndex[1] += 1
                else:
                    Ans[i] = 3 * modIndex[0] + 3
                    modIndex[0] += 1
            else:
                if modIndex[2] < modCount[2]:
                    Ans[i] = 3 * modIndex[2] + 2
                    modIndex[2] += 1
                else:
                    Ans[i] = 3 * modIndex[0] + 3
                    modIndex[0] += 1
    print(" ".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define int long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e5 + 5;

int n, C, a[N], dp[N], cht[N], sz;

long double inter (int i, int j)
{
    return (long double)( a[j] * a[j] + dp[j] - a[i] * a[i] - dp[i] ) / (a[i] - a[j]);
}

void add (int ind)
{
    while ( sz > 1 && inter( ind, cht[sz - 2] ) >= inter( cht[sz - 1], cht[sz - 2] ) )
        sz--;
    cht[sz++] = ind;
}
int get (int x)
{
    int l = -1, r = sz - 1;
    while (r - l > 1)
    {
        int md = (l + r) >> 1;
        if ( inter(cht[md], cht[md + 1]) > x )
            l = md;
        else
            r = md;
    }
    return a[cht[r] ] * x + a[ cht[r] ] * a[ cht[r] ] + dp[ cht[r] ];
}
main()
{
    cin >> n >> C;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);

    dp[1] = 0;

    add(1);

    for (int i = 2; i <= n; i++)
    {
        dp[i] = get( -2 * a[i] ) + a[i] * a[i] + C;
        add(i);
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 6016
s = input()
k = int(input())

if len(s) == 1:
    print(k//2)
    exit()

rep = [1]
prev = s[0]
for i in range(1, len(s)):
    if s[i] == prev:
        rep[-1] += 1
    else:
        rep.append(1)
        prev = s[i]

if len(rep) == 1:
    print(rep[0]*k//2)
    exit()

cnt = 0
for r in rep:
    cnt += r//2

if s[0] == s[-1]:
    ans = cnt*k + ((rep[0]+rep[-1])//2 - rep[0]//2 - rep[-1]//2)*(k-1)
    print(ans)
else:
    print(cnt*k)


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int N; cin >>N;
    int k = 1;
    while (k * k <= N) k++;
    cout << (k-1) * (k - 1) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))

a_2.insert(0, 0)
cnt = [0] * n
a_1_cnt = sum(a_1)
a_2_cnt = sum(a_2)
a_1_total = a_1_cnt

for i in range(n):
    a_1_cnt -= a_1[i]
    a_2_cnt -= a_2[i]
    cnt[i] = a_1_total - a_1_cnt + a_2_cnt

ans = max(cnt)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll d;
    cin>>d;
    vector<ll> c(26);
    rep(i,26){
        cin>>c[i];
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    vector<ll> last(d,0);
    rep(i,d){
        ll cnt=-inf;
        ll ans;
        rep(t,26){
            ll now=0;
            now+=s[i][t];
            ll tmp=last[t];
            last[t]=i+1;
            rep(j,26){
                now-=c[j]*(i+1-last[j]);
            }
            last[t]=tmp;
            if(chmax(cnt,now)){
                ans=t+1;
            }
        }
        cout<<ans<<endl;
    }   
}

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

int A, B;
char field[100][101];

int main(){
    cin >> A >> B;
    
    for(int i=0; i<100; i++)
        for(int j=0; j<100; j++)
            field[i][j] = '.';
    
    for(int i=0; i<100; i++)
        field[i][0] = '#';
    for(int i=0; i<100; i+=2)
        for(int j=0; j<100-1; j++)
            field[i][j] = '#';
    
    int h, w;
    
    h = 1;
    w = 2;
    while(A > 1){
        field[h][w] = '#';
        w += 2;
        if(w == 100){
            w = 2;
            h += 2;
        }
        A--;
    }
    
    h = 98;
    w = 97;
    while(B > 1){
        field[h][w] = '.';
        w -= 2;
        if(w == -1){
            w = 97;
            h -= 2;
        }
        B--;
    }
    
    cout << 100 << " " << 100 << endl;
    for(int i=0; i<100; i++)
        cout << field[i] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long int D,c[26],i,j;
	scanf("%ld",&D);
	for(i=0;i<26;i++){
		scanf("%ld",&c[i]);
	}
	long int s[D][26];
	for(i=0;i<D;i++){
		for(j=0;j<26;j++){
			scanf("%ld",&s[i][j]);
		}
	}
	
	long int v[D],w[26],t[D],score=0,day[26],k,temp[26],l;
	for(i=0;i<26;i++){
	day[i]=-1;
	}
	
	for(i=0;i<D;i++){
		v[i]=0;
		for(j=0;j<26;j++){
			for(l=0;l<26;l++){
				temp[l]=day[l];
			}
			w[j]=0;
			w[j] += s[i][j];
			temp[j] = i;
			for(k=0;k<26;k++){
				w[j] -= c[k]*(i - temp[k]);
			}
			if(v[i]<w[j]){
			v[i]=w[j];
			t[i]=j;
			}
		}
		day[t[i]]=i;
		score += v[i];
		printf("%ld\n",++t[i]);
	}
	return 0;
}

Measured memory_bytes: 1808
#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 d, t, s;
    cin >> d >> t >> s;

    int b = t * s;

    if(b >= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}
 
 //vector<int> a(3);
 //a.at(0);
 //a.size();
 //vector<vector<int>> a(3, vector<int>(3));
 //uint64_t sum = 0;
 //max(a, b);
 //min(a, b);
 //swap(a, b);
 //sort(vec.begin(), vec.end());  昇順
 //reverse(vec.begin(), vec.end());  降順

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;

  cin >> n;
  for(int i = 0; i < n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3856
import sys
input = sys.stdin.readline
def print_ans(A, P):
    """Test Case
    >>> print_ans(1, 3)
    3
    >>> print_ans(0, 1)
    0
    >>> print_ans(32, 21)
    58
    """
    print((A * 3 + P) // 2)

if __name__ == '__main__':
    A, P= map(int, input().rstrip().split())
    print_ans(A, P)




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

int main(void)
{
	int count = 0;
	char W[11], T[1001];
	char *E = "END_OF_TEXT";
	scanf("%s\n", W);
	for (; scanf("%s\n", T) > 0;) {
		if (strcasecmp(T, W) == 0) {
			count++;
		}
		if (strcmp(T, E) == 0) {
			break;
		}
	}
	printf("%d\n", count);
}


Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	double a,b,h;
	cin >> a >> b >> h;
	
	cout << (a+b)*h*0.5 << endl;	
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3030;
int a[maxn];
vector<int> to[maxn];
int win(int u, int p){
	if(to[u].size() == 1 && (p != -1)) return 0;
	int can = 0;
	for(int nxt : to[u]){
		if(nxt == p) continue;
		int val = win(nxt, u);
		if(val == 0 && a[nxt] < a[u]) can = 1;
	}
	return can;
}
int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		to[u].push_back(v);
		to[v].push_back(u);
	}
	for(int i = 1; i <= n; i++){
		if(win(i, -1)){
			cout << i << " ";
		}
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  for (char &c : s) if (c == '+') ans++; else ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 710

/*
    二部グラフでないなら{-1,-1}を返す.
    二部グラフなら{頂点Xを含む方の頂点の個数,反対側の頂点の個数}を返す.
    O(n).
*/

vector<int> G[MAX_N];
int flag_bin[MAX_N];
pair<int,int> BipartiteGraph(int X){
    // rep(i,MAX_N)flag_bin[i] = -1;
    queue<int> que;
    que.push(X);
    flag_bin[X] = 0;
    int flag = 0;
    while(que.size() > 0){
        int x = que.front();
        que.pop();
        rep(i,G[x].size()){
            if(flag_bin[G[x][i]] == -1){
                flag_bin[G[x][i]] = (flag_bin[x] + 1) % 2;
                que.push(G[x][i]);
            }else{
                if(flag_bin[G[x][i]] == flag_bin[x]){
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 1)break;
    }
    if(flag == 1) return make_pair(-1,-1);
    pair<int,int> res;
    res.first = 0; res.second = 0;
    rep(i,MAX_N){
        if(flag_bin[i] == 0){
            res.first++;
            flag_bin[i] = 1001001001;
        }
        if(flag_bin[i] == 1){
            res.second++;
            flag_bin[i] = 1001001001;
        }
    }
    return res;
}

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

    int GG[n][n];
    rep(i,n)rep(j,n)GG[i][j] = 0;

    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        GG[a][b] = 1;
        GG[b][a] = 1;
    }

    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            if(GG[i][j] == 0){
                G[i].push_back(j);
            }
        }
    }

    rep(i,MAX_N) flag_bin[i] = -1;

    vector<P> v;

    rep(i,n){
        if(flag_bin[i] == -1){
            pair<int,int> count = BipartiteGraph(i);
            if(count.first == -1){
                cout << -1 << endl;
                return 0;
            }
            v.push_back(count);
        }    
    }


    int w = v.size();
    int dp[w][MAX_N];
    rep(i,w)rep(j,MAX_N)dp[i][j] = 0;


    rep(i,w){
        if(i == 0){
            dp[i][v[i].first] = 1;
            dp[i][v[i].second] = 1;
        }else{
            rep(j,MAX_N){
                if(dp[i-1][j] == 1){
                    dp[i][j+v[i].first] = 1;
                    dp[i][j+v[i].second] = 1;
                }
            }
        }
    }
    
    int ans = 1001001001;

    rep(i,MAX_N){
        if(dp[w-1][i] == 1){
            ans = min(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
        }
    }

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


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    for (int i = 0; i < s.length(); ++i) {
        for (int j = 1; j <= k; ++j) {
            st.insert(s.substr(i, j));
        }
    }
    vector<string> ans(st.begin(), st.end());
    sort(ans.begin(), ans.end());
    cout << ans[k - 1] << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 1792
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  println(solve(readLine.trim))
  def solve(string: String): Int = {
    implicit val memo = Array.tabulate(string.length){_ ⇒ Array.tabulate(string.length){_ ⇒ None:Option[Int]}}
    def searchWithPos(left: Int, right: Int): Int = {
      if (string.indices.contains(left) && string.indices.contains(right)){
        memo(left)(right) match{
          case Some(r) ⇒ r
          case None ⇒
            (if (List(string(left), string(right)).forall(c ⇒ c != 'i' && c != 'w') && string(left) == string(right).flip) {
              //println(s"left = ${string(left)}, right = ${string(right)}")
              searchWithPos(left - 1, right + 1) + 2
            }else {
              math.max(searchWithPos(left - 1, right), searchWithPos(left, right + 1))
            }).also{r ⇒ memo(left)(right) = Some(r)}
        }
      }else 0
    }
    def calMax(str: List[Char], position: Int = 0): Int = {
      str match {
        case 'i'::'w'::'i'::t ⇒ math.max(calMax('i'::t, position + 2), searchWithPos(position, position))
        case Nil ⇒ 0
        case h::t ⇒ calMax(t, position + 1)
      }
    }
    calMax(string.toList) + 3
  }
  implicit class CharFlip(val char: Char){
    def flip: Char = char match {
      case 'i' ⇒ 'i'
      case 'w' ⇒ 'w'
      case '(' ⇒ ')'
      case ')' ⇒ '('
      case '{' ⇒ '}'
      case '}' ⇒ '{'
      case '[' ⇒ ']'
      case ']' ⇒ '['
      case _ ⇒ ???
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44148
//#pragma GCC optimize ("O3,unrolled-loops")
#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 1e5+5, INF = 1e18;

signed main(){
	fastio
	int n,cp;
	cin >> n >> cp;
	int w[n], v[n];
	for(int i = 0;i < n;i++) cin >> w[i] >> v[i];
	int dp[n][N];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < N;j++){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0, dp[0][v[0]] = w[0];
	for(int i = 1;i < n;i++){
		for(int j = 0;j < N;j++){
			dp[i][j] = min(dp[i-1][j], dp[i][j]);
			if(j >= v[i]){
				dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for(int j = 0;j < N;j++){
		if(dp[n-1][j] <= cp) ans = j; 
	}
	cout << ans << "\n";
}

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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()


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

    int r; cin >> r;
    if(r < 1200) {
        cout << "ABC" << '\n';
    } else if(r < 2800) {
        cout << "ARC" << '\n';
    } else {
        cout << "AGC" << '\n';
    }
    return 0;
}

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

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int ans;
    double diff_min = 1e5;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        double ave = t - h * 0.006;
        double diff = abs(a - ave);
        if (diff_min > diff) {
            diff_min = diff;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
left,right = [],[]
n.times.map{
  l,r = gets.split.map(&:to_i)
  left << l
  right << r
}
left.sort!.reverse!
right.sort!

def greedy(left,right)
  sum,max = 0,0
  left.size.times{|i|
    sum += left[i]*2
    max = sum if max < sum
    sum -= right[i]*2
    max = sum if max < sum
  }
  max
end

lans = greedy(left,right)
rans = greedy(right.map{|t|-t},left.map{|t|-t})

p [lans,rans].max


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    rep(i,n){
        if(s[i]=='R')count++;
    }
    if(n/2<count)yn;
    return 0;
}
 
 


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

int main() {
	bool card[4][13] = { false };
	int n, temp, s;
	char d, design[] = { 'S', 'H', 'C', 'D' };

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d >> temp;
		for (int j = 0; j < 4; j++) {
			if (d == design[j]) {
				s = j;
				break;
			}
		}
		card[s][temp - 1] = true;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (card[i][j] == false) {
				cout << design[i] << ' ' << j + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

int cum[100010],E[100010];
int N, A[100010];
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	COMinit();
	cum[0] = 0;
	REP(i, N) {
		cum[i + 1] = add(cum[i], inv[i+1]);
	}
	REP(i, N) {
		E[i] = cum[N - i] + cum[i + 1]; E[i] %= MOD;
		E[i] = sub(E[i], cum[1]);
	}
	ll ans = 0;
	REP(i, N) {
		ans = add(ans, mult(E[i], A[i]));
	}
	ans = mult(ans, fac[N]);
	print(ans%MOD);
}


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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> A(N,0);
    for(int i=1; i<N; i++){
        for(int j=i+1; j<N+1; j++){
            int dist = min(j-i, abs(i-X)+1+abs(Y-j));
            // cout << "(" << i << "," << j << "):" << dist << endl;
            dist--; // 1-indexed -> 0-indexed
            A.at(dist)++;            
        }
    }
    rep(i,N-1){
        cout << A.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.28 20:13:56
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

// ===================### char →　int ###=================== //
int ctoi(char c) {
    int ret = c - '0';
    if (0 <= ret && ret < 10) {
        return ret;
    } else {
        return -1;
    }
}

int main() {
    double t, a, h[1010];
    int n;
    scanf("%d", &n);
    int t1, a1;
    scanf("%d%d", &t1, &a1);
    t = t1;
    a = a1;

    rep(i, n) {
        int h1;
        scanf("%d", &h1);
        h[i] = h1;
    }

    int mi;
    double m = 1000000;
    rep(i, n) {
        double aa = 0.006d;
        double mt = abs((t - h[i] * aa) - a);
        if (m > mt) {
            m = mt;
            mi = i;
        }
    }

    printf("%d\n", mi + 1);

    /* --------------------------------- */
    return 0;
}

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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), AS(N + 1);
  vector<int> B(N), BS(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    AS[i + 1] = AS[i] + A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    BS[i + 1] = BS[i] + B[i];
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int a = AS[i] + BS[N] - BS[i - 1];
    chmax(ans, a);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

pll ope(pll &a, pll &b){
	vector<ll> arr(4);
	arr[0] = a.first;
	arr[1] = a.second;
	arr[2] = b.first;
	arr[3] = b.second;
	sort(arr.begin(), arr.end());
	return {arr[2], arr[3]};
}

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

	ll N;
	cin >> N;
	vector<ll> A(1<<N);
	REP(i, 1<<N) cin >> A[i];

	vector<pll> f(1<<N);
	REP(i, 1<<N){
		f[i] = {A[i], 0};
	}
	REP(i, N){
		REP(j, 1<<N){
			if(j>>i & 1){
				f[j] = ope(f[j], f[j^(1<<i)]);
			}
		}
	}

	ll ma = -1;
	REP(i, 1<<N){
		ma = max(ma, f[i].first+f[i].second);
		if(i>0) cout << ma << endl;
	}
    return 0;
}

Measured memory_bytes: 9216
def solve(n):
    k= -1
    for i in range(1000):
        if i * (i-1) == 2 * n:
            k =i
            print("Yes")
            break
        elif i*(i-1)  > 2*n:
            print("No")
            return
    ans = [[-1 for i in range(k-1)] for i in range(k)]
    c = 1
    print(k)
    for i in range(k):
        for j in range(k-i-1):
            ans[i][i+j] = c
            ans[i+j+1][i] = c
            c += 1

    for i in range(k):
        print(k-1 ,end = "")
        for j in ans[i]:
            print(" " + str(j),end = "")
        print()

solve(int(input()))
    
        




Measured memory_bytes: 9340
#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;

int main(){

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i,n) cin >> a[i];

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

    int mi=1e+9;

    for(int i=-100;i<=100;i++){
        int t=0;
        rep(j,n){
            t+=abs(i-a[j])*abs(i-a[j]);
        }
        mi=min(mi,t);
    }

    cout << mi << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ll n;
	cin >> n;
	vector <string> arr (n+1 , "");
	for (ll i = 0; i < n; i++) {
		cin >> arr[i];
		sort(arr[i].begin(), arr[i].end());
	}
	sort(arr.begin(), arr.end()-1);
	ll ans = 0 , sum = 1;
	for (ll i = 0; i < n; i++) {
		if (arr[i] == arr[i + 1])
			sum++;
		else{
			ans += (sum * (sum-1))/2;
			sum = 1;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 6412
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int cnt=0,n,l,A[N],*S;
 
void insertionSort(int A[], int n, int m){
int i,v,j;
  for(i=m;i<n;i++){
    v=A[i];
    j=i-m;
    while(j>=0&&A[j]>v){
      A[j+m]=A[j];
      j-=m;
      cnt++;
    }
    A[j+m]=v;
  }
}
 
void Sort(int A[],int n){
  int i=0,a;
 
S=(int *)malloc(n * sizeof(int));
 
for(a=1; ; ){
if(a>n) break;
S[i]=a;
i++;
  a=3*a+1;
}
l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,S[i]);
  }
}
 
 
 
int main(){
int i;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
cnt=0;
 
Sort(A,n);
 
printf("%d\n",l);
 
for(i=l-1;i>=0;i--){
printf("%d",S[i]);
if(i) printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for(i=0;i<n;i++)printf("%d\n",A[i]);
 
 free(S);
  return 0;
}



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> Plp;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,L;
    cin >> N >> L;
    vector<ll> a(N), S(N+1);
    rep(i,N){
        cin >> a[i];
    }
    ll id = 0;
    ll ma = 0;
    rep(i,N-1){
        //if(a[i] + a[i+1] < L){
            //cout << "Impossible" << endl;
            //return 0;
        //}
        if(a[i]+a[i+1] > ma){
            ma = a[i]+a[i+1];
            id = i;
        }
    }
    if(ma < L){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i,id){
        cout << i+1 << endl;
    }
    for(ll i=N-2;i>id;i--){
        cout << i+1 << endl;
    }
    cout << id+1 << endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
 
#define FOR(idx, begin, end) for(int idx = (begin); idx < (end); ++idx)
#define DMP(x) cerr << #x << ": " << x << "\n"
 
using namespace std;
typedef long long lint;
const int MOD = 1000000007;
 
int main() {
 
	cin.tie(0);
 
	int N, M;
	cin >> N >> M;
 
	vector<int> visited(N, 0);
 
	vector<int> a(M), b(M);
	FOR(i, 0, M) cin >> a[i] >> b[i];
 
	vector<vector<int>> path(N, vector<int>(N, 0));
	FOR(i, 0, M) {
		path[a[i] - 1][b[i] - 1] = true;
		path[b[i] - 1][a[i] - 1] = true;
	}
 
	int ans = 0;
 
	stack<pair<int, vector<int>>> node;
	node.push({0, visited});
 
	while (!node.empty()) {
		
		auto now = node.top();
		now.second[now.first] = 1;
		node.pop();
 
		FOR(i, 0, N) {
			if (now.second[i] == 0 && path[now.first][i] == 1) {
 
				node.push({i, now.second});
			}
		}
 
		FOR(i, 0, N) {
 
			if (now.second[i] == 0) break;
			if (i == N - 1) ans++;
		}
	
	}
 
	cout << ans;
 
	return 0;
}

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

typedef long long ll;

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

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

    int N;
    cin >> N;

    vector<int> s(N);
    int sum = 0;

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

    if(sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }

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

    for(int i = 0; i < N; i++) {
        if(s[i] % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }

    cout << 0 << endl;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
#ifdef LOCAL
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    int n, a = 0, w = 0, t = 0, r = 0;
    scanf("%d", &n);
    while (n--) {
        char s[5];
        scanf("%s", s);
        if (s[0] == 'A')
            a++;
        else if (s[0] == 'W')
            w++;
        else if (s[0] == 'T')
            t++;
        else
            r++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, w, t, r);
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2019;
const int MOD = 1e9 + 7;
int a[MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	rep (i, 1, n) {
		cin >> a[i];
	}
	lint step = 0;
	lint temp = 0;
	rep (i, 1, n) {
		rep (j, i, n) {
			if (a[j] < a[i]) ++step;
		}
		rep (j, 1, n) {
			if (a[j] < a[i]) ++temp;
		}
	}
	lint ans = step * k % MOD;
	ans += k * (k - 1ll) / 2 % MOD * temp % MOD;
	cout << ans % MOD << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =1e6+10;
const double pi=acos(-1.0);
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
const ll mod=1e9+7;
int a[N];
int vis[N];
signed main(){
    int n;
    si(n);
    int tmp=0;
    for (int i = 1; i <=n ; ++i) {
        si(a[i]);
        if(i==1){
            tmp=a[i];
        }else{
            tmp=__gcd(tmp,a[i]);
        }
    }
    if(tmp!=1){
        puts("not coprime");
    }else{
        for (int i = 1; i <=n ; ++i) {
            for(int j=1;j<=sqrt(a[i]);j++){
                if(a[i]%j!=0)continue;
                vis[1]=0;
                if(vis[j]||vis[a[i]/j]){
                    puts("setwise coprime");
                    return 0;
                }
                vis[j]=vis[a[i]/j]=1;
            }
        }
        puts("pairwise coprime");
    }
    return 0;
}

Measured memory_bytes: 7936
/*** ????§??§??????±??? ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 10000

int main() {
	int N, M, L, K, A, H;
	while(cin>>N>>M>>L>>K>>A>>H, N){
		bool froz[100]={};
		int T[100][100];
		
		REP(i, 0, N){
			REP(j, 0, N){
				T[i][j]=INF;
			}
		}
		REP(i, 0, L){
			int num;
			cin >> num;
			froz[num]=true;
		}
		froz[A]=true;
		froz[H]=true;
		REP(i, 0, K){
			int x, y, t;
			cin >> x >> y >> t;
			T[x][y]=t;
			T[y][x]=t;
		}
		
		REP(k, 0, N){
			REP(i, 0, N){
				REP(j, 0, N){
					if(i!=j) T[i][j]=min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}
		
		REP(i, 0, N){
			REP(j, 0, N){
				if(!froz[i] || !froz[j] || T[i][j]>M) T[i][j]=INF;
			}
		}
		
		REP(k, 0, N){
			REP(i, 0, N){
				REP(j, 0, N){
					if(i!=j) T[i][j]=min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}
		
		if(T[A][H]==INF) cout << "Help!" << endl;
		else cout << T[A][H]+max(0, T[A][H]-M) << endl;
		
	}
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,d,a;
  cin >> n >> d >> a;
  vector<pll> xh(n);
  REP(i,n){
    int32 x,h;
    cin >> x >> h;
    xh[i] = pii(x,h);
  }
  sort(ALL(xh));
  queue<pii> attack;
  int64 ans = 0;
  int64 minus = 0;
  REP(i,n){
    while(!attack.empty() && attack.front().first + 2 * d < xh[i].first){
      minus -= attack.front().second;
      attack.pop();
    }
    xh[i].second -= minus * a;
    if(xh[i].second < 0)xh[i].second = 0;
    int64 cnt = (xh[i].second + a - 1) / a;
    ans += cnt;
    minus += cnt;
    attack.push(pll(xh[i].first,cnt));
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 6656
#include <stdio.h>

void swap (int*,int*);

int main()
{
  int i,j,count=0,min=0,N;
  int a[100];

  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&a[i]);
    }

  for(i=0;i<N-1;i++)
    {
      min=i;
      for(j=i;j<N;j++)
	{
	  if(a[j]<a[min]) min=j;
	}
      swap(&a[i],&a[min]);
      if(i!=min) count++;
    }

  for(i=0;i<N;i++)
    {
      printf("%d",a[i]);
      if(i!=N-1) printf(" ");
    }
  printf("\n");
  printf("%d\n",count);

  return 0;
}
	  
void swap(int *x,int *y)
{
  int z;

  z=*x;
  *x=*y;
  *y=z;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;

	while(N>0){
		if(N%10==9){
			ce("Yes")
			return 0;
		}
		N/=10;
	}
	ce("No")
}

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

int main(){

int k,n;
int *a;
char line[10000000];
char space[] = " ";

if(fgets(line,sizeof(line),stdin)!=NULL){}
sscanf(line,"%d%d",&k,&n);

a = (int *)malloc(sizeof(int)*n);

if(fgets(line,sizeof(line),stdin)!=NULL){}

int i;
int max_distance = 0;
char *temp;
temp = strtok(line,space);
for(i=0;i<n;i++){
  a[i] = atoi(temp);
  temp = strtok(NULL,space);
  if(i!=0){
    if(a[i]-a[i-1]>max_distance){
      max_distance = a[i] - a[i-1];
    }
  }
}

if(k-a[n-1]+a[0] > max_distance){
  max_distance = k - a[n-1]+a[0];
}

printf("%d",k-max_distance);
return 0;

}


Measured memory_bytes: 4224
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


void solve(long long N, std::vector<long long> A){
    long long x = 1;

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

    if (A[0] == 0) {
        x = 0;
    } else {
        for (int i=0;i<A.size();++i) {
            if ((x / 10000) * (A[i] / 10000) > 10000000000) {
                x = -1;
                break;
            } else {
                x *= A[i];
                if (x > 1000000000000000000) {
                    x = -1;
                    break;
                }
            }
        }
    }
    cout << x << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4080