akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int A[3],i;
inline void solve(){
  INS(i,3,A);
  sort(A,A+3);
  OUT(A[2]-A[0]);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <iostream>

using lli = long long int;

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

int main(void){
    lli n, a, b, c, d;
    scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    n--;
    lli Dist = (a >= b) ? a - b : b - a;
    lli Cn = c * n;
    lli Dn = d * n;
    lli CPD = c + d;
    // + ... k個, - ... (n-k)個数
    // ~~~> Ck ≤ P ≤ Dk, -D(n-k) ≤ M ≤ -C(n-k)
    // ~~~> -Dn + (C+D)k ≤ P + M ≤ -Cn + (C + D)k の数字を構成できる
    // すなわち Dist + Cn ≤ (C+D)k ≤ Dist + Dn なる整数 0 ≤ k ≤ n が存在するか
    lli l = (Dist + Cn) / CPD; while((Dist + Cn) > CPD * l) l++;
    lli u = (Dist + Dn) / CPD; while((Dist + Dn) < CPD * u) u--;
    if(l <= n and l <= u) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VL H(N);
  rep(i,N) cin>>H[i];
  VL A(M),B(M);
  rep(i,M) cin>>A[i]>>B[i];
  int ans=0;
  VVL X(N,VL(0));
  rep(i,M){
    X[A[i]-1].pb(B[i]-1);
    X[B[i]-1].pb(A[i]-1);
  }
  rep(i,N){
    int tmp=1;
    sort(all(X[i]));
      rep(j,X[i].size()){
        if(j) if(X[i][j]==X[i][j-1]) continue;
        tmp*=(H[i]>H[X[i][j]]);
      }
    if(tmp) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11388
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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














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


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


int main(){
  string s,t;
  cin>>s>>t;
  int n1=s.size(), n2=t.size(),ans=n2;
  rep(i,n1-n2+1){
    int count=0;
    rep(j,n2){
      if(s.at(i+j)!=t.at(j))count++;
    }
    if(count<ans) ans=count;

  }
  cout<<ans;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>

using std::string;
using std::vector;


int main(){

    int n;
    scanf("%d", &n);

    int taroPoints = 0, hanakoPoints = 0;
    string taro, hanako;
    for (int i = 0; i < n; i++) {
        std::cin >> taro >> hanako;
        if (taro < hanako) {
            hanakoPoints += 3;
        } else if ( taro > hanako) {
            taroPoints += 3;
        } else {
            taroPoints++;
            hanakoPoints++;
        }
    }
    printf("%d %d\n", taroPoints, hanakoPoints);
}


Measured memory_bytes: 3324
#include <iostream>

using namespace std;

typedef long long int lli;

int main()
{
  lli n, s, t;
  int q, p;
  char c;

  while(cin>>q && q){
    s = t = 0;

    for(int i = 0; i < q; ++i){
      cin >> p >> c >> n;
      if(c == '(') s += n;
      else t += n;
      cout << ((s == t)? "Yes" : "No") << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
use std::io;


fn main() {
    let mut x = read::<usize>();
    x.sort();
    println!("{} {} {}", x[0], x[1], x[2]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,D[51];
    cin>>n;
    D[0]=0;
    rep(i,n) cin>>D[i+1];
    sort(D,D+n+1);
    int ans=D[1]-D[0];
    rep(i,(n+1)/2) D[2*i+1]=24-D[2*i+1];
    sort(D,D+n+1);
    rep(i,n) ans=min(ans,D[i+1]-D[i]);
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    string s;
    cin>>s;
    int a=0,i;
    fr(i,sl(s))
    {
        a+=(s[i]-'0');
    }
    if(a%9)
        cout<<"No";
    else
        cout<<"Yes";
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 3764
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int sum=0;
    rep(i,10){
        int a;
        cin>>a;
        sum+=a;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1160
program good_distance
  implicit none
  integer :: n, d, x(10,20), m, i, j, sq, rt
  x = 0
  read(*,*) n, d
  do i = 1, n
    read(*,*) x(i,1:d)
  end do
  m = 0
  do i = 1, n-1
    do j = i+1, n
      sq = sum((x(j,1:d)-x(i,1:d))**2)
      rt = int(sqrt(real(sq,8)))
      if (rt**2.eq.sq) m = m+1
    end do
  end do
  write(*,'(i0)') m
  stop
end program good_distance

Measured memory_bytes: 640
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    let mut i = 0;
    while i < n {
        if i + 1 == a[i] {
            ans += 1;
            i += 1;
        }
        i += 1;
    }
    println!("{}", ans);
}


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

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

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

int AA, BB, CC;
int dp[20][20][20][10][10][10];

int get(int ab, int bc, int ca, int a, int b, int c) {
	if(ab >= 20 or bc >= 20 or ca >= 20 or a >= 10 or b >= 10 or c >= 10) return 1e9;
	int A = ab + ca + 2 * a + AA;
	int B = ab + bc + 2 * b + BB;
	int C = bc + ca + 2 * c + CC;
	if(A == B and B == C) return 0;
	int &ret = dp[ab][bc][ca][a][b][c];
	if(ret != -1) return ret;
	ret = 1e9;
	ret = min(ret, get(ab+1, bc, ca, a, b, c));
	ret = min(ret, get(ab, bc+1, ca, a, b, c));
	ret = min(ret, get(ab, bc, ca+1, a, b, c));
	ret = min(ret, get(ab, bc, ca, a+1, b, c));
	ret = min(ret, get(ab, bc, ca, a, b+1, c));
	ret = min(ret, get(ab, bc, ca, a, b, c+1));
	ret++; return ret;
}

typedef tuple<int, int, int> trio;

int32_t main () {
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
	/*for(AA = 1; AA <= 50; AA++) {
		for(BB = 1; BB <= 50; BB++) {
			for(CC = 1; CC <= 50; CC++) {
				MEMSET(dp, -1);
				int temp = get(0, 0, 0, 0, 0, 0);
				if(temp >= 9000000) {
					cout<<AA<<' '<<BB<<' '<<CC<<endl;
				}
			}
		}
	}*/
	int mx = 0;
	int x, y, z;
	for(int i=1; i<=1; i++) {
		MEMSET(dp, -1);
		cin>>AA>>BB>>CC;
		//AA = myrand(1, 50);
		//BB = myrand(1, 50);
		//CC = myrand(1, 50);
		int temp = 0;
		int MX = max({AA,BB,CC});
		{
			int d = MX - AA;
			int inc = (d - (d % 2));
			AA += inc;
			temp += inc / 2;
		}
		{
			int d = MX - BB;
			int inc = (d - (d % 2));
			BB += inc;
			temp += inc / 2;
		}
		{
			int d = MX - CC;
			int inc = (d - (d % 2));
			CC += inc;
			temp += inc / 2;
		}
		temp += get(0, 0, 0, 0, 0, 0);
		if(temp >= 9000000) {
			//cout<<"fault!! >>>> "<<AA<<' '<<BB<<' '<<CC<<endl;
		}
		if(temp > mx) {
			mx = temp;
			tie(x, y, z) = trio(AA, BB, CC);
		}
	}
	cout<<mx<<endl;
	//cout<<x<<' '<<y<<' '<<z<<endl;
	return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++){
    	cout << "x"  ;
    }
    return 0;
}



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

long long chmin(long long a, long long b){
    if(a > b) return b;
    return a;
}

int main() {
    int i, j;
    int n;
    long long  h[100001] = {0};
    long long dp[100001] = {0};

    scanf("%d\n", &n);
    for(i = 0; i < n; i++){
        scanf("%lld", &h[i]);
    }
    dp[1] = abs(h[0] - h[1]);
    for(i = 2; i < n; i++){
        dp[i] = chmin(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    printf("%lld\n", dp[n-1]);

    return 0;
}


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

#define MP make_pair 
#define N 200005
typedef long long LL;
const int mod = 1e9 +7;

char s[N];
int af[N], aaf[N], bf[N];


int go(int x, int y)
{
	static int f[N];
	memset(f, 0, sizeof(f));
	f[x] = 1;
	for (int i = x+1; i <= y; ++i)
	{
		if (s[i] == '.') f[i] = f[i-1] | f[i-2];
	}
	return f[y];
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int n, a, b, c, d;
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", s + 1);
    int flag = 1;
	if (c > a && c < b) flag = go(b, d) & go(a, c);
    else if (c > b && c < d) flag = go(b, d) & go(a, c);
    else if (c > d) 
    {
    	af[a] = 1;
    	for (int i = a+1; i <= c; ++i)
			if (s[i] == '.') af[i] = af[i-1]|af[i-2];
		bf[b] = 1;
		for (int i = b+1; i <= c; ++i)
			if (s[i] == '.') bf[i] = bf[i-1]|bf[i-2];

		aaf[c] = 1;
		for (int i = c-1; i >= b; --i)
			if (s[i] == '.') aaf[i] = aaf[i+1] | aaf[i+2];
			
		flag = 0;
		for (int i = b; i <= d; ++i)
			if (af[i-1] && bf[i] && s[i+1]=='.') flag |= aaf[i+1];
		if (!bf[d]) flag = 0;  
    }
    else assert(0);
    puts(flag? "Yes": "No");
	
	
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
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; }

const ll INF = 1LL<<60;

//GCD(最大公約数)
ll gcd(ll a, ll b) {
   if(b == 0) return a;
   return gcd(b, a % b);
}

//素因数分解
vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    
    ll g = gcd(a, b);
    auto f = factorize(g);

    int ans = f.size() + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


n = ni()
p = na()

c = 1
f = p[0]

for pi in p[1:]:
    if f >= pi:
        c += 1
        f = pi
print(c)


Measured memory_bytes: 23588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = 3.141592653589;
double ans;

int main(){
  int n, m;
  cin >> n >> m;
  int ans;
  int a[10000];
  rep(i, m){
    cin >> a[i];
    n -= a[i];
  }
  cout << max(n, -1) <<endl;
}
  

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

using namespace std;

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

const int mod = 1e9 + 7;

vector<int> candidates;
vector<int> options = {3, 5, 7};


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

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

  if((A+B)%2 == 0){
    cout << (A+B) / 2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
   int height,width,count,limit,row,col;
   char table[100][101];
   while(true){
       scanf("%d %d",&height,&width);
       if(height == 0 && width == 0)break;
       for(int i = 0; i < height; i++){
           scanf("%s",table[i]);}
       count = 0;
       row = 0; col = 0;
       limit = height*width;
       while(table[row][col] != '.' && count < limit){
           switch(table[row][col]){
           case '>':col++;
                   count++;
                   break;
           case '<':col--;
                   count++;
                   break;
           case '^':row--;
                   count++;
                   break;
           case 'v':row++;
                    count++;
                    break;}}
       if(count >= limit){
           printf("LOOP\n");}
	   else{
           printf("%d %d\n",col,row);}}
    return 0;
}


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

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

	for (int i = 1; i <= 1009; i++) {
		a = i * 0.08;
		b = i * 0.1;

		if (A == a && B == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <string>
using namespace std;
string actionFunction(string x,string y) {
    vector<vector<int>> dp(x.length()+1,vector<int>(y.length()+1,0));
    if(x.length()==0 || y.length()==0)return "";
    for(int row=1;row<=x.length();row++) {
        for(int col=1;col<=y.length();col++) {
            if(x[row-1]==y[col-1])dp[row][col]=dp[row-1][col-1]+1;
            else dp[row][col]=max(dp[row-1][col],dp[row][col-1]);
        }
    }
    int maxlength=dp[x.length()][y.length()];
    int row=x.length(),col=y.length();
    string out;
    while(maxlength!=0 && col>0 && row>0) {
        if(dp[row][col-1]==maxlength) {
            col--;continue;
        }
      	if(dp[row-1][col]==maxlength) {
        	row--;continue;
        }
        if(dp[row-1][col-1]==maxlength-1) {
            out.push_back(y[col-1]);
            row--;
            maxlength--;
            col--;
        }
    }
    return out;
}
string reverseString(string a) {
    for(int i=0;i<a.length()/2;i++) {
        swap(a[i],a[a.length()-i-1]);
    }
    return a;
}
int main(void){
    string x,y;
    cin>>x>>y;
    cout<<reverseString(actionFunction(x,y))<<endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
int main()
{
	cin >>s;
	if ((int)s.size()%2)
	{
		cout <<"No";
		return 0;
	}
	for (int i=0;i<s.size();i++)
	{
		if ((i%2==0 && s[i]!='h') || (i%2 && s[i]!='i'))
		{
			cout <<"No";
			return 0;
		}
	}
	cout <<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int num;
int rabbit[100001];
bool flag[100001] = {};
int ans = 0;

int main() {
	scanf("%d", &num);
	for(int i=1;i<=num;i++){
		scanf("%d", &rabbit[i]);
	}
	for (int i = 1; i <= num; i++) {
		if (i == rabbit[rabbit[i]]) {
			flag[i] = true;
			flag[rabbit[i]] = true;
			ans++;
		}
	}
	printf("%d\n", ans / 2);
}

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

import math

N_tmp = N
cnt = {}
for p in range(2, int(math.sqrt(N)) + 1):
    i_p = 0
    while N_tmp % p == 0:
        i_p += 1
        N_tmp //= p
    #
    if i_p < 1: continue
    cnt[str(p)] = i_p
else:
    if N_tmp > 1: cnt[str(N_tmp)] = 1

ans = 0
for p in cnt.keys():
    for i in range(64):
        if (i + 1) * (i + 2) // 2 > cnt[p]: break
    #
    ans += i

print(ans)

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

int main() {
  string s,t;
  cin >> s >> t;

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

  
  bool flag = true;
  if (s.at(0) > t.at(0))
    flag = false;
  else if (s.at(0) == t.at(0)) {
    if (!(s.size()<t.size() && s.at(s.size()-1) == t.at(t.size()-1)))
      flag = false;
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

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

int main() {
    int a, b, i, r, l, ans = 0;
    cin >> a >> b;
    for(i = a; i < b + 1; i++) {
        r = i % 100;
        l = (i -  r) / 1000;
        l = (l % 10) * 10 + (l - (l % 10)) / 10;
        if(l == r) {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                Dictionary<string, string> dict = new Dictionary<string, string>();
                for (int i = 0; i < n; i++) {
                    string[] splited = Console.ReadLine().Split(' ');
                    dict.Add(splited[0], splited[1]);
                }
                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++) {
                    string str = Console.ReadLine();
                    if (dict.ContainsKey(str)) {
                        Console.Write(dict[str]);
                    }
                    else {
                        Console.Write(str);
                    }
                }
                Console.WriteLine();


            }
        }

        
    }



    
}

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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 500006
#define mod 1000000007
#define mod2 998244353
#define inf 1e17

int dp[101][100001];
int w[101],v[101];
int n,W;

int solve(int id,int val)
{
    if(val<=0)
        return 0;
    if(id<0)
        return inf;
    
    int &ans=dp[id][val];
    if(ans!=-1)
        return ans;
    //ans=0;
    ans=min(solve(id-1,val),w[id]+solve(id-1,val-v[id]));
    return ans;


}


int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif
    
    

    cin >> n >> W;

    
    memset(dp,-1,sizeof dp);
    int i,j;
    
    for(i=0;i<n;i++)
    {
        cin >> w[i] >> v[i];
    }

    for(i=100000;i>=0;i--)
    {
        if(solve(n-1,i)<=W)
        {
            cout << i << endl;
            return 0;
        }
    }

   


}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e14 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<'\n';
    return 0;  
}   

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int d[300*300+100];

int main(){
    map<int,pair<int,int> > grid;
    int H,W,D;
    cin >> H >> W >> D;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            int a;
            cin >> a;
            grid[a] = make_pair(i,j);
        }
    }

    for(int i=1;i<=W*H;i++){
        if(i<=D) d[i] = 0;
        else{
            auto tmp = grid[i];
            auto tmp2 = grid[i-D];
            d[i] = d[i-D] + abs(tmp.first - tmp2.first) + abs(tmp.second - tmp2.second);
        }
    }
    int Q; cin >> Q;
    int L, R;
    for(int i=0;i<Q;i++){
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        final Integer A = sc.nextInt(),
                B = sc.nextInt(),
                C = sc.nextInt();
        if (A * B * C == 5 * 5 * 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    Rep(i,n-1) {
        if(s[i] == s[i-1]) ans++;
    }
    ans = min(n-1, ans + k*2);
    cout << ans << endl;
}

Measured memory_bytes: 3760
/*

*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> a;
ll foo(int i,int k,vector<int> &dp){
    
    if(i==a.size()-1) return 0;

    if(i>=a.size()) return INT_MAX;
    
    if(dp[i]!=-1) return dp[i];

   ll mn = INT_MAX;

   for(int j=1;j<=k;j++){
       
    ll l = foo(i+j,k,dp)+abs(a[i+j]-a[i]);
    // ll r = foo(i+2,k,dp)+abs(a[i+2]-a[i]);

    mn = min(mn,l);

   }
    return dp[i]=mn;

}
int main(){

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

      int n,k;
      cin>>n>>k;
      for(int i=0;i<n;i++)
      {
          int x;
          cin>>x;
          a.push_back(x);
      }
      vector<int> dp(n,-1);
      cout<<foo(0,k,dp)<<"\n";
}

Measured memory_bytes: 8952
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	char str[1200];
	int i, l;
	fgets(str, 1200, stdin);
	l = strlen(str);
	for (i = 0; i < l; ++i)
	{
		if (isupper(str[i])) str[i] = tolower(str[i]);
		else if (islower(str[i])) str[i] = toupper(str[i]);
	}
	printf("%s", str);
	return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s;
  ll a,b;
  a=0;
  b=0;
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='0')a++;
    if(s[i]=='1')b++;
  }
  printf("%lld",min(a,b)*2);
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    
    ll ans = 0;
    while(N/10){
        ans += N%10;
        N /= 10;
    }
    ans += N;

    if(ans == 1) cout << "10" << endl;
    else cout << ans << endl;
}

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

int main() {
        int n;
        cin >> n;
        // a b c d
        int a = n/1000;
        int b = (n%1000)/100;
        int c = (n%100)/10;
        int d = (n%10);
        if ((a==b&&b==c)||(d==b&&b==c)) {
                        cout << "Yes" << endl;
        } else {
                        cout << "No" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_2
# CreatedDate:  2020-02-21 20:39:32 +0900
# LastModified: 2020-02-21 23:32:20 +0900
#


import heapq
def initial_signal(i,adj,N):
    d = [float("inf") for _ in range(N)]
    d[i] = 0
    Q = [(0,i)]
    return d,Q

def relax(n_cost, u, v, adj,d,Q):
    if d[v] > d[u]+n_cost:
        d[v]=d[u]+n_cost
        heapq.heappush(Q,(d[v],v))



def dijkstra(i,adj,N):
    d,Q = initial_signal(i,adj,N)
    while Q:
        cost, u = heapq.heappop(Q)
        for n_cost, v in adj[u]:
            relax(n_cost, u, v, adj, d, Q)
        
    return d



def main():
    N, M = map(int, input().split())
    adj = [[] for _ in range(N)]
    for _ in range(M):
        a,b,c = map(int, input().split())
        adj[a-1].append((c,b-1))
        adj[b-1].append((c,a-1))
    shortest = []
    for i in range(N):
        shortest.append(dijkstra(i,adj,N))
    ans = 0
    for i in range(N):
        for cost, j in adj[i]:
            if cost>shortest[i][j]:
                ans+=1
    print(ans//2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; return os;
}
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  queue<ll> que;
  rep(i, 9) que.push(i+1);

  int cnt = 0;
  while (!que.empty()) {
    ll v = que.front(); que.pop();
    ++cnt;
    if (cnt == K) {
      cout << v << endl;
      return 0;
    }
    
    int x = v % 10;
    rep2(i, -1, 2) {
      if ((x == 0 && i == -1) || (x == 9 && i == 1)) continue;
      que.push(v*10 + x + i);
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef double db;
#define re register
#define push_back pb
#define pri(a) printf("%d",(int)(a))
#define sa(n) scanf("%d", &(n))
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++)
const int INF = 0x3f3f3f3f;
const int maxn = 2e5+7;
const double eps = 1e-7;
const double pi = acos(-1.0);

string s,t;
int main(void)
{
    IOS;
    cin>>s;
    int ans = 1;
    int flag = 0;
    for(int i=1; i<s.length(); i++)
    {
        if(flag == 0 && s[i] == s[i-1]) flag = 1,i++;
        else if(flag == 1) flag = 0;
        if(i<s.length())ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int n[4];
    cin >> n[0] >> n[1] >> n[2] >> n[3];
    sort(n,n+4);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9){
        cout << "YES" << endl;
    } else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#define LL long long
#define PP std::pair<int,int>
LL N;
LL H, W;
LL ans[10];
int D[] = { -1,0,1 };
std::set<PP> B;
std::vector<PP> cen;
int main() {
	std::cin >> H >> W >> N;
	ans[0] = (H - 2)*(W - 2);
	for (int i = 0; i < N; i++) {
		int a, b;
		std::cin >> a >> b;
		B.insert({ a,b });
		for (auto u : D) {
			for (auto m : D) {
				if (1 < a + u&&a + u < H && 1 < b + m&&b + m < W) {
					cen.push_back({ a + u,b + m });
				}
			}
		}
	}
	std::sort(cen.begin(), cen.end());
	cen.erase(std::unique(cen.begin(), cen.end()), cen.end());
	for (auto u : cen) {
		int count = 0;
		for (auto dx : D) {
			for (auto dy : D) {
				auto it = B.find({ u.first + dx,u.second + dy });
				if (it != B.end()) {
					count++;
				}
			}
		}
		ans[count]++;
		ans[0]--;
	}
	for (int i = 0; i <= 9; i++) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 12780
import math
p = [2]
NM = 10000
c = 3
while len(p) < NM:
    m = int(math.sqrt(c))
    r = True
    for i in p:
        if i > m:
            break
        if c % i == 0:
            r = False
            break
    if r:
        p.append(c)
    c += 2

while True:
    n = int(raw_input())
    if n == 0:
        break
    print sum(p[:n])
        

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

//--------------------------------------------
#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(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(){
  double N;

  scanf("%lf",&N);

  FOR (h, 1, 3500) {
    FOR (n, 1, 3500) {
      double w = (N * double(n) * double(h)) / (4 * double(n) * double(h) - N * double(n + h));
      if (w == int(w) && w > 0 && 4 / N == 1 / double(h) + 1 / double(n) + 1 / double(w)) {
        printf("%d %d %d\n", h, n, int(w));
        exit(0);
      }
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll k;
ll sum(ll n){
    ll sumk=0;
    while(n>0){
        sumk+=n%10;
        n/=10;
    }
    return sumk;
}
double div(ll n){
    return double(n)/sum(n);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k;
    vector<ll> ex;
    ll keta=1;
    for(int i=0;i<15;i++){
        for(int j=2;j<=150;j++){
            ex.push_back(keta*j-1);
        }
        keta*=10;
    }
    sort(ALL(ex));
    ex.erase(unique(ALL(ex)),ex.end());
    for(ll i=0;i<ex.size();i++){
        for(ll j=i+1;j<ex.size();j++){
            if(div(ex[j])<div(ex[i])){
                ex.erase(ex.begin()+i);
                i--;
                break;
            }
        }
    }
    for(ll i=0;i<k;i++){
        cout<<ex[i]<<"\n";
    }
}

Measured memory_bytes: 384
while True:
	H,W = list(map(int, input().split()))
	if (H == 0) and (W == 0):
		break
	else:
		for n in range(0, H):
			s = ""
			for m in range(0, W):
				if (1 <= n and n <= (H-2)) and(1 <= m and m <= (W-2)):
					s += "."
				else :
					s += "#"
			print(s)
		print("")

Measured memory_bytes: 7588
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

lint n, m;
priority_queue<lint> d;
void input() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		lint a; cin >> a;
		d.push(a);
	}
	return;
}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	input();
	for (int i = 0; i < m; i++) {
		lint a = d.top();
		a /= 2;
		d.pop();
		d.push(a);
	}
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		ans += d.top();
		d.pop();
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4216
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

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

}

int arr[100001];
int f[100001];
int ma[100001];
int ans[100001];

int Find(int x) {

	if (x == f[x])
		return x;

	return f[x] = Find(f[x]); 

}
const int Mod = 1e9 + 7;

long long fastPower(long long base, long long power) {
	long long result = 1;
	while (power > 0) {
		if (power & 1) { 
			result = result * base % Mod;
		}
		power >>= 1; 
		base = (base * base) % Mod;
	}
	return result;
}
 
int Inv(int x) {
	return fastPower(x, Mod - 2);
}


int nChoosek(int n, int k) {
 
	int ans = 1;

	for (int i = 1; i <= k; ++i) 
		ans = ans * Inv(i) % Mod *(n - i + 1) % Mod;

	return ans % Mod;

}




map<int, int> m;

int32_t  main() {

	IOS;

	int N, M;

	cin >> N >> M;
	 
	int cnt = 0;
	int cntA = 0;

	map<int, int> wa;
	for (int i = 0; i < M; i++) {
	
		int tmp;
		string s;

		cin >> tmp >> s;

		if (s == "AC" && m[tmp] == 0) {
			m[tmp]++;
			cntA++;
			cnt += wa[tmp];
		}
		else if (s == "WA" && m[tmp] == 0) {
			wa[tmp]++;
		}

	}


	cout << cntA << " " << cnt << endl;



}


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

using namespace std;
using ll = long long;
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  rep(i, 10) rep(j, 10) rep(k, 10) {
    int l = 0;
    for (char c : S) {
      if (l == 0 && c - '0' == i) l++;
      else if (l == 1 && c - '0' == j) l++;
      else if (l == 2 && c - '0' == k) l++;
    }
    if (l == 3) {
      ans++;
    }
  }
  cout << ans << endl;
}


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


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

    if(a + b <= k){
        cout << 0 << ' ' << 0;
        return 0;
    }
    if(a >= k){
        cout << a-k << ' ' << b;
        return 0;
    }
    cout << 0 << ' ' << b-k+a;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll a,b;
  cin >>a >> b;

  cout << (min(a,b)>=1&&max(a,b)<=9?a*b:-1) << endl;
}

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


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c,d,e,f;
    for(; scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) && a+b+c+d+e+f;){
        a += d; b += e; c += f;
        int ans = 0;
        for(int x = 0; x < 3; x++){
            if( a >= x && b >= x && c >= x )
            ans = max(ans, (a-x)/3+(b-x)/3+(c-x)/3+x);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int L,R,D, count=0; cin >> L >> R>> D;
    for (int i=L;i<=R; ++i) {
        if (i%D==0) count++;
    }
    cout << count << "\n";
    return 0;
}

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

public class Main{

	
	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		PrintWriter  out=new PrintWriter(System.out);
		int n=sc.nextInt(),k=sc.nextInt();
		long tmp=n/k;
		
		long ans=tmp*tmp*tmp;
		
		
		long m=0;
		if(k%2==0)
		{
			
			int mod=k/2;
			while(mod<=n) {
				m++;
				mod+=k;
			}
			
			
		}
		ans+=m*m*m;
		//ans+=m*1L*(m-1)*3;
		out.println(ans);
		out.close();
	}
	
	static class Scanner {
        StringTokenizer st;
        BufferedReader br;
 
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        public Scanner(FileReader s) {
            br = new BufferedReader(s);
        }
 
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public String nextLine() throws IOException {
            return br.readLine();
        }
        public boolean ready() throws IOException {return br.ready();}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
       
    }

}

Measured memory_bytes: 21332