akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
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;}
const int INF = 1<<30;
const ll LINF = 1LL<<61;

int main()
{
    ll h, w, m;
    cin >> h >> w >> m;
    V<P> item(m);
    rep(i,m) cin >> item[i].first >> item[i].second;
    rep(i,m) item[i].first--, item[i].second--;
    V r(h), c(w);
    rep(i,m) r[item[i].first]++, c[item[i].second]++;

    int rmax = 0, cmax = 0;
    rep(i,h) chmax(rmax, r[i]);
    rep(i,w) chmax(cmax, c[i]);

    ll rcnt = 0, ccnt = 0;
    rep(i,h) if(r[i] == rmax) rcnt++;
    rep(i,w) if(c[i] == cmax) ccnt++;
    ll cnt = rcnt * ccnt;
    rep(i,m) if(r[item[i].first] == rmax && c[item[i].second] == cmax) cnt--;

    int ans = rmax + cmax;
    if(cnt <= 0) ans--;
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n; //4
  long long d; //5
  cin >> d;
  
  int wievielmal = 0;
  for (int i = 0; i<n; i++) {
    // X, Y einlesen (das wird wiederholt!)
    long long x;
    long long y;
    cin >> x;
    cin >> y;
    if (x*x + y*y <= d*d) {
      wievielmal++;
    }
  }
  cout << wievielmal << endl;
	return 0;
}


Measured memory_bytes: 3600
import sys
m, d = map(int, input().split())

if d < 22 or m < 4:
    print(0)
    sys.exit()

ans = 0
for i in range(4, m+1):
    for j in range(22, d+1):
        d_0 = j % 10
        d_10 = j // 10
        if d_0 == 1 or d_10 == 1:
            continue
        if d_0 * d_10 == i:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n;cin >>n;
    ll sum=0;
    ll c=n;
    while(c>0){
        sum+=c%10;
        c/=10;
    }
    if(n%sum==0)puts("Yes");
    else puts("No");
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MOD 1000000007
#define INF 1000000000

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

  for(int i=0;i<K;i++){
    if(A>=B){
      B*=2;
    }else{
      C*=2;
    }
  }

  if(A<B&&B<C){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main() {
  int N,i,a,b,j;
  cin >> N;
  string S;
  cin >> S;
  a = 0;
  for(i=1;i<N;i++){
    if(S.at(i) == 'E') a++;
  }
  b=a;
  for(i=1;i<N;i++){
    if(S.at(i-1) =='W') a++;
    if(S.at(i) =='E') a--;
    if(b > a) b=a;
  }
  cout << b << endl;
}



Measured memory_bytes: 900
import math
A,B = map(int, input().split())

# 最大公約数の算出
y = max(A,B)
x = min(A,B)
while y%x != 0:
  tmp = x
  x = y%x
  y = tmp

# 素因数分解
p = []
tmp = int(math.sqrt(x))+1
for n in range(2,tmp):
  while x % n == 0:
    x /= n
    p.append(n)
p.append(int(x))
p.append(1)
p = list(set(p))
print(len(p))
  
  


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


public class C
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		int D = Int32.Parse(args[3]);
		int E = Int32.Parse(args[4]);
		int F = Int32.Parse(args[5]);

		int optSugarWater = 0;
		int optSugar = 0;
		double optDencity = 0;
		for(int i = 0; i <= F/(100 * A); i++)
		{
			int binRest1 = F - i * 100 * A;
			for(int j = 0; j <= binRest1/(100 * B); j++)
			{
				int binRest2 = binRest1 - j * 100 * B;
				int sugarRest1 = (i * A + j * B) * E;
				for(int k = 0; k <= Math.Min(binRest2, sugarRest1)/C; k++)
				{
					int binRest3 = binRest2 - k * C;
					int sugarRest2 = sugarRest1 - k * C;
					for(int l = 0; l <= Math.Min(binRest3, sugarRest2)/D; l++)
					{
						if(i + j + k + l == 0)
							continue;

						double water = 100 * (i * A + j * B);
						double sugar = k * C + l * D;
						double dencity = sugar/(sugar + water);
						if(dencity > optDencity)
						{
							optDencity = dencity;
							optSugarWater = (int)(sugar + water);
							optSugar = (int)sugar;
						}
					}
				}
			}
		}
		
		if(optDencity == 0)
		{
			Console.WriteLine("600 0");
		}
		else
		{
			Console.WriteLine("{0} {1}", optSugarWater, optSugar);
		}
	}
}





Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#define N 1000

int main()
{
  int A[N],i,j,k,v,n;

  scanf("%d",&n);
  if(n<1 || n>100) exit(2);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

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

  for(k=1; k<n; k++){
    
    v = A[k];
    j = k-1;
    
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }    
    for(i=0; i<n-1; i++){
      printf("%d ",A[i]);
    }
    printf("%d",A[n-1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

void solve(){
    map <string,int> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mf=0;
    for(auto &x:mp)
        mf=max(mf,x.second);
    for(auto &x:mp)
        if(x.second==mf)
            cout<<x.first<<"\n";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++)
    cin>>a[i];
  
  int dp[n];
  memset(dp, 0, sizeof(dp));
  dp[1] = abs(a[1] - a[0]);
  
  for(int i=2; i<n; i++){
    dp[i] = min(abs(a[i] - a[i-1]) + dp[i-1], abs(a[i] - a[i-2]) + dp[i-2]);
  }
  
  cout<<dp[n-1];
  
}

Measured memory_bytes: 4324
# Problem B - Picture Frame

# input
H, W = map(int, input().split())
a_list = [['']*W for i in range(H)]
for i in range(H):
    a_nums = list(input())
    for j in range(W):
        a_list[i][j] = a_nums[j]

# output
ans = "#"*(W+2)
ans += "\n"
for i in range(H):
    ans += "#"
    for j in range(W):
        ans += a_list[i][j]
    ans += "#\n"
ans += "#"*(W+2)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    bool maki[n];
    memset(maki,0,sizeof(maki));
    ll num[n];
    memset(num,0,sizeof(num));
    string s;
    ll a;
    for(int i=0;i<m;i++){
        cin>>a>>s;
        a--;
        if(s=="AC")maki[a]=true;
        else if(maki[a]==0)num[a]++;
    }
    ll ans=0,sum=0;
    for(int i=0;i<n;i++){
        if(maki[i]){
            ans++;
            sum+=num[i];
        }
    }
cout << ans<<" "<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1280
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,M;
	cin >> N>>M;
	
	// 解法
	if (N>1 & M>1) cout << (N-2)*(M-2) << endl;
	else if (N>1) cout << N-2 << endl;
	else if (M>1) cout << M-2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i, x;
	cin >> n;
	int ind[n];
	int b[n], c[n];
	int ans = 0;
	fo(i, 0, n)
	cin >> ind[i];
	fo(i, 0, n)
	cin >> b[i];
	fo(i, 0, n - 1)
	cin >> c[i];
	fo(i, 0, n - 1){
		if(ind[i] + 1 == ind[i + 1])
		ans += c[ind[i] - 1];
	}
	
	fo(i, 0, n)
	ans += b[i];
	
	cout << ans;
}


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	char c;
	cin>>c;
	if(c<='Z'&&c>='A'){
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
	}
	return 0;
}


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

#define MAX(a, b)	((a) > (b) ? (a) : (b))
#define MIN(a, b)	((a) < (b) ? (a) : (b))
#define ABS(a)		((a) < (0) ? (-(a)) : (a))

void setIO(const char * in = NULL, const char * out = NULL);

int ord[100009];
int A[100009];
int rs[100009];

int main(){
	
	//setIO("file");
	
	int N;	scanf("%d", &N);
	
	for(int i = 1; i <= N; ++i){
		scanf("%d", &A[i]);
	}
	
	ord[1] = 3;
	rs[1] = 1;
	
	for(int i = 2; i <= N; ++i){
		if(ord[i - 1] == 1){
			if(A[i - 1] <= A[i]){
				ord[i] = 1;
				rs[i] = rs[i - 1];
			}else{
				ord[i] = 3;
				rs[i] = rs[i - 1] + 1;
			}
			
		}else if(ord[i - 1] == 2){
			if(A[i - 1] >= A[i]){
				ord[i] = 2;
				rs[i] = rs[i - 1];
			}else{
				ord[i] = 3;
				rs[i] = rs[i - 1] + 1;
			}
		}else{
			
			if(A[i - 1] < A[i])
				ord[i] = 1;
			else if(A[i - 1] > A[i])
				ord[i] = 2;
			else
				ord[i] = 3;
				
			rs[i] = rs[i - 1];
		}
	}
	
	printf("%d", rs[N]);
		
return 0;	
}

void setIO(const char * in, const char * out){
	if(in != NULL)	freopen(in, "r", stdin);
	if(out != NULL)	freopen(out, "w", stdout);
}



Measured memory_bytes: 1280
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
	print('Yes')
else:
	print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    string S;
    cin >> S;
    for (int i = 0; i < 3;i++)
    {
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
#define fi first
#define se second
#define iis std::ios::sync_with_stdio(false)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MXN = 1e6 + 5;
const int MXT = 2e7 + 6;
const uLL base = 99959;

unordered_map<uLL, int> mp;
int n, m, tn;
int head[MXN], tot;
struct lp {
    int v, c, nex;
}cw[MXT];
int dis[MXT], vis[MXT], fa[MXN];
void add_edge(int u,int v,int w) {
    cw[++tot].v = v;cw[tot].c = w;cw[tot].nex = head[u];
    head[u] = tot;
    cw[++tot].v = u;cw[tot].c = w;cw[tot].nex = head[v];
    head[v] = tot;
}
void dij() {
    priority_queue<pii,vector<pii>,greater<pii> >Q;
    for(int i = 1; i <= n; ++i) dis[i] = INF, vis[i] = 0;
    dis[1] = 0;
    Q.push({dis[1], 1});
    while(!Q.empty()) {
        pii now = Q.top();Q.pop();
        int u = now.se;
        if(vis[u]) continue;
        vis[u] = 1;
        for(int i = head[u]; ~i; i = cw[i].nex) {
            int v = cw[i].v;
            //if(vis[v]) continue;
            if(dis[v] > dis[u] + cw[i].c) {
                dis[v] = dis[u] + cw[i].c;
                Q.push({dis[v], v});
            }
        }
    }
    int ans = dis[tn];
    while(!Q.empty()) Q.pop();
    if(ans == INF) ans = -2;
    printf("%d\n", ans/2);
}
int Fi(int x) {
    return fa[x] == x? x: fa[x] = Fi(fa[x]);
}
int get(int x, int y) {
    uLL tmp = x;
    tmp = tmp * base * base + y * base + x ^ y;
    if(mp[tmp]) return mp[tmp];
    mp[tmp] = ++n;
    return n;
}
int main(int argc, char const *argv[]) {
    while(~scanf("%d%d", &n, &m)) {
        memset(head, -1, sizeof(head));
        tot = -1;
        mp.clear();
        tn = n;
        for(int i = 1; i <= n; ++i) fa[i] = i;
        for(int i = 0, u, v, c, pa, pb, uc, vc; i < m; ++i) {
            scanf("%d%d%d", &u, &v, &c);
            pa = Fi(u), pb = Fi(v);
            fa[pa] = pb;
            uc = get(u, c); vc = get(v, c);
            add_edge(u,uc,1);add_edge(uc,vc,0);add_edge(vc,v,1);
        }
        if(Fi(tn) != Fi(1)){
            printf("-1\n");
            continue;
        }
        dij();
    }
    return 0;
}


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

using namespace std;

const int MAX_N = 100;
int N, K;
int X[MAX_N];

int main(){
    scanf("%d", &N);
    scanf("%d", &K);
    for(int i = 0; i < N; ++i)
        scanf("%d", X + i);
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int tmp = min(X[i], K - X[i]);
        ans += tmp;
    }
    printf("%d\n", ans * 2);
    return 0;
}

Measured memory_bytes: 3816
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		cout<<'x';
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        while(true) {
            String line = sc.nextLine();
            int x = Integer.parseInt(line);
            if(x == 0) {
                break;
            }
            list.add(x);
        }
        for(int i = 0; i < list.size(); i++) {
            System.out.println("Case " + (i + 1) + ": " + list.get(i));
        }
         
    }
 } 


Measured memory_bytes: 60860
#include <iostream>
int main(){
  int n,m,x,y,t,mx=-100,my=100;
  std::cin>>n>>m>>x>>y;
  for(int i=0;i<n;++i){std::cin>>t;mx=(t>mx?t:mx);}
  for(int i=0;i<m;++i){std::cin>>t;my=(t<my?t:my);}
  std::cout << (mx<my&&my>x&&mx<y?"No War":"War") << "\n";
}
  

Measured memory_bytes: 256
//Prime Numbers
#include <iostream>
#include <cmath>

using namespace std;

bool isPrimeNumber(int n) {
    bool prime = true;
    for(int i = 2; i <= sqrt(n); i++) {
        if(n % i == 0) {
            prime = false;
            break;
        }
    }
    return prime;
}

int main() {
    int N, n, cnt = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> n;
        if(isPrimeNumber(n)) cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3060
from math import floor, sqrt

n = int(input())
n_root = floor(sqrt(n))

result = 10000000000
for a in range(1, n_root + 1):
    if not n % a == 0:
        continue
    b = int(n / a)
    digit_a = len(str(a))
    digit_b = len(str(b))
    tmp = max(digit_a, digit_b)
    result = min(tmp, result)

print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int N;
    int M;

    cin >> N >> M;

    VI preV(N, -1);
    VVI adja(N);

    for (int i = 0; i < M; ++i) {
        int f;
        int t;
        cin >> f >> t;
        --f;
        --t;

        adja[f].push_back(t);
        adja[t].push_back(f);
    }

    deque <int> que;
    const int source = 0;
    int reachable = 0;

    que.emplace_back(source);

    while (!que.empty()) {
        int now = que.front();
        que.pop_front();
        ++reachable;

        for (int i = 0; i < adja[now].size(); ++i) {
            int nextv = adja[now][i];

            if (preV[nextv] == -1 && nextv != source) {
                preV[nextv] = now;
                que.push_back(nextv);
            }
        }
    }

    if (reachable == N) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; ++i) {
            cout << preV[i] + 1 << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 10204
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}

ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1

print(ans)

Measured memory_bytes: 3064
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
动规顺序错，爆零两行泪。
大于少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int now=1,ans=0;
	while(now<b)ans++,now+=-1+a;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum P = 10L^^9+7;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    long[] ps, ms;
    bool has_zero;
    foreach (a; readln.split.to!(long[])) {
        if (a == 0) has_zero = true;
        if (a < 0) {
            ms ~= -a;
        } else if (a > 0) {
            ps ~= a;
        }
    }
    if (ms.length + ps.length < K) {
        writeln(0);
        return;
    }
    sort!"a > b"(ps);
    sort!"a > b"(ms);

    if (ms.length == 0) {
        long r = 1;
        foreach (p; ps[0..K]) (r *= p) %= P;
        writeln(r);
        return;
    } else if (ps.length == 0) {
        long r = 1;
        if (K%2 == 0) {
            foreach (m; ms[0..K]) (r *= m) %= P;
            writeln(r);
        } else {
            if (has_zero) {
                writeln(0);
            } else {
                ms.reverse();
                foreach (m; ms[0..K]) (r *= m) %= P;
                writeln(P - r);
            }
        }
        return;
    }

    if (ps.length + ms.length == K) {
        long r = 1;
        foreach (p; ps) (r *= p) %= P;
        foreach (m; ms) (r *= m) %= P;
        if (ms.length%2 == 0) {
            writeln(r);
        } else {
            writeln(has_zero ? 0 : P - r);
        }
        return;
    }

    long p_max = 1;
    auto k = K;
    size_t i, j;
    while (k > 0) {
        if (k >= 2 && j+1 < ms.length && (i == ps.length || i+1 == ps.length || ps[i] * ps[i+1] < ms[j] * ms[j+1])) {
            (p_max *= ms[j++]) %= P;
            (p_max *= ms[j++]) %= P;
            k -= 2;
        } else {
            (p_max *= ps[i++]) %= P;
            k -= 1;
        }
    }
    writeln(p_max);
}

Measured memory_bytes: 14540
using System;

public class ITP1_2_C
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        string[] str = Console.ReadLine().Split(' ');
        int[] nums = new int[str.Length];

        for (int i = 0; i < str.Length; i++)
        {
            nums[i] = int.Parse(str[i]);
        }

        Solve(nums);
    }

    private static void Solve(int[] nums)
    {
        BubbleSort(nums);

        for (int i = 0; i < nums.Length; i++)
        {
            Console.Write("{0:d}", nums[i]);
            if (i < nums.Length - 1)
            {
                Console.Write(" ", nums[i]);
            }
        }
        Console.WriteLine("");
    }

    private static void BubbleSort(int[] nums)
    {
        for (int i = 0; i < nums.Length; i++)
        {
            for (int j = i + 1; j < nums.Length; j++)
            {
                if (nums[i] > nums[j])
                {
                    var tmp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = tmp;
                }
            }
        }
    }
}



Measured memory_bytes: 17952
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>
#include <cctype>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;


void testcase() {
	string s; cin >> s;
	char a = s.at(0);
	char a1 = tolower(a);
	if (a == a1) {
		cout << "a";
	}
	else {
		cout << "A";
	}


}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    swap(h,w);
    vector<int> c(h+2);
    vector<set<int> > st(h+2);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        st[y].insert(x);
    }
    c[1] = 1;
    for(int i=2;i<=h;i++){
        int t = c[i-1]+1;
        if(st[i].size()!=0){
            auto p = st[i].lower_bound(t);
            if(p==st[i].end()){
                c[i] = t;
                if(c[i]==w){
                    break;
                }
            }
            if((*p)!=t){
                c[i] = t;
                if(c[i]==w){
                    break;
                }
            }else{
                t++;
                while(1){
                    p++;
                    if(p!=st[i].end()){
                        if(*p!=t){
                            c[i] = t;
                            break;
                        }
                    }else{
                        c[i] = t;
                        break;
                    }
                    t++;
                }
                if(c[i]==w){
                    break;
                }
            }
        }else{
            c[i] = t;
            if(c[i]==w){
                break;
            }
        }
    }
    //rep(i,h)cout << c[i+1] << endl;
    int ans = 10000000;
    for(int i=1;i<=h;i++){
        if(c[i]==0)break;
        if(st[i].size()==0){
            ans = min(ans,w);
        }else{
            auto p = st[i].lower_bound(c[i]);
            if(p==st[i].end()){
                ans = min(ans,w);
            }else{
                //cerr <<c[i] << " " << *p << endl;
                ans = min(ans,(*p)-1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a * c < b)
	{
		cout << c << endl;
	}
	else
	{
		cout << b/a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
s = gets.strip.split('')

left = s.count '('
right = s.count ')'

if left > right
  s += [')'] * (left - right)
elsif left < right
  s = ['('] * (right - left) + s
end

bra = 0
ket = 0
s.each do |x|
  if x == '('
    bra += 1
  else
    if bra > 0
      bra -= 1
    else
      ket += 1
    end
  end
end
s = ['('] * bra + s + [')'] * bra
puts s.join

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    total = 0
    for s in S:
        if s == '?':
            total += 1
    tri = [1]
    for i in range(1, total + 1):
        tri.append(tri[i - 1] * 3 % MOD)
    n = len(S)
    dp = [[0] * 4 for _ in range(n + 1)]
    cnt = 0
    for i in range(n):
        s = S[i]
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
        dp[i + 1][2] = dp[i][2]
        dp[i + 1][3] = dp[i][3]
        if s == '?':
            dp[i + 1][1] = dp[i][1] + 1
            dp[i + 1][2] = (dp[i][2] * 3 + dp[i][0] * tri[cnt] + dp[i][1] * tri[cnt - 1]) % MOD
            dp[i + 1][3] = (dp[i][3] + dp[i][2] * tri[total - cnt - 1]) % MOD
            cnt += 1
        elif s == 'A':
            dp[i + 1][0] = dp[i][0] + 1
        elif s == 'B':
            dp[i + 1][2] = (dp[i][2] + dp[i][0] * tri[cnt] + dp[i][1] * tri[cnt - 1]) % MOD
        elif s == 'C':
            dp[i + 1][3] = (dp[i][3] + dp[i][2] * tri[total - cnt]) % MOD
    #print(dp)
    ret = dp[n][3] % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28484
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int> pii;
typedef pair < ll, ll> pll;
typedef pair < double, double > pdd;
typedef pdd pt;
typedef vector < int > vi;

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 19;
const int OFF = (1 << LOG);

int n, mx[OFF], sol[OFF], a[OFF];

int main(){
    scanf("%d", &n);
    for(int i = 0;i<(1 << n);i++){
        scanf("%d", &a[i]);
        int x = i ^ ((1 << n) - 1);
        for(int y = x;y > 0; y = (y - 1) & x){
            sol[y ^ ((1 << n) - 1)] = max(sol[y ^ ((1 << n) - 1)], mx[y ^ ((1 << n) - 1)] + a[i]);
            mx[y ^ ((1 << n) - 1)] = max(mx[y ^ ((1 << n) - 1)], a[i]);
        }
        sol[((1 << n) - 1)] = max(sol[((1 << n) - 1)], mx[((1 << n) - 1)] + a[i]);
        mx[((1 << n) - 1)] = max(mx[((1 << n) - 1)], a[i]);

    }
    for(int i = 1;i<(1 << n);i++){
        sol[i] = max(sol[i], sol[i - 1]);
        printf("%d\n", sol[i]);
    }
    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int  N;
  int ans = 0;
  int sum=0;

  cin >> N;

  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  for(int i = 0; i < N-1; i++){
    sum += L[i];
  }
  if(L[N-1] < sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


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

int main(){
    int n,t,x,h;
    double ans=0.0;
    cin>>n>>t;
    while(n--){
        cin>>x>>h;
        ans=max(ans,(double)t*(double)h/(double)x);
    }
    printf("%.6lf\n",ans);
}


Measured memory_bytes: 3196
from bisect import bisect_left

n = int(input())
a = []
for _ in range(n):
    a += [int(input())]

def lis(A):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            L.append(a)
        else:
            L[bisect_left(L,a)] = a
    return len(L)
print(lis(a))


Measured memory_bytes: 11132
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int M;
  cin >> M;
  cout << 48 - M << endl;
  // cout << "12月30日の" << M << "時から次の年になるまでは" << 24 - M << "時間です。" << endl;
}

Measured memory_bytes: 3616
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 10:58:30

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t/a)*b << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589

using namespace std;
       
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
       
/* 
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
       
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
       
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
       
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
       
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
       
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("circlecover.in", "r", stdin);
    //freopen("circlecover.out", "w", stdout);
}
const int P = 1e9 + 7;
int add(int a, int b)
{
    return a + b >= P ? a + b - P : a + b;
}
int mul(int a, int b)
{
    return (a * b) % P;
}
int bpow(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}
int rev(int x)
{
    return bpow(x, P - 2);
}
int sub(int a, int b)
{
    return a - b >= 0 ? a - b : (a - b + P * P) % P;
}
struct comb
{
    vector <int> fact, revf;
    int N;
    comb() {}
    comb(int _n)
    {
        N = _n;
        fact.resize(N + 1, 1);
        revf.resize(N + 1, 1);
        for (int i = 1; i <= N; ++i)
            fact[i] = mul(fact[i - 1], i), revf[i] = mul(revf[i - 1], rev(i));
    }
    int operator () (int n, int k)
    {
        return mul(fact[n], mul(revf[k], revf[n - k]));
    }
};
signed main()
{
    Start();
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    cin >> a;
    sort(all(a));
    comb c(n + 5);
    int ans = 0;
    for (int i = 0; i < n - k + 1; ++i)
    {
        ans = add(ans, mul(a[i] + P, c(n - i - 1, k - 1)));
    }
    ans = mul(ans, P - 1);
    for (int i = k - 1; i < n; ++i)
    {
        ans = add(ans, mul(a[i] + P, c(i, k - 1)));
    }
    cout << ans;
    return 0;
}



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

namespace testcs
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            ulong ans;
            n = int.Parse(Console.ReadLine());
            ans = calc(n);
            Console.WriteLine(ans);
        }
        static ulong calc(int n)
        {
            ulong ans;
            ulong[] data = new ulong[100];
            data[0] = 2;
            data[1] = 1;
            for(int i = 2; i <= n; i++)
            {
                data[i] = data[i - 1] + data[i - 2];
            }
            ans = data[n];
            return ans;
        }
    }
}


Measured memory_bytes: 13140
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<long double, string>> p(n);
    for(auto &x : p){
        cin >> x.first >> x.second;
    }
    long double ans = 0.;
    for(auto &x : p){
        ans += (x.second == "JPY")? x.first : (x.first * 380000); 
    }
    cout << setprecision(16) << ans;
    return 0;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

myRead :: [String] -> [[Int]]
myRead = map (map (read :: String -> Int) . words)

matMul' :: [Int] -> [Int] -> Int
matMul' [] _          = 0
matMul' _ []          = 0
matMul' (a:as) (b:bs) = a * b + matMul' as bs

matMul :: [Int] -> [[Int]] -> [Int]
matMul _ []      = []
matMul as (b:bs) = matMul' as b : matMul as bs

solver' :: [[Int]] -> [[Int]] -> [[Int]]
solver' [] _      = []
solver' (a:as) bs = matMul a (transpose bs) : solver' as bs

solver :: [[Int]] -> [[Int]] -> [String]
solver matA matB =
  let matC = solver' matA matB
--  in map unwords (map (map show) matC)
  in map (unwords . map show) matC


main :: IO()
main = do
  (n:m:_) <- map (read :: String -> Int) . words <$> getLine
  matA <- myRead <$> replicateM n getLine
  matB <- myRead <$> replicateM m getLine
  mapM_ putStrLn $ solver matA matB

Measured memory_bytes: 12300
def down(a,num)
  if a.include?(num)
    num -= 1;
    down(a, num)
  else
    return num
  end
end

def up(a,num)
  if a.include?(num)
    num += 1;
    up(a, num)
  else
    return num
  end
end

x, n = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
over = up(arr, x) - x
under = x - down(arr, x)

puts (over >= under) ? down(arr, x) : up(arr, x)

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

typedef vector<int> vi;

vi lis( vi arr ){
	vi seq, back(arr.size()), ans;
	for( int i = 0; i < arr.size(); i++ ){
		int res = 0, lo = 1, hi = seq.size();
		while( lo <= hi ){
			int mid = (lo+hi)/2;
			if( arr[seq[mid-1]] < arr[i] ) res = mid, lo = mid+1;
			else hi = mid-1;
		}
		if( res < seq.size() ) seq[res] = i;
		else seq.push_back( i );
		back[i] = res == 0 ? -1 : seq[res-1];
	}
	int at = seq.back();
	while( at != -1 ) ans.push_back( at ), at = back[at];
	reverse(ans.begin(), ans.end());
	return ans;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(0);
	
	int N;
	
	cin >> N;
	vi num(N);
	for( int i = 0; i < N; i++ ){
		cin >> num[i];
	}
	
	cout << lis(num).size() << '\n';
	
	
	return 0;
}


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

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };

ll n, m;
vector<vector<ll>> v;
vector<ll> ans;
bool vis[500009];

void bfs(ll n)
{
    queue<ll> q;
    vis[n] = 1;
    q.push(n);
    while (!q.empty())
    {
        ll lol = q.front();
        q.pop();
        for (int i = 0; i < v[lol].size(); i++)
        {
            ll lol1 = v[lol][i];
            if (vis[lol1] == 0)
            {
                vis[lol1] = 1;
                q.push(lol1);
            }

            if (ans[lol1] == -1)
                {
                    ans[lol1] = lol;
                }
        }
    }
}

void solve()
{
    cin >> n >> m;
    v.resize(n + 5);
    ans.resize(n + 5);
    for (int i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    for (int i = 0; i <= n; i++)
        ans[i] = -1;
    memset(vis, 0, sizeof(vis));

    ll cnt = 0;

    for (int i = 1; i <= n; i++)
    {
        if (vis[i] == 0)
        {
            bfs(i);
            cnt++;
        }
    }

    if (cnt != 1)
    {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)
    {
        cout << ans[i] << endl;
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 13376
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=300005,inf=1e8;
int n,m,a,b,ans[N],tot;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(n<a+b-1||(LL)a*b<n) {printf("-1\n");return 0;}
	for(int i=1;i<=a;i++) ans[++tot]=(n-a+i);
	m=n-a; n-=a;
	for(int i=b-2;i>=0;i--)
	{
		int k=0;
		if(i<m%(b-1))
		  k=m/(b-1)+1;
		else k=m/(b-1);
		for(int j=n-k+1;j<=n;j++)
		  ans[++tot]=j;
		//cout<<k<<endl;
		n-=k;
	}
	for(int i=1;i<=tot;i++)
	  printf("%d ",ans[i]);
	putchar('\n');
	return 0;
}
//5 6 7 8 3 4 2 1


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    ll ans = 0;
    rep(i, min(K, N))
    {
        ans += X;
    }
    rep2(i, min(K,N), N)
    {
        ans += Y;
    }
    cout << ans;
    return 0;
}

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

static char avail[2'005][2'005];
static int memo_horz[2'005][2'005];
static int memo_vert[2'005][2'005];

int main() {
    int h, w;
    cin >> h >> w;

    for (int y = 0; y < 2'005; y++) {
        for (int x = 0; x < 2'005; x++) {
            memo_horz[y][x] = -1;
            memo_vert[y][x] = -1;
        }
    }

    // assume invisible walls outside inputs

    for (int row = 1; row <= h; row++) {
        for (int col = 1; col <= w; col++) {
            char c = '#';
            cin >> c;
            if (c == '.')
                avail[row][col] = true;
        }
    }

    for (auto row = 1; row <= h; ++row) {
        for (int col = 1; col <= w; ++col) {
            if (memo_horz[row][col] >= 0)
                continue;

            int left_wall = col - 1;
            int right_wall = col;
            while (avail[row][right_wall])
                right_wall++;
            int h_lit = (right_wall - left_wall) - 1;
            for (int i = col; i < right_wall; i++)
                memo_horz[row][i] = h_lit;
        }
    }

    for (auto row = 1; row <= h; ++row) {
        for (int col = 1; col <= w; ++col) {
            if (memo_vert[row][col] >= 0)
                continue;
            int upper_wall = row - 1;
            int lower_wall = row;
            while (avail[lower_wall][col])
                lower_wall++;
            int v_lit = (lower_wall - upper_wall) - 1;
            for (int i = row; i < lower_wall; i++)
                memo_vert[i][col] = v_lit;
        }
    }

    int maxcnt = 0;

    for (int row = 1; row <= h; ++row) {
        for (int col = 1; col <= w; ++col) {
            maxcnt = max(maxcnt, memo_horz[row][col] + memo_vert[row][col] - 1);
        }
    }

    cout << maxcnt;
    return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
////////////

int const MOD = 1e9 + 7;

int mul(int a, int b) {return a * 1LL * b % MOD;}

void add(int &a, int b) {a += b; if(a>=MOD) a-= MOD;}

void solve(){
	int ans = 1;
	int p = 1;

	int n;
	scanf("%d",&n);
	fi(0, n){
		int x;
		scanf("%d",&x);
		if(x < p){ 
			ans = mul(ans, (p+1)/2);
		}else{
			p += 2;
		}
	}

	int f = 1;
	for(int i=1;i*2+1<=p;++i){
		f = mul(f, i);
	}
	ans = mul(ans, f);



	printf("%d\n",ans);
}




int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

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

int main()
{
  vector<char> ACGT = {'A', 'C', 'G', 'T'};

  string S;
  cin >> S;

  int tmpMax = 0;
  int ans = 0;

  for (int i = 0; i < S.size(); i++)
  {
    if (find(begin(ACGT), end(ACGT), S.at(i)) != end(ACGT))
    {
      tmpMax++;
      ans = max(ans, tmpMax);
    }
    else
    {
      tmpMax = 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <stdio.h>
int main(void)
{
  int n, r;
  scanf("%d", &n);
  
  for (int i = 0; i < n; i++) {
    int h;
    scanf("%d", &h);
    if (r < h)
      r = h - 1;
    else if (r == h)
      r = h;
    else {
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128