akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
string s;
int main(){
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        tree.unite(x, y);
    }

    set<int> st;
    rep(i, N) {
        st.insert(tree.root(i));
    }

    cout << (int)st.size() << endl;
    return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    set<ll> st;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        st.insert(a);
    }
    cout << st.size() << endl;

}


Measured memory_bytes: 7788
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
INF = 10**5
COST = [INF,2,5,5,4,5,6,3,7,6]
digit = [-INF]*(N+1)
digit[0] = 0
for i in range(1, N+1):
    for a in A:
        c = COST[a]
        if i - c < 0:
            continue
        digit[i] = max(digit[i], 1 + digit[i-c])
ans = ''
n = N
for i in range(digit[N], 0, -1):
    for a in A:
        new_n = n - COST[a]
        if new_n < 0 or digit[new_n] < i - 1:
            continue
        ans += str(a)
        n = new_n
        break
print(ans)

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

void solve(string s){
	stack<int> st;
	for(auto i:s){
		if(i == '('){
			st.push(1);
		}else if(i == ')'){
			if(!st.empty() && st.top() == 1) st.pop();
			else st.push(2);
		}else if(i == '['){
			st.push(3);
		}else if(i == ']'){
			if(!st.empty() && st.top() == 3) st.pop();
			else st.push(4);
		}
	}
/*	cout << st.size() << "\n";
	while(!st.empty()){
		cout << st.top() << "\n";
		st.pop();
	}
*/	cout << (st.size() == 0 ? "yes" : "no") << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		string s;
		getline(cin, s);
		if(s == ".") return 0;
		solve(s);
	}
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N; cin >> N;
    deque <int> Q;
    bool ans=true;
    
    rep(i,N){
        int a; cin >> a;
        if (ans) Q.push_back(a);
        else Q.push_front(a);
        ans= !ans;
    }
    
    while(!Q.empty()){
        int x;
        if (ans){
            x=Q.front(); Q.pop_front();
        }else{
            x=Q.back(); Q.pop_back();
        }
        cout << x  << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using static Input;
class Program
{
    static int A;
    static int B;

    static void INPUT()
    {
        A = NextInt();
        B = NextInt();
    }
    static void OUTPUT()
    {
        int[] a = new int[3];
        a[0] = A + B;
        a[1] = A - B;
        a[2] = A * B;

        Console.WriteLine(a.Max());

    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
        //A = new int[] { 1, 1, 1, 1, 1 };
        //B = new int[] { 1, 1, 1, 1, 1 };
        A = 3;
        B = 4;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}



Measured memory_bytes: 13396
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
lines.pop()
line = lines.shift().split(' ')
N = line[0] * 1
M = line[1] * 1

lines = lines.map((x) => {
    return x.split(' ')
}).sort((a, b) => {
    return a[0] - b[0]
})
cnt = 0;
fee = 0;
for(i=0; i<N; i++) {
    c = 0
    b = lines[i][1] * 1
    if (cnt < M) {
        if (cnt + b > M) {
            c = M - cnt
        } else {
            c = b
        }
    } else {
        break;
    }
    cnt += c
    fee += c * lines[i][0]
}
console.log(fee)


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

using namespace std;

int main()
{
    string s, t;

    cin >> s;
    cin >> t;

    int total = 0;

    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i])
        {
            total++;
        }
    }

    cout << total << endl;

    return 0;
}


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

int main(){
  int n; cin >> n;
  string ret="APPROVED";
  int a;
  rep(i,n){
    cin >> a;
    if(a%2==0){
      if(a%3!=0&&a%5!=0)
        ret="DENIED";
    }
  }

  cout << ret;

}

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

using namespace std;

int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2){
        int f=1;
        for(int i=1;i<=3;i++){
            int s=i*a*b;
            if(s%2==1) {
                f=0;
                printf("Yes\n");
                break;
            }
        }
        if(f) printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,x,i,k,a[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(k=1;k<=m;k++){
		for(i=0;i<n-1;i++){
			if(a[i]%k>a[i+1]%k) swap(a[i],a[i+1]);
		}
	}
	for(i=0;i<n;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 2680
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c=0, n, k;
string s,t;
//cout<<<<endl;


int main()
{
	cin >> a >> b;
	c = 0;
	c += max(a, b);
	c += max(max(a, b) - 1, min(a, b));
	cout << c << endl;
}


Measured memory_bytes: 256
import math
n,h = map(int ,raw_input().split())
ais = [map(int, raw_input().split()) for _ in range(n)]
ais.sort(key = lambda x: (-x[1],x[0]))
r,m,cumul = h, max(ais)[0],0
r = (h+m-1)/m
for i in range(-1,len(ais)):
	if i >= 0: cumul += ais[i][1]
	r = min(r, i+1 + (max(h - cumul, 0) + m-1)/m)
print r


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

using namespace std;

int64_t calc(const std::vector<uint32_t>& as) {
  int const n = static_cast<int>(as.size());
  int64_t ret = 0;
  uint32_t ored = as[0];
  int64_t r = 1;
  for (; r < n; ++r) {
    uint32_t const a = as[r];
    if ((ored & a) != 0u) {
      break;
    }
    ored |= a;
  }
  ret += r;
  for (int64_t l = 1; l < n; ++l) {
    ored &= ~as[l - 1];
    for (; r < n; ++r) {
      uint32_t const a = as[r];
      if ((ored & a) != 0u) {
        break;
      }
      ored |= a;
    }
    ret += r - l;
  }
  return ret;
}

int main() {
  uint32_t n;
  std::cin >> n;
  std::vector<uint32_t> as(n, 0);
  for (int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }
  auto ret = calc(as);
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 1024
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << endl;}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec p(n);
	rep(i, n) cin >> p[i];

	ll sum = 0, ans = 0;
	rep(i, n){
		if(i < k) sum += p[i];
		else sum += p[i]-p[i-k];
		chmax(ans, sum);
	}
	setp(10);
	co((double)(ans+k)/2);

	return 0;
}


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

int main(){
	int n;
	cin >> n;
	if(n <= 999) cout << "ABC" <<endl;
	else cout << "ABD" << endl;
}

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

int main() {
    int N; cin >> N;
    ll K; cin >> K;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }

    ll ans = 0;
    for (int i = 40; i >= -1; i--){
        if(i != -1 && !(K>>i&1))continue;

        ll tmp = 0;
        for (int j = 40; j >= 0; j--){
            ll mask = 1LL<<j;
            ll num = 0;
            rep(i, N){
                if(A[i]&mask)num++;
            }

            if(j > i){
                if(K&mask){
                    tmp += mask*(N-num);
                } else {
                    tmp += mask*num;
                }
            } else if(j == i){
                tmp += mask*num;
            } else {
                tmp += mask * max(num, N-num);
            }
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;


    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b, c, d;

  scanf("%d %d %d %d", &a ,&b ,&c ,&d);

  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the Size of arrayss!!!
    
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000037
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
                         #define ll long long
                         #define int long long
//  #define ll int
 #define present(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
    
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn =506003;

void solve()
{
    ll n;cin>>n;
    ll a[n+3];ll ans =0;
    memset(a,0,sizeof a);
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
        {
            ans+=j;
        }
    }
    cout<<ans<<endl;
    
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//  solve();
//   }
    solve();
    
    return 0;
}


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

void sort( int* a, int n )
{
    for( int i = 0; i < n - 1; i++ )
        for( int j = i + 1; j < n; j++ )
            if( a[i] < a[j] )
            {
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
}

int main()
{
    int n, a, b, c;

    cin >> n >> a >> b >> c;

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

    sort( d, n );

    int max = 0, i = 0, sum = d[i];
    while( max <= ( c + sum ) / ( a + ( i + 1 ) * b ) )
    {
        max = ( c + sum ) / ( a + ( i + 1 ) * b );
        i++;
        sum += d[i];
    }

    cout << max << endl;
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  if(N==M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, h[22];

int main(){
    cin >> n;
    REP(i, n)cin >> h[i];
    int maxl = h[0], ans = 1;
    for(int i = 1;i < n;i++){
        if(maxl <= h[i]){
            ans++;
            maxl = h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static String N;
    static int K;
    static char[] D;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.next();
        K = sc.nextInt();
        D = new char[K];
        for(int i = 0; i < K; i++){
            D[i] = sc.next().charAt(0);
        }
        sc.close();

        int start = Integer.valueOf(N);
        while(!(is(start))){
            start++;
        }
        System.out.println(start);
    }

    static boolean is(int n){
        String s = String.valueOf(n);
        for(int i = 0; i < s.length(); i++){
            for(int j = 0; j < K; j++){
                if(s.charAt(i) == D[j])
                    return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 24148
#include <stdio.h>
#include <string.h>

struct Card
{
  char suit;
  int value;
};

main()
{
  struct Card C1[36], C2[36];
  int length, i, j, tmpint, min,flag = 0;
  char tmpchar;

  scanf("%d\n", &length);

  for(i = 0; i < length; i++)
    {
      if(i == 0)
	{
	  scanf("%c %d", &C1[i].suit, &C1[i].value);
	}
      else
	{
	  scanf(" %c %d", &C1[i].suit, &C1[i].value);
	}
    }

  for(i = 0; i < length; i++)
    {
      C2[i] = C1[i];
    }

  /*bubble sort start*/
  for(i = 0; i < length; i++)
    {
      for(j = length - 1; j >= i + 1; j--)
	{
	  if(C1[j].value < C1[j - 1].value)
	    {
	      tmpint = C1[j].value;
	      C1[j].value = C1[j - 1].value;
	      C1[j - 1].value = tmpint;
	      tmpchar = C1[j].suit;
	      C1[j].suit = C1[j - 1].suit;
	      C1[j - 1].suit = tmpchar;
	    }
	}
    }
  for(i = 0; i < length; i++)
    {
      if(i == length - 1)
	{
	  printf("%c%d\n", C1[i].suit, C1[i].value);
	}
      else
	{
	  printf("%c%d ", C1[i].suit, C1[i].value);
	}
    }
  printf("Stable\n");
  /*bubble sort finish*/

  /*select sort start*/
  for(i = 0; i < length; i++)
    {
      min = i;
      for(j = i + 1; j < length; j++)
	{
	  if(C2[j].value < C2[min].value)
	    {
	      min = j;
	      flag = 1;
	    }
	}
      if(flag == 1)
	{
	  tmpint = C2[i].value;
	  C2[i].value = C2[min].value;
	  C2[min].value = tmpint;
	  tmpchar = C2[i].suit;
	  C2[i].suit = C2[min].suit;
	  C2[min].suit = tmpchar;
	}
      flag = 0;
    }
  for(i = 0; i < length; i++)
    {
      if(i == length - 1)
	{
	  printf("%c%d\n", C2[i].suit, C2[i].value);
	}
      else
	{
	  printf("%c%d ", C2[i].suit, C2[i].value);
	}
    }
  for(i = 0; i < length; i++)
    {
      if(C1[i].suit == C2[i].suit)
	{
	  continue;
	}
      else
	{
	  flag = 1;
	  break;
	}
    }
  if(flag == 0)
    {
      printf("Stable\n");
    }
  else
    {
      printf("Not stable\n");
    }
  /*select sort finish*/
  return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        cin>>b[i];
        c[i]=a[i]-b[i];
    }
    ll n1 = 0,n2 = 0;
    rep(i,n){
        if(c[i]<0){
            ll d = (-c[i]+1)/2;
            n2 += d;
            c[i] += 2*d;
        }
        if(c[i]>0){
            ll d = c[i];
            n1 += d;
            c[i]=0;
        }
    }
    if(n2>=n1) cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
	endre;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
class diceroll{
    public:
    int num[6],new_num[6];
    void refresh();
    void turn_N();
    void turn_S();
    void turn_E();
    void turn_W();
};
    
void diceroll::refresh(){
    for(int i=0;i<6;i++){
        num[i]=new_num[i];
    }    
}
void diceroll::turn_N(){
    new_num[0]=num[1];
    new_num[1]=num[5];
    new_num[5]=num[4];
    new_num[4]=num[0];
    new_num[2]=num[2];
    new_num[3]=num[3];
}

void diceroll::turn_S(){
    new_num[0]=num[4];
    new_num[4]=num[5];
    new_num[5]=num[1];
    new_num[1]=num[0];
    new_num[2]=num[2];
    new_num[3]=num[3];
}

void diceroll::turn_E(){
    new_num[0]=num[3];
    new_num[3]=num[5];
    new_num[5]=num[2];
    new_num[2]=num[0];
    new_num[1]=num[1];
    new_num[4]=num[4];
}

void diceroll::turn_W(){
    new_num[0]=num[2];
    new_num[2]=num[5];
    new_num[5]=num[3];
    new_num[3]=num[0];
    new_num[1]=num[1];
    new_num[4]=num[4];
}

int main(){
    diceroll a;
    char ch;
    for(int i=0;i<6;i++){
        cin >> a.num[i];
    }
    
    while(scanf("%c", &ch) != EOF){
        if(ch == 'N'){
            a.turn_N();
            a.refresh();
        }
        
        else if(ch == 'S'){
            a.turn_S();
            a.refresh();
        }
        
        else if(ch == 'E'){
            a.turn_E();
            a.refresh();
        }
        
        else if(ch == 'W'){
            a.turn_W();
            a.refresh();
        }
        
        
        
    }
    
    cout << a.new_num[0] << endl;
    
    return 0;
}




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

int main() {
  int n;cin>>n;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  int cnt=0,ans=0;
  rep(i,n-1){
    if(h[i]>=h[i+1])cnt++;
    else cnt=0;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3704
sumOfDigit :: Int -> Int -> Int
sumOfDigit total 0 = total
sumOfDigit total n = sumOfDigit (total + r) q
  where
    q = n `div` 10
    r = n `mod` 10

main = do
  line <- getLine
  let
    [n,a,b] = map read $ words line :: [Int]
    ans = sum
      $ map (\x -> fst x)
      $ filter (\(_, x) -> a <= x && x <= b)
      $ map (\x -> (x, (sumOfDigit 0 x))) [1..n]
  putStrLn $ show ans


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	string numStr = a + b;
	int num = atoi(numStr.c_str());
	double abSqrtDouble = sqrt(num);
	int abSqrtInt = sqrt(num);
	if(abSqrtDouble - abSqrtInt == 0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = k;
  rep(i,n - 1){
    ans *= k-1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(begin(p), end(p)));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main(){
  long long n,k,cnt=0,num;
  cin >> n >> k;
  num = n/k;
  cnt = num*num*num;
  if(k%2==0){
    num = (n+k/2)/k;
    cnt += num*num*num;
  }
    cout << cnt <<"\n";
}


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

int main() {
  int N;
  char S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == 'Y') {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int d;
    while(cin>>d){
         int a;
         a=600/d;
         int b=0;
         for(int i=0;i<a;i++){
            b+=d*i*d*i*d;
         }
         cout<<b<<endl;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(void)
{
    int x,y,tmp;
    
    while(1){
       scanf("%d %d",&x,&y);
       if(x==0 && y==0){
           break;
       }
       if(x>y){
           tmp=x;
           x=y;
           y=tmp;
       }
           printf("%d %d\n",x,y);
           
    }
       
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>

using namespace std;

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

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

	vector<int> v(n, 0);
	int a, b;
	bool ispossible{ false };
	for(auto i = 0; i < m; ++i) {
		cin >> a >> b;
		if(a == 1) {
			v[b - 1] += 1;
			if(v[b - 1] == 3) {
				ispossible = true;
				break;
			}
		}
		if(b == n) {
			v[a - 1] += 2;
			if(v[a - 1] == 3) {
				ispossible = true;
				break;
			}
		}
	}

	if(ispossible) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

int main() {
  cout << fixed << setprecision(8);
  map<ll, ll> cost;
  ll n;
  cin >> n;
  vl l(n);

  FOR(i,0,n) {
    cin >> l[i];
  }

  cost[0] = 0;
  FOR(i,0,n-1) {
    if(has(cost, i+1))
      cost[i+1] = min(cost[i+1], cost[i] + abs(l[i] - l[i+1]));
    else
      cost[i+1] = cost[i] + abs(l[i] - l[i+1]);

    if(i == n-2)
      continue;
    
    if(has(cost, i+2))
      cost[i+2] = min(cost[i+2], cost[i] + abs(l[i] - l[i+2]));
    else
      cost[i+2] = cost[i] + abs(l[i] - l[i+2]);
  }

  cout << cost[n-1] << endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong A, B, M;
llong a[100005];
llong b[100005];
llong mina, minb;
llong x, y, c;
llong ans;

int main() {
    mina = minb = 1ll << 60ll;
    cin >> A >> B >> M;
    for (llong i = 0; i < A; i++) {
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    for (llong i = 0; i < B; i++) {
        cin >> b[i];
        minb = min(minb, b[i]);
    }

    ans = mina + minb;

    for (llong i = 0; i < M; i++) {
        cin >> x >> y >> c;
        --x, --y;
        ans = min(ans, a[x] + b[y] - c);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
s=input()
n=len(s)
a=s[0:(n-1)//2]
b=s[(n+3)//2-1:n]
c=a[::-1]
d=b[::-1]
sr=s[::-1]
for i in range(n):
    if s[i]==sr[i]:
        pass
    else:
        print("No")
        exit()
for i in range(len(a)):
    if a[i]==c[i]:
        pass
    else:
        print("No")
        exit()
for i in range(len(b)):
    if b[i]==d[i]:
        pass
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9084
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 500;
const int C_MAX = 30;
const int INF = 1e9;

int N, C;
int D[C_MAX][C_MAX];
int c[N_MAX][N_MAX];

int s[3][C_MAX];

void solve() {
  REP(i, N) REP(j, N) {
    int m = (i + j) % 3;
    REP(k, C) s[m][k] += D[c[i][j]][k];
  }
  // DUMP2D(s, 3, C);
  int ans = INF;
  REP(i, C) REP(j, C) {
    if (i == j) continue;
    REP(k, C) {
      if (i == k) continue;
      if (j == k) continue;
      ans = min(ans, s[0][i] + s[1][j] + s[2][k]);
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &C);
  REP(i, C) REP(j, C) scanf("%d", &D[i][j]);
  REP(i, N) REP(j, N) {
    scanf("%d", &c[i][j]);
    --c[i][j];
  }
}

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


Measured memory_bytes: 1152
n = input()
p = [0] * 2
for i in range(n):
    t, h = raw_input().split()
    if(t > h):
        p[0] += 3
    elif(t < h):
        p[1] += 3
    else:
        p[0] += 1
        p[1] += 1
print("%d %d" %(p[0], p[1]))

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    vint posx(m), posy(m);
    vll vcx(h, 0), vcy(w, 0);
    ll xmaxv = 0, ymaxv = 0;
    unordered_map<int, vint> ma;
    REP(i, m) {
        cin >> posx[i] >> posy[i];
        posx[i]--;posy[i]--;
        ma[posx[i]].push_back(posy[i]);
        vcx[posx[i]]++;
        vcy[posy[i]]++;
        xmaxv = max(xmaxv, vcx[posx[i]]);
        ymaxv = max(ymaxv, vcy[posy[i]]);
    }
    vint xidx, yidx;
    REP(i, h) {
        if (xmaxv == vcx[i]) {
            xidx.push_back(i);
        }
    }
    REP(i, w) {
        if (ymaxv == vcy[i]) {
            yidx.push_back(i);
        }
    }
    ll ans = xmaxv + ymaxv - 1;
    int sz = xidx.size();
    REP(i, sz) {
        int xnow = xidx[i];
        vint& ylis = ma[xnow];
        ll cnt = 0;
        for (int yid : ylis) {
            auto ite = lower_bound(yidx.begin(), yidx.end(), yid);
            if (ite != yidx.end()) {
                if (*ite == yid) ++cnt;
            }
        }
        if (cnt < yidx.size()) {
            ++ans;
            cout << ans << endl;
            return;
        }
    }
    cout << ans << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



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

using ll = long long;
using pii = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<int> l(n), r(n);
    for(int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
    }
    sort(l.begin(), l.end(), greater<>{});
    sort(r.begin(), r.end());

    ll ans = 0, sum_l = 0, sum_r = 0;
    for(int i = 0; i < n; ++i) {
        sum_l += 2 * l[i];
        sum_r += -2 * r[i];
        ans = max(ans, sum_l + sum_r);
        ans = max(ans, sum_l - 2 * l[i] + sum_r);
        ans = max(ans, sum_l + sum_r + 2 * r[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

void bubbleSort(struct Card A[], int N);//バブルソート関数
void selectionSort(struct Card A[], int N);//選択ソート関数
void trace(struct Card A[], int N);//配列の要素を順番に出力
bool isStable(struct Card i[], struct Card j[],int N);//ソート結果安定・不安定判断関数
bool DataEqual(struct Card* in, struct Card* out);

struct Card
{
	char suit, value;
};

int main()
{
	int N;
	Card card0[36];
	Card card1[36];
	Card card2[36];

	cin >> N;

	for (int i = 0;i<N;i++)
	{
		cin >> card1[i].suit >> card1[i].value;
		card2[i] = card1[i];
		card0[i] = card1[i];
	}

	bubbleSort(card1, N);
	trace(card1, N);
	if(isStable(card0,card1,N))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}

	selectionSort(card2, N);
	trace(card2, N);
	if (isStable(card0, card2, N))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}


	return 0;
}

void bubbleSort(Card A[], int N)
{
	bool flag = 1;
	int  c;
	Card v;
	c = 0;

	while (flag)
	{
		flag = 0;
		for (int j = N - 1;j > 0;j--)//数列最後尾から順に逆順要素の有無確認
		{
			if (A[j].value < A[j - 1].value)//逆順要素入れ替え
			{
				v = A[j];
				A[j] = A[j - 1];
				A[j - 1] = v;
				c = c + 1;
				flag = 1;//逆順要素入れ替えした場合、flag=1にする。
			}
		}
	}
}
void selectionSort(struct Card A[], int N)
{
	int minj;
	Card v;
	int c = 0;

	for (int i = 0;i < N;i++)
	{
		minj = i;

		for (int j = i; j<N;j++)//未整列の領域（iからn-1）から最小値検索
		{
			if (A[j].value < A[minj].value)
			{
				minj = j;
			}
		}
		v = A[i];
		A[i] = A[minj];
		A[minj] = v;
		if (i != minj)c = c + 1;
	}
}

void trace(struct Card A[], int N)
{
	cout << A[0].suit << A[0].value;
	for (int i = 1;i < N;i++)
	{
		cout << " " <<A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card in[], struct Card out[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			for (int a = 0; a < N; a++)
			{
				for (int b = a + 1; b < N; b++)
				{
					if (in[i].value == in[j].value && DataEqual(&in[i],&out[b]) && DataEqual(&in[j], &out[a]))
					{
						return false;
					}
				}
			}
		}
	}
	return true;
}

bool DataEqual(struct Card* in, struct Card* out)
{
	return in->value == out->value && in->suit == out->suit;
}


Measured memory_bytes: 3064
#include <iostream>
    using namespace std;
     
    int main() {
    	// your code goes here
    	string s;
    	cin >> s;
    	int num=s.length();
    	char ans[100000];
    	for(int i=0;i<(num+1)/2;i++){
    	   ans[i] = s[2*i];
    	}
    	//for(int i=0;i<(num+1)/2;i++){
    	 //  cout << ans[i];
    	//}
    	cout << ans << '\n';
    	return 0;
    }

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		char[] ch = sc.next().toCharArray();
		int w =sc.nextInt();
		
		for(int i =0 ; i < ch.length ; i+=w){
			System.out.print(ch[i]);
		}
		System.out.println();
		
	}
}


Measured memory_bytes: 23124
#include<cstdio>

using namespace std;

typedef long long LL;

int k;

double S(LL x){
	double res = 0;
	while(x){
		res += x % 10;
		x /= 10;
	}
	return res;
}

LL f(LL x){
	double mn = x / S(x);
	LL mark = x;
	for(LL d = 1; d <= x; d *= 10){
		LL t = x / d * d + d * 10 - 1;
		double tmp = t / S(t);
		if(tmp < mn){
			mn = tmp;
			mark = t;
		}
	}
	return mark;
}

int main(){
	scanf("%d", &k);
	LL now = 1;
	while(k--){
		printf("%lld\n", now);
		now = f(now+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(value) value.begin(),value.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(value) cerr << #value << " is " << value << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
   
    //a.erase(unique(a.begin(),a.end()),a.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const int mod=1e9+7 ,  inf =1e18;
    const ll  man =(int)305;
    

    long long binpow(int a,int b,int m)
    {   
        a %= m;int res = 1;
        while (b > 0)
        { 
            if (b & 1)res=(res*a)%m;
            a=(a*a)%m  ;    b/=2; 
        }
        return res;
    }
    int modinv(int n,int m) {return binpow(n,mod-2,m);}
    

/*......................................................................................................................*/

ld dp[man][man][man];
signed main()
{
    fast;
    int n;
    cin>>n;
    int A=0,B=0,C=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x==1)A++;
        else if(x==2)B++;
        else C++;
    }
    for(int c=0;c<man;c++)
    {
        for(int b=0;b+c<man;b++)
        {
            for(int a=0;a+b+c<man;a++)
            {
                ld total=a+b+c;
                if(a==0&&b==0&&c==0)continue;
                ld aa=a/total;
                ld bb=b/total;
                ld cc=c/total;
                // ld xx =1-aa-bb-cc;
                dp[a][b][c]=n/total;
                if(a)dp[a][b][c]+=dp[a-1][b][c]*aa;
                if(b)dp[a][b][c]+=dp[a+1][b-1][c]*bb;
                if(c)dp[a][b][c]+=dp[a][b+1][c-1]*cc;
            }
        }
    }
    cout<<fixed<<setprecision(10)<<dp[A][B][C]<<endl;
}   



Measured memory_bytes: 219652
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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


	int ans = BIG_NUM;
	for (int i = 0; i < n; i++) {
		int c, ti;
		cin >> c >> ti;

		if (ti <= t) {
			ans = min(ans, c);
		}
	}

	if (ans == BIG_NUM) {
		cout << "TLE" << endl;
	}
	else {

		cout << ans << endl;
	}
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>

const int MAX = 100000;
struct data {char name[11]; int time;} queue[MAX];
int head = 0, tail = 0;

int isEmpty(){
    return head == tail;
}

void enqueue(char n[], int v){
    strcpy(queue[tail].name, n);
    queue[tail].time = v;
    tail++;
    if(tail >= MAX) tail = 0;
}

struct data dequeue(void){
    struct data d = queue[head];
    head++;
    if(head >= MAX) head = 0;
    return d;
}

int main(void){
    int i, j, n, q, total = 0;
    char ch[11];
    struct data d;

    scanf("%d %d", &n, &q);
    for(i = 0; i < n; i++){
        scanf("%s %d", ch, &j);
        enqueue(ch, j);
    }

    while(!isEmpty()){
        d = dequeue();
        if(d.time > q){
            total += q;
            enqueue(d.name, d.time - q);
        } else {
            total += d.time;
            printf("%s %d\n", d.name, total);
        }
    }

    return 0;
}

Measured memory_bytes: 4116
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC97_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            var subs = new List<string>();

            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 1; j <= (s.Length < 5 ? s.Length : 5) && i + j <= s.Length; j++)
                {
                    subs.Add(s.Substring(i, j));
                }
            }

            subs.Sort();
            subs = subs.Distinct().ToList();
            Console.WriteLine(subs.ElementAt(K - 1));
        }
    }
}


Measured memory_bytes: 15200
def main():
  import sys
  buf=sys.stdin.buffer
  h,w=map(int,buf.readline().split())
  c,*s,_=buf.readline()
  a=b=x=y=c==35
  d=[(b,a)]
  for c in s:
    f=c==35
    b+=a^f
    a=f
    d+=(b,a),
  for c,*s in buf.read().split():
    f=c==35
    y+=x^f
    b=y
    a=x=f
    p=[(b,a)]
    for i,c in enumerate(s,1):
      f=c==35
      b+=a^f
      c,g=d[i]
      c+=f^g
      if b>c:b=c
      a=f
      p+=(b,a),
    d=p
  print(b+1>>1)
main()

Measured memory_bytes: 3192
N = int(input())
S = input()
R_lst = []
G_lst = []
B_lst = []
B_exist = [0] * N
for i in range(N):
    if S[i] == 'R':
        R_lst.append(i)
    elif S[i] == 'G':
        G_lst.append(i)
    else: #S[i] == 'B'
        B_lst.append(i)
        B_exist[i] = 1

ans = 0
B_len = len(B_lst)
for r in R_lst:
    for g in G_lst:
        if r < g:
            i, j = r, g
        else:
            i, j = g, r
        ans += B_len

        flug = False
        if j + j - i >= N:
            flug = False
        elif B_exist[j + j - i]:
            flug = True
        if flug:
            ans -= 1
        
        flug = False
        if i - (j - i) < 0:
            flug = False
        elif B_exist[i - (j - i)]:
            flug = True
        if flug:
            ans -= 1
            
        flug = False
        if (i + j) / 2 % 1 != 0:
            flug = False
        elif B_exist[(i + j) // 2]:
            flug = True
        if flug:
            ans -= 1
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  
  for (int i = 0; i<N; i++) {
    int h;
    cin >> h;
    if (h >= K) {ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)

 
int main()
{  
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif 
   
      ll n,i;
    cin>>n;
   vector<ll> a(n);
    ll sum=0;
    map<ll, ll> mp1;
    rep(i, n)
    {
        cin>>a[i];
        mp1[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll x, y;
        cin>>x>>y;
        sum-=mp1[x]*x;
        if(mp1.find(y)==mp1.end())
        {
            mp1[y]=mp1[x];
            sum+=mp1[y]*y;
            mp1.erase(x);
            cout<<sum<<endl;
            continue;
        }
        else
        {
            mp1[y]+=mp1[x];
            sum+=mp1[x]*y;
            mp1.erase(x);
            cout<<sum<<endl;
            continue;
        }
    }
}

 


Measured memory_bytes: 7908