akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll A,B,C;
    cin >> A >> B >> C;
    ll K;
    cin >> K;
    for(int i = 0;i < K;i++){
        if (B <= A){
            B = B * 2;
        }else if(C <= B){
            C = C * 2;
        }
    }
    if (A < B && B < C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

const int N = 1e5;
vi graph[N + 10];
int dp[N + 10];
bool visited[N + 10];

int count_dp(int v)
{
    if(graph[v].size() == 0) return 0;
    if(dp[v]) return dp[v];
    
    for(int& i : graph[v])
        dp[v] = max(dp[v], count_dp(i) + 1);

    return dp[v];
}
int main()
{
    turbo

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

    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        graph[b].pb(a);
    }

    int ans = 0;

    for(int i = 1; i <= n; i++)
    {
        if(!visited[i]) int x = count_dp(i);
        ans = max(ans, dp[i]);
    }

    return  cout << ans, 0;
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
   if(x-r<0 || y-r<0 || x+r>W || y+r>H){
       cout<<"No"<<endl;
   }else
   cout<<"Yes"<<endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	int n;
	cin>>n;
	vector<int> a(n+2);
	a[0]=0;a[n+1]=0;
	int ans=0;
	rep(i,n){
		cin>>a[i+1];
		ans+=abs(a[i+1]-a[i]);
	}
	ans+=abs(a[n]);
	
	rep(i,n){
		int b=min(a[i],a[i+2]);
		int c=max(a[i],a[i+2]);
		if(b<a[i+1] && a[i+1]<c){
			cout<<ans<<endl;
		}else{
			cout<<ans-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i]-a[i+2])<<endl;
		}
	}

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int H,W;
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};
int dist[1005][1005] = {};
bool in(int x, int y){
	return 0<=x&&x<H&&0<=y&&y<W;
}
int main() {
	cin>>H>>W;
	vs A(H);
	queue<P> Q;
	rep(i,H)cin>>A[i];
	rep(i,H)rep(j,W){
		dist[i][j] = -1;
		if(A[i][j] == '#'){
			Q.push({i,j});
			dist[i][j]  = 0;
		}
	}
	while(!Q.empty()){
		P p = Q.front();
		Q.pop();
		int x = p.first, y = p.second;
		rep(i,4){
			int nx = x + dx[i], ny = y + dy[i];
			if(!in(nx,ny)||dist[nx][ny]!=-1)continue;
			dist[nx][ny] = dist[x][y]+1;
			Q.push({nx,ny});
		}
	}
	int ans= 0;
	rep(i,H)rep(j,W){
		ans = max(ans,dist[i][j]);
	}
	cout<<ans<<endl;
}						

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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  int small = (a > b) ? b : a;
  int big = (a > b) ? a : b;
  
  string ret;
  for(int i=0; i<big; i++) ret += to_string(small); 
  
  cout << ret;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string S[100], T[100], U; int n;
vector<string>dp[1000];
char E[27] = "22233344455566677778889999";
int main() {
	while (true) {
		cin >> n; for (int i = 0; i < 1000; i++) { dp[i].clear(); } if (n == 0)break;
		for (int i = 0; i < 100; i++) { S[i] = ""; T[i] = ""; }
		for (int i = 0; i < n; i++) {
			cin >> S[i];
			for (int j = 0; j < S[i].size(); j++)T[i] += E[S[i][j] - 'a'];
		}
		cin >> U;
		dp[0].push_back("");
		for (int i = 0; i < U.size(); i++) {
			for (int j = 0; j < n; j++) {
				int a1 = T[j].size();
				if (U.size() < i + a1)continue;
				if (U.substr(i, T[j].size()) != T[j])continue;
				for (int k = 0; k < dp[i].size(); k++) {
					string T = dp[i][k] + S[j] + " ";
					dp[i + a1].push_back(T);
				}
			}
		}
		for (int i = 0; i < dp[U.size()].size(); i++) {
			cout << dp[U.size()][i].substr(0, dp[U.size()][i].size() - 1) + "." << endl;
		}
		cout << "--" << endl;
	}
	return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var S = inputLongArray[0];
            var W = inputLongArray[1];
            string result;

            if (S > W)
            {
                result = "safe";
            }
            else
            {
                result = "unsafe";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28060
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>m>>n>>o>>p;
    cnt=m;
    cntl=o;
    while(1){
        cntl-=n;
        if(cntl<=0){
            cout<<"Yes";
            return 0;
        }
        cnt-=p;
        if(cnt<=0){
            cout<<"No";
            return 0;
        }
    }
}

Measured memory_bytes: 10520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (auto& e : s) {
    if (e == '1')
      e = '9';
    else if (e == '9')
      e = '1';
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b>=c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}
 
int main(){
  string s = "Christmas";
  ll n;cin >> n;
  rep(i, 25-n)s += " Eve";
  cout << s << endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;
int yaku[1000005];
//
//vector<long long> divisor(long long n) {
//	vector<long long> ret;
//	for (long long i = 1; i * i <= n; i++) {
//		if (n % i == 0) {
//			ret.push_back(i);
//			if (i * i != n) ret.push_back(n / i);
//		}
//	}
//	sort(ret.begin(), ret.end()); // 昇順に並べる
//	return ret;
//}

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

	vector<long long> g(n+1);


	for (int j = 1;j <= n;j++) {
		for (int i = j;i <= n;i += j) {
			g[i]++;
		}
	}

	long long ans = 0;
	for (int i = 1;i < n;i++) {
		ans += g[i];
		//cout << g[i] << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

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

    if (s[0] != t[0]) {
        cout << -1 << endl;
        return 0;
    }
    ll l = lcm(n, m);
    ll l2 = lcm(l / n, l / m);
    
    for (int i = 1; i < m; i++) {
        ll x = i * (l / m);
        if (x % l2 == 0) {
            if (x <= (n - 1) * (l / n)) {
                if (t[i] != s[x / (l / n)]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 2e5 + 5, MOD = 1e9 + 7;
int A[N], B[N];
vector<int> go[N];
int main(){
  
  int n, m; 
  cin >> n >> m;
  
  for(int i = 0; i < n; i++){
    cin >> A[i] >> B[i];
    if(A[i]<=m)
    go[m-A[i]].push_back(B[i]);
  }
  priority_queue<int>pq;
  int ans = 0;
  for(int i = m-1; i>= 0; --i){
    for(auto x : go[i])pq.push(x);
    if(pq.size())ans+=pq.top(),pq.pop();
  }
  
  cout<<ans<<'\n';
  
  
  
  return 0;
}


Measured memory_bytes: 9472
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int h1,m1,h2,m2,k;
int t,totT;

int main(){
	cin>>h1>>m1>>h2>>m2>>k;
	
	t = (h2-h1)*60+m2-m1;
	
	if(t <= k){
		cout<<0;
		return 0;
	}
	
	
	cout<<t-k<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main(void){

  int n,d,x;
  scanf("%d %d %d", &n, &d, &x);
  int a[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int sum = x;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= d; j += a[i]) {
			sum++;
		}
	}
	printf("%d\n", sum);

  return 0;
}

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

typedef long long ll; 
#define inf 1000*1000*1000+9
#define infl (ll)inf*inf
#define sz(x) ((int) x.size())
#define all(a) a.begin(),a.end()
const int mod=1e9+7; 
const int nax=1e6+6; 
ll fac[nax], ifac[nax]; 
ll inv[nax]; 

void pp(){
	fac[0]=fac[1]=ifac[0]=ifac[1]=1; 
	inv[0]=inv[1]=1; 
	for(int i=2;i<nax;i++){
		fac[i]=i*fac[i-1]%mod; 
		ll q=mod/i, r=mod%i; 		
		inv[i]=(mod-(q*inv[r]%mod)); 
		ifac[i]=ifac[i-1]*inv[i]%mod; 
	}		
}

ll ch(int n, int r){
	return fac[n]*ifac[r]%mod*ifac[n-r]%mod; 
}

void pre(){
	pp(); 
	ll x,y; 
	cin>>x>>y; 
	ll ans=0; 
	ll b=(2*x-y)/3; 
	ll a=x-2*b; 
	if(a>=0 && b>=0 && a+2*b==x && 2*a+b==y){
		cout<<ch(a+b,b)<<endl; 
	}
	else {cout<<0<<endl; }
}

int main(){
	cout<<fixed<<setprecision(10); 
	pre(); 
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[3];
    cin>>s[0]>>s[1]>>s[2];
    if(s[0]=='R' && s[1]=='R' &&s[2]=='R')
    cout<<"3";
    else if(s[0]=='R' && s[1]=='S')
    cout<<"1";
    else if((s[0]=='S' && s[1]=='R' && s[2]=='R')||(s[0]=='R' && s[1]=='R' && s[2]=='S'))
    cout<<"2";
    else if(s[0]=='S' && s[1]=='S' &&s[2]=='S')
    cout<<"0";
    else cout<<"1";
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len = s.length();
    bool f = true;
    for(int i = 0; i < len; i++){
        if(i%2==0){
            // 奇数ばんめ
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') f = true;
            else {f = false; break;}
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') f = true;
            else {f = false; break;}
        }
    }
    cout << (f ? "Yes" : "No") <<  endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s1,s2;
	int pan=0;
	cin>>s1>>s2;
	if((s1[1]==s2[1])&&(s1[0]==s2[2])&&(s1[2]==s2[0]))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
sd=list(input())
t=list(input())

yn=""
for i in range(len(sd)-len(t)+1):
    ii=len(sd)-len(t)-i
    yn=""
    for j in range(len(t)):
        if sd[ii+j]!=t[j] and sd[ii+j]!="?":
            yn="NG"
            break
    if yn=="NG":
        continue
    else:
        yn="yes"
        break
    
if yn=="NG" or yn=="": 
    print("UNRESTORABLE")
else:
    for j in range(len(t)):
        sd[ii+j]=t[j]
    for j in range(len(sd)):
        if sd[j]=="?":
           sd[j]="a"
    strt="".join(sd)
    print(strt)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll dp[3030][3030][4];
int main(){
    ll r, c, k; cin >> r >> c >> k;
    vector<vector<ll>> g(r, vector<ll>(c, 0));
    
    rep(i, k){
        ll x, y, v; cin >> x >> y >> v;
        x--, y--;
        g[x][y] = v;
    }
    rep(i, r){
        rep(j, c){
            repd(t, 3){
                dp[i][j][t+1] = max(dp[i][j][t+1], dp[i][j][t]+g[i][j]);
            }
            rep(t, 4){
                dp[i+1][j][0] = max(dp[i][j][t], dp[i+1][j][0]);
                dp[i][j+1][t] = max(dp[i][j][t], dp[i][j+1][t]);
            }
        }
    }
    ll res=-LINF;
    rep(i, 4) res = max(res, dp[r-1][c-1][i]);
    cout << res << endl;

}


Measured memory_bytes: 357912
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N;
ll a[100001];
int main(){
    cin >> N;
    ll num = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i] < 0) num++;
        a[i] = max(a[i],(-1)*a[i]);
    }
    ll sum = 0;
    sort(a,a+N);
    //cout << num << endl;
    if(num % 2 == 0){
        for(int i = 0; i < N; i++){
            sum += a[i];
        }
    } else {
        for(int i = 1; i < N; i++){
            sum += a[i];
        }
        sum -= a[0];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll pow(ll m,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*m%MOD;
        m=m*m%MOD;
        n>>=1;
    }
    return res;
}
int main(){
    int m,n;
    cin>>m>>n;
    cout<<pow(m,n)<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N , k;
    scanf( "%d%d" , &N , &k );
    int Ans = ceil( (float)N / 2 );
    if( k <= Ans ) puts( "YES" );
    else puts( "NO" );
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p){
  os<<p.first<<' '<<p.second;
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const auto last=--cend(v);
  for(auto i=cbegin(v); i<last; ++i) os<<*i<<'\n';
  os<<*last<<'\n';
  return os;
}
template<typename Itr, typename Lt>
auto partition2(const Itr first, const Itr last, const Lt& lt){
  auto i=first;
  for(auto j=first; j!=last; ++j){
    if(!lt(*last, *j)){
      iter_swap(i, j);
      ++i;
    }
  }
  iter_swap(i, last);
  return i;
}
template<typename Itr, typename Lt>
void quick_sort2(const Itr first, const Itr last, const Lt& lt){
  if(first<last){
    auto mid=partition2(first, last, lt);
    quick_sort2(first, mid-1, lt);
    quick_sort2(mid+1, last, lt);
  }
}
int32_t main(){
  size_t n; cin>>n;
  using card=pair<char, uint32_t>;
  vector<card> a(n); for(auto&& e:a) cin>>e.first>>e.second;
  vector<card> b=a;
  const auto lt=[](const card& x, const card& y){ return x.second<y.second; };
  quick_sort2(begin(a), --end(a), lt);
  stable_sort(begin(b), end(b), lt);
  cout<<(a==b?"Stable\n":"Not stable\n")<<a;
}


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

// (i,j)が城ならまあいい
// (i,j)が黒かつ隣接する黒がなければ不可能
bool impo(vector<string> &s, int i, int j){
  if (s.at(i).at(j) == '.') return false;
  int h = s.size(), w = s.at(0).size();
  bool ok = false;
  //左端、右端、上端、下端なら各々判定をスキップ
  if (j>0)   if (s.at(i).at(j-1)=='#') ok = true;
  if (j<w-1) if (s.at(i).at(j+1)=='#') ok = true;
  if (i>0)   if (s.at(i-1).at(j)=='#') ok = true;
  if (i<h-1) if (s.at(i+1).at(j)=='#') ok = true;
  
  if (ok) return false;
  else return true;
}

int main() {
  int h,w; cin >>h >>w;
  vector<string> s(h);
  for (int i=0; i<h; i++) cin >>s.at(i);
  
  string ans = "Yes";
  bool possible = true, impossible = false;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      if (impo(s, i, j)){
        possible = false;
        ans = "No";
        break;
      }
    }
    if (!possible) break;
  }
  
  cout <<ans;
  cout <<endl;
}


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

const int MAX_N = 310;
double dp[MAX_N][MAX_N][MAX_N];
int N,a,f,s,t;

double dfs(int i, int j, int k){
    if (dp[i][j][k] != -1) return dp[i][j][k];
    if (i == 0 && j == 0 && k ==0) return 0.0; 

    double ans = 0.0;
    ans += (i > 0 ? dfs(i-1,   j,   k) * i : 0.0);
    ans += (j > 0 ? dfs(i+1, j-1,   k) * j : 0.0);
    ans += (k > 0 ? dfs(  i, j+1, k-1) * k : 0.0);
    ans += N;
    ans /= i + j + k;
    return dp[i][j][k] = ans;
}


int main() {
    cin >> N;
    for (int i = 0; i <= N; ++i){
        for (int j = 0; j <= N; ++j){
            for (int k = 0; k <= N; ++k){
                dp[i][j][k] = -1;
            }
        }
    }
    for (int i = 0; i < N; ++i){
        cin >> a;
        if (a == 1) f++;
        if (a == 2) s++;
        if (a == 3) t++;
    }
    cout << fixed << setprecision(10) << dfs(f, s, t) << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\???
// .???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????
// ?????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\??????????????????

int n, W, v[111], w[111], dp[111][11111];

int main() {
	cin >> n >> W;
	rep(i,n) cin >> v[i] >> w[i];
	rep(i,n) {
		rept(j,W) {
			if (j<w[i]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
		}
	}
	cout << dp[n][W] << ln;
}

Measured memory_bytes: 7416
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

struct tr{
    int a,b;
    int c;
    int t;
}a[100005];

bool cmp(const tr& x, const tr& y) { return x.a < y.a; }
bool cmpp(const tr& x, const tr& y) { return x.t < y.t; }

int main(){
    int llc[100005];
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a[i].a>>a[i].b;
        a[i].t=i;
        if(a[i].a>a[i].b){
            swap(a[i].a,a[i].b);
        }
    }
    sort(a,a+n-1,cmp);

    int co=1,ll,mx=0;;
    for(int i=0;i<n-1;i++){
        if(a[i].a==1){
            a[i].c=co;
            llc[a[i].b]=co;
            if(co>mx){
                mx=co;
            }
            co++;
        }
        else{
            if(a[i].a!=a[i-1].a){
                co=1;
            }
            if(llc[a[i].a]==co){
                co++;
            }
            a[i].c=co;
            llc[a[i].b]=co;
            if(co>mx){
                mx=co;
            }
            co++;
        }
    }
    sort(a,a+n-1,cmpp);
    cout<<mx<<endl;
    for(int i=0;i<n-1;i++){
        cout<<a[i].c<<endl;
    }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  cin>>n;
  for(i=1;i<10;i++) if(n%i==0 && n/i<10) break;
  if(i<10) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

int res, land[1080][1080];
int xs[] = {1, 1, 0, -1, -1, -1, 0, 1};
int ys[] = {0, 1, 1, 1, 0, -1, -1, -1};
void dfs(int x, int y){
	land[x][y] = 0;
	for(int i = 0;i < 8;i++){
		int tx = x + xs[i];
		int ty = y + ys[i];
		if(land[tx][ty])dfs(tx, ty);
	}
}

int main(){
	int w, h;
	while(cin >> h >> w, w | h){
		res = 0;
		for(int i = 1;i <= w;i++){
			for(int j = 1;j <= h;j++){
				cin >> land[i][j];
			}
		}
		for(int i = 1;i <= w;i++){
			for(int j = 1;j <= h;j++){
				if(land[i][j]){
					res++;
					dfs(i, j);
				}
			}
		}
		cout << res<< endl;
	}
	return 0;
}

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

int main()
{
  int a,b,c;
  while(cin>>a>>b>>c){
    int x,i,k,ans;
    i=0;k=0;
       vector<int> v;
       for(int i=1;i<=min(a,b);i++)
       {
          if(a%i==0&&b%i==0)v.push_back(i);
       }
      // for(int i=0;i<v.size();i++)cout<<v[i]<<" "<<endl;
      cout<<v[v.size()-c]<<endl;
  }
}


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

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    if(s < 1000000000){
        for(int i=0;i<k;++i) cout << s << " \n"[i==n-1];
        for(int i=k;i<n;++i) cout << s+1 << " \n"[i==n-1];
    }else{
        for(int i=0;i<k;++i) cout << s << " \n"[i==n-1];
        for(int i=k;i<n;++i) cout << 1 << " \n"[i==n-1];
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;


int main() {
	string s; ll k;
	cin >> s >> k;
	for (ll i = 0;i < k;i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
		
	}
	cout << "1" << endl;
	return 0;
}

Measured memory_bytes: 256
implicit none
integer, parameter :: NMOD = 2019
integer(8) :: l,r
integer(8) :: i,j,maxj
integer(8) :: s,k

read *,l,r

if (r-l+1 >= NMOD) then
   write(*,'(a)') '0'
   stop
endif

s = mod(l*r,NMOD)
maxj = min(r, l+NMOD-1)
do i = l,maxj-1
   do j = i+1, maxj
      k = mod(i*j,NMOD)
      if (k == 0) then
         write(*,'(i0)') k
         stop
      else if (k < s) then
         s = k
      endif
   enddo
enddo

write(*,'(i0)') s
end

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;
#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(A, N);
    ll result = LLONG_MAX;
    {
        ll temp = 0;
        ll sum = A[0];
        if (sum <= 0){
            temp += (1 - sum);
            sum = 1;
        }
        for (int i = 1; i < N; ++i){
            const ll next_sum = sum + A[i];
            if (sum > 0 && next_sum >= 0){
                temp += (next_sum + 1);
                sum = -1;
            }else if (sum < 0 && next_sum <= 0){
                temp += (1 - next_sum);
                sum = 1;
            }else{
                sum = next_sum;
            }
        }
        result = min(result, temp);
    }
    {
        ll temp = 0;
        ll sum = A[0];
        if (sum >= 0){
            temp += (sum + 1);
            sum = -1;
        }
        for (int i = 1; i < N; ++i){
            const ll next_sum = sum + A[i];
            if (sum > 0 && next_sum >= 0){
                temp += (next_sum + 1);
                sum = -1;
            }else if (sum < 0 && next_sum <= 0){
                temp += (1 - next_sum);
                sum = 1;
            }else{
                sum = next_sum;
            }
        }
        result = min(result, temp);
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

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

    ll now = 0;
    vl seen(N, 0);
    seen[now]++;
    vl cycle;
    ll until_roop = 0;

    while(1){
        now = A[now];
        seen[now]++;
        if(seen[now] == 2){
            break;
        }
        until_roop++;
    }
    seen.assign(N, 0);
    cycle.push_back(now);
    seen[now]++;
    while(1){
        now = A[now];
        seen[now]++;
        if(seen[now] == 2){
            break;
        }
        cycle.push_back(now);
    }
    until_roop -= cycle.size()-1;
    if(K < until_roop){
        now = 0;
        rep(i, K){
            now = A[now];
        }
        cout << now+1;
        return 0;
    }
    K -= until_roop;
    K %= cycle.size();
    ll ans = cycle[K]+1;
    // for(auto a: cycle){
    //     cout << a << " ";
    // }
    // cout << endl;
    // cout << until_roop;
    cout << ans;
}

Measured memory_bytes: 8424
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	  a -= Modulus;
	}
	return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	  a += Modulus;
	}
	a -= rhs.a;
	return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	  if (exp % 2) {
		*this *= rhs;
	  }
	  rhs *= rhs;
	  exp /= 2;
	}
	return *this;
  }
};

using mint = modint<mod>;

map<ll,ll> prime_factor(ll n){
	map<ll,ll> mp;
	for(ll i=2; i*i<=n; i++){
		while(n % i == 0){
			mp[i]++;
			n /= i;
		}
	}
	if(n != 1) mp[n] = 1;
	return mp;
}

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	map<ll,ll> mp;
	mint lc = 1;
	rep(i,n){
		auto pri = prime_factor(a[i]);
		for(auto j : pri){
			chmax(mp[j.first],j.second);
		}
	}
	for(auto i : mp) lc *= modpow(i.first,i.second,mod);
	mint ans = 0;
	rep(i,n) ans += lc/a[i];
	cout << ans.value() << endl;
}

Measured memory_bytes: 896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	fmt.Println("2018" + s[4:])
}


Measured memory_bytes: 1772
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

#define ll long long
#define pb push_back

using namespace std;


int main() {
    int n, m, k;
    cin>>n>>m>>k;
    vector<string> v;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        v.pb(s);
    }
    int a[n][m];
    memset(a,0,sizeof(a));
    int c= 0;
    bool new_got = false;
    bool got = false;
    for(int i=0;i<m;i++){
        bool flag = false;
        for(int j =0;j<n;j++){
            if(v[j][i]=='#'){
                flag = true;
                if(!got){
                new_got = true;
                got = true;
                }

                c+=1;
                break;
            }
        }
        if(flag){
            flag = false;
            for(int j=0;j<n;j++){
                //cout<<j<<' '<<flag<<' '<<c<<endl;
                if(v[j][i]=='#' && !flag){
                    flag =true;
                    a[j][i] = c;
                    continue;
                }
                if(v[j][i]=='#' && flag){
                    c+=1;
                }
                //cout<<j<<' '<<flag<<' '<<c<<endl;
                //cout<<endl;
                a[j][i] = c;
            }
        }
        else if(got){
            if(i>0){
            for(int j=0;j<n;j++){
                a[j][i] = a[j][i-1];
            }
            }
        }
        if(new_got){
            int k=i;

            //cout<<'f'<<endl;
            k--;
            while(k>=0){
                for(int j = 0;j<n;j++) a[j][k] = a[j][i];
                k--;
            }
        }
        if(new_got) new_got = false;
    }
    for(int i=0;i<n;i++){
        for(int j =0;j<m;j++){
            cout<<a[i][j]<<' ';
        }
        cout<<endl;
    }
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007

ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    ll n;
    cin>>n;
    vector<ll> v(5);
    rep(i, 0, 5)
        cin>>v[i];
    ll time = n / v[0] + (n % v[0] != 0);
    rep(i, 1, 5) {
        time = max(time, n/v[i] + (n%v[i] != 0));
    }
    cout<<time + 4<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stack>
using namespace std;
stack<int> st;
void calc(int depth,int mxdep,int prev,int& K){
  if(depth>mxdep) return;
  if(depth==1){
    for(int i=1; i<=9; i++){
      if(mxdep==depth) K--;
      else calc(depth+1,mxdep,i,K);
      if(K==0){
        st.push(i);
        return;
      }
    }
  }
  else{
    for(int i=max(0,prev-1); i<=min(9,prev+1); i++){
      if(mxdep==depth) K--;
      else calc(depth+1,mxdep,i,K);
      if(K==0){
        st.push(i);
        return;
      }
    }
  }
}
void solve(int& K){
  for(int i=1; i<=10; i++){
    calc(1,i,1,K);
    if(K==0) return;
  }
  // for(int i=1; i<=9; i++){
  //   for(int first=max(0,i-1); first<=min(9,i+1); first++){
  //
  //     for(int second=max(first-1,0); second<=min(first+1,9); second++){
  //
  //       for(int third=max(0,second-1); third<=min(9,second+1); third++){
  //
  //         for(int fourth=max(0,third-1); fourth<=min(9,third+1); fourth++){
  //           K--;
  //           if(K==0){
  //             cout<<i<<first<<second<<third<<fourth<<endl;
  //             return;
  //           }
  //         }
  //       }
  //     }
  //   }
  // }
}
int main(){
  int K;
  cin>>K;
  solve(K);
  while(!st.empty()){
    cout<<st.top();
    st.pop();
  }
  // for(int start=1; start<=5; start++){
  //   for(int a=0)
  // }
  return 0;
}


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

int a[100010],b[100010];
char c[100010];
long d[100010];
char e[100010][22];

int co(const void*p,const void*q){
	if(a[*(int*)p]<a[*(int*)q])return -1;
	if(a[*(int*)p]>a[*(int*)q])return 1;
	if(b[*(int*)p]<b[*(int*)q])return -1;
	if(b[*(int*)p]>b[*(int*)q])return 1;
	if(c[*(int*)p]<c[*(int*)q])return -1;
	if(c[*(int*)p]>c[*(int*)q])return 1;
	if(d[*(int*)p]<d[*(int*)q])return -1;
	if(d[*(int*)p]>d[*(int*)q])return 1;
	return strcmp(e[*(int*)p],e[*(int*)q]);
}
int idx[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d %c%ld%s",a+i,b+i,c+i,d+i,e[i]);
	for(int i=0;i<n;i++)idx[i]=i;
	qsort(idx,n,sizeof(int),co);
	for(int i=0;i<n;i++)printf("%d %d %c %ld %s\n",a[idx[i]],b[idx[i]],c[idx[i]],d[idx[i]],e[idx[i]]);
}


Measured memory_bytes: 6188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll h,w;
  cin>>h>>w;
  if(h!=1&&w!=1)
  {
    cout<<(h*w+1)/2<<endl;
    return 0;
  }
  cout<<1;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
        if (x > y)
                return gcd(y,x);
        if (x == 0)
                return y;
        return gcd(y%x,x);
}

int main() {
        ll N,M;
        string S,T;
        cin >> N >> M >> S >> T;
        ll g = gcd(N,M);

        for (ll x=0; x*N/g < N && x*M/g < M; x++) {
                if (S[x*N/g] != T[x*M/g]) {
                        cout << "-1\n";
                        return 0;
                }
        }

        cout << N*M/g << "\n";
        return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    try {
      Scanner sc = new Scanner(System.in);
      String s = sc.nextLine();
      if (s.endsWith("s")) {
        System.out.println(s + "es");
      } else {
        System.out.println(s + "s");
      }
      sc.close();


    } catch(Exception e) {
      System.out.println(e);
      System.out.println(e.getStackTrace());
    }
  }

}

Measured memory_bytes: 26852
from fractions import gcd


def lcm(x, y):
    return x // gcd(x, y) * y


def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a % b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, y, _ = extgcd(a, m)
    return (m + x % m) % m


N = int(input())
A = list(map(int, input().split()))
_lcm = 1
for a in A:
    _lcm = lcm(_lcm, a)
ans = 0
big = 1000000007
_lcm %= big
for a in A:
    ans += _lcm * mod_inverse(a, big)
print(ans % big)

Measured memory_bytes: 6100
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		int i = 1;
		while(true){
			if(Math.Pow(i+1,2) <= N){
				i += 1;
			} else {
				break;
			}
		}
		Console.WriteLine(Math.Pow(i, 2));
	}
}

Measured memory_bytes: 13140
D, G = map(int, input().split())
questions = []
for a in range(D):
    question = []
    p, c = input().split()
    question.append(int(p))
    question.append(int(c))
    questions.append(question)
numbers = []
S=[i for i in range(D)]
T=tuple(S)
for i in range(2 ** D):
    number = []
    for j in range(D):
        if ((i >> j) & 1):
            number.append(j)
    numbers.append(number)
del numbers[0]
answers=[]
for a in range(1, questions[D - 1][0]):
    b = D * 100 * a
    if G <= b:
        answers.append(a)
for a in numbers:
    goukei = 0
    suuji=0
    for b in a:
        goukei+=questions[b][0]*(b+1)*100+questions[b][1]
        suuji+=questions[b][0]
    if goukei>=G:
        answers.append(suuji)
    else:
        U = list(T)
        for c in range(len(a)):
            if a[c] in U:
                U.remove(a[c])
        saidai = max(U)
        rest=G-goukei
        kaisuu=rest//((saidai+1)*100)
        if kaisuu<questions[saidai][0]:
            answers.append(suuji+kaisuu)
print(min(answers))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ );
using namespace std;
const long long mod = 1000000007;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long n;
  cin >> n;
  long long sum = 0;
  vector<long long> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a.at(i);
    sum += a.at(i);
    sum %= mod;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    sum -= a.at(i);
    if (sum < 0) sum += mod;
    long long num  = (a.at(i)*sum)%mod;
    num %= mod;
    ans += num;
    ans %= mod;
  }
  ans %= mod;
  cout << ans << endl;
}

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

using namespace std;

int main() {
	int s;
	cin >> s;
	int m1, y1;
	y1 = s / 100; // YYMM
	m1 = s % 100; // YYMM

	if (0 < m1 && m1 < 13) {
		if (0 < y1 && y1 < 13) { // m1もy1も1~12
			cout << "AMBIGUOUS" << endl;
		}
		else { // m1だけ1~12
			cout << "YYMM" << endl;
		}
	}
	else if (0 < y1 && y1 < 13) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A, P;
    cin >> A >> P;
    Int allP = A*3 + P;
    Int ans = allP/2;

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

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

int main(){
    int S,h,m,s,hn;
    cin >> S;
    hn = S%3600;
    h = S/3600;
    m = hn/60;
    s = hn%60;
    cout << h <<":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        int a=sc.nextInt()+sc.nextInt()-sc.nextInt()-sc.nextInt();
        if(a>0){
            System.out.println("Left");
        }else if(a<0){
            System.out.println("Right");
        }else{
            System.out.println("Balanced");
        }
    }
}


Measured memory_bytes: 23636
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#scipy.sparse import csr_matrix
#scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N,K=map(int,input().split())
    ans=0
    for i in range(K+1,N+1):
        ans+=(N//i)*(i-K)+max((N%i-max(K,1)+1),0)
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 39024