akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def comb(a,b):
        return f[a]*inv[b]*inv[a-b]%mod
    k = I()
    s = input()
    n = len(s)
    m = n+k
    N = 2*10**6+10**5
    f = [1]*(N+1)
    for i in range(1,N+1):
        f[i] = f[i-1]*i%mod
    inv = [None]*(N+1)
    inv[N] = pow(f[N],mod-2,mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = pow(26, m, mod)
    for i in range(n):
        ans -= comb(m,i)*pow(25,m-i,mod)%mod
        ans %= mod
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 141312
def main():
    N,M,X,Y = map(int,input().split())
    x = [int(i) for i in input().split()]
    y = [int(i) for i in input().split()]
    maxx = max(x)
    miny = min(y)
    for z in range(X+1,Y+1):
        if maxx<z and miny>=z:
            print('No War')
            exit()
    print('War')
main()

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

int n, k;
ll ans, cnt[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> k;

	for (int i = 1; i <= n; i++)
		cnt[i % k]++;

	for (int i = 0; i < k; i++) {
		int a = i;
		int b = (k - a + k) % k;
		int c = (k - b + k) % k;
		if ((a + c) % k != 0)
			continue;
		ans += cnt[a] * cnt[b] * cnt[c];
	}

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


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

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORd(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); ++it)
#define ms(x, n) memset(x, n, sizeof(x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define prec(x) fixed << setprecision((x))
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define long long long
#define db(x) cerr << #x << " = " << (x) << ", ";
#define endln cerr << "\n";
#define chkpt cerr << "------\n";
template<class T> inline int chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline int chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
const int INF = (int) 1e9;
const long LINF = (long) 1e18;

const int maxn = 100 + 15;

int n, m;
char a[maxn][maxn];

int main() {
    cin >> n >> m;
    FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j];
    FOR(i, 0, n + 1) FOR(j, 0, m + 1) if (!(1 <= i && i <= n && 1 <= j && j <= m)) a[i][j] = '#';
    FOR(i, 0, n + 1) {
        FOR(j, 0, m + 1) cout << a[i][j];
        cout << '\n';
    }
    return 0;
}


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

int main() {
	map<int,int>mz,nz;
	int n,m;
	cin>>n;
	int a[n+3];
	for(int i=0;i<n;i++) { cin>>a[i];  mz[a[i]]++; }
	cin>>m;
	int b[m+3];
	for(int i=0;i<m;i++) { cin>>b[i];  nz[b[i]]++; }
	if(n<m)
	{
		cout<<"NO";
		return 0;
	}
	for(auto &x:nz)
	{
		if(x.second>mz[x.first])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;

int main(){
	/*freopen(".gir", "r", stdin);
	freopen(".cik", "w", stdout); 
    */ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin >> n;
	double a[n];
	double sum=0;
	rep(i,n){
		cin >> a[i];
		sum+=(double)1/a[i];
	}
	printf("%.15f\n",1/sum);
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<int,int>> fri(m),blo(k);
    UnionFind tree(n);

    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        fri[i]=make_pair(a,b);
        tree.merge(a,b);
    }
    for(int i=0; i<k; i++){
        int c,d;
        cin>>c>>d;
        c--;d--;
        blo[i]=make_pair(c,d);
    }
    map<int,int> fri_mp,blo_mp;
    for(int i=0; i<m; i++){
        fri_mp[fri[i].first]++;
        fri_mp[fri[i].second]++;
    }
    for(int i=0; i<k; i++){
        blo_mp[blo[i].first]++;
        blo_mp[blo[i].second]++;
    }
    
    //広義の友達候補の中で相互ブロックである数を知りたい
    //友達マップに含まれる相互ブロックの組み合わせをあらかじめカウントしておく
    map<int,int> friblo_mp;
    for(int i=0; i<k; i++){
        if(tree.issame(blo[i].first,blo[i].second)){
            friblo_mp[blo[i].first]++;
            friblo_mp[blo[i].second]++;
        }
    }
    for(int i=0; i<n; i++){
        //広義の友達候補(現友達を含める)は同じツリーに含まれる数、つまりある要素xにおけるunion find木のサイズ-1
        //すでに友達なのはfri_mp[i]]なので引く
        //ブロックマップと友達マップに含まれる組み合わせの数を引く
        int cnt=tree.size(i)-1;
        cnt-=fri_mp[i];
        cnt-=friblo_mp[i];
        cout<<cnt<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 17408
#include<iostream>
using namespace std;
typedef long long int ll;

int N;
int memo[200001][20];

int main(){
	cin >> N;
	for(int i = 1; i <= N; i++){
		int a;
		cin >> a;
		for(int j = 0; j < 20; j++){
			if(a & (1 << j)){
				memo[i][j] = memo[i - 1][j] + 1;
			}else{
				memo[i][j] = memo[i - 1][j];
			}
		}
	}
	ll ans = 0;
	ll t = 0, s = 0;
	while(t <= N){
		bool flag = true;
		for(int j = 0; j < 20; j++){
			if(memo[t][j] - memo[s][j] > 1) flag = false;
		}
		if(!flag){
			while(s < t){
				bool flag_ = true;
				for(int j = 0; j < 20; j++){
					if(memo[t][j] - memo[s][j] > 1) flag_ = false;
				}
				if(flag_){
					break;
				}
				s++;
			}
		}
		ans += t - s;
		t++;
	}
	cout << ans << endl;
	return 0;
}


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

int main(void)
{   
    int N;
    long long K;
    cin >> N >> K;
    
    vector<int> p{0};
    vector<long long> c{0};

    int tp;
    for(int i=0; i<N; ++i){
        cin >> tp;
        p.push_back(tp);
    }
    long long tc;
    for(int i=0; i<N; ++i){
        cin >> tc;
        c.push_back(tc);
    }

    long long max = -9223372036854775807;

    for(int i=1; i <= N; ++i){
        int naw = i;
        long long S = 0;
        long long l = 0;
        long long lmax = -9223372036854775807;
        int kl = K;
        long long max_l;
        long long imax;
        
        vector<long long>s{0};
        while (true){
            naw = p[naw];
            S += c[naw];
            s.push_back(c[naw]);
            l += 1;
            --kl;
            if(S > lmax) {
                lmax = S;
            }
            if(kl == 0 || naw == i){
                break;
            }
        }

        if(kl == 0){
            imax = lmax;
        }else{
            if(S <= 0){
                imax = lmax;                
            }else{
                long long sum = 0;
                long long tmax;
                imax = S;
                for(int j = 1; j <= l; ++j){
                    sum += s[j];
                    tmax = sum + S * ( (K - j) / l);
                    if(tmax > imax) imax = tmax;
                }

            }
        }

        if (imax > max) max = imax;
    }

    cout << max << endl;

}


Measured memory_bytes: 3764
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	dp := make([][]int, len(s)+1)
	dp[0] = make([]int, 13)
	dp[0][0] = 1
	for i, v := range s {
		dp[i+1] = make([]int, 13)
		if v != '?' {
			for j, m := range dp[i] {
				t := j*10 + int(v-'0')
				dp[i+1][t%13] += m
				dp[i+1][t%13] %= 1000000007
			}
			continue
		}
		for j, m := range dp[i] {
			for k := 0; k <= 9; k++ {
				t := j*10 + k
				dp[i+1][t%13] += m
				dp[i+1][t%13] %= 1000000007
			}
		}
	}
	fmt.Println(dp[len(s)][5])
}


Measured memory_bytes: 14592
n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))

count = 0
point = 0

while True:
	number = l[point]-1
	l[point] = 1
	point = number
	count += 1
	if number == 1:
		break
	elif number == 0:
		count = -1
		break

print(count)

Measured memory_bytes: 7084
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split())) +[0]

c = 0
ans = 0
for i in range(n+1):
    if c > a[i]:
        ans += a[i]
        a[i] = 0
        c = 0
        # print("a:" + str(c) + ":" + str(ans))
    else:
        ans += c
        a[i] -= c
        c = 0
        # print("b:" + str(c) + ":" +str(ans))

    if i == n:
        break
    elif a[i] <= b[i]:
        c = b[i] - a[i]
        ans += a[i]
        # print("c:" + str(c) + ":" +str(ans))
    else:
        c = 0
        ans += b[i]
        # print("d:" + str(c) + ":" +str(ans))
    

print(ans)


Measured memory_bytes: 82916
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int H, A; cin >> H >> A;
	print((H + A - 1) / A);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
//gcc listsirkuler.c map.c player.c mesinkata.c mesinkar.c matriks.c pcolor.c point.c queue.c unit.c main.c -o main
#include <bits/stdc++.h>
#define Semangat using
#define World namespace
#define Final std;
#define WF {ios_base::sync_with_stdio(0);cin.tie(0);}
 
Semangat World Final

string x;
bool a;
int coun;

int main(){
	WF
	cin>>x;
	coun=0;
	a=false;
	for(int i=0; i<2; i++){
		if(x[i]==x[i+1]){
			if(x[i]==x[i+2])
				a = true;
		}
	}
	if(a)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

int main(void){
    int m,d;
    cin >> m >> d;
    int count = 0;
    for(int i = 1;i <= m;i++){
        for(int j = 1;j <= d;j++){
            if(i == (j/10)*(j%10) && (j/10) > 1 && (j%10) > 1){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
ll greedy(ll a)
{
    ll ans = 0;
    ll counter = 1;
    while(a>0)
    {
        a -= counter;
        ans += 1;
        // cout<<a<<" "<<ans<<'\n';
        counter += 1;
    }
    return a<0?ans-1:ans;
}
long long int primeFactors(ll n)  
{  
    ll ans = 0;
    ll final = 0;
    while (n % 2 == 0)  
    {  
        ans += 1;
        n = n/2;  
    }  
    if(ans>0)
    {
        final += greedy(ans);
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        ans = 0;
        while (n % i == 0)  
        {  
            n = n/i; 
            ans += 1;
        }  
        if(ans>0)
        {
            final += greedy(ans);
        }
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        final += 1;
    return final;
}  
/* Driver code */
int main()  
{  
    ll n;
    cin>>n;
    vector<int> ans;
    cout<<primeFactors(n)<<'\n';  
    return 0;  
}

Measured memory_bytes: 3668
//
// ABC046B
// URL : https://atcoder.jp/contests/abc046/tasks/abc046_b
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC046B
    {
        static void Main(string[] args)
        {
            preprocess();
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(_inputStr => long.Parse(_inputStr)).ToArray();
            long N = inputLongArray[0];
            long K = inputLongArray[1];

            long ans = K;//最初のボールはK通りの色塗り
            for(int i = 1; i < N; ++i)//i番目のボールはi-1番目のボールの色以外なのでK-1通り
            {
                ans *= (K - 1);
            }

            Console.WriteLine(ans.ToString());
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}



Measured memory_bytes: 11348
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << "\n";
	return 0;
}




Measured memory_bytes: 256
import numpy as np
N,D=map(int,input().split())
X=[np.array(input().split(),dtype=np.int64) for _ in range(N)]
ans=0
for i in range(N):
    for j in range(i+1,N):
        d=((X[i]-X[j])*(X[i]-X[j])).sum()
        dd=int(round(d**.5))
        if d==dd*dd:
            ans +=1
print(ans)

Measured memory_bytes: 27176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  stack<char> st;
  ll ans = 0;
  REP(i, s.size()){
    if(st.empty() || st.top() == s[i]) st.push(s[i]);
    else{
      ans += 2;
      st.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        string s; cin>>s;
        sort(all(s));
        if(s=="abc")cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


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

  vector<int> v(N);
  REP(i, N) cin >> v[i];

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

  int ans = v[N / 2]  - v[N / 2 - 1] ;

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


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

signed main(){
	int N, f = 1;
	string W[110];
	char m;
	
	cin>>N>>W[0];
	
	m = W[0][W[0].size()-1];
	
	for(int i = 1; i < N; i++){
		cin>>W[i];
		if(W[i][0] != m) f = 0;
		m = W[i][W[i].size()-1];
		for(int j = 0; j < i; j++){
			if(W[j] == W[i]) f = 0;
		}
	}
	
	cout<<(f?"Yes":"No")<<endl;
	
	return 0;
}

Measured memory_bytes: 256
/* Stay hungry, stay foolish. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
int n, ans;
int main() {
	//freopen("fuck.in","r",stdin);
	//freopen("fuck.out","w",stdout);
	read(n);
	int ans = 0;
	for (int i = 1, h = 0, a; i <= n; ++i) {
		read(a);
		if (a > (1 << h)) while (a > (1 << h)) ++h, ++ans;
		else while (a < (1 << h)) --h;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans,pri[10000001],num[10000001];
signed main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
		if(!pri[i])
		{
			num[i]=2;
			ans+=2*i;
			for(int l=i*2;l<=n;l+=i)
			{
				pri[l]=1;
				int k=l,cnt=0;
				while(k%i==0)
				{
					k/=i;
					cnt++;
				}
				if(!num[l])
					num[l]=cnt+1;
				else
					num[l]*=(cnt+1);
			}
		}
		else
			ans+=num[i]*i;
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 159844
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		int minus = 0;
		int zero = 0;
		long[] absmin = new long[2];
		Arrays.fill(absmin,Integer.MAX_VALUE);
		for(int i = 0;i<n;i++){
			a[i] = sc.nextLong();
			if(a[i]<0)minus++;
			if(a[i]==0)zero++;
			if(Math.abs(a[i])<absmin[1]){
				absmin[1]=Math.abs(a[i]);
				absmin[0]=i;
			}
		}
		sc.close();
		long ans = 0;
		if(zero!=0 || minus%2==0){
			for(int i = 0;i<n;i++){
				ans += (long)Math.abs(a[i]);
			}
		}else{
			for(int i = 0;i<n;i++){
				if(i!=absmin[0])ans += (long)Math.abs(a[i]);
			}
          ans-=absmin[1];
		}
		System.out.println(ans);
	}
}


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

using namespace std;

#define int long long
typedef pair<int,int> ii;

int r,c,n;
vector<ii> c1,c2,r1,r2;
stack<int> st;
bool used[100005];

bool check(int x1,int y1,int x2,int y2){
    if((x1==0||x1==r||y1==0||y1==c)&&(x2==0||x2==r||y2==0||y2==c)) return 1;
    else return 0;
}

void upd(int x,int y,int id){
    if(x==0&&y!=c) r1.push_back(ii(y,id));
    else if(y==0&&x!=0) c1.push_back(ii(x,id));
    else if(x==r&&y!=0) r2.push_back(ii(y,id));
    else c2.push_back(ii(x,id));
}

signed main(){
    //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>r>>c>>n;
    for(int i=1;i<=n;++i){
        int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
        if(check(x1,y1,x2,y2)){
            upd(x1,y1,i); upd(x2,y2,i);
        }
    }

    sort(c1.begin(),c1.end());
    sort(c2.begin(),c2.end());
    sort(r1.begin(),r1.end());
    sort(r2.begin(),r2.end());

    if(r2.size())
    for(int i=0;i<r2.size();++i){
        int id=r2[i].second;
        if(!used[id]) st.push(id),used[id]=1;
        else{
            if(st.top()==id) st.pop();
            else { cout<<"NO"; return 0; }
        }
    }
    if(c2.size())
    for(int i=c2.size()-1;i>=0;--i){
        int id=c2[i].second;
        if(!used[id]) st.push(id),used[id]=1;
        else{
            if(st.top()==id) st.pop();
            else { cout<<"NO"; return 0; }
        }
    }
    if(r1.size()){
        for(int i=r1.size()-1;i>=0;--i){
            int id=r1[i].second;
            if(!used[id]) st.push(id),used[id]=1;
            else{
                if(st.top()==id) st.pop();
                else { cout<<"NO"; return 0; }
            }
        }
    }
    if(c1.size())
    for(int i=0;i<c1.size();++i){
        int id=c1[i].second;
        if(!used[id]) st.push(id),used[id]=1;
        else{
            if(st.top()==id) st.pop();
            else { cout<<"NO"; return 0; }
        }
    }

    cout<<"YES";

    return 0;
}


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

using namespace std;

int N, k, phi[109];
char A[109], B[109];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
scanf ("%s\n", A + 1);
scanf ("%s\n", B + 1);
for (int i=2; i<=N; i++)
{
    while (k && B[k + 1] != B[i]) k = phi[k];
    if (B[k + 1] == B[i]) k ++;
    phi[i] = k;
}
k = 0;
for (int i=1; i<=N; i++)
{
    while (k && B[k + 1] != A[i]) k = phi[k];
    k += (A[i] == B[k + 1]);
}
printf ("%d\n", 2 * N - k);

return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200007;
const int K = 5000;
int sz[N], p[N], f[N], used[N], c[N], w[N], cnt[N];
pair < int, int > lb[N];
vector < int > z[N];
int gt(int x){
    if (p[x] == x) return x;
    return p[x] = gt(p[x]);
}
void unite(int x, int y){
    x = gt(x);
    y = gt(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x, y);
    p[y] = x;
    sz[x] += sz[y];
}
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
main(){
    ios_base::sync_with_stdio(0 );
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int x, y;
    cin >> x >> y;
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n; i++){
        p[i] = i;
        lb[i].F = 1e12;
        sz[i] = 1;
    }
    for (int i = 1; i <= n; i++){
        cin >> c[i] >> w[i];
        if (lb[c[i]].F > w[i]){
            lb[c[i]].S = i;
            lb[c[i]].F = w[i];
        }
    }
    vector < pair < pair < int, int >, int > > a;
    for (int i = 1; i <= n; i++){
        if (lb[i].F != 1e12){
            a.pb({lb[i], i});
        }
    }
    sort(a.begin(), a.end());
    int k = 3;
    if (a.size() < 3) k = a.size();
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < k; j++){
            int l = a[j].S;
            if (l == c[i]){
                if (a[j].F.F + w[i] <= x){
                    unite(i, a[j].F.S);
                }
            } else{
                if (a[j].F.F + w[i] <= y){
                    unite(i, a[j].F.S);
                }
            }
        }
        int l = lb[c[i]].S;
        if (w[l] + w[i] <= x){
            unite(i, l);
        }
    }
    int ans = 1;
    for (int i = 1; i <= n; i++){
        z[gt(i)].pb(c[i]);
    }
    for (int i = 1; i <= n; i++){
        int res = 1;
        int w = 0;
        for (auto j: z[i]){
            cnt[j]++;
            w++;
            res = res * w % mod * binpow(cnt[j], mod - 2) % mod;
        }
        ans = ans * res % mod;
        for (auto j: z[i]) cnt[j] = 0;
    }
    cout << ans;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = (int)1e5 + 1000;
int n, u, v, a[maxn], b[maxn], vis[maxn];
vvi g(maxn);
 
void dfs1(int now, int step) {
	for (auto it : g[now]) {
		if (a[it] == -1) {
			a[it] = step + 1;
			dfs1(it, step + 1);
		}
	}
}
void dfs2(int now, int step) {
	for (auto it : g[now]) {
		if (b[it] == -1) {
			b[it] = step + 1;
			dfs2(it, step + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	ms(a, -1); ms(b, -1);
	cin >> n >> u >> v;
	forn(i, n - 1) {
		int e1, e2;
		cin >> e1 >> e2;
		g[e1].pb(e2);
		g[e2].pb(e1);
	}
	a[u] = 0;
	dfs1(u, 0);
	b[v] = 0;
	dfs2(v, 0);
	int ans = -1;
	for1(i, n) {
		if (a[i] < b[i]) {
			ans = max(ans, b[i]);
		}
	}
	cout << (ans - 1) << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int a, b;
  cin >> a >> b;
  cout << a / b + a % b << endl;
}

Measured memory_bytes: 3176
#include<iostream>
using namespace std;
int main(){
  int k,c;
  long all;

  while(cin >>k && k!=0){
    all=0;

    for(int i=0;i<k*(k-1)/2;i++){
      cin>>c;
      all+=c;}

    cout << all/(k-1)<<endl;}
  return 0;
}
  

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    ll N,M;
    cin >> N >>M;
    ll ans = 0;
    if((N*2)<M){
        ll sumMC = M-N*2;
        sumMC /= 4;
        ans = sumMC + N;
    } else {
        ans = M/2;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] cost = new int[n];
        int[] time = new int[n];
        for(int i = 0; i < n; i++){
            cost[i] = sc.nextInt();
            time[i] = sc.nextInt();
        }
        int mincos = 1001;
        for(int i = 0; i < n; i++){
            if(time[i] <= t && cost[i] < mincos){
                mincos = cost[i];
            }
        }
        if(mincos == 1001){
            System.out.print("TLE");
        } else {
            System.out.print(mincos);
        }
    }
}

Measured memory_bytes: 21332
parsons = int(input())
days, remaining_ammount = list(map(int, input().split()))
terms = [int(input()) for i in range(parsons)]

ans = parsons

for i in terms:
    cnt = i
    while 1 + i <= days:
        if True:
            ans += 1
            i += cnt

print(ans + remaining_ammount)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;
string s;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

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


int main(){
	int x,y;
	std::cin>>x>>y;
	std::cout<<gcd(x,y)<<std::endl;
	return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

int main() {

	int N;
	int d[105];

  	scanf("%d", &N);
  
	for(int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	
	
	// 降順に並べ替える
	for(int i = 0; i < N; i++) {
		for(int j = i + 1; j < N; j++) {
			
           if(d[j] == d[i]) {
             d[i] = 0;
           }
         	
          	if(d[j] > d[i]) {
				int tmp;
				tmp = d[i];
				d[i] = d[j];
				d[j] = tmp;
			}
		}
	
	}
	
   int count = 0;
	for(int i = 0; i < N; i++) { 
		if(d[i] == 0) {
          break;
        }
        count ++;
	}
	
   printf("%d", count);
}

Measured memory_bytes: 1708
import math

A, B, H, M = list(map(lambda n: int(n), input().split(" ")))

thetaM = 6 * M
thetaH = 30 * H + 0.5 * M
theta = math.radians(180 - abs(abs(thetaH - thetaM) - 180))

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)))

Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] x = new int[n][d];
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				if(isInteger(getDistance(x[i], x[j]))) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
	
	static boolean isInteger(double d) {
		int f = (int)Math.floor(d);
		if(d-f > 0)return false;
		else return true;
	}
	
	static double getDistance(int[] x1, int[] x2) {
		double d = 0;
		for (int i = 0; i < x1.length; i++) {
			d += Math.pow(x1[i]-x2[i], 2);
		}
		return Math.sqrt(d);
	}

}


Measured memory_bytes: 21844
NK = input().split()
N, K = int(NK[0]), int(NK[1])
S = list(input())

if(S[K-1] == "A"):
    S[K-1] = "a"
elif(S[K-1] == "B"):
    S[K-1] = "b"
elif(S[K-1] == "C"):
    S[K-1] = "c"
        
print("".join(S))


Measured memory_bytes: 3060
# AOJ 0240: Interest Rates
# Python3 2018.6.25 bal4u
 
while True:
    n = int(input())
    if n == 0: break   
    y = float(input())
    id, vmax = -1, 0
    for i in range(n):
        b, r, t = map(int, input().split())
        if t == 1: m = y*(r/100)+1
        else: m = (r/100+1)**y
        if id < 0 or m >= vmax: id, vmax = b, m
    print(id)


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

int main(){
    int num=0;
    char s[11]={},t[11]={};
    scanf("%s%s",s,t);
    while (s[num]!='\0') num++;
    if (strncmp(s, t, num)==0) printf("Yes");
    else printf("No");
    return 0;
}




Measured memory_bytes: 1768
import java.util.Scanner;


public class Main {
	public static void main(String args[]) {
		Scanner n = new Scanner(System.in);
		
		int N = n.nextInt();
		
		if(N >= 100) {
			N = N % 100;
		}
		
		if(N >= 10) {
			N = N % 10;
		}
		
		if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
			System.out.println("hon");
			
		}else if(N == 0 || N == 1 || N == 6 || N == 8) {
			System.out.println("pon");
			
		}else {
			System.out.println("bon");
		}
	}
}


Measured memory_bytes: 35592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;

import javax.print.attribute.standard.MediaSize.Other;
import javax.xml.bind.ParseConversionEvent;

public class Main {

	public static String[][] flick = new String[][]
			{
				{"wa",  "i", "nn",  "e", "wo"},
				{ "a",  "i",  "u",  "e",  "o"},
				{"ka", "ki", "ku", "ke", "ko"},
				{"sa", "si", "su", "se", "so"},
				{"ta", "ti", "tu", "te", "to"},
				{"na", "ni", "nu", "ne", "no"},
				{"ha", "hi", "hu", "he", "ho"},
				{"ma", "mi", "mu", "me", "mo"},
				{"ya", "yi", "yu", "ye", "yo"},
				{"ra", "ri", "ru", "re", "ro"}
			};
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		char[] input = sc.next().toCharArray();
		
		Map<Character, Integer> map = new HashMap<Character, Integer>();
		map.put('T', 0);
		map.put('L', 1);
		map.put('U', 2);
		map.put('R', 3);
		map.put('D', 4);
		
		int pos = 0;
		while(pos < input.length){
			int f = input[pos] - '0';
			int n = map.get(input[pos + 1]);
			
			System.out.print(flick[f][n]);
			
			pos += 2;
		}
		
		System.out.println();
	}

}

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

int main() {
  string a,b,c; cin>>a>>b>>c;
  char tmp = 'A'-'a';
  cout<<(char)(a[0]+tmp)<<(char)(b[0]+tmp)<<(char)(c[0]+tmp)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

vvll adj;
vll ans,visited;
ll n;

void dfs(ll root)
{
	visited[root]=1;
	vll dis(n+1);
	queue<ll> q;
	q.push(root);
	visited[root]=1;
	while(!q.empty())
	{
		ll val=q.front();
		q.pop();
		for(auto i:adj[val])
		{
			if(visited[i]==0)
			{
				q.push(i);
				visited[i]=1;
				dis[i]=dis[val]+1;
			//	db(i,dis[i],root);
				ans[dis[i]]++;
			}
		}
	}
}

int main()
{
	fastIO
	//inp_out();
	ll x,y;
	cin>>n>>x>>y;
	ans.resize(n);
	adj.resize(n+1);
	adj[x].pb(y);
	adj[y].pb(x);
	for(ll i=1;i<n;++i)
	{
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}

	for(ll i=1;i<=n;++i)
	{
		visited.clear();
		visited.resize(n+1,0);
		dfs(i);
	}

	for(ll i=1;i<n;++i)
	{
		cout<<ans[i]/2<<"\n";
	}

	

	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        String line2 = br.readLine();
        String[] str = line2.split(" ");
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i]=Integer.parseInt(str[i]);
        for(int i=0;i<n;i++){
        	int tmp = a[i];
        	int j = i-1;
        	while(j>=0&&a[j]>tmp){
        		a[j+1]=a[j];
        		j--;
        	}
        	a[j+1]=tmp;
        	for(int k=0;k<n;k++){
        		if(k!=n-1)System.out.print(a[k]+" ");
        		else System.out.println(a[k]);
        	}
        }
	}
}

Measured memory_bytes: 30196
n, *d = map(int, open(0).read().split())
a = [0] * (n + 1)
for x in d:
	a[x] += 1
mod = 998244353
if a[0] != 1 or d[0] != 0:
	print(0)
	exit()
if n == 1:
	print(1)
	exit()
ans = 1
bef = 1
cnt = 1
for x in a[1:]:
	cnt += x
	if x == 0:
		if cnt == n:
			break
		else:
			print(0)
			exit()
	ans *= bef ** x
	ans %= mod
	bef = x
print(ans)

Measured memory_bytes: 13956
d, g = map(int, input().split())
pc = [0] + [list(map(int, input().split())) for i in range(d)]
def dfs(d_, g_):
    if d_ == 0:
        return float("inf")
    cnt = min(g_ // (d_ * 100), pc[d_][0])
    cur = cnt * 100 * d_
    if cnt == pc[d_][0]:
        cur += pc[d_][1]
    if g_ > cur:
        cnt += dfs(d_ - 1, g_ - cur)
    return min(cnt, dfs(d_ - 1, g_))
print(dfs(d, g))

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const int max_n = 110, INF = 1e16;
int n;
bool f[max_n][10];
int p[max_n][10];
long long ans = -INF;

int main(){
    cin >> n;
    rep(i, n){
        rep(j, 10) cin >> f[i][j];
    }
    rep(i, n) rep(c, 11) cin >> p[i][c];

    for(int bit = 1; bit < (1 << 10); bit++){
        int sum = 0;
        for(int i = 0; i < n; i++){
            int tmp = 0;
            for(int j = 0; j < 10; j++){
                if(f[i][j] == true && ((bit >> j) & 1) == 1) tmp++; 
            }
            sum += p[i][tmp];
        }
        if(ans < sum) ans = sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    string sd, t;
    cin >> sd >> t;
    string s = sd;
    int ssd = SZ(sd);
    int st = SZ(t);
    
    bool restored = false;
    reab(i, ssd-st+1, 0){
        bool f = true;
        rep(j, st){
            if(sd[i+j] != t[j] && sd[i+j] != '?'){  
                f = false;
                break;
            }
        }
        if(f){
            s.replace(i, st, t);
            restored = true;
            break;
        }
    }
    if(restored){
        replace(ALL(s), '?', 'a');
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    string c[H];
    rep(i, H) {
        cin >> c[i];
    }
    int ans = 0;
    for (int h = 0; h < (1 << H); h++) {
        for (int w = 0; w < (1 << W); w++) {
            // cout << h << " " << w << endl;
            bool redH[H] = {}, redW[W] = {};
            rep(i, H) if ((1 << i) & h) redH[i] = true;
            rep(i, W) if ((1 << i) & w) redW[i] = true;
            int cnt = 0;
            rep(i, H) {
                if (redH[i]) continue;
                rep(j, W) {
                    if (redW[j]) continue;
                    if (c[i][j] == '#') cnt++;
                }
            }
            // cout << cnt << endl;
            if (cnt == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long H, W;
	cin >> H >> W;

	if(H == 1 || W == 1){
		printf("1\n");
		return 0;
	}

	long long ans = 0;
	long long b;
	if((H % 2) == 0){
		b = H / 2;
		ans = b*W;
	}
	else{
		b = (H / 2) + 1;
		ans = b * (W/2); 
		ans += (b-1) * (W/2);
		if((W % 2) == 1){
			ans += b;
		}
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3748
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {

            int i = 1;
            while (true)
            {
                int x = int.Parse(Console.ReadLine());
                if (x == 0)
                {
                    break;
                }

                Console.WriteLine("Case {0}: {1}", i, x);
                i++;


            }
        }
    }
}


Measured memory_bytes: 17928