akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int a, b;
	int ab;
	int i;
	
	while (scanf("%d %d", &a, &b) != EOF){
		ab = a + b;
		i = 0;
		while (ab != 0){
			ab /= 10;
			i++;
		}
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 600
import copy

N, K = map(int, input().split())
my_R, my_S, my_P = map(int, input().split())
hand_score = {'r': my_P, 's': my_R, 'p': my_S}
T = input()
ans = 0

for i in range(K):
    cnt = (N - i - 1) // K + 1
    dp = {'R': 0, 'S': 0, 'P': 0}
    new_dp = {'R': 0, 'S': 0, 'P': 0}
    for j in range(cnt):
        check = {'r': 0, 's': 0, 'p': 0}
        check[T[(j * K) + i]] = hand_score[T[(j * K) + i]]

        new_dp['R'] = max(dp['S'] + check['s'], dp['P'] + check['p'])
        new_dp['S'] = max(dp['P'] + check['p'], dp['R'] + check['r'])
        new_dp['P'] = max(dp['R'] + check['r'], dp['S'] + check['s'])

        dp = copy.copy(new_dp)
    ans += max(dp.values())
print(ans)


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(4e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, x, d[20], c[20];
ll dmin[MAX_N];

void dijkstra(){
    fill(dmin,dmin+MAX_N,IINF);
    dmin[2*x] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push({0,x*2});
    while(!que.empty()){
        P p = que.top();
        que.pop();
        ll now = p.second;
        if(now == x*3)break;
        if(dmin[now] < p.first) continue;
        //cout << now << endl;
        REP(i,n){
            if(now+d[i]<MAX_N && now+d[i]>=0){
                int to = now + d[i];
                //cout << to << endl;
                if(dmin[to] > dmin[now]+c[i]){
                    dmin[to] = dmin[now] + c[i];
                    que.push({dmin[to],to});
                }
            }
            if(now-d[i]<MAX_N && now-d[i]>=0){
                int to = now - d[i];
                if(dmin[to] > dmin[now]+c[i]){
                    dmin[to] = dmin[now] + c[i];
                    que.push({dmin[to], to});
                }
            }
        }
    }

}

int main() {
    cin >> n >> x;
    REP(i,n){
        cin >> d[i] >> c[i];
    }
    dijkstra();
    if(dmin[x*3] != IINF){
        cout << dmin[x*3] << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 14248
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i64 = iter.next().unwrap().parse().unwrap();
    let k: i64 = iter.next().unwrap().parse().unwrap();
    let mut c: u64 = 0;
    let mut c2: u64 = 0;
    if k % 2 != 0 {
        for a in 1..(n + 1) {
            if a % k == 0 {
                c += 1;
            }
        }
        println!("{}", c.pow(3));
    } else {
        for a in 1..(n + 1) {
            if a % k == 0 {
                c += 1;
            } else if a % k == k / 2 {
                c2 += 1;
            }
        }
        println!("{}", c.pow(3) + c2.pow(3));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll n,k;cin>>n>>k;
    if(n>=2*k-1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    ll a, b, n;
    cin >> a >> b >> n;

    ll x = 0;
    if(n >= b) x = b-1;
    else x = n;

    ll ans = ((a * x) / b) - (a * (x / b));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   ll N;cin>>N;
   for(ll h=1;h<=3500;h++){
      for(ll n=h;n<=3500;n++){
         if(4*h*n==(n+h)*N)continue;
         if((h*n*N)%(4*h*n-(n+h)*N)==0){
            ll w=(h*n*N)/(4*h*n-(n+h)*N);
            if(w>=1 && w<=3500){
               printf("%lld %lld %lld\n",h,n,w);
               return 0;
            }
         }
      }
   }

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
string tr;
char c,d,w='\"';
int n,m;
int main(){
    scanf("%d",&n);
    while(n){
        tr = "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz";
        for(int i = 0; i < n; i++){
            scanf(" %c", &c);
            scanf(" %c", &d);
            tr[c - 48] = d;
        }
        scanf("%d",&m);
        for(int i = 0; i < m; i++){
            scanf(" %c", &c);
            cout << tr[c - 48];
        }
        cout << endl;
        scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 3224
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
#define debug2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define debugg(g,h,w) rep(i,0,h) { rep(j,0,w) cout << g[i][j] << " "; cout << endl;}
#define debugv(v) for(auto&& x : v){cout << x << " ";} cout << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll;

int g[10][5];
int n;
int score;

int check()
{
	int ret = 0;

	rep(i,0,n) rep(j,0,3) {
		if (g[i][j] > 0 && g[i][j] == g[i][j+1] && g[i][j] == g[i][j+2]) {
			int num = g[i][j];
			int same = 0;
			int jj = j;
			while (jj < 5) {
				if (g[i][jj] == num) {
					same++;
					g[i][jj] = -1;
					jj++;
				}
				else break;
			}
			score += num * same;
			ret++;
			continue;
		}
	}
	return ret;
}

void down()
{
	bool update = true;
	while (update) {
		update = false;
		rep(i,0,n-1) rep(j,0,5) {
			if (g[i][j] > 0 && g[i+1][j] == -1) {
				swap(g[i][j], g[i+1][j]);
				update = true;
			}
		}
	}
}

int main()
{
	Vi vans;
	while (1) {
		cin >> n;
		if (!n) break;
		rep(i,0,n) rep(j,0,5) cin >> g[i][j];
		score = 0;
		
		while (1) {
			int a = check();
			if (!a) break;
			down();
			//debugg(g,n,5);
			//debug(score);
		}
		//cout << score << endl;
		vans.pb(score);
	}
	for (auto a:vans) cout << a << endl;
	return 0;
}

Measured memory_bytes: 3068
m,d = map(int, input().split(' '))
mlist = list(range(m+1))
c = 0
for _d in range(d+1):
	d1 = _d // 10
	d0 = _d % 10
	if d1 > 1 and d0 > 1 and d1*d0 in mlist:
		c+=1
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    // count i -> j 
    int num[10][10];
    memset(num, 0, sizeof(num));
    for(int i=0; i<n-1; i++){
        num[s[i]-'0'][s[i+1]-'0']++;
    }

    vector<int> v(9);
    iota(v.begin(), v.end(), 1);

    ll costmin=INF;
    vector<int> ans(9);
    do{
        int phone[3][3];
        for(int i=0; i<9; i++){
            phone[i/3][i%3]=v[i];
        }

        int cost[10][10];
        for(int i=0; i<9; i++){
            for(int j=0; j<9; j++){
                cost[phone[i/3][i%3]][phone[j/3][j%3]]=abs(i/3-j/3)+abs(i%3-j%3);
            }
        }

        ll sum=0;
        for(int i=1; i<=9; i++){
            for(int j=1; j<=9; j++){
                sum+=cost[i][j]*num[i][j];
            }
        }

        if(sum<costmin){
            costmin=sum;
            ans=v;
        }

    }while(next_permutation(v.begin(), v.end()));

    for(int i=0; i<9; i++){
        cout << ans[i];
        if((i+1)%3==0) cout << endl;
    }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

vector<long long> make_divisors(long long n){
    vector<long long> divisors;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i*i != n) divisors.push_back(n/i);
        }
    }
    // sort(divisors.begin(), divisors.end());
    return divisors;
}

int main(void){
    ll N; cin >> N;
    auto v = make_divisors(N-1);
    ll ans = v.size()-1;
    v = make_divisors(N);
    for(ll q : v){
        if(q == 1) continue;
        ll n = N;
        while(n%q == 0) n /= q;
        if(n%q == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T chmin(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T chmax(T& l, T r) {
    return l = max(l, r);
}
// ============ template finished ============

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

    ll res = 0;
    {
        ll use = min(A, K);
        res += use;
        K -= use;
    }
    {
        ll use = min(B, K);
        K -= use;
    }
    {
        ll use = min(C, K);
        res -= use;
        K -= use;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = l[0], h = l[1];

            var ab = new int[n][];
            for (var i = 0; i < n; i++)
                ab[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var maxA = ab.Max(x => x[0]);
            var count = 0L;

            foreach (var val in ab.Where(x => x[1] >= maxA).OrderByDescending(o => o[1]))
            {
                count++;
                h -= val[1];
                if (h <= 0) break;
            }

            if (h <= 0)
                Console.WriteLine(count);
            else
            {
                count += h % maxA == 0 ? h / maxA : h / maxA + 1;
                Console.WriteLine(count);
            }
        }
    }
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 100000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main()
{
    fio;
    ld l;cin>>l;
    ld ans=l/3;
    ans=ans*ans*ans;
    cout<<setprecision(8)<<ans<<"\n";
}



Measured memory_bytes: 256
//=======Includes=======||
#include <iostream>     //
#include <cmath>        //
#include <cstdio>       //
#include <cstring>      //
#include <utility>      //
#include <cstdlib>      //
#include <cassert>      //
#include <ctime>        //
#include <sstream>      //
#include <algorithm>    //
#include <functional>   //
#include <numeric>      //
#include <string>       //
#include <vector>       //
#include <queue>        //
#include <stack>        //
#include <map>          //
#include <set>          //
#include <iomanip>      //
//======================||

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
#define ll long long
#define ld long double

int main()
{
    fastio();
    int k;
    cin>>k;
    int count=0;
    for (int i=1;i<=k;i++)
    {
        for (int j=1;j<=k;j++)
        {
            if (i%2==0 && j%2==1)
            {
                count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int r;cin>>r;
  cout<<2*r*M_PI<<endl;
}


Measured memory_bytes: 3820
def draw_frame(h, w)
  h.times do |i|
    if i == 0 || i + 1 == h
      puts "#" * w
    else
      puts "#" + "." * (w - 2) + "#"
    end
  end
end

loop do
  h, w = gets.chomp.split(" ").map(&:to_i)
  if h == 0 && w == 0
    break
  else
    draw_frame(h, w)
    print "\n"
  end
end

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

int main() {
  int n,k;
  string s;
  cin >> n >> s >> k;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) != s.at(k-1)){
      s.at(i) = '*';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))

graph = [[] for _ in range(N+1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
  
root = 1
parent = [0]*(N+1)
order = []
stack = [root]
while stack:
  x = stack.pop()
  order.append(x)
  for y in graph[x]:
    if y == parent[x]:
      continue
    parent[y] = x
    stack.append(y)
color = [-1]*(N+1)
for x in order:
  ng = color[x]
  c = 1
  for y in graph[x]:
    if y == parent[x]:
      continue
    if c == ng:
      c += 1
    color[y] = c
    c += 1
    
answer = []
for a, b in AB:
  if parent[a] == b:
    answer.append(color[a])
  else:
    answer.append(color[b])
K =max(answer)

print(K)
print('\n'.join(map(str, answer)))

Measured memory_bytes: 43376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

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

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

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    }
    else {
        cout << R + 100 * (10 - N) << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue

ll n, m, h;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= 100; i++){
        if(i == 1){
            h = 1;
        }
        else {
            h *= 2;
        }
        if(n * h > m){
            cout << i - 1;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int P,Q,cp[15][9],cq[15][9],T[11][5],i,j,k,f,R,C,S,cR,cC,cS,ch;
int K[8001][3],pat;
char t,a[]="(){}[]";

void in(int N,int I[15][9])
{
	for(i=0;i<N;i++)
	{
		for(f=1;(t=getchar())!=10;)
		{
			if(t!='.')f=0;
			if(f)I[i][0]++;
			for(k=0;k<6;k++)
				if(t==a[k])
					I[i][k+1]++;
		}
	}
}

int main()
{
	for(;scanf("%d%d\n",&P,&Q),P;)
	{
		memset(T,-1,sizeof(T));
		memset(cp,0,sizeof(cp));
		memset(cq,0,sizeof(cq));
		in(P,cp);in(Q,cq);
		cR=cp[0][1]-cp[0][2];
		cC=cp[0][3]-cp[0][4];
		cS=cp[0][5]-cp[0][6];
		for(ch=1;ch<P;ch++)
		{
			T[ch-1][0]=cR;
			T[ch-1][1]=cC;
			T[ch-1][2]=cS;
			T[ch-1][3]=cp[ch][0];
			cR+=cp[ch][1]-cp[ch][2];
			cC+=cp[ch][3]-cp[ch][4];
			cS+=cp[ch][5]-cp[ch][6];
		}
		R=C=S=-1;
		for(pat=0,i=1;i<=20;i++)
			for(j=1;j<=20;j++)
				for(k=1;k<=20;k++)
				{
					cR=cp[0][1]-cp[0][2];
					cC=cp[0][3]-cp[0][4];
					cS=cp[0][5]-cp[0][6];
					for(ch=1;ch<P;ch++)
					{
						if(i*cR+j*cC+k*cS!=cp[ch][0])
							break;
						cR+=cp[ch][1]-cp[ch][2];
						cC+=cp[ch][3]-cp[ch][4];
						cS+=cp[ch][5]-cp[ch][6];
					}
					if(ch==P)
					{
						K[pat][0]=i;
						K[pat][1]=j;
						K[pat][2]=k;
						pat++;
					}
				}
		R=K[0][0];C=K[0][1];S=K[0][2];
		for(i=1;i<pat;i++)
		{
			if(R!=K[i][0])R=-1;
			if(C!=K[i][1])C=-1;
			if(S!=K[i][2])S=-1;
		}
		cR=cq[0][1]-cq[0][2];
		cC=cq[0][3]-cq[0][4];
		cS=cq[0][5]-cq[0][6];
		for(printf("0%s",Q==1?"\n":" "),i=1;i<Q;i++)
		{
			for(j=0;j<P;j++)
				if(cR==T[j][0]&&cC==T[j][1]&&cS==T[j][2])
				{
					printf("%d%s",T[j][3],i==Q-1?"\n":" ");
					break;
				}
			if(j==P)
			{
				if((cR&&R==-1)||(cC&&C==-1)||(cS&&S==-1))
					printf("-1%s",i==Q-1?"\n":" ");
				else
					printf("%d%s",cR*R+cC*C+cS*S,i==Q-1?"\n":" ");
			}
			cR+=cq[i][1]-cq[i][2];
			cC+=cq[i][3]-cq[i][4];
			cS+=cq[i][5]-cq[i][6];
		}
	}
	return 0;
}

Measured memory_bytes: 700
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int A[104];
    int B=0;
    cin >> N >> M;
    REP(i,N){
        cin >> A[i];
        B+=A[i];
    }
    int num=0;
    REP(i,N){
        if(A[i]*4*M>=B)num++;
    }
    //cout << num << endl;
    if(num>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>

using namespace std;

int main() {
  char a,b;
  cin >> b;
  switch (b) {
    case 'A':
    a = 'T';
    break;
    case 'T':
    a = 'A';
    break;
    case 'G':
    a = 'C';
    break;
    case 'C':
    a = 'G';
    break;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>
#include <cstdio>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	for (int i = 0; i < n; i++)
	{
		int ta, tb;
		cin >> ta >> tb;
		a.push_back(ta);
		b.push_back(tb);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n % 2 == 0)
	{
		int l1 = a[n / 2 - 1];
		int l2 = a[n / 2];
		int r1 = b[n / 2 - 1];
		int r2 = b[n / 2];
		cout << (r1 + r2 - l1 - l2 +1);
	}
	else
	{
		int l = a[n / 2];
		int r = b[n / 2];
		cout << (r - l + 1);
	}
}



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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 


// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;



inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);


template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

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

bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.second < b.second);
}

const int MAX_N = 4123;

int arr[MAX_N];
 
int main() {
	int N;
	ll H;
	scanf("%d %lld",&N,&H);
	ll a,b,ma=0,mb=LLONG_MAX;
	vector<pair<ll,ll> > V;
	for(int i=0;i<N;i++){
		scanf("%lld %lld",&a,&b);
		V.push_back(make_pair(a,b));
		if(a>ma){
			ma=a;mb=b;
		}
		else if(a==ma && b<mb){
			mb=b;
		}
	}
	for(int i=0;i<N;i++){
		if(V[i].first==ma && V[i].second==mb){
			V[i]=make_pair(0,0);
			break;
		}
	}
	sort(V.begin(),V.end(),sortby);
	ll ans=0;
	int j=N-1;
	while(H>mb && V[j].second>ma){
		H-=V[j].second;
		ans++;
		j--;
	}
	if(H>0){
		H-=max(ma,mb);
		ans++;
		if(H>0)
			ans+=max((H-1)/ma+1,0LL);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
      char str[6];
      for(int i=0;i<5;i++){cin>>str[i];}
      for(int i=0;i<5;i++){
        if(str[i]=='A'&&str[i+1]=='C'){
          cout<<"Yes"<<endl;
          return 0;
        }
       
        
      }
cout<<"No"<<endl;return 0;
}
  

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

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

    int p, q;
    cin >> p >> q;
    int g = __gcd(p, q);
    q /= g;
    int ans = 1;
    for (int i = 2; i * i <= q; i++) {
        if (q % i == 0) {
            ans *= i;
            while (q % i == 0) {
                q /= i;
            }
        }
    }
    if (q > 1) ans *= q;
    cout << ans << endl;
}



Measured memory_bytes: 3188
console.log((args=>{
  const [HW,...A] = args.trim().split('\n');
  const [H,W] = HW.split(' ').map(v=>v|0);
  let stack = [], _stack = [], count = 0;
  const map = Array.from({length:H},_=>Array(W).fill(false));
  for ( let i = 0; i < H; i++ ) {
    for ( let j = 0; j < W; j++ ) {
      if ( A[i][j] === '#' ) {
        stack.push([i,j]);
        map[i][j] = true;
      }
    }
  }
  const dir = [[-1,0],[0,-1],[1,0],[0,1]];
  while ( stack.length ) {
    const [i,j] = stack.pop();
    for ( const [di,dj] of dir ) {
      const h = i+di, w = j+dj;
      if ( h < 0 || H <= h || w < 0 || W <= w || map[h][w] ) continue;
      map[h][w] = true;
      _stack.push([h,w]);
    }
    if ( stack.length === 0 ) {
      [stack,_stack] = [_stack,[]];
      count++;
    }
  }
  return `${count-1}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 154664
#include<bits/stdc++.h>
using namespace std;
int a[20];
int n,ans;
void dfs(int x,bool y){
	if (x==n){ans+=y;return;}
	dfs(x+1,!((a[x+1]-1)&1)||y);
	dfs(x+1,!((a[x+1])&1)||y);
	dfs(x+1,!((a[x+1]+1)&1)||y);
}
int main(){
	cin>>n;for (int i=1;i<=n;i++)cin>>a[i];
	dfs(0,0);cout<<ans<<endl;
}

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

const int nm = 1e7;
int n;
ll ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int l = n / i;
		ans += (ll) (i + i * l) * l / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
n=int(input())
sp=[]
for i in range(n):
  s,p=map(str,input().split())
  p=int(p)
  sp.append([s,p,i+1])

cities = list(set([sp[i][0] for i in range(n)]))
cities.sort()

for city in cities:
  c = []
  for i in sp:
    if city == i[0]:
      c.append(i[1:])
  #print(c)
  c.sort()
  #print(c)
  c.reverse()
  for i in c:
    print(i[1])

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    YESNO(N == M, "Yes", "No");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void Area_Circumference(double F_r, double* F_area, double* F_circumference)
{
    *F_area = F_r*F_r*M_PI;
    *F_circumference = 2*F_r*M_PI;
}

int main()
{
    double r,area,circumference;
    
    scanf("%lf", &r);
    Area_Circumference(r, &area, &circumference);
    
    printf("%f %f\n" ,area, circumference);
    
    return 0;
}


Measured memory_bytes: 2044
import math

x1,y1,x2,y2=(int(i) for i in input().split())
x3,y3,x4,y4=0,0,0,0
Xsa=x2-x1
Ysa=y2-y1
x3=x2-Ysa
y3=y2+Xsa
x4=x3-Xsa
y4=y3-Ysa

print("{0} {1} {2} {3}".format(x3,y3,x4,y4))


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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

int d[114514];

signed main() {
  int n;
  cin >> n;
  rep(i, n) {
    cin >> d[i];
  }
  int ma = 0;
  rep(i, n) {
    ma = max(ma, d[i]);
  }
  int f = 0;
  int h = 0;
  rep(i, n) {
    if(d[i] == ma) {
      f++;
    }
    else if(d[i] == ma - 1) {
      h++;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  if(h == 0) {
    if(1 <= ma && ma <= f / 2) {
      cout << "Yes" << endl;
    }
    else if(ma == f - 1) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    if(f == 1) {
      cout << "No" << endl;
    }
    else if(h + 1 <= ma && ma <= h + f / 2) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}


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

using namespace std;
typedef long long ll;
ll a[100005];
void solve()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
             cout<<0<<endl;
             return;
        }
    }
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=1000000000000000000/ans)
           ans*=a[i];
        else
        {
            cout<<-1<<endl;
            return;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4368
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end
long long N,K;
int ans=200000;
bool dislike[10]={false};

void dfs(int current, int add){
    current=10*current+add;

    if(current<N) {
        for (int i = 0; i < 10; i++) {
            if(!dislike[i])
                dfs(current, i);
        }
    }else{
        ans=min(ans, current);
        return;
    }
}


int main() {

    cin >> N >>K;
    int d;

    rep(i,K){
        cin >> d;
        dislike[d]=true;
    }

    for(int i=1; i<10; i++){
        if(!dislike[i])
            dfs(0,i);
    }

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



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

int main(){
    ll th = 1000000000000000000;
    int n;
    bool zero = false;
    cin >> n;
    vector<ll> a(n);
    ll ans = 1;

    rep(i, n){
        cin >> a.at(i);
        if(a.at(i)==0) zero=true;
    }
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    rep(i, n){
        if(a.at(i) <= th/ans) ans*=a.at(i);
        else{
            cout << -1 << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 4036
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,k,ans=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)ans+=min(ans,k);
    cout<<ans<<endl;
	return 0;
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    int ans=0;
    string S;
    cin>>S;

    for(int i=0;i<S.length();i++){
        if(S[i]=='+'){ans++;}
        else{ans--;}
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cassert>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

double r[1010],x[1010];

const double eps=1e-5;
const double inf=1e9;

bool cross(int m,double cx,double cy){
	rep(i,m){
		double dd=0.0;
		dd+=1.0*(x[i]-cx)*(x[i]-cx);
		dd+=1.0*(r[i]-cy)*(r[i]-cy);
		double rr=1.0*(r[i]+r[m])*(r[i]+r[m]);
		// cerr << rr << " " << dd << endl;
		if(rr>dd+eps) return true;
	}
	return false;
}

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> r[i];
	rep(i,n) x[i]=inf;
	
	rep(i,n){
		for(int j=-1;j<i;++j){
			double cx=r[i];
			if(j>=0){
				double d=1.0*(r[i]+r[j])*(r[i]+r[j]);
				d-=1.0*(r[i]-r[j])*(r[i]-r[j]);
				cx=x[j]+sqrt(d);
			}
			if(cx<r[i]) continue;
            if(i>0&&x[i-1]>=cx) continue;
            if(cross(i,cx,r[i])) continue;
            x[i]=min(x[i],cx);
		}
		// cerr << i << " " << x[i] << " " << r[i] << endl;
	}

	double ans=0.0;
	rep(i,n) ans=max(ans,x[i]+r[i]);
	cout.precision(20);
	assert(ans<inf);
	cout << fixed << ans << endl;
	return 0;
}

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

int main()
{
    long long a, b, c, d;

    long long max_result = LLONG_MIN;

    cin >> a >> b >> c >> d;

    max_result = max(max_result, a*c);
    max_result = max(max_result, a*d);

    max_result = max(max_result, b*c);
    max_result = max(max_result, b*d);

    cout << max_result << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

template<typename T> inline T sqr(T x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{
	int N, M;
	cin >> N >> M;
	VVI way(N + 1);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		way[a].push_back(b);
		way[b].push_back(a);
	}
	
	VI signpost(N + 1,0);
	signpost[1] = 1;
	queue<int> que;
	que.push(1);

	while (!que.empty()) {
		int p = que.front();
		que.pop();

		for(auto& next : way[p]){
			if (signpost[next] == 0) {
				signpost[next] = p;
				que.push(next);
			}	
		}
	}

	rng(i, 2, N+1) {
		if (signpost[i] == 0) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	rng(i, 2, N+1) {
		COL(signpost[i]);
	}

	return 0;
}

Measured memory_bytes: 10088
#include <cmath>
#include <vector>
#include <iostream>
#include <limits>
#include <iostream>
#include <vector>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Long;
typedef pair<int,int> PII;
int L[100010];
int P[100010];
int D[100010];

int compute(int u, vector<int> &VIS){
	if(VIS[u])return L[u];
	VIS[u] = 1;
	return L[u] = compute(P[u], VIS) + 1;
}

int main(){
	int N,K;
	cin >> N >> K;
	for(int i = 0; i < N; ++i){
		cin >> P[i];
		P[i]--;
	}
	int c = 0;
	if(P[0] != 0)c++;
	P[0] = 0;
	priority_queue<PII> PQ;
	{
		vector<int> VIS(N);
		VIS[0] = 0;
		L[0] = 0;
		for(int i = 0; i < N; ++i)
			PQ.push( PII( compute(i, VIS) , i ) );
	}
	while(PQ.size()){
		PII t = PQ.top(); PQ.pop();
		int d = t.first, u = t.second;
		if(u == 0)break;
		int h = D[u] + 1;
		if(h == K){
			if(P[u] != 0)c++;
		}else{
			D[ P[u] ] = max(h, D[ P[u] ]);
		}
	}
	cout << c << endl;
	
	
}


/*



 */


Measured memory_bytes: 4088
def backtrack(books, cur_book_ids, threshold, result):
    if len(cur_book_ids) > len(books):
        return
    if len(cur_book_ids) == len(books):
        achieved = True
        price_skills = [0] * len(books[0])
        for book,is_bought in zip(books, cur_book_ids):
            for j in range(len(book)):
                price_skills[j] += book[j]*is_bought
        for i in range(1, len(price_skills)):
            if price_skills[i] < threshold:
                achieved = False
        if achieved:
            if not result:
                result.append(price_skills[0])
            else:
                result[0] = min(result[0], price_skills[0])

    for i in (0,1):
        cur_book_ids.append(i)
        backtrack(books, cur_book_ids, threshold, result)
        cur_book_ids.pop()

def solve():
    N,M,X = [int(i) for i in input().split()]
    books = []
    for i in range(N):
        book = [int(i) for i in input().split()]
        books.append(book)
    result = []
    backtrack(books, [], X, result)
    if not result:
        print(-1)
    else:
        print(result[0])

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9196
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end

(* open MyInt64 *)
let () =
	let x1,y1,x2,y2 = scanf " %d %d %d %d" (fun u v w x -> (u,v,w,x))
	in
	let dx,dy = x2 - x1, y2 - y1 in
	let px,py = x2 - dy, y2 + dx in
	let qx,qy = px - dx, py - dy in
	printf "%d %d %d %d\n" px py qx qy











Measured memory_bytes: 384