akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
using namespace std;
typedef long long LL;
const int N = 100010, mod = 1e9 + 7;
int f[N][2], s[N][2], n, pa[N], pb[N]; LL a, b, x[N];
int main() {
	cin >>n>>a>>b;
	rep(i,1,n) scanf("%lld",&x[i]);
	pa[1] = 1; rep(i,2,n) pa[i] = (x[i] - x[i - 1] >= a) ? pa[i - 1] : i - 1;
	pb[1] = 1; rep(i,2,n) pb[i] = (x[i] - x[i - 1] >= b) ? pb[i - 1] : i - 1;
	int ra = 1, rb = 1; bool A = true, B = true;
	rep(i,1,n) {
		if (i > 1) { if (x[i] - x[i - 1] < a) A = false; if (x[i] - x[i - 1] < b) B = false; }
		rep(d,0,1) s[i][d] = s[i - 1][d];
		//A
		while (x[i + 1] - x[ra] >= b) ra++;
		int r = ra - 1, l = pa[i];
		if (l <= r) f[i][0] = (s[r][1] - s[l - 1][1]) % mod;
		if (A) f[i][0]++;
		//b
		while (x[i + 1] - x[rb] >= a) rb++;
		r = rb - 1, l = pb[i];
		if (l <= r) f[i][1] = (s[r][0] - s[l - 1][0]) % mod;
		if (B) f[i][1]++;
		//s
		rep(d,0,1) (s[i][d] += f[i][d]) %= mod;
	}
	int ans = (s[n - 1][0] - s[pb[n] - 1][0]) % mod + (s[n - 1][1] - s[pa[n] - 1][1]) % mod;
	ans += A + B;
	ans %= mod; if (ans < 0) ans += mod;
	cout <<ans<<endl;
}

Measured memory_bytes: 3456
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n,m;
        while((n = scan.nextInt()) != 0 && (m = scan.nextInt()) != 0){
            ArrayList<Integer> tarou = new ArrayList<Integer>();
            ArrayList<Integer> hanako = new ArrayList<Integer>();
            int t_total = 0, h_total = 0, t_result = 100, h_result = 100;

            for(int i=0; i<n; i++){
                int s = scan.nextInt();
                tarou.add(s);
                t_total += s;
            }
            for(int i=0; i<m; i++){
                int s = scan.nextInt();
                hanako.add(s);
                h_total += s;
            }

            for(int i=0; i<m; i++){
                for(int j=0; j<n; j++){
                    int t = t_total;
                    int h = h_total;
                    t = t - tarou.get(j) + hanako.get(i);
                    h = h - hanako.get(i) + tarou.get(j);
                    if(t == h && tarou.get(j)+hanako.get(i) < t_result+h_result){
                        t_result = tarou.get(j);
                        h_result = hanako.get(i);
                    }
                }
            }

            if(t_result == 100 && h_result == 100){
                System.out.println(-1);
            } else{
                System.out.println(t_result + " " + h_result);
            }
        }
    }
}

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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K < A) cout << K << endl;
    else if(K <= (A+B)) cout << A << endl;
    else cout << A - (K - (A+B)) << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 1000;

int main(void){
    string N;
    cin >> N;
    ll answer[3];

    rep(i, 3){
        if (N[i] == '1') answer[i] = 9;
        else if (N[i] == '9') answer[i] = 1;
        else answer[i] = N[i];
    }
    cout << answer[0] * 100 + answer[1] * 10 + answer[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, long long M, std::vector<long long> A){
    vll S(N+1, 0);
    REP(i, N) S[i+1] = (S[i] + A[i]) % M;
    ll total = (S[N] - S[0]) % M;
    map<ll, vll> R;
    REP(r, N){
        ll x = S[N]-S[r+1];
        if(x < 0 ) x+= M;
        if(R.count(x)){
            R[x].push_back(r+1);
        }
        else{
            R[x] = vll(1, r+1);
        }
    }
    ll cnt = 0;
    REP(l, N){
        ll tmp = (total - S[l]) % M;
        if(tmp < 0) tmp += M;
        if(!R.count(tmp)) continue;
        cnt += R[tmp].end() - upper_bound(ALL(R[tmp]), l);
    }
    cout<<cnt<<endl;



}

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


Measured memory_bytes: 9088
def cc070
    n = gets.chomp.to_i

    u = 1
    tn = []
    for i in 1..n
        t = gets.chomp.to_i
        if i == 1
            u = t
        else
            u = u.lcm(t)
        end
        tn.push(t)
    end

    w = true
    ma = tn.max
    tn.each do |t|
        unless ma % t == 0
            w = false
            break
        end
    end

    puts w ? ma : u
end

cc070

Measured memory_bytes: 1788
import math
from collections import defaultdict
# 0以上整数x「未満」の素数をリストに格納して返す
n = int(input())
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0  # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
pr = primes(n + 1)
q = math.factorial(n)
di = {}
di = defaultdict(int)
for i in pr:
    while q % i == 0:
        q = q // i
        di[i] += 1

ans = 1
mod = 10 ** 9 + 7
for i in di:
    ans *= di[i] + 1
    ans %= mod
print(ans)

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

using namespace std;

int N;
int L[201];

int main() {
  cin >> N;
  for(int i = 0; i < 2*N; i++) cin >> L[i];

  int ans = 0;

  sort(L,L+2*N);

  for(int i = 0; i < 2*N; i+=2){
    ans += L[i];
  }

  cout << ans <<endl;
}


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

void solve2(){
  long long int n; cin >> n;
  long long int i;
  long long int mini = n;
  for(i = 1; i <= pow(n, 0.5); i++){
    //cout << i << endl;
    if((double)n / i == floor(n / i)){
      mini = min(i + n/i -2, mini);
      //cout << i << " " << n/i << endl;
    }
  }
  cout << mini << endl;
  return;
}

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


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

vector<string> bubbleSort(vector<string> v, int N);
vector<string> selectionSort(vector<string> v, int N);
void display(vector<string> v, int N);

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

	vector<string> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	vector<string> v1 = bubbleSort(v, N);
	cout << "Stable" << endl;
	vector<string> v2 = selectionSort(v, N);
	if (v1 == v2) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}

vector<string> bubbleSort(vector<string> v, int N) {
	int i = 0;
	while (1) {
		for (int j = N - 1; j > i; j--) {
			if (v.at(j).at(1) < v.at(j - 1).at(1)) {
				string x = v.at(j);
				v.at(j) = v.at(j - 1);
				v.at(j - 1) = x;
			}
		}
		i++;
		if (i == N - 1) break;
	}

	display(v, N);
	return v;
}

vector<string> selectionSort(vector<string> v, int N) {
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;

		for (int j = i; j < N; j++) {
			if (v.at(j).at(1) < v.at(minj).at(1)) minj = j;
		}

		if (i != minj) {
			string n = v.at(i);
			v.at(i) = v.at(minj);
			v.at(minj) = n;
			cnt++;
		}
	}

	display(v, N);
	return v;
}

void display(vector<string> v, int N) {
	for (int i = 0; i < N; i++) {
		cout << v.at(i);
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}


Measured memory_bytes: 3164
#include <iostream>
using namespace std;
int dar[100002];

int func(short ar[],int start, int end){
	dar[end]=0;
	dar[end - 1] = abs(ar[end] - ar[end - 1]);
	
	for(int i=end -2 ;i>=start ; i--)
	{
		dar[i] = min(dar[i+1] + abs(ar[i+1] - ar[i]) , dar[i+2] + abs(ar[i+2] - ar[i]));
		
	}
	
	return dar[0];
}

int main() {
	// your code goes here
	int N;
	short ar[100002];
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>ar[i];
	}
	
	cout<<func(ar,0,N-1);
	cout<<endl;
	return 0;
}

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

pub 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")
}

use std::cmp::{max, min};

fn main() {
    let x: usize = read();
    let a: usize = read();
    if x < a {
        println!("{}", 0);
    } else {
        println!("{}", 10);
    }
}


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

const int mxn = 1e5 + 5;
long long n, l, w[mxn], v[mxn], dp[105][mxn];

int main() {
	cin >> n >> l;
	for (int i=1; i<=n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=l; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - w[i] < 0) {
				// cout << dp[i][j] << ' ';
				continue;
			}
			dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			// cout << dp[i][j] << ' ';
		}
		// cout << '\n';
	}
	cout << dp[n][l];
}

Measured memory_bytes: 81280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
import heapq
def prim_heap():
    used = [True] * n
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res
n, *t = map(int, open(0).read().split())
x = sorted((x, i) for i, (x, y) in enumerate(zip(t[::2], t[1::2])))
y = sorted((y, i) for i, (x, y) in enumerate(zip(t[::2], t[1::2])))
edge = [[] for _ in range(n)]
for i, j in zip(x, x[1:]):
    a, b, c = i[1], j[1], j[0] - i[0]
    edge[a].append((c, b))
    edge[b].append((c, a))
for i, j in zip(y, y[1:]):
    a, b, c = i[1], j[1], j[0] - i[0]
    edge[a].append((c, b))
    edge[b].append((c, a))
print(prim_heap())

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef vector<int> vi;
typedef vector<vi> vvi;

/*{
  }*/

signed main(){
  int x, y;
  cin >> x >> y;

  int a[] = {300000, 200000, 100000};
  int ans = 0;
  if(x <= 3) ans += a[x-1];
  if(y <= 3) ans += a[y-1];
  if(x == 1 and y == 1) ans += 400000;
  cout << ans << endl;

  return 0;
}



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

int main() {
    int N,A;
    set<int> s;
    cin >> N;

    rep(i,N) {
        cin >> A;
        if(!s.count(A))
            s.insert(A);
        else {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

int main(){
    int n;
    cin >> n;
    int x[n],y[n],h[n];
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int num;
            int height;
            rep(l,n){
                if(h[l]!=0){
                    height=h[l]+abs(x[l]-i)+abs(y[l]-j);
                    num=l;
                    break;
                }
            }

            bool z=false;

            for(int k=0;k<n;k++){
                if(num==k) continue;
                if(h[k]!=0){
                    if(h[k]+abs(x[k]-i)+abs(y[k]-j)==height) continue;
                    else{
                        z=true;
                        break;
                    }
                }
                else{
                    if(height-abs(x[k]-i)-abs(y[k]-j)<=0) continue;
                    else{
                        z=true;
                        break;
                    }
                }
            }
            //printf("hello\n");
            if(z==false){
                cout << i << " " << j << " " <<  height;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, Y, Z = MAP()
M = X + Y + Z

# XYZとの一致をチェックするビット列
check = 1<<(X+Y+Z-1) | 1<<(Y+Z-1) | 1<<(Z-1)
dp = list2d(N+1, 1<<(M-1), 0)
# dp[i][S] := i個目まで見て、前の値M-1以下までの集合がSの時の、XYZを含まないものの通り数
dp[0][0] = 1
msk1 = (1<<M) - 1
msk2 = (1<<(M-1)) - 1
for i in range(N):
    for S in range(1<<(M-1)):
        if not dp[i][S]:
            continue
        for j in range(10):
            # 1ビットずらして1を足してjビットずらしてマスクする
            S2 = (S<<1|1)<<j & msk1
            # 直前Mビットで使った値がXYZと一致していないか確認する
            if not (S2 & check) == check:
                dp[i+1][S2&msk2] += dp[i][S]
                dp[i+1][S2&msk2] %= MOD
total = pow(10, N, MOD)
cnt = 0
for S in range(1<<(M-1)):
    cnt += dp[N][S]
    cnt %= MOD
print((total-cnt)%MOD)


Measured memory_bytes: 62316
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int calculate_digits_total(int x) {
	int digits_total = 0;
	while (x) {
		digits_total += x % 10;
		x /= 10;
	}

	return digits_total;
}

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

	int min = INF;
	for (int i = 1; i < N; i++){
		chmin(min, calculate_digits_total(i) + calculate_digits_total(N - i));
	}
	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

void rec(int d, LL val, vector<LL> &ans) {
	ans.push_back(val);
	if (d == 10)return;

	for (int j = -1; j <= 1; j++) {
		int add = (val % 10) + j;
		if (add >= 0 && add <= 9)rec(d + 1, val * 10 + add, ans);
	}
}

int main() {
	int k; cin >> k;
	vector<LL> ans;
	for (int i = 1; i < 10; i++)rec(1, i, ans);
	sort(ans.begin(), ans.end());
	cout << ans[k-1] << endl;
	return 0;
}

Measured memory_bytes: 2420
import math

INF = float("inf")

V, E = map(int, input().split())
es = []

for _ in range(E):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -c])

d = [INF] * V
d[0] = 0
cnt = [0] * V

for _ in range(V):
    updated = False
    for e in es:
        if math.isinf(d[e[0]]):
            continue
        if d[e[1]] > d[e[0]] + e[2]:
            d[e[1]] = d[e[0]] + e[2]
            cnt[e[1]] += 1
            updated = True
    if not updated:
        break

print(-d[V-1] if cnt[V-1] < V else "inf")


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define vic vector<int>
#define vit vector<int>::iterator
#define pir pair<int,int>
#define fr first
#define sc second
#define mp(x,y) make_pair(x,y)
#define rsort(x,y) sort(x,y),reverse(x,y)
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=1100000;
const int inf=0x3f3f3f3f;

int n,a[Maxn],s[Maxn],top;

signed main() {
//	freopen("test.in","r",stdin);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) {
		int temp=-1;
		for(int j=n-i+1;j>=1;j--) if(a[j]==j) {
			temp=j;
			break;
		}
		if(temp==-1) return 0*puts("-1");
		s[++top]=temp;
		for(int j=temp;j<n-i+1;j++) a[j]=a[j+1];
	}
	while(top) printf("%d\n",s[top--]);
	return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N];
ll x,sum[N];
int main()
{
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
    ll ans=sum[n]*5+2*n*x;
    for(int i=1;i<=n;i++)
    {
        ll res=x*i;
        for(int j=n,t=1;j>=1;j-=i,t++)
        {
            res+=(sum[j]-sum[max(0,j-i)])*(t==1?5:2*t+1);
            if(res>ans) break;
        }
        ans=min(ans,res);
    }
    printf("%lld\n",ans+n*x);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
#define ll long long

int a[N];

int C(int n){
    return (n-1)*n/2;
}

void solve(){
    int n,m;
    cin>>n>>m;
    int a=C(n),b=C(m);
    cout<<a+b<<endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

#define COMMENT

int A[1<<20], B[1<<20], N;

int _xor(int a, int b) {
  return a ^ b;
}

string getBinary30(int num) {
  string out;
  for(int i = 29;i >= 0;i--) {
    char _bit = ((1<<i) & num) ? '1' : '0';
    out.push_back(_bit);
  }

  return out;
}

int lps[7000099];
vector<int> text;
vector<int> pattern;
vector<int> match_index;

void build_lps() {
    int N = pattern.size();
    for(int i = 2;i <= N;i++) {
        int prev = i-1;
        while(prev != 0) {
            if(pattern[lps[prev]] == pattern[i-1]) {
                lps[i] = lps[prev]+1;
                break;
            }
            prev = lps[prev];
        }
    }
}

void find_pattern() {
    int i = 0, j = 1;
    while(i < text.size()) {
        if(j == 1 && pattern[j-1] != text[i]) {
            i += 1;
        }
        else if(j == pattern.size() && pattern[j-1] == text[i]) {
            match_index.push_back(i+1-pattern.size());
            i++;
            j = lps[j]+1;
        }
        else if(pattern[j-1] == text[i]) {
            i++;j++;
        } else {
            j = lps[j-1]+1;
        }
    }
}

int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

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

  for(int i = 0;i < N;i++) {
    text.push_back(_xor(A[i], A[(i+1)%N]));
    pattern.push_back(_xor(B[i], B[(i+1)%N]));
  }

  for(int i = 0;i < N;i++) {
    text.push_back(text[i]);
  }

  build_lps();
  find_pattern();

  for(auto in: match_index) {
    // debug(in);
    if(in < N) {
      cout << in << " " << _xor(A[in], B[0]) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,s;
    cin>>a>>b>>c;
    if((b+c==a)||(c+a==b)||(a+b==c))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
    int N;  
    cin >> N;
    int P[N];
    rep(i,N) cin >> P[i];

    int count = 0;
    rep(i,N){
        if(P[i]==i+1){
            count++;
            i++;
        }
    }
    cout << count;

    return 0;
}

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

using namespace std;

int main()
{
	string s,t;
	cin>>s>>t;
	int l=s.size();
	int flag=0;
	for(int i=0;i<l;i++)
	{
		if(s[i]!=t[i])
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}

Measured memory_bytes: 3632
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pll in[200050];
vector <pll> Vu;

ll A[200050];
int main() {
	ll sx, sy, ex, ey;
	scanf("%lld %lld %lld %lld", &sx, &sy, &ex, &ey);
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &in[i].first, &in[i].second);

	if (sx > ex) {
		sx = 100000000 - sx;
		ex = 100000000 - ex;
		for (i = 1; i <= N; i++) in[i].first = 100000000 - in[i].first;
	}
	if (sy > ey) {
		sy = 100000000 - sy;
		ey = 100000000 - ey;
		for (i = 1; i <= N; i++) in[i].second = 100000000 - in[i].second;
	}

	for (i = 1; i <= N; i++) if (sx <= in[i].first && in[i].first <= ex && sy <= in[i].second && in[i].second <= ey) Vu.push_back(in[i]);
	sort(all(Vu));

	int c = 0;
	for (auto it : Vu) {
		int p = lower_bound(A, A + c, it.second) - A;
		if (p == c) c++;
		A[p] = it.second;
	}

	db ans = 100.0 * (ex - sx + ey - sy);
	ans += (5 * PI - 20) * c;
	if (c == min(ex - sx + 1, ey - sy + 1)) ans += 5 * PI;

	return !printf("%.20lf\n", ans);
}

Measured memory_bytes: 9584
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define MOD 1000000007

char str[110];
int N;
map<string, ll> m[110];

ll dfs(int cur)
{
    if (cur == N + 3) {
        return 1;
    }
    else {
        string l = string() + str[cur - 3] + str[cur - 2] + str[cur - 1];
        if (m[cur].find(l) != m[cur].end()) {
            return m[cur][l];
        }
        else {
            ll count = 0;
            // set 'A' to str[cur]
            str[cur] = 'A';
            count = (count + dfs(cur + 1)) % MOD;

            // set 'T'' to str[cur]
            str[cur] = 'T';
            count = (count + dfs(cur + 1)) % MOD;

            // set 'C' to str[cur]
            if ((str[cur - 2] == 'A' && str[cur - 1] == 'G')
            || (str[cur - 2] == 'G' && str[cur - 1] == 'A')
            || (str[cur - 3] == 'A' && str[cur - 1] == 'G')
            || (str[cur - 3] == 'A' && str[cur - 2] == 'G')
            ) {
                ;
            }
            else {
                str[cur] = 'C';
                count = (count + dfs(cur + 1)) % MOD;
            }

            // set 'G' to str[cur]
            if (str[cur - 2] == 'A' && str[cur - 1] == 'C') {
                ;
            }
            else {
                str[cur] = 'G';
                count = (count + dfs(cur + 1)) % MOD;
            }
            m[cur].insert(make_pair(l, count));
            return count;
        }
    }
}

int main(int argc, char **argv)
{
    cin >> N;
    str[0] = 'T';
    str[1] = 'T';
    str[2] = 'T';
    cout << dfs(3) << endl;
    return 0;
}


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

l=list(map(int,input().split()))
a,b,c=sorted(l)
#print(a,b,c)
if a%2==b%2 and a%2==c%2:
    print((2*c-a-b)//2)
elif a%2==b%2:
    print((2*c-2-a-b)//2+1)
else:
    print((2*c+1-a-b)//2+1)

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

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

    int sum=0;
    
    string word;
    while (cin >> word)
    {
        if (word=="END_OF_TEXT")
        {
            break;
        }
        if (word.at(word.size()-1) == '.')
        {
            word = word.substr(0, word.size()-1);
        }
        for (int i=0; i<word.size(); i++)
        {
            char moji = word.at(i);
            if (isupper(moji))
            {
                word.at(i)=tolower(moji);
            }
        }
        if (word==W)
        {
            sum++;
        }
    }
    

    cout << sum << endl;

}


Measured memory_bytes: 3156
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        String first = s.substring(0, 1);
        String middle = s.substring(1, s.length()-1);
        String end = s.substring(s.length()-1);
        System.out.println(first + middle.length() + end);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,x,i,j,k,m=0,p;
    string s;
    cin >> s;
    a=s.size();
    for(i=0;i<a;i++)
    {
        cout << "x";
    }

 
    return 0;

}


Measured memory_bytes: 3548
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]*(N+1)
Kmax=-1
for i in range(N):
    Q[i+1]+=P[i]+Q[i]

for j in range(N-K+1):
    if Q[j+K]-Q[j]>Kmax:
        Kmax=Q[j+K]-Q[j]
print((Kmax+K)/2)


Measured memory_bytes: 25604
'use strict'

function Main(input) {
  const R = Number(input.split(" ")[0])
  const G = Number(input.split(" ")[1])
  const B = Number(input.split(" ")[2])
  const N = Number(input.split(" ")[3])

  const nums = [R, G, B].sort((x, y) => y - x)

  const max = nums[0]
  const min = nums[1]
  const mid = nums[2]

  const maxDivided = Math.floor(N / max)

  let ans = 0
  for (let i=0; i<=maxDivided; i++) {
    const midDivided = Math.floor((N - (i * max)) / mid)
    for (let j=0; j<=midDivided; j++) {
      const reminder = N - (i * max) - (j * mid)
      if (reminder % min === 0) {
        ans++
      }
    }
  }

  console.log(ans)
}

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


Measured memory_bytes: 7500
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;cin>>a>>b;
	if(a==0){
		if(b>=1989)cout<<"H"<<b-1988<<endl;
		else if(b>=1926)cout<<"S"<<b-1925<<endl;
		else if(b>=1912)cout<<"T"<<b-1911<<endl;
		else if(b>=1868)cout<<"M"<<b-1867<<endl;
	}
	int c[4]={1867,1911,1925,1988};
	if(a){
		cout<<c[a-1]+b<<endl;
	}
	return 0;
}

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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

ll ten[42];

ll d;

ll ans(ll D, int a, int b, int z=0) {
	ll DD=D;
	int aa=a, bb=b;
	while(aa>bb) {
		DD+=9*(ten[aa]-ten[bb]);
		aa--;
		bb++;
	}
	if(DD<0) return 0;
	DD=D;
	aa=a; bb=b;
	while(aa>bb) {
		DD-=9*(ten[aa]-ten[bb]);
		aa--;
		bb++;
	}
	if(DD>0) return 0;
	if(a<b) {
		if(D==0) return 1;
		else return 0;
	} else if(a==b) {
		if(D==0) return 9+z;
		else return 0;
	}
	ll ret=0;
	for(int d=-(8+z); d<=8+z; d++) {
		ret+=(9+z-abs(d))*ans(D-d*(ten[a]-ten[b]), a-1, b+1, 1);
	}
	return ret;
}

int main()
{
	ten[0]=1;
	for(int i=1; i<=18; i++) ten[i]=10*ten[i-1];
	scanf("%lld", &d);
	ll a=0;
	for(int i=0; i<=18; i++) {
		a+=ans(d, i, 0);
	}
	printf("%lld\n", a);

	return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    S = input().rstrip()
    T = input().rstrip()

    if S == T[:-1]:
        res = 'Yes'
    else:
        res = 'No'

    print(res)



main()


Measured memory_bytes: 9120
#include <iostream>
#include <vector>
int main(int argc, const char * argv[]) {
    int n;
    std::cin >> n;
    int wrong = -1;
    bool flag = false;
    int i;
    for(i=1; i<=n; i++)
    {
        int t;
        std::cin >> t;
        if(t!=i)
        {
            if(flag) break;
            if(wrong == -1){
                wrong = i;
            }else{
                if(wrong == t)
                {
                    flag = true;
                }else{
                    break;
                }
            }
        }
    }
    if(i==n+1)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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


ll gcd(ll a, ll b){
  return (b ? gcd(b,a%b) : a);
}

const ll INF = 1LL << 60;

struct Edge{
  int to,weight;
  Edge(int t, int w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;

int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;

  vi C;
  int now = 1; //1の個数から数え始める
  int cnt = 0;
  rep(i, n){
    if(s[i] == (char)(now + '0')) cnt++;
    else{
      C.pb(cnt);
      now = 1-now;
      cnt = 1;
    }
  }
  C.pb(cnt);
  // 1-0-1-0-1-0-1 (奇数長)の配列を作る
  if(C.size()%2 == 0) C.pb(0);

  //rep(i, C.size()) std::cout << C[i]; cout << '\n';

  int right = 0;
  int ans = 0;
  int sum = 0;
  rep(left, C.size()){
    while (right < C.size() && right - left <= 2*k) {
      sum += C[right];
      right++;
    }
    chmax(ans, sum);

    sum -= C[left];
    left++;
    sum -= C[left];
  }

  std::cout << ans << '\n';
}


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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
//#define INF 1e9
constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  REP(i, N){
    cin >> A[i];
    sum += A[i];
  }
  sort(A.rbegin(), A.rend());
  int s = (sum+(4*M-1)) / (4*M);
  REP(i, M){
    if(A[i] < s){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
	int n, i, input;
	vector<int> v;
	vector<int>::iterator it;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> input;
		it = v.begin();
		v.insert(it, input);
	}
	for (i = 0; i < n-1; i++) {
		cout << v[i] << " ";
	}
	cout << v[n-1] << endl;
}

Measured memory_bytes: 1220
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char str[100005], str2[100005];
char zh(char ch) {
	switch(ch) {
		case 'b': return 'd';
		case 'd': return 'b';
		case 'p': return 'q';
		case 'q': return 'p';
		default: break;
	}
	return ch;
}
int main() {
	cin >> str;
	int len= strlen(str);
	for(int i= 0; i < len; i++) str2[len - i - 1]= zh(str[i]);
	cout << string(strcmp(str, str2) == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int B=1000000;
int N,M;
int dat[50][50];
int fld[100][100];
void rotate(){
      int tmp[50][50];
      REP(i,M)REP(j,M){
            tmp[j][i]=dat[i][M-j-1];
      }
      REP(i,M)REP(j,M)dat[j][i]=tmp[j][i];
}
int main(){
      int n,m;
      while(cin>>N>>M&&(N||M)){
            vector<P> ans;
            REP(i,N)REP(j,N)cin>>fld[j][i];
            REP(i,M)REP(j,M)cin>>dat[j][i];
            REP(times,4){
                  //REP(x,M)REP(y,M)printf("%2d%c",dat[y][x],y==M-1?'\n':' ');
                  //cout<<endl;
                  //cout<<times<<endl;
                  REP(i,N-M+1){
                        REP(j,N-M+1){
                              bool f=true;
                              REP(x,M)REP(y,M){
                                    if(dat[x][y]==-1)continue;
                                    if(dat[x][y]!=fld[x+i][y+j])f=false;
                              }
                              if(f){
                                    //REP(x,N)REP(y,N)printf("%d%c",fld[y][x],y==N-1?'\n':' ');
                                    //REP(x,M)REP(y,M)printf("%2d%c",dat[y][x],y==M-1?'\n':' ');
                                    REP(y,M)REP(x,M)if(dat[x][y]!=-1)ans.PB(P(y+j+1,x+i+1));
                              }
                        }
                  }
                  rotate();
            }
            sort(ALL(ans));
            if(ans.size()==0){
                  cout<<"NA"<<endl;
            }else{
                  cout<<ans[0].second<<" "<<ans[0].first<<endl;
            }
      }
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long N, K;
    cin >> N >> K;

    long A[N], F[N];
    long sa = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sa += A[i];
    }
    for(int i=0; i<N; i++){
        cin >> F[i];
    }
    if(sa <= K){
        cout << 0 << endl;
        return 0;
    }
    sort(A, A+N);
    sort(F, F+N, greater<int>());

    long l = -1;
    long r = 1000000000000000;
    long mid = (l+r)/2;
    while(r > l+1){
        mid = (l+r)/2;
        long ts = 0;
        for(int i=0; i<N; i++){
            ts += max(A[i]-mid/F[i], (long)0);
        }
        if(ts <= K) r = mid;
        else l = mid;
    }

    printf("%ld\n", l+1);

    return 0;
}

Measured memory_bytes: 3328
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat May 26 22:01:32 2018
//
package main

import (
	"fmt"
)

var A, B int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&A, &B)
	fmt.Println(max(A+B, max(A-B, A*B)))
}


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

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    string s;
    cin>>s;
    while(s.size()){
        s.pop_back();
        s.pop_back();
        if(s.substr(0,s.size()/2)==s.substr(s.size()/2)){
            cout<<s.size()<<endl;
            break;
        }
    }
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  for (int i = A; i <= min(A + K - 1, B); i++) cout << i << "\n";
  for (int i = max(A + K, B - K + 1); i <= B; i++) cout << i << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
    int L,N;
    cin >> N>>L;
    string S[N];
    REP(i,N){
        cin >> S[i];
    }

    sort(S,S+N,[](const string x,const string y){return x<y;});

    string ans;
    REP(i,N){
        ans += S[i];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    while (1)
    {
        cin >> h >> w;
        if(h == 0 && w == 0)
            break;
        
        for(int i = 0 ; i < h ; i++){
            for(int j = 0 ; j < w ; j++)
                cout << "#";
            cout << endl;
        }
        cout << endl;
    }
    
  
    return 0;
}


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

const int DIGIT = 10; // 最大桁数
int main() {
	string N;
	cin >> N;
	
	int dp[DIGIT][8]; // 第x桁目に部分集合y(y:{3,5,7})ができている組み合わせ
	memset(dp, 0, sizeof(dp)); // 全ての初期値は0よね
	
	bool isCover = true; // 全てNと同じ値を選ぶような選び方が存在するか否か
	
	for (int i = 0, nowDigit, j, k, cover = 0;i < N.size();++ i) {
		nowDigit = N[i] & 15; // 今見ている桁の値
		dp[i][0] = 1; // 第x桁目が空集合……すなわち今まで0だった、これが最初の桁の組み合わせは当然だが1通り
		for (j = 1;j < 8;j <<= 1) {
			for (k = 0;k < 8;++ k) dp[i + 1][j | k] += dp[i][k];
			if (isCover && (j & 6) + 3 > nowDigit) -- dp[i + 1][j | cover]; // Nを超える場合をちょっと引き算
		}
		cover |= 1 << (nowDigit - 3 >> 1); // 現時点で、Nと同じ値を連続して選んだ時の{3,5,7}の集合
		isCover &= ((nowDigit | nowDigit << 1) & 7) == 7; // これA問題と同じだね、誘導問だったか
	}
	cout << dp[N.size()][7]; // {3,5,7}全てを含む場合のみが答えなので
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

dpすると解ける
*/

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> S >> K;
    for (int i = 0; i < N; i++) {
        if (S[i] == S[K - 1]) cout << S[i];
        else cout << '*';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin >> N;
  string S; cin>>S;
  
  if (N%2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  string f = S.substr(0, N/2);
  string r = S.substr(N/2, N/2);
  string ans = f == r ? "Yes" : "No";

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int a[200005];
signed main()
{
	int n,k;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	for (int i=0;i<n-k;i++){
		if (a[i]<a[i+k])  cout<<"Yes\n";
		else  cout<<"No\n";
	}
	re 0;
}


Measured memory_bytes: 5168
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<queue>
#include<functional>
#include<numeric>
 
using namespace std;
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, R;
	cin >> n >> m >> R;
	vector<int> r(R);
	for (auto& e : r) {
		cin >> e;
		e--;
	}
	vector<vector<pair<int, int>>> g(n,vector<pair<int, int>>(0));
	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].push_back(make_pair(c, b));
		g[b].push_back(make_pair(c, a));
	}
	vector<vector<long long>> rg(r.size(), vector<long long>(r.size(),LLONG_MAX));

	for (int i = 0; i < r.size(); i++) {
		priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
		vector<long long> d(n,LLONG_MAX);
		d[r[i]] = 0;
		que.push(pair<long long, int>(0, r[i]));

		while (!que.empty()) {
			auto p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			for (int j = 0; j < g[v].size(); j++) {
				auto e = g[v][j];
				if (d[e.second] > d[v] + e.first) {
					d[e.second] = d[v] + e.first;
					que.push(pair<long long, int>(d[e.second], e.second));
				}
			}
		}
		for (int j = 0; j < r.size(); j++) {
			rg[i][j] = d[r[j]];
		}
	}
	vector<int> index(r.size());
	iota(index.begin(),index.end(), 0);
	long long ans = LLONG_MAX;
	long long tmp;
	do {
		tmp = 0;
		for (int i = 0; i < r.size() - 1; i++) {
			tmp += rg[index[i]][index[i + 1]];
		}
		ans = min(ans, tmp);
	} while (next_permutation(index.begin(), index.end()));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
N = int(input())
p = 1

for i in range(2, N + 1):
    p *= i
ans = 1

for i in range(2, N + 1):
    if p % i != 0:
        continue
    c = 1
    while p % i == 0:
        p //= i
        c += 1
    ans *= c
print(ans % 1000000007)

Measured memory_bytes: 3064
num_m = 5
mins = [int(input()) for _ in range(num_m)]
ans = 0
for i in range(num_m - 1, -1, -1):
    if not mins[i] % 10:
        ans += mins[i]
        mins.pop(i)
mins = sorted(mins, key=lambda item: item % 10)
for m in mins[1:]:
    ans += (m // 10 + 1) * 10
if len(mins):
    ans += mins[0]

print(ans)


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N-1;i++){
    int j;
    cin>>j;
    A[j-1]++;
  }
  for(int i:A)
    cout<<i<<endl;
}

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

int gcd(int a, int b) {
	while(b > 0) {
		int tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

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

	std::vector<int> A(N);
	for(int &a : A) {
		std::cin >> a;
	}

	std::vector<int> left(N);
	left[0] = A[0];
	for(int i = 1; i < N; i++) {
		left[i] = gcd(left[i - 1], A[i]);
	}

	std::vector<int> right(N);
	right[N - 1] = A[N - 1];
	for(int i = N - 2; i >= 0; i--) {
		right[i] = gcd(right[i + 1], A[i]);
	}

	// 左端
	int result = right[1];

	// 中
	for(int i = 1; i < N - 1; i++) {
		const int n = gcd(left[i - 1], right[i + 1]);
		result = std::max(result, n);
	}

	// 右端
	result = std::max(result, left[N - 2]);

	std::cout << result << std::endl;

	return 0;
}


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

int main(){
  int Yen,hpns;
  cin >> Yen ;
  hpns += Yen / 500;
  hpns *= 1000;
  Yen = Yen % 500;
  hpns += (Yen / 5) * 5;
  cout << hpns << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : aoj2575.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string d, b = "AIDUNYAN", a = "AIZUNYAN";
	int al[26];
	fill(al,al + 26,0);
	for(int i = 0;i < b.size();i++){
		al[b[i] - 'A']++;
	}
	cin >> d;
	for (int i = 0; i + b.size() - 1 < d.size(); i++) {
		int tmp[26], k;
		fill(tmp, tmp + 26, 0);
		for (k = i; k < i + b.size(); k++) {
			tmp[d[k] - 'A']++;
		}
		for (k = 0; k < 26; k++) {
			if (al[k] != tmp[k]) {
				break;
			}
		}
		if (k == 26) {
			for (k = i; k < i + a.size(); k++) {
				d[k] = a[k - i];
			}
			i += a.size() - 1;
		}
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 1192