akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
vector<P> es;
int addnot;
int v1[80010],v2[80010];

int V;
vector<int> g[80010],rg[80010];
vector<int> vs;
bool used[80010];
int cmp[80010];

void add_edge(int from,int to){
  g[from].push_back(to);
  rg[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<g[v].size();i++){
    if(!used[g[v][i]])dfs(g[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rg[v].size();i++){
    if(!used[rg[v][i]])rdfs(rg[v][i],k);
  }
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++){
    if(!used[v])dfs(v);
  }
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return k;
}

bool ok(int x){
  rep(i,V){
    g[i].clear();
    rg[i].clear();
  }
  rep(i,es.size()){
    if(v1[i]<x&&v2[i]<x)add_edge(es[i].fi,es[i].se);
  }
  scc();
  bool ok=true;
  rep(i,n){
    if(cmp[i]==cmp[i+addnot])ok=false;
  }
  return ok;
}

int main(){
  cin>>n>>m;
  addnot=n;
  V=n*2;
  rep(i,m){
    int a1,a2;
    string d1,d2,c;
    cin>>a1>>d1>>c>>a2>>d2;
    a1--; a2--;
    v1[i*2]=a1; v2[i*2]=a2;
    es.push_back(P(a1+(d1=="left"?addnot:0),a2+(d2=="left"?0:addnot)));
    v1[i*2+1]=a2; v2[i*2+1]=a1;
    es.push_back(P(a2+(d2=="left"?addnot:0),a1+(d1=="left"?0:addnot)));
  }
  int lb=0,ub=n;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(ok(mid))lb=mid;
    else ub=mid;
  }
  cout<<ub<<endl;
  return 0;
}



Measured memory_bytes: 9572
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<deque>
#include<algorithm>
#include<math.h>

using namespace std;
int main() {

	long long int n, m;
	cin >> n >> m;
	if (n >= m / 2) {
		cout << m / 2 << endl;
		return 0;
	}
	else {
		cout << n + (m - 2 * n) / 4 << endl;
		return 0;
	}

}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    M -= 2 * N;
    if(M < 0) {
        cout << min((M + 2 * N) / 2, N) << endl;
    } else {
        cout << N + M / 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))

(defun main (a b &aux (a-sum (comulative #'+ a)) (b-sum (reverse (comulative #'+ (reverse b)))))
  (loop for i in a-sum
        for j in b-sum
        maximize (+ i j)))

(let ((n (read)))
  (princ (main (read-times n) (read-times n))))


Measured memory_bytes: 13876
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
  int a,b,c;
 cin >> a >> b >> c;
  vector<int> ve ={a,b,c};
  sort(ve.begin(),ve.end());
  cout << ve.at(2) -  ve.at(0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[3];
	int i,c=0,f=0,x=0;
	for(i=0;i<3;i++){
		scanf("%c",&s[i]);
		if(s[i]=='R') c++;
		if(s[i]!='R') f++;
	}
	for(i=0;i<3;i++){
		if(s[i]=='R'&&s[i+1]=='R') x=1;
	}
	if(x==1||c==0) printf("%d\n",c);
	else if(c<f) printf("%d\n",f-c);
	else printf("%d\n",c-f);
	return 0;
}


Measured memory_bytes: 1636
#include<set>
#include<queue>
#include<cstdio>

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

using namespace std;

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

struct data{
	int S;
	int x,y;
	bool operator<(const data &D)const{
		if(S!=D.S) return S<D.S;
		if(x!=D.x) return x<D.x;
		return y<D.y;
	}
};

int n;

data next_state(int S,int x,int y){
	S|=1<<y*n+x;
	int T=0;
	rep(i,n) rep(j,n) {
		int cnt=0;
		rep(k,8){
			int yy=i+dy[k],xx=j+dx[k];
			if(0<=yy && yy<n && 0<=xx && xx<n && S&(1<<yy*n+xx)) cnt++;
		}
		if(S&(1<<i*n+j)){
			if(cnt==2 || cnt==3) T|=1<<i*n+j;
		}
		else{
			if(cnt==3) T|=1<<i*n+j;
		}
	}
	T&=~(1<<y*n+x);
	return (data){T,x,y};
}

int main(){
	for(;scanf("%d",&n),n;){
		data ini={};
		rep(i,n){
			char s[6]; scanf("%s",s);
			rep(j,n){
				if(s[j]=='#') ini.S|=1<<(i*n+j);
				if(s[j]=='@') ini.x=j, ini.y=i;
			}
		}

		int ans=-1;
		set<data> Vis;
		queue< pair<int,data> > Q; Q.push(make_pair(0,ini));
		while(!Q.empty()){
			int t=Q.front().first;
			data D=Q.front().second; Q.pop();

			if(Vis.count(D)>0) continue;
			Vis.insert(D);

			if(D.S==0){ ans=t; break; }

			rep(k,8){
				int yy=D.y+dy[k],xx=D.x+dx[k];
				if(0<=yy && yy<n && 0<=xx && xx<n && (D.S&(1<<yy*n+xx))==0){
					Q.push(make_pair(t+1,next_state(D.S,xx,yy)));
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, D, A; cin >> N >> D >> A;
    vector<Pll_ll> XH(N);
    REP(i, N) cin >> XH[i].first >> XH[i].second;
    SORT(XH);
    ll cnt = 0;
    if(XH[N-1].first-XH[0].first <= (ll)2*D){
        ll maxa = 0;
        REP(i, N) chmax(maxa, XH[i].second);
        cnt = (maxa + A - 1) / A;
    }
    else REP(i, N){
        if(XH[i].second <= 0) continue;
        ll times = (XH[i].second + A - 1) / A;
        cnt += times;
        ll damage = times * A;
        FOR(j, i+1, N){
            if(XH[i].first + (ll)2*D < XH[j].first) break;
            XH[j].second -= damage;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] t=new int[n];
		int sum=0;
		for(int i=0;i<n;i++){
			t[i]=sc.nextInt();
			sum+=t[i];
		}
		int m=sc.nextInt();
		int[] p=new int[m];
		int[] x=new int[m];
		for(int i=0;i<m;i++){
			p[i]=sc.nextInt();
			x[i]=sc.nextInt();
		}

		for(int i=0;i<m;i++){
			int a=t[p[i]-1]-x[i];
			System.out.println(sum-a);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 36340
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a * b % 2 == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}


Measured memory_bytes: 23892
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=(s[0]-'0')*10+s[1]-'0',b=(s[2]-'0')*10+s[3]-'0';
	if (a==0 && b==0) cout<<"NA";
	else if (a==0 && b>12) cout<<"NA";
	else if (a>12 && b==0) cout<<"NA";
	else if (a>12 && b>12) cout<<"NA";
	else if ((a<=12 && a!=0) && (b<=12 && b!=0)) cout<<"AMBIGUOUS";
	else if (a<=12 && a!=0) cout<<"MMYY"; 
	else cout<<"YYMM";
}

Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: num(4)
      
      read*,num
      
      print*,max(maxval(num(1)*num(3:4)),maxval(num(2)*num(3:4)))
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2920
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//カードの枚数
int d;
bool ban;
int temp;
int main()
{
  while(cin >>n,n){
    vector<int> Card(2*n);
    vector<int> T(n);
    vector<int> H(n);
  for(int i = 0;i < 2*n;i++){
    Card[i] =1;
  }
  for(int i = 0;i <n;i++){
    cin >>T[i];
    Card[T[i] -1] = 0;
  }
  int c = 0;
  for(int i = 0;i <n*2;i++){
    if(Card[i])
      H[c++] = i+1;
  }
  temp = 0;
  while(1){
  sort(T.begin(),T.end());
  sort(H.begin(),H.end());
  ban = true;
  for(int i = 0; i < T.size();i++){
    if(T[i] > temp){
      temp = T[i];
      T.erase(T.begin()+i);
      ban =false;
      break;
    }
  }
  if(ban)
    temp = 0;
  if(T.empty())
    break;
  ban = true;
  for(int i = 0; i < H.size();i++){
  if(H[i] > temp){
    temp = H[i];
    H.erase(H.begin()+i);
    ban =false;
    break;
    }
  }
 if(ban)
   temp = 0;
 if(H.empty())
   break;
  }
  cout <<H.size()<<endl;
  cout<<T.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(){
    int a,b,c;
    int ans;
    scanf("%d %d %d",&a, &b, &c);
    if(a>=b && a>=c) ans = a*10+b+c;
    else if (b>=c && b>=a) ans=b*10+a+c;
    else ans=c*10+b+a;
    printf("%d\n",ans);  
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
  
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
  
const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
   
ll mn[2*MAX_N-1], part[2*MAX_N-1];
int m;
  
void init(int n){
    m=1;
    while(m<n) m*=2;
    for(int i=0; i<2*m-1; i++){
        mn[i]=INF;
        part[i]=INF;
    }
}
 
void eval(int k, int l, int r){
    if(part[k]<INF){
        mn[k]=part[k];
        if(k<m-1){
            part[2*k+1]=part[k];
            part[2*k+2]=part[k];
        }
        part[k]=INF;
    }
}
   
void update(int a, int b, ll x, int k, int l, int r){
  eval(k, l, r);
  if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        part[k]=x;
        eval(k, l, r);
    }else{
        update(a, b, x, k*2+1, l, (l+r)/2);
        update(a, b, x, k*2+2, (l+r)/2, r);
        mn[k]=min(mn[2*k+1], mn[2*k+2]);
    }
}
   
ll find(int a, int b, int k, int l, int r){
  eval(k, l, r);
    if(b<=l || r<=a){
        return INF;
    }
    if(a<=l && r<=b){
        return mn[k];
    }else{
        return min(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
    }
}
  
int main()
{
    int n, q;
    cin>>n>>q;
    init(n);
    for(int i=0; i<q; i++){
        int tp;
        cin>>tp;
        if(tp==0){
            int s, t; ll x;
            cin>>s>>t>>x;
            update(s, t+1, x, 0, 0, m);
        }else{
            int s, t;
            cin>>s>>t;
            cout<<find(s, t+1, 0, 0, m)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7208
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < (i##_MACRO); i++)
#define RANGE(i, a, b) for(int i = (a); i < (b); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d\n", &n);
	char s[10001];
	scanf("%s", s);
	int i = 0;
	while(s[i] != '\n' && s[i] != '\0') {
		s[i] = (((s[i] - 0x41) + n) % 26) + 0x41;
		i++;
	}
	puts(s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  REP(i, n) {
    REP(j, n) {
      cin >> a[i][j];
    }
  }
  vector<ll> dp(1 << n, 0);
  dp[0] = 1;
  REP(i, n) {
    vector<ll> ndp(1 << n, 0);
    REP(j, n) {
      if (a[i][j] == 0) {
        continue;
      }
      REP(k, (1 << n) - 1) {
        if ((k & (1 << j)) == 0) {
          ndp[k | (1 << j)] += dp[k];
          ndp[k | (1 << j)] %= MOD;
        }
      }
    }
    swap(dp, ndp);
  }
  cout << *(dp.rbegin()) << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 35064
#include <bits/stdc++.h>
using namespace std;
#define N 5555
#define mod 1000000007
#define LL long long
int n;
int ec[N],ea[N*2],eb[N*2],tot;
void add(int x, int y) {
    tot++;ea[tot]=y;eb[tot]=ec[x];ec[x]=tot;
}
LL g[N];
inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while (ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while (ch>='0' && ch<='9'){
        x=x*10+ch-'0';ch=getchar();
    }
    return x*f;
}
LL f[N][N],sz[N],tmp[N];
void dfs(int u,int fa) {
    f[u][sz[u]=1] = 1;
    for (int i=ec[u];i;i=eb[i]){
        int v=ea[i];
        if (v==fa) continue;
        dfs(v,u);
        for (int j=0; j<=sz[u]+sz[v];j++) tmp[j]=f[u][j],f[u][j]=0;
        for (int j=1; j<=sz[u];j++){
            for (int k=0;k<=sz[v];k++){
                (f[u][j+k]+=(tmp[j]*f[v][k])%mod)%=mod;
            }
        }
        sz[u]+=sz[v];
    }
    for (int i=2;i<=sz[u];i+=2) {
        f[u][0]-=(f[u][i]*g[i]%mod);
        f[u][0]%=mod;
    }
    if (f[u][0]<0) f[u][0]+=mod;
}
int main(){
    g[0]=1;
    for (int i=2;i<N;i+=2) g[i]=g[i-2]*(i-1)%mod;
    n=read();
    memset(ec,0,sizeof(ec));
    tot=0;
    for (int i=1;i<n;i++){
        int u=read(),v=read();
        add(u,v);add(v,u);
    }
    dfs(1,0);
    cout<<(mod-f[1][0])%mod<<'\n';    
    return 0;
}

Measured memory_bytes: 218880
import java.util.*;

class Main{
    static int[][] field;
    static int w,h;
    static int count;

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

	w = sc.nextInt();
	h = sc.nextInt();

	while(w!=0 && h!=0){
	    field = new int[h][w];
	    for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
		    field[i][j] = sc.nextInt();
		}
	    }

	    solve();

	    System.out.println(count);

	    w = sc.nextInt();
	    h = sc.nextInt();
	}
    }

    public static void solve(){
	count = 0;

	for(int i=0; i<h; i++){
	    for(int j=0; j<w; j++){
		if(field[i][j]==1){
		    setNumber(j,i);
		    //System.out.println(j+" "+i);
		    count++;
		}
	    }
	}
    }

    public static void setNumber(int x, int y){
	int[] numSet = {1,0,-1};

	for(int i=0; i<numSet.length; i++){
	    for(int j=0; j<numSet.length; j++){
		if(!(numSet[i]==0 && numSet[j]==0) && x+numSet[j]>=0 && x+numSet[j]<w && y+numSet[i]>=0 && y+numSet[i]<h){
		    //System.out.println(x+" "+y);
		    if(field[y+numSet[i]][x+numSet[j]]==1){
			//System.out.println(x+" "+y);
			field[y][x] = 0;
			setNumber(x+numSet[j],y+numSet[i]);
			field[y][x] = 1;
		    }
		}
	    }
	}
	//System.out.println("("+x+","+y+")ツづー0ツづ可つオツづ慊つキツ。");
	field[y][x] = 0;
    }
}

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

int main() {
  int n;
  int a[3010];

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

  cout << accumulate(a, a + n, 0) - n << endl; 
}

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

int main(){
  int str[5], i;

  cin >> str[0] >> str[1] >> str[2] >> str[3] >> str[4];

  sort(str, str + 5);

  for(i = 4;i >= 0;i--){
    cout << str[i] << flush;
    if(i != 0){
      cout << " " << flush;
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int N = 1e5+100;
#define ll long long
int main()
{
    string s;
    cin>>s;
    int l = s.size();
    int k = 0;l --;
    int sum = 0;
    while(k <= l){
        if(s[k++] != s[l--]) sum ++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "d"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

// TODO: make 'p' script focus emacs
l const BITS = 20;

// finds lowest x: f(x) = true, x within [a, b), b if f(b - 1) = false
l binary_search_lower(l a, l b, function<bool(l)> f) {
  l count = b - a;
  while (count > 0) {
    l step = count / 2;
    l m = a + step;
    if (f(m)) {
      count = step;
    } else {
      a = m + 1;
      count -= step + 1;
    }
  }
  return a;
}

// finds lowest x: f(x) = true, x within [a, b)
double binary_search_lower_double(double a, double b, function<bool(double)> f) {
  double diff = b - a;
  while (diff > EPS) {
    diff /= 2;
    double m = a + diff;
    if (!f(m)) a = m;
  }
  return a;
}

// TODO: make problem parsers cross platform
void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n);
  VVL(acc, n + 1, BITS, 0);
  F(i, 0, n) {
    cin >> v[i];
    l t = v[i];
    F(j, 0, BITS) {
      acc[i + 1][j] = acc[i][j] + (t % 2);
      t /= 2;
    }
  }
  l z = 0;
  F(i, 0, n) {
    l t = binary_search_lower(0, n - i, [&](l x) {
        l j = n - x;
        F(k, 0, BITS) if (acc[j][k] - acc[i][k] > 1) return false;
        return true;
      });
    z += n - t - i;
  }
  cout << z << endl;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 40832
def solve(n, x, l):
    p = sorted([(a+b, a-b) for a, b in zip(x, l)])
    _, th = p[0]
    best = 0
    for t, s in p:
        if th <= s:
            best += 1
            th = t
    return best

n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i], l[i] = map(int, input().split())
print(solve(n, x, l))

Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll n=s.size();
    vector<string> s0(n);
    vector<ll>ans(n);
    rep(0,i,n){
        s0[i]=s.substr(i,1);
        ans[i]=0;
    }
    ll odd=0,even=0;
    rep(0,i,n){
        if(s0[i]=="R"){
            if(i%2==0)++odd;
            if(i%2==1)++even;
        }if(s0[i]=="L"){
            if(i%2==0){
                ans[i]+=odd;
                ans[i-1]+=even;
            }else{
                ans[i]+=even;
                ans[i-1]+=odd;
            }
            odd=0,even=0;
        }
    }
    rep(0,i,n){
        ll x=n-1-i;
        if(s0[x]=="L"){
            if(x%2==0)++odd;
            if(x%2==1)++even;
        }if(s0[x]=="R"){
            if(x%2==0){
                ans[x]+=odd;
                ans[x+1]+=even;
            }else{
                ans[x]+=even;
                ans[x+1]+=odd;
            }
            odd=0,even=0;
        }
    }
    rep(0,i,n){
        cout<<ans[i];
        if(i!=n-1)cout<<" ";
    }
    cout<<endl;
}

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

int main(){
	int x,y;

	while(1){
		cin >> x >> y;
		if (x==0&&y==0) break;
		if (x>=y){
			cout << y << " " << x << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
	
		
	return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e3+11;
const int M=4e6+11;
const int mod=1e9+7;
int n,k,f[N][N],fac[M],ifac[M];
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int qpow(int a,int b){
    int re=1;
    while(b){
        if(b&1) re=(re*a)%mod;
        b>>=1;a=a*a%mod;
    }return re;
}
int C(int a,int b){
    if(a<b) return 0;
    return fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}
signed main(){
    n=read(),k=read();
    if(k==1) return puts("1"),0;
    fac[0]=1;ifac[0]=1;f[0][0]=1;
    for(int i=1;i<=n*k;i++) fac[i]=fac[i-1]*i%mod;
    ifac[n*k]=qpow(fac[n*k],mod-2);
    for(int i=n*k-1;i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++){
            if(i>j) f[i][j]+=f[i-1][j];
            f[i][j]=(f[i][j]+f[i][j-1]*C((n-j+1)*(k-1)+n-i-1,k-2)%mod)%mod;
        }
    printf("%lld\n",f[n][n]*fac[n]%mod);
    return 0;
}


Measured memory_bytes: 94208
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

void show_array(int length, int *array){
  for(int i = 0; i < length; i++){
    cout << array[i];
    if(i == length-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
}

int main(int argc, char *argv[]){

  int N;
  cin >> N;

  int A[N], B[N], C[N];
  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++) cin >> C[i];

  // sort
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  /*
  cout << "A : "; show_array(N, A);
  cout << "B : "; show_array(N, B);
  cout << "C : "; show_array(N, C);
  */
  int counter[N] = {};
  int cnt = 0, tmp = 0;
  for(int a = 0, b = 0; b < N; b++){
    if(b != 0) counter[b] = counter[b-1];
    while(1){
      if(A[a] < B[b] && a < N){
        //printf("(a, b) = (%d, %d)\n", A[a], B[b]);
        a++;
        counter[b]++;
      }else{
        break;
      }
    }
  }

  //show_array(N, counter);
  long  counterc[N] = {};
  for(int b = 0, c = 0; c < N; c++){
    if(c != 0) counterc[c] = counterc[c-1];
    while(1){
      if(B[b] < C[c] && b < N){
        //printf("(b, c) = (%d, %d)\n", B[b], C[c]);
        counterc[c] += counter[b];
        b++;
      }else{
        break;
      }
    }
  }
  long  sum = 0;
  for(int c = 0; c < N; c++){
    sum += counterc[c];
  }
  //show_array(N, counterc);

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    int x = scanner.nextInt();
    int y = scanner.nextInt();

    List<Integer>[] a = new List[2];
    for (int i = 0; i < 2; i++) a[i] = new ArrayList<>();

    int i = 0;
    while (i < s.length && s[i++] == 'F') x--;

    int j = 1;
    for (; i < s.length; i++) {
      int c = i;
      while (i < s.length && s[i] == 'F') i++;
      if (i > c) a[j].add(i - c);
      j = 1 - j;
    }

    if (solve(a[0], Math.abs(x)) && solve(a[1], Math.abs(y))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean solve(List<Integer> a, int x) {
    final int MAX = 16010;
    boolean[][] dp = new boolean[a.size() + 1][MAX];
    dp[0][0] = true;
    for (int i = 1; i <= a.size(); i++) {
      for (int j = 0; j < MAX; j++) {
        dp[i][j] = false;
        int v = a.get(i - 1);
        if (j - v >= 0) dp[i][j] |= dp[i - 1][j - v];
        if (j + v < MAX) dp[i][j] |= dp[i - 1][j + v];
      }
    }
    return dp[a.size()][x];
  }
}


Measured memory_bytes: 122324
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList <String> W = new ArrayList <String>();
        boolean judge = true;
        
        for(int i=0; i<N; i++){
            String tmp = sc.next();
            if(W.contains(tmp)){
                judge = false;
            }
            W.add(tmp);
            
        }
        

        for(int i=0; i<N-1; i++){
            String str1 = W.get(i);
            String str2 = W.get(i+1);
            int num = str1.length()-1;
            if(str1.charAt(num) == str2.charAt(0)){
                continue;
            }else{
                judge = false;
                break;
            }
        }
        
        if(judge == true) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
    
        }
    }
}


Measured memory_bytes: 35880
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0;i < n;i++){
    cin >> v[i];
  }
  vector<int> c(n);
  for(int i = 0;i < n;i++){
    cin >> c[i];
  }
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(v[i] > c[i]){
      ans += (v[i] - c[i]);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint dp0[2005][2005];
mint dp1[2005][2005];
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n+1), t(m+1);
  for(int i = 0; i < n; i++) cin >> s[i];
  for(int i = 0; i < m; i++) cin >> t[i];
  dp0[0][0] = 1;
  for(int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      // printf("%d %d : %lld %lld\n", i,j,dp0[i][j].x,dp1[i][j].x);
      dp0[i+1][j] += dp0[i][j];
      dp1[i][j] += dp0[i][j];
      dp1[i][j+1] += dp1[i][j];
      if (s[i] == t[j]) {
        dp0[i+1][j+1] += dp1[i][j];
      }
    }
  }
  mint ans = dp1[n][m];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 63232
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = [int(sys.stdin.buffer.readline()) for _ in range(N)]

# 最初が0じゃないとだめ
if A[0] > 0:
    print(-1)
    exit()
ans = 0
for a, b in zip(A, A[1:]):
    if a + 1 < b:
        print(-1)
        exit()
    if a + 1 == b:
        ans += 1
    elif b > 0:
        ans += b
print(ans)


Measured memory_bytes: 12612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n,m;
  cin>>n>>m;
  ll x[n],y[m];
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<m;i++) cin>>y[i];
  ll X=0, Y=0;
  for(int i=1;i<=n;i++){
    (X+=(i-1)*x[i-1]-(n-i)*x[i-1])%=MOD;
  }
  for(int i=1;i<=m;i++){
    (Y+=(i-1)*y[i-1]-(m-i)*y[i-1])%=MOD;
  }
  cout<<(X*Y)%MOD<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
    if (a[i] % 2 == 1) {
    	cout << 0 << endl;
      	return 0;
    }
  }
  
  int even_cnt = 1;
  bool is_continue = true;
  while (is_continue) {
  	for (int i = 0; i < n; i++) {
    	a[i] /= 2;
      	if (a[i] % 2 == 1) {
        	is_continue = false;
          	break;
        }
    }
    if (is_continue) {
    	even_cnt++;
    }
  }
  
  cout << even_cnt << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  for(int i = 0; i < H; i++){
    cin >> C[i];
  }

  for(int i = 0; i < H; i++){
    cout << C[i] << endl;
    cout << C[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,m;
    string s;
    cin>>s;
    if(s[2] == s[3] and s[4] == s[5]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;
vector<string> weather = {"Sunny", "Cloudy", "Rainy"};


int main(){
  string s;cin>>s;
  for (int i = 0; i < 3; i++) {
    if(s == weather.at(i))
    {
      cout << weather.at((i+1)%3) << endl;
    }
  }
}

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

int main(){
	int n,max = -114514,x = 0;
	string s;


	cin >>n >>s;

	for(int i=0;i<n;i++){
		if(s[i] == 'I')
			x++;
		else if(s[i] == 'D')
			x--;

		if(x > max)
			max = x;
	}
	if(max<0)
		max = 0;

	cout << max <<endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <long long> vi;
const int N=3e5+10;
int main() {
    ll i,n,m,k,len,sum=0,l=0,r=0,flag=0;
    string s;
    cin>>s;
    stack<int> st;
    for(i=0;i<s.length();i++){
        if(st.size()==0){
            st.push(s[i]);
        }
        else if(s[i]!=st.top()){
            st.pop();
            sum++;
        }
        else st.push(s[i]);
    }
    cout<<2*sum;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}

using P = pair<i64, int>;

inline void max_assign(i64 &x, const i64 y) {
    x = max(x, y);
}

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for(int i = 0; i < N; i++) {
        i64 a;
        cin >> a;
        A[i] = {a, i};
    }
    sort(REV_WHOLE(A));
    vector2d<i64> dp(N + 1, vector<i64>(N + 1, 0));
    for(int j = 0; j < N; j++) {
        i64 a;
        int i;
        tie(a, i) = A[j];
        // j = x + y
        for(int x = 0; x <= j; x++) {
            int y = j - x;
            max_assign(dp[x + 1][y], a * (i - x) + dp[x][y]);
            max_assign(dp[x][y + 1], a * (N - 1 - y - i) + dp[x][y]);
        }
    }
    i64 ans = 0;
    for(int x = 0; x <= N; x++) {
        int y = N - x;
        max_assign(ans, dp[x][y]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 34656
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

int main(){
  ll N,ax=0,bx=0,x=0; cin >> N;
  vi a,b; a.assign(N,0); b.assign(N,0);
  rep(i,0,N){ cin >> a[i]; x -= a[i]; }
  rep(i,0,N){ cin >> b[i]; x += b[i]; }
  //cout << ax << " " << bx << " " << x << endl;

  rep(i,0,N-1){
    if (b[i] > a[i]) {
      ax += (b[i]-a[i]+1)/2;
      bx += ((b[i]-a[i])%2);
    } else {
      bx += (a[i]-b[i]);
    }
    //cout << ax << " " << bx << endl;
  }
  //rep(i,0,N) cout << a[i] << " " << b[i] << endl;
  //cout << ax << " " << bx << " " << x << endl;
  if (a[N-1]+2*(x-ax) == b[N-1]+x-bx && x >= ax && x >= bx) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N;
	cin >> N;
	vector<ll> H;

	int ans = 0;
	int num = 0;
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		H.pb(tmp);
		if (i != 0) {
			if (H[i-1] >= H[i]) {
				num++;
			} else {
				if (ans < num) {
					ans = num;
				}
				num = 0;
			}
		}
	}

	if (ans < num) {
		ans = num;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1400
from networkx import*
N, M = map(int, input().split())
X = [[0 if a == "#" else 1 if a == "." else 2 for a in input()] for _ in range(N)]
cnt = sum(sum([1 if a == 2 else 0 for a in x]) for x in X)
G = MultiDiGraph()
t = N * M
G.add_node(t, demand = cnt)
for i in range(N):
    for j in range(M):
        if X[i][j] == 0: continue
        a = i * M + j
        G.add_node(a, demand = 1 - X[i][j])
        G.add_edge(a, t, capacity = 1, weight = 0)
        if i + 1 < N and X[i+1][j]:
            b = a + M
            G.add_edge(a, b, capacity = N * M, weight = -1)
        if j + 1 < M and X[i][j+1]:
            b = a + 1
            G.add_edge(a, b, capacity = N * M, weight = -1)

print(-min_cost_flow_cost(G))

Measured memory_bytes: 63348
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int L;

int main()
{
  int n;
  int ret=0;
  double len;

  cin >> L;

  len = (double)L/3;
  printf("%lf\n", len*len*len);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll N,M;
vector<vector<ll>> adj;
map<ll,ll> depth;

ll func(ll n){
	if(depth[n])return depth[n];
	ll ans = 1;
	for(auto x:adj[n])chmax(ans,func(x)+1);
	return depth[n] = ans;
}

signed main(){
	cin >> N >> M;
	adj.resize(N);
	FOR(i,0,N-1+M){
		ll A,B;
		cin >> A >> B;
		A--;
		B--;
		adj[B].pb(A);
	}
	FOR(i,0,N)func(i);
	FOR(i,0,N){
		bool flag = 1;
		for(auto x:adj[i]){
			if(depth[x] + 1 == depth[i]){
				cout << x+1 << endl;
				flag = 0;
				break;
			}
		}
		if(flag)cout << 0 << endl;
	}
}

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

int main(){
	int n, k;
	cin >> n >> k;
	
	int m;
	map<pair<string, string>, int> mp;
	for(int i = 0;i < n;i++){
		cin >> m;
		
		string item[20];
		for(int j = 0;j < m;j++){
			cin >> item[j];
		}
		
		sort(item, item+m);
		
		for(int j = 0;j < m;j++){
			for(int k = j+1;k < m;k++){
				pair<string, string> p = {item[j], item[k]};
				mp[p]++;
			}
		}
	}
	
	vector<pair<string, string>> ans;
	for(auto a : mp){
		if(a.second >= k){

			ans.push_back(a.first);
		}
	}
	
	cout << ans.size() << endl;
	
	sort(ans.begin(), ans.end());
	
	for(auto a : ans){
		cout << a.first << " " << a.second << endl;
	}
	
	return 0;
}
		
		


Measured memory_bytes: 3692
def is_prime(n):
  i=2
  r=[]
  while i*i<=n:
    if n%i==0:
      c=0
      while n%i==0:
        c+=1
        n//=i
      r.append((i,c))
    i+=1
  if n> 1:
    r.append((n,1))
  return r

def main():
  n=int(input())
  r=0
  for p,e in is_prime(n):
    i=1
    while e>=i:
      r+=1
      e-=i
      i+=1
  return r
print(main())

#nの素数判定
# def is_prime(n):
#     if n == 1:
#         return False
#     for i in range(2,int(n**0.5)+1):
#         if n % i == 0:
#             return False
#     return True

# def is_prime(n):
#   i=2
#   table=[]
#   while i*i<=n:
#     while n%i == 0:
#       n//=i
#       table.append(i)
#     i+=1
#   if n>1:
#     table.append(n)
#   return table

# from itertools import groupby
# n=int(input())
# p=is_prime(n)

# ans = 0

# for v, g in groupby(p):
#   n=len(list(g))
#   for i in range(1,100000):
#     n-=i
#     if n>=0:
#       ans+=1
#     else:
#       break
# print(ans)

Measured memory_bytes: 9204
until(a=(1..(m=gets.to_i)).map{|i|[i]})==[]
until(i,j=gets.split.map(&:to_i))==[0,0]
next if(t=a.find{|p|p.include?(i)}).index(i)==0&&j==0||t.include?(j)&&t.index(i)>=t.index(j)
a<<[t.pop]until t.last==i
t.pop
j>0?a.find{|p|p.include?(j)}<<i :a<<[i]end
puts a.map(&:size).sort.select{|i|i>0},:end
end

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

#define mod 1000000007

using namespace std;
using ll=long long;

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

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

    ll res = 0;
    ll cnt[100001] = {};
    for (ll i = K; i > 0; --i) {
        cnt[i] += mypow((K / i), N);
        for (ll j = 2; j <= K; ++j) {
            if (i * j <= K) {
                cnt[i] -= cnt[i * j];
            } else {
                break;
            }
        }
        res += (cnt[i] * i) % mod;
    }
    res = res % mod;
    cout << res;
    return 0;
}

Measured memory_bytes: 4404
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc162_c solver = new abc162_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc162_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            long ans = 0;
            for (int a = 1; a <= K; a++) {
                for (int b = 1; b <= K; b++) {
                    for (int c = 1; c <= K; c++) {
                        ans += gcd(gcd(a, b), c);
                    }
                }

            }
            out.println(ans);
        }

        private long gcd(long m, long n) {
            if (m < n) return gcd(n, m);
            if (n == 0) return m;
            return gcd(n, m % n);
        }

    }
}



Measured memory_bytes: 36392