akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#ifdef _DEBUG
#define dbg(x) cerr << #x << ":" << x << endl;
#else
#define dbg(x) while(false){}
#endif

#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)

////////

int const M = 20;
int const N = (1<<M);
string const YES = "Possible";
string const NO = "Impossible";

int n, v, x[N];
int le[N][M], ri[N][M];
int cnt;
string ans[N];

void setAns(string val, int l, int r){
	fi(l, r+1) ans[i] = val;
}

void print(){
	fi(1, n+1) printf("%s\n", ans[i].c_str());
	exit(0);
}

void check(){
	int cn = cnt + 1;
	int v = 1;
	while(v <= n){
		v = ri[v][0] + 1;
		--cn;
	}
	if(cn < 0){
		setAns(NO, 1, n);
		print();
	}
}

void build(){
	int vi = v;
	fi(0, M){
		cnt = i;
		le[1][i] = 1;
		fj(2, n+1){
			if(x[j] - x[j-1] <= vi) le[j][i] = le[j-1][i];
			else le[j][i] = j;
		}
		ri[n][i] = n;
		for(int j=n-1;j>0;--j){
			if(x[j+1] - x[j] <= vi) ri[j][i] = ri[j+1][i];
			else ri[j][i] = j;
		}
		if(vi == 0) break;
		vi /= 2;
	}
}

int dl[N], dr[N];

void remax(int &a, int b){
	a = max(a, b);
}

void remin(int &a, int b){
	a = min(a, b);
}

void calcDp(){
	dl[0] = 0;
	fi(0, (1<<cnt)){
		fj(0, cnt){
			if((1<<j)&i) continue;
			int nval = dl[i];
			if(nval != n){
				nval = ri[dl[i]+1][j+1];
			}
			remax(dl[((1<<j)^i)], nval);
		}
	}
	fi(0, (1<<cnt)) dr[i] = n+1;
	fi(0, (1<<cnt)){
		fj(0, cnt){ 
			if((1<<j)&i) continue;
			int nval = dr[i];
			if(nval != 1){
				nval = le[dr[i]-1][j+1];
			}
			remin(dr[((1<<j)^i)], nval);
		}
	}
}

void findAnswers(){
	int v, nxt;
	v = 1;
	while(v <= n){
		nxt = ri[v][0];
		bool can = false;
		fi(0, (1<<(cnt))){
			int maskL = i;
			int maskR = ( ((1<<(cnt))-1) ^ maskL );
			int lb = dl[maskL];
			int rb = dr[maskR];
			if(lb+1 >= v && rb-1 <= nxt){
				can = true;
				break;
			}
		}
		if(can){
			setAns(YES, v, nxt);
		}else{
			setAns(NO, v, nxt);
		}
		v = nxt + 1;
	}
}

void solve(){
	scanf("%d %d",&n,&v);
	fi(1, n+1) scanf("%d",&x[i]);

	build();
	dbg(cnt);
	check();
	calcDp();
	findAnswers();
	print();
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

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

int main()
{
  long long int ans=-1e18;
  long long int a,b,c,d;cin>>a>>b>>c>>d;
  long long int res=1;
  res=a*c;
  ans=max(ans,res);
  res=a*d;ans=max(ans,res);
  res=b*c;ans=max(ans,res);
  res=b*d;ans=max(ans,res);
  cout<<ans<<endl;
}

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

int U[2000][2000];
int D[2000][2000];
int L[2000][2000];
int R[2000][2000];
bool Map[2000][2000];
int main(){
	int H,W;
  cin>>H>>W;
	for(int i=0;i<H;i++){
		string S;
    cin>>S;
		for(int j=0;j<W;j++){
			if(S[j] == '#'){
				Map[i][j] = true;
			}
		}
	}
	for(int j=0;j<W;j++){
		if(!Map[0][j]){
			U[0][j] = 1;
		}
	}
	for(int i=1;i<H;i++){
		for(int j=0;j<W;j++){
			if(!Map[i][j]){
				U[i][j] = U[i-1][j]+1;
			}
		}
	}
	for(int j=0;j<W;j++){
		if(!Map[H-1][j]){
			D[H-1][j] = 1;
		}
	}
	for(int i=H-2;i>=0;i--){
		for(int j=0;j<W;j++){
			if(!Map[i][j]){
				D[i][j] = D[i+1][j]+1;
			}
		}
	}
	for(int i=0;i<H;i++){
		if(!Map[i][0]){
			L[i][0] = 1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=1;j<W;j++){
			if(!Map[i][j]){
				L[i][j] = L[i][j-1]+1;
			}
		}
	}
	for(int i=0;i<H;i++){
		if(!Map[i][W-1]){
			R[i][W-1] = 1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=W-2;j>=0;j--){
			if(!Map[i][j]){
				R[i][j] = R[i][j+1]+1;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans = max(ans,U[i][j]+D[i][j]+R[i][j]+L[i][j]-3);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 66688
#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 pair<ll,ll> pll;

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 DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,n;
pii pts[3252];

ll modinv(ll a){
  ll b=MOD-2, r=1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}
ll fact[252521], ifact[252521];
ll comb(ll a, ll b){
  return fact[a] * ifact[b] % MOD * ifact[a-b] % MOD;
}

ll dp[3252];

int main(){
  scanf("%d%d%d",&h,&w,&n);
  REP(i,n){
    int y,x;
    scanf("%d%d",&y,&x);--x;--y;
    pts[i] = pii(y,x);
  }
  sort(pts,pts+n);
  fact[0] = 1;
  FOR(i,1,252521)fact[i] = fact[i-1] * i % MOD;
  ifact[252521-1] = modinv(fact[252521-1]);
  FORR(i,1,252521)ifact[i-1] = ifact[i] * i % MOD;
  REP(i,n){
    int y = pts[i].first;
    int x = pts[i].second;
    dp[i] = MOD - comb(x+y,x);
    REP(j,i){
      int fy = pts[j].first;
      int fx = pts[j].second;
      if(fy<=y && fx<=x){
        dp[i] += MOD - comb(x-fx+y-fy,x-fx) * dp[j] % MOD;
        dp[i] %= MOD;
      }
    }
  }
  ll ans = comb(w-1+h-1,w-1);
  REP(i,n){
    int y = pts[i].first;
    int x = pts[i].second;
    ans += dp[i] * comb(w-1-x+h-1-y,w-1-x) % MOD;
    ans %= MOD;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4352
<?php
fscanf(STDIN, "%s", $n);
echo ex($n, "1", "9");

function ex($str, $a, $b) {
    if ($a != "1" && $b != "1") {
        $x = "1";
    }
    if ($a != "2" && $b != "2") {
        $x = "2";
    }
    if ($a != "3" && $b != "3") {
        $x = "3";
    }
    $str = str_replace($a, $x, $str);
    $str = str_replace($b, $a, $str);
    $str = str_replace($x, $b, $str);
    return $str;
}


Measured memory_bytes: 4728
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> count(4,0);
    for(ll i=0;i<N;++i){
        string S;
        cin >> S;
        if(S=="AC")count[0]++;
        else if(S=="WA")count[1]++;
        else if(S=="TLE")count[2]++;
        else count[3]++;
    }
    cout<<"AC x "<<count[0];cout<<endl;
    cout<<"WA x "<<count[1];cout<<endl;
    cout<<"TLE x "<<count[2];cout<<endl;
    cout<<"RE x "<<count[3]<<endl;fl

    return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int h,w,a[52][52]={0};
  char s[52][52]={};
  cin >> h >> w;
  for(int i=1; i<=h; i++) {
    for(int j=1; j<=w; j++) {
      cin >> s[i][j];
      if(s[i][j]=='#') {
        a[i][j]=1;
      }
      else {
        a[i][j]=0;
      }
    }
  }
  for(int i=1; i<=h; i++) {
    for(int j=1; j<=w; j++) {
      if(a[i][j]==1) {
        cout << '#';
      }
      else {
        cout << a[i+1][j-1]+a[i+1][j]+a[i+1][j+1]+a[i][j-1]+a[i][j+1]+a[i-1][j-1]+a[i-1][j]+a[i-1][j+1];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,a,b;string s,op,p;cin>>s>>n;
    for(int i=0;i<n;i++){
        cin>>op;
        if(op=="print"){
            cin>>a>>b;
            for(int i=a;i<b+1;i++) cout<<s[i];
            cout<<'\n';
        }
        else if(op=="reverse"){
            cin>>a>>b;int m=b-a+1;
            string re=s.substr(a,m);
            for(int i=0;i<m;i++){
                s[a+i]=re[m-i-1];
            }
        }
        else {
            cin>>a>>b>>p;
            s.replace(a,b-a+1,p);
        }
    }
}


Measured memory_bytes: 3236
# frozen_string_literal: true

w, h, x, y, r = gets.split(' ').map(&:to_i)

# x-axis
x_edge = 0..w
x_include = x_edge.include?(x-r) && x_edge.include?(x+r)

# y-axis
y_edge = 0..h
y_include = y_edge.include?(y-r) && y_edge.include?(y+r)

puts x_include && y_include ? :Yes : :No


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

    class Program2
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var nodes = new List<int[]>();
            for (int i = 0; i < input[0]; i++)
                nodes.Add(Console.ReadLine().Split(' ').Select(k => int.Parse(k)).ToArray());

            var ans = 0;
            var x = 0d;
            for (int i = 0; i < input[0]; i++)
            {
                for (int j = i+1; j < input[0]; j++)
                {
                    x = Math.Sqrt(Pow(nodes[i], nodes[j]));
                    if (x == (int) x)
                        ans++;
                }
            }
            Console.WriteLine(ans);
        }

        static int Pow(int[] a, int[] b)
        {
            var x = 0;
            for (int i = 0; i < a.Length; i++)
            {
                x += (int) Math.Pow(Math.Abs(a[i] - b[i]), 2);
            }
            return x;
        }
    }

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, std::vector<long long> X){
    if(M <= N) {
        cout << 0 << endl;
        return ;
    }
    sort(ALL(X));
    VI diff;
    REP(i, X.size()-1){
        diff.PB(X[i+1] - X[i]);
    }

    sort(ALL(diff));
    int ans = 0;
    REP(i, diff.size() - N + 1){
        ans += diff[i];
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, M, std::move(X));
    return 0;
}


Measured memory_bytes: 1660
n=int(input())
dic={}
a=[]
b=[]
for i in range(n):
	tmp1,tmp2=input().split()
	a.append(tmp1)
	b.append(tmp2)

for i in range(n):
	if a[i]=='insert':
		dic[b[i]]=1
	else:
		if b[i] in dic:
			print("yes")
		else:
			print("no")


Measured memory_bytes: 152804
import Data.List


main = do
    [x1, y1, x2, y2] <- map read . words <$> getLine
    let positions = ans x1 y1 x2 y2
    putStrLn $ intercalate " " $ map show positions
    

ans x1 y1 x2 y2 = [x3, y3, x4, y4]
    where
        x4 = x1 + y1 - y2
        y4 = y1 + x2 - x1
        x3 = x2 + x4 - x1
        y3 = y2 + y4 - y1


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int n,q,i;
int main()
{
	cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++)cin>>a[i];
	a.erase(unique(a.begin(),a.end()),a.end());
	for(i=0;i<a.size();i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    int a, b;
    cin >> a >> b;
    if( (a+b) % 2 == 0 ) cout << (a+b)/2 << "\n";
    else cout << ((a+b)/2)+1 << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long M = scan.nextLong();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong()/2;
        }
        long lcm = lcm(A);
        long count_odd = 0;
        long count_even = 0;
        for (int i = 0; i < N; i++) {
            long x = lcm / A[i];
            if (x % 2 == 0) {
                count_even += 1;
            } else {
                count_odd += 1;
            }
        }
        if (0 < count_even && 0 < count_odd) {
            System.out.println(0);
            return;
        }
        long answer = M / lcm;
        if (answer % 2 == 1) {
            answer += 1;
        }
        System.out.println(answer/2);
    }
    public long lcm(long[] T) {
        long current_lcm = T[0];
        for (int i = 0; i < T.length; i++) {
            current_lcm = lcm(T[i], current_lcm);
        }
        return current_lcm;
    }
    public long lcm(long x, long y) {
        long gcd = gcd(x, y);
        return x/gcd*y;
    }
    private long gcd(long x, long y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);

    }
}


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

string s;
int cnt=0;

int main(){
    cin>>s;

    for (int i = 0; i < 3; i++)
    {
        if(s[i] == 'o') cnt++;
    }

    cout << 700+100*cnt << endl;
    return 0;
    
}


Measured memory_bytes: 256
N, K = map(int, input().split())
Ps = list(map(int, input().split()))

s = 0
for i in range(K):
    s += 1 + Ps[i]

ans = s

for i in range(K, N):
    s = s - Ps[i-K] + Ps[i]
    ans = ans if ans > s else s

print(ans / 2)

Measured memory_bytes: 25060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> cnt(n);
    for (int i = 0; i < q; ++i) {
        int a;
        cin >> a;
        --a;
        ++cnt[a];
    }

    for (int i = 0; i < n; ++i) {
        cout << (k - q + cnt[i] > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
A=[]
for _ in range(K):
    d=int(input())
    A.append(list(map(int,input().split()))) #Aのリストをflattenしたい
print(N-len(set(sum(A,[])))) #[]にAの要素を積んでいくやりかた。なるほどなぁ

Measured memory_bytes: 67752
import java.util.*;
class Main{
	
    public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
    	String a=sc.next();
    	int c=0;
    	for(int i = 0;i < 3;i++){
    		if(a.charAt(i)=='1') {
    			c++;
    		}
    	}
    	System.out.println(c);
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readIntegerList() + 0
    val curve = BooleanArray(n + 1)
    for (i in 1 until aList.size) {
        if (aList[i - 1] == aList[i]) {
            curve[i] = curve[i - 1]
        } else {
            curve[i] = aList[i - 1] < aList[i]
        }
    }

    var m = 1000L
    var stock = 0L
    var ansm = m
    for (i in 0 until (n - 1)) {
        if (curve[i]) {
            if (curve[i + 1] == false) {
                m += aList[i] * stock
                stock = 0
            }
        } else {
            if (curve[i + 1] == true) {
                val tmp = m / aList[i]
                stock += tmp
                m -= tmp * aList[i]
            }
        }

        ansm = max(ansm, m)
    }

    m += stock * aList[n - 1]
    ansm = max(ansm, m)
    out.println(ansm)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)




Measured memory_bytes: 36420
n, a, b = list(map(int, input().split(' ')))

# 二項係数 mod [検索]
mmm = 1000000000 + 7
fac = []
inv = []
inv_fac = []
def init(n):
    fac.append(1)
    fac.append(1)
    inv.append(0)
    inv.append(1)
    inv_fac.append(1)
    inv_fac.append(1)
    for i in range(2, n):
        fac.append(fac[-1] * i % mmm)
        inv.append(mmm - inv[mmm%i] * (mmm // i) % mmm)
        inv_fac.append(inv_fac[-1] * inv[-1] % mmm)

def choice(a, b):
    if a < b:
        return 0
    v = 1
    for i in range(b):
        v = (v * (a-i)) % mmm  # 偶然通っていたけどここはnではなくa (eの途中で気づいた)
    return v * inv_fac[b]

init(int(2e5) + 1)


ans = pow(2, n, mmm) - 1  # v, e, mod
bunshi = 1
for i in range(a):
    bunshi = (bunshi * (n-i)) % mmm
ans -= choice(n, a)
ans -= choice(n, b)
print(ans % mmm)

'''
4, 1, 3 => 4c2 + 4c4 -> 6+1 = 7
4 + 6 + 4 + 1 - 4c1 - 4c2 
1        1
11       2
121      4
1331     8
14641   16, 0が無いので-1, 大きい combination -> 二項係数 mod [検索]
'''


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

int main() {
	int n, a, b, mn, mx;
	cin >> n >> a >> b;
	mn = a + b - n;
	mx = min(a, b);
	if (mn < 0) mn = 0;
	cout << mx << " " << mn << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x;
  cin>>n>>x;
  int c=0,d=0,ans=10000,a,b;
  int aa[n];
  rep(i,0,n) cin>>aa[i];
  sort(aa,aa+n);
  rep(i,0,n){
    x-=aa[i];
    if(x==0){
      c++;
      break;
    }
    else if(x>0) c++;
    else break;
  }
  if(x>0) c--;
    
  co(c);
  
  return 0;
}

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

int main(void){
  int n, i, j, a[N], mini, c=0;
  scanf("%d", &n);
 for(i=0; i < n; i++) scanf("%d", &a[i]);
  for(i=0; i < n; i++){
    mini = i;
    
    for(j=i; j < n; j++){
      if(a[j] < a[mini]) mini = j;
    }
    
    if(i != mini){
      swap(&a[i], &a[mini]);
      c++;
    }
    printf("%d", a[i]);
    if(i < n-1) printf(" ");  
  }


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

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

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char data[7][7];

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> data[i][j];
        }
    }

    int ans = 0;

    for(int hr = 0; hr < (1 << h); ++hr){
        for(int wr = 0; wr < (1 << w); ++wr){
            int black = 0;
            for(int i = 0; i < h; ++i){
                for(int j = 0; j < w; ++j){
                    if((((hr >> i) & 1) == 0) && (((wr >> j) & 1) == 0) && data[i][j] == '#'){
                        black++;
                    }
                }
            }
            if(black == k){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

int f(int n){
    if(n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int main(void)
{
    int s;
    cin >> s;
    vector<int> v;  
    v.push_back(s);
    REP(i, 1000000){
        int fi = f(v[i]);
        for (int x : v) {
            if(x == fi){
                cout << i + 2 << endl;
                return 0;
            }
        }
        v.push_back(fi);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
#define MAXN 300100
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int check(int x){
	int a = sqrt(x);
	if(a*a==x)return true;
	return false;
}

int32_t main(){
	int n,d;
	cin>>n>>d;
	int cord[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin>>cord[i][j];
		}
	}	
	int r=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int dist=0;
			for(int k=0;k<d;k++){
				dist+=(cord[i][k]-cord[j][k])*(cord[i][k]-cord[j][k]);
			}
			if(check(dist))r++;
		}
	}
	cout<<r<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
branch = dict()
a = []
b = []
for i in range(n+1):
	branch[i] = []
for i in range(m):
	atemp,btemp = map(int,input().split())
	a.append(atemp)
	b.append(btemp)
	branch[atemp].append(btemp)
	branch[btemp].append(atemp)

counter = 0
for i in range(m):
	check = True
	delindex1 = branch[a[i]].index(b[i])
	delindex2 = branch[b[i]].index(a[i])
	del branch[a[i]][delindex1]
	del branch[b[i]][delindex2]
	arrival = [0 for i in range(n+1)]
	q = [1]
	while len(q) >= 1:
		arrival[q[0]]=1
		for k in range(len(branch[q[0]])):
			if arrival[branch[q[0]][k]] == 0:
				q.append(branch[q[0]][k])
		q.pop(0)

	for k in range(1,n+1):
		if arrival[k] == 0:
			check = False
	if check==False:
		counter += 1
	branch[a[i]].append(b[i])
	branch[b[i]].append(a[i])
print(counter)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 110000;
long long w[MAXN], v[MAXN], dp[111][MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int N, W;
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  for (int i = 1; i < MAXN; i++)
    dp[0][i] = INT32_MAX;
  for (int i = 1; i <= N; i++) {
    int q = i % 2;
    for (int j = 0; j < MAXN; j++) {
      dp[q][j] = INT32_MAX;
    }
    for (int j = 0; j < MAXN; j++) {
      dp[q][j] = min(dp[q][j], dp[!q][j]);
      if (j - v[i - 1] >= 0) {
        dp[q][j] = min(dp[q][j], dp[!q][j - v[i - 1]] + w[i - 1]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < MAXN; i++) {
    if (dp[N % 2][i] <= W) {
      ans = i;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3968
import sys
input = lambda : sys.stdin.readline().rstrip()

m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if len(str(j)) >= 2 and int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0])*int(str(j)[1]) == i:
            #print(i, j)
            ans += 1
print(ans)

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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
  string s;
  ll k;
  cin>>s>>k;
  ll n=s.size();
  auto dp1=vector<vector<ll>>(n+1,vector<ll>(k+1,0));
  auto dp2=vector<vector<ll>>(n+1,vector<ll>(k+1,0));
  REP(i,n)dp1[i+1][0]=1;
  dp2[0][0]=1;
  REP(i,n){
    REP(j,k){
      dp1[i+1][j+1]=
        s[i]=='0'
          ? dp1[i][j+1]
          + dp1[i][j]*9
          : dp1[i][j+1]+dp2[i][j+1] // <>0
          + dp1[i][j]*9 // <>(1-9)
          + dp2[i][j]*(s[i]-'0'-1);
      dp2[i+1][j+1]=s[i]=='0'?dp2[i][j+1]:dp2[i][j];
    }
  }
  cout<<(dp1[n][k]+dp2[n][k])<<endl;
}


Measured memory_bytes: 256
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]

child = [[] for _ in range(N+1)]
par = [0]*(N+1)

for ab in AB:
    a,b = ab[0], ab[1]
    child[a].append(b)
    par[b] = a

k = 0
for i in range(1,N+1):
    l = len(child[i])
    if par[i] > 0:
        l += 1
    k = max(k, l)

print(k)
col = [0] * (N+1)
col[1] = 1
for i in range(1, N):
    cnt = 0
    for c in child[i]:
        cnt += 1
        col[c] = (col[i] + cnt) % k

for ab in AB:
    b = ab[1]
    print(col[b] + 1)


Measured memory_bytes: 77016
// agc039_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;
    ll K;
    cin >> K;
    ll n = S.size();

    ll ans = 0;
    if (S[0] == S[n-1]){

        ll tmp1=1, tmp2=1;
        {
            int i = 0;
            while(i < n-1 && S[i] == S[i+1]){
                tmp1++;
                i++;
            }

            if (i == n - 1) {
                print((n * K) / 2);
                return 0;
            }

            i = n-1;
            while(i > 0 && S[i] == S[i-1]){
                tmp2++;
                i--;
            }

            ans += ((tmp1 + tmp2) / 2) * (K-1);
            ans += tmp1 / 2;
            ans += tmp2 / 2;
        }

        REPN(i, tmp1, n-tmp2){
            if (S[i] == S[i+1]){
                ll tmp = 1;
                while(S[i] == S[i+1] && i < n){
                    tmp++;
                    i++;
                }
                ans += (tmp / 2) * K;
            }
        }

    } else {
        REP(i, n){
            if (S[i] == S[i+1]){
                ll tmp = 1;
                while(S[i] == S[i+1] && i < n){
                    tmp++;
                    i++;
                }
                ans += (tmp / 2) * K;
            }
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL N,L;cin>>N>>L;
    LL a[N];REP(i,N)cin>>a[i];

    int remain=-1;
    REP(i,N-1){
        if(a[i]+a[i+1]>=L)remain=i+1;
    }
    if(remain>0){
        cout<<"Possible"<<endl;
        for(int i=1;i<remain;i++)cout<<i<<endl;
        for(int i=N-1;i>remain;i--)cout<<i<<endl;
        cout<<remain<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }


    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

const i64 MOD = 1e9 + 7;

struct int_m {
    static int64_t mod;
    int64_t v;
    int_m() {}
    int_m(int64_t x) : v(x) {}
    int_m operator+(const int_m &y) { return (v + y.v) % mod; }
    int_m operator-(const int_m &y) { return (v - y.v + mod) % mod; }
    int_m operator*(const int_m &y) { return (v * y.v) % mod; }
    void operator+=(const int_m &y) { *this = *this + y; }
    void operator-=(const int_m &y) { *this = *this - y; }
    void operator*=(const int_m &y) { *this = *this * y; }
    friend istream &operator>>(istream &ist, int_m &m) { return ist >> m.v; }
    friend ostream &operator<<(ostream &ost, int_m &m) { return ost << m.v; }
};

int64_t int_m::mod = MOD;

const i64 INF = 2e18;

int main() {
    int N;
    cin >> N;
    i64 A, B;
    cin >> A >> B;
    vector<i64> S(N);
    for(auto &x : S) cin >> x;
    vector<int_m> dp_x(N + 1, 0), dp_y(N + 1, 0),
        S_x(N + 1, 0), S_y(N + 1, 0);
    vector<int> y_min(N), y_max(N), x_min(N), x_max(N);
    for(int b = 0; b < 2; b++) {
        for(int i = 0; i < N; i++) {
            y_min[i] = max(i, i ? y_min[i - 1] : 0);
            y_max[i] = max(i, i ? y_max[i - 1] : 0);
            while (y_min[i] < N - 1 &&
                S[y_min[i] + 1] - (i ? S[i - 1] : -INF) < B) y_min[i]++;
            while (y_max[i] < N - 1 &&
                S[y_max[i] + 1] - S[y_max[i]] >= A) y_max[i]++;
        }
        swap(y_min, x_min);
        swap(y_max, x_max);
        swap(A, B);
    }
    dp_x[N] = dp_y[N] = S_x[N] = S_y[N] = 1;
    for(int i = N - 1; i >= 0; i--) {
        if(y_min[i] <= y_max[i])
            dp_x[i] = S_y[y_min[i] + 1] - (y_max[i] + 2 <= N ? S_y[y_max[i] + 2] : 0);
        if(x_min[i] <= x_max[i])
            dp_y[i] = S_x[x_min[i] + 1] - (x_max[i] + 2 <= N ? S_x[x_max[i] + 2] : 0);
        S_x[i] = dp_x[i] + S_x[i + 1];
        S_y[i] = dp_y[i] + S_y[i + 1];
    }
    int_m ans = dp_x[0] + dp_y[0];
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n,l;
	scanf("%d %d",&n, &l);
	int i,j;
	char array[n][l+1];
	for (i=0;i<n;i++)
	{
		scanf("%s",array[i]);
	}
	for (i=0;i<n-1;i++)
	{
		for (j=0;j<n-i-1;j++)
		{
			if (strcmp(array[j],array[j+1])>0)
			{
				char temp[l];
				strcpy(temp,array[j]);
				strcpy(array[j],array[j+1]);
				strcpy(array[j+1],temp);
			}
		}
	}
	for (i=0;i<n;i++)
	{
		printf("%s",array[i]);
	}
	return 0;
	
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> v(N, 0);
    for(int i=0; i<N; i++)
    {
        string s;
        cin >> s;
        if(s == "AC") v[0]++;
        else if(s == "WA") v[1]++;
        else if(s == "TLE") v[2]++;
        else v[3]++;
    }
    
    cout << "AC x " << v[0] << endl;
    cout << "WA x " << v[1] << endl;
    cout << "TLE x " << v[2] << endl;
    cout << "RE x " << v[3] << endl;
}


Measured memory_bytes: 3800
from fractions import gcd

a, b, c, d = map(int, input().split())
a-=1

def lcm(x, y):
    return (x * y) // gcd(x, y)


l = lcm(c, d)
la = a // l
lb = b // l
aa = a // c + a // d - la
bb = b // c + b // d - lb


print((b - a) - (bb - aa))


Measured memory_bytes: 5076
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

typedef pair<int, ll_ll> P;

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		list<P> l;
		l.push_back(P(-1, ll_ll(0, LLONG_MAX)));
		while (N--) {
			/*for (list<P>::iterator it = l.begin(); it != l.end(); it++) {
				int& i = it->first;
				ll& a = it->second.first, b = it->second.second;
				cout << i << ' ' << a << ' ' << b << endl;
			}*/
			string s; cin >> s;
			if (s == "W") {
				int I, S; cin >> I >> S;
				for (list<P>::iterator it = l.begin(); S > 0; it++) {
					int& i = it->first;
					ll& a = it->second.first, b = it->second.second;
					if (i >= 0) continue;
					if (b - a <= S) {
						i = I;
						S -= b - a;
					}
					else {
						l.insert(it, P(I, ll_ll(a, a + S)));
						a += S;
						S = 0;
					}
				}
			}
			else if (s == "D") {
				int I; cin >> I;
				for (list<P>::iterator it = l.begin(); it != l.end(); it++) {
					int& i = it->first;
					ll& a = it->second.first, b = it->second.second;
					if (i == I) i = -1;
				}
			}
			else if (s == "R") {
				int p; cin >> p;
				for (list<P>::iterator it = l.begin(); it != l.end(); it++) {
					int& i = it->first;
					ll& a = it->second.first, b = it->second.second;
					if (p >= a && p < b) {
						cout << (i >= 0 ? i : -1) << endl;
						break;
					}
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1424
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int buckets[256];
int main(int argc,char const* argv[])
{
  while(1)
    {
      int n,trues,truea,truec;
      int m=256;
      cin >> n;
      if(!n)break;
      vi l(n+5);
      vi r(n+5);
      vi o(n+5);
      for(int i=1;i<=n;i++)
	{
	  cin >> l[i];
	}
      double ans=1000;
      for(int s=0;s<=15;s++)
	{
	  for(int a=0;a<=15;a++)
	    {
	      for(int c=0;c<=15;c++)
		{
		  memset(buckets,0,sizeof(buckets));
		  for(int i=0;i<=n;i++)
		    {
		      if(i==0) r[i]=s;
		      else
			{
			  r[i]=(a*r[i-1]+c)%m;
			  o[i]=(l[i]+r[i])%m;
			  buckets[o[i]]++;
			}
		    }
		  double tmp=0;
		  for(int i=0;i<=255;i++)
		    {
		      if(buckets[i]!=0)
			{
			  tmp-=buckets[i]/(double)n*log(buckets[i]/(double)n);
			}
		    }
		  if(tmp+eps<ans)
		    {
		      ans=tmp;
		      trues=s;
		      truea=a;
		      truec=c;
		    }
		}
	    }
	}
      cout << trues << ' ' << truea << ' ' << truec << endl;
    }
  return 0;
}



Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#define maju 1919114514
using namespace std;

int main() {
	int a;
	bool yj = false;
	cin >> a;
	int c[4];
	for (int i = 0; i < 4; i++) {
		c[i] = a/pow(10, 3 - i);
		a -= c[i] * pow(10, 3 - i);
	}
	for (int i = 0; i < 3; i++) {
		if (c[i] == c[i + 1])yj = true;
	}
	if (yj)cout << "Bad" << endl;
	else cout << "Good" << endl;


	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define piii pair<int, pii >
#define ppp pair<pii, pii >
#define F first
#define S second
#define pb push_back
#define pp pop_back

const int P = 1000000007;

using namespace std;

int main(){

	string s, t;
	cin >> s >> t;
	if(s.size() <= 10 && s.size() > 0 &&
			t.size() == s.size()+1 && t.substr(0, s.size()) == s) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    for (ll i = 1; (ll)i*i <= x; ++i) {
        if (x % i == 0) {
            for (int j = -500; j <= 500; ++j) {
                int a = i + j;
                int b = j;
                if (pow(a,5)-pow(b, 5) == x) {
                    cout << a << " " << b << '\n';
                    return 0;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4060
use std::ascii::AsciiExt;

fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret
}

fn capslock(c: char) -> char {
    if c.is_uppercase() {
        c.to_ascii_lowercase()
    } else {
        c
    }
}

fn main() {
    let mut done: bool = false;
    let mut code_counts: Vec<u8> = vec![0; 26];
    while !done {
        let s = getline();

        if s == "" {
            done = true;
        } else {
            for c in s.chars().map(capslock) {
                let code = c as u8;
                if code >= b'a' && code <= b'z' {
                    code_counts[(code - b'a') as usize] += 1;
                }
            }
        }
    }
    for (index, code_count) in code_counts.iter().enumerate() {
        println!("{} : {}", ((index as u8) + b'a') as char, code_count);
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, a, b;
ll h[100010];

bool dekiru(ll x){
	ll kai=0;
	for(int i=1; i<=n; ++i){
		if((h[i]+b-1)/b<=x) continue;
		ll c=h[i]-b*x;
		kai += (c+a-1)/a;
	}
	return kai <= x;
}

int main()
{
	ll l=0, r=ll(1e18)+5;
	read(n, a, b); a-=b;
	for(int i=1; i<=n; ++i) read(h[i]);
	while(l+1 < r){
		ll mid=(l+r)/2;
		(dekiru(mid)?r:l)=mid;
	}
	printf("%lld\n", r);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = []
b = []

t = True
for i in input().split():
    if t:
        a.append(i)
    else:
        b.append(i)
    t = not t

if n % 2 == 0:
    print(" ".join(b[::-1] + a))
else:
    print(" ".join(a[::-1] + b))


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

long long MOD = 1e9 + 7;
string s;
long long pow10th[100002];
int n;
long long dp[100002][13];
long long solve(int in, int md) {

	if(in == n) return md==0;
	if(dp[in][md]!=-1) 
		return dp[in][md];
	long long ans =0;
	if(s[in]=='?') {
		int i;
		for(i=0;i<=9;i++){
			int x = ( (md - i*pow10th[n-1-in])%13 + 13)%13;
			ans+=solve(in+1, x);
			ans%=MOD;
		}
	} else {
		int d = s[in]-'0';
		int x = ( (md - d*pow10th[n-1-in])%13 + 13)%13;
		ans =  solve(in+1, x);
	}
	return dp[in][md] = ans;
}


void init(int n){
	int i, j;
	pow10th[0]=1;
	for(i=1;i<=n;i++){
		pow10th[i] = (pow10th[i-1]*10)%13;
	}
	for(i=0;i<=n;i++) 
		for(j=0;j<=12;j++)
			dp[i][j]=-1;
}
int main() {
	cin>>s;
	n = s.size();
	
	init(n);
	cout<<solve(0, 5)<<"\n";
	return 0;
}

Measured memory_bytes: 19200
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int MIN(int a,int b){return a<b?a:b;}
void ifMAX(int *a,int b){*a=MAX(*a,b);}
int main(){
  int h,n,k,m,p,d,i,j,l,a[110],b[110],c[110],e[110],dp[110][110]={};
  int s[11010]={};
  int t[110][11010]={1};
  scanf("%d %d %d %d %d %d",&h,&n,&k,&m,&p,&d);
  for(i=0;i<n;i++)scanf("%d %d",&e[i],&c[i]);
  for(i=0;i<m;i++)scanf("%d %d",&b[i],&a[i]);
  for(i=0;i<10010;i++){
    for(j=0;j<m;j++)ifMAX(&s[i+a[j]],s[i]+b[j]);
  }
  for(l=0;l<n;l++){
    for(i=k-1;i>-1;i--){
      for(j=h-1;j>-1;j--){
	if(t[i][j])ifMAX(&t[i+1][j+e[l]],t[i][j]+c[l]);
      }
    }
  }
  for(i=0;i<=d;i++){
    for(j=h;j;j--){
      if(dp[i][j]==0&&i)continue;
      ifMAX(&dp[i][j-1],dp[i][j]);
      for(l=0;l<=j;l++){
	if(t[k][l])ifMAX(&dp[i+1][MIN(h,j-l+p)],dp[i][j]+s[t[k][l]-1]);
      }
    }
  }
  printf("%d\n",dp[d][p]?dp[d][p]:-1);
  return 0;
}

Measured memory_bytes: 5428
int main(void){
    int n,k,x,y;
    scanf("%d", &n);
    scanf("%d", &k);
    scanf("%d", &x);
    scanf("%d", &y);
    if (n-k < 0) printf("%d\n",n*x);
    else printf("%d\n",k*x + (n-k)*y);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    vi b(N);
    rep(i, N) cin >> b[i];
    
    vi res;
    int cnt = N;
    rep(i, N) {
        int seq = -1;
        for(int j=cnt-1; j>=0; j--) {
            if(b[j]==j+1) {
                seq = j;
                break;
            }
        }
        if(seq<0) {
            cout << seq << endl;
            return 0;
        }
        res.pb(seq+1);
        for(int j=seq; j<cnt; j++) {
            b[j] = b[j+1];
        }
        cnt--;
    }

    reverse(ALL(res));
    rep(i, N) {
        cout << res[i] << endl;
    }

    return 0;
}

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

int main() {
	string s; cin >> s;
	int n = s.size();
	if(s[0] != '1' or s[n - 1] == '1') {
		cout << -1 << '\n';
		return 0;
	}
	s = '0' + s;
	for(int i = 1; i < n; ++i) {
		if(s[i] != s[n - i]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	int par = 1;
	for(int i = 1; i < n; ++i) {
		if(s[i] == '1') {
			cout << par << " " << i + 1 << '\n';
			par = i + 1;
		} else {
			cout << par << " " << i + 1 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p pair<ll,ll>
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
ll mod= 1e9+7;
ll a[200005];
void init()
{
     a[1]=1;
     for(int i=2;i<=200000;i++)
      {
           a[i] = a[i-1]+i ;
      }
}
int main()
{     
    //   init();
    // ll n,k;
    // cin>>n>>k;
    // ll ans=0;
    // for(int i=k;i<=n+1;i++)
    //   {   if(i==n+1){ans++;continue;}
    //      ans+=  ( a[n]-a[n-i] -a[i-1] +1   )%mod;

    //   }
    // cout<<ans%mod<<endl;
    map <string,int> s;
   int n;cin>>n;
   for(int i=1;i<=n;i++)
   {
     string a;cin>>a;
     s[a]++;
   }
   cout<<s.size();
    
    return 0;
}



Measured memory_bytes: 19288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;
    int ans = 0;
    A--;
    B--;

    ans = B / A;
    if(B % A != 0) {
        ans++;
    }

    cout << ans << endl;
}


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

using namespace std;

void printSharpLine(int n) {
    for (int i = 0; i < n; i++) {
        cout << "#";
    }
    cout << endl;
}


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> data(h, vector<char>(w, 0));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> data.at(i).at(j);
        }
    }

    printSharpLine(w + 2);

    for (int i = 0; i < h; i++) {
        cout << "#";
        for (int j = 0; j < w; j++) {
            cout << data.at(i).at(j);
        }
        cout << "#" << endl;
    }

    printSharpLine(w + 2);

    return 0;
}


Measured memory_bytes: 3624