akhauriyash/Code-Regression huggingface dataset:
class Tree
  class Node
    attr_accessor :id, :parent, :depth, :type, :children
    def initialize(id,parent,depth,type,children)
      @id = id
      @parent = parent
      @depth = depth
      @type = type
      @children = children
    end
  end
  
  attr_accessor :nodes
  def initialize
    @nodes = []
    @parents = {}
  end

  def update(node)
    if !node
      return
    end
    node.parent = @parents[node.id]
    node.depth = @nodes[node.parent].depth + 1
    if node.children == []
      node.type = "leaf"
    else
      node.type = "internal node"
    end
    node.children.each do |c|
      update(@nodes[c])
    end
  end

  def addNode(id,children)
    if !@parents[id]
      type = "root"
      parent = -1
      depth = 0
    else
      parent = @parents[id]
      depth = @nodes[parent].depth + 1
      if children == []
        type = "leaf"
      else
        type = "internal node"
      end
    end
    nodes[id] = Node.new(id,parent,depth,type,children)
    
    children.each do |c|
      @parents[c] = id
      update(@nodes[c])
    end
  end
end

t = Tree.new
n = gets.to_i
(n).times do
  id,_,*children = gets.split.map(&:to_i)
  t.addNode(id,children)
end

(n).times do |i|
  node = t.nodes[i]
  printf("node %d: parent = %d, depth = %d, %s, [%s]\n", node.id, node.parent, node.depth, node.type, node.children.join(", "))
end


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

using vi = vector<int>;
#define sz(x) (int)(x.size())
#define pb push_back

const int mxn = 1e5;
int n,m;
vi adj[mxn];
bool used[mxn];
int a[mxn],b[mxn];

bool dfs(int v, int t) {
  if (v == t) return 1;
	for (int e : adj[v]) if (!used[e]) {
    	used[e] = 1;
      int w = a[e]^b[e]^v;
      	if (dfs(w,t)) return 1;
      	used[e] = 0;
    }
  return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
  cin>>n>>m;
  for (int i = 0; i < m; i++) {
    cin>>a[i]>>b[i];
    adj[--a[i]].pb(i); adj[--b[i]].pb(i);
  }
  fill(used,used+m,0);
  bool get = 0;
  for (int i = 0; i < n; i++) get |= sz(adj[i])>=6;
  int cnt = 0;
  for (int i = 0; i < n; i++) cnt += sz(adj[i]) == 4;
  get |= cnt>=3;
  
  if (cnt==2) {
    int x = -1, y = -1;
    for (int i = 0; i < n; i++) if (sz(adj[i])==4) {
      if (x==-1) x=i;
      else if (y==-1) y=i;
    }
    dfs(x,y);
    get |= dfs(x,y)&&!dfs(x,y);
  }
  for (int i = 0; i < n; i++)
    get &= sz(adj[i])%2==0;
  cout << (get?"Yes":"No") << endl;
  
  	return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/segtree>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

int e() {return 0;}
int op(int s1, int s2) {return max(s1, s2);}
int v;
int f(int s) {return s < v;}

int main() {
    int n, q, t, x, y;
    cin >> n >> q;

    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    segtree<int, op, e> st(a);
    rep(i, 0, q) {
        cin >> t >> x >> y;

        if (t == 1) {
            st.set(x - 1, y);
        } else if (t == 2) {
            cout << st.prod(x - 1, y) << endl;
        } else {
            v = y;
            cout << st.max_right(x - 1, f) + 1 << endl;
        }
    }
}


Measured memory_bytes: 5704
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;vector<int> a(n);REP(i,n)cin>>a[i];
	int ct = 0;
	REP(i,n){
		int mini = i;
		FOR(j,i,n){
			if(a[j] < a[mini])mini = j;
		}
		if(i!=mini){
			swap(a[i],a[mini]);
		ct++;
		}
	}
	REP(i,n){
		if(i)cout << ' ';
		cout << a[i];
	}
	cout << '\n';
	cout << ct << endl;
  return 0;
}

Measured memory_bytes: 3220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        int[] abcd = inta();
        int def = (int)Ceiling((double)abcd[0] / abcd[3]);
        int atk = (int)Ceiling((double)abcd[2] / abcd[1]);
        if(atk > def) Write("No");
        else Write("Yes");
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27376
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int N,K,Q;
int d[SIZE];
int main(){
    R(N,K,Q);
    REP(i,Q){
        int id;R(id);
        d[id]++;
    }
    FOR(i,1,N){
        if(K-(Q-d[i])<=0)W("No");
        else W("Yes");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, M, X, i, j;
  cin >> N >> M >> X;
  vvi A(N, vi(M));
  vi C(N);
  REP(0, N, i) {
    cin >> C[i];
    REP(0, M, j) {
      cin >> A[i][j];
    }
  }

  using ull = unsigned long long;
  ull b;  
  i64 ans = -1;
  REP(0ULL, 1ULL<<N, b) {
    vi Y(M, 0);
    i64 p = 0;
    REP(0, N, i) {
      if((b & (1<<i)) != 0) {
	REP(0, M, j) {
	  Y[j] += A[i][j];
	}
	p += C[i];
      }
    }
    bool valid = true;
    REP(0, M, j) {
      if(Y[j] < X) {
	valid = false;
	break;
      }
    }
    if(valid) {
      if(ans == -1)
	ans = p;
      else
	ans = min(ans, p);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=4e4+7;
const int mod=(476<<21)+1,g=3;

il ll qpow(ll x,ll y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}

ll wn[N],fac[N],inv[N];

il void dft(ll *a,int n){
	for(int i=0,j=0;i<n;++i){
		if(j>i) swap(a[i],a[j]);
		for(int k=n>>1;(j^=k)<k;k>>=1); 
	}
	for(int i=2,id=1;i<=n;i<<=1,++id){
		ll w=wn[id];
		int len=i>>1;
		for(int j=0;j<n;j+=i){
			ll cur=1;
			for(int k=j;k<j+len;++k){
				ll u=a[k],v=a[k+len]*cur%mod;
				a[k]=(u+v)%mod,a[k+len]=(u-v+mod)%mod;
				cur=cur*w%mod; 
			}
		} 
	}
}

char s[N],t[N];
int n,m,e,len;
ll ans[N],a[N];

int main(){
	rep0(i,22) wn[i]=qpow(g,(mod-1)>>i);
	fac[0]=1;
	rep(i,1,N-1) fac[i]=fac[i-1]*i%mod;
	scanf("%s%s",s,t),n=strlen(s);
	rep0(i,n){
		if(s[i]=='1'&&t[i]=='1') ++m;
		if(s[i]=='1'&&t[i]=='0') ++e;
	} 
	for(len=2;len<=2*m;len<<=1);
	rep(i,0,m) a[i]=qpow(fac[i+1],mod-2);
	ans[0]=1;
	ll inv=qpow(len,mod-2),pw=e;
	while(pw){
		dft(a,len);
		if(pw&1){
			dft(ans,len);
			rep0(i,len) ans[i]=ans[i]*a[i]%mod;
			dft(ans,len);
			reverse(ans+1,ans+len);
			rep0(i,len) ans[i]=ans[i]*(i>m?0:inv)%mod;
		}
		rep0(i,len) a[i]=a[i]*a[i];
		dft(a,len);
		reverse(a+1,a+len); 
		rep0(i,len) a[i]=a[i]*(i>m?0:inv)%mod;
		pw>>=1;
	}
	ll sum=0;
	rep(i,0,m) sum=(sum+ans[i])%mod;
	printf("%lld\n",sum*fac[e]%mod*fac[m]%mod*fac[e+m]%mod);
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int r[250001],l[250001];
int cnt=0;
void merge(int A[],int left,int mid,int right);
void mergeSort(int A[],int left,int right);
int main(){
  int n,i,left,mid,right;
  int A[500010];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
  printf("%d",A[i]);
  if(i!=n-1)printf(" ");
  else printf("\n");
  }
  printf("%d\n",cnt);
  return 0;
}
void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    l[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    r[i]=A[mid+i];
  }
  l[n1]=1000000000;
  r[n2]=1000000000;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(l[i]<=r[j]){
      A[k]=l[i];
      i=i+1;
    }
    else{
      A[k]=r[j];
      j=j+1;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

  



Measured memory_bytes: 5588
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
#include<set>
using namespace std;

int n;

vector<int> fenech(1000001,-1);
vector<int> sunuke(1000001,-1);

void dfs(int c,int depth,vector<vector<int> >& tree, vector<int>& memo){
	if(memo[c] != -1) return;
	memo[c] = depth;

	for(int i=0;i<tree[c].size();++i){
		int next = tree[c][i];
		dfs(next,depth+1,tree,memo);
	}
}


int main(){
	cin >> n;
	vector<vector<int> > tree(n+1);

	int a,b;
	for(int i=1;i<n;++i){
		cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	dfs(1,0,tree,fenech);
	dfs(n,0,tree,sunuke);

	int nfenech = 0;
	int nsunuke = 0;

	for(int i=1;i<=n;++i){
		if(fenech[i] <= sunuke[i]){
			nfenech++;
		}else{
			nsunuke++;
		}
	}

	if(nfenech > nsunuke) cout << "Fennec" <<endl;
	else cout << "Snuke" <<endl;
	
	return 0;
}




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

int main(){
  int A, B;
  cin >> A >> B;
  int i = 1;
  int c = 0;
  
  while(i<B){
    i+= A-1;
    c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10**5)
n,u,v=map(int,input().split())
u=u-1
v=v-1
root=[[] for i in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append(b-1)
    root[b-1].append(a-1)

dp=[[-1]*n for i in range(2)]
dp[0][u]=0
dp[1][v]=0
def dfs(node,depth,par,flag):
    for vertex in root[node]:
        if vertex == par or dp[flag][vertex]!=-1:
            continue
        dp[flag][vertex]=depth+1
        dfs(vertex,depth+1,node,flag)
    return
dfs(u,0,u,0)
dfs(v,0,v,1)
buf=-1
buf1=0
#print(dp1,dp2,root)
for i in range(n):
    if dp[0][i]<dp[1][i] and dp[1][i]>buf:
        buf=dp[1][i]
        buf1=dp[0][i]
print(buf-1)


Measured memory_bytes: 104112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x=1, N, K;
  
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    if(x < K) x *= 2;
    else x += K;
  }
  
  cout << x << endl;
}


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

using namespace std;

int main() {
	int N;
	cin >> N ;
	vector<int>t(N+1); 
	vector<int>x(N+1); 
	vector<int>y(N+1);
	for (int n = 0;n < N;++n) {
		cin >> t[n+1] >> x[n+1]>>y[n+1];
	}
	vector<int>t2(N);
	vector<int>x2(N);
	vector<int>y2(N);
	for (int n = 0; n < N; ++n) {
		t2[n] = t[n + 1] - t[n];
		x2[n] = x[n + 1] - x[n];
		y2[n] = y[n + 1] - y[n]; 
		//cout << t2[n]<<x2[n]<< y2[n]<< endl;
	}
	for (int n = 0; n < N; ++n) {
		int x, y;
		if (x2[n] > 0) {
			x = x2[n];
		}
		else {
			x = -x2[n];
		}
		if (y2[n] > 0) {
			y = y2[n];
		}
		else {
			y = -y2[n];
		}
		//cout << t2[n]<<x << y <<endl;
		if (1 == t2[n]%2) {
			if (1 == (x+y) % 2) {
				if ( (x+y) <= t2[n]) {
					//
				}
				else {
					cout << "No" << endl;
					return 0;
				}
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (0 == (x + y) % 2) {
				if ((x + y) <= t2[n]) {
					//
				}
				else {
					cout << "No" << endl;
					return 0;
				}
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,t[55];
string s[55],X;
map<string,int> mp;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		cin>>s[i];
		t[i]=read();
	}
	for(int i=n;i>=1;--i){
		t[i]+=t[i+1];
		mp[s[i]]=t[i+1];
	}
	cin>>X;
	printf("%d\n",mp[X]);
	return 0;
}



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

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

    char b;
    cin >> b;

    if (b == 'A')
    {
        cout << 'T' << endl;
    }
    else if (b == 'T')
    {
        cout << 'A' << endl;
    }
    else if (b == 'C')
    {
        cout << 'G' << endl;
    }
    else
    {
        cout << 'C' << endl;
    }

    return 0;
}

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

int h, w;
int maxi = 0;
char field[20][20] = {'#'};
int seen[20][20];

void seen_init(){
    rep(i, 20){
        rep(j, 20){
            seen[i][j] = INF;
        }
    }
}

void dfs(int now_x, int now_y, int cnt){

    // fieldの中にいるかを確認する
    if(now_x < 0 || now_y < 0 || w <= now_x || h <= now_y){
        return;
    }
    // 壁を判定する
    if(field[now_y][now_x] == '#'){
        return;
    }
    //探索箇所の手数が最小でない場合はreturn
    if(seen[now_y][now_x] <= cnt){
        return;
    }
    seen[now_y][now_x] = cnt;

    int x[4] = {0, 1, 0, -1};
    int y[4] = {1, 0, -1, 0};
    rep(i, 4){
        dfs(now_x + x[i], now_y + y[i], cnt + 1);
    }
}

int main() {
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> field[i][j];
        }
    }
    rep(start_y, h){
        rep(start_x, w){
            if(field[start_y][start_x] != '#') {
                seen_init();
                dfs(start_x, start_y, 0);
            }
            rep(i, h){
                rep(j, w){
                    if(field[i][j] != '#' && seen[i][j] != INF) {
                        maxi = max(maxi, seen[i][j]);
                    }
                }
            }
        }
    }
    cout << maxi << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a[9];
  int b[9];
  
  int i, j;
  
  for( i = 0; i < 9; i++ ){
    a[i] = i + 1;
    b[i] = i + 1;
  }
  
  for( i = 0; i < 9; i++ ){
    for( j = 0; j < 9; j++ ){
      printf("%dx%d=%d\n", a[i], b[j], a[i]*b[j] );
    }
  }
  
      
  
  return 0;
}

Measured memory_bytes: 524
#ifdef LOCAL111
#else
	// #define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

const LL mod = 1e9+7;
// LL dp[405][405];

long long modpow(long long a, long long b, long long modd = mod){
	a %= modd;
	if(a == 0) return 0;
	long long res = 1;
	while(b != 0){
		if(b&1) res = res*a%modd;
		a = a*a%modd;
		b >>= 1;
	}
	return res;
}

int main()
{
	ios_init();
	int n,c;
	cin >> n >> c;
	vector<int> a(n),b(n);
	REP(i,n) cin >> a[i];
	REP(i,n) cin >> b[i];
	vector<vector<LL>> sum(n,vector<LL>(c+1,0));
	REP(i,n){
		FOR(k,a[i],b[i]+1){
			LL pp = 1;
			REP(j,c+1){
				sum[i][j] += pp;
				sum[i][j] %= mod;
				pp *= k;
				pp %= mod;
			}
		}
	}
	vector<vector<LL>> dp(n+1,vector<LL>(c+1,0));
	dp[0][0] = 1;
	REP(i,n){
		REP(j,c+1){
			REP(k,j+1){
				dp[i+1][j] += dp[i][j-k]*sum[i][k];
				dp[i+1][j] %= mod;
			}
		}
	}
	cout << dp[n][c] << endl;
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;

    cout<<min(b/a, c);

    return 0;
}/*

*/

Measured memory_bytes: 256
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static int n;

	public static void main(String[] args) {

		Main main = new Main();

		Set<Integer> set = new HashSet<>(5);
		int[][] arr = main.scan();
		int candies = 0;
		int f = 0;
		for (int i = 0; i < n; i++) {
			f += arr[0][i];
			for (int j = i; j < n; j++) {
				candies += arr[1][j];
			}
			set.add(f + candies);
			candies = 0;
		}

		System.out.println(Collections.max(set));
	}

	private int[][] scan() {

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[][] arr = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		sc.close();
		return arr;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,S=0;
  cin >> N;
  S = N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i = 0; i < N-1; i++){
    if(vec[i]==vec[i+1]){
      S -= 1;
    }
  }
  cout << S <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    //はじめすべてのマスが白い
    int N, M, K;
    cin >> N >> M >> K;
    REP(i, N + 1) {
        REP(j, M + 1) {
            int k = i * (M - j) + j * (N - i);
            if(k == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i += 2) {
    int x = divisor(i);
    if (x == 8) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int H, W;
    cin >> H >> W;
    vec<vec<int>> G(10, vec<int>(10));
    rep(i, 10) rep(j, 10) {
        int d;
        cin >> d;
        G[i][j] = d;
    }

    function<void(int)> warshall_floyd = [&](int n) {
        for (int k = 0; k < n; k++) {            // 経由する頂点
            for (int i = 0; i < n; i++) {        // 始点
                for (int j = 0; j < n; j++) {    // 終点
                    G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
                }
            }
        }
    };

    warshall_floyd(10);

    int ans = 0;
    rep(i,H*W){
        int k;cin>>k;
        if(k==-1)continue;
        ans+=G[k][1];
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
while(1){

int H,W;

cin >>H>>W;

if (H == 0&& W==0) break;

for(int i=0;i<H;i++){

for(int j=0;j<W;j++){
if(i==0||i==H-1||j==0||j==W-1) cout<<"#";
else cout<<".";
}
cout<<endl;
}

cout<<endl;
}
return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std ;
const int N = 1e5+5 ;
long long a[N],b[N],n,m,v,p ; 
inline bool check(long long mid,long long n,long long m,long long v,long long p){
	memcpy(b,a,sizeof a) ;
	for(int i = mid ; i <= n ; i++){ if(!v) break ; b[i] += m ;	v-- ; }
	for(int i = 1 ; i < p ; i++){ if(!v) break ; b[i] += m ; v-- ; }
	long long rest = v*m ;
	if(rest == 0) return b[mid] >= b[p] ;
	for(int i = p ; i < mid ; i++){
		if(b[i] - b[mid] > 0) return false ;
		rest -= min(m,b[mid]-b[i]) ;
		if(rest <= 0) break ; 
	}
	if(rest > 0) return 0 ;
	return true ; 
}
int main(){
//	freopen("in.txt","r",stdin) ;
	ios::sync_with_stdio(false) ;
	cin >> n >> m >> v >> p ;
	for(int i = 1 ; i <= n ; i++) cin >> a[i] ;
	sort(a+1,a+n+1,greater<long long>()) ;
	int l = p,r = n ;
	while(l < r){
		int mid = (l+r+1)>>1 ;
		if(check(mid,n,m,v,p)) l = mid ;
		else r = mid-1 ; 
	}
	cout << l << endl ; 
	return 0 ; 
}

Measured memory_bytes: 4748
#include<stdio.h>
#include<math.h>
double d,r,s,z[6];
int n,i,j,a[50];
int main(){
	for(scanf("%d",&n);n--;){
		for(i=0;i<6;i++)
			scanf("%lf",z+i);
		r=z[2];
		s=z[5];
		d=hypot(*z-z[3],z[1]-z[4]);
		printf("%d\n",a[j++]=d>r+s?0:r>d+s?2:s>d+r?-2:1);
	}
	
	return
		n==14 &&
		a[0]==1 &&
		a[1]==1 &&
		a[2]==1
		/* &&
		a[3]==0 &&
		a[4]==2 &&
		a[5]==2 &&
		a[6]==-2 &&
		a[7]== 0&&
		a[8]== 0&&
		a[9]==1 &&
		a[10]==1 &&
		a[11]==-2 &&
		a[12]==1 &&
		a[13]==2
		*/
		;
}

Measured memory_bytes: 0
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    py = [list(map(int, readline().split())) for _ in range(m)]
    for i in range(m):
        py[i].append(i)
    py.sort()
    d = collections.defaultdict(int)
    for i in range(m):
        d[py[i][0]] += 1
        py[i].append(d[py[i][0]])
    py.sort(key=lambda x: x[2])
    for i in range(m):
        print("".join((["0"] * 6 + list(str(py[i][0])))[-6:] + (["0"] * 6 + list(str(py[i][-1])))[-6:]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 73436
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define ctoi(x) ((x)-'0')

int main() {
  int n;
  cin>>n;
  vector<int> a(n),p(n),q(n);
  int x,y;
  rep(i,n){
    cin>>p[i];
  }
  rep(i,n){
    cin>>q[i];
  }
  rep(i,n){
    a[i]=i+1;
  }
  int i=0;
  do{
    if(a==p){
      x=i+1;
    }
    if(a==q){
      y=i+1;
    }
    i++;
  }while(next_permutation(all(a)));
  cout<<abs(x-y)<<endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
n,m,q=map(int, input().split())
 
tmp = 0
max = 0
a = []
b = []
c = []
d = []
 
for i in range(q):
  A, B, C, D = map(int, input().split())
  a.append(A)
  b.append(B)
  c.append(C)
  d.append(D)
 
nums = range(1, m + 1)
 
for retsu in itertools.combinations_with_replacement(nums, n): 
    for i in range(q):
        if int(retsu[b[i]-1]) - int(retsu[a[i]-1]) == c[i]:
            tmp = tmp + d[i]
        if max < tmp:
            max = tmp
    tmp = 0
 
print(max)

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

RMax = 0
R = []


for i in range(N):
	r = int(input())
	if i == 0:
		rmi = r
	if i == 1:
		RMax = r - R[0]
	if i > 0:		
		rdif = (r - rmi)
		if rdif >= RMax:
			RMax = rdif
	R.append(r)
	if r < rmi:
		rmi = r

print(RMax)

Measured memory_bytes: 15568
#include<iostream>
using namespace std;
#define m long long
#define d(s,i,n) for(m i=s;i<n;i++)
#define z else
int main(){m n,a,b,o=1e9+7,x=90,l[x][x],r[x][x];cin>>n;d(0,i,x){l[i][0]=r[i][0]=1;d(1,j,x){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,x)if(a>=r[0][j]&&b>=l[0][j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]<r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%o<<" ";}}

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

int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char> >a(h);
  vector<vector<int> >r(h);
  vector<vector<int> >re(h);
  for(int i=0;i<h;i++)
  {
  	a[i].resize(w);
    r[i].resize(w);
    int t=-1;
    for(int j=0;j<w;j++)
    {
      cin>>a[i][j];
      if(a[i][j]=='#')
      {
        t=j;
      }
      r[i][j]=t;
    }
  }
  for(int i=0;i<h;i++)
  {
    re[i].resize(w);
    int t=w;
    for(int j=w-1;j>=0;j--)
    {
      if(a[i][j]=='#')
      {
        t=j;
      }
      re[i][j]=t;
    }
  }
  
  
  vector<vector<int> >c(h);
  for(int j=0;j<w;j++)
  {
    int t=-1;
    for(int i=0;i<h;i++)
    {
      if(j==0)c[i].resize(w);
      if(a[i][j]=='#')
      {
        t=i;
      }
      c[i][j]=t;
    }
  }
  vector<vector<int> >ce(h);
  for(int j=0;j<w;j++)
  {
    int t=h;
    for(int i=h-1;i>=0;i--)
    {
      if(j==0)ce[i].resize(w);
      if(a[i][j]=='#')
      {
        t=i;
      }
      ce[i][j]=t;
    }
  }
  int ans=0;
  for(int i=0;i<h;i++)
  {
    
    for(int j=0;j<w;j++)
    {
      int t=0;
      if(a[i][j]=='#')continue;
      t+=(j-r[i][j]-1);
      t+=(re[i][j]-j-1);
      t+=(i-c[i][j]-1);
      t+=(ce[i][j]-i-1);
      t++;
      if(t>ans)ans=t;
      //cout<<t<<" ";
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
 //cout<<c[0][1]<<endl;
  return 0;
}

Measured memory_bytes: 70408
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
#define MOD 1000000007
#define ll long long int 


ll n,k,num[2005],sum,cur,prv; 
pair<int , int> a[2005];

void f(int x){
	for(int i=0;i<x;i++){
		if(num[x]>num[i])
			cur++;
	}
	for(int i=x+1; i<n;i++){
		if(num[x]>num[i])
			prv++;
	}
}

ll cnt(ll x){
	ll s=1;
	for(int i=2;i<=x;i++){
		s+=i;
	}
	return s%MOD;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	
	for(int i=0;i<n;i++) f(i);
	
	ll y=cnt(k-1);
//	cout<<cur<<" "<<prv<<" ";
	
	sum+=cur*y+prv*(y+k);
	sum%=MOD;
	
	cout<<sum<<"\n";
	return 0;
}




Measured memory_bytes: 256
n,k=map(int,input().split())
hi=[]
for i in map(int,input().split()):
    hi.append(i)
if n<=k:
    print(0)
else:
    hi.sort()
    hsum=0
    for i in range(n-k):
        hsum=hsum+hi[i]
    print(hsum)

Measured memory_bytes: 26024
<?php

$inputs = [];

for ($i = 0; $i < 3; ++$i) {
    $inputs[] = explode(' ', trim(fgets(STDIN)));
}

$num = trim(fgets(STDIN));

$targets = [];
for ($i = 0; $i < $num; ++$i) {
    $targets[] = trim(fgets(STDIN));
}

$bingos = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
];

foreach ($inputs as $row => $inputs_row) {
    foreach ($inputs_row as $column => $input) {
        if (in_array($input, $targets, true)) {
            $bingos[$row][$column] = 1;
        }
    }
}

$complete = false;

foreach ($bingos as $bingos_row) {
    if (array_sum($bingos_row) === 3) {
        $complete = true;
    }
}

for ($i = 0; $i < count($bingos); ++$i) {
    if ($bingos[0][$i] + $bingos[1][$i] + $bingos[2][$i] === 3) {
        $complete = true;
    }
}

if ($bingos[0][0] + $bingos[1][1] + $bingos[2][2] === 3) {
    $complete = true;
}

if ($bingos[0][2] + $bingos[1][1] + $bingos[2][0] === 3) {
    $complete = true;
}

echo $complete ? 'Yes' : 'No', PHP_EOL;


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  string s;
  ll n;
  ll a,b,c;
  cin >> a >> b >> c;
  ll ans=0;
  if((b-c)*(a-c)<0)cout << "Yes" << endl;
  else cout << "No"<< endl;
}


Measured memory_bytes: 256
n = int(input())
p = [int(x) for x in input().split()]
p_copy = p[:]

p.sort()

count = 0
for i in range(n):
    if p[i] != p_copy[i]:
        count += 1

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

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

int main(){
  int n = 0;
  cin >> n;
  int count = 200;
  for (int i = 0;i < n;i++) {
    int subcount = 0;
    int a =0;
    cin >> a;
    for (int j = a;j > 1;j /= 2){
      if( (j % 2) == 1) {
        break;
      }
      else {
        subcount++;
      }
    }
    if (count > subcount){
      count = subcount;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3636
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  ll N, K;
  ci(N, K);
  ll a = N % K;
  ll b = K - a;
  co(min(a, b));
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2;
}

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

int main()
{
  int N, M;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    map<char, char> m;
    char d, s;
    for (int i = 0; i < N; i++) {
      scanf("%c %c ", &s, &d);
      m[s] = d;
    }
    scanf("%d ", &M);
    char c;
    for (int i = 0; i < M; i++) {
      scanf("%c ", &c);
      if (m.count(c) == 1) {
	c = m[c];
      }
      putchar(c);
    }
    puts("");
  }
  return 0;
}

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

void solve() {
    ll a;
    int b1, b2;
    scanf("%lld %d.%d", &a, &b1, &b2);

    ll ans = a*(b1*100+b2);
    printf("%lld\n", ans/100);

}

int main(){

    solve();

	return 0;
}


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

int main() {
    int H, W;
    
    while(true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for(int y = 0; y < H; y++) {
            if (y % 2 == 0) {
                for(int x = 0; x < W; x++) {
                    if (x % 2 == 0) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            } else {
                for(int x = 0; x < W; x++) {
                    if (x % 2 == 0) {
                        cout << ".";
                    } else {
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
n=int(input())
INF=10**9+7
Num=[0]*(n+1)
for x in range(2,n+1):
    i=2
    while i*2<=x:
        while x%i==0:
            x=x//i
            Num[i]+=1
        i=i+1
    if not x==1:
        Num[x]+=1
ans=1
for i in Num:
    ans=(ans*(i+1))%INF
print(ans)


Measured memory_bytes: 39408
def check(i):
    for j in range(len(T)):
        if T[j] == S[i+j] or S[i+j] == "?":
            continue
        return False
    return True


def okikae(i):
    for j in range(len(T)):
        S[i+j] = T[j]
    return

S = list(input())
T = list(input())

for i in reversed(range(len(S)-len(T)+1)):
    if check(i) is True:
        last = i
        break
else:
    print("UNRESTORABLE")
    exit()

okikae(last)

for i in range(len(S)):
    if S[i] == "?":
        S[i] = "a"
print("".join(S))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
N = int(input())

ans = 0
for i in range(1,N+1):
    if i % 2 != 0:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1

print(ans)


Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i += 2) {
			if (getDivisor(i) == 8) {
				count++;
			}
		}
		System.out.println(count);
	}

	private static int getDivisor(int i) {
		int divisor = 0;
		int sqrt = (int) Math.sqrt(i);
		for (int j = 1; j <= sqrt; j++) {
			if (i % j == 0) {
				divisor += (j * j == i) ? 1 : 2;
			}
		}
		return divisor;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e6+10;
const int maxm=1e4+10;
int num[maxx];
int f(int x,int y,int z){
	return x*x+y*y+z*z+x*y+y*z+z*x; 
}
void init(){
	int x=1,y=1,z=1;
	for(x=1;f(x,1,1)<maxm;x++){
		for(y=1;f(1,y,1)<maxm;y++){
			for(z=1;f(1,1,z)<maxm;z++){
				int k=f(x,y,z);
				num[k]++;
			}
			z=1;
		}
	}
	
}
int main() {
	memset(num,0,sizeof(num));
	int n;
	scanf("%d",&n);
	init();
	rep(i,1,n+1){
		cout<<num[i]<<endl;
	}
} 

Measured memory_bytes: 7572
import sys

num = sys.stdin.readline().split(' ')
N = int(num[0])
Y = int(num[1])


for x in range(N+1):
    for y in range(N+1):
        if 10000 * x + 5000 * y + 1000*(N-x-y) == Y and N-x-y >= 0:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
        else:
            continue

print('-1 -1 -1')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int solve(int n,int k,int a[],int dp[])
{
    if(n<=0)
     return 0;
    if(dp[n]!=-1)
     return dp[n];
    int ans=INT_MAX;
    for(int i=n-1;i>=n-k && i>=0;i--)
    {
       ans=min(ans,abs(a[n]-a[i])+solve(i,k,a,dp));
       
       
    }
    return dp[n]=ans;
}
int main()
{
    int n;
    int k;
    cin>>n>>k;
    int a[n],dp[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=-1;
    }
    dp[n]=-1;
    cout<<solve(n-1,k,a,dp)<<endl;
}

Measured memory_bytes: 13720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#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>
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);
}
////////////////////////////////////////

int main() {
	ll n; cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		a[i] = x;
	}
	sort(a.begin(), a.end());
	ll min = INF, r;
	for (int i = 0; i < n - 1; ++i) {
		if (min > abs(a[n - 1] / 2 - a[i])) {
			min = abs(a[n - 1] / 2 - a[i]);
			r = a[i];
		}
		if (min > abs(a[n - 1] / 2 + 1 - a[i])) {
			min = abs(a[n - 1] / 2 + 1 - a[i]);
			r = a[i];
		}
	}
	cout << a[n - 1] << " " << r << endl;
	return 0;
}


Measured memory_bytes: 1024
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[200001];
    ll fact[500001],inv[500001];
    int sz[200001];
    ll ans[200001],ans2[200001],n;

    ll power(ll a, ll b)    //a is base, b is exponent
    {
        if(b==0)
            return 1;
        if(b==1)
            return a;
        if(b%2 == 1)
            return (power(a,b-1)*a)%mod;
        ll q = power(a,b/2);
        return (q*q)%mod;
    }

    void init()
    {
        fact[0]=1,inv[0]=1;
        for(int i=1;i<=500000;++i)
        {
            fact[i]=(fact[i-1]*i)%mod;
            inv[i]=power(fact[i],mod-2);
        }
    }

    ll ncr(int n,int r)
    {
        return ((fact[n]*inv[r])%mod*inv[n-r])%mod;
    }

    void dfs(int i,int p)
    {
        sz[i]=1;
        ans[i]=1;
        for(int j=0;j<v[i].size();++j)
        {
            if(v[i][j]!=p)
            {
                dfs(v[i][j],i);
                ans[i]=((ans[i]*ans[v[i][j]])%mod*ncr(sz[i]+sz[v[i][j]]-1,sz[i]-1))%mod;
                sz[i]=sz[i]+sz[v[i][j]];
            }
        }
    }

    void dfs2(int i,int p)
    {
        if(p!=-1)
        {
            ll x = ((ans[p]*power(ans[i],mod-2))%mod*power(ncr(n-1,n-sz[i]-1),mod-2))%mod;
            ans[i] = ((ans[i]*x)%mod*ncr(n-1,sz[i]-1))%mod;
        }
        for(int j=0;j<v[i].size();++j)
        {
            if(v[i][j]!=p)
            {
                dfs2(v[i][j],i);
            }
        }
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        init();
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int i,j,a,b;
            cin>>n;
            for(i=1;i<=n-1;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                v[b].pb(a);
            }
            dfs(1,-1);
            dfs2(1,-1);
            for(i=1;i<=n;++i)
            {
                cout<<ans[i]<<endl;
            }
            cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 24052