akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 2e5 + 5; 
vii g[N]; 
bool vis[N];
int cnt;

void dfs(int node) {
	if(vis[node]) return ;
	vis[node] =1 ; 
	++cnt ; 

	for(auto i : g[node]) {
		if(not vis[i]) {
			dfs(i) ;
		}
	}
} 

void solve(int test) {
	
	int n, m; cin >> n>> m ;
	rep(i,0,m) {
		int u,v; cin >> u >> v;
		g[u].eb(v) ;
		g[v].eb(u) ;
	}

	int ans = 0 ; 

	rep(i,1,n+1) {
		if(not vis[i]) {
			cnt = 0 ; 
			dfs(i) ;
			ans = max(ans, cnt) ;
		}
	}

	cout << ans ; 
}

int32_t main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif   

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 20984
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int n;
ll a[200001],sum[200001];
bool test(ll d){
    rep(i,n){
        int cur=i;
        bool flag=true;
        rep(j,3){
            cur=lower_bound(sum,sum+2*n,sum[cur]+d)-sum;
            if(cur>i+n){
                flag=false;break;
            }
        }
        if(flag) return true;
    }
    return false;
}
int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        a[i+n]=a[i];
    }
    rep(i,2*n) sum[i+1]=sum[i]+a[i];
    ll lb=0,ub=100010001000000;
    while(ub-lb>1){
        ll mid=(ub+lb)/2;
        if(test(mid)) lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;
    return 0;
}


Measured memory_bytes: 6236
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        x: [u64; 3],
    }
    let mut abc = x;
    abc.sort();
    if abc[0] == 5 && abc[1] == 5 && abc[2] == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)

	min := N - 1 // (1,N)
	for i := 2; i <= int(math.Sqrt(float64(N))); i++ {
		if N%i != 0 {
			continue
		}
		j := N / i
		d := (i - 1) + (j - 1)
		if d < min {
			min = d
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int a,b,x;
cin>>a>>b>>x;
if(a>x) cout<<"NO";
if(a==x) cout<<"YES";
if(a<x){
if((a+b)>=x){
    cout<<"YES";
}
else cout<<"NO";
}

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){int n,a,b,c;scanf("%d",&n);while(n--){scanf("%d %d %d",&a,&b,&c);a*=a;b*=b;c*=c;printf("%s\n",a+b==c||b+c==a||c+a==b?"YES":"NO");}return 0;}

Measured memory_bytes: 1008
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[575575],ls[1234321],sum[1234321],sum2[1234321],cnt[1234321];

int main(void){
	int n,i,a,x=0;
	ll ans=0ll;
	cin >> n;
	fill(ls,ls+1234321,0);
	cnt[0] = 0ll;
	for(i=0; i<n; ++i){
		cnt[i+1] = cnt[i];
		cin >> a;
		x ^= a;
		if(!x){
			++cnt[i+1];
		}
		if(!ls[x]){
			dp[i] = 1ll;
			sum[x] = dp[i];
		}else if(!x){
			dp[i] = 1ll;
			add_mod(dp[i],sum[x]);
			add_mod(sum[x],dp[i]);
		}else{
			dp[i] = 1ll;
			add_mod(sum2[x],(sum[x]*(cnt[i+1]-cnt[ls[x]]))%MOD);
			add_mod(dp[i],sum2[x]);
			add_mod(sum[x],dp[i]);
		}
		ls[x] = i+1;
	}
	if(x){
		cout << dp[n-1] << endl;
	}else{
		ans = dp[n-1];
		for(i=1; i<(1<<20); ++i){
			if(ls[i]){
				add_mod(ans,sum[i]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 39168
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
const double PI=M_PI;
signed main(){
    ll ans=0;
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        if(a[i]%2==0){
            ans+=a[i]/2;
            a[i]=0;
        }else{
            if(a[i+1]>0){
                ans++;
                a[i]--;
                a[i+1]--;
            }
        }
    }
    rep(i,n){
        ans+=a[i]/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define io ios_base::sync_with_stdio(false); cin.tie(0);

#define fs first
#define sc second
#define pb push_back

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef long double ld;

const ll LINF = 1e18;
const int INF = 1e9;
const ld EPS = 1e-9;
const int MOD = 1e9+7;

/// Scanf para ler char array separado por espacos -> scanf(" %[^\n]", texto);
 
////////////////////////// Solution starts below. //////////////////////////////

void change(ll& a, ll b){
	a = max(a, b);
}

int main(){

	int n, W;
	scanf("%d %d", &n, &W);
	vll dp(W+1);
	for(int i =  0; i < n; i++){
		ll value, weight;
		scanf("%lld %lld", &weight, &value);
		for(int weight_now = W - weight; weight_now >= 0; weight_now--){
			change(dp[weight_now + weight], dp[weight_now] + value);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= W; i++){
		change(ans, dp[i]);
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 1024
N=int(input())
a=list(map(int,input().split()))



dic={0:1}
tmp=0
for i in range(N):
    tmp+=a[i]
    dic.setdefault(tmp,0)
    dic[tmp]+=1



ans=0
for i in dic:
    ans+=dic[i]*(dic[i]-1)//2

print(ans)

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

int main() {
    vector<int> ABC(3);
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(ABC.begin(), ABC.end());
    if (ABC[0] == 5 && ABC[1] == 5 && ABC[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
uses Math;
var
	a,b,x,L,R,M:real;
	i:Longint;
	flag:boolean;
begin
	read(a,b,x);
	L:=0;
	R:=PI/2;
	for i:=1 to 50 do begin
		M:=(L+R)/2;
		flag:=false;
		if a*tan(M)<=b then flag:=a*a*b-a*a*a*tan(M)/2>=x else flag:=a*b*b>=x*tan(M)*2;
		if flag then L:=M else R:=M;
	end;
	writeln(L*180/PI:0:9);
end.


Measured memory_bytes: 128
h, w = map(int, input().split())
C = [tuple(map(int, input().split())) for _ in range(10)]
A = [tuple(map(int, input().split())) for _ in range(h)]
AtoOne = [1001 for i in range(10)]

from collections import deque
q = deque([[1, 0]])

while q:
    i, cost = q.popleft()
    if AtoOne[i] > cost:
        AtoOne[i] = cost
    else:
        continue

    for j in range(10):
        if i == j:
            continue
        q.append([j, cost + C[j][i]])

counts = [0] * 10
for i in range(h):
    for j in range(w):
        a = A[i][j]
        if a > -1:
            counts[a] += 1
ans = 0 
for from_i, c in enumerate(counts):
    ans += c * AtoOne[from_i]
print(ans)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    map <int , int> a;
    int n;
    for(int i = 0; i < 3; i++){
        cin >> n;
        a[n]+=1;
    }
    n = 0;
    for(auto x : a){
        n++;
    }
    cout << n << endl;
}


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

int main(){
  
  int x,y; cin >> x >> y;
  
  if(x == 2 || y == 2){
    cout << "No" << endl;
  }
  
  else if(x == 4 || x == 6 || x == 9 || x == 11){
    if(y == 4 || y == 6 || y == 9 || y == 11){
      cout << "Yes" << endl;
    }
    
    else{
      cout << "No" << endl;
    }
  }
  
  else if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int cnt[26];
signed main(void)
{
  string s;
  cin >> s;
  for(auto c: s) cnt[c-'a']++;
  REP(i, 26) if(cnt[i] == 0) {
    cout << (char)('a'+i) << endl;
    return 0;
  }
  cout << "None" << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main(){
    ll X;
    ll ans = 0;
    cin >> X;
    while(X >= 500) {
        X -= 500;
        ans += 1000;
    }

    while(X >= 5) {
        X -= 5;
        ans += 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,m=MI()
lis=LI()
dp=[0 for i in range(n+1)]
for i in range(n):
    dp[i+1]=(dp[i]+lis[i])%m
#print(dp)
C=Counter(dp)
ans=0
for x in C.keys():
    ans+=(C[x]*(C[x]-1))//2
print(ans)

Measured memory_bytes: 59164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define int long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n+1,0);
  rep1(i,n)cin>>a[i];
  vector<vector<int>> dp(n+1,vector<int>(3,0));
  dp[0][0]=1000;
  rep1(i,n){
      dp[i][0]=max(dp[i-1][0],dp[i-1][1]+dp[i-1][2]*a[i]);
      dp[i][1]=dp[i][0]%a[i];
      dp[i][2]=dp[i][0]/a[i];
  }
  cout<<dp[n][0]<<"\n";
  return 0;
}

Measured memory_bytes: 3592
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

ll dp[4][3005][3005];
ll d[3005][3005];

void solve() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        d[r][c] = v;
    }

    rep(i, R) rep(j, C) {
        rep(k, 4) {
            if (i > 0) {
                ll v = (k < 3 ? d[i - 1][j] : 0);
                chmax(dp[0][i][j], dp[k][i - 1][j] + v);
            }
            if (j > 0) {
                chmax(dp[k][i][j], dp[k][i][j - 1]);
                if (k < 3) {
                    ll v = d[i][j - 1];
                    chmax(dp[k + 1][i][j], dp[k][i][j - 1] + v);
                }
            }
        }
    }

    ll ans = 0;
    rep(i, 4) {
        ll v = (i < 3 ? d[R - 1][C - 1] : 0);
        chmax(ans, dp[i][R - 1][C - 1] + v);
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 355540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
ll n, a[100005], ans[100005];
int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	fast;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	ans[0] = 0;
	ans[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; ++i)
	{
		ans[i] = min(abs(a[i] - a[i - 1]) + ans[i - 1], abs(a[i] - a[i - 2]) + ans[i - 2]);
	}

	cout << ans[n - 1];
	return 0;
}

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

ll A, B, C, D;

ll calc(ll N) {
    return N / C + N / D - N / (C / __gcd(C, D) * D);
}

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

    cin >> A >> B >> C >> D;
    cout << B - A + 1 - (calc(B) - calc(A - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

prob = 0
for n in range(1, N+1):
    i = 0
    while (2 ** i) * n < K:
        i += 1
    #print(n, i)
    prob_a = 1.0 / float(N) * (1 / 2**i)
    #print(prob_a)
    prob += prob_a
print(prob)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int K;
  cin >> K;
  queue<int> q;
  repp(i, 1, 9) {
    q.push(i);
  }

  K--;
  while (K-- > 0) {
    int temp = q.front();
    q.pop();
    int res = temp % 10;

    if (res != 0)
      q.push(temp * 10 + res - 1);
    q.push(temp * 10 + res);

    if (res != 9)
      q.push(temp * 10 + res + 1);
  }

  int ans = q.front();
  cout << ans << endl;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;

#[fastout]
fn main() {
    input! {
        s: String,
    }
    let c = s.chars().collect_vec();
    println!(
        "{}",
        if c[2] == c[3] && c[4] == c[5] {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2172
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

// n<b, f(b,n) = n;
// n>=b, f(b,n) = f(b, n/b) + (n mod b)
// inp n, s;
// f(b,n) = s, b=?
// b進で表したらpqで、すべての桁の和がsになる
// 10進で表したら、 nになる

ll f(ll b,ll n){
  if(n < b ) {
    return n;
  }
  else {
    return (n%b) + f(b,n/b);
  }
}

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

  
  ll n, b, s;
  cin >> n >> s; 

  
  rep(i, sqrt(n)){
    if(i == 0 || i==1) continue;
    b =  i;
    if(f(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  vector<ll> posq1;
  // q p;
  // q + p = s;
  // q * b + p = n
  // b = ((n-s) / q)+1
  // よって、bは(n-s) の約数

  // q==0の可能性もあるのでそれを先に例外処理する。
  // その場合p(s) = n , b > p
  if(s == n) {
    cout << s + 1 << endl;
    return 0;
  }

    
  
  rep(i, sqrt(n-s)+1){
    if(i == 0) continue;
    if((n-s) % i == 0){
      posq1.pb(i);
      posq1.pb((n-s)/i);
    }
  }
  

  ll ans = n+n;
  rep(i, posq1.size()){
    b = (n-s) / posq1[i] +1;
    if(b < 2) continue;
    if(f(b, n) == s)
      ans = min(ans, b);
  }

  if(ans != (n+n)) cout << ans << endl;
  else cout << "-1" << endl;


  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a[10000],i,j,n,saidai,saishou,u,q=0;
	long long goukei;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]<a[j]){
				u=a[i];
				a[i]=a[j];
				a[j]=u;
			}
		}
	}saidai=a[0];
	saishou=a[n-1];
	goukei=0;
	for(i=0;i<n;i++){
		goukei+=a[i];
	}cout<<saishou<<" "<<saidai<<" "<<goukei<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define turbo cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define inf 999999999999999

using namespace std;

int tab[3009][3009];

int main(){
    turbo
    string a = "#",b = "#",k;
    cin >> k;
    a += k;
    cin >> k;
    b += k;
    for(int i=1;i<a.size();i++){
      for(int j=1;j<b.size();j++){
        if(a[i]==b[j]){
          tab[i][j] = tab[i-1][j-1]+1;
        }
        else{
          tab[i][j] = max(tab[i-1][j],tab[i][j-1]);
        }
      }
    }
    string c;
    int x = a.size()-1,y = b.size()-1;

    while(x>0 and y>0){
      //cout << "POINT " << x << " " << y << "\n";
      if(a[x]==b[y]){
        c+=a[x];
        x--;
        y--;
      }
      else{
        if(y==0){
          x--;
          continue;
        }
        if(x==0){
          y--;
          continue;
        }
        if(tab[x-1][y] > tab[x][y-1]){
          x--;
        }
        else{
          y--;
        }
      }
    }
    reverse(c.begin(),c.end());
    cout << c << "\n";
    return 0;
}


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

int main() {
	string s;
	int Q;
	cin >> s >> Q;
	int check = 1;
	deque<char> ans;
	for (int i = 0; i < s.size(); i++) ans.push_back(s[i]);
	for (int i = 0; i < Q; i++) {
		int t;
		cin >> t;
		if (t == 1) check *= -1;
		else {
			int f;
			char c;
			cin >> f >> c;
			f = f == 1 ? 1 : -1;
			int tmp = f * check;
			if (tmp == 1) ans.push_front(c);
			else ans.push_back(c);
		}
	}
	if (check == 1) {
		for (int i = 0; i < ans.size(); i++) cout << ans[i];
		cout << endl;
	}
	else {
		for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;cin>>n;
    lint ans=0;
    vector<int> vec(n);for(int i=0;i<n;i++)cin>>vec[i];
    sort(all(vec));
    int reml=vec[0],remr=vec[0];
    int left=1,right=n-1;
    int nokori=n-1;
    bool L=false;
    while(nokori>0){
        if(nokori==1){
            if(L){
                ans+=max(abs(vec[left]-remr),abs(vec[left]-reml));
            }
            else{
                ans+=max(abs(vec[right]-remr),abs(vec[right]-reml));
            }
            nokori--;
        }
        else{
            if(L){
                ans+=abs(vec[left]-reml)+abs(vec[left+1]-remr);
                reml=vec[left];
                remr=vec[left+1];
                left+=2;
                L=false;
            }
            else{
                ans+=abs(vec[right]-reml)+abs(vec[right-1]-remr);
                reml=vec[right];
                remr=vec[right-1];
                right-=2;
                L=true;
            }
            nokori-=2;
        }
    }
    lint ans2=0;
    int reml2=vec[n-1],remr2=vec[n-1];
    int left2=0,right2=n-2;
    int nokori2=n-1;
    bool L2=true;
    while(nokori2>0){
        if(nokori2==1){
            if(L2){
                ans2+=max(abs(vec[left2]-remr2),abs(vec[left2]-reml2));
            }
            else{
                ans2+=max(abs(vec[right2]-remr2),abs(vec[right2]-reml2));
            }
            nokori2--;
        }
        else{
            if(L2){
                ans2+=abs(vec[left2]-reml2)+abs(vec[left2+1]-remr2);
                reml2=vec[left2];
                remr2=vec[left2+1];
                left2+=2;
                L2=false;
            }
            else{
                ans2+=abs(vec[right2]-reml2)+abs(vec[right2-1]-remr2);
                reml2=vec[right2];
                remr2=vec[right2-1];
                right2-=2;
                L2=true;
            }
            nokori2-=2;
        }
    }
    cout<<max(ans,ans2)<<endl;
}


Measured memory_bytes: 3804
from collections import defaultdict

N, P = map(int, input().split())
S = input()

if P == 2 or P == 5 :
  ret = 0
  for i, v in enumerate(S) :
    if int(v) % P == 0 :
      ret += i + 1
  print(ret)

else :
  mem = defaultdict(int)
  mem[0] += 1

  T = [0]
  dec = 1
  x = 0
  for s in S[::-1] :
    s = int(s)
    x = (dec * s + x) % P
    dec = dec * 10 % P
    T.append(x)
    mem[x] += 1

  ret = 0
  for i, t in enumerate(T) :
    ret += mem[t] - 1
    mem[t] -= 1
    
  print(ret)

Measured memory_bytes: 53416
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
typedef long long ll;
using namespace std;

int main(void){
    ll n,sum=0;
    cin>>n;
    vector<pair<ll,ll>>p(n);
    for(ll i=0;i<n;i++){
        cin>>p[i].second>>p[i].first;
    }
    stable_sort(p.begin(),p.end());

    for(ll i=0;i<n;i++){
        sum+=p[i].second;
        if(sum>p[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 6528
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){


int N,A,B,C,D;
string S;
cin>>N>>A>>B>>C>>D>>S;
bool judge=true;
if((B<C)&&(C<D)){
    rep4(i,A,C-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
        
    }
    rep4(i,B,D-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
    }
    if(judge)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}
else if((C<B)&&(B<D)){
    rep4(i,A,C-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
        
    }
    rep4(i,B,D-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
    }
    if(judge)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}
else{
    rep4(i,A,C-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
        
    }
    rep4(i,B,D-2){
        if((S[i-1]=='#')&&(S[i]=='#')){
            judge=false;
        }
    }
    if(!judge){
        cout<<"No"<<endl;
    return 0;
    }
    judge=false;
    rep4(i,B-1,D-1){
        if((i+2<=S.size())&&(S[i-1]=='.')&&(S[i]=='.')&&(S[i+1]=='.'))judge=true;
    }
    if(judge)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

return 0;
}

Measured memory_bytes: 3736
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int par[MAXN];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n,q;
	scanf("%d%d",&n,&q);
	while(q--){
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v)
			swap(u,v);
		par[u+1]++;par[v+1]--;
	}
	for(int i=2;i<=n;i++){
		par[i]+=par[i-1];
		if(par[i]&1){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


struct Edge{
    ll from, to, cost;
};

using Edges = vector<Edge>;
vector<bool> negative;


void bellman_ford(Edges &Es, int V, int s, vector<ll>& dis){
    dis.resize(V,LINF);
    dis[s] = 0;
    int cnt = 0;

    while(cnt < V){
        for(auto e: Es){

            if(dis[e.from] != LINF && dis[e.from]+e.cost < dis[e.to]){
                dis[e.to] = dis[e.from] + e.cost;
            }
        }
        cnt++;
    }

    negative.resize(V,false);
    cnt = 0;

    while(cnt < V){
        for(auto e: Es){

            if(dis[e.to] != LINF && dis[e.from]+e.cost < dis[e.to]){
                dis[e.to] = dis[e.from] + e.cost;
                negative[e.to] = true;
            }
            if(negative[e.from]) negative[e.to] = true;
        }
        cnt++;
    }
    return;
}

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

    vector<Edge> Es(M);

    REP(i,M){
        int a,b,c; cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        Es[i] = {a,b,-c};
    }

    vector<ll> dis(N,LINF);

    bellman_ford(Es, N, 0, dis);

    if(!negative[N-1]){
        cout << max(-dis[N-1],0ll) << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<ll>;
int main(){
   int n;
   cin >> n;
   auto c = v(n-1,0);
   auto s = v(n-1,0);
   auto f = v(n-1,0);
   for (int i = 0; i < n-1; i++)
   {
      cin >> c[i] >> s[i] >> f[i];
   }

   for (int i = 0; i < n; i++)
   {
      ll t = 0;
      for (int j = i; j < n-1; j++)
      {  
      	 if(s[j] >t) t=s[j];
         else if(t%f[j]==0);
         else t+= f[j]-t%f[j];
         t+=c[j];
      }
      cout << t << endl;
   }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main() {
    int n;
    cin >> n;
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;
    rep(i,n){
        double f;
        cin >> f;
        dp[i+1][0]=dp[i][0]*(1-f);
        rep(j,n){
            dp[i+1][j+1]=dp[i][j]*f+dp[i][j+1]*(1-f);
        }
    }
    double ans=0;
    rep(i,n/2+1) ans+=dp[n][n-i];
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int a[100005];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll count = 1;
	n = n - k;
	while (n>0) {
		n = n - (k - 1);
		count++;
	}
	cout << count << endl;
	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N+1];
        long[] B = new long[N];
        for(int n=0; n<=N; n++) A[n]=sc.nextLong();
        for(int n=0; n<N; n++) B[n]=sc.nextLong();
        long defeat = 0;
        for(int n=0; n<N; n++){
            long d1 = Math.min(A[n], B[n]);
            defeat += d1;
            A[n] -= d1;
            B[n] -= d1;

            long d2 = Math.min(A[n+1], B[n]);
            defeat += d2;
            A[n+1] -= d2;
            B[n] -= d2;
        }
        System.out.println(defeat);
    }
}

Measured memory_bytes: 92184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int ans, N, A[200001];
int a[1000001];
bool f[1000001],d[1000001];


int main()
{
    int i, j,m=0;
    cin >> N;

    rep(1,i, N+1){
        cin >>A[i];
        a[A[i]]++;
        m=max(m,A[i]);
    }
    rep(1,i,N+1){
        if (f[A[i]]||d[A[i]]) continue;
        for(j=A[i]*2;j<m+1;j+=A[i])
            f[j]=true;
        if(a[A[i]]>1) f[A[i]]=true;
        d[A[i]]=true;
    }
    
    rep(1,i, N+1)
    {
        if(!f[A[i]])ans++;
    }

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

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

int main() {
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) cin >> a[i];

vector<int> rev(n);
for(int i=0;i<n;i++) rev[a[i]-1] = i+1;
for(int i=0;i<n;i++) cout << rev[i] << endl;
return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

void merge(int[],int,int,int);
void mergesort(int[],int,int);

int count=0;

int main(){
  int i;
  int n;
  int S[500000];
  int l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  l=0;
  r=n;

  mergesort(S,l,r);
  
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count++);
  return 0;
}

void merge(int S[],int l,int m,int r){
  int i,j,k;
  int n1,n2;
  int L[500000];
  int R[500000];
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++){
    L[i]=S[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=S[m+i];
  }
  L[n1]=1000000001;
  R[n2]=1000000001;
  i = 0;
  j = 0;
  for(k=l;k<r;k++){
    count++;
    if(L[i]<=R[j]){ 
      S[k]=L[i];
      i = i+1;
    } else{
      S[k]=R[j];
      j = j+1;
    }
  }
}

void mergesort(int S[],int l,int r){
  int m;
  if(l+1 < r){
    m = (l+r)/2;
    mergesort(S,l,m);
    mergesort(S,m,r);
    merge(S,l,m,r);
  }
}

Measured memory_bytes: 4520
// AtCoder Grand Contest 017
// D - Game on Tree

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;


const int MAX_N = 100000;

int N;
vector<int> G[MAX_N];

int calc_grundy(int v = 0, int par = -1) {
    int grundy = 0;

    for (int to : G[v]) {
        if (to == par) {
            continue;
        }
        grundy ^= (calc_grundy(to, v) + 1);
    }

    return grundy;
}

int main() {

    int x, y;

    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> x >> y; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    cout << (calc_grundy() != 0 ? "Alice" : "Bob") << endl;

    return 0;

}





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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    dbg_out(T...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
    #define dbg(...) 42
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int a, b;
    cin >> a >> b;
    string s, t;
    string aa = to_string(a), bb = to_string(b);
    fr(i, 0, b) s += aa;
    fr(i, 0, a) t += bb;
    // dbg(aa, bb, s, t);
    s > t ? cout << t : cout << s;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  REP(i, 1, 10) if (n % i == 0 && n / i <= 9) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[20];
int main()
{
	cin>>a;
	int i,la=strlen(a),no=0;
	if(la%2){cout<<"No";return 0;}
	for(i=0;i<la;i++)
	{
		if(i%2)
		{
			if(a[i]=='i');
			else no=1;
		}
		else
		{
			if(a[i]=='h');
			else no=1;
		}
	}
	if(no){cout<<"No";return 0;}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {

	private static final String SPLIT_STR = " ";
	private static final String SPACE = " ";

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine();

		sc.close();

		String[] split = x.split(SPLIT_STR);

		List<Integer> list = new ArrayList<>(split.length);
		for (int i = 0; i < split.length; i++) {
			list.add(Integer.parseInt(split[i]));
		}

		Collections.sort(list);

		for (int i = 0; i < list.size() - 1; i++) {
			System.out.print(list.get(i) + SPACE);
		}
		System.out.println(list.get(list.size() - 1));
	}
}



Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(s[i] != s[n-1-i]) ans++;
		//cout << s[i] << " " << s[n-1-i] << "\n";
	}
	ans /= 2;
	cout << ans;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,m;
vector<int> v[100010];
int a[100010];


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

  return a[x] = root(a[x]);
}


void unite(int x,int y){
  x = root(x);
  y = root(y);
  if(x==y) return;
  a[x]=a[y];
}

bool find(){
  FOR(i,1,n){
    if(root(i)!=root(i+1)) return false;
  }

  return true;
}

int main(){
  cin>>n>>m;
  rep(i,n+1){
    a[i]=i;
  }
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int l;
      cin>>l;
      v[l].push_back(i+1);
    }
  }
  rep(i,m+1){
    rep(j,v[i].size()-1){
      if(v[i].size()==0) break;
      int x=v[i][j],y=v[i][j+1];
      unite(x,y);
    }
  }

  if(!find()){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }

  return 0;
}


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

typedef long long LL;
const int M=2e5+5;

int vis[M];
int a[M];

vector<int> step;

int main()
{
	int n; LL k;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int u=1;
	memset(vis,-1,sizeof(vis));
	vis[u]=0;
	step.push_back(u);
	int st=-1;
	while(1)
	{
		u=a[u];
		if(vis[u]!=-1)
		{
			st=vis[u];
			break;
		}
		vis[u]=step.size();
		step.push_back(u);
	}
	if(k<step.size())
		printf("%d\n",step[k]);
	else
	{
		k-=step.size();
		k%=(step.size()-st);
		printf("%d\n",step[k+st]);
	}
	return 0;
}

Measured memory_bytes: 5912
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
t=10**6
index=1

for i in range(N):
    if t>abs(A-(T-(H[i]*0.006))):
        t=abs(A-(T-0.006*H[i]))
        index=i+1

print(index)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;

long long int h,w,dp[1200][1200]={};
string str[2000];


int main() {
    int count=0;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>str[i];
        str[i].push_back('#');
    }
    for(int i=0;i<=w;i++){
        str[h].push_back('#');
    }
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str[i][j+1]=='.'){
                dp[i][j+1]+=dp[i][j];
                dp[i][j+1]%=mod;
            }
            if(str[i+1][j]=='.'){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=mod;
            }
        }
    }
    cout<<dp[h-1][w-1];
} 


Measured memory_bytes: 11520
#include <iostream>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=1; i<n-1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]){
            ans++;
        }else if(p[i-1] > p[i] && p[i] > p[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define ilog2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}



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

	ll a, b, n;cin>>a>>b>>n;
	cout << (a*min(n, b-1))/b - a*(min(n, b-1)/b) << endl;

	return 0;
}


Measured memory_bytes: 3656