akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}  
void solve()
{ 
 ll n,x,t;
 cin>>n>>x>>t;
 ll k= (n/x);
 if(n%x) k++;
 cout<<(t*k)<<kl;
}
int main() 
{ 
    // lop
    solve();
	return 0; 
} 




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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int D; 
int c[30];
int s[400][30];
int t[400];


ll cal_score(int temp[]){
    int last[30] = {0};
    ll score = 0;
    for(int d=1;d<=D;++d){
        int i = temp[d];
        score += s[d][i];
        last[i] = d;
        for(int j=1;j<=26;++j){
            score -= c[j]*(d-last[j]);
        }
        //cout << score << "\n";
    }
    return score;
}

int main(){
    cin >> D;
    for(int i=1;i<=26;++i){ cin >> c[i]; }
    for(int d=1;d<=D;++d){ for(int i=1;i<=26;++i){ cin >> s[d][i]; } }
    
    int score_max = 0;
    
	random_device rand_d;
    default_random_engine e1(rand_d());
    uniform_int_distribution<int> uniform_dist(1, 26);   
    
    REP(count,40000){
        int temp[400];
        for(int d=1;d<=D;++d){
            temp[d] = uniform_dist(e1);
            for(int i=1;i<=26;++i){
                if((double)s[d][i]>(double)s[d][temp[d]]*1.3){
                    temp[d] = i;
                }
            }
        }
        if(cal_score(temp)>score_max){
            for(int d=1;d<=D;++d){
                t[d] = temp[d];
            }
        }
    }
    for(int d=1;d<=D;++d){
        cout << max(t[d]%27,1) << "\n";
    }
    if(DEBUG){
        cout << cal_score(t) << "\n";
    }
}


Measured memory_bytes: 3680
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

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

int main(){
 
  int d; cin >> d;
  
  if(d == 25)
    pr("Christmas");
  else if(d == 24)
    pr("Christmas Eve");
  else if(d == 23)
    pr("Christmas Eve Eve");
  else if(d == 22)
    pr("Christmas Eve Eve Eve");

  return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	cout << (n/500*1000+(n%500)/5*5);

	return 0;
}



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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
char str[20];

int main() {
    scanf("%s", str + 1);
    int len = strlen(str + 1);
    if (len & 1) {
        puts("No");
        return 0;
    }
    for (int i = 2; i <= len; i += 2) {
        if (str[i - 1] == 'h' && str[i] == 'i')continue;
        else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 3720
# from abs import math
n = int(input())
tmpt = 0
tmpx, tmpy = 0, 0
c = 0

def check(t, x, y):
    if t>=x+y and ( (t%2==0 and (x+y)%2==0) or (t%2==1 and (x+y)%2==1) ):
        return True
    else:
        return False

for i in range(n):
    t, x, y = map(int, input().split())
    if x==tmpx and y==tmpy:
        break   

    target = t-tmpt
    tmpt = t
    t_x, t_y = abs(x-tmpx), abs(y-tmpy)
    tmpx = x
    tmpy = y
    if check(target, t_x, t_y):
        c+=1
    else:
        break

if n==c:
    print('Yes')
else:
    print('No')



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 N;
string s;


int main() {
    cin >> s;
    N = s.length();

    string sr = s;
    reverse(sr.begin(), sr.end());
    if (s != sr) {
        cout << "No" << endl;
        return 0;
    }

    string ss;
    ss = s.substr(0, (N - 1) / 2);
    sr = ss;
    reverse(sr.begin(), sr.end());
    if (ss != sr) {
        cout << "No" << endl;
        return 0;
    }

    ss = s.substr((N + 3) / 2 - 1);
    sr = ss;
    reverse(sr.begin(), sr.end());
    if (ss != sr) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int h,w;

    cin >> h >> w;
    
    vector<vector<int>> a(h,vector<int>(w,0));
    queue<vector<int>> que;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char tmp;
            cin >> tmp;
            if(tmp=='.'){
                a[i][j]=-1;
            }else{
                que.push({i,j});
            }
        }
    }

    vector<int> x = {1,-1,0,0};
    vector<int> y = {0,0,1,-1};
    int num;

    while(!que.empty()){
        auto now = que.front();
        que.pop();

        for(int k=0; k<4; k++){
            if(now[0]+x[k]<0 || now[0]+x[k]>h-1 || now[1]+y[k]<0 || now[1]+y[k]>w-1) continue;

            if(a[now[0]+x[k]][now[1]+y[k]]==-1){
                a[now[0]+x[k]][now[1]+y[k]]=a[now[0]][now[1]]+1;
                que.push({now[0]+x[k],now[1]+y[k]});
            }
        }
        if(que.empty()){
            num=a[now[0]][now[1]];
        }
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 59572
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] HW = br.readLine().split(" ");
        int H = Integer.parseInt(HW[0]);
        int W = Integer.parseInt(HW[1]);
        String[] hw = br.readLine().split(" ");
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);
        
        
        System.out.println(H*W-h*W-w*(H-h));
    }
}



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

using namespace std;

using ll = long long;

constexpr int kMaxN = 1e5 + 3;

vector<int> edges[kMaxN];

ll mod;

ll add(ll a, ll b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
  return a;
}

ll mul(ll a, ll b) {
  return a * b % mod;
}

using pll = pair<ll, ll>;

pll merge(pll a, pll b) {
  pll res;

  res.first = mul(a.first, b.first);
  res.second = add(
      mul(a.second, add(b.first, b.second)),
      mul(a.first, b.second)
  );

  return res;
}

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

  ll n;
  cin >> n >> mod;

  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    edges[x].emplace_back(y);
    edges[y].emplace_back(x);
  }

  vector<ll> ans(n);
  vector<pll> dp(n);

  function<pll(int, int)> dfs = [&] (int u, int p) {
    // first - white, second - black
    pll cur{1, 0};
    for (int v: edges[u]) {
      if (v != p) {
        auto res = dfs(v, u);
        cur = merge(cur, res);
      }
    }

    dp[u] = {cur.first, add(cur.first, cur.second)};

    return dp[u];
  };

  dfs(0, -1);

  function<void(int, int, pll)> fill_ans = [&] (int u, int p, pll up) {

    vector<pll> subtree;
    pll cur{1, 0};
    for (int v: edges[u]) {
      if (v != p) {
        subtree.emplace_back(dp[v]);
      }
    }

    vector<pll> pref, suf;
    cur = {1, 0};
    pref.emplace_back(1, 0);
    for (int i = 0; i < subtree.size(); ++i) {
      cur = merge(cur, subtree[i]);
      pref.emplace_back(cur);
    }

    cur = {1, 0};
    for (int i = subtree.size() - 1; i >= 0; --i) {
      cur = merge(cur, subtree[i]);
      suf.emplace_back(cur);
    }
    reverse(suf.begin(), suf.end());
    suf.emplace_back(1, 0);

    pll tmp = merge(up, pref.back());
    ans[u] = add(tmp.first, tmp.second);

    int i = 0;
    for (int v: edges[u]) {
      if (v != p) {
        tmp = up;
        tmp = merge(tmp, pref[i]);
        tmp = merge(tmp, suf[i + 1]);
        tmp.second = add(tmp.first, tmp.second);
        fill_ans(v, u, tmp);
        ++i;
      }
    }
  };

  fill_ans(0, -1, {1LL, 0LL});

  for (ll a: ans) {
    cout << a << '\n';
  }

  return 0;
}


Measured memory_bytes: 34688
// 2017/09/26
#include<iostream>
using namespace std;
int main()
{
	int i, j, H, W;
	while(1)
	{
		cin >> H >> W;
		if ((H==0) && (W==0)) break;
		for ( i=0; i<H; i++)
		{
			for ( j=0; j<W; j++)
			{
				if ((i==0) || (i==H-1) || (j==0) || (j==W-1)) {
					cout << "#";
					} 
					else {
					cout << "." ;
					}
			}
			cout << endl; // ??????
		}
		cout << endl; //??????
	}
	return 0;
}

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

int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	int xa = min(a,k);
	k -= xa;
	int xb = min(b,k);
	k -= xb;
	cout << xa -k << endl;
}

Measured memory_bytes: 3592
n, d, a = map(int, input().split())
xh = []
for _ in range(n):
    x, h = map(int, input().split())
    h = (h+a-1)//a
    xh.append([x, h])

xh.sort(key=lambda x:x[0])

def bisect(x):
    i_min=0
    i_max=n
    while i_min<i_max:
        i = (i_min+i_max)//2
        if xh[i][0]<=x:
            i_min = i+1
        else:
            i_max = i
    return i_min

ans = 0
accu = 0
out = [0]*(n+1)
for i, (x, h) in enumerate(xh):
    accu -= out[i]
    hp = h-accu
    if hp<=0:
        continue
    accu += hp
    ans += hp
    out[bisect(x+2*d)] += hp 
print(ans)

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

LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}


Measured memory_bytes: 4392
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    println!("{}", a * b);
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s = "MARCH";
    int c[5] = {0, 0, 0, 0, 0};
    int N;
    cin >> N;
    rep(i, N) {
        string t;
        cin >> t;
        rep(j, 5) {
            if(t[0] == s[j]) {
                c[j]++;
            }
        }
    }

    ll ans = 0;
    rep(i, 5) {
        for(int j = i+1; j < 5; j++) {
            for(int k = j+1; k < 5; k++) {
                ans += (ll)c[i]*c[j]*c[k];
            }
        }
    }

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

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

using namespace std;

const int MOD = 1000000007;

int n, m;
string s;
int dp[212123];
int dpsum[212123];
bool nonmono;

// msize EVEN
void non(int msize) {
	assert(msize % 2 == 0);
	dp[0] = 1;
	dpsum[0] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = dpsum[i-2];
		if (i-msize-2 >= 0) {
			dp[i] += MOD - dpsum[i-msize-2];
			dp[i] %= MOD;
		}
		dpsum[i] = (dp[i] + dpsum[i-2]) % MOD;
	}
	int ans = dp[n];
	for (int i = 1; i < n; i++) {
		// first colour must be i + 1 + evener
		int x = i + 1;
		if (x % 2 != 0) x++;
		// x now even
		if (x > msize) break;
		ans = (ans + dpsum[n-x]) % MOD;
		if (n-msize-2 >= 0) {
			ans += MOD - dpsum[n-msize-2];
			ans %= MOD;
		}
	}
	cout << ans << '\n';
}

void mono() {
	dp[0] = 1;
	dpsum[0] = 1;
	dpsum[1] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = dpsum[i-2];
		dpsum[i] = (dpsum[i-1] + dp[i]) % MOD;
	}
	int ans = dp[n] + 1;
	for (int i = 0; i <= n-2; i++) {
		ans = (ans + dpsum[i]) % MOD;
	}
	cout << ans << '\n';
}

int main() {
	cin >> n >> m >> s;
	for (int i = 1; i < m; i++) {
		if (s[i] != s[0]) {
			nonmono = true;
			break;
		}
	}
	if (nonmono) {
		int msize = n;
		if (msize % 2 == 1) msize--;
		int fcur = -1;
		int cur = 0;
		for (int i = 0; i < m; i++) {
			if (s[i] == s[0]) cur++;
			else if (cur) {
				if (fcur == -1) fcur = cur;
				if (cur % 2 == 1) {
					cur++;
					msize = min(msize, cur);
				}
				cur = 0;
			}
		}
		fcur += 2;
		if (fcur % 2 == 1) fcur--;
		msize = min(fcur, msize);
		//cout << msize << '\n';
		non(msize);
	} else {
		mono();
	}
	return 0;
}



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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

typedef long long ll;

using namespace std;

const int N = 123, mod = (int)1e9 + 7, inf = (int)1e9;
const ll INF = (ll)1e18;

int n, m, k, cur, a[N * N], b[N][N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(NULL);

	cin >> n >> m >> k;

	for(int i = 1; i <= k; ++i)
		cin >> a[i];

	for(int i = 1; i <= n; ++i){
		if(i & 1){
			for(int j = 1; j <= m; ++j){
				if(a[cur] == 0)
					cur++;
				b[i][j] = cur;
				a[cur]--;
			}	
		}else{
		    for(int j = m; j >= 1; --j){
				if(a[cur] == 0)
					cur++;
				b[i][j] = cur;
				a[cur]--;
			}
		}
	}

	for(int i = 1; i <= n; ++i, cout << endl)
	for(int j = 1; j <= m; ++j)
		cout << b[i][j] << " ";

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		int a = sc.nextInt();

		int h = a / 3600;
		int m = (a - (h * 3600)) / 60;
		int s = (a - ((h * 3600) + (m * 60)));

		System.out.println(h + ":" + m + ":" + s);

	}
}



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

int main() {
  int A, B,C;
  string op;
  cin >> A >> B;
	C = (A*B)%2;
  if(A%2==0|B%2==0){
  cout<<"Even"<<endl;}
    else{
    cout<<"Odd"<<endl;}
}

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

int main()
{
    int l,r;
    cin >> l >> r;

    int MOD = 2019;
    if(r-l>=MOD)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = MOD;
    rep2(i,l,r)
        rep2(j,i+1,r+1)
        {
            int tmp = (i%MOD) * (j%MOD);
            ans = min(ans, tmp%MOD);
        }

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

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

const ll MOD = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll temp1 = 0;
    for(ll i=0; i<N; i++) {
        for(ll j=i+1; j<N; j++) {
            if(A[i] > A[j]) temp1++;
        }
    }
    temp1 %= MOD;

    ll temp2 = 0;
    for(ll i=0; i<N; i++) {
        for(ll j=0; j<N; j++) {
            if(A[i] > A[j]) temp2++;
        }
    }
    temp2 %= MOD;

    ll temp3 = (temp1 * K) % MOD;
    ll temp4, temp5 = 0;
    if(K%2) {
        temp4 = (temp2 * K) % MOD;
        temp5 += (temp4 * ((K-1)/2)) % MOD;
        temp5 += (temp4 * ((K-1)/2)) % MOD;
    } else {
        temp4 = (temp2 * (K-1)) % MOD;;
        temp5 += (temp4 * (K/2)) % MOD;
        temp5 += (temp4 * (K/2)) % MOD;
    }
    temp5 /= 2;
    temp5 %= MOD;
    ll res = (temp3 + temp5) % MOD;  

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;





int main(){

	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++){
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (a[i][j] == '#'){
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++){
		if (row[i]){
			for (int j = 0; j < w; j++){
				if (col[j]){
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{	
	int i, N, u, w;
	list *adj[200001] = {}, e[400001];
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d\n", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int dist[200001] = {}, q[200001], head, tail;
	list *p;
	q[0] = 1;
	dist[q[0]] = -1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (dist[w] == 0) {
				dist[w] = -1;
				q[tail++] = w;
			}
		}
	}
	q[0] = q[tail-1];
	dist[q[0]] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (dist[w] == -1) {
				dist[w] = dist[u] + 1;
				q[tail++] = w;
			}
		}
	}
	
	if ((dist[q[tail-1]] + 1) % 3 != 0) printf("First\n");
	else printf("Second\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 11036
N = int(input())


def fn(n, a):
    res = 0
    while n > 0:
        res += n % a
        n = n // a
    return res


ans = 1 << 60
for i in range(0, N+1):
    tmp = fn(i, 6) + fn(N - i, 9)
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  int n,i;cin>>n;int a,b;a=0;b=0;
  vint v(n);vint c(n);
  for(i=0;i<n;i++){
    cin>>v[i];
  }
  for(i=0;i<n;i++){
    cin>>c[i];
  }
  //caricurate
  for(i=0;i<n;i++){
   if(v[i]>c[i]){a+=(v[i]-c[i]);} 
    else if(v[i]<c[i]){b+=(c[i]-v[i]);}
  }
  //output
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

vector<ll> divisor(int n){
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(void){
    int a,b;
    cin >> a >> b;
    int n;
    if(b == 100){
        n = 1000 * a + b;
    }
    else if(b >= 10){
        n = 100 * a + b;
    }
    else{
        n = 10 * a + b;
    }

    vector<ll> div = divisor(n);
    if(div.size() % 2 == 0) cout << "No";
    else cout << "Yes";

    return 0;
}

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

long division(long start, long end, long num){
    long first = (start-1)/num;
    long last = end/num;
    return last-first;
}
int main()
{
    long numa , numb , numc , numd;
    cin >> numa >> numb >> numc >> numd;
    if(numc == numd){
        cout << numb - numa + 1 - division(numa, numb, numc) << endl;
        return 0;
    }
    if((numc-1)*(numd-1)==0){
        cout << '0' << endl;
        return 0;
    }
    long divc = division(numa, numb, numc);
    long divd = division(numa, numb, numd);
    if(numc<numd){
        swap(numc, numd);
    }
    long cd=numc*numd;
    long c = numc, d=numd,r;
    r = c%d;
    while(r!=0){
        c = d;
        d = r;
        r = c%d;
    }
    cd /= d;

    long divcd = division(numa, numb, cd);
    cout << numb - numa + 1 - divc - divd + divcd << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

map<ll, ll> m;

// 素因数分解
void prime_factor(int n) {
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            m[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        m[n]++;
    }
}


int main(){
  ll N; cin>>N;
  repn(i,N) prime_factor(i);

  ll ans = 1;
  repn(i,N){
    if(m[i] >= 1) ans *= m[i] + 1;
    ans %= MOD;
  }
  cout<<ans<<endl;
}


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

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

    int a = 0, b = 0, c = 0;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        if(x % 4 == 2) {c=1; continue;}
        if(x % 4 == 0) a++;
        else b++;
    }
    cout << ((a >= b) || (!c && a+1==b) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n, dp[100010], a[100010];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    dp[i]=30000;
  }
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
  }

  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def tento(xs):
    bit = Bit(max(xs)+1)
    ans = 0
    for i, p in enumerate(xs):
        ans += i-bit.sum(p)
        bit.add(p, 1)
    return ans
N = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
us = []
vs = []
for i in range(N):
    a, b = xs[i], ys[i]
    if i%2:
        us.append((a,i))
        vs.append((b,i))
    else:
        us.append((b,i))
        vs.append((a,i))
vs.sort()
r = 10**18
for i in range(2**N):
    t = 0
    tt = 0
    rs = [0]*N
    rs2 = [0]*(N//2)
    for j in range(N):
        if i%2:
            if 2*t < N:
                rs[t*2] = vs[j]
            t += 1
        else:
            if 2*tt+1 < N:
                rs2[tt] = us[vs[j][1]]
            tt += 1
        i = i>>1
    if t != (N+1)//2:
        continue
    rs2.sort()
    for i in range(N//2):
        rs[i*2+1] = rs2[i]
    b,ff = 0,0
    for z,j in rs:
        if b>z:
            ff = 1
            break
        b = z
    if ff:
        continue
#    print(rs)
    rs = [j+1 for _,j in rs]
    r = min(r, tento(rs))
print(r if r != 10**18 else -1)


Measured memory_bytes: 52700
N,M=map(int,input().split())  

par=[i for i in range(N+M)]
rank=[0]*(N+M)
friend=[0]*(N+M)
block=[0]*(N+M)
size=[1]*(N+M)

def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

#同じ集合か判定
def same(x,y):
  return find(x)==find(y)

def union(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 
  if rank[x]>rank[y]:
    par[y]=x
    size[x]+=size[y]
  else:
    par[x]=y
    size[y]+=size[x]
    if rank[x]==rank[y]:
      rank[y]+=1


for i in range(N):
  A=list(map(int, input().split()))
  a=A[0]
  A=A[1:]
  for j in A:
    union(i,N+j-1)
D=[]
for i in range(N):
  D.append(find(i))
if len(set(D))==1:
  print('YES')
else:
  print('NO')

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

int main() {
  int a, b, ans;
  cin >> a >> b;
  if (a >= 13) ans = b;
  else if (a <= 5) ans = 0;
  else ans = b / 2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

class BipMatch {
private:
  int v;
  vector<vector<int> > g;
  vector<int> match;
  vector<bool> used;

  bool dfs(int v) {
    used[v] = true;
    rep (i, g[v].size()) {
      int u = g[v][i], w = match[u];
      if (w < 0 || (!used[w] && dfs(w))) {
	match[v] = u;
	match[u] = v;
	return true;
      }
    }
    return false;
  }

public:
  BipMatch() : v(0) {}

  int next() {
    g.push_back(vector<int>());
    match.push_back(0);
    used.push_back(0);
    return v++;
  }

  void add_edge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
  }

  int run() {
    int res = 0;
    fill(match.begin(), match.end(), -1);
    rep (i, v) if (match[i] < 0) {
      fill(used.begin(), used.end(), 0);
      if (dfs(i)) res++;
    }
    return res;
  }
};

int main() {
  while (true) {
    int n, m, l;
    cin >> n >> m >> l;
    if (n == 0 && m == 0 && l == 0) break;
    int dis[n][n];
    rep (i, n) rep (j, n) dis[i][j] = 1e9;
    rep (i, n) dis[i][i] = 0;
    rep (i, m) {
      int u, v, d;
      cin >> u >> v >> d;
      dis[u][v] = min(dis[u][v], d);
      dis[v][u] = min(dis[v][u], d);
    }
    int p[l], t[l];
    rep (i, l) cin >> p[i] >> t[i];
    rep (k, n) rep (i, n) rep (j, n) dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
    BipMatch bm;
    int left[l], right[l];
    rep (i, l) left[i] = bm.next();
    rep (i, l) right[i] = bm.next();
    rep (i, l) rep (j, l) if (t[i] < t[j] && dis[p[i]][p[j]] <= t[j] - t[i]) bm.add_edge(left[i], right[j]);
    cout << l - bm.run() << endl;
  }
}

Measured memory_bytes: 6680
from itertools import combinations
n = int(input())
s = sorted([int(input()) for _ in range(n)])

ans = sum(s)
if ans % 10 != 0: print(ans)
elif all(i%10 == 0 for i in s): print(0)
else:
  for i in range(1,n):
    for j in combinations(s,i):
      t = sum(j)
      if (ans-t)%10 != 0:
        print(ans-t)
        exit()

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
int N, C;
int d[50][50];
int c[600][600];
long long int x[3][50];
long long int p[50];
pair <long long int , int> P[50];
long long int q[50];
pair <long long int , int> Q[50];
long long int r[50];
pair <long long int , int> R[50];
long long int s[3][3][3];
int main()
{
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 50; j++)
        {
            x[i][j] = 0;
        }
    }
    cin >> N >> C;
    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < C; j++)
        {
            cin >> d[i + 1][j + 1];
        }
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cin >> c[i + 1][j + 1];
        }
    }
    
    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < N; k++)
            {
                for(int l = 0; l < N; l++)
                {
                    if((k + l) % 3 == j)
                    {
                        x[j][i + 1] = x[j][i + 1] + d[c[k + 1][l + 1]][i + 1];
                    }
                }
            }
        }
    }
    
    for(int i = 0; i < C; i++)
    {
        p[i] = x[0][i+1];
        P[i] = make_pair(p[i], i);
        q[i] = x[1][i+1];
        Q[i] = make_pair(q[i], i);
        r[i] = x[2][i+1];
        R[i] = make_pair(r[i], i);
    }
    
    sort(P, P+C);
    sort(Q, Q+C);
    sort(R, R+C);
    
    
    
    
    
    long long int ans = 250000000;
    
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                if(P[i].second != Q[j].second && Q[j].second != R[k].second && R[k].second != P[i].second)
                {
                    s[i][j][k] = P[i].first + Q[j].first + R[k].first;
                }
                else
                {
                    s[i][j][k] = 250000000;
                }
                ans = min(ans, s[i][j][k]);
            }
        }
    }
    cout << ans << endl;
    
    
    
    
    
    

}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

const int limit = 50;

int main() {
	int N; ll Y;
	cin >> N >> Y;
	for (int a = 0; a <= N; a++) {
		for (int b = 0; b <= N; b++) {
			int c = N - a - b;
			if (c >= 0) {
				if (a * 10000LL + b * 5000LL + c * 1000LL == Y) {
					cout << a << " " << b << " " << c << endl;
					return 0;
				}
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    while(a[i]%2!=1){
      a[i]/=2;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
 
Ans = 0
N = int(input())
S = []
T = []
U = []
for _ in range(N):
  S.append(str(input()))
T = ['a'] * N  
U = ['a'] * N
 
for i in range(N):
  U[i] = ''.join(sorted(S[i]))
 
T = sorted(U)
 
j = 0
while j < N:
  for k in range(1,N):
    if j + k == N - 1:
      if T[j] != T[j + k]:
        Ans = Ans + (k-1) * k / 2
      else:
        Ans = Ans + (k+1) * k / 2
        
      print(int(Ans))
      sys.exit()
      
    if T[j] != T[j + k]:
      Ans = Ans + (k-1) * k / 2
      a = k
      break
  
  j = j + a
  
print(int(Ans))

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

using namespace std;

long double x[10], y[10], d[10][10];

long double distance (long double x1, long double x2, long double y1, long double y2) {
	long double x = (x2 - x1) * (x2 - x1);
	long double y = (y2 - y1) * (y2 - y1);
	return (long double) sqrt(x + y);
}	
	
long double factorial(long double n) {
	if (n == 0)
		return 1;
	else 
		return n * factorial(n - 1);
}

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long double n;
	cin >> n;
	vector<int> cities;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i];
		cities.push_back(i);
	}

	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			d[i][j] = d[j][i] = distance(x[i], x[j], y[i], y[j]);
		}
	}

	long double total = 0;
	do {
		for (int i = 0; i < n - 1; ++i) {
			total += d[cities[i]][cities[i + 1]];
		}
	} while(next_permutation(cities.begin(), cities.end()));
	cout << setprecision(12) << total / factorial(n) << '\n';
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	ll n, a, b, c,i,ans=0,pa[111111],pb[111111],rab;
	cin >> n >> a >> b >> c;
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
	rab = modinv(a + b);
	pa[0] = 1;
	pb[0] = 1;
	for (i = 1; i <= n; i++) {
		pa[i] = pa[i - 1] * a%M*rab%M;
		pb[i] = pb[i - 1] * b%M*rab%M;
	}
	for (i = 0; i < n; i++) {
		ans = (ans + pa[n] * pb[i] % M*comb(n + i-1, i) % M*(n+i)%M) % M;
		ans = (ans + pb[n] * pa[i] % M*comb(n + i-1, i) % M*(n+i)%M) % M;
	}
	ans = ans * 100 % M*modinv(100 - c) % M;
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<ll> layers(51,-1);
vector<ll> pt(51,-1);

pair<ll, ll> calc(ll level, ll x){
    ll pre_x = x;
    if(x == 0) return make_pair(0,0);
    if(level == 0){
        return make_pair(1, 1);
    }

    ll ans = 0;
    if(layers[level] != -1 && layers[level] <= x){
        ans = pt[level];
        x -= layers[level];
    } else {
        x--;
        auto tmp = calc(level-1, x);
        ans += tmp.first;
        x -= tmp.second;
        if(x > 0){
            ans++;
            x--;
            if(x > 0){
                tmp = calc(level-1, x);
                ans += tmp.first;
                x -= tmp.second;
                if(x > 0 && layers[level] == -1){
                    layers[level] = pre_x-x+1;
                    pt[level] = ans;
                }
                if(x > 0) x--;
            }
        }
    }

   // cout << "layer:" << level << " num:" << pre_x-x << " pt:" << ans << endl;

    return make_pair(ans, pre_x-x);
}

int main(){
    ll n,x;
    cin >> n >> x;

    auto ans = calc(n,x);
    cout << ans.first << endl;
    
    return 0;
}

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

int n, s1, s2, mx, a[300000];
int main() {
	int i, j;
	cin >> n;
	for(i=0; i<1<<n; i++) scanf("%d", &a[i]);
	for(i=1; i<1<<n; i++) {
		s1=a[0], s2=0;
		for(j=i; j; j=(j-1)&i) {
			if(a[j] > s1) {
				s2 = s1;
				s1 = a[j];
			} else if(a[j] > s2) {
				s2 = a[j];
			}
		}
		mx = max(mx, s1 + s2);
		printf("%d\n", mx);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

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

    int res = 0;
    REP(i, N+1) {
        if(i == 0) continue;

        int num = i;
        int cnt = 0;
        while(true) {
            num = num / 10;
            cnt++;

            if(num == 0) {
                if(cnt % 2 == 1) {
                    res++;
                }
                break;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
using namespace std;

struct UnionFind {
  vector<int> par;
  vector<int> sz;
    
  UnionFind(int n = 210000) { init(n); }
  void init(int n = 210000) {
	par.resize(n); sz.resize(n);
	for (int i = 0; i < n; ++i) par[i] = i, sz[i] = 1;
  }
    
  int root(int x) {
	if (par[x] == x) return x;
	else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
	return root(x) == root(y);
  }

  int size(int x) {
	return sz[root(x)];
  }

  bool direct(int x, int y) {
	x = root(x); y = root(y);
	if (x == y) return false;
	par[x] = y;
	return true;
  }
    
  friend ostream& operator << (ostream& s, UnionFind uf) {
	map<int, vector<int> > res;
	for (int i = 0; i < uf.par.size(); ++i) {
	  int r = uf.root(i);
	  res[r].push_back(i);
	}
	for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
	  s << endl;
	  for (int j = 0; j < (int)it->second.size(); ++j) {
		s << it->second[j] << ", ";
	  }
	}
	return s << endl;
  }
};

typedef pair<long long, long long> pll;

int N, M;
vector<long long> a, b;
vector<vector<int> > G;

bool cmp(int i, int j) {
  return a[i] - b[i] < a[j] - b[j];
}

int main() {
  cin >> N >> M;
  a.resize(N); b.resize(N);
  for (int i = 0; i < N; ++i) {
	cin >> a[i] >> b[i];
  }
  G.clear(); G.resize(N);
  for (int i = 0; i < M; ++i) {
	int u, v; cin >> u >> v; --u, --v;
	G[u].push_back(v); G[v].push_back(u);
  }
  vector<int> ord(N);;
  std::iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), cmp);

  vector<long long> sumB(N), dp(N), seen(N, 0);
  for (int i = 0; i < N; ++i) {
	sumB[i] = b[i];
	dp[i] = max(a[i], b[i]);
  }
  UnionFind uf(N);
  for (auto v : ord) {
	set<int> adj;
	for (auto to : G[v]) {
	  if (!seen[to]) continue;
	  adj.insert(uf.root(to));
	}
	long long tmpsum = b[v];
	for (auto r : adj) {
	  tmpsum += sumB[r];
	  uf.direct(r, v);
	}
	sumB[v] = tmpsum;
	if (!adj.empty()) {
	  long long minv = 1LL<<59;
	  for (auto r : adj) {
		long long subB = tmpsum - sumB[r];
		long long tmp = subB + max(a[v] - b[v], dp[r]);
		minv = min(minv, tmp);
	  }
	  dp[v] = minv;
	}
	seen[v] = true;

	//cout << "-------------------------" << endl;
	//cout << v << ": " << dp[v] << ", " << sumB[v] << endl;
  }
  cout << dp[uf.root(0)] << endl;
}






Measured memory_bytes: 12540
def solve():
    S = list(input())
    results = []
    dfs(S, 0, "", results)
    
    ans = 0
    for res in results:
        ans += eval(res)
    print(ans)

def dfs(S,idx,res,results):
    res += S[idx]
    if idx == len(S)-1:
        results.append(res)
        return
    dfs(S,idx+1,res+'+',results)
    dfs(S,idx+1,res,results)

if __name__ == '__main__':
    solve()

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

using namespace std;

// Graph template
template <class... Args>
struct Edge
{
  int from, to;
  tuple<Args...> values;
  Edge(int from, int to, Args... values)
      : from(from), to(to), values(values...) {}
};
template <class E>
auto operator<(const E &e, const E &f)
{
  return e.values > f.values;
}

template <class... Args>
class Graph
{
  using Edges = vector<Edge<Args...>>;
  vector<Edges> graph_;

public:
  Graph(int n) : graph_(n) {}
  size_t size() { return graph_.size(); };
  size_t size() const { return graph_.size(); };
  auto &operator[](unsigned int x) { return graph_[x]; }
  const auto &operator[](unsigned int x) const { return graph_[x]; }
  void AddEdge(int s, int t, Args... v) { graph_[s].emplace_back(s, t, v...); }
};

// Connects a set of subsets and checks the belonging of the data.
// unite : near O(1)
// root : near O(1)
// same : near O(1)
// size : near O(1)
class UnionFind
{
  using Abel = int;
  std::vector<Abel> data;

public:
  UnionFind(int n) : data(n, -1) {}

  // Connects between x and y.
  bool unite(Abel x, Abel y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
      {
        std::swap(x, y);
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  // Finds the belonging of x.
  Abel root(Abel x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

  // Checks where x and y belong to the same subset.
  bool same(Abel x, Abel y) { return root(x) == root(y); }

  // Look up the size of the subset belonged to x.
  Abel size(Abel x) { return -data[root(x)]; }
};

int dfs(int s, const Graph<> &g, int k)
{
  const int n = g.size();
  vector<bool> visited(n, 0);
  int ret = 0;
  int rest = 0;
  queue<pair<int, int>> qu;
  qu.push({s, 0});
  UnionFind uf(n);
  vector<int> buf(n, 0);
  while (!qu.empty())
  {
    auto now = qu.front();
    qu.pop();
    visited[now.first] = 1;
    if (now.second <= k / 2)
    {
      ret++;
    }
    else
    {
      break;
    }
    for (const auto &e : g[now.first])
    {
      if (visited[e.to])
        continue;
      qu.push({e.to, now.second + 1});
      if (now.second > 0)
      {
        uf.unite(e.to, e.from);
      }
      if ((k & 1) && now.second + 1 > k / 2)
      {
        buf[uf.root(e.to)]++;
      }
    }
  }
  for (const auto &x : buf)
  {
    rest = max(x, rest);
  }
  //cout << rest;
  return ret + rest;
}

int main()
{
  int n, k;
  cin >> n >> k;
  if (k == 1)
  {
    cout << n - 2 << endl;
    return 0;
  }
  Graph<> g(n);
  for (int i = 0; i < n - 1; ++i)
  {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g.AddEdge(u, v);
    g.AddEdge(v, u);
  }
  int ans = 1e9;
  for (int i = 0; i < n; ++i)
  {
    ans = min(ans, n - dfs(i, g, k));
  }
  //cout << dfs(1, g, k) << endl;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  long n,m;

  cin >> n >> m;//-9のとき

  // x/p = (1900M + 100(N − M)) × 2M

  long ans = (1900*m + 100*(n-m)) * pow(2,m);

  cout << ans;

  return 0;
}


Measured memory_bytes: 256