akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &A, &B, &K)

	for i := A; i <= B; i++ {
		if i < A+K || i > B-K {
			fmt.Println(i)
		}
	}

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
	ll n; cin >> n;
	ll po[n];
	set<ll> hidari, migi;
	hidari.insert(1);
	migi.insert(n);
	for(ll i = 0; i < n; ++i){
		ll a; cin >> a;
		po[--a] = i;
		hidari.insert(-i);
		migi.insert(i);
	}
	ll ans = 0;
	for(ll i = n - 1; i >= 0; --i){
		ll si = -(*hidari.upper_bound(-po[i]));
		ll na = *migi.upper_bound(po[i]);
		hidari.erase(-po[i]);
		migi.erase(po[i]);
		ans += (i + 1) * (po[i] - si) * (na - po[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20608
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		string a = to_string(i);
		if (a.length() % 2 == 1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
vll palin(ll N, ll k) {
	if (N == 0) { return {}; }
	if (N % 2 == 0) {
		vll ret = palin(N-1, k + 1);
		ret.push_back(k);
		ret.push_back(k);
		return ret;
	}

	vll ret(1, k);
	vll ad = palin(N / 2, k + 1);
	ret.insert(ret.end(), ad.begin(), ad.end());
	ret.push_back(k);
	return ret;
}

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

	vll ans = palin(N, 1);
	ll M = ans.size();
	cout << M << endl;
	for(ll i = 0; i < M; i += 2) { cout << ans[i] << " "; }
	for (ll i = M - 1; i >= 0; i -= 2) { cout << ans[i] << " "; }
	cout << endl;

	


}

Measured memory_bytes: 3648
from heapq import heappush, heapify, heappop
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=1)
h = [-a[0]]
heapify(h)
ans = 0
for i in range(1, n):
    ans -= heappop(h)
    heappush(h, -a[i])
    heappush(h, -a[i])
print(ans)


Measured memory_bytes: 105184
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
using mint = modint<998244353>;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
	}
	vector<int> xp(N), yp(N);
	for (int i = 0; i < N; ++i) {
		xp[i] = i;
		yp[i] = i;
	}
	sort(xp.begin(), xp.end(), [&](int i, int j) { return X[i] < X[j]; });
	sort(yp.begin(), yp.end(), [&](int i, int j) { return Y[i] < Y[j]; });
	for (int i = 0; i < N; ++i) {
		X[xp[i]] = i;
		Y[yp[i]] = i;
	}
	vector<mint> pw(N);
	pw[0] = 1;
	for (int i = 1; i < N; ++i) {
		pw[i] = pw[i - 1] * 2;
	}
	vector<int> bit(N + 1);
	mint ans = pw[N - 1] * N;
	for (int i : xp) {
		mint sub = pw[N - 1] - 1;
		sub -= pw[X[i]] + pw[Y[i]] + pw[N - X[i] - 1] + pw[N - Y[i] - 1] - 4;
		int part = 0;
		for (int j = Y[i]; j >= 1; j -= j & (-j)) {
			part += bit[j];
		}
		for (int j = Y[i] + 1; j <= N; j += j & (-j)) {
			++bit[j];
		}
		int pa = part;
		int pb = X[i] - pa;
		int pc = Y[i] - pa;
		int pd = N - 1 - pa - pb - pc;
		sub += pw[pa] + pw[pb] + pw[pc] + pw[pd] - 4;
		ans += sub;
	}
	cout << ans.get() << endl;
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
sum = 0
for i in range(1, N+1):
  sum = sum + i
for j in range(0, N+1, 3):
  sum = sum - j
for k in range(0, N+1, 5):
  sum = sum - k
for l in range(0, N+1, 15):
  sum = sum + l
print(sum)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n,q; cin>>n>>q;
    string t; cin>>t;

    ll s[n+1]; s[0]=0;
    rep(i,n){
        if(t.substr(i,2)=="AC") s[i+1]=s[i]+1;
        else s[i+1]=s[i];
    }
    rep(i,q){
        int l,r; cin>>l>>r;
        l--; r--;
        cout<<s[r]-s[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4544
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var dx = ps.Select((p, i) => new { p, i }).ToLookup(_ => _.p[0]);
		var dy = ps.Select((p, i) => new { p, i }).ToLookup(_ => _.p[1]);

		var uf = new UF(n);
		foreach (var g in dx)
		{
			var p0 = g.First();
			foreach (var p in g) uf.Unite(p0.i, p.i);
		}
		foreach (var g in dy)
		{
			var p0 = g.First();
			foreach (var p in g) uf.Unite(p0.i, p.i);
		}

		var r = 0L;
		foreach (var g in uf.ToGroups())
			if (g.Count() > dx[ps[g.First()][0]].Count())
				r += (long)g.Select(i => ps[i][0]).Distinct().Count() * g.Select(i => ps[i][1]).Distinct().Count() - g.Count();
		Console.WriteLine(r);
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
	public int[][] ToGroups() => Enumerable.Range(0, p.Length).GroupBy(GetRoot).Select(g => g.ToArray()).ToArray();
}


Measured memory_bytes: 51856
def dfs(formula, index):
    if index + 1 == max_index:
        return sum(list(map(int, formula.split("+"))))

    return dfs(formula + "+" + S[index + 1], index + 1) + dfs(formula + S[index + 1], index + 1)


S = input()
max_index = len(S)
print(dfs(S[0], 0))


Measured memory_bytes: 38896
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)
#define ll long long

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void Main() {
    int N, M; cin >> N >> M;
    int minId = 0;
    int maxId = 10000000;

    rep(i, M) {
        int L, R; cin >> L >> R;
        chMax(minId, L);
        chMin(maxId, R);
    }

    int nb = std::max(maxId - minId + 1, 0);

    cout << nb << endl;
}

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

    return 0;
}


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

using namespace std;

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

  string s;
  cin >> s;
  if (s.size()%2 != 0){
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < s.size();i+=2){
    if (s.substr(i, 2) != "hi"){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p = (ll)1e9 + 7;
ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)ans = (ans % m) * (a % m) % m;
        b /= 2;
        a = (a % m) * (a % m) % m;
    }
    ans %= m;
    return ans;
}
ll inv(ll x, ll p)
{
    return pow(x, p - 2, p);
}
ll C(ll n, ll m, ll p)
{
    if(m > n)return 0;
    ll up = 1, down = 1;
    for(int i = n - m + 1; i <= n; i++)up = up * i % p;
    for(int i = 1; i <= m; i++)down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

int main()
{
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	ll ans = pow(2,n,p)-1;
	ll t1 = Lucas(n,a,p);
	ll t2 = Lucas(n,b,p);
	ans -= t1;
	ans = (ans+p)%p;
	ans -= t2;
	ans = (ans+p)%p;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		while(true){
//			System.gc();
			int h = sc.nextInt();
			int w = sc.nextInt();

			if(h == 0){
				break;
			}

			char[][] input = new char[h][w];

			for(int i = 0; i < h; i++){
				input[i] = sc.next().toCharArray();
			}

			String result = "";
			int dx[] = {0,1,1,1,0,w-1,w-1,w-1};
			int dy[] = {h-1,h-1,0,1,1,1,0,h-1};
			boolean visit1[][] = new boolean[h][w];
			boolean visit2[][] = new boolean[h][w];

			StringBuffer tmpResult;

			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					for(int k = 0; k < h; k++){
						for(int l = 0; l < w; l++){
							if(i == k && j == l){
								continue;
							}

							if(input[i][j] != input[k][l]){
								continue;
							}

							if(i*w + j >= k*w + l){
								continue;
							}

							for(int d1 = 0; d1 < 8; d1++){
								for(int d2 = 0; d2 < 8; d2++){
									for(int p = 0; p < h; p++){
										Arrays.fill(visit1[p], false);
										Arrays.fill(visit2[p], false);
									}

									int x1 = j, y1 = i, x2 = l, y2 = k;
//									String tmpResult = "";
//									tmpResult = "";
									tmpResult = new StringBuffer();
									while(input[y1][x1] == input[y2][x2]){
//										tmpResult += input[y1][x1];
										tmpResult.append(input[y1][x1]);
										visit1[y1][x1] = true;
										visit2[y2][x2] = true;

										x1 = (x1 + dx[d1])%w;
										y1 = (y1 + dy[d1])%h;
										x2 = (x2 + dx[d2])%w;
										y2 = (y2 + dy[d2])%h;

										if(visit1[y1][x1] || visit2[y2][x2]){
											break;
										}
									}

									if(tmpResult.length() > result.length() ||
											(tmpResult.length() == result.length() && tmpResult.toString().compareTo(result) < 0)){
//										result = tmpResult;
										result = tmpResult.toString();
									}
//									System.gc();
								}
							}
//							System.gc();
						}
						//System.gc();
					}
				}
			}

			System.out.println(result.length() >= 2 ? result : 0);
//			System.gc();
		}
	}

}



Measured memory_bytes: 162920
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  cout<<(x-a)%b<<endl;
  return 0;
  }

  

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct UF {
    int n;
    vector<int> parent;
    vector<int> size;
    
    UF(int n): n(n) {
        size.assign(n + 1, 1);
        parent.assign(n + 1, 0);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
        }
    }
    
    void unite(int u, int v) {
        int i = findRoot(u);
        int j = findRoot(v);
        if (size[i] < size[j]) {
            parent[i] = j;
            size[j] += size[i];
        }
        else {
            parent[j] = i;
            size[i] += size[j];
        }
    }
    
    bool find(int u, int v) {
        return findRoot(u) == findRoot(v);
    }
    
    int findRoot(int u) {
        //Can add path compression here
        while (u != parent[u]) {
            u = parent[u];
        }
        return u;
    }
    
};


struct Node {
    int vertex;
    int dist;
    
    Node(int vertex, int dist):vertex(vertex), dist(dist){}
    
    bool operator<(const Node& other) const {
        return dist > other.dist;
    }
};

struct Edge {
    int from, to;
    int weight;
    Edge(int from, int to, int weight):from(from), to(to), weight(weight){}
    
    int other(int u) {
        return from == u? to: from;
    }
    
    bool operator<(const Edge& other) const {
        return weight < other.weight;
    }
};



struct Kruskal {
    int n;
    vector<Edge> edges;
    vector<vector<int>> g;
    
    Kruskal(int n):n(n) {
        g.assign(n + 1, vector<int>());
    }
    
    void addEdge(int from, int to, int w) {
        edges.push_back(Edge(from , to, w));
        g[from].push_back(edges.size() - 1);
        g[to].push_back(edges.size() - 1);
    }
    
    int solve(int s) {
        UF uf(n + 1);
        
        int total = 0;
        
        sort(edges.begin(), edges.end());
        
        for (Edge edge : edges) {
            if (!uf.find(edge.from, edge.to)) {
                total += edge.weight;
                uf.unite(edge.from, edge.to);
            }
        }
        
        return total;
    }
    
};

int main() {
    int v, e;
    cin >> v >> e;
    Kruskal d(v);
    for (int i = 0; i < e; i++) {
        int from, to, w;
        cin >> from >> to >> w;
        d.addEdge(from, to, w);
    }
    int ans = d.solve(0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int cost = 0;
  if(A<B){
    cost += A;
  }else{
    cost += B;
  }
  
  if(C<D){
    cost += C;
  }else{
    cost += D;
  }
  
  cout << cost << endl;
  
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0 || s[i] != s[i - 1]) res++;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n, x;
	cin>>n>>x;
	if(x==1 || x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	for(int i = 1, o = 1; i <= 2*n-1; i++){
		if(n-1<=i && i<=n+1){
			o--;
			if(i==n-1) cout<<1<<endl;
			else if(i==n) cout<<x<<endl;
			else cout<<2*n-1<<endl;
		} else {
			if(i+o==x) o++;
			cout<<i+o<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#define L64 long long

struct Snukes{
    Snukes(L64 i, double s):index(i),snuke(s){}
    L64 index;
    double snuke;
};

Snukes getSnuke(L64 index)
{
  L64 denom = 0;
  L64 tmp = index;
  while(0 < tmp){
    L64 a = tmp % 10;
    denom += a;
    tmp /= 10;
  }
  double snk = index / (1.0 * denom);
  return Snukes(index, snk);
}

int main(void)
{
  int k;
  std::cin >> k;
  std::deque<Snukes> snks;
  for(int dig = 1; dig <= 16; dig++){
    if(dig == 1) {
      for(int i = 1; i <= 9; i++){
        snks.push_front(Snukes(i, 1));
      }
    }
    else if(dig <= 3) {
      L64 base = 0;
      L64 mul = 1;
      for(int i = 2; i <= dig; i++){
        base = base * 10 + 9;
        mul *= 10;
      }
      for(L64 i = 1; i <= 9; i++){
        L64 v = base + mul * i;
        snks.push_front(getSnuke(v));
      }
    }
    else if(dig <= 14) {
      L64 base = 0;
      L64 mul = 1;
      for(int i = 3; i <= dig; i++){
        base = base * 10 + 9;
        mul *= 10;
      }
      for(L64 i = 10; i <= 99; i++){
        L64 v = base + mul * i;
        snks.push_front(getSnuke(v));
      }
    }
    else {
      L64 base = 0;
      L64 mul = 1;
      for(int i = 4; i <= dig; i++){
        base = base * 10 + 9;
        mul *= 10;
      }
      for(L64 i = 100; i <= 999; i++){
        L64 v = base + mul * i;
        snks.push_front(getSnuke(v));
      }
    }
  }
  double snkmax = snks.front().snuke;
  for(Snukes& snk : snks){
    if(snkmax < snk.snuke){
      snk.index = -1;
    } else {
      snkmax = snk.snuke;
    }
  }
  int cnt = 0;
  size_t sz = snks.size();
  for(size_t t = 0; t < sz; t++){
    size_t i = sz - t - 1;
    if(snks[i].index < 0) continue;
    std::cout << snks[i].index << std::endl;
    cnt++;
    if(cnt == k){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    while True:
        r=a%b
        if r==0:
            return b
        a, b = b, r

def gcf(a,b):
    return a*b//gcd(a,b)

N=int(input())
ans=1
for _ in range(N):
    t=int(input())
    ans=gcf(ans,t)
print(ans)



Measured memory_bytes: 2940
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>

using namespace std;

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

    a--, b--;

    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int a,b; cin>>a>>b;
    rep(i,1,1000){
        int t1=i*0.08;
        int t2=i*0.1;
        if(t1==a&&t2==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  sort(all(d));
  d.erase(unique(all(d)), d.end());
  cout << d.size() << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#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

using namespace std;

int digits(lint x){
    int cnt = 0;
    while(x > 0){
        x /= 10;
        cnt++;
    }
    return cnt;
}

int main(){
    lint n;
    cin >> n;
    int ans;
    for(lint i = sqrt(n) ; i >= 1 ; i--){
        if(n % i == 0){
            lint res = n / i;
            ans = digits(res);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

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

const ll MOD = 1000000000 + 7;
const ll INF = LLONG_MAX;
const ll MAX_V = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

int n, color[100005]{};
vector<int> G[100005], path;

bool dfs(int from, int to) {
    if (to == n - 1) {
        path.push_back(n - 1);
        return true;
    }
    if (G[to].size() == 1) return false;

    for (int i = 0; i < G[to].size(); i++) {
        if (G[to][i] == from) continue;
        if (dfs(to, G[to][i])) {
            path.push_back(to);
            return true;
        }
    }
    return false;
}

void paint(int from, int to) {
    if (color[to]!=0 && color[to] != color[from]) return;
    color[to] = color[from];
    for (int i = 0; i < G[to].size(); i++) {
        if (G[to][i] == from) continue;
        paint(to, G[to][i]);
    }
}

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

    for (int i = 0; i < G[0].size(); i++) {
        if (dfs(0, G[0][i])) break;
    }
    path.push_back(0);
    reverse(path.begin(), path.end());
    
    for (int i = 0; i < path.size(); i++) {
        int c;
        if (i < (path.size() + 1) / 2)
            c = 1;
        else
            c = 2;
        color[path[i]] = c;
    }
    paint(0, 0);
    paint(n - 1, n - 1);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (color[i] == 1) cnt++;
    }
    if (cnt * 2 > n)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	
	int a[n];
	map<int , int> mp;
	for(int i=0;i<n-1;i++)
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	
	for(int i=1;i<=n;i++)
	{
		cout << mp[i] << endl ;
	}
	return 0;
}

Measured memory_bytes: 13376
def main():
    S = input()
    T = input()

    ans = 10**4
    for i in range(len(S)-len(T) + 1):
        count = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                count += 1

        if ans > count :
            ans = count 

    if ans == 10**4:
        print(len(T))
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll tt) {
    ll d,t,s;
    cin>>d>>t>>s;
    if(ceil((ld)d/s)<=t) cout<<"Yes\n";
    else cout<<"No\n";    
} 

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n, a[200009];
vector<std::pair<int, int> > dhth;

bool check(int d) {
	dhth.clear();
	dhth.push_back(std::make_pair(0, 0));
	for (int i = 1; i <= n; ++i)
		if (a[i] <= a[i - 1]) {
			while (dhth.back().first > a[i]) dhth.pop_back();
			for (int j = a[i]; ; --j) {
				if (j < 1) return false;
				int t = 1;
				if (dhth.back().first == j) t = 1 + dhth.back().second, dhth.pop_back();
				if (t < d) {
					dhth.push_back(make_pair(j, t));
					break;
				}
			}
		}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int liiiii = 1, riiiii = n;
	while (liiiii < riiiii) {
		int mid = (liiiii + riiiii) / 2;
		if (check(mid)) riiiii = mid;
		else liiiii = mid + 1;
	}
	printf("%d\n", liiiii);
}


Measured memory_bytes: 1024
N = int(input())
grids = [[s for s in input()],[s for s in input()]]
MOD = 1000000007

if grids[0][0] == grids[1][0]:
  prv_row_type = 1
  ans = 3
  posx = 1
else:
  prv_row_type = -1
  ans = 6
  posx = 2

while posx < N:
  if grids[0][posx] ==  grids[1][posx]:
    if prv_row_type == 1: ans  *= 2
    else: ans *= 1
    prv_row_type = 1
    posx += 1
  else:
    if prv_row_type == 1: ans *= 2
    else: ans *= 3
    prv_row_type = -1
    posx += 2

print(ans%MOD)

Measured memory_bytes: 38256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.ReadLine();
		Console.WriteLine(read().Zip(read(), (x, y) => x - y).Where(x => x > 0).Sum());
	}
}


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

x = []
y = []

S = []

ans = 0

for i in range(N):
    A = int(input())
    xy = []
    for j in range(A):
        X, Y = list(map(int, input().split()))
        x.append(X)
        y.append(Y)
        xy.append([X, Y])
    S.append(xy)

for i in range(2**N):
    flag = True
    t = bin(i).count('1')
    for j in range(N):
        if i & (1 << j):
            for p in S[j]:
                if ((i >> (p[0]-1)) & 1) != p[1]:
                    flag = False
                    break
    if flag == True:
        if ans < t:
            ans = t


print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            long sum=0;
            for(var i=0;i<N;i++){
                sum += a[i]-1;
            }
            Console.WriteLine(sum);
        }
    } 
}

Measured memory_bytes: 11200
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define INF (int)1e9
#define MOD (int)(1e9+7)
#define endl "\n"
typedef long long ll;
using namespace std;
//https://atcoder.jp/contests/dp/tasks/dp_a
int main(){
    int n; cin>>n; int h[n];
    for(int i=0; i<n; i++)
        cin>>h[i];
    int dp[n]; dp[0]=0; dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++)
        dp[i]=min(abs(h[i]-h[i-2])+dp[i-2], abs(h[i]-h[i-1])+dp[i-1]);
    cout<<dp[n-1]<<endl;

return 0;
}


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

int main(){
  int N;
  cin >> N;
  int count = 0;
  int A[N];
  bool flg = true;
  
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  while(flg){
    for(int i = 0; i < N; ++i){
      if(A[i] % 2 == 0) A[i] /= 2;
      else{
        flg = false;
        break;
      }
    }
    if(flg) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100];
int n,ans,bns,k1,k2;
bool a[30],b[30];
int main() {
	cin>>n>>s;
	for(int i=1; i<n; i++) {
		for(int j=0; j<i; j++) {
			a[s[j]-97]=true;
		}
		for(int j=i; j<n; j++) {
			b[s[j]-97]=true;
		}
		for(int j=0; j<26; j++) if(a[j]==1&&b[j]==1) bns++;
		if(ans<bns) ans=bns;
		bns=0;
		for(int j=0; j<26; j++) a[j]=0,b[j]=0;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      cout << '9';
    else
      cout << '1';
  }
  cout << endl;
  return 0;
}

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


void solve(std::string S){
    int cnt = 0;
    for(int i = 0;i < S.size();i++){
        if(S[i] != S[S.size()-i-1]){
            cnt++;
        }
    }
    cout<<cnt/2<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
from math import sqrt
from itertools import permutations
def dist(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for q in permutations(data):
    for i in range(1,n):
        ans += dist(q[i-1],q[i])
for i in range(n):
    ans /= (i+1)
print(ans)

Measured memory_bytes: 40812
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> v(N), P(N), Q(N);
  for (int i = 0; i < N; ++i) v[i] = i+1;
  for (int i = 0; i < N; ++i) std::cin >> P[i];
  for (int i = 0; i < N; ++i) std::cin >> Q[i];

  int p = -1, q = -1;
  int idx = 0;
  do {
    bool is_p = true, is_q = true;
    for (int i = 0; i < v.size(); ++i) {
      if (v[i] != P[i]) is_p = false;
      if (v[i] != Q[i]) is_q = false;
      if (!is_p && !is_q) break;
    }
    if (is_p) p = idx;
    if (is_q) q = idx;
    if (p >= 0 && q >= 0) break;
    ++idx;
  } while(next_permutation(v.begin(), v.end()));

  std::cout << std::abs(p-q) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int T, A, N;
  cin >> N >> T >> A;
  int dis = (T - A) * 1000 / 6;
  int ans = 0;
  int iti = 0;
  int ni = 10000000;
  for ( int i = 1; i <= N; i ++) {
    int kn;
    cin >> kn;
    iti = max(kn - dis, dis - kn);
    if (iti < ni){
      ni = iti;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    S = [i for i in input()]
    ans = 0
    b_cnt = 0
    for i in range(len(S)):
        if S[i] == "B":
            b_cnt += 1
        elif S[i] == "W":
            ans += b_cnt
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60000
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define REP(i, a) for (int (i) = (a)-1; (i) >= 0; (i)--)
#define REPS(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define INF 2e9

int bit;
int D, G;
int v[10];
int c[10];
int p[10];
int V[10];

void culc(int& cost, int& score)
{
	int t = bit;
	int i = 0;
	cost = 0;
	score = 0;
	while(t) {
		if (t % 2 == 1) {
			cost += p[i];
			score += V[i];
		}
		i++;
		t >>= 1;
	}
	score = min(G, score);
}

void rest(int& cost, int& score)
{
	int t = bit;
	int i2 = -1;
	int pt = -1;
	rep(i, D) {
		if (t % 2 == 0) {
			pt = (G - score + v[i] - 1) / v[i];
			i2 = i;
		}
		t >>= 1;
	}
	if (i2 == -1) return;
	if (pt >= p[i2]) return;
	else {
		cost += pt;
		score = G;
	}
}

int main()
{
	cin >> D >> G;
	G /= 100;
	int mi = 0;
	rep(i, D) {
		cin >> p[i] >> c[i];
		v[i] = i+1;
		c[i] /= 100;
		V[i] = v[i]*p[i] + c[i];
		mi += p[i];
	}
	for (bit = 0; bit < (1 << D); bit++) {
		int cost;
		int score;
		culc(cost, score);
		if (score != G) rest(cost, score);
		if (score == G) mi = min(mi, cost);
	}
	cout << mi << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n;
    while(1) {
        cin >> n;
        if(n == 0) break;
        vector<int> point(n, 0);
        for(int i = 0; i < n; ++i) cin >> point[i];
        sort(point.begin(), point.end());
        int sum = 0;
        for(int i = 1; i < n-1; ++i) sum += point[i];
        cout << sum/(n-2) << endl;
    }
}


Measured memory_bytes: 3164
import sys
lines = sys.stdin.readlines()

h, w = [int(x) for x in lines[0].split()]
lines[0] = '#' * (w + 2)
for i in range(1, h+1):
    lines[i] = '#' + lines[i].rstrip() + '#'
lines.append('#' * (w + 2))

for i in range(h+2):
    print(lines[i])



Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N,K;

ll rem=0;
ll Sum(ll num){
	ll sum=0;
	ll sum2=0;
	if(num == N+2){
		return 0;
	}

	sum=((num-1)%BUFSIZE)*(num%BUFSIZE)/2;

	sum2=(N*2+1-num)*num/2;
	rem=rem + sum2 - sum + 1;
	rem=rem%BUFSIZE;
	Sum(num+1);
	return 0;
}

int main(void){
	scanf("%d",&N);
	scanf("%d",&K);
	if(N < K){
		printf("1");
		exit(0);
	}
	
	Sum(K);
	
		printf("%lld",rem%BUFSIZE);
	
}

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

using namespace std;

using ll = long long;

int main() {
    std::string S;
    ll K;

    cin >> S >> K;

    ll num_one = 0;
    char c = '1';
    for (ll i = 0; i < S.size(); ++i) {
        if (S[i] != '1') {
            num_one = i;
            c = S[i];
            break;
        }
    }

    cout << (num_one >= K ? '1' : c) << endl;

    return 0;
}


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


using namespace std;

typedef long long ll;

int k, length, pointer;
string S, str[100005];

int main(){

    cin >> S >> k;
    length = S.size();

    for (int i = 1; i <= 5; i++){
        for (int j = 0; j <= length-i; j++){
            str[pointer++] = S.substr(j,i);
        }
    }

    sort(str, str+pointer);
    unique(str, str+pointer);

    cout << str[k-1];

    return 0;

}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str = sc.next();
			StringBuffer ans = new StringBuffer();
			int i=0;
			//System.out.println(str.length());
			
			while(i != str.length()){
				if(str.charAt(i) == '@'){
					++i;		
					char c = str.charAt(i);
					int k = Integer.parseInt(String.valueOf(c));
					//System.out.println("k=" +k);
					++i;
					c=str.charAt(i);	
					for(int j=0; j<k; j++){
						ans.append(c);
					}
					++i;
				}
				else{
					ans.append(str.charAt(i));
					++i;
				}
			
			}
			System.out.println(ans);	
		}
	
	}
}

Measured memory_bytes: 17128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
const int MaxN = 1e5;
const int oo = 1 << 30;
const int mod = 1e9 + 7;
typedef long long LL;

int n;
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		LL ans = 1;
		for(int i = 1; i <= n; i++)
			ans = (ans * i) % mod;
		printf("%I64d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		string str;
		cin>>str;
		
		REP(i,n){
			string str2="";
			int cnt=1;
			REP(j,SZ(str)-1){
				if(str[j]==str[j+1]){
					cnt++;
				}else{
					str2+=toString(cnt);
					str2+=toString(str[j]);
					cnt=1;
				}
			}
			str2+=toString(cnt);
			str2+=toString(str[SZ(str)-1]);
			str=str2;
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=25005,K=405;
const int ms=1e9+7;
int a[N],f[N][K],g[N][K],las[K],n,m,k;
void add(int &x,int y){
	x+=y; if (x>=ms) x-=ms;
}
ll ksm(ll x,int k){
	ll t=1;
	for (;k;k>>=1){
		if (k&1) t=(t*x)%ms;
		x=(x*x)%ms;
	}
	return t;
}
ll fac(int x){
	ll ans=1;
	for (int i=2;i<=x;i++) ans=(ans*i)%ms;
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&k,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	int mx=0,now=0; ll ans=(ll)(n-m+1)*ksm(k,n-m)%ms;
	for (int i=1;i<=m;i++){
		now=min(now+1,i-las[a[i]]);
		las[a[i]]=i; mx=max(mx,now);
	}
	if (mx==k){printf("%lld\n",ans); return 0;}
	if (mx==m){
		f[0][0]=1;
		for (int i=1;i<=n;i++){
			int s=0,t=0;
			for (int j=k-1;j>=1;j--){
				add(s,f[i-1][j]); add(t,g[i-1][j]);
				(f[i][j]+=(ll)f[i-1][j-1]*(k-j+1)%ms)%=ms;
				(g[i][j]+=(ll)g[i-1][j-1]*(k-j+1)%ms)%=ms;
				add(f[i][j],s); add(g[i][j],t);
				if (j>=m) add(g[i][j],f[i][j]);
			}
		}
		int tmp=0;
		for (int i=1;i<=k;i++) add(tmp,g[n][i]);
		tmp=(ll)tmp*fac(k-m)%ms*ksm(fac(k),ms-2)%ms;
		ans=(ans+ms-tmp)%ms;
		printf("%lld\n",ans);
		return 0;
	}else{
		int u=0,v=0;
		memset(las,0,sizeof(las));
		for (int i=1;i<=m;i++){
			if (las[a[i]]) break;
			u++; las[a[i]]=1;
		}
		memset(las,0,sizeof(las));
		for (int i=m;i>=1;i--){
			if (las[a[i]]) break;
			v++; las[a[i]]=1;
		}
		f[0][u]=g[0][v]=1;
		for (int i=1;i<=n;i++){
			int s=0,t=0;
			for (int j=k-1;j>=1;j--){
				add(s,f[i-1][j]); add(t,g[i-1][j]); 
				(f[i][j]+=(ll)f[i-1][j-1]*(k-j+1)%ms)%=ms;
				(g[i][j]+=(ll)g[i-1][j-1]*(k-j+1)%ms)%=ms;
				add(f[i][j],s); add(g[i][j],t);
			}
		}
		for (int i=0;i+m<=n;i++){
			int s=0,t=0;
			for (int j=1;j<k;j++){
				add(s,f[i][j]); add(t,g[n-m-i][j]);
			}
			ans=(ans+ms-(ll)s*t%ms)%ms;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 79488
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<long long>& S) {
        int n = S.size();
        int N = n - 1;
        long long res = 0;

        for (int i = 1; i < n - 1; ++i) {
            int l = 0;
            int r = n - 1;
            long long sum = 0;
            if ((n - 1) % i == 0) {
                while (l < r) {
                    sum += S[l];
                    sum += S[r];
                    res = max(res, sum);
                    l += i;
                    r -= i;
                }
            } else {
                while (l + i <= n - 1) {
                    sum += S[l];
                    sum += S[r];
                    res = max(res, sum);
                    l += i;
                    r -= i;
                }
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> S(n);
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    Solution sol;
    cout << sol.solve(S) << "\n";

    return 0;
}

Measured memory_bytes: 1024