akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Control.Monad.State
import Debug.Trace
 
main = do
    [n,m] <- map read . words <$> getLine
    ass <- replicateM n (map read . tail . words <$> getLine) :: IO [[Int]]
    print . fst $ runState (solve n m ass) (replicate m 0) 
 
oneHot :: Int -> [Int] -> [Int]
oneHot m s = map (\x -> if x `elem` s then 1 else 0) [1..m]

reflesh :: Int -> Int-> [Int] -> State [Int] Int
reflesh n m as = state $ \s -> 
        let s' = zipWith (+) s $ oneHot m as
            a' = length $ filter (==n) s'
        in (a',s')

solve :: Int -> Int -> [[Int]] -> State [Int] Int
solve n m [] = do
    reflesh n m (replicate m 0) 
solve n m (as:ass) = do
    reflesh n m as
    solve n m ass

Measured memory_bytes: 1148
#include <stdio.h>

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

    scanf("%d %d %d %d", &a, &b, &c, &d);
    while (1)
    {
        c -= b;
        if (c <= 0)
        {
            printf("Yes");
            break;
        }
        a -= d;
        if (a <= 0)
        {
            printf("No");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;return 0;
    }
    bool alp[26]={};
    for(int i=0;i<s.size();i++){
        int tmp=s[i]-'a';
        alp[tmp]=true;
    }
    bool flag=true;
    for(int i=0;i<26;i++){
        if(!alp[i]){
            char ttt='a'+i;
            cout<<s+ttt<<endl;return 0;
        }
    }
    bool f=false;
    string t=s;
    do{
        int x=0;
        if(f){
            while(s[x]==t[x]){
                cout<<s[x];
                x++;
            }
            cout<<s[x];
            cout<<endl;return 0;
        }
        f=true;
    }while(next_permutation(ALL(s)));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
#define int long long

class SqrtDecomposition{
private:
    int n; //元の配列のサイズ
    int sz; //1つのバケットが担当する区間の長さ
    int num; //バケットの個数
    vector<int> v,backet;
    int init;

    int combine(int a, int b){
        return min(a,b);
        //return max(a,b);
    }

    int idx(int i){
        return i/sz;
    }
    void build(){
        sz = sqrt(n);
        num = (n + sz-1)/sz;
        backet = vector<int>(num,init);
        //backetの更新
        for(int i = 0; i < n; i++){
            backet[idx(i)] = combine(backet[idx(i)], v[i]);
        }
    }
public:
    SqrtDecomposition(){
    }
    SqrtDecomposition(int size, int initial){
        n = size;
        init = initial;
        v = vector<int> (n,init);
        build();
    }
    SqrtDecomposition(vector<int> in, int initial){
        n = in.size();
        init = initial;
        v = in;
        build();
    }
    void update(int ind, int x){
        //v[ind]をxに変更する
        v[ind] = x;
        int id = idx(ind);
        backet[id] = init;
        for(int i = id*sz; i < min((id+1)*sz,n); i++){
            backet[id] = combine(backet[id], v[i]);
        }
    }
    int query_min(int l, int r){
        //[l,r)の最小値を求める
        int ret = init;
        int lid = idx(l);
        int rid = idx(r);
        if(lid == rid){
            for(int i = l; i < r; i++){
                ret = min(ret, v[i]);
            }
            return ret;
        }
        for(int i = l; i < (lid+1)*sz; i++){
            ret = min(ret, v[i]);
        }
        for(int i = lid+1; i < rid; i++){
            ret = min(ret, backet[i]);
        }
        for(int i = rid*sz; i < r; i++){
                ret = min(ret, v[i]);
        }
        return ret;
    }
    void show(){
        cout << endl;
        cout << "n = " << n;
        cout << ", sz = " << sz;
        cout << ", num = " << num;
        cout << endl;
        cout << "v:";
        for(int i = 0; i < n; i++)cout << " " << v[i];cout << endl;
        cout << "backet:";
        for(int i = 0; i < num; i++)cout << " " << backet[i];cout << endl;
        cout << endl;
    }
};

void dsl2a(){
    int n,q;
    cin >> n >> q;
    long init = (1LL<<31)-1;
    vector<int> in(n,init);
    SqrtDecomposition sd(in,init);
    while(q--){
        int com,x,y;
        cin >> com >> x >> y;
        if(com == 0){//a_xをyに変更する
            sd.update(x,y);
        }else{//a_x ~ a_yの最小値を出力する
            //sd.show();
            cout << sd.query_min(x,y+1) << endl;
        }
    }
}

signed main(){
    dsl2a();
}



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

int main() {
  int a, b;
  
  cin >> a >> b;
  
  if ((a + b)%2 == 1){
    cout << (a+b+1)/2 << endl;
  } else {
    cout << (a+b)/2 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
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;
}
///////////////////////////////////////
ll dp[100100][13];
int main() {
	string S; cin >> S;
	reverse(S.begin(), S.end());
	ll f[100100];
	f[0] = 1;
	for (int i = 0; i < 100000; ++i) {
		f[i + 1] = f[i]*10;
		f[i + 1] %= 13;
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		int c;
		if (S[i] == '?')c = -1;
		else c = S[i] - '0';
		for (int j = 0; j < 10; ++j) {
			if (c != -1 && c != j)continue;
			for (int ki = 0; ki < 13; ++ki) {
				dp[i + 1][(ki+j*f[i])%13] += dp[i][ki];
			}
		}
		for (int j = 0; j < 13; ++j) {
			dp[i + 1][j] %= INF;
		}
	}
	cout << dp[S.size()][5] << endl;
	return 0;
}


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

vector<int> par, rnk, tsize;

void init(int n) {
    for(int i = 0; i < n; ++i) {
        par[i] = i;
        rnk[i] = 0;
        tsize[i] = 1;
    }
}

int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }

bool issame(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y)
        return;
    if(rnk[x] < rnk[y])
        swap(x, y);
    par[y] = x;
    tsize[x] += tsize[y];
    if(rnk[x] == rnk[y])
        rnk[x]++;
}

int main() {
    ll N, M, c;
    cin >> N >> M;
    c = N * (N - 1) / 2;
    stack<ll> ans;
    stack<pair<int, int>> ab;
    ans.push(c);
    par.resize(N);
    rnk.resize(N);
    tsize.resize(N);
    init(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ab.push(make_pair(a, b));
    }
    for(int i = 0; i < M - 1; ++i) {
        if(!issame(ab.top().first, ab.top().second)) {
            ans.push(ans.top() - tsize[root(ab.top().first)] * tsize[root(ab.top().second)]);
            unite(ab.top().first, ab.top().second);
        } else
            ans.push(ans.top());
        ab.pop();
    }
    for(int i = 0; i < M; ++i) {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    ll n,power = 1;
    cin >> n;

    REP(n){

        power = power*(i+1)%MAX_A;

    }
    cout << power << endl;


    return 0;
}

Measured memory_bytes: 256
a, b, c, d = gets.split.map(&:to_i)

cdiv = b / c - (a - 1) / c # 6 - 1 = 5
ddiv = b / d - (a - 1) / d # 5 - 1 = 4
cddiv = b / c.lcm(d) - (a - 1) / c.lcm(d) # 0

p(b - a + 1 - cdiv - ddiv + cddiv) 



Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>

int main()
{
	long long n, a;
	scanf("%lld %lld", &n, &a);
	long long x[50];
	long long dp[51][51][2501];
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", x + i);
	}
	memset(dp[0][0], 0, (n * 50 + 1) * sizeof(long long));

	dp[0][0][0] = 1;
	const long long jlim = n * 50;
	for (int i = 0; i < n; ++i)
	{
		for (int k = 0; k <= n; ++k)
		{
			for (int j = 0; j <= jlim; ++j)
			{
				if (j - x[i] >= 0 && k >= 1)
				{
					dp[i + 1][k][j] = dp[i][k - 1][j - x[i]] + dp[i][k][j];
				}
				else
				{
					dp[i + 1][k][j] = dp[i][k][j];
				}
			}
		}
	}

	long long ans = 0;
	for (long long i = 1; i <= n && i * a <= jlim; ++i)
	{
		ans += dp[n][i][i * a];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 50944
H,W=map(int,input().split())
#横長パターンと縦長パターンのみ
ans=H*W
if H%3==0 or W%3==0:
  ans=0

#横長パターン
for h in range(H):
  A=h*W
  if W%2==0:
    B=(H-h)*(W/2)
    C=(H-h)*(W/2)
  else:
    B=(H-h)*(W+1)/2
    C=(H-h)*(W-1)/2
  sa=abs(A-B)
  sa=max(sa,abs(B-C),abs(A-C))
  ans=min(ans, sa)
#縦長パターン
for w in range(W):
  A=w*H
  if H%2==0:
    B=(W-w)*(H/2)
    C=(W-w)*(H/2)
  else:
    B=(W-w)*(H+1)/2
    C=(W-w)*(H-1)/2
  sa=abs(A-B)
  sa=max(sa,abs(B-C),abs(A-C))
  ans=min(ans, sa)

#均等パターン
  ans=min(ans,H,W)
print(int(ans))


Measured memory_bytes: 3064
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()
if N == M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10752
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val T = sc.next().toInt()
        val t = IntArray(N) { sc.next().toInt() }
        var prev = 0
        var ans = T
        t.forEach { t ->
            ans += arrayOf(t - prev, T).min()!!
            prev = t
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 55292
#include <iostream>
const int MAX_N = 100;
const int INF = 999999999;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
using namespace std;

int n;
int color[MAX_N];
int adj[MAX_N][MAX_N];
int d[MAX_N], p[MAX_N];

int prim(void) {
    int u, minv;

    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        d[i] = INF;
        p[i] = -1;
    }

    d[0] = 0;
    while (1) {
        minv = INF;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (minv == INF) break;

        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && adj[u][v] != INF) {
                if (d[v] > adj[u][v]) {
                    d[v] = adj[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += adj[i][p[i]];
    }

    return sum;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int v; cin >> v;
            if (v == -1) adj[i][j] = INF;
            else adj[i][j] = v;
        }
    }

    cout << prim() << endl;
    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  void init() {
  }

  void solve() {
    string S;
    cin >> S;
    rep(i, S.size()) cout << "x";
    cout << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 0x3FFFFFFF
using namespace std;
int n;
int a[MAXN],b[MAXN],c[MAXN],d[MAXN],t[MAXN],f[MAXN];
bool used[MAXN],flag;
vector<pair<int,int> >px[MAXN];
priority_queue<pair<int,int> > q;
int main(){
	SF("%d",&n);	
	for(int i=1;i<=n;i++)
		SF("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n+1;i++)	
		SF("%d",&c[i]);
	sort(c+1,c+2+n);
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(c+1,c+1+n+1,a[i])-c;
		b[i]=lower_bound(c+1,c+1+n+1,b[i])-c;
	}
	memset(used,1,sizeof used);
	for(int i=1;i<=n;i++)
		d[a[i]-1]--;
	for(int i=1;i<=n;i++)
		px[a[i]-1].push_back(make_pair(-b[i],i));
	int delta=0;d[n+2]=n;
	for(int i=n+1;i>=1;i--){
		for(int j=0;j<int(px[i].size());j++)
			q.push(px[i][j]);
		d[i]+=d[i+1];
		t[i]=d[i]-i;
		while(t[i]<-1){
			if(q.empty()||-q.top().first>i){
				flag=1;
				break;
			}
			else{
				pair<int,int> tx=q.top();
				q.pop();
				used[tx.second]=0;
				delta++;
				d[i]++;
				t[i]++;
				d[-tx.first-1]--;	
			}
		}
	}	
	for(int i=0;i<=n+1;i++)
		d[i]=0;
	for(int i=1;i<=n;i++){
		if(used[i])
			d[a[i]]++;
		else
			d[b[i]]++;
	}
	for(int i=1;i<=n+1;i++){
		d[i]+=d[i-1];
		t[i]=d[i]-i;
	}
	while(!q.empty())
		q.pop();
	for(int i=1;i<=n+1;i++)
		px[i].clear();
	for(int i=1;i<=n;i++)
		if(used[i])
			px[b[i]].push_back(make_pair(a[i]-1,i));
	int cur=0;
	for(int i=1;i<=n+1;i++){
		for(int j=0;j<int(px[i].size());j++)
			q.push(px[i][j]);	
		f[i]=f[i-1];
		if(t[i]==-1){
			if(cur<i){
				if(q.empty()||q.top().first<i)
					f[i]=INF;
				else{
					pair<int,int> tx=q.top();
					q.pop();
					cur=tx.first;
					f[i]++;
				}
			}
		}
	}
	int Q;
	SF("%d",&Q);
	for(int i=1;i<=Q;i++){
		int x,y;
		SF("%d%d",&x,&y);
		x=lower_bound(c+1,c+2+n,x)-c;
		y=lower_bound(c+1,c+2+n,y)-c;
		if(flag)
			PF("-1\n");
		else{
			int xx=f[x-1]+delta;
			int yy=f[y-1]+delta;
			int ans=min(xx,yy+1);
			if(ans>n+1)
				PF("-1\n");
			else
				PF("%d\n",n+1-ans);
		}	
	}	
}

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

#define rep(a,b) for(int ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  fst_io;
  int n,c=0;
  cin>>n;
  ll a[n];
  rep(0,n)
  {
  	cin>>a[ii];
  	if(a[ii]%2!=0&&(ii+1)%2!=0) c++;
  } 
  cout<<c<<endl;
  return 0;
}

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

// @author: pashka

map<int, vector<int>> g;
map<int, int> z;
int sz;
int c = 0;

void dfs(int x) {
    if (z[x] != 0) return;
    z[x] = c;
    sz += g[x].size();
    for (int y : g[x]) {
        dfs(y);
    }
}

int main() {
    ios::sync_with_stdio(false);

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

    vector<pair<int, int>> aa(n + 1);
    vector<pair<int, int>> bb(n + 1);
    for (int i = 0; i <= n; i++) aa[i] = {a[i], i};
    for (int i = 0; i <= n; i++) bb[i] = {b[i], i};

    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());

    for (int i = 0; i <= n; i++) {
        if (aa[i].first != bb[i].first) {
            cout << -1;
            return 0;
        }
        if (a[aa[i].second] != a[bb[i].second]) {
            g[a[aa[i].second]].push_back(a[bb[i].second]);
            g[a[bb[i].second]].push_back(a[aa[i].second]);
        }
    }

    int res = 0;

    for (auto &p : g) {
        if (z[p.first] == 0) {
            c++;
            sz = 0;
            dfs(p.first);
            sz /= 2;
//            cout << p.first << " " << z[a[n]] << " " << sz <<  "\n";
            if (sz > 0) {
                if (z[a[n]] == c) {
                    if (a[n] == b[n]) {
                        res += sz;
                    } else {
                        res += sz - 1;
                    }
                } else {
                    res += sz + 1;
                }
            }
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
 ll n,a,b;
 cin >> n >> a >> b;
 ll ans = (b*(n-1)+a)+1-(a*(n-1)+b);
if(a>b){
cout << 0 << endl;
}
else if(n==1&&a!=b){
  cout << 0 << endl;
}
else{
  
  cout << ans << endl;
}
 }
 


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

long p = 998244353;
long ans;
vector<long> facMap;

vector<long> makeFacMap(long n)
{
    vector<long> fac;
    long cur = 1;
    rep(i, n + 1)
    {
        fac.push_back(cur);
        cur *= i + 1;
        cur %= p;
    }
    return fac;
}

long modPow(long n, long m)
{
    if (m == 0)
    {
        return 1;
    }
    long halfPow = modPow(n, m / 2);
    if (m % 2 == 0)
    {
        return (halfPow * halfPow) % p;
    }
    else
    {
        long v = (halfPow * halfPow) % p;
        return (v * n) % p;
    }
}
long comb(long n, long m)
{
    long ret = facMap.at(n);
    ret *= modPow(facMap.at(n - m), p - 2);
    ret %= p;
    ret *= modPow(facMap.at(m), p - 2);
    ret %= p;
    // cout << n << "C" << m << "=" << ret << endl;
    return ret;
}

int main()
{
    long n, m, k;
    cin >> n >> m >> k;
    facMap = makeFacMap(n + 1);
    ans = 0;
    long temp;
    for (long i = 0; i <= k; i++)
    {
        // cout << n - 1 << " " << i << endl;
        temp = (m * modPow(m - 1, n - i - 1)) % p;
        temp *= comb(n - 1, i);
        // cout << temp << endl;
        ans += temp % p;
        ans %= p;
    }
    // puts("ok3");
    // scanf("%d", &x);
    // printf("%d\n", x * x * x);
    cout << ans << endl;
}

Measured memory_bytes: 5276
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"    [";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=2e9;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int dp[2001][2];
int flag[2001][2];
int N, Z, W;
vector<int> A;
int dfs(int i, int turn, int x, int y) {
    if (flag[i][turn]) return dp[i][turn];
    if (i == N) {
        return abs(x - y);
    }
    int score = turn ? INF : 0;
    if (turn) {
        for (int j = i; j < N; ++j) {
            score = min(score, dfs(j + 1, 1 - turn, x, A[j]));
        }
    } else {
        for (int j = i; j < N; ++j) {
            score = max(score, dfs(j + 1, 1 - turn, A[j], y));
        }
    }
    dp[i][turn] = score;
    flag[i][turn] = 1;
    return score;
}

int main(int argc, char const *argv[]) {
    
    cin >> N >> Z >> W;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    cout << dfs(0, 0, Z, W) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


void solve() {
}

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0)cout << N << endl;
    else cout << N * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
mod =10**9+7
n,a,b = map(int,input().split())
ans = pow(2,n,mod)-1
def cmb(n,k):
    x,y = 1,1
    for i in range(k):
        x = x * (n-i) % mod
        y = y * (k-i) % mod
    return x * pow(y, mod-2, mod) % mod
ans -= cmb(n,a) + cmb(n,b)
print(ans%mod)

Measured memory_bytes: 38512
class Card
  attr_reader :number
  POWER_MAP = {
   "1": 13,
   "2": 1,
   "3": 2,
   "4": 3,
   "5": 4,
   "6": 5,
   "7": 6,
   "8": 7,
   "9": 8,
   "10": 9,
   "11": 10,
   "12": 11,
   "13": 12
  }

  def initialize(number)
    raise ArgumentError, "number must be between 1 and 13. Given: #{number.inspect}" unless (1..13).include?(number.to_i)
    @number = number.to_s
  end

  def power
    POWER_MAP[number.to_sym]
  end
end

class CardSet
  attr_reader :deck
  def initialize
    @deck = (1..13).map do |i|
      Card.new(i)
    end
    @deck
  end

  def draw
    deck.sample
  end
end

class Player
  attr_reader :name
  attr_accessor :card
  def initialize(name)
    @name = name
  end

  def card_power
    card.power
  end
end

class OneTimePoker
  def initialize(player_a, player_b, card_set)
    @player_a = player_a
    @player_b = player_b
    @card_set = card_set
  end

  def game
    draw_cards
    result
  end

  private

  def result
    case @player_a.card_power <=> @player_b.card_power
    when -1
      @player_b.name
    when 0
      "Draw"
    when 1
      @player_a.name
    end
  end

  def draw_cards
    @player_a.card ||= @card_set.draw
    @player_b.card ||= @card_set.draw
  end
end

card_numbers = gets.chomp.split(' ')
card_set = CardSet.new
player_a = Player.new("Alice")
player_a.card = Card.new card_numbers[0]
player_b = Player.new("Bob")
player_b.card = Card.new card_numbers[1]
puts OneTimePoker.new(player_a, player_b, card_set).game

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;


int min3(int a,int b,int c){
	return min(min(a,b),c);
}

int main(){
    ofstream out("output.txt");
    			
    int a,b;
    cin>>a>>b;

    int necesarios = 0, total = 1;
    while(b>total){
    	total += a;
    	total--;
    	necesarios++;
    }
    cout<<necesarios<<endl;	

    return 0;
}

 
 







Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int A, B, X;

int main(int argc, char **argv) {
    std::cin >> A >> B >> X;
    
    if (A <= X && X <= A + B) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<double> A(N);
	REP(i, N)cin >> A[i];
	rSORT(A);
	
	double ans = 0;
	REP(i, N) {
		FOR(j, i + 1, N) {
			int cnt = 0;
			int f = 0;
			if (i != 0) { cnt += A[0]; f++; }
			if (i != 1 && j != 1 && f < 2) { cnt += A[1]; f++; }
			if (i != 2 && j != 2 && f < 2) { cnt += A[2]; f++; }
			if (i != 3 && j != 3 && f < 2) { cnt += A[3]; f++; }
			//cout << cnt << " " << A[i] << " " << A[j] <<" "<< cnt / (A[i] - A[j]) << endl;
			ans = max(ans, (double)cnt / (A[i] - A[j]));
		}
	}
	//cout << ans << endl;
	printf("%.6f", ans);
	return 0;
}




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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);

  ll B=0;
  while(true){
    ll A5 = X+B*B*B*B*B;
    ll A = (ll)pow(A5, 1.0/5.0);
    ll A1 = A+1;

    if(A*A*A*A*A-B*B*B*B*B==X){
      printf("%lld %lld\n", A, B);
      return 0;
    }
    A = A1;

    if(A*A*A*A*A-B*B*B*B*B==X){
      printf("%lld %lld\n", A, B);
      return 0;
    }

    B = -B;

    A5 = X+B*B*B*B*B;
    A = (ll)pow(A5, 1.0/5.0);
    A1 = A+1;

    if(A*A*A*A*A-B*B*B*B*B==X){
      printf("%lld %lld\n", A, B);
      return 0;
    }
    A = A1;

    if(A*A*A*A*A-B*B*B*B*B==X){
      printf("%lld %lld\n", A, B);
      return 0;
    }

    B = -B;
    B++;
  }

  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n,k;
	cin>>n>>k;
	if(n<k){
		cout<<min(n,(abs(n-k)));
	}
	else if(n==k){
		cout<<"0";
	}
	else{
		if(n%k==0){
			cout<<"0";
		}
		else{
			cout<<min((n%k),abs((n%k)-k));
		}
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

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

    ll a[n];
    for(int i = 0; i < n; i++)
        scanf("%lld",&a[i]);

    ll mn = a[0];
    ll p = 0, mp = 0;
    ll c = 0;

    for(int i = 1; i < n; i++)
    {
        if(a[i] <  mn)   mn = a[i];
        if(a[i] >= mn)   p = a[i] - mn;

        if(p > mp)         mp = p,c = 1;
        else if(p == mp)   c++;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
program B_solution

implicit none
integer :: a,b,i,j
character(11) :: s

read(*,*) a,b
read(*,*) s

if(index(s(1:),'-') == a+1 .and. index(s(a+2:),'-') == 0) then
  write(*,*) "Yes"
else
  write(*,*) "No"
endif

end program

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n, m;
  cin >> n >> m;

  pr((n-1)*(m-1));


  return 0;
}


Measured memory_bytes: 256
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int mon, day;
		cin >> mon;
		
		if( mon == 0 )		break;
		
		cin >> day;
		
		for(int i = 1; i < mon; i++) {
			switch(i) {
			case 2:
				day += 29;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				day += 30;
				break;
			default:
				day += 31;
				break;
			}
		}
		
		switch(day % 7) {
		case 0:
			cout << "Wednesday" << endl;
			break;
		case 1:
			cout << "Thursday" << endl;
			break;
		case 2:
			cout << "Friday" << endl;
			break;
		case 3:
			cout << "Saturday" << endl;
			break;
		case 4:
			cout << "Sunday" << endl;
			break;
		case 5:
			cout << "Monday" << endl;
			break;
		case 6:
			cout << "Tuesday" << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    //dream dreamer erase eraser
    //5 7 5 6
    string str;
    cin >> str;
    
    string strs[] = {"dream", "dreamer", "erase", "eraser"};
    int a[] = {5,7,5,6};
    
    for(int i = str.length()-1; i >= 0; i--){
        bool f = true;
            
        for(int j = 0; j < 4; j++){
            f = true;
            for(int k = 0 ; k < strs[j].size(); k++){
                if(str[k+i-strs[j].size()+1] != strs[j][k]){
                    f = false;
                }
            }
            if(f){
                i = i - a[j] + 1;
                break;
            }
        }
        if(!f){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int k, n;
  cin >> k >> n;
  int maxS = 0;
  while(n--) {
    int t;
    cin >> t;
    maxS = max(maxS, t);
  }
  cout << max(0, 2*maxS-1-k) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int x, t;
  cin >> x >>t;
  dump(max(x-t, 0));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
    
int n, a, b, sa, sb;
    
int main(){
  for(;;){
    sa = 0;
    sb = 0;
    cin >> n;
    if(n == 0){
      break;
    }else{
      for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a < b){
          sb += a + b;
        }else if(a > b){
          sa += b + a;
        }else if(a == b){
          sa += a;
          sb += b;
        }
      }
      cout << sa << " " << sb << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    int ab = a * b;

    if (ab % 2 == 0) {
      System.out.println("Even");
    }
      else {
        System.out.println("Odd");
      }
  }
}


Measured memory_bytes: 21588
n,m = map(int,input().split())
anli = [-1]*n
poss = 0
for i in range(m):
    s,c = map(int,input().split())
    if anli[s-1] == -1:
        anli[s-1] = c
    elif anli[s-1] == c:
        continue
    else:
        poss = 1
        break
if n == 1:
    if poss == 1:
        print(-1)
    else:
        if anli[0] == -1:
            print(0)
        else:
            print(anli[0])
else:
    if anli[0] == 0 or poss == 1:
        print(-1)
    else:
        if anli[0] == -1:
            anli[0] = 1
        for i in range(n):
            if anli[i] == -1:
                anli[i] = 0
            print(anli[i],end=(''))

Measured memory_bytes: 61884
from operator import itemgetter
N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
lst = [""] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
    lst[i] = (S[i], P[i], NUM[i])
sorted1 = sorted(lst, key=itemgetter(1), reverse=True)
sorted2 = sorted(sorted1, key=itemgetter(0))
for i in range(0,N):
     print(sorted2[i][2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N, K;
    cin>>N>>K;
    vector<ll> A(N);

    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    sort(A.begin(), A.end());

    ll Min=-1*1000000000000000000-1;
    ll Max=1*1000000000000000000+1;

    while(Max-Min>1){
      	ll Mid=Max+Min;
        Mid/=2;
        ll Sum=0;
        for(int i=0; i<N; i++){
            if(A[i]>0){
                ll X=((Mid>=0)?Mid/A[i]:((Mid+1)/A[i]-1));
                auto itr=upper_bound(A.begin(), A.end(), X);
                Sum+=distance(A.begin(), itr);
                if(X>=A[i])Sum--;
            }
            else if(A[i]<0){
                ll X=((Mid>=0)?Mid/A[i]:(Mid+1)/A[i]+1);
                auto itr=lower_bound(A.begin(), A.end(), X);
                Sum+=distance(itr, A.end());
                if(X<=A[i])Sum--;
            }
            else if(Mid>=0){
                Sum+=N-1;
            }

        }
        Sum/=2;
        if(Sum<K){
            Min=Mid;
        }
        else{
            Max=Mid;
        }
    }
    cout<<Max<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
   int i,j,k,n,ans;
   long l[100],x;

   scanf("%d",&n);
   for (i=j=0;i<n;i++)
      scanf("%ld",&l[i]);
   for (ans=i=0;i<n;i++)
      for (j=i+1;j<n;j++) {
         if (l[i]==l[j]) continue;
         for (k=j+1;k<n;k++) {
            if (l[i]==l[k] || l[j]==l[k]) continue;
            if (l[i]>l[j]) x=l[i];
            else           x=l[j];
            if (x<l[k]) x=l[k];
            if (x<l[i]+l[j]+l[k]-x) ans++;
         }
      }
   printf("%d\n",ans);
   return 0;
}

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

int main(){
	bool prime[10001];
	for(int i=0;i<=10000;i++) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for(int i=2;i<=10000;i++){
		if(prime[i]){
			for(int j=2*i;j<=10000;j+=i){
				if(prime[j]) prime[j] = false;
			}
		}
	}
	
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=n;i>2;i--){
			if(prime[i] && prime[i-2]){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  int aplace;
  for(int i=0;i<s.size();i++){
    if(s.at(i) == 'A'){
      aplace = i;
      break;
    }
  }
  
  reverse(s.begin(),s.end());
  int zplace;  
  for(int i=0;i<s.size();i++){
    if(s.at(i) == 'Z'){
      zplace = s.size()-1-i;
      break;
    }
  }
  
  cout << zplace - aplace + 1 << endl;
}
      


Measured memory_bytes: 640
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<cmath>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 100050
#define ll long long
#define inf int(1e9)
#define mm 1000000007
#define low(x) x&(-x)
using namespace std;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
struct data{int obj,pre;
}e[maxn*2];
int head[maxn],sg[maxn],flag[maxn],n,tot;
void insert(int x,int y){
	e[++tot].obj=y; e[tot].pre=head[x]; head[x]=tot;
}
void dfs(int u,int f){
	int ans=0; sg[u]=0;
	for (int j=head[u];j;j=e[j].pre){
		int v=e[j].obj;
		if (v!=f) {
			dfs(v,u); ans=ans^(sg[v]+1);
		}
	}
	sg[u]=ans;
}
int main(){
	n=read();
	rep(i,1,n-1){
		int x=read(),y=read();
		insert(x,y); insert(y,x);
	}
	dfs(1,0);
	if (sg[1]) puts("Alice");
	else puts("Bob");
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>

using namespace std;

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

    int ans1 = 0;
    int ans2 = 0;

    for (int i = 0; i < S.length(); ++i) {
        if(S[i] - '0' != i%2) ans1++;
        if(S[i] - '0' != (i+1)%2) ans2++;
    }

    cout << min(ans1, ans2);
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main(void)
{
 
  int x, y, m, tmp;
 
  scanf("%d %d", &x, &y);
 
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  m = x % y;
  
  while(m != 0){
    
    x = y;
    y = m;
    m = x % y;
  }
 
  printf("%d\n", y);
 
  return 0;
}



Measured memory_bytes: 2072
import sys
sys.setrecursionlimit(10**9)


def solve(n, a, b, c, d):
    memo = {}

    def dfs(m, cost):
        if m not in memo or memo[m] > cost:
            memo[m] = cost

            if m > 0:
                dfs(m // 2, cost + (m % 2) * d + a)
                dfs(m // 3, cost + (m % 3) * d + b)
                dfs(m // 5, cost + (m % 5) * d + c)

                dfs((m + (2 - m % 2)) // 2, cost + (2 - m % 2) * d + a)
                dfs((m + (3 - m % 3)) // 3, cost + (3 - m % 3) * d + b)
                dfs((m + (5 - m % 5)) // 5, cost + (5 - m % 5) * d + c)

                dfs(0, cost + m * d)

    dfs(n, 0)
    return memo[0]


t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    ans = solve(n, a, b, c, d)
    print(ans)


Measured memory_bytes: 119420
import java.io.*;
class Main{
    public static void main(String[] args){
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = br.readLine();
            String[] strArr = str.split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int c = Integer.parseInt(strArr[2]);
            if(a < b){
                if(b < c){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }else{
                System.out.println("No");
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24156
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[10]; for (int i = 0; i < n; i++) cin >> a[i];
    int sum = 0; for (int i = 0; i < n; i++) sum += a[i];
    for (int i = 0; i < n; i++) if (a[i] >= sum - a[i]) { cout << "No" << endl; return 0; }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
struct UnionFind {
    vector<int> par,siz; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

    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[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[rx]+=siz[ry];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x){
        return siz[root(x)];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> p(n),x(m),y(m);
    REP(i,n){
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf(n);
    REP(i,m){
        cin >> x[i] >> y[i];
        x[i]--,y[i]--;
        uf.unite(x[i],y[i]);
    }
    int ans=0;
    REP(i,n){
        if(uf.same(i,p[i])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5284
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

vector<int> sieve(long long int n)
{
	vector<int> ans;
	for(int i=1;i*i<=(n); i++)
	{	
		if(n%i==0)
		{
			// for(int j = i ;j<=n;j+=i)
			// {
				ans.push_back(i);
				ans.push_back(n/i);
		// /	}
		}
	}
	return ans;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
	long long int n,m;
	cin>>n>>m;
	vector<int> divisors = sieve(m);
	sort(divisors.begin(), divisors.end());
	for(int i= divisors.size()-1 ; i>=0 ; i--)
	{
		if(m/divisors[i]>=n)
		{
			cout<<divisors[i];
			return 0;
		}
	}
	// cout<<1<endl;
	return 0 ;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nCities := scanInt(sc)
	nTrains := scanInt(sc)
	nQuestions := scanInt(sc)

	cities := make([][]int, nCities)
	for i := 0; i < nTrains; i++ {
		start := scanInt(sc) - 1
		end := scanInt(sc) - 1

		if cities[start] == nil {
			cities[start] = make([]int, nCities-start)
		}
		cities[start][end-start] += 1
	}

	for _, city := range cities {
		if len(city) < 2 {
			continue
		}
		sum := city[0]
		for i := 1; i < len(city); i++ {
			sum += city[i]
			city[i] = sum
		}
	}

	out := bufio.NewWriter(os.Stdout)
	for q := 0; q < nQuestions; q++ {
		start := scanInt(sc) - 1
		end := scanInt(sc) - 1
		cnt := 0

		for i := start; i <= end; i++ {
			if cities[i] != nil {
				cnt += cities[i][end-i]
			}
		}
		fmt.Fprintln(out, cnt)
	}

	out.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


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

int main() {
  string S,T;
  cin >> S >> T;
  
  int K = S.size();

  if(S == T.substr(0,K)){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 3628