akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll MOD = 1000000007;

int main() {FIN

	ll h, w, i, j;
	cin >> h >> w;

	vvll dp(h, vll(w));
	vs rw(h);
	dp[0][0] = 1;
	for (i = 0; i < h; i++) {
		cin >> rw[i];
		for (j = 0; j < w; j++) {
			if (rw[i][j] == '.') {
				if (i > 0 and rw[i - 1][j] == '.')
					dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
				if (j > 0 and rw[i][j - 1] == '.')
					dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
			}
		}
	}

	cout << dp[h - 1][w - 1] << "\n";

	return 0;
}

Measured memory_bytes: 12372
#include <stdio.h>

int cnt;

void insertionSort(int A[], int n, int g)
{
    int i;
    for (i = g; i < n; i++) {
        int v, j;
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    int i, m = 0;
    int G[10] = {262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1};

    for (i = 0; i < 10; i++) {
        if (G[i] <= n) {
            m++;
            insertionSort(A, n, G[i]);
        }
    }

    printf("%d\n", m);
    
    i = 10 - m;

    printf("%d", G[i]);
    for (i++; i < 10; i++) printf(" %d", G[i]);
    putchar('\n');
}

int main(void)
{
    int n;
    scanf("%d", &n);

    int A[n];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &A[i]);

    shellSort(A, n);

    printf("%d\n", cnt);

    for (i = 0; i < n; i++)
        printf("%d\n", A[i]);

    return 0;
}



Measured memory_bytes: 5596
from decimal import *
x, k, d = map(Decimal, input().split())

if x >= 0:
  if x-k*d >= 0:
    print(abs(x-k*d))
  else:
    if x//d%2 == k%2:
      print(abs(x%d))
    else:
      print(abs(d-x%d))
else:
  if x+k*d <= 0:
    print(abs(x+k*d))
  else:
    if -x//d%2 == k%2:
      print(abs(-x%d))
    else:
      print(abs(d+x%d))

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

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()å
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

    int A,B,T;

signed main(){
 
    cin>>A>>B>>T;

    cout <<(T/A)*B<<endl;

    return 0;
 
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=1e9;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int N;
	long long sum=0,minb=INF;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		long long a,b;
		scanf("%lld %lld",&a,&b);
		sum+=a;
		if(a>b)minb=min(minb,b);
	}
	printf("%lld\n",minb==INF?0:sum-minb);
	return 0;
}

Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int s = 0, const int d = 0, const Weight w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;
  using iterator = std::vector<Edges>::iterator;
  using const_iterator = std::vector<Edges>::const_iterator;

public:
  Graph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  const Edges &operator[](const int i) const { return g[i]; }
  void addArc(const int src, const int dst, const Weight w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int node1, const int node2, const Weight w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
  iterator begin() { return g.begin(); }
  const_iterator begin() const { return g.begin(); }
  iterator end() { return g.end(); }
  const_iterator end() const { return g.end(); }
};

std::vector<int> tsort(const Graph &g) {
  int n = g.size(), k = 0;
  std::vector<int> ord(n), in(n);
  for (auto &es : g) {
    for (auto &e : es) in[e.dst]++;
  }
  std::queue<int> q;
  rep(i, n) if (in[i] == 0) q.push(i);
  while (q.size()) {
    int v = q.front();
    q.pop();
    ord[k++] = v;
    for (auto &e : g[v])
      if (--in[e.dst] == 0) q.push(e.dst);
  }
  return *std::max_element(in.begin(), in.end()) == 0 ? ord : std::vector<int>();
}

main {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  while (m--) {
    int s, t;
    cin >> s >> t;
    g.addArc(s, t);
  }
  vi v = tsort(g);
  for (auto &x : v) cout << x << endl;
}

Measured memory_bytes: 4796
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,W,w[N],v[N],dp[N][105];
signed main(){
    FastIO;
    cin>>n>>W;
    rep(i,1,n) cin>>w[i]>>v[i];
    rep(j,1,W){
        rep(i,1,n){
            dp[j][i]=dp[j][i-1];
            if(j>=w[i]) dp[j][i]=max(dp[j][i],dp[j-w[i]][i-1]+v[i]);
        }
    }
    cout<<dp[W][n];
    return 0;
}


Measured memory_bytes: 82304
#include <iostream>
using namespace std;
int sum(int n){
	int s = 0;
	while(n){
		s+= n%10;
		n/=10;
	}
	return s;
}
int main(){
	int n,min = 100000;
	cin>>n;
	for(int i = n-1,j = 1;i>0;i--,j++){
		int suma = sum(j) +sum(i); 
		if(suma<min) min = suma;
	}
	cout<<min<<endl;
	return 0;
}

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

void Main()
{
	int N; cin >> N;
	cout << N * (N + 1) / 2 << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
from collections import defaultdict
    
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
    
n, k = map(int, input().split())
MOD = 10**9 + 7
com = Combinatorics(n, MOD)
ans = com.binom(n-1, k-1)
print(ans)


Measured memory_bytes: 6180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<int> s(N);
  int min10 = 101;
  int sum = 0;
  rep(i, N)
  {
    cin >> s[i];
    if (s[i] % 10 != 0)
      min10 = min(min10, s[i]);
    sum += s[i];
  }
  int ans = 0;
  if (sum % 10 != 0)
    ans = sum;
  else if (min10 == 101)
    ans = 0;
  else
    ans = sum - min10;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            //数値の入力（空白区切り）
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            int c = Convert.ToInt32(input[2]);
          	//判定、出力
            if (a <= c && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

int main()
{
    std::int32_t min, max;
    std::cin >> min >> max;

    std::int32_t count = 0;
    for (std::int32_t n = min; n <= max; n++)
    {
        if ((n / 10000 == n % 10) && (n / 1000 % 10 == n / 10 % 10))
        {
            count += 1;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int num = 0;
        int cnt = 0;
        if (m == 1) {
            System.out.println(0);
            return;
        }
        while (true) {
            cnt++;
            num += n;
            if (num >= m) {
                break;
            }
            num--;
        }
        System.out.println(cnt);
    }    
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= y/10000; i++){
        for (int k = 0; k <= y/5000; k++){
            int x = n - (i + k);
            if (x < 0) continue;
            if (10000*i + 5000*k + 1000*x == y) {
                cout << i << " " << k << " " << x << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}










Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	char ST[200001];
	/*文字列の入力*/
	scanf("%s", ST);
	
	/*文字列の文字数の確認*/
	int i, s, flag = 0;
	for (i = 0; ST[i] != '\0'; i++);
	
	/*ST削除*/
	for (s = 0; ST[s] != '\0'; s++) {
		if (ST[s] == 'S') {
			flag++;
		}
		if (flag > 0 && ST[s] == 'T') {
			flag--;
			i = i - 2;
		}
	}
	
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define N 101
#define WHITE -1
#define GRAY 0
#define BRACK 1
#define INF -1

int G[N][N] = {}, d[N] = {}, color[N], Q[N];
int n, head = 1, tail = 1;

void Enqueue(int);
int Dequeue(void);
void BFS(int);

int main(){
  int u, k, v, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }
  BFS(1);
  for(i = 1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}

void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  color[s] = GRAY;
  d[s] = 0;
  for(i = 1; i <= n; i++) Q[i] = 0;
  Enqueue(s);
  while(head != tail){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(G[u][i] == 1){
	if(color[i] == WHITE){
	  color[i] = GRAY;
	  d[i] = d[u] + 1;
	  Enqueue(i);
	}
      }
    }
    color[u] = BRACK;
  }
}

int Dequeue(void){
  int x;
  x = Q[head];
  if(head + 1 == n) head = 1;
  else head++;
  return x;
}

void Enqueue(int x){
   Q[tail] = x;
  if(tail + 1 == n) tail = 1;
  else tail++;
}

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

int main() {
  int n,m,k;
  cin>>n>>m;
  if(n%2==1){
  for(int i=0;i<m;i++){
    cout<<n/2-i<<' '<<n/2+1+i<<endl;
  }
  }
  else {
    for(int i=0;i<m;i++){
      if(2*i+1<n/2){
    cout<<n/2-i<<' '<<n/2+1+i<<endl;
      }
      else {
        k=i;
        break;
      }
  }
    for(int i=k;i<m;i++){
      cout<<n/2-i<<' '<<n/2+2+i<<endl;
    }
  }
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s;
    cin>>s;
    int n;
    if(s=="SUN"){
        n=7;
    }else if(s=="MON"){
        n=6;
    }else if(s=="TUE"){
        n=5;
    }else if(s=="WED"){
        n=4;
    }else if(s=="THU"){
        n=3;
    }else if(s=="FRI"){
        n=2;
    }else if(s=="SAT"){
        n=1;
    }
    cout<<n;
    return 0;
}


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

typedef long long ll;

const ll N = 5e3 + 15, inf = 1000000LL * 1000000LL * 10, LOG = 23;
ll n, R, L;
int Arr[N];
ll dp[N], ans;
vector <int> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> R >> L;
	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	for (int i = 0; i < n; i++) {
		while (vec.size() && Arr[vec.back()] > Arr[i])
			vec.pop_back();

		dp[i] = inf;
		if (vec.empty())
			dp[i] = R * i;

		int cnt = 0, val = 0;
		for (int j = i - 1; ~j; j--) {
			if (Arr[j] < Arr[i])
				val = max(val, Arr[j]);

			if (Arr[j] < Arr[i] && val == Arr[j])
				dp[i] = min(dp[i], dp[j] + L * (i - j - 1 - cnt) + R * cnt);

			cnt += (Arr[j] > Arr[i]);
		}

		vec.push_back(i);
	}

	vec.clear();

	ans = inf;
	for (int i = n - 1; ~i; i--) {
		while (vec.size() && Arr[vec.back()] < Arr[i])
			vec.pop_back();

		if (vec.empty())
			ans = min(ans, dp[i] + (n - i - 1) * L);

		vec.push_back(i);
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	ll H, W, ch, cw, dh, dw;
	cin >> H >> W;
	cin >> ch >> cw;
	cin >> dh >> dw;
	vs S(H);
	rep(i, H) cin >> S[i];
	ll dir[] = {1, 0, -1, 0, 1};
	
    deque<pair<ll, ll>> q;
    vector<vector<ll>> dp(H, vector<ll>(W, INF));
    dp[ch - 1][cw - 1] = 0;
    q.push_back({ch - 1, cw - 1});
	ll x, y, nx, ny;
    
    while(!q.empty()){
        tie(x, y) = q.front();
        q.pop_front();
		rep(i, 4){
			ny = y + dir[i];
			nx = x + dir[i + 1];
			if (ny < 0 || nx < 0 || nx >= H || ny >= W)continue;
			if (S[nx][ny] == '#') continue;
			if (dp[nx][ny] > dp[x][y]) {
				dp[nx][ny] = dp[x][y];
				q.push_front({nx, ny});
			}
		}
        rep2(i, -2, 3){
            rep2(j, -2, 3){
                nx = x + i;
                ny = y + j;
                if (ny < 0 || nx < 0 || nx >= H || ny >= W)continue;
				if (S[nx][ny] == '#') continue;
				if(dp[nx][ny] > dp[x][y] + 1){
					dp[nx][ny] = dp[x][y] + 1;
					q.push_back({nx, ny});
				}
			}
		}
	}

	ll ans = dp[dh - 1][dw - 1];
	if(ans == INF) print(-1);
	else print(ans);	
}	

int main(){
	
	fastio;
	solve();
    
	return 0;
	
}


Measured memory_bytes: 12712
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    char c;
    cin >> c;
    if (c == 'A') cout << 'T' << endl;
    if (c == 'T') cout << 'A' << endl;
    if (c == 'C') cout << 'G' << endl;
    if (c == 'G') cout << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k=0;
	string a,b;
	cin>>a>>b;
	for(int i=0;i<3;i++)
	{
		if(a[i]==b[i])
		k++;
	}
	cout<<k<<"\n";
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var x = next();
  var m = n*2-1;
  if(x === 1 || x === m)return "No";
  console.log("Yes");
  if(n === 2)return "1\n2\n3";
  var ans = Array(m);
  if(x === 2){
    for(var i = 1; i <= m; i++){
      var t = i+n-3;
      ans[t%m] = i;
    }
  }else{
    ans[n-2] = x-1;
    ans[n-1] = x;
    ans[n] = x+1;
    ans[n+1] = x-2;
    for(var i = 5; i <= m; i++){
      var t = i+n-3;
      ans[t%m] = (x+i-4)%m+1;
    }
  }
  return ans.join("\n");
}

Measured memory_bytes: 48588
N = input()
raw_input1 = input()

l = raw_input1.split()
l_num = [int(x) for x in l]

flag = 0
flag1 = 0

for a in l_num:
    if a % 2 ==0:
        if a % 3 == 0 or a % 5 == 0:
            flag = 0
        else:
            flag = 1
    if flag != 0:
        break

if flag == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
#define INF ll(1e18)

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

struct Point
{
    ll x,y,p;
    bool operator<(const Point &rhs) const {
        return x != rhs.x ? x < rhs.x : y < rhs.y;
    }
};

vector<int> get_state(int id, int n) {
    vector<int> state(n);
    rep(i,n){
        state[i] = id % 3;
        id /= 3;
    }
    return state;
}

int main(void) {
    int n;
    cin >> n;
    vector<Point> v(n);
    rep(i,n) cin >> v[i].x >> v[i].y >> v[i].p;
    vector<vector<ll>> distX(1<<n, vector<ll>(n, INF)), distY(1<<n, vector<ll>(n, INF));
    rep(i,n){
        distX[0][i] = abs(v[i].x);
        distY[0][i] = abs(v[i].y);
    }
    rep(mask, 1<<n) {
        rep(road,n) {
            if (mask & bit(road)) continue;
            rep(i,n) {
                distX[mask|bit(road)][i] = min(distX[mask][i], abs(v[road].x - v[i].x));
                distY[mask|bit(road)][i] = min(distY[mask][i], abs(v[road].y - v[i].y));
            }
        }
    }
    vector<ll> res(n+1, INF);
    rep(id, pow(3,n)+0.5) {
        vector<int> state = get_state(id,n);
        int maskX = 0, maskY = 0;
        rep(i,n) {
            if (state[i] == 1) maskX |= bit(i);
            if (state[i] == 2) maskY |= bit(i);
        }
        int use = 0;
        ll sum = 0;
        rep(i,n) {
            if (state[i]) use++;
            sum += min(distX[maskX][i], distY[maskY][i]) * v[i].p;
        }
        res[use] = min(res[use], sum);
    }
    rep(i,n+1){
        cout << res[i] << endl;
    }
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    ll A, B, V, W, T;
    cin>>A>>V>>B>>W>>T;

    if (A<B) {
	ll a = A+V*T;
	ll b = B+W*T;
	if (a>=b) out("YES");
	out("NO");
    } else {
	ll a = A-V*T;
	ll b = B-W*T;
	if (a<=b) out("YES");
	out("NO");
    }

    
    
    
    return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,k;cin>>n>>k;
  std::vector<int> v(n);Inparray(v,n);
  sort(All(v),greater<int>());
  int ans=0;
  for (int i = 0; i < k; ++i)
  {
  	ans+=v[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int a[100005],b[100005];
bool usea[100005],useb[100005];
int cnt00,cnt11;
multiset<int>used,not_used;
vector<int>all;
int ans=0;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		all.push_back(a[i]);
		all.push_back(b[i]);
	}
	sort(all.begin(),all.end());
	for(int i=0;i<n;i++)used.insert(all[i]);
	for(int i=n;i<n+n;i++)not_used.insert(all[i]);
	multiset<int>tmp=used;
	for(int i=1;i<=n;i++){
		if(tmp.count(a[i])){
			usea[i]=1;
			tmp.erase(tmp.find(a[i]));
		}
		if(tmp.count(b[i])){
			useb[i]=1;
			tmp.erase(tmp.find(b[i]));
		}
		if(!usea[i]&&!useb[i])cnt00++;
		if(usea[i]&&useb[i])cnt11++;
	}
	for(auto x:used)ans+=x;
	if(cnt00||cnt11){
		cout<<ans<<endl;
		return 0;
	}
	set<int>hop;
	for(int i=1;i<=n;i++){
	    if(usea[i])hop.insert(1);
	    else hop.insert(0);
	}
	if(hop.size()==1){
	    cout<<ans<<endl;
	    return 0;
	}
	int res=inf*inf;
	for(int i=1;i<=n;i++){
		if(usea[i]){
			auto itr=not_used.begin();
			if(b[i]==*itr)itr++;
			res=min(res,ans+(*itr-a[i]));
		}else{
			auto itr=not_used.begin();
			if(a[i]==*itr)itr++;
			res=min(res,ans+(*itr-b[i]));
		}
	}
	cout<<res<<endl;
	return 0;
}

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

ll z(ll a){
  ll p=0;
  while(a%2==0){
    p++;
    a/=2;
  }
  return p;
}

int main() {
  int n,m;
  cin>>n>>m;
  ll vec[n],vecb[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    vec[i]/=2;
  }
  ll a=1;
  for(int i=0;i<n;i++){
    vecb[i]=z(vec[i]);
    a=(a*vec[i])/__gcd(a,vec[i]);
  }
  sort(vecb,vecb+n);
  if(vecb[0]!=vecb[n-1]){
    cout<<0<<endl;
    return 0;
  }
  cout<<(1+m/a)/2<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(void){
  long n;
  scanf("%ld",&n);
  long long sum=0;
  for(long i=0;i<n;i++){
    if((i+1)%3!=0&&(i+1)%5!=0)
    sum += i+1;
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n){
		int in;
		cin >> in;
		in--;
		p.at(i) = in;
	}
	int ans = 0;
	rep(i, n-1){
		if(p.at(i) == i){
			swap(p.at(i), p.at(i+1));
			ans++;
		}
	}
	if(p.at(n-1) == n-1) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
#include <stdio.h>
#include<cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int deg[100005];
vector<int> to[100005];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]) {
      if (uf.same(i,u)) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 6784
class Tree
  attr_accessor :id,:parent,:children
  def initialize(id)
    @id=id
    @parent=-1
    @children=[nil,nil]
  end
  def preorder
    print " #{id}"
    children[0].preorder if children[0]
    children[1].preorder if children[1]
  end
  def inorder
    children[0].inorder if children[0]
    print " #{id}"
    children[1].inorder if children[1]
  end
end
def insert(id)
  z=Tree.new(id)
  y=nil
  x=$root
  while x
    y=x
    x= z.id < x.id ? x.children[0] : x.children[1]
  end
  unless y
    $root=z
  else
    z.id < y.id ?  y.children[0]=z : y.children[1]=z
  end
end
def find(id)
  x=$root
  while x!=nil && id!=x.id
    if id<x.id
      x=x.children[0]
    else
      x=x.children[1]
    end
  end
  return x
end
N=gets.to_i
N.times do
  cmd,id=gets.split
  case cmd
  when "insert" 
    insert(id.to_i)
  when "find"
    if find(id.to_i)
      puts "yes"
    else
      puts "no"
    end
  else
    $root.inorder
    puts ""
    $root.preorder
    puts ""
  end
end

Measured memory_bytes: 79892
#124

S = str(input())

N = len(S)
count_tmp1 = 0
count_tmp2 = 0

#101010...
for j in range(0,N):
    if j % 2 == 0 and S[j] == '0':
        count_tmp1 += 1
    elif j % 2 == 1 and S[j] == '1':
        count_tmp1 += 1

#0101010...
for j in range(0,N):
    if j % 2 == 0 and S[j] == '1':
        count_tmp2 += 1
    elif j % 2 == 1 and S[j] == '0':
        count_tmp2 += 1

if count_tmp1 >= count_tmp2:
    print(count_tmp2)

else:
    print(count_tmp1)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#define MAXNUM 1e+6

using namespace std;

int ham[4]={1,2,3,5};
bool memo[(int)MAXNUM+1]={false};

void func(int n){
	if(n>MAXNUM || memo[n]){
		return ;
	}
	memo[n]=true;
	func(n*2);
	func(n*3);
	func(n*5);
}

int main(){
	int m,n,ans;
	func(1);
	
	while(cin>>m){
		if(m==0){
			break;
		}
		cin>>n;
		ans=0;
		for(int i=m;i<=n;i++){
			if(memo[i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

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

int main() {
  int h,w;cin>>h>>w;
  vector<string> list(h);
  for (int i=0;i<h;i++) {
    cin>>list.at(i);
  }
  int flag=0;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if(list.at(i).at(j)=='#') {
        if(j-1>-1) {
          if(list.at(i).at(j-1)=='#') {
            continue;
          }
        }
        if(j+1<w) {
          if(list.at(i).at(j+1)=='#') {
            continue;
          }
        }
        if(i-1>-1) {
          if(list.at(i-1).at(j)=='#') {
            continue;
          }
        }
        if(i+1<h) {
          if(list.at(i+1).at(j)=='#') {
            continue;
          }
        }
        flag=1;
        break;
      }
    }
    if(flag) {
      break;
    }
  }
  if(flag) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19220
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[1001];
int n,c,x,y,cp,p,ans;
int ch(int x,int y){
  if(s[n-y-1][n-x-1]!=s[y][x])return 0;
  if(s[n-y-1][x]!=s[y][x])return 0;
  if(s[y][n-x-1]!=s[y][x])return 0;
  return 1;
}
int main(){
  cin>>c>>n;
  r(i,n)cin>>s[i];
  r(i,n/2)r(j,n/2)cp+=ch(j,i)*4;
  if(cp==n*n)ans++;
  r(i,c-1){
    cin>>p;
    r(i,p){
      cin>>y>>x;x--;y--;
      cp-=ch(x,y)*4;
      if(s[y][x]=='0')s[y][x]='1';
      else s[y][x]='0';
      cp+=ch(x,y)*4;
    }
    if(cp==n*n)ans++;
  }
  cout<<ans<<endl;
}

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

int main(void){
  int n,x,count;
  while(1){
    count = 0;
    cin >> n >> x;
    if(n == 0 && x == 0)break;
    for(int i = 1; i < n - 1; i++){
      for(int j = i + 1; j < n; j++){
        for(int k = j + 1; k <= n; k++){
          if(i != j && j != k && i + j + k == x){
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}


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


int main(void) {
  string S;
  cin >> S;
  sort(S.begin(), S.end());

  if (S == "abc") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  map<int,int>m;
  int x;
  for(int i=0;i<n;i++) cin>>x,m[x]++;
  cout<<(m.size()==n?"YES":"NO");
  return 0;
}

Measured memory_bytes: 9600
s = input()
l,r,ans = 0,len(s)-1,0
while l<r:
	if s[l]==s[r]: l,r = l+1,r-1
	elif s[l]=="x": l,ans = l+1,ans+1
	elif s[r]=="x": r,ans = r-1,ans+1
	else: break
if l>=r: print(ans)
else: print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

void solve(){
	char c;
	cin>>c;

	if(c>='A'&&c<='Z')
		cout<<'A'<<endl;
	else
		cout<<'a'<<endl;
}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

int d[100010] ,ans[100010];

signed main(){
    int n, m; cin >> n >> m;
    vector<int> G[n];
    REP(i,n+m-1){
        int u, v; cin >> u >> v; --u; --v;
        G[u].pb(v);
        d[v]++;
    }
    stack<int> st;
    REP(i,n) if(!d[i]){
        st.push(i);
        ans[i] = -1;
    }
    vector<int> vec;
    while(st.size()){
        int now = st.top(); st.pop();
        vec.pb(now);
        for(auto v:G[now]){
            d[v]--;
            if(!d[v]){
                st.push(v);
                ans[v] = now;
            }
        }
    }
    REP(i,n)cout << ans[i] + 1 << '\n';
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
db Snuke(ll x) {
    ll tmp=0,c=x;
    for (;c;c/=10)tmp+=c%10;
    return 1.0*x/tmp;
}
int main(){
	int n;
	read(n);
    ll res=0,x=1;
    for (;n--;){
  		db t1,t2;
        while(true) {
            t1=Snuke(res+x),t2=Snuke(res+x*10);
            if(t1<=t2)break;
            x*=10;
        }
        res+=x;
        printf("%lld\n",res);
    }
    return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;

    vector<vi> dp(N, vi(N));
    REP(i, N)
    {
        dp[i][i] = 0;
        for (ll j = i + 1; j < N; ++j)
        {
            dp[i][j] = dp[i][j - 1] + 1;
            dp[j][i] = dp[i][j];
        }
    }
    // REP(i, N)
    // {
    //     REP(j, N)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    REP(i, N)
    {
        for (ll j = i + 1; j < N; ++j)
        {
            dp[i][j] = min(dp[i][j], dp[i][X - 1] + dp[Y - 1][j] + 1);
            dp[j][i] = dp[i][j];
        }
    }

    vi ans(N);
    REP(i, N)
    {
        for (ll j = i + 1; j < N; ++j)
        {
            ++ans[dp[i][j]];
        }
    }

    REP1(k, N - 1)
    {
        OUT(ans[k]);
    }
}
#pragma endregion template

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n),ins(n);
    rep(i,n){
        cin>>a[i];
        ins[i]=a[i];
    }

    ll ans=INF;
    rep(i,(1<<n)){
        ll visible=1;//見える建物の数
        rep(j,n){
            if(j==0) continue;
            if((i>>j)&1) visible++;
        }
        if(visible<k) continue;//k個以上じゃないとだめ

        ll sum=0;//見るのに必要な費用
        ll MAX=0;//j個目のビルの手前にある建物のうち、最大の高さ
        rep(j,n){
            if(j==0) continue;
            if((i>>j)&1){
                rep(k,j) MAX=max(MAX,a[k]);//手前の建物の中で最大の高さを探す
                if(MAX-a[j]+1ll>=0){//j番目の建物がMAXより小さいなら増築    
                    sum+=(MAX-a[j]+1ll);//増築費用
                    a[j]+=(MAX-a[j]+1ll);
                }
            }
        }

        rep(j,n) a[j]=ins[j];//aを元に戻す

        ans=min(ans,sum);
    }

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

int main() {
    int N, R;
    while(cin >> N >> R) {
        queue<int> A, B, C;
        rep(i,N)C.push(i);
        rep(x,R){
            int c; cin >> c;
            rep(i,N) {
                if(N/2<=i) { A.push(C.front()); }
                else { B.push(C.front()); }
                C.pop();
            }
            while(A.size() || B.size()){
                rep(i,c) {
                    if(A.size()==0) break;
                    C.push(A.front()); A.pop();
                }
                rep(i,c) {
                    if(B.size()==0) break;
                    C.push(B.front()); B.pop();
                }
            }
        }
        cout << C.back() << endl;
    }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
int n,t[107],t0[107];
bool chk(int x){
	for(int i=0;i<=n;++i)t[i]=t0[i];
	for(int i=1;i<=x;++i)if(0>--t[std::max(x-i,i-1)])return 0;
	for(int i=0,m=x/2;i<=m;++i)if(t[i])return 0;
	for(int i=x;i<=n;++i)if(t[i])return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=0,x;i<n;++i){
		scanf("%d",&x);
		++t0[x];
	}
	for(int d=1;d<=n;++d)if(chk(d))return puts("Possible"),0;
	return puts("Impossible"),0;
}

Measured memory_bytes: 256
class node:
    def __init__(self,key,pri,left=None,right=None):
        self.left = left
        self.right = right
        self.key = key
        self.pri = pri

def insert(n,key,pri):
    if(n == None):
        return node(key,pri)
    if(key == n.key):
        return n
    if(key < n.key):
        n.left = insert(n.left, key, pri)
        if(n.pri < n.left.pri):
            n = rightRotate(n)
    else:
        n.right = insert(n.right, key, pri)
        if(n.pri < n.right.pri):
            n = leftRotate(n)
    return n

def rightRotate(n):
    child = n.left
    swapL,swapR,swapK,swapP = child.left,child.right,child.key,child.pri
    n.left = swapR
    n = node(swapK,swapP,swapL,n)
    return n

def leftRotate(n):
    child = n.right
    swapL,swapR,swapK,swapP = child.left,child.right,child.key,child.pri
    n.right = swapL
    n = node(swapK,swapP,n,swapR)
    return n

def find(n,key):
    if(n == None):
        return None
    elif(n.key == key):
        return n
    elif(n.key > key):
        return find(n.left,key)
    else:
        return find(n.right,key)

def delete(n, key):
    if(n == None):
        return None
    if(key < n.key):
        n.left = delete(n.left, key)
    elif(key > n.key):
        n.right = delete(n.right, key)
    else:
        return _delete(n, key)
    return n

def _delete(n, key):
    if(n.left == None and n.right == None):
        return None
    elif(n.left == None):
        n = leftRotate(n)
    elif(n.right == None):
        n = rightRotate(n)
    else:
        if(n.left.pri > n.right.pri):
            n = rightRotate(n)
        else:
            n = leftRotate(n)
    return delete(n, key)

def inorder(n):
    if(n==None):
        return
    if(n.left != None):
        inorder(n.left)
    print(" "+str(n.key), end='')
    if(n.right != None):
        inorder(n.right)

def preorder(n):
    if(n==None):
        return
    print(" "+str(n.key), end='')
    if(n.left != None):
        preorder(n.left)
    if(n.right != None):
        preorder(n.right)

op_num=(int)(input())
root = None
for i in range(op_num):
    items = input().split()
    if(items[0] == "insert"):
        root = insert(root,(int)(items[1]),(int)(items[2]))
    elif(items[0] == "delete"):
        root = delete(root,(int)(items[1]))
    elif(items[0] == "find"):
        res = find(root,(int)(items[1]))
        if(res == None):
            print("no")
        else:
            print("yes")
    else:
        inorder(root)
        print("")
        preorder(root)
        print("")



Measured memory_bytes: 52028
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main =
  readInts >>= print . showAnswer . solve

type Input  = [Int]
type Output = Int

solve :: Input -> Output
solve = g . map f
  where
    f x = x + (x-1)
    g [x,y] = if x == y then x+1 else max x y

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes"  b
  show (YESNO b)    = bool "NO" "YES"  b
  show (AB b)       = bool "B"  "A"    b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

const int INF = 1 << 28;

int main()
{
  int n;
  while(cin >> n, n) {
    int ax = 0;
    int in = INF;
    int sum = 0;
    rep(i, n) {
      int m;
      cin >> m;
      ax = max(ax, m);
      in = min(in, m);
      sum += m;
    }
    sum -= ax;
    sum -= in;
    sum /= n - 2;

    cout << sum << endl;
  }
  return 0;
}

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

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

    if(A <= 5){
        cout << 0 << endl;
    }else if(6 <= A && A <= 12){
        cout << B/2 << endl;
    }else{
        cout << B << endl;
    }
    return 0;
}

Measured memory_bytes: 256