akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanString()
	q := scanInt()

	b := make([]bit, 26)
	for i := 0; i < 26; i++ {
		b[i] = make(bit, n+1)
	}

	ss := make([]rune,n)

	for i, e := range s {
		val := e-'a'
		b[val].add(i,1)
		ss[i] = e
	}


	for i := 0; i < q; i++ {
		act := scanInt()
		if act == 1 {
			idx := scanInt()-1
			c := scanString()
			
			b[ss[idx]-'a'].add(idx, -1)
			ss[idx] = rune(c[0])
			b[c[0]-'a'].add(idx, 1)
		} else {
			l := scanInt()-1
			r := scanInt()-1
			cnt := 0
			for j := 0; j < 26; j++ {
				if b[j].sum(r)-b[j].sum(l-1) > 0 {
					cnt++
				}
			}
			fmt.Fprintln(wr, cnt)
		}
	}

	
}

type bit []int

func (t bit) sum(i int) int {
	s := 0
	for i++; i > 0; i -= i & -i { s += t[i] }
	return s
}

func (t bit) add(i, x int) {
	for i++; i < len(t); i += i & -i { t[i] += x }
}

func replaceAtIndex(in string, r rune, i int) string {
	out := []rune(in)
	out[i] = r
	return string(out)
}


Measured memory_bytes: 109824
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  int cnt = 0;
  int ans = 10000;
  vector<int> cost(n);
  vector<int> time(n);
  for (int i = 0; i < n; i++) {
    cin >> cost[i] >> time[i];
    if (time[i] > t) cnt++;
    else ans = min(ans, cost[i]);
  }
  if (cnt < n) cout << ans << endl;
  else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
a.sort()

cnt = [0]*(10**6 + 1)
lst = [True]*(10**6+1)
for i in a:
    cnt[i] += 1

ans = 0
for i in a:
    if cnt[i] == 1 and lst[i]:
        ans += 1
        j = 1
        while i*j <= 10**6:
            lst[i*j] = False
            j += 1
    elif lst[i]:
        j = 1
        while i*j <= 10**6:
            lst[i*j] = False
            j += 1

print(ans)


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int D;
vll C, T;
vvll S;

ll calcScore(vll &T) {
	vll last(26, -1);	
	ll score = 0;
	for (int i = 0; i < D; i++) {
		score += S[i][T[i]];
		last[T[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= (i-last[j])*C[j];
		}
	}
	return (score);
}

void Main() {
	cin >> D;
	C = makeVector(26, 0ll); cin >> C;
	S = makeVector(D, 26, 0ll); cin >> S;
	T = makeVector(D, 0ll);
	
	ll maxv = -LLINF;
	int M = 100000;
	for (int i = 0; i < M; i++) {
		int d = rand()%D;
		int q = rand()%26;
		ll tmp = T[d];
		T[d] = q;
		ll score = calcScore(T);
		if (score <= maxv) T[d] = tmp;
		else maxv = score;
	}
	for (int i = 0; i < D; i++) {
		assert(T[i] < 26);
		assert(T[i] >= 0);
		cout << T[i]+1 << el;
	}
	//cout << maxv << endl;
}

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


Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>
int main(){
	int b,n,i,j,min=2147483647,max,ans=-214783648;
	int *r;
	scanf("%d",&n);
	r = malloc(sizeof(int) * (n));
	scanf("%d",r);
	max = min = *r;
	for(i=1; i<n; i++){
		scanf("%d",(r+i));
		max = *(r+i);
		//if(min != max)b = max - min;
		b = max - min;
		if(min > *(r+i))min = *(r+i);
		if(n==2 || ans < b)ans = b;
	}
	
	printf("%d\n",ans);
	free(r);
	return 0;
}
		

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<random>
#include<functional>
#include<list>
#include<cmath>

using namespace std;
using ll = long long int;

const ll MOD = 1000000007;
const ll INF = (1LL << 60LL);

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

ll mypow(ll x, ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
}

long long int extGcd(long long int a,long long int b,long long int &x,long long int &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    long long int gcdVal = extGcd(b,a%b,x,y);
    long long int tmpX = x;
    x = y;
    y = tmpX - (a/b)*y;
    return gcdVal;
}

void printall(ll a,ll b,ll c,ll d,ll e,ll f){
    cout << a << " ";
    cout << b << " ";
    cout << c << " ";
    cout << d << " ";
    cout << e << " ";
    cout << f << endl;
}

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

    ll s;
    cin >> s;

    ll ss = (ll)sqrt((double)s);
    if(ss * ss == s){
        printall(0,0,ss,0,0,ss);
    }else{
        if(ss*ss > s){
            ss--;
        }
        ll targ = (ss+1)*(ss+1);
        ll diff = targ - s;
        ll t = 1;
        ll ans = diff;
        for(ll j = 1; j*j <= diff; j++){
            if(diff % j == 0){
                ans = diff/j;
                t = j;
            }
        }
        printall(0,0,ss+1,ans,t,ss+1);
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int k;
	scanf("%d", &k);
	int oddNumber=0,evenNumber=0;
	if(k%2)
		oddNumber=k/2+1,evenNumber=k/2;
	else
		oddNumber=evenNumber=k/2;
	printf("%d\n", oddNumber*evenNumber);
	
	return 0;
}

Measured memory_bytes: 128
import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  val nums = readLine.trim.split(' ').map(_.toInt).zipWithIndex.groupBy(_._1).toArray.sortBy(_._1).map(_._2.map(_._2))
  val countBit = new CountBit(n)
  var count = 0L
  for (indices ← nums) {
    for (i ← indices) countBit.increment(i)
    val rest = n - countBit.apply(n - 1)
    for (i ← indices) {
      val left = i + 1 - countBit(i)
      val right = rest - left
      count += Math.min(left, right)
    }
  }
  println(count)

  class CountBit(size: Int) {
    private val array: Array[Int] = Array.fill(size){0}
    def increment(position: Int): Unit = {
      if (position < size){
        array(position) += 1
        increment(position + ((position + 1) & ~position))
      }
    }
    def apply(position: Int): Int = {
      if (position >= 0){
        array(position) + apply(position - ((position + 1) & ~position))
      }else 0
    }
  }
}


Measured memory_bytes: 220964
use std::io::*;
use std::str::FromStr;

use std::cmp::max;


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut v: Vec<i32> = (0..n).map(|_| read()).collect();
    let mut c: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut ans = 0;

    for i in 0..n {
        let hoge = v[i] - c[i];
        if hoge > 0 { ans += hoge };
    }
    
    println!("{}", ans);
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int K;	cin>>K;
	string S;	cin>>S;
	if(S.size()<=K)	cout<<S<<endl;
	else{
		FOR(i,0,K)	cout<<S[i];
		cout<<"..."<<endl;
	}


    return 0;
}




Measured memory_bytes: 3656
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*d++;printf("%d\n",s)){for(memset(z,t=9,2e4);s--;)for(j=i=d;--i;a&&*p>a?*p=a,*z[t]>a?t=i:0:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;d+~i++;t=a)for(s+=*z[t],*z[t]=0,a=j=d;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

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

    int d = b - a;

    if (d % 2 == 1) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int n = console.nextInt();		//number of boxes
		int m = console.nextInt();		//number of operations
		console.nextLine();
		int[] numBalls = new int[n];
		boolean[] couldHaveRed = new boolean[n];
		//intialize boxes
		for(int i = 0; i < n; i++) {
			numBalls[i] = 1;
			couldHaveRed[i] = false;
		}
		couldHaveRed[0] = true;
		
		for(int i = 0; i < m; i++) {
			int box1 = console.nextInt() - 1;	//to adjust for zero indexing
			int box2 = console.nextInt() - 1;
			console.nextLine();
			
			//if could have red ball
			if(couldHaveRed[box1]) 
				couldHaveRed[box2] = true;
			numBalls[box2]++;		//box 2 gains a ball
			numBalls[box1]--;		//box 1 loses a ball
			if(numBalls[box1] == 0)
				couldHaveRed[box1] = false;
		}
		
		int numPossible = 0;
		for(int i = 0; i < n; i++)
			if(couldHaveRed[i])
				numPossible++;
		System.out.println(numPossible);
		
	}
}

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

using namespace std;
typedef         long long int   ll;


#define         input           freopen("input.txt","r",stdin)
#define         output          freopen("output.txt","w",stdout)
#define         si(a)           scanf("%d",&a)
#define         sii(a,b)        scanf("%d%d",&a,&b)
#define         siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define         pi(a)           printf("%d",a)
#define         spc             printf(" ")
#define         bl              printf("\n")
#define         here(a)         printf("#### %d ####",a)
#define         pii             pair<int,int>
#define         fr(i,n)         for(int i=0;i<n;i++)
#define         case(num)       printf("Case %d:",num)
#define         inf             1000000050
#define         MAX             500020




int main(){

    //input;
    //output;

    int n,mx,cmx;

    cin>>n;
    vector<int>v(n);

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

    }

    ll sum = 0;
    int d;
    for(int i=1;i<n;i++){
        if(v[i]<v[i-1]){
            d = v[i-1]-v[i];
            sum += d;
            v[i]+= d;
        }
    }

    cout<<sum<<endl;

    return 0;
}
/**
*/


Measured memory_bytes: 4024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
const long long maxn = 1e6;
struct Node{
	int ai,bi;
}node[maxn];
bool cmp(Node a,Node b)
{
	if(a.bi == b.bi) return a.ai < b.ai;
	return a.bi < b.bi;
}
int main(void)
{
	scanf("%d",&n);
	for(int i = 1;i<=n;i++)
		scanf("%d %d",&node[i].ai,&node[i].bi);
	sort(node+1,node+1+n,cmp);
//	int ans = 0;
//	for(int i = 1;i<=n;i++)
//	{
//		if((ans + node[i].ai) <= node[i].bi) ans += node[i].ai;
//		else{
//			puts("NO");
//			return 0;
//		}
//	}
//	puts("Yes");
	int t=0;
	for(int i=1;i<=n;i++)
	{
		if(t+node[i].ai<=node[i].bi)
			t+=node[i].ai;	
		else
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1792
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	sort(ALL(a)); reverse(ALL(a));

	ll A = 0, B = 0;
	rep(i, N) {
		if (i % 2 == 0) A += a[i];
		else B += a[i];
	}

	cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[100];

int main(){
	int n; scanf("%d%s", &n, s);
	int ans = 0;
	REP(i, n-2){
		if(s[i] == 'A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++;
		}
	}
	printf("%d\n", ans);
}


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

int main()
{
    int N;
    cin >> N;
    ll C[N+2], S[N+2], F[N+2];
    for(int i = 0; i < N-1; ++i) cin >> C[i] >> S[i] >> F[i];

    for(int i = 0; i < N-1; ++i) {
        ll t = 0;
        t += S[i] + C[i];
        for(int j = i + 1; j < N-1; ++j) {
            if(t < S[j]) t = S[j];
            if(t % F[j]) t = (t/F[j] + 1)*F[j];
            t += C[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, Q; cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    rep(i, N) {
        ll tmp; cin >> tmp;
        fw.add(i, tmp);
    }
    rep(i, Q) {
        int t; cin >> t;
        if (t) {
            int l, r; cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
        else {
            ll p, x; cin >> p >> x;
            fw.add(p, x);
        }
    }
}


Measured memory_bytes: 8216
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

ll N,K;

ll dp[200000][101];

int main(){
    cin>>N>>K;
    ll BIG=N+1, SMALL=0;
    while(BIG>SMALL+1){
        ll MID=(BIG+SMALL)/2;
        if(MID*MID>N) BIG=MID;
        else SMALL=MID;
    }
    ll n=SMALL*2;
    if(SMALL*BIG>N) n--;
    //cout<<"n=="<<n<<endl;
    vec x(n+1,0);
    rep(i,SMALL+1) dp[i][0]=i;
    REP(i,SMALL+1,n+1) dp[i][0]=N/(n+1-i);
    REP(i,1,K){
        REP(j,1,n+1) dp[j][i]=(dp[j-1][i]+(dp[j][0]-dp[j-1][0])*dp[n+1-j][i-1])%mod;
    }
    /*rep(i,K){
        cout<<i+1<<':';
        REP(j,1,n+1) cout<<dp[j][i]<<' ';
        cout<<endl;
    }
*/    cout<<dp[n][K-1]<<endl;




    

}

Measured memory_bytes: 53512
function Main(inp) {
    var input = inp.split('\n')[0].split(' ').map(function(n) {
        return Number(n);
    });
    var number = input[0];
    var colors = input[1];
    var patterns = colors * Math.pow(colors - 1, number - 1); 
    console.log(patterns);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7880
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	else if (b == c) {
		cout << a << endl;
	}
	else {
		cout << b << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,x;cin>>n>>x;
    vector<ll>ans(2*n);
    if(x==1||x==2*n-1){
        cout<<"No"<<endl;
    }else{
        set<ll>st;
        ans[n]=x;
        ans[n-1]=x-1;
        ans[n+1]=x+1;
        st.insert(x);
        st.insert(x+1);
        st.insert(x-1);
        ll l=1;
        REP(i,1,2*n){
            if(ans[i])continue;
            while(st.find(l)!=st.end()){
                l++;
            }
            ans[i]=l;
            st.insert(l);
        }
        cout<<"Yes"<<endl;
        REP(i,1,2*n){
            cout<<ans[i]<<endl;
        }
    }
}

Measured memory_bytes: 12416
loop do
  n = gets.to_i
  break if n==0
  ts = Array.new
  n.times{
    ts << gets.to_i
  }
  if n==1
    puts 0
    next
  end
  ts.sort!
  wt = (0..n-2).inject([0]){|seq,i| seq<<(seq[i]+ts[i])}
  total = wt.inject{|x,y| x+y}
  puts total
end

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  long long n, k;
  cin >> n >> k;
  
  while (n >= abs(n - k)) {
    long long m = n / k;
    if (m > 0) {
        n -= m * k;
    } else {
	    n = abs(n - k);
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s_list = []
for i in range(h):
    s_list.append(input())

for i in range(h):
    for j in range(w):
        if s_list[i][j] == '#':
            flag = False
            for dy in range(-1, 2):
                for dx in range(-1, 2):
                    # 自分自身は無視
                    if dy == 0 and dx == 0:
                        continue
                    # 上下左右に限定(斜めは無視)
                    if dy == 0 or dx == 0:
                        ny = dy + i
                        nx = dx + j
                        # 端っこは無視
                        if ny < 0 or nx < 0 or ny >= h or nx >= w:
                            continue
                        # 1つでも#あれば探索完了
                        if s_list[ny][nx] == '#':
                            flag = True
                            break
                if flag:
                    break
            # 上下左右で#がない#のマスがあればそこで終了
            if not flag:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 3064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
#include <assert.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };

ll x;

int main() {
	cin >> x;
	ll MA = 6207;
	for (ll i = -MA; i <= MA; i++) {
		for (ll j = -MA; j <= MA; j++) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {


	var X int

	fmt.Scan(&X)

	sum := 100

	cnt :=0

	for{

		sum =  int(float64(sum) + float64(sum)*0.01)
		cnt++


		if sum >=X{
			break

		}

	}
	fmt.Println(cnt)
}

Measured memory_bytes: 1752
N,A[999][1000],id[1000],used[1000];
i,j;day;flag=2;
main(){
	for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);
	for(;flag&2;)
		for(flag=1,i=!++day;i<N;++i)
			used[i]<day&id[i]<N-1&&id[flag&=2,j=A[id[i]][i]-1]<N-1&&used[j]<day&A[id[j]][j]==i+1&&++id[used[i]=used[j]=day,++id[i],flag=2,j];
	printf("%d",flag*day-1);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int cnt[1000005],a[1000005];
signed main() {
	cin>>a[1];
	cnt[a[1]]++;
	for(int i=2;;i++){
		if(a[i-1]%2)a[i]=a[i-1]*3+1;
		else a[i]=a[i-1]/2;
		cnt[a[i]]++;
		if(cnt[a[i]]==2){
			cout<<i<<endl;
			return 0;
		}
	}
}



Measured memory_bytes: 2304
//Matrix Chain Multiplication
#include <iostream>
#include <climits>

using namespace std;

int matrixChainMultiplication(int p[], int n) {
    int dp[n+1][n+1];
    for(int i = 0; i < n + 1; i++) dp[i][i] = 0;
    for(int l=2; l<n+1; l++) {
        for(int i=1; i<n-l+2; i++) {
            int j = i+l-1;
            dp[i][j] = INT_MAX;
            for(int k=i+1; k<j+1; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k-1] + dp[k][j] + p[i - 1] * p[k - 1] * p[j]);
            }
        }
    }
    return dp[1][n];
}

int main() {
    int n, r, c;
    cin >> n;
    int p[n+1];
    for(int i=0; i<n; i++) {
        cin >> r >>  c;
        if(i == 0) p[0] = r;
        p[i+1] = c;
    }

    cout << matrixChainMultiplication(p, n) << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    n -= 1000;
    if(n<0){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (U == S) cout << A - 1 << " " << B << endl;
  else cout << A << " " << B - 1 << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();

  if(s[0] != '1' || s[n-1] != '0') {
    cout << -1 << endl;
    return 0;
  }

  for(int i = 2; i < n-1; ++i) if(s[i-1] != s[n-i-1]) {
    cout << -1 << endl;
    return 0;
  }

  s.back() = '1';

  set<int> st;
  rep(i, n) if(s[i] == '1') st.insert(i+1);

  rep(i, n-1) cout << i+1 << " " <<  *st.upper_bound(i+1) << endl;
  
}

Measured memory_bytes: 8396
N = [int(s) for s in input()]
n = len(N)
a = 0
b = 11
for n in N:
    a1 = min(a+n, b+n)
    b1 = min(a+11-n, b+9-n)
    a = a1
    b = b1
print(min(a,b))

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

signed main() {
  int n, m, l, r; cin >> n >> m;
  int max_l = 1, min_r = n;

  int res = 0;
  for(int i = 0; i < m; i++) {
    cin >> l >> r;
    max_l = max(max_l, l);
    min_r = min(min_r, r);
  }

  cout << (min_r >= max_l ? (min_r - max_l + 1) : 0) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h,n;
    cin>>h>>n;
    vi a(n);
    ll sum = 0;
    REP(i,n) {
        cin>>a[i];
        sum += a[i];
    }

    if(sum>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

int main(){
  int P[100010];
  int K[100010];
  int T[100010];
  for(int i=0;i<100009;i++){
    P[i]=1;
    K[i]=0;
    T[i]=0;
  }

  for(int i=2;i<1005;i++){
    for(int j=2;j<100010/i+1;j++){
      P[i*j]=0;
    }
  }
  P[1]=1;
  P[2]=1; 
  
  for(int i=0;i<100010;i++){
    if(P[i]==1 && P[(i+1)/2]==1){
      K[i]=1;
    }
  }
  
  int temp=0;
  T[0]=0;
  T[1]=0;
  T[2]=0;  
  for(int i=3;i<100010;i++){
    T[i]=temp+K[i];
    temp=T[i];
  }

    
  int Q;
  cin>>Q;
  int l,r;
  for(int i=0;i<Q;i++){
    cin>>l>>r;
    cout<<T[r]-T[l-1]<<endl;
  }
      
  /*for(int i=1;i<20;i++){
    cout<<i<<" "<<T[i]<<endl;
  }*/
  
  //cout<<T[1]<<" "<<T[53]<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r * 2 * Math.PI);
        }
    }
}


Measured memory_bytes: 27584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll dp[n]={0};
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	// if(n>=2)
	for(ll i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		// cout<<dp[i]<<" ";
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i,M) cin >> B[i];
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
        cin >> A[i][j];
        }
    }
    int ans = 0;
    rep(i,N) {
        int sum = 0;
        rep(j,M){
            sum += A[i][j]*B[j];
        }
        sum += C;
        if(sum > 0) ans++;
    }

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



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 100001;

vl A;
vl B;

ll inv(){
    ll ans = 0;
    rep(c1,0,n){
        rep(c2,c1+1,n){
            if(A[c1] > A[c2])ans++;
        }
    }
    return ans;
}

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> n >> k;
    rep(c1,0,n){
        cin >> a;
        A.push_back(a);
    }

    ll st = 0;
    rep(c1,0,n){
        rep(c2,0,n){
            if(A[c2] < A[c1])st++;
        }
    }

    cout << ((inv()*k)%big + (((k-1)*k)/2)%big * st%big)%big << "\n";

    return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

func main() {
  // fmt.Println("Input: ")
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var a int
  var b int
  for {
    // Get first number
    if sc.Scan() { a, _ = strconv.Atoi(sc.Text()) }

    // Get second number
    if sc.Scan() { b, _ = strconv.Atoi(sc.Text()) }

    // finish condition
    if a == 0 && b == 0 { break }

    // Output with swqpped if necessary
    if a > b {
      fmt.Printf("%d %d\n", b, a)
    } else {
      fmt.Printf("%d %d\n", a, b)
    }
  }
}



Measured memory_bytes: 1096
#include<stdio.h>

int main(void){

	double w;

	while(scanf("%lf",&w)!=EOF){

		if(w > 91.0)
			puts("heavy");
		else if(w > 81.0)
			puts("light heavy");
		else if(w > 75.0)
			puts("middle");
		else if(w > 69.0)
			puts("light middle");
		else if(w > 64.0)
			puts("welter");
		else if(w > 60.0)
			puts("light welter");
		else if(w > 57.0)
			puts("light");
		else if(w > 54.0)
			puts("feather");
		else if(w > 51.0)
			puts("bantam");
		else if(w > 48.0)
			puts("fly");
		else
			puts("light fly");

	}

	return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    map<int, int> m;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        m[a]++;
    }
    vector<int> v;
    transform(m.begin(),m.end(),back_inserter(v),[](auto p){return p.second;});
    sort(v.begin(), v.end());
    if((int) v.size()-K<=0){
        cout << 0 << endl;
    } 
    else{
        cout << accumulate(v.begin(), v.end()-K, 0LL) << endl;
    }     
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<tuple<ll, ll, ll>> items;
    for (int i = 0; i < N; ++i) {
        ll x, y, h;
        cin >> x >> y >> h;
        items.push_back(make_tuple(x, y, h));
    }

    for (ll i = 0; i <= 100; ++i) {
        for (ll j = 0; j <= 100; ++j) {
            ll H = 0;
            bool flag = true;
            for (int k = 0; k < N; ++k) {
                ll x = get<0>(items[k]);
                ll y = get<1>(items[k]);
                ll h = get<2>(items[k]);
                if (h != 0 && H == 0) {
                    H = h + abs(x - i) + abs(y - j);
                }
            }
            for (int k = 0; k < N; ++k) {
                ll x = get<0>(items[k]);
                ll y = get<1>(items[k]);
                ll h = get<2>(items[k]);
                if (h == max(0LL, H - abs(x - i) - abs(y - j))) {
                    continue;
                }else{
                    flag = false;
                }
            }
            if (flag && H >= 1) {
                cout << i << " " << j << " " << H << endl;
                return;
            }
        }
    }

}

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


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

typedef long long ll;
#define REP(i,n) for(int(i)=0;(i)<(n);++(i))

int main () {
  ll x, y;
  cin >> x >> y;
  if (x == 0) {
    if (y > 0) cout << y;
    else cout << -y + 1;
    return 0;
  }
  if (y == 0) {
    if (x > 0) cout << x + 1;
    else cout << -x;
    return 0;
  }
  
  if(abs(x - y) > abs(x + y)) {
    if (x + y > 0) cout << x + y + 1;
    else cout << -(x + y) + 1;
  } else {
    if (x - y > 0) cout << x - y + 2;
    else cout << -(x - y);
  } 
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 10;
int n , m;
int cnt[3];

main(){
	cin >> n;
	rep(i , 1 , n){
		int x;
		cin >> x;
		cnt[x%2]++;
	}				
	cnt[0] += cnt[1] / 2;
	cnt[1] %= 2;
	if(cnt[1] == 0)
		ret("YES");
	ret("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100+10;
int a[MAXN*MAXN];
int col[MAXN][MAXN];
int main()
{
    int H,W;
    int N;
    scanf("%d%d%d",&H,&W,&N);
    int now=1;
    for(int i=1;i<=N;i++)    scanf("%d",a+i);
    for(int i=1;i<=H;i++)
    {
        for(int j=(i%2==1)?1:W;(i%2==1)?j<=W:j>=1;(i%2==1)?j++:j--)
        {
            while(a[now]==0)    now++;
            col[i][j]=now;
            a[now]--;
        }
    }
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            printf("%d",col[i][j]);
            if(j!=W)    printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
/***
 *          ___           ___
 *         /\  \         /\  \                                     _____
 *         \:\  \        \:\  \                                   /::\  \       ___           ___
 *          \:\  \        \:\  \                                 /:/\:\  \     /\__\         /\__\
 *      _____\:\  \   ___  \:\  \   ___     ___   ___     ___   /:/ /::\__\   /:/__/        /:/  /
 *     /::::::::\__\ /\  \  \:\__\ /\  \   /\__\ /\  \   /\__\ /:/_/:/\:|__| /::\  \       /:/__/
 *     \:\~~\~~\/__/ \:\  \ /:/  / \:\  \ /:/  / \:\  \ /:/  / \:\/:/ /:/  / \/\:\  \__   /::\  \
 *      \:\  \        \:\  /:/  /   \:\  /:/  /   \:\  /:/  /   \::/_/:/  /   ~~\:\/\__\ /:/\:\  \
 *       \:\  \        \:\/:/  /     \:\/:/  /     \:\/:/  /     \:\/:/  /       \::/  / \/__\:\  \
 *        \:\__\        \::/  /       \::/  /       \::/  /       \::/  /        /:/  /       \:\__\
 *         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/
 *
 *      @author      : Dylan Dsouza (dsouzadyn@gmail.com)
 *      @created     : Saturday Feb 16, 2019 23:37:56 IST
 */
#include <bits/stdc++.h>

using namespace std;

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

  int n;
  cin >> n;
  vector<int> arr(n);
  for(int i = 0; i < arr.size(); i++) cin >> arr[i];
  sort(arr.begin(), arr.end(), greater<int>());
  int sum = 0;
  for(int i = 1; i < arr.size(); i++) sum += arr[i];
  if (arr[0] < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,K;
char ch[N];
string ans,cur,a,b;
string calc(string &a,int k){
	int cnt=0;
	for (cnt=0;(cnt<n)&&(a[cnt]==a[0]);cnt++);
	string ret;
	for (int i=1;i<=n;i++)
	ret+=(i<=(cnt<<k)) ? a[0] : a[i-(cnt<<k)+cnt-1];
	return ret;
}
int main(){
	n=read();K=read();
	scanf(" %s",ch+1);
	if ((K>=20)||((1<<(K-1))>=n)){
		char c=ch[1];
		for (int i=1;i<=n;i++) c=min(c,ch[i]);
		for (int i=1;i<=n;i++) putchar(c);
		puts("");
		return 0;
	}
	for (int i=n;i;i--) b+=ch[i];
	cur=b;
	ans=calc(cur,K);
	for (int i=n;i;i--){
		b=ch[i]+b;
		cur=min(cur,b);
	}
	ans=min(ans,calc(cur,K-1));
	for (int i=0;i<n;i++) putchar(ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    ll count = 0;
    rep(i, n) {
        if (a[i] < b[i]) {
            count += (b[i] - a[i]) / 2;
        } else {
            count += b[i] - a[i];
        }
    }
    if (count >= 0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    reverse(all(s));
    int x = 1;
    int tot = 0;
    vector<int> cnt(2019);
    ll ans = 0;
    rep(i, n) {
        cnt[tot]++;
        tot += (s[i] - '0') * x;
        tot %= 2019;
        ans += cnt[tot];
        x = x * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3728
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/

void solve(){
    int a, b;
    cin >> a >> b;
    rep(i, 0, 101){
        rep(j, 0, 101){
            if(i+j == a and 2*i + 4*j == b){
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3688
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#define MAX_V 10000

using namespace std;

typedef pair<int, int> P;

vector<int> G[MAX_V];
int C[MAX_V];

int assign[MAX_V];

void dfsCalcEdgeCost( int v, int parent, int &cidx )
{
    assign[v] = C[cidx++];

    for ( auto to : G[v] )
    {
        if ( to == parent ) continue;

        dfsCalcEdgeCost( to, v, cidx );
    }
}

long long calcCost( int v, int parent )
{
    long long cost = 0;
    for ( auto to : G[v] )
    {
        if ( to == parent ) continue;

        cost += min( assign[to], assign[v] );
        cost += calcCost( to, v );
    }
    return cost;
}

int main( int argc, char **argv )
{
    // input
    int N;
    cin >> N;

    for ( int i = 0; i < N - 1; i++ )
    {
        int a, b;
        cin >> a >> b;

        G[a - 1].push_back( b - 1 );
        G[b - 1].push_back( a - 1 );
    }

    for ( int i = 0; i < N; i++ ) cin >> C[i];

    // solve
    sort( C, C + N, [&]( int a, int b ) { return a > b; } );

    int cidx = 0;
    dfsCalcEdgeCost( 0, -1, cidx );

    long long cost = calcCost( 0, -1 );
    cout << cost << endl;

    for ( int i = 0; i < N - 1; i++ ) cout << assign[i] << " ";
    cout << assign[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    long long a,b;  cin>>a>>b;
    double num=(double)a/(double)b;
    cout<<a/b<<" "<<a%b<<" "<<fixed<<setprecision(5)<<num<<endl;
}


Measured memory_bytes: 3300