akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"strconv"
)
 
var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)
 
func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}
 
func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
 
	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}
 
func readInt() int {
	return int(readInt64())
}
 
func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}
 
func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}
 
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}
 
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}
 
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}
 
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}
 
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
 
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
 
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
 
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
 
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
 
func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}
 
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
 
func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}
 
// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64
 
// -----------------------------------------------------------------------------
 
type Job struct {
	A, B int
}
 
func main() {
	defer stdout.Flush()
	N := readInt()
	J := make([]Job, N)
	for i := range J {
		J[i].A = readInt()
		J[i].B = readInt()
	}
 
	pq := new(PriorityQueue)
	push := func(x Job) {
		heap.Push(pq, x)
	}
	pop := func() Job {
		x := heap.Pop(pq)
		return x.(Job)
	}
	empty := func() bool {
		return pq.Len() == 0
	}
 
	for _, x := range J {
		push(x)
	}
	t := 0
	for !empty() {
		j := pop()
		if j.B < t+j.A {
			println("No")
			return
		}
		t = t + j.A
	}
	println("Yes")
 
}
 
// -----------------------------------------------------------------------------
 
type PriorityQueue []Job
 
func (pq PriorityQueue) Len() int {
	return len(pq)
}
 
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].B < pq[j].B {
		return true
	} else if pq[j].B < pq[i].B {
		return false
	}
	return pq[i].A < pq[j].A
}
 
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
 
func (pq *PriorityQueue) Push(x interface{}) {
	old := *pq
	*pq = append(old, x.(Job))
}
 
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old) - 1
	x := old[n]
	*pq = old[:n]
	return x
}

Measured memory_bytes: 20608
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans_k = float("inf")
for i in range(n):
    kion = t - (h[i] * 0.006)
    if abs(ans_k - a) > abs(kion - a):
        ans_k = kion
        ans = i
print(ans + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
class node{
	public:
	int cnt;
	node* left;
	node* right;
	
	node(int cnt,node* left,node* right):
	cnt(cnt),left(left),right(right){}
	
	node* insert(int x,int l,int h);
	node* update(int ind,int l,int h);
	int query(int l,int h,int s,int e);
};
 
node* root[500005];
 
node* null=new node(0,NULL,NULL);
 
 
 
node* node::insert(int x,int l,int h)
{
    //cout<<l<<" "<<h<<"\n";
	if(x>=l and x<h)
	{
		if(l+1==h)
		return new node(1,null,null);
		
		int m=(l+h)>>1;
	
		return new node(this->cnt+1,this->left->insert(x,l,m),this->right->insert(x,m,h));
		
	}
	return this;
}
 
node* node::update(int ind,int l,int h)
{
	if(ind>=l and ind<h)
	{
		if(l+1==h){
		return new node(0,null,null);
		}
		
		int m=(l+h)>>1;
		//cout<<ind<<"Yyyyy\n";
		//this->cnt--;
		return new node((this->cnt)-1,this->left->update(ind,l,m),this->right->update(ind,m,h));
		
	}
	return this;
}
 
int node::query(int l,int h,int s,int e)
{
    //cout<<l<<" "<<h<<" "<<this->cnt<<"\n";
    
    if(l>=h)
    return 0;
    
	if(e<=l or s>=h)
	return 0;
	
	if(s<=l and e>=h)
	return this->cnt;
	
	int m=(l+h)>>1;
	
	return this->left->query(l,m,s,e)+this->right->query(m,h,s,e);
}
 
int main() {
    fastio;
	int n,q;
	cin>>n>>q;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int prev[500005];
	memset(prev,-1,sizeof(prev));
	null->left=null->right=null;
	root[0]=null->insert(0,0,n);
	prev[a[0]]=0;
	for(int i=1;i<n;i++){
	root[i]=(root[i-1])->insert(i,0,n);
	if(prev[a[i]]==-1)
	prev[a[i]]=i;
	else{
	root[i]=root[i]->update(prev[a[i]],0,n);
	prev[a[i]]=i;}
	}
	for(int i=0;i<q;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		//cout<<0<<"\n";
		cout<<root[y]->query(0,n,x,y+1)<<"\n";
	}
	return 0;
} 

Measured memory_bytes: 635604
import sys
import math

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    a, b = LI()
    print(math.ceil((b-1)/(a-1)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define N 2019

int main(void){
	std::string num;
	int ns = 0, x = 1, t = 0, ans = 0;
	std::cin >> num;
	ns = num.size();
	std::vector<int> cnt(N);

	reverse(num.begin(), num.end());
	for(int i = 0; i < ns; i++){
		cnt[t]++;
		t += x * (num[i] - '0');
		t %= N;
		ans += cnt[t];
		x = x * 10 % N;
		// std::cout << ans;
		// if(i == ns-1) cnt[t]++;
	}
	std::cout << ans << std::endl;
	/*for(int i = 0; i < N; i++)
		if(cnt[i] > 0)       
			std::cout << i << " " << cnt[i] << std::endl;
	*/
	return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define u128 __int128
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

// ll n, m, k;

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	set<char> ch;
	char c1;
	for (int i = 0; i < 4; ++i)
	{
		cin >> c1;
		ch.insert(c1);
	}
	if(ch.size() == 2)
	{
		cout << "Yes\n";
	}
	else
		cout << "No\n";
	return 0;
}

// int dpf(int last, int sum0, int sum1, int k)
// {
// 	if(k == m)
// 		return 1;
// 	for (int j = 0; j < n; ++j)
// 	{
// 		if(j != last && sum0 + vi[j] > sum1)
// 		{
// 			if(dpf(j, sum1, sum0 + vi[j], k + 1))
// 			{
// 				path[sum1] = j;
// 				return 1;
// 			}
// 		}
// 	}
// 	return 0;
// }


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int n;cin >> n;
    map<string,int> mp;
    string pre; cin >> pre;
    mp[pre]++;
    rep1(i,n){
        string s; cin >> s;
        if(mp[s] >= 1 || pre[pre.size()-1] != s[0]){
            cout << "No" << endl;
            return 0;
        }
        mp[s]++;
        pre = s;
    }
    cout << "Yes" << endl;
}

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

#define ll long long

using namespace std;

vector< vector<int> > G;
vector<int> D, P, R;

void BFS(int v) {
    queue<int> Q;
    Q.push(v);
    P[v] = -5;
    D[v] = 0;
    while(Q.size()) {
        int t = Q.front(); Q.pop();
        for(int i = 0; i < G[t].size(); i++)
            if(P[G[t][i]] == -1) {
                P[G[t][i]] = t;
                D[G[t][i]] = D[t] + 1;
                Q.push(G[t][i]);
            }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m, a, b;
    cin >> n >> m;
    G.resize(n);
    while(m--) {
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
    }
    D.resize(n);
    R.resize(n + 2);
    for(int i = 0; i < n; i++) {
        P.clear();
        P.resize(n, -1);
        BFS(i);
        for(int j = 0; j < n; j++)
            if(i != j && P[j] != -1) {
                for(int k = 0; k < G[j].size(); k++)
                    if(G[j][k] == i && R.size() > D[j] + 1) {
                        int tmp = j;
                        R.clear();
                        for(int q = 0; q < D[j] + 1; q++) {
                            R.push_back(tmp);
                            tmp = P[tmp];
                        }
                    }
            }
    }

    if(R.size() != n + 2) {
        cout << R.size() << "\n";
        for(int i = 0; i < R.size(); i++)
            cout << R[i] + 1 << "\n";
    } else {
        cout << "-1\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> fd(n + 1);
    rep(i, 0, m)
    {
        int t1, t2;
        cin >> t1 >> t2;
        fd[t1].push_back(t2);
        fd[t2].push_back(t1);
    }
    int ans = 0;
    vector<bool> checked(n + 1, 0);
    rep(i, 0, n)
    {
        if (checked[i])
            continue;
        queue<int> q;
        q.push(i);
        checked[i] = 1;
        int count = 0;
        while (!q.empty())
        {
            int cr = q.front();
            q.pop();
            count++;
            for (int x : fd[cr])
            {
                if (!checked[x])
                {
                    checked[x] = 1;
                    q.push(x);
                }
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14908
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    int X,Y;
    X=tx-sx;Y=ty-sy;
    for(int i=0;i<X;i++)cout<<"R";
    for(int i=0;i<Y;i++)cout<<"U";
    for(int i=0;i<X;i++)cout<<"L";
    for(int i=0;i<=Y;i++)cout<<"D";
    for(int i=0;i<=X;i++)cout<<"R";
    for(int i=0;i<=Y;i++)cout<<"U";
    cout<<"LU";
    for(int i=0;i<=X;i++)cout<<"L";
    for(int i=0;i<=Y;i++)cout<<"D";
    cout<<"R"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	if (s.size() >= 4 && s.substr(0, 4)=="YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    ll n;
    cin >> n;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> prime_factor;
    vector<ll> factor_dimensition;

    // factorization
    for(ll i=2; i*i<=n; i++){
        // if(is_prime(i) && n%i==0){
        //     prime_factor.push_back(i);
        //     factor_dimensition.push_back(1);
        //     n /= i;
        //     while(n%i==0){
        //         n /= i;
        //         factor_dimensition[cur]++;
        //     }
        //     cur++;
        // }
        if(n%i==0){
            ll count = 0;
            while(n%i==0){
                n /= i;
                count++;
            }
            prime_factor.push_back(i);
            factor_dimensition.push_back(count);
        }
    }
    if(n!=1){
        prime_factor.push_back(n);
        factor_dimensition.push_back(1);
    }
    

    ll ans = 0;
    // count operation possible for each prime factor
    for(ll i=0; i<prime_factor.size(); i++){
        ll count = 1;
        while((count+2)*(count+1)/2 <= factor_dimensition[i]){
            count++;
        }
        ans += count;
    }
    
    cout << ans << endl;

    return 0;
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<char> ma(n),mb(n),ans(n+n);
	REP(i,n) cin >> ma[i];
	REP(i,n) cin >> mb[i];
	REP(i,n+n){
		if(i%2==0)ans[i] = ma[i/2];
		else ans[i] = mb[i/2];
	}
	REP(i,n+n) cout << ans[i];
  cout << endl;
}


Measured memory_bytes: 3636
let () = Scanf.scanf "%d %d %d %d" @@ fun x1 y1 x2 y2 ->
  let dx, dy = x2 - x1, y2 - y1 in
  Printf.printf "%d %d %d %d\n" (x2 - dy) (y2 + dx) (x2 - dy - dx) (y2 + dx - dy)


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    string s;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
    int day;
    string S;
    cin >> S;
    
    if (S.compare("SUN") == 0) {
        day = 7;
    } else if (S.compare("MON") == 0) {
        day = 6;
    } else if (S.compare("TUE") == 0) {
        day = 5;
    } else if (S.compare("WED") == 0) {
        day = 4;
    } else if (S.compare("THU") == 0) {
        day = 3;
    } else if (S.compare("FRI") == 0) {
        day = 2;
    } else if (S.compare("SAT") == 0) {
        day = 1;
    }
    cout << day << endl;
 
    return 0;
}

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

using namespace std;
typedef long long int ll;

#define INF (1e9)

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

    if (B - A <= 2) {
        cout << K + 1 << endl;
        return 0;
    }

    K -= A - 1;

    if (K < 0) {
        cout << K + 1 << endl;
        return 0;
    }

    ll ans;
    ans = (B - A) * (K / 2) + A;

    if (K % 2 == 1) {
        ans++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100005;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    for(int i=1;i<1000;i++){
        int t=x*i;
        t%=360;
        if(t==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
import math
k=list(map(int,input().split()))
a = int(k[0])
b = int(k[1])
x = int(k[2])
t = x/a**2
if(t * 2 > b):
    i = 2*(b - t)/a
    print(math.degrees(math.atan(i)))
else:
    i = 2*x/(a*b**2)
    print(90 - math.degrees(math.atan(i)))

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

int n, p, ans;
long long sum[100005], top, d, m, v, a[100005];

bool cmp(int a, int b) { return a > b; }

int main() {
	cin>>n>>m>>v>>p;
	v = n - v;
	top = v*m;
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; i++)
	    sum[i] = sum[i - 1] + a[i];
	ans = p;
	for(int i = p + 1; i <= n; i++) {
		d =  sum[i - 1] - sum[p - 1] - a[i]*(long long)(i - p);
		if(d > top) continue;
		if(a[p] - a[i] > m) continue;
		ans++;
	}
	cout<<ans<<endl;
} 



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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,k,x,y;

main() {
    cin >> n >> k >> x >> y;
    ct(min(n,k)*x+max((long long)0,n-k)*y)
}



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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n, m; cin >> n >> m;
  if (n == m && n == 1) cout << 1 << endl;
  else if (n == 2 || m == 2) cout << 0 << endl;
  else cout << max(1LL, n - 2) * max(1LL, m - 2) << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define N 300005
#define MOD 1000000007
/*typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;   */

using namespace std;
 
int h,w,a,b,ans,f[N];
 
int pw(int ta,int us) {
 
  if(!us) return 1;
  if(us==1) return ta;
  int c=pw(ta,us/2);
  c=(1ll*c*c)%MOD;
  if(us%2) c=(1ll*c*ta)%MOD;
  return c;
 
}
 
int main() {
 
  scanf("%d %d %d %d",&h,&w,&a,&b);
  f[0]=1;
  for(int i=1;i<=N-4;i++) {
    f[i]=(1ll*f[i-1]*i)%MOD;
  }
  for(int i=1;i<=h-a;i++) {
    int ust1=f[i-1+b-1];
    int ust2=f[h-i+w-b-1];
    int alt1=(1ll*f[i-1]*f[b-1])%MOD;
    int alt2=(1ll*f[h-i]*f[w-b-1])%MOD;
    ans=(ans+1ll*(1ll*ust1*pw(alt1,MOD-2)%MOD)*((1ll*ust2*pw(alt2,MOD-2))%MOD))%MOD;
  }
  printf("%d",ans);
 
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int dis(int i,int j,int x,int y){
  return abs(i-x)+abs(j-y);
}
void qt(int i,int j,int h){
  cout<<i<<' '<<j<<' '<<h<<endl;
  exit(0);
}
int x[MAXn],y[MAXn],h[MAXn];
int main(){
  IOS();
  int n;
  cin>>n;
  REP(i,n) cin>>x[i]>>y[i]>>h[i];
  REP(i,101)REP(j,101){
    vector<int> m,tmp;
    REP(k,n) m.eb(dis(i,j,x[k],y[k]));
    int th = -1;
    bool fg = true;
    REP(k,n){
      if( h[k]==0 ) tmp.eb(k);
      else if( th==-1 ) th = h[k]+m[k];
      else if( th!=h[k]+m[k] ){
        fg = false;
        break;
      }
    }
    if( !fg ) continue;
    if( th==-1 ){
      int tp = INF;
      REP(k,n) chkmin(tp,m[k]);
      qt(i,j,tp);
    }
    for( int it:tmp ){
      if( m[it]<th ){
        fg = false;
        break;
      }
    }
    if( fg ) qt(i,j,th);
  }
}


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

int main()
{
	int n;
	string s;
	cin >> n >> s;

	int ans = 0;

	for (int i = 1; i <= n; i++)
	{
		string t = s.substr(0, i), u = s.substr(i, n);

		set<char> ts, us;
		for (auto &&c : t)
		{
			ts.insert(c);
		}
		for (auto &&c : u)
		{
			us.insert(c);
		}

		int tmp = 0;

		for (auto &&c : ts)
		{
			if (us.find(c) != us.end())
			{
				tmp++;
			}
		}

		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n,k;
    cin>>n>>k;
    vector<pii> a;
    REP(i,n) {
        int x,y;
        cin>>x>>y;
        a.push_back({x,y});
    }
    sort(ALL(a));
    int sum=0;
    REP(i,n) {
        sum+=a[i].second;
        if(sum>=k) {
            cout<<a[i].first<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
//0-indexedで用いる (実装は1-indexedの配列だけど
//SegmentTree(n,f,m1):=サイズnの初期化。ここでfは2つの区間の要素をマージする二項演算m1はモノイドの単位元である。
//set(k,x) k番目の要素にxを代入する
//build() (代入で作った場合)セグメント木を構築するのに必要
//query(a,b) 区間[a,b)に対して二項演算した結果を返す
//update(k,x) k(0-indexed)番目の要素をxに変更する 
//operator[k] k(0-indexed)番目の要素を返す

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

  // PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A"
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<tuple<ll,ll,ll> >e(m); //r,l,c!!!!
  rep(i,m){
    int l,r,c;    
    cin >> l >> r >> c;
    --l;--r;
    e[i]=make_tuple(r,l,c);
  }
  sort(e.begin(),e.end());
  SegmentTree< ll > seg(n, [](ll a, ll b) { return min(a, b); }, LLONG_MAX/4);
  seg.set(0,0);
  seg.build();
  rep(i,m){
    ll r=get<0>(e[i]);
    ll l=get<1>(e[i]);
    ll c=get<2>(e[i]);
    ll t=seg.query(l,r+1);
    seg.update(r,min(t+c,seg.query(r,r+1)));
    //    cout << t+c << endl;
  }
  if(seg.query(n-1,n)== LLONG_MAX/4) cout << -1 << endl;
  else cout << seg.query(n-1,n) << endl;
  
}


Measured memory_bytes: 4608
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////


//////////////////////////////////////

int main() {
    
    ll A, B, K;
    cin >> A >> B >> K;
    if (K <= A) {
        cout << A - K << " " << B << endl;
    } else {
        if (K - A <= B) {
            cout << 0 << " " << B - K + A << endl;
        } else {
            cout << 0 << " " << 0 << endl;
        }
    }
    
    return 0;
}


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

bool Search(int key,int start,int end){
  if (start>=end-1){
    if (S[start]==key){
      return true;
    }else return false;
  }else{
    if (S[(start+end)/2] == key){
      return true;
    }else if (S[(start+end)/2] > key){
      return Search(key,start,(start+end)/2);
    }else return Search(key,(start+end)/2+1,end);
  }
}

int main(void){
  int n,q;
  scanf("%d",&n);
  S.resize(n);

  int t;
  for(int i=0;i<n;i++){
    scanf("%d",&t);
    S[i]=t;
  }
  scanf("%d",&q);
  int cnt=0;
  for(int i=0;i<q;i++){
    scanf("%d",&t);
    if (Search(t,0,n)) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3476
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N, A, B;
    string S;
    cin >> N >> A >> B;
    cin >> S;
    int passA = 0;
    int passB = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a' && passA + passB < A + B)
        {
            cout << "Yes" << endl;
            passA++;
        }
        else if (S[i] == 'b' && passA + passB < A + B && passB < B)
        {
            cout << "Yes" << endl;
            passB++;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    //cout << res << endl;
    return 0;
}

Measured memory_bytes: 848
import Foundation
let s = readLine()!
let t = readLine()!

if t.isEmpty {
  print(s.isEmpty ? 0 : -1)
  exit(0)
}

let S = Array(s)
let T = Array(t)

var ans = T.count

func diff(_ S: [Character], _ T: [Character], _ index: Int) -> Int {

  var diff = 0
  for i in 0..<T.count {
    if T[i] != S[index + i] {
      diff += 1
    }
  }
  
  return diff
}

for i in 0...S.count - T.count {
  ans = min(ans, diff(S, T, i))
  if ans == 0 {
    break
  }
}

print(ans)

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

namespace Atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ');
			var X = int.Parse(firstLine[0]);
			var Y = int.Parse(firstLine[1]);
			var result = X + Y / 2;
			Console.Write(result.ToString());


		}
	}
}


Measured memory_bytes: 11092
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long gcd(long long a, long long b) {
    long long numerator = max(a, b);
    long long denominator = min(a, b);
    long long rest = numerator % denominator;
 
    if (rest == 0) return denominator;
    else return gcd(denominator, rest);
}

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

    long long allGcd;
    cin >> allGcd;
    for (int i = 1; i < n; i++) {
        long long monster;
        cin >> monster;
        
        allGcd = gcd(allGcd, monster);
    }

    cout << allGcd << endl;
}


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

int main(){
  int N,W;
  cin >> N >>W;
  long long dp[110][100010]={};
  long long w[110];
  long long v[110];
  for(int i=0;i<=N;i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0;i<N;i++){
    for(long long sum_w=0;sum_w<=W;sum_w++){
      if(sum_w-w[i]>=0){
        dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
      }
      dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w]);
    }
  }
  cout<<dp[N][W]<<endl;
  return 0;
}


Measured memory_bytes: 89520
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        long a = 1000000000000000000L;
        //out.println(a % 10);

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] T = new long[N];
        for (int i = 0; i < N; i++){ T[i] = sc.nextLong(); }

        solver(N, T);
    }

    public static void solver(int N, long[] T) {
        long ans = 1;
        for(int n = 0; n < N; n++) {
            ans = lcm(ans, T[n]);
        }
        out.println(ans);
    }

    //参考: https://www.suzushin7.jp/entry/2016/11/05/calculate-least-common-multiple-in-java/
    //最大公約数 ユークリッドの互除法 O(logN)
    static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        //out.println(m+" "+n);
        return gcd(n, m % n);
    }

    //最小公倍数lcm ユークリッドの互除法 O(logN)
    static long lcm(long m, long n) {
        return m * (n / gcd(m, n));
    }
}

Measured memory_bytes: 25172
#include<stdio.h>
int main(){
    int a,b,c,k;scanf("%d %d %d %d",&a,&b,&c,&k);
    int list[3];
    list[0]=a;
    list[1]=b;
    list[2]=c;
    int max,maxj;
    for(int i=0;i<k;i++){
        max=-1;
        
        for(int j=0;j<3;j++){
            if(max<list[j]){
                max=list[j];
                maxj=j;
            }
        }
        list[maxj]*=2;
    }
    int sum=0;
    for(int i=0;i<3;i++)sum+=list[i];

    printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n;
    int ans;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i = 0;i<n ;i++){
        cin >> v.at(i);
    }

    for(int i = 0;i<n ;i++){
        cin >> c.at(i);
    }

    for(int i = 0;i<n ;i++){
        if(v.at(i) - c.at(i) > 0){
            ans += (v.at(i) - c.at(i));
        }
    }
    cout << ans << endl;
 } 


Measured memory_bytes: 256
n = int(input())

def func(a, b):
    a = len(str(a))
    b = len(str(b))
    return max(a, b)

ans = float('inf')
for i in range(1, int(n**0.5)+1):
    if n%i==0: ans = min(ans, func(i, n//i))

print(ans)
            




Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int ans=(n/500)*1000;
    ans+=((n%500)/5)*5;
    cout << ans;
}

Measured memory_bytes: 256
S=input()
T=list(S)
U=list(set(T))
b=[0]*2
if len(U)==2:
  for x in range(4):
    if U[0]==S[x]:
      b[0]+=1
    elif U[1]==S[x]:
      b[1]+=1
  if b[0]==2 and b[1]==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
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>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long K){
  ll x = 0;
  for (int i = 1; i < 9*K; i++) {
    x = (x*10 + 7)%K;
    if(x == 0){
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
    long long K;
  scanf("%lld",&K);
    solve(K);
    return 0;
}


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

int main(){
  ll n; cin>>n;
  string hey=to_string(n);
 
    if(hey[hey.length()-1]=='0'){
    }else if(hey[hey.length()-1]=='1'){
      n-=101;
    }else if(hey[hey.length()-1]=='2'){
      n-=102;
    }else if(hey[hey.length()-1]=='3'){
      n-=103;
    }else if(hey[hey.length()-1]=='4'){
      n-=104;
    }else if(hey[hey.length()-1]=='5'){
      n-=105;
    }else if(hey[hey.length()-1]=='6'){
      n-=105;
      n-=101;
    }else if(hey[hey.length()-1]=='7'){
      n-=105;
      n-=102;
    }else if(hey[hey.length()-1]=='8'){
      n-=105;
      n-=103;
    }else if(hey[hey.length()-1]=='9'){
      n-=105;
      n-=104;
    }
    if(n<0){
      cout<<0;
    }else if(n==0){
      cout<<1;
      }else{
     hey=to_string(n);


      if(hey[hey.length()-2]=='0'){
        cout<<1;
    }else if(hey[hey.length()-2]=='1'){
      n-=(105*2);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='2'){
      n-=(105*4);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='3'){
      n-=(105*6);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='4'){
      n-=(105*8);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='5'){
      n-=(105*10);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='6'){
      n-=(105*12);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='7'){
      n-=(105*14);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='8'){
      n-=(105*16);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }else if(hey[hey.length()-2]=='9'){
      n-=(105*18);
      if(n>=0){
        cout<<1;
      }else{
        cout<<0;
      }
    }




    }
  
  }


Measured memory_bytes: 256
from heapq import heappop, heappush
n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
    a, b, c = map(int, input().split())
    g[a-1].append((b-1, c))
    g[b-1].append((a-1, c))


def dijkstra(s, n, edges):
    # edges[i][j] : the cost of i→j
    # import 'heap'
    d = [10**18] * n
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in edges[u]:
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d


q, k = map(int, input().split())
d = dijkstra(k-1, n, g)

for _ in range(q):
    x, y = map(int, input().split())
    print(d[x-1]+d[y-1])


Measured memory_bytes: 90400
#A
N=int(input())
a=len(str(N))
if(a==1):
    ans=N
elif(a==2):
    ans=9
elif(a==3):
    ans=(N-99)+9
elif(a==4):
    ans=909
elif(a==5):
    ans=(N-9999)+909
elif(a==6):
    ans=90909
print(ans)

Measured memory_bytes: 3064
package main
import(
  "fmt"
  "sort"
)
func main(){
  var n, m, i int
  fmt.Scan(&n, &m)
  x:=make([]int, m)
  l:=make([]int, m-1)
  for i=0;i<m;i++{
    fmt.Scan(&x[i])
  }
  if n>=m{
    fmt.Println(0)
    return
  }
  sort.Sort(sort.IntSlice(x))
  for i=0;i<m-1;i++{
    l[i]=x[i+1]-x[i]
  }
  sort.Sort(sort.Reverse(sort.IntSlice(l)))
  ans:=x[len(x)-1]-x[0]
  for i=0;i<n-1;i++{
    ans-=l[i]
  }
  fmt.Println(ans)
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a+b+c>21)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)



def tree_init(N,M):
    edgelist = [[] for _ in range(N)]
    for a, b in [map(int, input().split()) for i in range(M)]:#木じゃない場合N-1をNに変える
        edgelist[a-1].append(b-1)#ノードの番号が0から始まる場合-1を消す
        edgelist[b-1].append(a-1)
    return edgelist

def dfs(N, start, edge):
    q=deque([(start,0)])
    visited=[False]*N
    ans=[0]*N
    while len(q):
        e, pe=q.popleft()#ここをpopleftにすると幅優先探索BFSになる
        if visited[e]:continue
        ans[e]=pe
        visited[e]=True
        for ne in edge[e]:
            q.append((ne,e))
            
    return ans

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    edgelist=tree_init(N,M)

    ans=dfs(N,0,edgelist)
    print('Yes')
    for a in ans[1:]:
        print(a+1)





if __name__ == "__main__":
    main()

Measured memory_bytes: 153896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
using namespace std;

int main()
{
	unsigned int N;
	unsigned short K;
	unsigned int keta;

	cin >> N >> K;

	keta = log(N) / log(K);
	keta++;

	cout << keta << endl;

	return 0;
}

Measured memory_bytes: 512
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

def readInts():
  return list(map(int,input().split()))

def main():
  """
  10,11,12 １の末尾に0,1,2を付けたもの！
  21,22,23 2の末尾に0,1,2を付けたもの！
  queueを使う！
  1,2,3,4,5,6,7,8,9,
  2,3,4,5,6,7,8,9,10,11,12
  3,4,5,6,7,8,9,10,11,12,21,22,23
  という風に、pushしていく
  """
  k = int(input())
  from collections import deque
  d = deque()
  # まず一桁のやつを最初にいれていく
  for i in range(1,10):
    d.append(i)
  #一桁ずつ増えていく感じで実装する
  
  #print(d)
  #exit()
  cnt = len(d)
  while True:
    if k <= cnt:
      print(d[k-1])
      exit()
    #k -= cnt # これで2桁目以上で、k番目ってのが出来るよ('ω')！！
    x = d.popleft()
    cnt -=1
    k -=1
    for i in range(-1,2,1):
      a = x % 10 + i
      if a < 0 or a > 9 :continue
      nx = x * 10 + a # くっつける
      d.append(nx)
      cnt += 1
      # これで列挙が出来る
    #print(d,len(d),cnt,k)
if __name__ == '__main__':
  main()

Measured memory_bytes: 6132
#include<stdio.h>

int main(void){
        char array[10000];
        char cmpA[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
        char cmpB[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
        char result[26] = {};
        int i,j,N,count;

        scanf("%d",&N);
        scanf("%s",array);

        for(i = 0; i < 10000;i++){
                if(array[i] == '\0') break;
                for(j = 0; j < 26;j++){
                        if(array[i] == cmpA[j]){
                                if(j + N  >= 26){
                                        result[count] = cmpB[j + N - 26];
                                }else{
                                        result[count] = cmpB[j + N];
                                }
                        }
                }
                count++;
        }
        for(i = 0;i < count;i++){
                printf("%c",result[i]);
        }


        return 0;
}




Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<string> blue(n);
	for(int i=0; i<n; i++){
		cin >> blue.at(i);
	}
	sort(blue.begin(), blue.end());
	int m;
	cin >> m;
	vector<string> red(m);
	for(int i=0; i<m; i++){
		cin >> red.at(i);
	}

	int ans=0;
	int tmp=0;
	for(int i=0; i<n; i++){
		tmp=0;
		for(int j=i; j<n; j++){
			if(blue.at(i)==blue.at(j)){
				tmp++;
			}
		}

		for(int r=0; r<m; r++){
			if(blue.at(i)==red.at(r)){
				tmp--;
			}
		}
		if(tmp>ans){
			ans=tmp;
		}
	}

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

Measured memory_bytes: 256