akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for (int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
template <typename T> bool chkmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template <typename T> bool chkmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template <typename T> T sgn(const T&a) { return (a > T(0)) - (a < T(0)); }
typedef long long LL;
typedef long double LD;
const int BUF_SIZE = (int)2e7 + 10;
struct fastIO {
    char buf[BUF_SIZE], buf1[BUF_SIZE];
    int cur, cur1; FILE *in, *out;
    fastIO() { cur = BUF_SIZE, in = stdin, out = stdout; cur1 = 0; __builtin_prefetch(buf);__builtin_prefetch(buf1);}
    inline char getchar() { if(cur == BUF_SIZE) fread(buf, BUF_SIZE, 1, in), cur = 0; return *(buf + (cur++)); }
    inline void putchar(char ch) { *(buf1 + (cur1++)) = ch; if (cur1 == BUF_SIZE) fwrite(buf1, BUF_SIZE, 1, out), cur1 = 0; }
    inline int flush() { if (cur1 > 0) fwrite(buf1, cur1, 1, out); return cur1 = 0; }
}IO;
#define getchar IO.getchar
LL read() {
	LL x = 0, flag = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(LL x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + '0');
} 

const int Maxn = 1e5 + 9;
struct edge {
	int to, nxt;
}g[Maxn << 1];
int n, head[Maxn];
void add(int u, int v) { 
	static int e = 0;
	g[++e] = (edge){v, head[u]}, head[u] = e; 
}

int ans = 0;
static int bit[Maxn];

int calc(int limit) {
    int mx=20;
    while(mx>=0&&(!(limit&(1<<mx))))mx--;
    mx++;
	return mx;
}

void dfs(int u, int pa) {
	int same = 0;
	for (int i = head[u]; ~i; i = g[i].nxt) {
		int v = g[i].to;
		if (v != pa) {
			dfs(v, u);
			same |= bit[u] & bit[v];
			bit[u] |= bit[v];
		}
	}
	int mx = same ? 32 - __builtin_clz(same) : 0;
	while (bit[u] & (1 << mx)) ++mx;
	bit[u] |= (1 << mx);
	chkmax(ans, mx), bit[u] = bit[u] >> mx << mx;
}

int main() {

	clar(head, -1);
	n = read();
	rep (i, 1, n - 1) {
		int u = read(), v = read();
		add(u, v), add(v, u);
	}
	dfs(1, 0);
	cout << ans << endl;

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int numsum(int a){
    if(a==1)return 1;
    else{
        return a+numsum(a-1);
    }
}
double expect(int a){
    return numsum(a)/(double)a;
}
int main(){
    int k,n;cin>>n>>k;
    vector<double>p(n);//
    double max=0;
    int a;
    double sum=0;
    rep(i,n){
        cin>>a;
        p.at(i)=expect(a);
        if(i<k-1){
            sum+=p.at(i);
        }else if(i>=k-1){
            sum+=p.at(i);
            if(max<sum){
                max=sum;
            }
            sum-=p.at(i-k+1);
        }
    }
    /* これだとo(nk)でTLE
    for(int i=0;i<n-k+1;i++){
        sum=0;
        for(int j=i;j<i+k;j++){
            sum+=p.at(j);
        }
        if(max<sum){
            max=sum;
        }
    }*/
    printf("%.12f\n",max);


}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using edge = pair<int, int>;

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

  set<edge> edges;

  if(n % 2 == 0){
    int s = n + 1;
    FOR(i, 1, n+1)FOR(j, 1, n+1){
      if(j == i || j == s-i || i > j) continue;
      edges.insert({i, j});
    }
  } else {
    int s = n;
    FOR(i, 1, n+1)FOR(j, 1, n+1){
      if(j == i || j == s-i || i > j) continue;
      edges.insert({i, j});
    }
  }

  cout << edges.size() << endl;
  for(const edge& e: edges){
    cout << e.first << " " << e.second << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
const long long LINF=1e18;
signed main(void)
{
  int N,over=0;
  long long x,y;
  x=scanf("%d",&N);
  while(~scanf("%lld",&y))
  {
    if(y==0)return printf("%d",0),0;
    else if(LINF/y<x)over=1;
    else x*=y;
  }
  if(over)x=-1;
  return printf("%lld",x),0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);

    vector<vector<int>> rts(n+1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        rts.at(a).push_back(b);
        rts.at(b).push_back(a);
    }

    int cnt = 0;
    rep(i,n){
        int ch = h.at(i);
        bool good_fl = true;
        for(int x : rts.at(i+1)){
            if(ch <= h.at(x-1)){
                good_fl = false;
                break;
            }
        }
        if(good_fl){
            // cout << "i:" << i+1 << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 8752
def MAP(): return list(map(int,input().split()))
def f(x):
    tmp = (x+1)%4
    if tmp==0:
        return 0
    elif tmp==1:
        return x
    elif tmp==2:
        return 1
    else:
        return 1^x
A,B = MAP()
print(f(A-1)^f(B))

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

int check(int n, int k, int w[], long long mid){
    long long P = mid;
    
    int i = 0;
    for(int j = 0; j < k; j++){
        long long s = 0;
        while(s + w[i] <= P){
            s += w[i];
            i++;
            if(i == n) return n;
        }
    }
    
    return i;
}

long long solve(int n, int k, int w[], long long max){
    long long mid;
    long long left = 0;
    long long right = max;
    
    while(right - left > 1){
        mid = (right + left) / 2;
        int v = check(n, k, w, mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    
    return right;
}

int main(void){
    int n, k;
    long long max, P;
    
    cin >> n >> k;
    int w[n];
    max = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        max += w[i];
    }
    
    P = solve(n, k, w, max);
    cout << P << endl;
    
    return 0;
}



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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, m, k;
ll kai[1000001];
ll p3[1000001];
ll dp[1000001];

void init (int _n) {
    kai[0] = 1;
    p3[0] = 1;
    for (int i = 1; i <= _n; i++) kai[i] = kai[i-1]*i%MOD;
    for (int i = 1; i <= _n; i++) p3[i] = p3[i-1]*3%MOD;
}

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

ll conb (ll x, ll y) {
    ll z = x-y;
    ll ret = kai[x]*mod_pow(kai[y],MOD-2)%MOD;
    ret = ret*mod_pow(kai[z],MOD-2)%MOD;
    return ret;
}

int main() {
    cin >> n >> m >> k;
    ll s = n+m+k;
    ll ans = 0;
    init(s);
    dp[0] = 1;
    for (ll i = 1; i <= s; i++) {
        if (i <= m && i <= k) {
            dp[i] = dp[i-1]*2%MOD;
        } else if (i <= m) {
            dp[i] = (dp[i-1]*2-conb(i-1,i-1-k)+MOD*MOD)%MOD;
        } else if (i <= k) {
            dp[i] = (dp[i-1]*2-conb(i-1,m)+MOD*MOD)%MOD;
        } else {
            dp[i] = (dp[i-1]*2-conb(i-1,m)-conb(i-1,i-1-k)+2*MOD*MOD)%MOD;
        }
    }
    for (ll i = n; i <= s; i++) {
        ll add = p3[s-i];
        add = add * conb(i-1, n-1) % MOD;
        add = add * dp[i-n] % MOD;
        ans = (ans + add) % MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 22912
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int x, y; cin >> x >> y;
    eFOR(i, 0, x) {
        if (i * 2 + (x - i) * 4 == y) {
            print("Yes");
            return 0;
        }
    }
    print("No");

    return 0;
}

Measured memory_bytes: 3652
using System;

public class Hello
{
    public static void Main()
    {
        var dp = new int[10, 10];
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        for (int i = 0; i < 10; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 10; j++) dp[i, j] = int.Parse(line2[j]);
        }
        goWarshall(dp);
        var csum = 0;
        for (int i = 0; i < h; i++)
        {
            string[] line3 = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line3, int.Parse);
            for (int j = 0; j < w; j++)
                if (a[j] != -1) csum += dp[a[j], 1];
        }
        Console.WriteLine(csum);
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}


Measured memory_bytes: 13268
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       char a;
       cin>>a;
       if(a>=65 && a<=91)
       cout<<"A"<<"\n";
       else if(a>=97 && a<=122)
       cout<<"a\n";
    }
}



Measured memory_bytes: 3648
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[MAX_N], value[MAX_N];
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Measured memory_bytes: 86400
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

vector < vector < int >> g;
vector < int > vis;

void dfs(int u) {
	vis[u] = 1;
	for(int v : g[u]) {
		if(vis[v])
			continue;
		dfs(v);
	}
}

int32_t main() {
	boost;
	int n, m;
	cin >> n >> m;
	g.resize(n + 1);
	for(int i = 1, u , v; i <= m; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vis.resize(n + 1, 0);
	int ans = 0;
	for(int i = 1;  i <= n; i++) {
		if(vis[i])
			continue;
		dfs(i);
		ans++;
	}
	cout << ans - 1 << endl;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define sbp(p, n) rep(i, n) { int a, b; scanf("%d %d", &a, &b); p[i] = make_pair(a, b); }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int x[5], f;
	rep(i, 5) cin >> x[i];
	cin >> f;
	bool flg = true;
	rep(i, 5){
		rep(j, 5){
			if(abs(x[i] - x[j]) > f) flg = false;
		}
	}
	if(flg) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

n = int(input())
print("Yes" if n >= 30 else "No")









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

int main(){
  string s; cin>>s;
  long long ans=0;
  int n=s.size()-1;
  for(int bit=0;bit<(1<<n);bit++){
    long long tmp=s[0]-'0';
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
        ans+=tmp;
        tmp=(s[i+1]-'0');
      }else{
        tmp=tmp*10+(s[i+1]-'0');
      }
    }ans+=tmp;
  }
  cout<<ans<<endl;
}       

Measured memory_bytes: 256
#include <stdio.h>

/* this is prime */
#define MOD_BY 100000007

int getInv(int x) {
	int nowzyou=MOD_BY-2;
	long long now=x;
	long long result=1;
	while(nowzyou>0) {
		if(nowzyou & 1)result=(result*now)%MOD_BY;
		now=(now*now)%MOD_BY;
		nowzyou>>=1;
	}
	return (int)result;
}

int nCr(int n,int r) {
	long long result=1;
	int i;
	for(i=n;i>n-r;i--)result=(result*i)%MOD_BY;
	for(i=1;i<=r;i++)result=(result*getInv(i))%MOD_BY;
	return (int)result;
}

int main(void) {
	int w,h,sx,sy,dx,dy;
	int x,y,x1,y1,x2,y2,now;
	int result;
	scanf("%d%d%d%d%d%d",&w,&h,&sx,&sy,&dx,&dy);
	x=(w-dx)+(sx-0);
	now=(w-sx)+(dx-0);if(now<x)x=now;
	x1=x;
	now=dx-sx;if(now<0)now=-now;if(now<x)x=now;
	x2=now;
	y=(h-dy)+(sy-0);
	now=(h-sy)+(dy-0);if(now<y)y=now;
	y1=y;
	now=dy-sy;if(now<0)now=-now;if(now<y)y=now;
	y2=now;
	result=nCr(x+y,x);
	if(x1==x2)result=(result*2)%MOD_BY;
	if(y1==y2)result=(result*2)%MOD_BY;
	printf("%d\n",result);
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>

#define N 100000
#define INF 1000000
#define MAX 500000

typedef struct{
  int go, back, cost;
}Date;

int n,d[N];
Date a[MAX];
void root(int);

int main(){
  int i,j,z,k;
  int count = 0;
  scanf("%d",&n);
  for(i = 0; i<n ; i++){
    scanf("%d%d",&z,&k);
    for(j = 0; j < k ;j++){
      a[count].back = z;
      scanf("%d%d", &a[count].go,&a[count].cost);
      count++;
    }
  }
  root(count);
  for(i = 0; i<n ; i++) {
    printf("%d %d\n",i,d[i]);
  }
    return 0;
  }

  void root(int b){
    int i,judge = 1;
    for(i = 0; i<n ;i++){
      d[i] = INF;
    }
      d[0] = 0;
   
    while(judge != 0){
      judge = 0;
      for(i = 0; i<b ;i++){
	if(a[i].cost + d[a[i].back] < d[a[i].go]){
	  d[a[i].go] = a[i].cost + d[a[i].back];
	  judge = 1;
	}
      }
    }
  }



Measured memory_bytes: 7572
N,M,X = map(int,input().split())
C = []
A = []
for i in range(N):
    L = list(map(int,input().split()))
    C.append(L[0])
    A.append(L[1:M+1])
import itertools
L = []
Num = [i for i in range(N)]
for i in range(1,N+1):
    for j in itertools.combinations(Num,i):
        L.append(list(j))
c = 20000000
for i in range(len(L)):
    Z = [0 for _ in range(M)]
    m = 0
    for j in range(len(L[i])):
        for k in range(M):
            Z[k] += A[L[i][j]][k]
        m += C[L[i][j]]
    for l in range(M):
        if Z[l] < X:
            break
        if l == M-1:
            c = min(c,m)
if c == 20000000:
    print(-1)
else:
    print(c)

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (n != 0) {
        if (n % 2 == 0) {
            s += '0';
        } else {
            s += '1';
            n--;
        }
        n /= -2;
    }
    reverse(ALL(s));
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int n, m;
    cin >> n >> m;
    vs32 c(m);
    rep (i, m) cin >> c[i];

    vs32 dp(n + 1, (int)1e9);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i)
    {
        rep (j, m)
        {
            if (i - c[j] >= 0)
            {
                dp[i] = MIN(dp[i], dp[i - c[j]] + 1);
            }
        }
    }

    cout << dp[n] << "\n";
    return 0;
}



Measured memory_bytes: 3304
n=int(input())
h='hon'
p='pon'
b='bon'
if n>=100:
    if n-(n//10)*10==3:
        print(b)
    elif n-(n//10)*10==0 or n-(n//10)*10==1 or n-(n//10)*10==6 or n-(n//10)*10==8:
        print(p)
    else:
        print(h)
if 100>n>=10:
    if n%10==3:
        print(b)
    elif n%10==0 or n%10==1 or n%10==6 or n%10==8:
        print(p)
    else:
        print(h)
if 10>n:
    if n==3:
        print(b)
    elif n==0 or n==1 or n==6 or n==8:
        print(p)
    else:
        print(h)


Measured memory_bytes: 9156
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# リーダよりW (左)→ E(右)
# リーダよりE (右)→ W (左)
# W, Eの数を累積和として持っておく

N =  int(sys.stdin.readline())
S =  list(sys.stdin.readline().rstrip())

Wn = [0] * N
En = [0] * N

Wc = 0
Ec = 0
for i, s in enumerate(S):
    if s == "W":
        Wc += 1
    else:
        Ec += 1
    Wn[i] = Wc
    En[i] = Ec

ans = 10 ** 10
Wn = [0] + Wn
En = [0] + En
for i, (w, e) in enumerate(zip(Wn[1::], En[1::])):
    ans = min(Wn[i] + En[N] - En[i + 1], ans)

print(ans)

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),m=in(),l[m],k,a,ans=0;
  for (int i=0;i<m;i++) l[i]=0;
  for (int i=0;i<n;i++){
    cin >> k;
    for (int i2=0;i2<k;i2++) {
      cin >> a;
      l[a-1]++;
    }
  }
  for (int i=0;i<m;i++) {
    if (l[i]==n) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int hp = sc.nextInt();
    int skills = sc.nextInt();

    int total = 0;
    for (int i = 0; i < skills; i++) {
      total += sc.nextInt();
    }

    if (total >= hp) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 51028
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
ll fact(ll  n) 
{ 
    if (n == 0) 
        return 1; 
    return n * fact(n - 1); 
} 
int main()
{
    ll n,p=0,u=0,j,v,s=1,q=0,i,r=1;
    cin>>n;
   ll a[n];
   for(i=0;i<n;i++)
   {
       cin>>a[i];
   }
   q=a[0];
   for(i=1;i<n;i++)
   {
       p=q&a[i];
       if(p==0)
       {
           r++;
           q=q|a[i];
           
               s=s+r;
           
           
       }
       else
       {
           
           for(j=i-r;j<i;j++)
           {
               if(a[i]&a[j])
               {
                   r=i-j;
                   
               }
           }
           
           
               s=s+r;
          
           q=a[i-r+1];
           for(j=i-r+1;j<=i;j++)
           {
               q=q|a[j];
           }
       }
   }
   cout<<s<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());

		int sum=0;

		System.out.println((a+b) * h / 2);

	}

}

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

using namespace std;

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

    int fp = ((s[0] - '0') * 10) + ((s[1] - '0') * 1);
    int sp = ((s[2] - '0') * 10) + ((s[3] - '0') * 1);

    bool mmyy = false;
    bool yymm = false;
    int cnt = 0;
    
    if (fp > 0 && fp < 13 && sp >= 0 && sp <= 99)
    {
	mmyy = true;
	++cnt;
    }

    if (sp > 0 && sp < 13 && fp >= 0 && fp <= 99)
    {
	yymm = true;
	++cnt;
    }
    
    if (cnt == 0)   cout << "NA" << '\n';
    if (cnt == 2)   cout << "AMBIGUOUS" << '\n';
    if (cnt == 1 && mmyy)   cout << "MMYY" << '\n';
    if (cnt == 1 && yymm)   cout << "YYMM" << '\n';

    return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll mod=998244353;
ll n,m,k;
const int N=2e5+5;
ll fact[N],invfact[N];
ll pwr(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1) res=(res*a)%m;
        b=b>>1;
        a=(a*a)%m;
    }
    return res%m;
}
ll modinv(ll x,ll m)
{
    return pwr(x,m-2,m);
}
void precompute()
{
    fact[0]=1;
    repA(i,1,N-1)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
    invfact[N-1]=modinv(fact[N-1],mod);
    repD(i,N-2,0)
    {
        invfact[i]=(i+1)*invfact[i+1];
        invfact[i]%=mod;
    }
}
ll C(ll n,ll r)
{
    if(r>n) return 0;
    ll num=fact[n];
    num*=invfact[r];
    num%=mod;
    num*=invfact[n-r];
    num%=mod;
    return num;
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n>>m>>k;
    precompute();
    ll ans=0;
    repA(i,0,k)
    {
        ll cur=pwr(m-1,n-i-1,mod);
        cur*=m;
        cur%=mod;
        cur*=C(n-1,i);
        cur%=mod;
        ans+=cur;
        ans%=mod;
    }
    ans%=mod;
    cout<<ans<<'\n';
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 6780
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>

using namespace std;

int main(){
	int N, a[100], b[100], c[100], d[100], redX[200], blueX[200], tmp;
	int i, j, ans = 0, k;

	for (i = 0; i < 200; i++){
		redX[i] = -1;
		blueX[i] = -1;
	}
	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%d %d", &a[i], &b[i]);
		redX[a[i]] = i;
	}
	for (i = 0; i < N; i++){
		scanf("%d %d", &c[i], &d[i]);
		blueX[c[i]] = i;
	}

	for (i = 0; i <2*N; i++){
		tmp = -1;
		if (blueX[i] != -1){
			for (j = 0; j <2*N; j++){
				if (redX[j] != -1){
					if ((a[redX[j]] < c[blueX[i]]) && (b[redX[j]] < d[blueX[i]])){
						if (tmp < b[redX[j]]){
							tmp = b[redX[j]];
							k = j;
						}
					}
				}
			}
			if (tmp != -1){
				ans++;
				redX[k] = -1;
			}
		}
	}

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


	return 0;
}

Measured memory_bytes: 128
def bubbleSort(A, N):
    flag = True
    swap = 0

    while flag:
        flag = False

        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                swap += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(swap)

def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    bubbleSort(A, N)

main()




Measured memory_bytes: 5608
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = LI()
        u, v = u - 1, v - 1
        w = w % 2
        edges[u].append([v, w])
        edges[v].append([u, w])
    ans = [-1] * N
    ans[0] = 0
    def solve(k):
        for e, w in edges[k]:
            if ans[e] == -1:
                ans[e] = ans[k] if w == 0 else 1 - ans[k]
                solve(e)
    solve(0)
    for a in ans:
        print(a)
    return

main()

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

// https://atcoder.jp/contests/abc135/submissions/6597565 を参考

int K;

// 終点からスタートして原点に近づいていく
// 1つ前の点を返す関数
pair<int, int> pre(int x, int y) {
    if(x > y){
        auto p = pre(y, x);
        return {p.second, p.first};
    }
    if(x < 0){
        auto p = pre(-x, y);
        return {-p.first, p.second};
    }

    // 0 <= x <= y が保証される
    if(x + y == K) return {0, 0};
    if(x + y >= 2*K) return {x, y-K};

    // x+y < 2*K && x+y != K のとき, x+y-KとKの偶奇が一致していれば2回,
    // そうでなければ x'+y' < 2*K を満たす(x', y')を経由して3回で原点に行ける
    // 以下2回で行ける場合を考える
    // 図示すれば第二象限の (x', y') | y >= y', -x'+y' = K に移動できることがわかる
    // x'<=0, y'>= 0, -x'+y'=K, (y-y')+(x-x')=K をx'について解くと
    int x_next = (x + y) / 2 - K;
    // yは (y-y')+(x-x')=K が成り立つように決める
    int y_next = y + x - x_next - K;
    // 3回の場合もこれでx'+y' < 2*K を満たす
    return {x_next, y_next};
}

int main() {
    int X, Y;
    cin >> K >> X >> Y;

    // 到達不可能な場合
    if(!(K&1) && (X+Y)&1) {
        cout << "-1";
        return 0;
    }

    vector<pair<int, int>> ans;
    ans.reserve(200000);
    ans.push_back({X, Y});
    while(ans.back().first || ans.back().second){
        auto t = pre(ans.back().first, ans.back().second);
        ans.push_back(t);
    }

    cout << ans.size()-1 << "\n";
    for (int i = ans.size()-2; i >= 0; --i) {
        cout << ans[i].first << " " << ans[i].second << "\n";
    }
    return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	if(s[0]==s[2]) cout<<"Yes\n";
	else cout<<"No\n";
}


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

int main(){

	int count[4][3][10];
	int b, f, r, v;
	int n, i, j, k;

	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){

				count[i][j][k] = 0;
			}
		}
	}



	cin >> n;
	for (i = 0; i < n; i++){

		cin >> b >> f >> r>>v;
		count[b - 1][f - 1][r - 1] =count[b - 1][f - 1][r - 1] + v;

	}

	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){
				if (k == 9){
					cout << " " << count[i][j][k] << endl;
				}
				else{
					cout << " " << count[i][j][k];
				}
			}
		}
		if (i != 3){
			cout << "####################" << endl;
		}
		
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main()
{
  for (int i = 0; i < 5; ++i) 
  {
    int x;
    cin >> x;
    if (x == 0)
    {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    long double a,b;
    cin >> a >> b;
    cout << fixed << setprecision(0) << floor(a*(b*1000) / 1000) << endl;
    return 0;
}

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

int main(){
    int a,b;
    char op;
    cin>>a>>op>>b;

    if(op=='+') cout<<a+b<<"\n";
    else cout<<a-b<<"\n";
    return 0;
}

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

using namespace std;
using ll = long long;
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) \
	sort(all(v)); \
(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f)                  \
	if ((f))                      \
{                             \
	cout << (TRUE__) << endl; \
}                             \
else                          \
{                             \
	cout << FALSE__ << endl;  \
}
#define RS resize
#define CINV(v, N)             \
	do                         \
{                          \
	v.RS(N);               \
	rep(i, N) cin >> v[i]; \
} while (0);
#define RCINV(v, N)             \
	do                          \
{                           \
	v.RS(N);                \
	rrep(i, N) cin >> v[i]; \
} while (0);
	template <typename T>
inline T GET()
{
	T val;
	cin >> val;
	return val;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> v;
int need;
int res;

void init()
{
	cin >> N;
	CINV(v, N);
	rep(i, N) {
		int t;
		cin >> t;
		v[i] -= t;
	}
	sort(all(v), greater<int>());
	rep(i, N) {
		if (v[i] < 0) {
			need += -v[i];
			res++;
		}
	}
}

void solve()
{
	rep(i, N) {
		if (need <= 0) break;
		need -= v[i];
		res++;
	}
	if (need <= 0) {
		cout << res << endl;
	} else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

/*
        time complexty
auto start = chrono::steady_clock::now();
    ............

auto endd = chrono::steady_clock::now();
auto dif =   endd- start;
cout << chrono::duration<double, milli>(dif).count() <<"ms"<<endl;

*/

const int S = 1e7+3;
LL ans=0 ,  n ;

int a[S];

int main(){

scanf("%lld",&n);

for(LL i = 2 ; i <= n; i++){

    for(int j = i ; j <= n ; j+=i)
     a[j]+= 1;

  ans+=(max( a[i] , 1 )+1)*i;
}

cout <<ans+1;

return 0;
}


Measured memory_bytes: 42780
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

const ll MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    vector<ll> a(n);
    ll sum=0;
    ll ans=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
        sum%=MOD;
    }
    rep(i,n){
        ll x=sum-a[i];
        x=(x+MOD)%MOD;
        ll res=a[i]*x;
        res%=MOD;
        ans+=res; ans%=MOD;
    }
    if(ans%2==1){
        ans=(ans+MOD)/2;
    }
    else ans/=2;
    cout << ans << endl;
    
}




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

const int MOD = 10000;

int n, k;
int memo[128][4][4];
int reserve[128];

int pasta(int d, int b1, int b2);

int main(void)
{
	int sum;
	
	scanf("%d %d", &n, &k);
	while (k-- > 0){
		int d, p;
		
		scanf("%d %d", &d, &p);
		reserve[d] = p;
	}
	
	memset(memo, -1, sizeof(memo));
	printf("%d\n", pasta(1, 0, 0));
	
	return 0;
}

int pasta(int d, int b1, int b2)
{
	int i;
	
	if (d > n) return 1;
	if (memo[d][b1][b2] != -1) return memo[d][b1][b2];
	if (reserve[d] != 0){
		if (b1 == b2 && b2 == reserve[d]) return 0;
		else return pasta(d + 1, reserve[d], b1) % MOD;
	}
	int tmp = 0;
	for (i = 1; i <= 3; i++){
		if (b1 == b2 && b2 == i) continue;
		tmp += pasta(d + 1, i, b1);
	}
	
	return memo[d][b1][b2] = tmp % MOD;
}

Measured memory_bytes: 608
#include <iostream>
using namespace std;
int n,m;
int main(void){
    cin>>n;
    cout<<n<<':';
    m=n;
    for(int i=2;i*i<=n;i++){
        while(m%i==0){
            m/=i;
            cout<<" "<<i;
        }
    }
    if(m!=1)cout<<" "<<m;
    cout<<endl;
}



Measured memory_bytes: 3112
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,*A = map(int,read().split())

class Dinic:
    def __init__(self, N, source, sink):
        self.N = N
        self.G = [[] for _ in range(N)]
        self.source = source
        self.sink = sink

    def add_edge(self, fr, to, cap):
        n1 = len(self.G[fr])
        n2 = len(self.G[to])
        self.G[fr].append([to, cap, n2])
        self.G[to].append([fr, 0, n1]) # 逆辺を cap 0 で追加
        
    def add_edge_undirected(self, fr, to, cap):
        n1 = len(self.G[fr])
        n2 = len(self.G[to])
        self.G[fr].append([to, cap, n2])
        self.G[to].append([fr, cap, n1])
        
    def bfs(self):
        level = [0] * self.N
        G = self.G; source = self.source; sink = self.sink
        q = deque([source])
        level[source] = 1
        pop = q.popleft; append = q.append
        while q:
            v = pop()
            lv = level[v] + 1
            for to, cap, rev in G[v]:
                if not cap:
                    continue
                if level[to]:
                    continue
                level[to] = lv
                if to == sink:
                    self.level = level
                    return
                append(to)
        self.level = level
        
    def dfs(self,v,f):
        if v == self.sink:
            return f
        G = self.G
        prog = self.progress
        level = self.level
        lv = level[v]
        E = G[v]
        for i in range(prog[v],len(E)):
            to, cap, rev = E[i]
            prog[v] = i
            if not cap:
                continue
            if level[to] <= lv:
                continue
            x = f if f < cap else cap
            ff = self.dfs(to, x)
            if ff:
                E[i][1] -= ff
                G[to][rev][1] += ff
                return ff
        return 0
    
    def max_flow(self):
        INF = 10**18
        flow = 0
        while True:
            self.bfs()
            if not self.level[self.sink]:
                return flow
            self.progress = [0] * self.N
            while True:
                f = self.dfs(self.source, INF)
                if not f:
                    break
                flow += f
        return flow

source = 0; sink = N+1; INF = 10 ** 18
dinic = Dinic(N+2,source,sink)
add = dinic.add_edge

for i,x in enumerate(A,1):
    if x < 0:
        # source側：割るものを表現。sink側にうつすときにカット-xが必要。
        add(source,i,-x)
    else:
        # sink側：割らないものを表現。source側にうつすときにカットxが必要。
        add(i,sink,x)

for i in range(1,N+1):
    for j in range(i+i,N+1,i):
        # iを割るならjも割る。iを割ってjを割らないのは禁止
        # iがsourceでjがsinkなのは禁止
        add(i,j,INF)

f = dinic.max_flow()
x = sum(x for x in A if x >= 0)
answer = x - f

print(answer)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	vector<ll>ch[100010];
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	ll ans[100010];
	for(ll i=0;i<n;i++){
		ans[i]=-1;
	}
	queue<ll>q;
	ans[0]=0;
	q.push(0);
	while(q.size()!=0){
		ll now=q.front();
		q.pop();
		//cout <<now<<endl;
		for(ll i=0;i<ch[now].size();i++){
			ll next=ch[now][i];
		//	cout <<next<<endl;
			if(ans[next]!=-1){
				continue;
			}
			ans[next]=now;
			q.push(next);
		}
	}
	cout <<"Yes"<<endl;
	for(ll i=1;i<n;i++){
		cout <<ans[i]+1<<endl;
	}
	// your code goes here
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define fr(x,v) for(auto&x :v)
#define pr(a,b) cout << a << " " << b << endl
#define pr1(a,b,c) cout << a << " " << b << " "<< c << endl

typedef long long int ll;
typedef vector<ll> vi;

struct input{
	ll a;
};

const ll M=998244353;
const ll N=3e5+1;
template< class T > T gcd(const T a, const T b) { return (b ? gcd<T>(b, a%b) : a); }



ll pw(ll x, ll p)
{
	if(p==0)
		return 1;
	ll t=pw(x,p/2);
	if(p%2==0) return (t*t)%M;
	else	   return (((t*t)%M)*x)%M;
}

int main()
{
	
	fastio;
	
	ll n,m,i,j,k,temp,x,y,z,t,p;
	string S;
	ll a,b;
	cin >> n >> a >> b >> k;
	ll modi[n+1];
	modi[0]=1;
	modi[1]=1;
	ll nf=1;

	for(i=2;i<=n;i++)
	{	
		nf=(i*nf)%M;
		modi[i]=(modi[i-1]*pw(i,M-2))%M;
	}
	// cout << nf*modi[n] << endl;
	ll ans=0;
	for(i=0;i<=n;i++)
	{
		t=(k-a*i);
		x=i;
		if(t>=0 && t%b==0)
		{
			y=(t)/b;
			// pr(x,y);
			if(y<=n){
			ans+=(((((nf*modi[x])%M)*modi[n-x])%M)*((((nf*modi[y])%M)*modi[n-y])%M))%M;
			ans%=M;
			}
		}
	}

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

Measured memory_bytes: 2560
def main():
    import sys
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    
    n= ini()
    tmp = 0
    for _ in range(n):
        l,r = ina()
        if(l==r):
            tmp+=1
            if(tmp==3):
                print("Yes")
                return
        else:
            tmp =0
    print("No")
        


        


    




















if __name__ == "__main__":
    main()

Measured memory_bytes: 62160
#include<iostream>

using namespace std;

int main(){
	
	int sum;
	int kouka[] = {1,5,10,50,100,500};
	int c;
	
	for(int i= 0; i < 6; i++){
		int c;
		cin >> c;
		sum += c *kouka[i];
	}
	
	if (sum >= 1000){
		cout << "1" << endl;
	}else{
		cout << "0"<< endl;
	}

	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];

            for (var i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine());

            var pos = 0;
            var ans = -1;
            var count = 0;
            var visited = new bool[100000];

            while (pos < n)
            {
                count++;

                if (a[pos] == 2)
                {
                    ans = count;
                    break;
                }

                visited[pos] = true;
                if (visited[a[pos]-1]) break;

                pos = a[pos] - 1;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int H,A;
    cin >> H >> A;
    cout << dup(H,A) << endl;
    
    return 0;
}

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

using namespace std;

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

	vector<int> D;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D.push_back(d);
	}

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

	int count = 1;
	for (int i = 0; i < N-1; i++) {
		if (D[i] < D[i + 1]) {
			count++;
		}
	}

	cout << count << endl;
	
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

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

	set<pair<int,int> > ed;
	if(n%2==1){
		for(int i=1;i<n;i++){
			ed.insert({min(i,n),max(i,n)});
		}
		n--;
	}
	int su = n+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i+j == su || i==j) continue;
			ed.insert({min(i,j),max(i,j)});
		}
	}
	cout<<ed.size()<<endl;
	for(auto k:ed){
		cout<<k.X<<" "<<k.Y<<endl;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
 
int num =0;
long long count(int a){
    if(a%2!=0){
        return num;
    }else{
        num++;
        a = a/2;
        return count(a);
    }
}

int main(){
    int n; 
    cin >> n;
    int cnt = 0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        cnt = count(x);
    }
    cout << cnt <<endl;
    return 0; 
}

Measured memory_bytes: 256