akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    ll ans = 1LL;
    if (s[0] == t[0])
    {
        (ans *= 3LL) %= MOD;
        for (int i = 1; i < n; i++)
        {
            if (s[i] == t[i])
            {
                if (s[i - 1] == t[i - 1])
                {
                    (ans *= 2LL) %= MOD;
                }
            }
            else
            {
                if (s[i - 1] == t[i - 1])
                {
                    (ans *= 2LL) %= MOD;
                }
                else
                {
                    (ans *= 3LL) %= MOD;
                }
                i++;
            }
        }
    }
    else
    {
        (ans *= 6LL) %= MOD;
        for (int i = 2; i < n; i++)
        {
            if (s[i] == t[i])
            {
                if (s[i - 1] == t[i - 1])
                {
                    (ans *= 2LL) %= MOD;
                }
            }
            else
            {
                if (s[i - 1] == t[i - 1])
                {
                    (ans *= 2LL) %= MOD;
                }
                else
                {
                    (ans *= 3LL) %= MOD;
                }
                i++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define MYDEBUG
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
	int n, maxv, minv;
	maxv = -2000000000; //???????°??????????????????????????¨????
	cin >> n;
	cin >> minv;

	for (int i = 1; i < n; ++i) {
		int r;
		cin >> r; //R[i]??????????????????????????°????????????????±???????r??????????????????
		maxv = max(maxv, r - minv); //?????§????????´??°
		minv = min(minv, r); //???????????§???????°?????????????????????????
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define inf 1072114514

int min(int a, int b)
{
  if (a < b)
  {
    return a;
  }
  return b;
}

int sortfncsj(const void *a, const void *b)
{
  if (*(int *)a > *(int *)b)
  {
    return 1;
  }
  if (*(int *)a == *(int *)b)
  {
    return 0;
  }
  return -1;
}

int main(void)
{
  int i, n, k, a[524288], r = inf;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), sortfncsj);
  for (i = k - 1; i < n; i++)
  {
    r = min(r, a[i] - a[i - k + 1]);
  }
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 1020
N = int(input())
M = (N * (N - 1)) // 2

ans_lst = [[1] * N for _ in range(N)]

if N % 2 == 0:
    for i in range(N):
        ans_lst[i][N - i - 1] = 0
else:
    for i in range(N - 1):
        ans_lst[i][N - i -2] = 0
#output
M = 0
for i in range(N):
    for j in range(i + 1, N):
        if ans_lst[i][j] == 1:
            M += 1

print (M)
for i in range(N):
    for j in range(i + 1, N):
        if ans_lst[i][j] == 1:
            print (i + 1, j + 1)

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

int main(){
    string s;
    cin >> s;
    
    int n = s.size();
    int ans = 0;
    rep(i, n/2){
        if(s[i] != s[n-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
is_approved = True
l = list(map(int, input().split()))
for i in l:
    if i % 2 == 0:
        if not (i % 5 == 0 or i % 3 == 0):
            is_approved = False
            break
print('APPROVED' if is_approved else 'DENIED')

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int n;



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

    int X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll a[5005],p[5005],vis[5005];
int main(){
    ll n,k,ans=-2e9;cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>p[i];
    }
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    for(ll i=1;i<=n;i++){
        ll now=i,sum=0;
        vector<ll> c;
        c.push_back(0);
        while(vis[now]!=i){
            vis[now]=i;sum+=a[now];
            c.push_back(sum);now=p[now];
        }
        if(sum>0){
            ll mx=-2e9,s=c.size()-1;
            for(ll j=(k<s);j<=k&&j<c.size();j++){
                mx=max(mx,c[j]+(k-j)/s*sum);
            }
            ans=max(ans,mx);
        }
        else{
            ll mx=-2e9;
            for(ll j=1;j<=k&&j<c.size();j++){
                mx=max(mx,c[j]);
            }
            ans=max(ans,mx);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct Event {
    int x;
    int type; //0 start, 1 end
    int v;
    Event(int x, int type, int v):x(x), type(type), v(v) {
    }
};

bool cmp(const Event& a, const Event& b) {
    return a.x < b.x || (a.x == b.x && a.type > b.type);
}

int main() {
    int n, t;
    cin >> n >> t;
    vector<Event> events;
    for (int i = 0; i < n; i++) {
        int from, to;
        cin >> from >> to;
        events.push_back(Event(from, 0, 1));
        events.push_back(Event(to, 1, -1));
    }
    
    sort(events.begin(), events.end(), cmp);
    
    int ans = 0;
    int sum = 0;
    for (Event event : events) {
        if (event.x > t) {
            break;
        }
        sum += event.v;
        ans = max(ans, sum);
    }
    cout << ans << endl;    
}

Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(ll i = x; i < n; i++)


int main(){
  ll n,p; cin >> n >> p;
  ll ans = 1;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }

  ll a = 1;
  while(pow(a, n) <= p){
    ll i = pow(a, n);
    if(p % i == 0) ans = a;
    a++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int INF = 1 << 30;

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

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n, 0);
    vector<vector<int> > a(n, vector<int>(m, 0));
    REP(i, n) {
        cin >> c[i];
        REP(j, m)
            cin >> a[i][j];
    }

    int ans = INF;
    REP(mask, 1 << n) {
        vector<int> level(m, 0);
        int cost = 0;
        REP(i, n) {
            if ((mask >> i) & 1) {
                cost += c[i];
                REP(j, m) level[j] += a[i][j];
            }
        }
        bool ok = true;
        REP(j, m) if (level[j] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }

    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}


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


int main() {
int N,m,J;
  cin>>N;
  vector<int> x(N);
  for(int i=0;i<N;i++){
  cin>>x.at(i);
  }
  m=10000000000;
  int wa;
  for(int P=1;P<=100;P++){
    for(int i=0;i<N;i++){
     wa +=(x.at(i)-P)*(x.at(i)-P); 
    }
    m=min(m,wa);
    wa=0;
}
  cout<<m<<endl;
}


Measured memory_bytes: 256
N = int(input())

a = [int(i) for i in input().split()]

S = sum(a)

ans = 10 ** 18
x = 0
for i in range(N-1):
    x += a[i]
    ans = min(ans, abs((S-x)-x))

if N == 2:
    ans = abs(a[0]-a[1])
print(ans)

Measured memory_bytes: 24928
a=[input()for i in range(3)]
t,end="A",0
def turn(s):
  global t,end
  if s=="":end=1
  else:
    t=s[0].upper()
    return s[1:]
while end==0:
  if t=="A":a[0]=turn(a[0])
  elif t=="B":a[1]=turn(a[1])
  else:a[2]=turn(a[2])
print(t)

Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1)) + 1):
        if temp%i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    
    if temp != 1:
        arr.append([temp, 1])
    
    if arr == []:
        arr.append([n, 1])
    
    return arr

n = int(input())
line = factorization(n)
m = len(line)
ans = 0
for i in range(m):
    power = line[i][1]
    j = 1
    while power > 0:
        power -= j
        if power < 0:
            break
        j += 1
        ans += 1

if n == 1:
    print(0)
else:
    print(ans)


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

int fill_color(vector<vector<int>> &tree, unordered_map<int, unordered_map<int, int>> &color, int parent, int parent_color) {
  int max_color = 0;
  for (int i = 0; i < tree[parent].size(); i++) {
    int current_color;
    if (i + 1 < parent_color) {
      current_color = i + 1;
    } else {
      current_color = i + 2;
    }

    int child = tree[parent][i];
    color[parent][child] = current_color;

    int submax_color = fill_color(tree, color, child, current_color);

    if (max_color < current_color) max_color = current_color;
    if (max_color < submax_color)  max_color = submax_color;
  }
  return max_color;
}

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

  vector<int> a(n - 1);
  vector<int> b(n - 1);
  vector<vector<int>> tree(n + 1);
  unordered_map<int, unordered_map<int, int>> color;

  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    tree[a[i]].push_back(b[i]);
  }

  int max_color = fill_color(tree, color, 1, __INT_MAX__);
  
  cout << max_color << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << color[a[i]][b[i]] << endl;
  }
}


Measured memory_bytes: 18188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
/*==================================================*/
/*function*/

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

int main() {
    cin>>N;
    long long L0 = 2;
    long long L1 = 1;

    if(N == 1){
        cout<<L1<<endl;
        return 0;
    }

    REP(i,2,N+1){
        long long newL = L0 + L1;
        L0 = L1;
        L1 = newL;
        if(i == N){
            cout<<newL<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, K;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                K = line[1];
            }

            int[] H = new int[N];
            for (int i = 0; i < N; i++)
            {
                H[i] = Input.ReadInt();
            }

            Array.Sort(H);

            int ret = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                if (i + K - 1 >= N) continue;
                ret = Math.Min(ret, H[i + K - 1] - H[i]);
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 15584
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, c; cin >> a >> b >> c;
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc176/tasks/abc176_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string S;
    cin >> S;
    int t = 0;
    for (auto &x : S) {
        t += x - '0';
        // t %= 9;
    }
    if (t % 9 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

int main(){
  int n,a,b,sum,s;
  cin >> n >> a >> b;
  for(int i=1;i<=n;i++){
    int k=i;
    s=0;
    while(k!=0){
      s += k%10;
      k /= 10;
    }
    if((a<=s)&&(s<=b))sum+=i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;
int main()
{
    int i,count=0;

    string str;
    string change_str;

    cin >> str;
    cin >> change_str;

    for(i=0;i<change_str.length();i++){
        if(str[i]!=change_str[i]) count++;
    }
    
    cout << count;

    return 0;
}

Measured memory_bytes: 3928
while True:
    n, x = map(int, input().split())
    if (n + x) == 0:break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    ans += 1
    print(ans)


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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    long long base = A + B;
    long long answer = (N / base) * A;
    N -= (N / base) * base;
    answer += min(N, A);
    cout << answer << endl;
    return 0;
}

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

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

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

ll calc(ll n, ll div1, ll div2)
{
	return n - n/div1 - n/div2 + n/lcm(div1, div2);
}

int main(int argc, char **argv)
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	std::cout << calc(b,c,d) - calc(a-1,c,d) << std::endl;
}

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

int main()
{
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];
ll maxi=a[0];
ll c=1;
for(ll i=1;i<n;i++)
{
    if(maxi<=a[i])
    {
        maxi=a[i];
        c++;
    }
}
cout<<c<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N, K;
    cin >> N >> K;
    vll a(N+1);
    rep(i, N) cin >> a[i+1];

    ll c = 1;
    while(K) {
        if(K % 2 == 1) c = a[c];
        vll na(N+1);
        rep(i, N+1) na[i] = a[a[i]];
        swap(na, a);
        K /= 2;
    }
    cout << c << endl;
}


Measured memory_bytes: 6364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

char ca[100005];
LL t[30];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	cin>>ca;
	for(i=0;i<n;i++){
		a=(int)ca[i]-(int)'a';
		t[a]++;
	}
	for(i=0,a=1;i<26;i++){
		a*=(t[i]+1);
		if(a>=MAX)a%=MAX;
	}
	a--;
	if(a<0)a+=MAX;
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int n, m;
vs A(60), B(60);

bool match(int x, int y) {
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			if (A[i + y][j + x] != B[i][j]) {
				return false;
			}
		}
	}

	return true;
}

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

	cin >> n >> m;

	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < m; i++) cin >> B[i];

	bool flag = false;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			if (match(j, i)) {
				flag = true;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

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

int main(){

    int A, B;
    cin >> A >> B;

    vector<vector<char> > white(50, vector<char>(100, '.'));
    vector<vector<char> > black(50, vector<char>(100, '#'));
    A--; B--;

    for(int i = 1; i < 50 - 1; i += 2){
        if(A == 0) break;
        for(int j = 1; j < 100 - 1; j += 2){
            black[i][j] = '.';
            A--;
            if(A == 0) break;
        }
    }

    for(int i = 1; i < 50 - 1; i += 2){
        if(B == 0) break;
        for(int j = 1; j < 100 - 1; j += 2){
            white[i][j] = '#';
            B--;
            if(B == 0) break;
        }
    }

    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 100; j++){
            cout << white[i][j];
        }
        cout << endl;
    }
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 100; j++){
            cout << black[i][j];
        }
        cout << endl;
    }

    return 0;
}

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



int main(){
	int n;
	while(cin>>n&&n){
		int prev,a,b;
		bool f=false;
		cin>>a;
		prev=a;
		for(int i=1;i<n;i++){
			cin>>b;
			if(prev+1!=b){
				if(f)cout<<' ';
				f=true;
				if(prev!=a)cout<<a<<'-'<<prev;
				else cout<<a;
				a=b;
			}
			prev=b;
		}
		if(f)cout<<' ';
		if(prev!=a)cout<<a<<'-'<<prev;
		else cout<<a;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python
# DP解

x = int(input())
dp = [False for _ in range(x+1)]
dp[0] = True

if 1 <= x < 100:
    print(0)
    exit()

for i in range(1, 100):
    dp[i] = False
for i in range(100, x+1):
    tmp = False
    for j in range(6):
        if i-(100+j) >= 0:
            tmp = (tmp or dp[i-(100+j)])
    if tmp:
        dp[i] = True
    else:
        dp[i] = False

if dp[x]:
    print(1)
else:
    print(0)


Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;
 
int main(){
    int n, m, k[15], p[15], s[15][15], ans=0, on[15], count=0;
    int c, t;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> k[i];
        for(int j=0; j<k[i]; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0; i<m; i++){
        cin >> p[i];
    }
    for(int i=0; i<pow(2,n); i++){
        t=i;
        for(int j=0; j<n; j++){
            on[j] = t%2;
            t /= 2;
        }
        for(int j=0; j<m; j++){
            c=0;
            for(int r=0; r<k[j]; r++){
                c += on[s[j][r]];
            }
            if(c%2==p[j]) count++;
        }
        if(count==m) ans++;
        count = 0;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {

  long long N, X;
  cin >> N >> X;

  if (2*X == N) {
    cout << 3 * X << endl;
    return 0;
  }

  long long res = 0, a = X, b;
  if (2*X < N) {
    res = 2 * X + N;
    b = N - 2 * X;
  } else {
    res = N;
    b = N - X;
  }

  if (a > b) swap(a,b);

  while (a != b) {
    long long c = ceil((long double)(b - a) / a);
    res += a * 2 * c;
    tie(a,b) = make_pair(b-c*a,a);
  }

  // a == b の 平行四辺形
  cout << res + a << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, j;
	int a[3];
	int count = 0;

	for (i = 0; i < 3; i++)
		scanf("%d", &a[i]);

	for (i = a[0]; i <= a[1]; i++)
	{
		if (a[2] % i == 0)
			count++;
	}

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

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

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;

    cin >> s;
    cin >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), std::greater<char>());

    int isNo = 0;

    int i, len = min(s.size(), t.size());

    for (i = 0; i < len; i++) {
        if (s[i] < t[i]) {
            isNo = 1;

            break;
        } else if (t[i] < s[i]) {
            isNo = -1;

            break;
        }
    }

    if (isNo == 0) {
        if (s.size() < t.size()) isNo = 1;
        else isNo = -1;
    }

    if (isNo == -1) cout << "No" << '\n';
    else cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
N,*A = `dd`.split.map &:to_i

ns = (1..N).map{ [] }
A.each{ |a|
  (1..N).each{ |i|
    ns[i-1] << ((a == i) ? i : 0)
  }
}

op = []

(1..N).reverse_each{ |i|
  (1..i).reverse_each{ |a|
    if ns[a-1][a-1] == a
      op << a
      (1..N).each{ |j|
        ns[j-1].delete_at(a-1)
      }
      break
    end
  }
  if op.size < N-i+1
    p -1; exit
  end
}
puts op.reverse

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

int two_div(int n){
  int div=0;
  while(n%2==0){
    div++;
    n/=2;
  }
  return div;
}

int main(){
  int N;
  cin >> N;
  
  int m=0;
  int ans=1;
  for(int i=1; i<=N; i++){
    int temp=two_div(i);
    if(m<temp){
      ans=i;
      m=temp;
    }
  }
  cout << ans <<endl; 
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline int read() {
    int res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

String s;
int ans = INT_MAX, n;

int main() {
    std::cin >> s;
    ans = n = s.length();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) {
            int tmp = std::max(i + 1, n - i - 1);
            if (tmp < ans) ans = tmp;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    [A] = [int(input_raw[0])]

    if N % 500 <= A:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()

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

int main() {
  int N; cin >>N;
  vector<int> A(N);
  rep(i,0,N) cin >>A[i];
  int ans=0;
  while (true) {
    rep(i,0,N) {
      if (A[i]%2) {
        cout <<ans <<endl;
        return 0;
      }
      A[i]/=2;
    }
    ans++;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N,H;
    cin >> N >> H;
    vector<ll> a(N),b(N);
    rep(i,N){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    ll Ma = a[0];
    if(Ma >= b[0]){
        cout << (H+Ma-1)/Ma << endl;
        return 0;
    } 
    vector<ll> B;
    rep(i,N){
        if(Ma < b[i]){
            B.push_back(b[i]);
        }
    }
    ll cnt=0;
    rep(i,B.size()){
        H -= B[i];
        cnt++;
        if(H <= 0){
            break;
        }
    }
    if(H <= 0){
        cout << cnt << endl;
        return 0;
    }
    cnt += (H+Ma-1)/Ma;
    cout << cnt << endl;
}


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

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

    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        for(int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> nn(n);
    for (int i=0; i<m; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        nn.at(tmp1-1) += 1;
        nn.at(tmp2-1) += 1;
    }
    for (int i=0; i<n; i++) {
        cout << nn.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int a,b;cin >>a >> b;
  int cnt =0;
  int t = 1;
  while(t<b){
    ++cnt;
    --t;
    t+=a;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = {}
num = 0
for i in a:
    if i not in d:
        d[i] = 1
        num += 1

if num % 2 == 0:
    print(num - 1)
else:
    print(num)

Measured memory_bytes: 18152
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	cin >> N;
	vll A;
	ll i, j;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	ll ans = 0;
	ll e = A[N - 1];
	ans += e;
	ll now = A[N - 1];
	for (i = N - 2; i >= 0; i--){
		e = max(e - 1, (ll)0);
		now = A[i];
		if (now < e){
			cout << -1 << endl;
			return 0;
		}
		if (now > e){
			ans += now;
			e = now;
		}
	}
	if (now != 0){
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;

	return 0;
}



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

int dp[100010];

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

    int n,k;
    cin >> n >> k;
    
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,100010) dp[i] = 1e9;
    
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i-j>=0) {
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
            else {
                break;
            }
        }
    }
    
    cout << dp[n-1] << endl;
    
}


Measured memory_bytes: 1024
// icst and i'll ngu 
#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9+7;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define inf 1e18
int main()
{
	// ios_base:: sync_with_stdio(false); cin.tie(0);
	// freopen ("inp","r",stdin);
	// freopen ("out","w",stdout);
	int n;
	cin>>n;
	int a[n];
	ll tot=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		tot+=a[i];
	}
	ll curr=0,ans=inf;
	for(int i=0;i<n-1;i++)
	{
		curr+=a[i];
		ans=min(ans,abs(2*curr-tot));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  map<char,int> Achk;
  map<char,int> Bchk;
  for(int i = 0; i < N; i++) ++Bchk[S[i]];

  int cnt;
  int Ans = 0;

  for(int i = 0; i < N; i++){
    ++Achk[S[i]];
    --Bchk[S[i]];
    cnt = 0;
    for(auto x: Achk){
      if(Bchk[x.first]!=0) ++cnt;
    }
    Ans = max(Ans,cnt);
  }

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

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

ll dp[200002][3] = {};

int main() {
	IOS();
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		dp[i + 1][1] = dp[i][2] + 1;
		if (i >= 1 && s[i - 1] != s[i]) dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + 1);
		if (i == 0) continue;
		dp[i + 1][2] = dp[i - 1][1] + 1;
		if (i >= 3 && s.substr(i - 1, 2) != s.substr(i - 3, 2)) dp[i + 1][2] = max(dp[i + 1][2], dp[i - 1][2] + 1);
	}
	dump(max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 5268
import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    long[][] count = new long[10][10];
    int n = in.nextInt();

    for (int i = 1; i <= n; ++i) {
      int f = getFirst(i);
      int l = getLast(i);

      ++count[f][l];
    }

    long ans = 0;
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        ans += count[i][j] * count[j][i];
        //System.err.println(i + " " + j + " " + count[i][j]);
      }
    }

    out.println(ans);
  }

  private int getFirst(int n) {
    int ret = 0;
    while (n >= 10) {
      n /= 10;
    }
    return n % 10;
  }

  private int getLast(int n) {
    return n % 10;
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007


int main()
{
  string K;
  ull i,j,n,m,D,sum,ans;
  cin >> K >> D;
  sum=0;
  n=K.size();
  for(i=0;i<n;++i)
  {
    sum+=(int)K[i]-(int)'0';
  }
  vector<vector<ull>> dp(2);
  dp[0].resize(D,0);
  dp[1].resize(D);
  dp[0][0]=1;
  if(sum%D)
  {
    ans=BIG_PRIME-1;
  }
  else
  {
    ans=0;
  }
  for(i=0;i<n;++i)
  {
    m=(int)K[n-1-i]-(int)'0';
    sum-=m;
    for(j=0;j<m;++j)
    {
      ans = (ans+dp[0][(100000*D-sum-j)%D])%BIG_PRIME;
    }
    dp[1][D-1]=dp[0][D-1];
    for(j=1;j<=9;++j)
    {
      dp[1][D-1]=(dp[1][D-1]+dp[0][(10*D-1-j)%D])%BIG_PRIME;
    }
    for(j=1;j<D;++j)
    {
      dp[1][D-1-j]=(dp[1][D-j]+dp[0][(10*D-10-j)%D]+BIG_PRIME-dp[0][D-j])%BIG_PRIME;
    }
    for(j=0;j<D;++j)
    {
      dp[0][j]=dp[1][j];
    }
  }
  cout << ans;
  return 0;
}


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

using namespace std;

typedef long long ll;

char g[105][105];

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)
			cin >> g[i][j];
	}
	for(int i=0;i<w+2;i++){
    	g[0][i] = '#';
    	g[h+1][i] = '#';
	}
	for(int i=0;i<h+2;i++){
		g[i][0] = '#';
		g[i][w+1] = '#';
	}
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			cout << g[i][j];
		}
		cout << endl; 
	}
    
	return 0;
}


Measured memory_bytes: 256
# D - Recording

N, C = map(int, input().split())
max_time = 10**5
gantt = [[0] * (max_time + 1) for _ in range(C+1)]
stc = []

for _ in range(N):
    stc.append(list(map(int, input().split())))
    
stc = sorted(stc, key = lambda x: x[0])
stc = sorted(stc, key = lambda x: x[2])    

for idx in range(N):
    s, t, c = stc[idx][0], stc[idx][1], stc[idx][2]
    try:
        if stc[idx-1][2] == c and stc[idx-1][1] == s:
            gantt[c][s+1] += 1
        else:
            gantt[c][s] += 1
    except IndexError:
        gantt[c][s] += 1
    if t+1 <= max_time:
        gantt[c][t+1] -= 1

for c in range(C+1):
    for idx in range(1, max_time+1):
        gantt[c][idx] += gantt[c][idx-1]
    
import numpy as np
print(np.max(np.sum(gantt, axis = 0)))

Measured memory_bytes: 86128
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string str;
    cin >> str;
    int f = -1, c = INT_MAX;
    rep(i, str.size())
    {
        if (str[i] == 'C')
        {
            c = min(c, i);
        }
        if (str[i] == 'F')
        {
            f = max(f, i);
        }
    }
    if (f != -1 && c != INT_MAX && c < f)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}


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

int main() {
  int n,k,x;
  cin >> n >> k;
  if (k>=n) {
    puts("1");
    return 0;
  }
  for (int i=0;i<n;++i) {
    cin >> x;
    if (x==1) {
      x = i;
      break;
    }
  }
  int a,b,tmp,jwb;
  a = max(0, x+1-k);
  b = a+k-1;
  jwb = (a+k-2)/(k-1);
  jwb += (n-1-b+k-2)/(k-1);
  ++a; ++b;
  while (a<=x && b<n) {
    tmp = (a+k-2)/(k-1);
    tmp += (n-1-b+k-2)/(k-1);
    jwb = min(jwb, tmp);
    ++a; ++b;
  }
  ++jwb;
  cout << jwb << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-9;
const double PI = acos(-1);
const LL INFF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e5+7;
vector<LL>ans;
inline LL val(LL v){
	LL res = 0;
	while(v){
		res += v % 10;
		v /= 10;
	}
	return res;
}
void build(){
	rep1(i, 1, 10) ans.pb(i);
	LL bs = 10, cv = 19;
	while(1){
		if((cv + bs)*val(cv) < cv*val(cv + bs)){
			cv -= bs;
			bs *= 10; 
			cv += bs;
		}
		if(cv > 1e15) break;
		ans.pb(cv);
		cv += bs;
	}
	return ;
}
int main(void){
	build();
	DRI(n);
	rep(i, n) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long dp[87];
    dp[0] = 2;
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 256
b,s,o,i;main(a){for(scanf("%d",&i);i<20&&~scanf("%s",&a);b=a%3?a&1?o?b:(s=!printf("%d\n",b>3?s+b-3:s)):b+1:!(s+=++b))  o=a&1?-~o%3:o;return 0;}

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

int main(){
  int N;
  cin>>N;
  vector <int> ans(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    ans.at(a-1)=i+1;
  }
  for(int i=0;i<N;i++){
    cout<<ans.at(i)<<endl;
  }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<char> ch(26, '.');
    set<char> st;
    rep(i, t.length()) {
        if(st.find(t.at(i)) == st.end()) {
            ch.at(s.at(i) - 'a') = t.at(i);
            st.insert(t.at(i));
        }
    }
    bool flag = true;
    rep(i, s.length()) {
        if(ch.at(s.at(i) - 'a') != t.at(i)) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main()
{
    long long n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    bool chk[2][52];
    memset(chk,0,sizeof(chk));
    long long colors=1;
    int c=2;
    for(int i=0; i<n; i++)
    {

        if(i+1<n&&s1[i]==s1[i+1])
        {
            // int c;

            // cout<<s1[i]<<" "<<s1[i+1] <<" "<<c<<endl;
            if(i==0)c=6;
            else c=c+1;

            colors*=c;

            colors%=MOD;
            c=2;
            chk[0][i]=1;
            chk[0][i+1]=1;
            chk[1][i]=1;
            chk[1][i+1]=1;
            i++;
        }

        else if(s1[i]==s2[i])
        {
           // int c;
            if(i==0)
                c=3;
            if(i!=0&&s1[i-1]==s2[i-1])
            {
                c=2;

            }


            else if(i!=0)
                c=1;
            colors=(colors*c)%MOD;
            c=1;
            chk[0][i]=1;
            chk[1][i]=1;
          //  cout<<s1[i]<<" "<<s1[i] <<" "<<c<<endl;
        }
    }
    cout<<colors<<endl;
    //main();
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    priority_queue<pair<long long, int>> pq;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        pq.push(make_pair(a, 1));
    }
    for(int i = 0; i < m; i++){
        int b;
        long long c;
        cin >> b >> c;
        pq.push(make_pair(c, b));
    }
    long long ans = 0;
    int cnt = 0;
    while(cnt < n){
        pair<long long, int> p = pq.top();
        pq.pop();
        if(cnt+p.second <= n){
            ans += p.first * p.second;
            cnt += p.second;
        }
        else{
            ans += p.first * (n-cnt);
            cnt = n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define ri register int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
typedef long long ll;
inline ll readl(){
	ll ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline int Read(bool*s){
	int top=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))s[++top]=ch^48,ch=gc();
	return top;
}
const int N=45;
int n;
ll f[N][N][N],res=0;
bool trans[N][N];
ll dfs(int l,int r,int p){
	if(~f[l][r][p])return f[l][r][p];
	if(l==r)return f[l][r][p]=1;
	if(l==p||r==p)return f[l][r][p]=0;
	ll res=0ll;
	for(ri _l=l;_l<p;++_l)for(ri _r=r;_r>p;--_r)if(trans[_l][_r])
	for(ri a=_l;a<p;++a)for(ri b=_r;b>p;--b)res+=dfs(l,a,_l)*dfs(a+1,b-1,p)*dfs(b,r,_r);
	return f[l][r][p]=res;
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	memset(f,-1,sizeof(f));
	for(ri i=1;i<=n*2;++i)Read(trans[i]);
	if(n==1)return cout<<trans[1][2],0;
	for(ri i=3;i<n*2;++i)(trans[1][i])&&(res+=dfs(2,n*2,i));
	cout<<res;
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main()
{
  int x,y,a;

  while(1)
    {
      scanf("%d %d", &x , &y );
      if( x == 0 && y == 0) break;
      if( x > y )
	{
	  a = x;
	  x = y;
	  y = a;
	}
      printf("%d %d\n", x , y );
    }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,m;
int a[305][305],p[305],num[305],mini=1000000,h[1005];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for (;;){
		for (int i=0;i<n;i++){
			num[a[i][p[i]]]++;
		}
		int nm=1;
		for (int i=1;i<=m;i++){
			if (num[i]>num[nm]) nm=i;
		}
		if (num[nm]<mini) mini=num[nm];
		h[nm]=1;
		for (int i=0;i<n;i++){
			int it=(a[i][p[i]]==nm);
			if (it) p[i]++;
			while (h[a[i][p[i]]] && p[i]<m) p[i]++;
		}
		for (int i=0;i<n;i++){
			if (p[i]==m){
				cout<<mini;
				return 0;
			}
		}
		for (int i=0;i<=m;i++) num[i]=0;
	}
} 

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n,a,b,c,d,t1,t2;
	cin >> n >> a >> b >> c >> d;

	if(n%a == 0) t1 = n/a*b;
	else t1 = (n/a+1)*b;

	if(n%c == 0) t2 = n/c*d;
	else t2 = (n/c+1)*d;

	cout << min(t1,t2) << endl;

	return 0;

}



Measured memory_bytes: 3220
n = gets.to_i
array = gets.split().map(&:to_i)

n.times do |i|
  v = array[i]
  j = i - 1
  while j >= 0 and array[j] > v
    array[j+1] = array[j]
    j -= 1
  end
  array[j+1] = v
  puts array.join(" ")
end



Measured memory_bytes: 6892
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		@SuppressWarnings("resource")
		final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		final int N = in.nextInt();
		final int K = in.nextInt();
		final String S = in.next();
		String R = solve(S, K);
		System.out.println(R);
	}

	public static boolean isPossibleMonth(String m) {
		final int val = Integer.parseInt(m);
		return val <= 12 && val >= 1;
	}

	static String solve(final String S, final int K) {
		final char[] chars = S.toCharArray();
		chars[K - 1] = (char) (chars[K - 1] - 'A' + 'a');
		return new String(chars);
	}
}


Measured memory_bytes: 21844