akhauriyash/Code-Regression huggingface dataset:
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (ll i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (ll i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
const ll mod = 1000000007; 
#define MAX 1000000+1
ll prime[MAX]; 
map<ll, ll> max_map; 
ll power(ll a, ll n) 
{ 
    if (n == 0) 
        return 1; 
    ll p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (ll j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
#define F fi
#define S se
ll lcmModuloM(const ll* ar, ll n) 
{ 
  
    for (ll i = 0; i < n; i++) { 
        ll num = ar[i]; 
        map<ll, ll> temp; 
        while (num > 1) { 
  
            ll factor = prime[num]; 

            temp[factor]++; 
  
            num /= factor; 
        } 
  
        for (auto it : temp) { 

            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 
ll gcdExtended(ll  a, ll b, ll *x, ll *y); 
ll modInverse(ll b, ll m) 
{ 
    ll x, y; // used in extended GCD algorithm 
    ll g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 

    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
ll modDivide(ll a, ll b, ll m) 
{
    ll inv = modInverse(b, m); 
    return  (inv * a) % m; 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll l=lcmModuloM(a,n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=modDivide(l,a[i],1000000007);
        ans%=1000000007;
    }
    cout<<ans;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=200010;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
    int n,x;cin>>n>>x;
    int mi=INF;
    int ans=0;
    for(int i=0;i<n;i++){
        int m;cin>>m;
        mi=min(mi,m);
        x-=m;
    }
    ans=n+x/mi;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int ans = a * b / 2;
		System.out.println(ans);
	}
 
}

Measured memory_bytes: 20820
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<ll> D(n);
    for (auto &d : D) {
        cin >> d;
    }
    sort(D.begin(), D.end());
    if (D[n/2]==D[n/2-1]) {
        cout << 0 << endl;
    } else {
        cout << D[n/2] - D[n/2-1]<< endl;
    }
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef unsigned int uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

typedef long long Int;
//int n,m;
int N;
const int MAX = (1<<18);
Int data[MAX], ct[MAX];

typedef pair<int,int> range;

void init(int n){
	memset(data,0,sizeof(data));
	memset(ct,0,sizeof(ct));
	N = n+5;
}

//point-query
pair<Int,Int> get(int t){
	pair<Int,Int> ret;
	for(int x=t;x<=N;x+=x&-x)ret.first+=data[x];
	for(int x=t;x<=N;x+=x&-x)ret.second+=ct[x];
	return ret;
}

Int range_add(int a,int d){
	for(int x=a;x>0;x-=x&-x){
		data[x]+=d;
		if(d>0)ct[x]+=1;
		else if(d<0)ct[x]-=1;
	}
}

//range-query
void range_add(const range &p, int d){
	if(p.first>=p.second)return;
	range_add(p.second-1,d);
	range_add(p.first-1,-d);
}

void solve(int n, int m, vector<int> a){
	init(m*2);
	Int sum = 0;
	REP(i,n)a[i]--;
	REP(i,n-1){
		int s = a[i],t = a[i+1];
		if(a[i]>a[i+1]){
			t += m;
		}
//		dump(s);dump(t);
		sum+=t-s;
		range_add(make_pair(s+1 +1,t+1 +1),s+1);
		/*
		dump(s+1)
		dump(t+1)
		
		dump("==========");
		*/
	}
	dump(sum);
	Int mini = 1e+18;
	for(int x=0;x<m;x++){
		dump(x);
		auto p0 = get(x+1), p1 = get(x+m+1);
		Int result = p0.first-p0.second*x+p1.first-p1.second*(x+m);
		/*
		dump(p0.first);
		dump(p0.second);
		dump(p1.first);
		dump(p1.second);
		dump(result);
		dump("========");
		*/
//		dump(result);
		mini = min(result,mini);
	}
	cout<<sum+mini<<endl;
}

int main(){	
	int m;
	int n;
	scanf("%d",&n);
	vector<int> a(n-1+1);
	scanf("%d",&m);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%d",&a[i]);
	}
	solve(n, m, a);
	return 0;
}



Measured memory_bytes: 5248
import sys

tree={}
np = -1

home=0
tree[home]=[None, None, None]

def search(p, x):
    node_pos=[None,None]
    while p != None:
        tmp = tree[p]
        if tmp[0] == x:
            node_pos[0] = p
            return node_pos
        node_pos[1] = p
        if x < tmp[0]:
            p = tmp[1]
        else:
            p = tmp[2]
    return node_pos

def node(x):
    global np
    np += 1
    tree[np] = [x, None, None]
    return np

def insert(p, x):
    if p == None or np == -1: return node(x)
    tmp = tree[p]
    if x== tmp[0]: return p
    elif x<tmp[0]:
        tree[p][1]=insert(tmp[1],x)
    else:
        tree[p][2]=insert(tmp[2],x)
    return p

def deletenode(p, parent, child=None):
        if tree[parent][1]==p:
            tree[parent][1] = child
        elif tree[parent][2]==p:
            tree[parent][2] = child
        del tree[p]

def searchmin(p):
    while tree[p][1]!=None:
        p = tree[p][1]
    return p

def delete(x):
    p, parent = search(0,x)
    if tree[p][1:3]==[None,None]:
        deletenode(p,parent)
    elif tree[p][1]==None:
        deletenode(p, parent, tree[p][2])
    elif tree[p][2]==None:
        deletenode(p, parent, tree[p][1])
    else:
        p1=searchmin(tree[p][2])
        p1, parent1 = search(0,tree[p1][0])

        if tree[parent1][1]==p1:
            tree[parent1][1] = None
        elif tree[parent1][2]==p1:
            tree[parent1][2] = None

        if tree[parent][1]==p:
            tree[parent][1] = p1
        elif tree[parent][2]==p:
            tree[parent][2] = p1
        tree[p1][1]=tree[p][1]
        tree[p1][2]=tree[p][2]
        del tree[p]
    return

def preorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return [tree[p][0]] + preorder(p1) + preorder(p2)

def inorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return inorder(p1) + [tree[p][0]] +inorder(p2)

n = int(input())
i = 0
while i<n:
    s = raw_input()
    if s[0]=='i':
        p = insert(0,int(s[7:]))
    elif s[0]=='f':
        if search(0,int(s[5:]))[0]!=None: print 'yes'
        else: print 'no'
    elif s[0]=='d':
        delete(int(s[7:]))
    elif s[0]=='p':
        print ' ' + ' '.join(map(str, inorder(home)))
        print ' ' + ' '.join(map(str, preorder(home)))
    i += 1

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int L, R, D, res = 0;
	cin >> L >> R >> D;
	fore(i, L, R)
	{
		if (i%D == 0)
			++res;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3644
import java.util.*;
import java.io.*;
public class Main {
    void solve(BufferedReader in) throws Exception {
        int[] xx = toInts(in.readLine());
        int H = xx[0], W = xx[1];
        int N = toInt(in.readLine());
        int[] a = toInts(in.readLine());
        int[][] b = new int[H][W];
        int count = 0;
        for(int i = 0; i<H; i++) {
            if(i%2 == 0) {
                for(int j = 0; j<W; j++) {
                    if(a[count] == 0) count++;
                    b[i][j] = count+1;
                    a[count]--;
                }
            } else {
                for(int j = W - 1; j>=0; j--) {
                    if(a[count] == 0) count++;
                    b[i][j] = count+1;
                    a[count]--;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                sb.append(b[i][j]).append(" ");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    int toInt(String s) {return Integer.parseInt(s);}
    int[] toInts(String s) {
        String[] a = s.split(" ");
        int[] o = new int[a.length];
        for(int i = 0; i<a.length; i++) o[i] = toInt(a[i]);
        return o;
    }
    void e(Object o) {
        System.err.println(o);
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        (new Main()).solve(in);
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int pn[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

int pnc[48];

void factoring(int n){
	for(int i=0;i<15;i++){
		if(n==pn[i]){
			pnc[pn[i]]++;
			return;
		}
	}
	for(int i=0;i<15;i++){
		if(n%pn[i]==0){
			factoring(n/pn[i]);
			pnc[pn[i]]++;
			return;
		}
	}
}
	
int f2=0;
int f4=0;
int f14=0;
int f24=0;	
int f74=0;	
		

int main(){
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		factoring(i);
	}
	int ans=0;
	for(int i=2;i<48;i++){
		//cout<<i<<" "<<pnc[i]<<endl;
		if(pnc[i]>=2){
			f2++;
			//cout<<pnc[i];
		}
		if(pnc[i]>=4)f4++;
		if(pnc[i]>=14)f14++;
		if(pnc[i]>=24)f24++;
		if(pnc[i]>=74)f74++;
	}
	/*cout<<f2<<endl;
	cout<<f4<<endl;
	cout<<f14<<endl;
	cout<<f24<<endl;*/
	if(f4>=2){
		ans+=(f4*(f4-1)*(f2-2))/2;
	}
	if(f14>=1){
		ans+=(f14*(f4-1));
	}
	if(f24>=1){
		ans+=(f24*(f2-1));
	}
	if(f74>=1){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 1000005


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

   int ar[10];
    for(int i=1;i<=5;i++) cin>>ar[i];
    for(int i=1;i<=5;i++){
      if(ar[i]==0) return cout<<i,0;
    }

    return 0;
}




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

int main(void){

	int a;
	scanf("%d",&a);

	if(a>= 65 && a<=90){
		printf("1\n");
	}else if(a >= 97 && a<=122){
		printf("2\n");
	}else{
		printf("0\n");
	}


    return 0;
}


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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

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

    string s;
    cin>>s;
    int cnt=0;
    int tmp=0;
    rep(i,3){
        if(s[i]=='R'){
            tmp++;
        }else{
            cnt = max(tmp,cnt);
            tmp=0;
        }
    }
    print(max(tmp,cnt));

    return 0;
}




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

int main (){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> masu(H, vector<char>(W));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            char temp;
            cin >> temp;
            if(temp=='#') masu.at(i).at(j)='#';
            else masu.at(i).at(j) = '0';
        }
    }
    //全てのマスを参照
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            //#のマスなら何も処理しない
            if(masu.at(i).at(j)=='#') continue;
            //masu.at(i).at(j)の周りのマスをmasu.at(y).at(x)で参照
            for(int y=i-1; y<=i+1; ++y){
                for(int x=j-1; x<=j+1; ++x){
                    //マスからはみ出てないかチェック
                    if(0<=y && y<H && 0<=x && x<W){
                        //調べたマスが#なら
                        if(masu.at(y).at(x)=='#')
                            ++masu.at(i).at(j);
                    }
                }
            }
        }
    }

    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            cout << masu.at(i).at(j);
        }
        cout << endl;
    }
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int n;
	cin >> n;
	int maxi = 0;
	int a[n];
	int ok = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		maxi = max(maxi,a[i]);
		if(a[i - 1] != a[i] && i != 0)ok = 1;
	}
	if(!ok){
		for(int i = 0; i < n; i++){
			cout << maxi << endl;
		}
	}
	else{
		int maxii = 0;
		int count = 0;
		for(int i = 0; i < n; i++){
			if(maxii < a[i] && a[i] != maxi){
				maxii = max(maxii,a[i]);
			}
			if(a[i] == maxi)count++;
		}
		for(int i = 0; i < n; i++){
			if(a[i] == maxi && count < 2)cout << maxii << endl;
			else cout << maxi << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<queue>
#include<algorithm>
#define maxn 100050
using namespace std;
priority_queue<int>q;
struct node{
	int a,b;
}a[maxn];
bool cmp(node a,node b){
	return a.b>b.b;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i].b,&a[i].a);
		a[i].b=m-a[i].b+1;
	}
	sort(a+1,a+1+n,cmp);
	int now=1,ans=0;
	for (int i=a[1].b;i>0;i--){		
		while (now<=n&&m-a[now].b+i<=m) q.push(a[now].a),now++;
		if (!q.empty()) ans+=q.top(),q.pop();
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

string s;

int main(){
	cin >> s;
	bool b[26] = {0};
	for(int i = 0; i < s.size(); i++){
		b[s[i] - 'a'] = 1;
	}
	bool none = 1;
	for(int i = 0; i < 26; i++){
		if(!b[i]){
			none = 0;
			char ans = 'a'+i;
			cout << ans << endl;
			break;
		}
	}
	if(none) cout << "None" << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,c;
    cin>>n>>m>>c;

    vector<int>b(m);
    vector<vector<int>>a(n,vector<int>(m,0));

    for (int i=0;i<m;i++) {
        cin>>b[i];
    }

    for(int i=0;i<n;i++){
        for (int j=0;j<m;j++) {
        cin>>a[i][j];
        }
    }

    int count=0;
    int sum=0;
    for(int i=0;i<n;i++){
        for (int j=0;j<m;j++) {
            sum+=a[i][j]*b[j];
        }
        if(sum+c>0){
            count++;
        }
        sum=0;
    }

    cout <<count<<endl;

}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

void show(vector<int> a) {
    for (int x : a)
        cout << x << " ";
    cout << "\n";
}

vector<int> read(int n) {
    vector<int> a(n);
    for (int &x : a)
        cin >> x;
    return a;
}

vector<int> slow(vector<int> a, int k) {
    int n = (int) a.size();
    vector<int> b(n);
    for (int iter = 0; iter < k; iter++) {

        b.assign(n, 0);
        for (int i = 0; i < n; i++) {
            b[i]++;
            if (i + a[i] + 1 < n)
                b[i + a[i] + 1]--;
            if (i + 1 < n)
                b[i + 1]--;
            b[max(0, i - a[i])]++;
        }
        for (int i = 0; i < n; i++) {
            if (i + 1 < n)
                b[i + 1] += b[i];
            b[i]--;
        }

        if (a != b)
            a = b;
        else
            break;

//        cout << iter << " : ";
//        cout << endl;
//        show(a);
    }

    return a;
}

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> a = read(n);
//    vector<int> a(n);

    a = slow(a, k);

    show(a);

    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

string s;
bool nwse[4];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> s;
  for (int i = 0; i < (int)s.size(); i++)
    if (s[i] == 'N') nwse[0] = true;
    else if (s[i] == 'W') nwse[1] = true;
    else if (s[i] == 'S') nwse[2] = true;
    else nwse[3] = true;

  if (nwse[0] == nwse[2] && nwse[1] == nwse[3])
    cout << "Yes\n";
  else
    cout << "No\n";


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005];
int cnt = 0;

int main()
{
  scanf("%d",&n);
  for(int i = 1; i <= n; i ++)  scanf("%d",&a[i]);
  sort(a + 1, a + n + 1);
  for(int i = 1; i < n - 1; i ++)
    for(int j = i + 1; j < n; j ++){
      int k = lower_bound(a + j + 1, a + n + 1, a[i] + a[j]) - a;
      cnt += k - j - 1;
    }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] array = new int[n];
        for(int i=0; i<m; i++){
            int a = sc.nextInt();
            array[a] = 1;
        }

        int costMinus = 0;
        int costPlus = 0;

        for(int i=x; i>=0; i--){
            costMinus+=array[i];
        }

        for(int i=x; i<n; i++){
            costPlus+=array[i];
        }

        System.out.println(Math.min(costMinus, costPlus));
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl

int main() {
    int l, r; cin >> l >> r;
    int ans = 1e9 + 7;
    //2019 = 3 * 673
    //673つの数を見れば必ず673の倍数の数があり、3の倍数の数もある
    rep3(i, l, min(r, l + 672)) rep3(j, i + 1, min(r, l + 672) + 1) {
        int sa = (ll)i * j % 2019;
        chmin(ans, sa);
    }
    out(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int,int);
void swap(int *,int *);


int main(){
  int m,n;
  scanf("%d%d",&m,&n);
  printf("%d\n",gcd(m,n));
  return 0;
}

int gcd(int x,int y){
  int r;
  if(x<y)
    swap(&x,&y);
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
  return;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cmath>

int main(){
   int X;
   std::cin >> X;
   int max = 1;
   for (int i=1; i<=32; i++){
      for (int j=2; j<=9; j++){
         int tmp = std::pow(i, j);
         if (tmp <= X){
            max = std::max(max, tmp);
         }
      }
   }
   std::cout << max << std::endl;

}



Measured memory_bytes: 256
#include "stdio.h"
#include "math.h"

#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0076 : Treasure Hunt II **/
int main()
{
	int n;
	while (cin>>n, n>0) {
		double x, y;
		x=1.0; y=0.0;
		REP(i, 1, n) {
			double nx = -y;
			double ny = x;
			double dx = nx/sqrt(nx*nx+ny*ny);
			double dy = ny/sqrt(nx*nx+ny*ny);
			x = x+dx; y = y+dy;
		}
		cout << fixed << setprecision(2) << x << "\n" << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
int B[1100][1100];
#include<iostream>
using namespace std;

int main (){
	int H;
	int W;
	char A[1100][1100];
	long ans =0;
	cin >> W;
	cin >> H;
	int X;
	X= 1e9+7;

	for(int j=1; j<W+1; j++){
		for(int i=1; i<H+1; i++){
			cin >> A[i][j];
		}
	}
	B[0][1]=1;
	
	for(int i=1; i<H+1; i++){
		 if(A[i][1]=='#'){
			B[i][1]=0;
		 } else if(A[i][1]=='.'){
			if(B[i-1][1]==0){
				B[i][1]=0;
		    } else {
				B[i][1]=1;
		    }
		}
	}
	for(int j=1; j<W+1; j++){
		 B[1][0]=1;
		 if(A[1][j]=='#'){
			B[1][j]=0;
		 } else if(A[1][j]=='.'){
			if(B[1][j-1]==0){
				B[1][j]=0;
		    } else {
				B[1][j]=1;
		    }
		}
	}
	for(int i=2; i<H+1;i++){
		for(int j=2; j<W+1; j++){
			if(A[i][j]=='#'){
				B[i][j]=0;
			} else if(A[i][j]=='.'){
				B[i][j]=(B[i-1][j]%X+B[i][j-1]%X)%X;
			}
		}
	}
		ans = B[H][W];
	 cout << ans  << endl;
	  
	  return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

  vector<int> roll(char opp,vector<int>  DICE)
  {
    vector<int> rolled(6,0);

    if(opp =='W')
    {
      rolled[0] = DICE[2];
      rolled[1] = DICE[1];
      rolled[2] = DICE[5];
      rolled[3] = DICE[0];
      rolled[4] = DICE[4];
      rolled[5] = DICE[3];
    }
    else if( opp == 'S')
    {
      rolled[0] = DICE[4];
      rolled[1] = DICE[0];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[5];
      rolled[5] = DICE[1];
    }
    else if(opp == 'N')
    {
      rolled[0] = DICE[1];
      rolled[1] = DICE[5];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[0];
      rolled[5] = DICE[4];
    }

    else
    {
      rolled[0] = DICE[3];
      rolled[1] = DICE[1];
      rolled[2] = DICE[0];
      rolled[3] = DICE[5];
      rolled[4] = DICE[4];
      rolled[5] = DICE[2];
    }

    return rolled;
    

  }

void solve(void)
{ 

  vector<int> DICE (6,0);

  for (int i = 0; i < 6; i++)
  {
    cin>>DICE[i];
  }

  string opp;
  cin>>opp;

  for (int i = 0; i < opp.size(); i++)
  {
    DICE = roll(opp[i],DICE);
  }
  // cout<<face<<endl
  cout<<DICE[0]<<endl;
  
  


  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3208
#include <iostream>

using namespace std;

int main(void) {
        int a[3];
        bool flag = true;
        int i = 0;

        for(int i = 0; i < 3; i++) {
                cin >> a[i]; 
        }

        while(i != 2) {
                if(a[i] >= a[i + 1]) {
                        flag = false;
                }
                i++;
        }
        
        if(flag == true) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
        return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <vector>
#include <list>
#include <string>

using namespace std;

struct node {
  list<node*> children;
  int cnt = 0;
};

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

  vector<node> nodes(n+1);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    nodes[a].children.push_back(&(nodes[b]));
  }

  for (int i = 0; i < q; ++i) {
    int p, x;
    cin >> p >> x;
    nodes[p].cnt += x;
  }

  list<node*> queue;
  queue.push_back(&(nodes[1]));

  while (!queue.empty()) {
    auto nn = *(queue.begin());
    queue.pop_front();
    for (auto cn : nn->children) {
      queue.push_back(cn);
      cn->cnt += nn->cnt;
    }
  }

  string delim = "";
  for (int i = 1; i <= n; ++i) {
    cout << delim << nodes[i].cnt;
    delim = " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vector<int>> s(m);
    vector<int> p(m),k(m);
    rep(i,m){
        cin>>k.at(i);
        s.at(i).resize(k.at(i));
        rep(j,k.at(i))cin>>s.at(i).at(j);
    }
    rep(i,m)cin>>p.at(i);
    int ans=0;
    for(int i=0; i<(1<<n); i++){
        vector<int> cnt(m,0);
        bool ok=true;
        rep(j,m){
            rep(l,k.at(j)){
                if((1<<(s.at(j).at(l)-1))&i)cnt.at(j)++;
            }
            if(cnt.at(j)%2!=p.at(j))ok=false;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
map <string,int> cost;
multimap <string,string>  rule;
set <string> his;

void update(string a){
  multimap<string,string>::iterator it=rule.find(a);
  while(it != rule.end() && it->first == a) {
    if(cost[it->second]>cost[a])cost[it->second]=cost[a], update(it->second);
    it++;
  }
}
int mk_rule(string a){
  if(his.count(a) == 0){
    his.insert(a);    
    multimap<string,string>::iterator it=rule.find(a);
    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second)),it++;
    update(a);
  }
  return cost[a];
}

int main(){
  int n,m,b;
  cin >> n;
  string a,c,ls[5002];
  for(int i=0;i<n;i++) {
    cin >> a >> b;
    cost[a] = b , ls[i] = a;
  }
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> a >> c;
    rule.insert(pair<string,string>(a,c));
    rule.insert(pair<string,string>(c,a));
  }
  int ans=0;
  for(int i=0;i<n;i++) ans += mk_rule(ls[i]);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 2240
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B, C, D; std::cin >> A >> B >> C >> D;
  int t = std::ceil( (double)A/D );
  int a = std::ceil( (double)C/B );
  if ( t == a ) std::cout << "Yes" << std::endl;
  else if ( t > a ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}



Measured memory_bytes: 3660
# https://atcoder.jp/contests/arc101/tasks/arc101_b
"""
タグ: 中央値、二分探索、転倒数
"""
class Bit:
    def __init__(self, n):
        self.n = n
        self.tree = [0]*(n+1)
        self.el = [0]*(n+1)
        self.depth = n.bit_length() - 1

    def sum(self, i):
        """ 区間[0,i) の総和を求める """
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1) )- 1
        return s

    def add(self, i, x):
        self.el[i] += x
        while i < self.n:
            self.tree[i] += x
            i |= i + 1

class BitSet2:
    """ 座標圧縮が必要な場合 """
    def __init__(self, data, A=[]):
        """ BitSetに入り得る値を先読みした物を data に格納 """
        self.data = sorted(list(set(data)))
        self.n = len(self.data)
        self.p = Bit(self.n + 1)
        self.size = 0
        self.flip = 0
        self.code = {}
        self.decode = {}
        for i, b in enumerate(self.data):
            self.code[b] = i
            self.decode[i] = b
        for a in A:
            self.add(a)

    def add(self,x):
        self.p.add(self.code[x], 1)
        self.size += 1
        self.flip += self.size - self.p.sum(self.code[x]+1)

    def remove(self,x):
        self.p.add(x, -1)
        self.size -= 1

    def flip_counter(self):
        return self.flip

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

def test(x):
    S = [0]
    for a in A:
        if a >= AS[x]:
            S.append(S[-1]+1)
        else:
            S.append(S[-1]-1)
    B = BitSet2(S,S)
    cnt = M - B.flip_counter()
    return cnt >= ceil(M/2)

import sys
from math import ceil
input = sys.stdin.readline

N = int(input())
M = N*(N+1)//2
A = list(map(int, input().split()))
AS = sorted(A)
print(AS[binary_search_int(0,N,test)])


Measured memory_bytes: 258920
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

map<string, ll> mp;

int main() {
    cin >> n;
    REP(i,n) {
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    REP(i,m) {
        cin >> s;
        mp[s]--;
    }
    for(auto p:mp){
        if(p.second>ans){
            ans = p.second;
        }
    }
    cout << max<ll>(ans, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int val = (n-1)*(n-2);
	val/=2;
	if(val<k){
		cout<<"-1\n";
		return 0;
	}
	cout<<n-1+val-k<<endl;
	for(int i=2;i<=n;i++)	cout<<"1 "<<i<<endl;
	val = val-k;
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(val==0)	return 0;
			cout<<i<<" "<<j<<endl;
			val--;
		}
	}
	return 0;
}

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

int N;
int a[100];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];

    int maxv = a[0];
    int minv = a[0];
    for(int i = 1; i < N; i++){
        minv = min(a[i], minv);
        maxv = max(a[i], maxv);
    }
    cout << (maxv-minv);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
int a[100];
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
int main() {
	int n;cin>>n;
	int arr[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	ll ans = 1e3;
	for(int i = 0; i < n - 1; ++i){
		ll st = 0;
		if(arr[i] < arr[i+1]) st = ans / arr[i];
		ans += (max(0, arr[i+1] - arr[i]))*st;
	}
	cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;



int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    ll x;
    cin >> x;
    vector<ll> a(n);
    for (ll& x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    ll sm = 0;
    int ptr = 0;
    while (ptr < n && sm + a[ptr] <= x) {
        sm += a[ptr];
        ptr++;
    }
    if (ptr == n && sm != x) {
        ptr--;
    }
    cout << ptr << endl;
}




Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))

    allxor = 0
    for i in a:
        allxor ^= i

    ans = [0] * N
    for i in range(N):
        ans[i] = allxor ^ a[i]

    print(*ans)


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 31512
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //var p = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var X = long.Parse(Console.ReadLine());

            if (30 <= X) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 27468
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int main(){
  int n; cin>>n;
  int arr[n]; take(arr,n);
  sort(arr,arr+n,greater<int>());
  ll i=1, j=0, sum=0; 
  while(i<n){
    if(i&1){ sum+=(ll)arr[j]; i++; j++; }
    else{ sum+=(ll)arr[j]; i++; }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 4408
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

#define N 100
#define INF 0x7FFFFFFF

int prim(std::unordered_map<int, int> a[N], const int n){
    std::unordered_set<int> checked;
    int total = 0;
    checked.insert(0);
    while(checked.size() != n){
        int newId = INF;
        int newWeight = INF;
        for(auto &x: checked){
            for(auto &j: a[x]){
                if(checked.find(j.first) == checked.end() && newWeight > j.second){
                    newId = j.first;
                    newWeight = j.second;
                }
            }
        }
        checked.insert(newId);
        total += newWeight;
    }
    return total;
}

int main(){
    int n;
    std::scanf("%d", &n);
    std::unordered_map<int, int> a[N];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            int v;
            std::scanf("%d", &v);
            if(v != -1){
                a[i].insert(std::make_pair(j, v));
            }
        }
    }
    int val = prim(a, n);
    std::printf("%d\n", val);
    return 0;
}



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

using namespace std;

const int MAX_W_V_SIZE = 405, M = 2e5 + 1;
int64_t W[405], V[405], dp[M];


int main() {
    int n, w, min_weight;
    cin >> n >> w;

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

    for (int k = 0; k < n; k++) {
        for (int x = w; x >= 0; x--) {
            if(dp[x] || !dp[0]) dp[x + W[k]] = max(dp[x + W[k]], V[k] + dp[x]);
        }
    }

    cout << *max_element(dp, dp + w + 1);
    
    return 0;
}



Measured memory_bytes: 1792
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

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

void solve(){
	P s = P(rlong, rlong);
	P t = P(rlong, rlong);
	
	long w = t.x - s.x;
	long h = t.y - s.y;
	
	foreach(i; 0 .. w) "R".write;
	foreach(j; 0 .. h) "U".write;
	foreach(i; 0 .. w) "L".write;
	foreach(j; 0 .. h) "D".write;
	
	"DR".write;
	foreach(i; 0 .. w) "R".write;
	foreach(j; 0 .. h) "U".write;
	"UL".write;
	"UL".write;
	foreach(i; 0 .. w) "L".write;
	foreach(j; 0 .. h) "D".write;
	"DR".write;
	
	"".writeln;
}
struct P{
	long x, y;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

int n,k;

int solve() {
	return n-k+1;
}

void run() {
	scanf("%d%d",&n,&k);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int link[10005];
int size[10005];
int find(int x)
{
	while(x!=link[x])
		x=link[x];
	return x;
}
bool same(int a, int b)
{
	return find(a)==find(b);
}
void unite(int a, int b)
{
	a=find(a);
	b=find(b);
	if(size[a]<size[b])
		swap(a,b);
	size[a]+=size[b];
	link[b]=a;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,q;
	cin >> n >> q;
	for(int i=1;i<=n;i++)
	{
		link[i]=i;
		size[i]=1;
	}
	while(q--)
	{
		int x,a,b;
		cin >> x >> a >> b;
		// dbg3(x,a,b);
		if(x==0)
			unite(a,b);
		else if(x==1)
		{
			if(same(a,b))
				cout << "1\n";
			else
				cout << "0\n";
		}
	}
}


Measured memory_bytes: 3300
#include <cstdio>
#include <algorithm>
using namespace std;
int A,B,K,fl;
int main(){
	scanf("%d%d%d",&A,&B,&K);
	while (K--){
		if (fl) A+=B/2,B/=2;
			else B+=A/2,A/=2;
		fl^=1;
	}
	printf("%d %d",A,B);
	return 0;
}

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

#print(N,K)
#print(S)

res=0
rl=0
lr=0
for i in range(N-1):
  if S[i]==S[i+1]:
    res+=1
  if S[i]=='R' and S[i+1]=='L':
    rl+=1
  if S[i]=='L' and S[i+1]=='R':
    lr+=1

if min(rl,lr)>K:
  res+=2*K
else:
  res+=min(rl,lr)+min(max(rl,lr),K)
print(res)

Measured memory_bytes: 3316
import numpy as np
 
h, w = list(map(int, input().split()))
 
aaa = [list(map(int, input().split())) for _ in range(h)]
bbb = [list(map(int, input().split())) for _ in range(h)]
aaa = np.array(aaa, dtype=np.int8)
bbb = np.array(bbb, dtype=np.int8)
diff = abs(aaa - bbb)
 
 
def merge_new_can(d, can, prev_can):
    if d == 0:
        can |= prev_can
    else:
        can[d:] |= prev_can[:-d]
        can[:-d] |= prev_can[d:]
 
 
prev_row = [None] * w
 
can = np.zeros(25601, dtype=np.int8)
can[diff[0][0] + 12800] = 1
prev_row[0] = can
 
for j in range(1, w):
    d = diff[0][j]
    can = np.zeros(25601, dtype=np.int8)
    prev_can = prev_row[j - 1]
    merge_new_can(d, can, prev_can)
    prev_row[j] = can
 
for i in range(1, h):
    curr_row = [None] * w
 
    d = diff[i][0]
    prev_can = prev_row[0]
    can = np.zeros(25601, dtype=np.int8)
    merge_new_can(d, can, prev_can)
    curr_row[0] = can
 
    for j in range(1, w):
        d = diff[i][j]
        can = np.zeros(25601, dtype=np.int8)
        prev_can1 = prev_row[j]
        prev_can2 = curr_row[j - 1]
        merge_new_can(d, can, prev_can1)
        merge_new_can(d, can, prev_can2)
        curr_row[j] = can
 
    prev_row = curr_row
 
goal = prev_row[-1]
goal[12801:] |= goal[:12800][::-1]
goal = goal[12800:]
print(np.argmax(goal))

Measured memory_bytes: 18520
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        double r = Double.parseDouble(br.readLine());
        System.out.println(String.format("%f", (r*r*Math.PI)) + " " + String.format("%f", (2*r*Math.PI)));
    }
}

Measured memory_bytes: 24644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int x = sc.nextInt();

		int start = x - (k-1);
		int end = x + (k-1);

		for (int i = start; i <= end; i++) {
			System.out.print(i);
			System.out.print(" ");
		}

}}

Measured memory_bytes: 22996