akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    vector<ll> count;
    ll r = 0, l = 0;
    bool flag = true;
    for(ll i=0;i<s.size();++i){
        if(flag == true){
            if(s[i] == 'R'){
                r++;
            }else if(s[i] == 'L'){
                flag = false;
                l++;
            }
        }else if(flag == false){
            if(s[i] == 'L'){
                l++;
            }else if(s[i] == 'R'){
                flag = true;
                count.push_back(r);
                count.push_back(l);
                r = 1;
                l = 0;
            }
        }
    }
    count.push_back(r);
    count.push_back(l);
    
    for(ll i=0;i<count.size();i+=2){
        ll sum = count[i] + count[i+1];
        for(ll j=0;j<count[i]-1;++j){
            cout<<0<<' ';
        }
        
        if(sum % 2 == 0){
            cout<<sum/2<<' '<<sum/2<<' '; 
        }else{
            if(count[i] % 2 == 1){
                cout<<sum/2+1<<' '<<sum/2<<' ';
            }else{
                cout<<sum/2<<' '<<sum/2+1<<' ';
            }
        }

        for(ll j=0;j<count[i+1]-1;++j){
            cout<<0<<' ';
        }
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll ans=0;
  rep(i,1000001){
    if(i==0) continue;
    if(n%i==0)ans+=n/i-1;
    else ans+=n/i;
  }
  COUT(ans);
  
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){row[i]=col[i]=FREE;}
  for(i=0;i<2*N-1;i++){dpos[i]=dneg[i]=FREE;} 
}
void print(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%s",row[i]==j?"Q":".");
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    print(); return; 
  }

  for(j=0;j<N;j++){
    if(NOT==col[j]||NOT==dpos[i+j]||NOT==dneg[i-j+N-1]) continue;
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,a,b;
  initialize();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++) X[i][j]=false;

  scanf("%d",&j);

  for(i=0;i<j;i++){
    scanf("%d %d",&a,&b);
    X[a][b]=true;  
  }
  recursive(0);

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define ll long long
int main()
{
    faster();
    int t;
  	cin>>t;
  	if(t>=30) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int cnt = 0;
    for (int i=0; i<= A; i++){
        for (int j=0; j<= B; j++){
            for (int k=0; k<=C; k++){
                if (500*i + 100*j + 50*k == X){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
implicit none
integer :: i,n
character(16),parameter :: ans = 'CODEFESTIVAL2016'
character(16) :: str

read *,str
n = 0
do i = 1, 16
   if (ans(i:i) /= str(i:i)) then
      n = n + 1
   endif
enddo

print '(i0)',n
end

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
int main(){
    fast;
    ll x;
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }else if(s=="MON"){
        cout<<6<<endl;
    }else if(s=="TUE"){
        cout<<5<<endl;
    }else if(s=="WED"){
        cout<<4<<endl;
    }else if(s=="THU"){
        cout<<3<<endl;
    }else if(s=="FRI"){
        cout<<2<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int x, a, b;

	cin >> x >> a >> b;

	int val = x - a + b;
	// cerr << val << endl;
	if (val <= x) {
		cout << "delicious" << endl;
	} else if (val <= 2 * x) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(1, M+1):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for j  in range(1, N+1):
        if j in c:
            d += 2**(j-1)
    for j in range(2**N):
        dp[j | d] = min(dp[j | d], dp[j] + a)
print(dp[-1] if dp[-1] != float("inf") else -1)

Measured memory_bytes: 9104
#include<stdio.h>
int main(void)
{
 char s[3];
 int i;
 int a=0,b=0,c=0;
 scanf("%s",&s[0]);
 for(i=0;i<3;i++){
     if(s[i]=='a')
        a++;
     else if(s[i]=='b')
        b++;
     else if(s[i]=='c')
        c++;
 }
 if(a==1&&b==1&&c==1)
    printf("Yes");
 else
    printf("No");
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int dp[6005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, t;
	cin >> n >> t;
	vector<pi> a(n);
	rep(i, 6005) dp[i] = -1e9;
	dp[0] = 0;
	rep(i, n) cin >> a[i].fi >> a[i].se;
	sort(all(a));
	rep(i, n){
		for(int j = t - 1; j >= 0; j--){
			dp[j + a[i].fi] = max(dp[j + a[i].fi], dp[j] + a[i].se);
		}
	}
	int ans = 0;
	rep(i, 6005) ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll k; cin>>k;
  if(k<=9){
    cout<<k<<endl;
    return 0;
  }
  
  vll nxt={-1,0,1};
  queue<ll> q;
  reps(i,9){
    q.push(i);
  }
  ll cnt=10;
  while(!q.empty()){
    ll v=q.front(); q.pop();
    ll mod=v%10;
    rep(i,3){
      ll a=mod+nxt[i];
      if(a<0 || a>9) continue;
      ll b=v*10+a;
      if(cnt==k){
        cout<<b<<endl;
        return 0;
      }
      cnt++;
      q.push(b);
    }
  }
  
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


double dp[3005][3005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	std::vector<double> v(n+3);
	REP(i,n) cin>>v[i];
	cout<<fixed;
	cout<<setprecision(10);


	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <=i; ++j)
		{
			 if(j)dp[i][j] += (dp[i-1][j-1] * v[i-1]);
			 dp[i][j] += (dp[i-1][j] * (1-v[i-1]));
		}
	}
	double sum = 0;
	for (int i = (n+1)/2; i <= n; ++i)
	{
		sum += dp[n][i];
	}
	cout<<sum;
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	
	int even, odd;
	even = 0; odd = 0;
	
	F0R(i, N) {
		int x; cin >> x;
		if (x % 2) ++odd;
		else ++even;
	}

	if (N <= 1 || odd % 2 == 0) {
		print("YES");
	} else {
		print("NO");
	}
}

Measured memory_bytes: 256
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)
sorted(S) #Sを辞書順にソート
exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N=input()
if N=="A" or N=="B" or N=="C" or N=="D" or N=="E" or N=="F" or N=="G" or N=="H" or N=="I" or N=="J" or N=="K" or N=="L" or N=="M" or N=="N" or N=="O" or N=="P" or N=="Q" or N=="R" or N=="S" or N=="T" or N=="U"or N=="V"or N=="W"or N=="X" or N=="Y" or N=="Z":
    print("A")
else: print("a")





Measured memory_bytes: 27152
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define sz(x) int(x.size())

using namespace std;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    string s;
    string t;
    cin >> s >> t;
    
    int cnt = 0;
    for(int i=0 ;i<3; i++){
        if(s[i] == t[i])cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 4000 + 5 ; 
const int P = 998244353 ; 
int maxn, n, K, C[N][N], Ans[N] ; 
signed main()
{
	K = gi(), n = gi(), maxn = n + K ; 
	C[0][0] = 1 ; 
	rep( i, 1, maxn ) rep( j, 0, maxn ) C[i][j] = (!j) ? 1 : ( C[i - 1][j - 1] + C[i - 1][j] ) % P ; 
	for( re int i = 2; i <= 2 * K; ++ i ) {
		int u = 0, v = 0 ; 
		rep( j, 1, K ) 
			if( ((i - j) != j) && ( (i - j) <= K ) && ( (i - j) >= 1 ) ) ++ u ; 
			else if( (i - j) != j ) ++ v ;
		u /= 2, v += u ; 
		if( i % 2 == 0 ) ++ u ; 
		for( re int j = 0; j <= n; ++ j ) {
			Ans[i] = ( Ans[i] + C[u][j] * C[(n - j) + v - 1][(n - j)] % P ) % P ;
		}
	}
	rep( i, 2, 2 * K ) printf("%lld\n", Ans[i] ) ;
	return 0 ;
}

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

int main()
{
	int n;
	cin >> n;
	auto p = vector<int>(n);
	for(auto&& pp : p) cin >> pp;
	int ans = 0;
	for(auto i = 1; i < n - 1; ++i){
		if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
a=int(s[:2])
b=int(s[2:])
if 0<a<13 and 0<b<13:
  print('AMBIGUOUS')
elif 0<a<13:
  print('MMYY')
elif 0<b<13:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#i don't know anything
N,A,B,C = map(int,input().split())

mod = 10**9 + 7

factrial = [1] * (2*N)
pa = [1] * (2*N)
pb = [1] * (2*N)
pab = [1] * (2*N)
for k in range(1, 2*N):
    factrial[k] = (factrial[k-1] * k) % mod
    pa[k] = (pa[k-1] * A) % mod
    pb[k] = (pb[k-1] * B) % mod
    pab[k] = (pab[k-1] * (A+B)) % mod
    
fact_inv = [1] * (2*N)
fact_inv[2*N-1] = pow(factrial[2*N-1], mod - 2, mod)
pab_inv = [1] * (2*N)
pab_inv[2*N-1] = pow(pab[2*N-1], mod - 2, mod)
for k in range(2*N-2, -1, -1):
    fact_inv[k] = (fact_inv[k+1] * (k+1)) % mod
    pab_inv[k] = (pab_inv[k+1] * (A+B)) % mod
 
def comb_mod(n, r, mod=10**9+7):
    return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % mod

ans = 0
for m in range(N, 2*N):
    Em = (comb_mod(m-1, N-1) * (pa[N]*pb[m-N] + pa[m-N]*pb[N]) * pab_inv[m] * m * 100 * pow(100-C, mod-2, mod)) % mod

    ans = (ans + Em) % mod

print(ans)

Measured memory_bytes: 81852
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

int main() {

    long int n;

    scanf("%ld", &n);

    if (n % 2 != 0) {
        printf("0");
        return 0;
    }

    long int temp_sum = 0;

    long int product = 0;

    long int ans = 0;

    for (long int i=1; i <= 25; i++) {
        long int den = 10 * (long int)(powl(5, 25-i));
        product = n / den;
        ans += (26-i)*(product - temp_sum);

        temp_sum = product;
    }

    printf("%ld", ans);
    return 0;


}


Measured memory_bytes: 128
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(list(map(int, input().split())))

moves = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                if j == w - 1 and i != h - 1:
                    a[i+1][j] += 1
                    moves.append((i+1, j+1, i+2, j+1))
                elif j != w - 1:
                    a[i][j+1] += 1
                    moves.append((i+1, j+1, i+1, j+2))
    else:
        for j in range(w-1, -1, -1):
            if a[i][j] % 2 == 1:
                if j == 0 and i != h - 1:
                    a[i+1][j] += 1
                    moves.append((i+1, j+1, i+2, j+1))
                elif j != 0:
                    a[i][j-1] += 1
                    moves.append((i+1, j+1, i+1, j))

print(len(moves))
for m in moves:
    print(' '.join(map(str, m)))


Measured memory_bytes: 26280
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

long long N, A[1 << 18], B[1 << 18];
long long Answer = -1;

bool solve(long long lim) {
	for (int i = 0; i <= N; i++) B[i] = 0;
	for (int i = N; i >= 1; i--) {
		B[i] += A[i];
		long long f1 = (B[i] + 1LL) / 2LL;
		long long f2 = B[i];
		if (lim >= f2 - f1) {
			B[i - 1] += f2;
			lim -= (f2 - f1);
		}
		else {
			B[i - 1] += (f1 + lim);
			lim = 0;
		}
	}
	B[0] += A[0];
	if (B[0] >= 2) return false;

	long long sum = 0;
	for (int i = 0; i <= N; i++) sum += B[i];
	Answer = max(Answer, sum);
	return true;
}

int main() {
	cin >> N;
	for (int i = 0; i <= N; i++) cin >> A[i];
	
	long long cl = 0, cr = (1LL << 60), cm;
	for (int i = 0; i < 65; i++) {
		cm = (cl + cr) / 2;
		bool I = solve(cm);
		if (I == true) { cl = cm; }
		else { cr = cm; }
	}

	if (Answer == -1) cout << "-1" << endl;
	else cout << Answer << endl;
	return 0;
}

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

#define int long long
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

signed main(){
    string s;
    cin>>s;
    int ans=0;
    for(int bit = 0; bit < (1<<(s.size()-1)); ++bit){
        string formula = s;
        int j=1;
        for(int i=0;i<(s.size()-1);i++){
            if(bit & (1<<i)){
                formula.insert(i+j,"+");
                j++;
            }
        }
        int digit = 0;
        int part = 0; 
        for(int i=0;i<formula.size();i++){
            if(formula[i] != '+'){
                part *= 10;
                part += formula[i] - '0';
            }
            else if(formula[i] == '+'){
                ans += part;
                part = 0;
            }     
        }
        ans += part;

    } 

    put(ans);
}


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

int h, w, l;
char S[10][10010];

int main()
{
	scanf ("%d %d %d", &h, &w, &l);
	for (int i = 0; i < h; i++) scanf ("%s", S[i]);

	int ans = 1000000;
	for (int b = 0; b < (1 << (h - 1)); b++){
		int cut = 0, cnt[10] = { 0, }, cut2 = 0;
		for (int i = 1; i < h; i++) if (b & (1 << (i - 1))) cut++;
		for (int j = 0; j < w; j++){
			int k = 0;
			cnt[0] += (S[0][j] == '1');
			for (int i = 1; i < h; i++){
				if (b & (1 << (i - 1))) k++;
				cnt[k] += (S[i][j] == '1');
			}

			bool g = 1;
			for (int k = 0; k <= cut; k++) if (cnt[k] > l) g = 0;
			if (!g){
				for (int k = 0; k <= cut; k++) cnt[k] = 0;

				int k = 0;
				cnt[0] += (S[0][j] == '1');
				for (int i = 1; i < h; i++){
					if (b & (1 << (i - 1))) k++;
					cnt[k] += (S[i][j] == '1');
				}

				bool g = 1;
				for (int k = 0; k <= cut; k++) if (cnt[k] > l) g = 0;
				if (!g){
					cut2 = -1;
					break;
				}
				cut2++;
			}
		}

		if (cut2 >= 0){
			if (ans > cut + cut2)
				ans = cut + cut2;
		}
	}

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

	return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
 
int puz[3][3];
int tmp[3][3];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);
 
 
int main() {
    int i,j,ans,x,y,l;
     
    //puzzle input
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) scanf("%d",&puz[i][j]);
    }
     
     
    empty(&x,&y);
    for(l=0; l<100; l++) {
        //copy
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) tmp[i][j] = puz[i][j];
        }
         
        //dfs
        ans = dfs(x,y,-1,0,l);
        if(ans!=-1) {
            printf("%d\n",ans);
            break;
        }
         
        //copy
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) puz[i][j] = tmp[i][j];
        }
         
        //error
        ans = -1;
        if(l==99) printf("%d\n",ans);
    }
     
    //ans output
    //printf("%d\n",ans);
     
    return 0;
}
 
 
void empty(int *x,int *y) {
    int i,j;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            if(!puz[i][j]) {
                *x = j;
                *y = i;
                return;
            }
        }
    }
}
 
 
void swap(int *a,int *b) {
    int tmp;
     
    tmp = *a;
    *a = *b;
    *b = tmp;
}
 
 
int cal() {
    int i,a,sum=0;
     
    for(i=0; i<9; i++) {
        a = puz[i/3][i%3];
        if(a) {
            a--;
            sum += abs(i/3 - a/3) + abs(i%3 - a%3);
        }
    }
     
    return sum;
}
 
 
int dfs(int x,int y,int p,int dep,const int lim) {
    int i,h,nx,ny,res;
     
    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;
     
    for(i=0; i<4; i++) {
        nx = x+dx[i];
        ny = y+dy[i];
         
        if(~p && i==(p+2)%4) continue;
        if(!(0<=nx && nx<3 && 0<=ny && ny<3)) continue;
         
        swap(&puz[y][x],&puz[ny][nx]);
        res = dfs(nx,ny,i,dep+1,lim);
        if(~res) return res;
         
        swap(&puz[y][x],&puz[ny][nx]);
    }
     
    return -1;
}

Measured memory_bytes: 600
using System;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int i = 0;
            int[] array = new int[5];
            while (true)
            {
                if (i == 5) break;
                array[i] = int.Parse(input[i]);
                if (array[i] == 0)
                {
                    Console.WriteLine(i + 1);
                }
                i++;
            }
        }
    }
}


Measured memory_bytes: 17612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++)
    cin>>h.at(i);
  sort(h.begin(),h.end());
  int m=h.at(n-1)-h.at(0);
  for(int i=k-1;i<n;i++)
    m=min(m,h.at(i)-h.at(i-(k-1)));
  cout<<m<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
int m[3] = {0};

int is(double a){
	if(abs(a) < EPS)return 1;
	if(a < 0)return 0;
	if(a > 0)return 2;
}

double mysqrt(double x){
	double l = 0 , r = x;
	for(int i = 0 ; i < 64 ; i++){
		double m = (l+r) / 2.0;
		if(m * m < x) l = m;
		else r = m;
	}
	return l;
}

double solve(double a,double b,double c,double d){
	//cout << a << " " << b << " " << c << " " << d << endl;
	if(abs(a) < EPS){
		if(c * c - 4 * b * d < -EPS)return 0.0;
		double one = ( -c + mysqrt(c*c-4*b*d)  )/(2*b);
		double two = ( -c - mysqrt(c*c-4*b*d)  )/(2*b);
		//cout << one << "<>" << two << endl;
		m[is(one)]++;
		m[is(two)]++;
		return 0.0;
	}
	
	double l = -1000.0 , r = 1000.0;
	
	if(a < 0){ a *= -1; b *= -1; c *= -1; d *= -1;}
	
	for(int i=0;i<64;i++){
		double x = (l+r)/2.0;
		double res = a*x*x*x+b*x*x+c*x+d;
		if(res>0){
			r = x;
		}else{
			l = x;
		}
	}
	
	return l;
}
int main(){
	int N; cin >> N;
	while(N--){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		m[0] = m[1] = m[2] = 0;
		
		double n = solve(a,b,c,d); // Oûö®ÉÍK¸êÂÈãÀªªÜÜêÄ¢éÌÅA»êð©Â¯éB
		m[is(n)]++;
		
		solve(0,a,a*n+b,n*(a*n+b)+c);
		cout << m[2] << " " << m[0] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
 
int N, A[200000];

ll score(int b) {
    ll res = 0;
    REP(i, N) res += abs(A[i] - b);
    return res;
}

pll search() {
    ll l = -1000000000, r = 1000000000;
    while (r - l >= 3) {
        ll m1 = (2 * l + r) / 3;
        ll m2 = (l + 2 * r) / 3;

        if (score(m1) < score(m2))
            r = m2;
        else
            l = m1;
    }
    return pll(l, r);
}
 
int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= i;
    }

    pll p = search();
    ll ans = score(p.second);
    FOR(x, p.first, p.second) {
        ans = min(ans, score(x));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, ans = 0;
    string s, t, r;

    cin >> n;
    cout << n / 3 << endl;

}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    string s;
    cin>>s;
    lg len=0;
    lg ans=0;
    for(lg i=0;i<s.length();i++)
    {
        if(s[i]=='R') len++;
        else
        {
            ans=max(ans,len);
            len=0;
        }
    }
    ans=max(ans,len);

    cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if((a==5 && b==7 && c==5) ||(a==5 && b==5 && c==7) || (a==7 && b==5 && c==5)){
        printf("YES\n");
    }
    
    else{
        printf("NO\n");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

struct range {
    int start, end;
};

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    S.push_back('1');
    vector< range > v0;
    char cur = S[0];
    int s = 0;
    range tmp = {-1, -1};
    v0.push_back(tmp);
    for (int i = 1; i <= N; i++) {
        if (S[i] != cur) {
            if (cur == '0') {
                range tmp = {s, i - 1};
                v0.push_back(tmp);
                cur = '1';
            } else {
                cur = '0';
            }
            s = i;
        }
    }
    tmp = {N, N};
    v0.push_back(tmp);

    // for (int i = 0; i < v0.size(); i++) {
    //     cout << i << ": " << v0[i].start << " " << v0[i].end << endl;
    // }

    if (v0.size() - 2 <= K) {
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    for (int i = 1; i + K < v0.size(); i++) {
        // cout << i << ": " << v0[i].start << " " << v0[i].end << endl;
        ans = max(ans, v0[i + K].start - 1 - v0[i - 1].end);
    }

    cout << ans << endl;
}

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

int solve(int N, vector<int> skewers)
{
    sort(begin(skewers), end(skewers), greater<int>());
    auto result = 0;
    for (auto i = 0; i < N; i++)
        result += skewers[2*i+1];
    return result;
}

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

    auto skewers = vector<int>(2*N);
    for (auto& x : skewers)
        cin >> x;

    cout << solve(N, skewers) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[111];
void rec(int I, int c) {
    if (I == N) {
	puts(S);
    } else {
	for (char x='a'; x<=c && x<='z'; x++) {
	    S[I] = x;
	    rec(I+1, max(x+1, c));
	}
    }
}

void MAIN() {
    scanf("%d", &N);
    rec(0, 'a');
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<set<char>> digit1(N), digit3(N);
    set<char> set;
    set.insert(S[0]);
    digit1[0] = set;
    for (int i = 1; i < N; ++i) {
        set.insert(S[i]);
        digit1[i] = set;
    }

    set.clear();

    set.insert(S.back());
    digit3[N - 1] = set;
    for (int i = N - 2; i >= 0; --i) {
        set.insert(S[i]);
        digit3[i] = set;
    }

    map<string, int> m;
    for (int i = 1; i < N - 1; ++i) {
        for (char c1 : digit1[i - 1]) {
            for (char c3 : digit3[i + 1]) {
                string res = "";
                res.push_back(c1);
                res.push_back(S[i]);
                res.push_back(c3);
                m[res]++;
            }
        }
    }

    cout << m.size() << endl;
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}

int main()
{
    int N;
    cin>>N;
    vvint graph(N);
    int a,b;
    for (size_t i = 0; i < N-1; i++)
    {
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vint c(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>c[i];
    }
    sort(all(c),greater<int>());
    vint ans(N);
    queue<int> q;
    q.push(0);
    int idx=0;
    while(!q.empty())
    {
        int p = q.front();
        ans[p] = c[idx];
        q.pop();
        for (auto &&i : graph[p])
        {
            if(ans[i] != 0)
            continue;
            q.push(i);
        }
        idx++;
    }
    cout<<accumulate(all(c),0LL) - c[0]<<endl;
    for (auto &&i : ans)
    {
        cout<<i<<" ";
    }
    
    return 0;
}

Measured memory_bytes: 4088
#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--)

class UnionFind {
public:
  int k;
  vector<int> o;
  void init(int n) {
    k = n;
    o.resize(n, -1);
  }
  int find(int n) {
    if(o[n] < 0) {
      return n;
    }
    return o[n] = find(o[n]);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a != b) {
      k--;
      o[a] = b;
    }
  }
  int num() {
    return k;
  }
};

int a[114514];
int b[114514];

signed main() {
  int n;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }
  int all = 0;
  rep(i, n) {
    all = all ^ a[i];
  }
  int ans = 0;
  map<int, int> mp;
  mp[all]++;
  vector<int> v;
  rep(i, n) {
    if(a[i] != b[i]) {
      ans++;
      v.push_back(a[i]);
      v.push_back(b[i]);
    }
    mp[a[i]]++;
  }
  v.push_back(all);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  rep(i, n) {
    if(mp[b[i]] == 0) {
      cout << -1 << endl;
      return 0;
    }
    mp[b[i]]--;
  }
  UnionFind uf;
  uf.init(v.size());
  rep(i, n) {
    if(a[i] != b[i]) {
      uf.unite(lower_bound(v.begin(), v.end(), a[i]) - v.begin(), lower_bound(v.begin(), v.end(), b[i]) - v.begin());
    }
  }
  cout << ans + uf.num() - 1 << endl;
}


Measured memory_bytes: 11376
import sys

def main():
    N = int(input())
    p = list(map(int, input().split()))
    q = sorted(p)
    d = 0
    for i in range(N):
        if p[i] != q[i]:
            d += 1

    if d == 0 or d == 2:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MAX = 1e18;

int main() {
int x, n, i, p;
cin >> x >> n;
pair<int, int> ans(9999, -1);
vector<int> d(102);
for(i = 0; i < n; i++){
    cin >> p;
    d.at(p) = 1;
}
for(i = 0; i <= 101; i++){
    if(d.at(i) == 1){
        continue;
    }
    int dif = abs(x - i);
    ans = min(ans, make_pair(dif, i));
}
cout << ans.second << endl;

return 0;
}


Measured memory_bytes: 3616
package main
import . "fmt"
var min int
var d []int = []int{
  59049,
  46656,
  7776,
  6561,
  1296,
  729,
  216,
  81,
  36,
  9,
  6,
  1,
}
func main() {
  var n,m int
  Scan(&n)
  min = 0
  m = n
  for i:=0;i<12;i++ {
    min += m/d[i]
    m %= d[i]
  }
  withdraw(0,0,n)
  Println(min)
}
func withdraw(i int,x int,n int) {
  if x+n/d[i] >= min { return }
  if i == 11 {
    x += n
    if x < min { min = x }
    return
  }
  for j:=n/d[i];j>=0;j-- {
    withdraw(i+1,x+j,n-j*d[i])
  }
  return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int dp[300100];
vector<int> v; 
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int seed=1;
	v.push_back(seed);
	seed*=6;
	while(seed<=n){
		v.push_back(seed);
		seed*=6;
	}
	seed=9;
	while(seed<=n){
		v.push_back(seed);
		seed*=9;
	}
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<=100000;i++){
		for(int j=0;j<v.size();j++){
			dp[i+v[j]]=min(dp[i+v[j]],dp[i]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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


int main(){
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());

    int e = 0;
    for(int i : v) if(i%2==0) e++;

    int ans = 0;
    if(e == 0){
        ans += (v[2]-v[0])/2;
        ans += (v[2]-v[1])/2;
    }else if(e == 1){
        for(int i = 0; i < 3; i++) if(v[i]%2) v[i]++;
        ans++;
        sort(v.begin(), v.end());
        ans += (v[2]-v[0])/2;
        ans += (v[2]-v[1])/2;
    }else if(e == 2){
        for(int i = 0; i < 3; i++) if(v[i]%2==0) v[i]++;
        ans++;
        sort(v.begin(), v.end());
        ans += (v[2]-v[0])/2;
        ans += (v[2]-v[1])/2;
    }else{
        ans += (v[2]-v[0])/2;
        ans += (v[2]-v[1])/2;
    }
    cout << ans << endl;
}

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


using namespace std;


int main(void){
  
  string s;
  string ans="Yes";
  
  cin >> s;
  
   
  for(int i = 0; i< s.size()  ;i++){
    if(s[i] != s[s.size()-1-i] ){
      ans = "No";
      break;
    }
  }

  
  for(int i = 0; i< (s.size()-1)/2  ;i++){
    if(s[i] != s[(s.size()-1)/2-1-i] ){
      ans = "No";
      break;
    }
  }

  for(int i = (s.size()+3)/2; i< s.size()  ;i++){
    if(s[i] != s[s.size()-i-1]){
      ans = "No";
      break;
    }
  }

 
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int m = n;
	int sum = 0;
	while( m ) {
		sum += m % 10;
		m /= 10;
	}
	
	if( n % sum == 0 ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, m, ans, x, y, a[10];
bool edge[10][10];

int main () {
	
	scanf("%d%d", &n, &m);
	
	FOR(i, 0, m) {
		scanf("%d%d", &x, &y);
		edge[x][y] = edge[y][x] = 1;
	}
	
	FOR(i, 0, n) a[i] = i + 1;
	
	do {
		bool ok = 1;
		FOR(i, 1, n) if (edge[a[i]][a[i - 1]] == 0) ok = 0;
		if (ok) ans++;
	} while (next_permutation(a + 1, a + n));
	
	printf("%d\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DUMP(x) cout << #x << " = " << (x) << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

int main() {
  int n; cin >> n;
  VI a(n);
  REP(i, n) {
    cin >> a[i];
  }
  int ans = 0;
  bool isAble = true;
  do {
    REP(i, n) {
      if (a[i] % 2 == 0) isAble = isAble and true;
      else isAble = isAble and false;
    }
    if (isAble) {
      REP(i, n) {
        a[i] = a[i] >> 1;
      }
      ans++;
    }
  } while (isAble);
  cout << ans << endl;
  return 0;
}

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

signed main(){
    vector<int> A(5);
    for(int i=0;i<5;i++)cin>>A[i];
    int k; cin>>k;
    sort(A.begin(),A.end());
    cout<<((A[4]-A[0])<=k ? "Yay!" : ":(")<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = 1e18;
typedef long double ld;

lint N, W, weight_base, w, v;
plint arr[100];
lint dp[101][101][400];//どこまで見たか,いくつ選んだか,選んだ重さからbase引いたものはいくつか
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> W;
	fill((long long*)dp, (long long*)dp + sizeof(dp) / sizeof(long long), 0);
	cin >> weight_base >> v;
	arr[0] = { 0, v };
	REP(i, N - 1) {
		cin >> w >> v;
		arr[i + 1] = { w - weight_base, v };
	}
	dp[0][0][0] = 0;
	REP(i, N) {
		REP(j, N) {
			REP(k, 301) {
				chmax(dp[i + 1][j + 1][k + arr[i].first], dp[i][j][k] + arr[i].second);
				chmax(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}

	lint maxv = 0;
	// 重さの計算　いくつ選んだか*base_weight + 超過分
	REP(i, N + 1) {
		REP(j, 301) {
			if (W < i * weight_base + j) continue;
				chmax(maxv, dp[N][i][j]);
		}
	}
	cout << maxv << endl;
}


Measured memory_bytes: 32128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String t = sc.nextLine();
        String ret = t.replace("?", "D");
//       String ret = t.replace("?D", "PD");
//       ret = t.replace("?", "D");

        System.out.printf(ret);
    }
}


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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define GREP(a, b) for (register int a = G.first[b]; a; a = G.edge[a].nxt)
#define FREP(a, b) for (register int a = F.first[b]; a; a = F.edge[a].nxt)

const int SIZE = 2505;

int n, m, p;

struct Edge {
    int v, dis, nxt;
}; 

struct Graph {
    int first[SIZE], ecnt;
    Edge edge[SIZE << 1];
    void Add_Edge (int u, int v, int dis) {
        ++ecnt;
        edge[ecnt].v = v;
        edge[ecnt].dis = dis;
        edge[ecnt].nxt = first[u];
        first[u] = ecnt;
    }
} G, F;

bool mark[SIZE], inq[SIZE];
int cnt[SIZE];
long long dis[SIZE];
long long SPFA () {
    queue<int> Q;
    memset(dis, 127, sizeof dis);
    dis[1] = 0;
    Q.push(1);
    cnt[1] = 1;
    inq[1] = 1;
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        inq[u] = 0;
        GREP (i, u) {
            Edge& e = G.edge[i];
            if (mark[e.v] && dis[e.v] > dis[u] + e.dis) {
                dis[e.v] = dis[u] + e.dis;
                if (!inq[e.v]) {
                    inq[e.v] = 1;
                    Q.push(e.v);
                    if (++cnt[e.v] == n) return -1;
                }
            }
        }
    }

    dis[n] = -dis[n];
    if (dis[n] < 0) return 0;
    return dis[n];
}

void _main () {
    scanf ("%d%d%d", &n, &m, &p);

    REP (i, 1, m) {
        int u, v, d;
        scanf ("%d%d%d", &u, &v, &d);
        G.Add_Edge(u, v, p - d);
        F.Add_Edge(v, u, p - d);
    }

    queue<int> Q;
    Q.push(n);
    mark[n] = 1;
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        FREP (i, u) {
            Edge& e = F.edge[i];
            if (!mark[e.v]) Q.push(e.v), mark[e.v] = 1;
        }
    }

    printf ("%lld\n", SPFA());
    
}

int main () {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    _main();   
    return 0;
}


Measured memory_bytes: 384