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





int main() {
  string a,b;
  cin>>a>>b;
  int asize,bsize;
  asize=int(a.size());
  bsize=int(b.size());
  

  if(asize>bsize){
    cout<<"GREATER"<<endl;
  }
  
  else if(asize<bsize){
    cout<<"LESS"<<endl;
  }
  
  else if(asize==bsize){
    if(a<b){
      cout<<"LESS"<<endl;
    }
    else if(a>b){
      cout<<"GREATER"<<endl;
    }
    
    else if(a==b){
      cout<<"EQUAL"<<endl;
    }
  }

  
}












Measured memory_bytes: 256
import java.util.*;

class Main{            
     
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);  
       
       int N = sc.nextInt();
       int [] aMid = new int[N];
       
       Queue<Integer> zenhan = new PriorityQueue<>();
       Queue<Integer> kouhan = new PriorityQueue<>((o1 ,o2) -> o2 - o1);
       
       long[] zenhanSums = new long[N+1];
       long[] kouhanSums = new long[N+1];
       
       for(int i = 0;i < N;i++){
           int a = sc.nextInt();
           zenhan.add(a);                   
           zenhanSums[0] += a;
       }
       
       for(int i = 0;i < N;i++){
          aMid[i] = sc.nextInt();
       }
       
       for(int i = 0;i < N;i++){
           int a = sc.nextInt();
           kouhan.add(a);
           kouhanSums[N] += a;
       }
       
       for(int i = 0;i < N;i++){
          int min = zenhan.poll();
          int added = Math.max(min,aMid[i]);
          zenhan.add(added);
          zenhanSums[i+1] = zenhanSums[i] - min + added;
       }
       
       for(int i = 0;i < N;i++){
           int max = kouhan.poll();
           int added = Math.min(max,aMid[N-i-1]);
           kouhan.add(added);
           kouhanSums[N-i-1]= kouhanSums[N-i] -max + added;
       }
       
       long ans = Long.MIN_VALUE;
       
       for(int i = 0;i < N+1;i++){
           ans = Math.max(ans,zenhanSums[i] - kouhanSums[i]);
       }
       
       System.out.println(ans);
       
   }
}

Measured memory_bytes: 102128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;

const int Z = 1e9+7;

void dfs1(vi e[], int inv[], int x, int p[], int sz[], int dp[]) {
    sz[x] = 1;
    dp[x] = 1;

    for (int y : e[x]) {
        if (y != p[x]) {
            p[y] = x;
            dfs1(e, inv, y, p, sz, dp);
            sz[x] += sz[y];
            dp[x] = 1ll * dp[x] * dp[y] % Z;
        }
    }

    dp[x] = 1ll * dp[x] * inv[sz[x]] % Z;
}

void dfs2(vi e[], int inv[], int x, int p[], int sz[], int dp[]) {
    dp[x] = x == 0 ? dp[x] : 1ll * dp[p[x]] * sz[x] % Z * inv[sz[0]-sz[x]] % Z;

    for (int y : e[x]) {
        if (y != p[x]) {
            dfs2(e, inv, y, p, sz, dp);
        }
    }
}

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

    int n;
    cin >> n;
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    int inv[n+1];
    for (int i = 1; i <= n; i++) {
        inv[i] = i == 1 ? 1 : 1ll * (Z - Z / i) * inv[Z%i] % Z;
    }

    int p[n], sz[n], dp[n];
    p[0] = -1;
    dfs1(e, inv, 0, p, sz, dp);

    dfs2(e, inv, 0, p, sz, dp);

    int facn = 1;
    for (int i = 1; i <= n; i++) {
        facn = 1ll * facn * i % Z;
    }

    for (int i = 0; i < n; i++) {
        cout << 1ll * facn * dp[i] % Z << endl;
    }

    return 0;
}


Measured memory_bytes: 17012
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    val c = cin.nextInt()

    var ans = 0
    var checker = 2

    var inf_flag = false

    while (a % 2 == 0) {
        if (a % checker != b % checker || b % checker != c % checker) {
            break
        }
        if (checker > a && checker > b && checker > c) {
            inf_flag = true
            break
        }
        ans += 1
        checker *= 2
    }

    if (inf_flag) {
        println(-1)
    } else {
        println(ans)
    }
}

Measured memory_bytes: 31520
s=list(input())
t=list(input())
s_len=(len(s))
t_len=(len(t))

for i in range(s_len-t_len,-1,-1):
    for j in range(t_len):
        if s[i+j]==t[j] or s[i+j]=="?":
            continue
        else:
            break
    else:
        for k in range(t_len):
            s[i+k]=t[k]
        
        print(("".join(s)).replace("?","a"))
        exit()

print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#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 repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define o_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
#define trav(it, v) for(auto &it : v)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 	return r;
}


int d(int x, int y)
{
	return abs(x - y);
}
void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> pts(n);
	rep(i, n) cin >> pts[i];
	int res = inf;
	rep(i, n - k + 1){
		int f = pts[i], s = pts[i + k - 1];
		res = min(res, min(d(f, 0), d(s, 0)) + d(f, s));
	}
	cout << res;
}
int main()
{
    Red;
    // freopen("black.in", "r", stdin);
	// freopen("black.out", "w", stdout);
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i) {
    	// cout << "Case #" << i << ": ";
    	solve();
  	}
  	return 0;

}


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

int main(){
    //入力
    int A,B,C;
    cin >> A >> B >> C;

    //出力
    if(C>=A&&C<=B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

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

using namespace std;
using pint = pair<int, int>;

int N;
vector<vector<pint>> v;

bool judge(int bit) {

    for (int i=0; i<N; i++) {
        
        if (!((bit)&(1<<i))) continue;

        for (pint xy : v[i]) {
            int x = xy.first;
            int y = xy.second;

            if (y==1&&!(bit&(1<<x))) return false;
            if (y==0&&(bit&(1<<x))) return false;
        }
    }

    return true;
}

int main(){

    // 標準入力の受け取り
    cin >> N; v.resize(N);
    for (int i=0; i<N; i++) {
        int A; cin >> A;
        v[i].resize(A);
        
        for (int j=0; j<A; j++) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int res = 0;
    for (int bit=0; bit<(1<<N); bit++) {

        if (judge(bit)) {
            
            int count = 0;
            for (int i=0; i<N; i++) {
                if (bit & (1<<i)) ++count;
            }
            res = max(res, count);
        }
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
li.append(len(s))
sum = 0
if len(li) == 1:
    print(0)
else:
    for i in range(len(li)-1):
        diff = li[i+1] - li[i] - 1
        if sum + diff >= i+1:
            sum = i+1
        else:
            sum += diff
    print(sum)

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int y, m, d;
    char dc1, dc2;
    cin>>y>>dc1>>m>>dc2>>d;
    if(m<=4){
        cout<<"Heisei"; return 0;
    }
    else cout<<"TBD";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int main(){
    int N,M;
    cin >> N >> M;
    if(!M){
        P(0);
        return 0;
    }
    vector<int> edges[N];
    REP(i,0,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    queue<pair<int, vector<int>>> que;
    vector<int> nodes(N,0);
    nodes[0]=1;
    que.push(make_pair(0, nodes));

    int ans=0;
    while(!que.empty()){
        pair<int, vector<int>> node = que.front();

        // P(node.first);
        // REP(i,0,N){
        //     cout << node.second[i];
        //     if(i!=N-1) cout << " ";
        // }
        // cout << endl;

        que.pop();
        if(accumulate(ALL(node.second),0)==N){
            ans++;
            continue;
        }
        for(auto e : edges[node.first]){
            if(node.second[e]==1){
                continue;
            }else{
                node.second[e]=1;
                que.push(make_pair(e, node.second));
                node.second[e]=0;
            }
        }
    }

    P(ans);
}

Measured memory_bytes: 640
def AddDepth(list, hash, depth, index)
	list[index] = depth
	hash[depth] = Array.new if hash[depth] == nil
	hash[depth] << index
end

mapstr = gets.chomp

list_depth = Array.new(mapstr.length, nil)
hash_depth = Array.new(mapstr.length*2, nil)
depth = 0

mapstr.length.times { |i|
	case mapstr[i]
	when "\\"
		depth -= 1
		AddDepth(list_depth, hash_depth, depth, i)
	when "/"
		AddDepth(list_depth, hash_depth, depth, i)
		depth += 1
	when "_"
		AddDepth(list_depth, hash_depth, depth, i)
	end
}

#=============================================================================

list_lakeregion = Array.new
i = 0
while i < mapstr.length
	if mapstr[i] == "\\"
		depth_i = list_depth[i]
		hash_depth[depth_i].each { |di|
			nextloop = false
			if i == di
				hash_depth[depth_i].each { |ei|
					next if mapstr[ei] != "/" or ei <= di 

					list_lakeregion << (di..ei)
					i = ei if ei != nil
					nextloop = true
					break
				}
				break if nextloop
			end
		}
	end
	i += 1
end

#======================================================================

list_area = Array.new

list_lakeregion.each { |r|
	area = 0
	zero_depth = list_depth[r.first] + 1
	r.each { |i|
		depth = zero_depth - list_depth[i]
		case mapstr[i]
		when "\\","/"
			depth -= 0.5
		end
		area += depth
	}
	list_area << area
}

puts list_area.inject(:+).to_i
print list_lakeregion.length
list_area.each { |a| print " #{a.to_i}" }
puts

Measured memory_bytes: 10252
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char nc()
{
    // return getchar();
    static char buf[100000],*l=buf,*r=buf;
    return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
    x=0; int f=1,ch=nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x*=f;
}
const int maxn=1e5+50;
int n;
int m;
int k;
int b[maxn];
int an[maxn];
int anc[maxn];
int deg[maxn];
int dep[maxn];
int head[maxn];
bool mark[maxn];
struct edge
{
    int to,nex;
    edge(int to=0,int nex=0):to(to),nex(nex){}
};
vector<edge> G;
inline void addedge(int u,int v)
{
    G.push_back(edge(v,head[u])),head[u]=G.size()-1;
    G.push_back(edge(u,head[v])),head[v]=G.size()-1;
    ++deg[u],++deg[v];
}
void dfs(int u,int fa)
{
    anc[u]=fa;
    dep[u]=dep[fa]+1;
    if(k==-1||dep[k]<dep[u]) k=u;
    for(int i=head[u];~i;i=G[i].nex)
    {
        int v=G[i].to; if(v==fa) continue;
        dfs(v,u);
    }
}
void sol(int type)
{
    static int p[maxn];
    int tot=0;
    for(int i=0;i<m;++i)
    {
        // debug("%d %d\n",b[i],tot);
        int nex=tot+b[i]+1;
        for(int j=tot+1;j<nex;++j)
        {
            p[j]=j+1;
        }
        p[nex]=tot+1;
        tot=nex;
    }
    if(type)
    {
        for(int i=1;i<=n;++i) if(an[i]!=p[i])
        {
            if(an[i]<p[i]) return;
            break;
        }
    }
    memcpy(an,p,sizeof(p));
}
int main()
{
    read(n);
    memset(head,-1,sizeof(head));
    for(int i=1;i<n;++i)
    {
        int u,v; read(u),read(v);
        addedge(u,v);
    }
    k=-1,dfs(1,0);
    int root=k;
    k=-1,dfs(root,0);
    for(int x=k;x;x=anc[x]) 
    {
        b[m++]=deg[x]-2;
        mark[x]=1;
    }
    b[0]=b[m-1]=0;
    for(int i=1;i<=n;++i) if(deg[i]!=1)
    {
        if(!mark[i]) {puts("-1"); return 0;}
    }
    sol(0);
    reverse(b,b+m);
    sol(1);
    for(int i=1;i<=n;++i)
    {
        if(i!=1) printf(" ");
        printf("%d",an[i]);
    }
    printf("\n");
    return 0;
}

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

int N;
vector<int> G[100000];
int depth[100000];
int parent[100000];
int nex[100000];

int rec(int pos,int prev=-1){
  int res=1;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    res+=rec(to,pos);
  }
  return res;
}

void dfs(int pos,int prev=-1){
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    depth[to]=depth[pos]+1;
    parent[to]=pos;
    dfs(to,pos);
  }
}

int main(){
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0);
  int cnt=0;
  int si=0,ti=N-1;
  map<int,bool> used;
  used[si]=used[ti]=true;
  
  while( si!=ti ){
    if(depth[si]<depth[ti]){
      ti=parent[ti];
    }else{
      si=parent[si];
    }
    used[si]=used[ti]=true;
  }
  cnt=used.size()-2;
  
  int S,T;

  map<int,bool> vd;
  vd[0]=true;
  int ss=0;
  for(int i=0;i< (cnt+1)/2;i++){
    for(int i=0;i<(int)G[ss].size();i++){
      int to=G[ss][i];
      if(!used[to])continue;
      if(vd[to])continue;
      vd[to]=true;
      ss=to;
      break;
    }
  }

  for(int i=0;i<(int)G[ss].size();i++){
    int to=G[ss][i];

    if(!used[to])continue;
    if(vd[to])continue;

    S=rec(ss,to);
    break;
  }
  
  T=N-S;

  if(S>T){
    cout<<"Fennec"<<endl;
  }else{
    cout<<"Snuke"<<endl;
  }
  return 0;
}


Measured memory_bytes: 21376
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    left = 0
    right = N-1
    for _ in range(M):
        L,R = map(int, input().split())
        left = max(left,L-1)
        right = min(right,R-1)
        if right < left:
            print(0)
            return 0
    print(right-left+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  final static int[] WEIGHT =
  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }

  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    StringBuffer ret = new StringBuffer();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        ret.append(WEIGHT[count]);
        ret.append(" ");
      }
      count++;
    }
    return ret.toString().trim();
  }

}

Measured memory_bytes: 24240
MAX_VAL = 10 ** 18

N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

ans = 1
for i, a in enumerate(A):
    if i == 0:
        ans = a
    else:
        ans *= a

    if ans > MAX_VAL:
        print(-1)
        exit()

print(ans)


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;
const int maxn = 1e6+5;
const int MOD = 1e9+7;

LL binpow(LL x, LL n, LL p) {
    x %= p;
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % p;
        x = x * x % p;
        n >>= 1;
    }
    return res;
}

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

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

    int sp[maxn] = {0};
    unordered_map<int, int> m;

    for (int i = 2; i < maxn; i+=2) sp[i] = 2;
    for (LL i = 3; i < maxn; i+=2) {
        if (!sp[i]) {
            sp[i] = i;
            for (LL j = i; (j*i) < maxn; j+=2) {
                if (!sp[j*i]) {
                    sp[j*i] = i;
                }
            }
        }
    }

    for (auto x : a) {
        unordered_map<int, int> cur_m;
        while (x > 1) {
            ++cur_m[sp[x]];
            x /= sp[x];
        }

        for (const auto& item : cur_m) {
            m[item.first] = max(m[item.first], item.second);
        }
    }

    LL lcm = 1;
    for (const auto& item : m) {
        for (int i = 0; i < item.second; ++i) {
            lcm *= item.first;
            lcm %= MOD;
        }
    }

    LL ans = 0;
    for (auto x : a) {
        ans += (lcm * binpow(x, MOD-2, MOD));
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  ll sum[n];
  rep(i,0,n){
    sum[i]=0;
  }
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    sum[a-1]++;
    sum[b-1]++;
  }
  rep(i,0,n){
    cout<<sum[i]<<endl;
  }
}

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

typedef long long LL;
typedef long long ll;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(__typeof(b) var=(a)-((a)<(b)?0:1);var!=(b)-((a)<(b)?0:1);var+=((a)<(b)?1:-1))
#define REP(var,n) FOR(var,0,n)
#define STR(s) string s;cin>>s

int main(){
  STR(s); LL ans = 0LL;
  auto eval = [](string s){
    s += '+';
    LL rtn = 0LL, tmp = 0LL;
    for(auto c: s){
      if (c == '+'){
        rtn += tmp;
        tmp = 0;
      }
      else {
        tmp *= 10;
        tmp += c - '0';
      }
    }
    return rtn;
  };
  
  function<void(string, string)> dfs = [&](string s, string t){
    if (s == ""){
      ans += eval(t);
    }
    else {
      if (1 < SZ(s)){
        dfs(s.substr(1), t + s[0] + "+");
      }
      dfs(s.substr(1), t + s[0]);
    }
  };
  dfs(s, "");
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import math
import sys

def cmb(n, r):
	if n - r < r: r = n - r
	if r == 0: return 1
	if r == 1: return n

	numerator = [n - r + k + 1 for k in range(r)]
	denominator = [k + 1 for k in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p - 1]
		if pivot > 1:
			offset = (n - r) % p
			for k in range(p-1,r,p):
				numerator[k - offset] /= pivot
				denominator[k] /= pivot

	result = 1
	for k in range(r):
		if numerator[k] > 1:
			result *= int(numerator[k])
			result %= MOD

	return result

x,y = map(int,input().split())

min_xy = min(x,y)
max_xy = max(x,y)

MOD = 10**9+7

if max_xy / min_xy == 2.0:
	print(1)
	sys.exit()
if max_xy / min_xy > 2.0:
	print(0)
	sys.exit()
if max_xy == min_xy and max_xy % 3 != 0:
	print(0)
	sys.exit()
if max_xy == min_xy and max_xy % 3 == 0:
	print(cmb(2 * max_xy//3, max_xy//3))
	sys.exit()

for i in range(min_xy//3+1):
	if (max_xy-3*i) / (min_xy-3*i) == 2.0:
		print(cmb(2*i + (min_xy-3*i),i)%MOD)
		sys.exit()

print(0)



Measured memory_bytes: 44048
# include "iostream"
# include "cstdio"
# include "algorithm"

using namespace std;

const int maxm=2e5+10; 

int n,num[maxm];
long long ans;

int main(){
	register int i;
	scanf("%d",&n); 
	for(i=0;i<n;i++){
		scanf("%d",&num[i]); 
		num[i]-=(i+1); 
	}
	sort(num,num+n);
	int mid=num[n>>1];
	for(i=0;i<n;i++){
		ans+=abs(num[i]-mid); 
	}
	printf("%lld",ans);
	return 0; 
} 

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


LL solve(LL n, vector<LL>& a){
    vector<LL> left(n+1);
    vector<LL> right(n+1);
    for(LL i = 0; i < n; ++i){
        left[i+1] = left[i] + a[i];
        right[n-i-1] = right[n-i] + a[n-1-i];
    }
    LL ans = accumulate(a.begin(), a.end(), 0LL);
    vector<vector<LL>> dp(n+1, vector<LL>(3));
    for(LL i = 0; i < n; ++i){
        dp[i+1][0] = dp[i][0] + a[i] % 2 + ((a[i]==0)?2:0);
        dp[i+1][1] = dp[i][1] + (a[i]+1) % 2;
        dp[i+1][2] = dp[i][2] + a[i] % 2 + ((a[i]==0)?2:0);
        // start
        dp[i+1][0] = min<LL>(dp[i+1][0], left[i] + a[i] % 2);
        dp[i+1][1] = min<LL>(dp[i+1][1], left[i]);
        // 0 -> 1
        dp[i+1][1] = min<LL>(dp[i+1][1], dp[i][0] + (a[i]+1) % 2);
        // 1 -> 2
        dp[i+1][2] = min<LL>(dp[i+1][2], dp[i][1] + a[i] % 2 + ((a[i]==0)?2:0));

        ans = min<LL>(ans, dp[i+1][0] + right[i+1]);
        ans = min<LL>(ans, dp[i+1][1] + right[i+1]);
        ans = min<LL>(ans, dp[i+1][2] + right[i+1]);
        //cerr << "debug:" << i << ":" << cur << ", " << rest <<", " << ans<< endl;
    }
    return ans;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    LL ans = solve(n, a);
    reverse(a.begin(), a.end());
    ans = min<LL>(ans, solve(n, a));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15872
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = (int)2e5 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 1e9 + 21;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
const long double pi = 3.1415926535897932;

int a[4][4];
bool ok[4][4];
bool is_ok(int y) {
	for (int i = 1; i <= 3; ++i) {
		for (int j = 1; j <= 3; ++j) {
			if (!ok[i][j] && a[i][j] == y) {
				ok[i][j] = 1;
				goto f;
			}
		}
	}
f:
	if (ok[1][1] && ok[1][2] && ok[1][3])return 1;
	if (ok[2][1] && ok[2][2] && ok[2][3])return 1;
	if (ok[3][1] && ok[3][2] && ok[3][3])return 1;
	if (ok[1][1] && ok[2][1] && ok[3][1])return 1;
	if (ok[1][2] && ok[2][2] && ok[3][2])return 1;
	if (ok[1][3] && ok[2][3] && ok[3][3])return 1;
	if (ok[1][1] && ok[2][2] && ok[3][3])return 1;
	if (ok[1][3] && ok[2][2] && ok[3][1])return 1;
	return 0;
}
int b[100];
int main() {
	drobucs;
	
	for (int i = 1; i <= 3; ++i)for (int j = 1; j <= 3; ++j)cin >> a[i][j];
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)cin >> b[i];
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += is_ok(b[i]);
	}
	if (ans != 0)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dp[1005][20000];
int a[1005];
int b[1005];
const int INF = 1e9;

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

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= 20000; j++) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 20000; j++) {
      if(j < a[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]] + b[i]);
    }
  }
  int ans = INF;
  for(int i = h; i < h + 10000; i++) {
    ans = min(ans,dp[n][i]);
  }
  
  
  cout << ans << endl;
  
}
  


Measured memory_bytes: 78464
def f(s,i,t,k):
 n=len(s)
 if k>n-i:return 0
 a=max(t,int(s[i]))
 z=0
 i+=1
 if a==0:z=f(s,i,t,k)
 elif k==1:z=a+(n-i)*9
 else:
  z+=f(s,i,9,k)
  z+=(a-1)*f(s,i,9,k-1)
  z+=f(s,i,t,k-1)
 return z
print(f(input(),0,0,int(input())))

Measured memory_bytes: 41192
from collections import defaultdict
N, *A = map(int, open(0).read().split())
cnt = defaultdict(int)
csum = 0
for a in A:
    cnt[a] += 1
    csum += 1

dup = 0
for v in cnt.values():
    if v > 1:
        dup += v-1
        
if dup & 1:
    print(N-dup-1)
else:
    print(N-dup)

Measured memory_bytes: 17712
#include<bits/stdc++.h>
using namespace std;
int n, num[100007];
int gcd(int a, int b)
{
	if (!b)return a;
	return gcd(b, a % b);
}
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int solve()
{
	int cnt = 0;
	bool is = 0;
	for (int i = 1; i <= n; i++)
		if (num[i] == 1)
			is = 1;
		else if (num[i] % 2 == 0)cnt++;
	if (is)
		return cnt % 2;
	if (cnt % 2 == 1)
		return 1;
	if (n - cnt > 1)
		return 0;
	for (int i = 1; i <= n; i++)
		if (num[i] % 2 == 1)num[i]--;
	int g = num[1];
	for (int i = 2; i <= n; i++)
		g = gcd(g, num[i]);
	for (int i = 1; i <= n; i++)
		num[i] /= g;
	return solve() ^ 1;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	cout << (solve()? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 999999999999999999
#define endl "\n"
#define MOD 1000000007
 
 
 
void func(){
 
ll n;
cin>>n;
 
ll a[n+1]={0};
 
for(int i=1;i<n;i++){
  ll t;
  cin>>t;
  a[t]++;
}
 
for(int i=1;i<=n;i++)
cout<<a[i]<<endl;
}
 
 
 
 
    
int main(){
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
     
         /* #ifndef ONLINE_JUDGE
          freopen("input.txt", "r" , stdin);
          freopen("output1.txt", "w" , stdout);
          #endif*/
     
       ll t=1;
       //cin>>t;
       while(t--)
       func();
}

Measured memory_bytes: 5260
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b) * h / 2 << endl;

	return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans="APPROVED";
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a%2 == 0){
            if((a%3) !=0 && (a%5) != 0) ans = "DENIED";
        }
    }
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)
 
using namespace std;
 
int n ;
int a[100010][3];
int dp[100010][3];
 
int solve(int in , int st){
 
    if(in==n+1)return 0;
 
    if(dp[in][st]!= -1)return dp[in][st];
 
    if(st==0)return dp[in][st] =  max(a[in][1] + solve(in+1 , 1) , a[in][2] + solve(in+1 , 2));
    if(st==1)return dp[in][st] = max(a[in][0] + solve(in+1 , 0) , a[in][2] + solve(in+1 , 2));
    if(st==2)return dp[in][st] = max(a[in][1] + solve(in+1 , 1) , a[in][0] + solve(in+1 , 0));
 
 
}
 
 
int32_t main(){   
 
/*fastio
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt","w", stdout);
#endif*/
 
memset(dp , -1, sizeof(dp));
cin>>n;
for(int i =1 ; i<=n ; i++){
   cin>>a[i][0]>>a[i][1]>>a[i][2];
}
 
 
cout<<max({a[1][0] + solve(2 , 0)  , a[1][1] + solve(2 , 1) , a[1][2] + solve(2, 2)})<<'\n';
 
 
 
 
return 0;
}

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

int main(){
  int a,b;
  cin >>a >>b;
  int ans = 0;
  int outlet = 1;
  while(outlet < b){
    outlet--;
    outlet += a;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int N = 100;
static const int INFTY = (1 << 21);

int n;
int M[N][N], d[N], color[N];

void bfs(int s){
    for(int i = 0; i < n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }

    queue<int> q;
    color[s] = GRAY;
    d[s] = 0;
    q.push(s);

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v = 0; v < n; v++){
            if(M[u][v] && color[v] == WHITE){
                color[v] = GRAY;
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
        color[u] = BLACK;
    }

    for(int i = 0; i < n; i++){
        if(d[i] != INFTY) cout << i + 1 << " " << d[i] << endl;
        else cout << i + 1 << " " << -1 << endl;
    }
}

int main(){
    cin >> n;
    int u, k, v;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v;
            M[u-1][v-1] = 1;
        }
    }
    bfs(0);

    return 0;
}


Measured memory_bytes: 3124
N, A, B = map(int, input().strip().split(" "))
students = list(input().strip())

kaigai = 0
total = 0
for s in students:
    if s == "a":
        if total < A+B:
            print("Yes")
            total += 1
        else:
            print("No")
    elif s == "b":
        if total < A+B and kaigai < B:
            print("Yes")
            kaigai += 1
            total += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 78832
#include <bits/stdc++.h>
#define rep(i,n) for(lli (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    lli n;
    cin >> n;
    vector<vector<lli>> hs;
    rep(i,n) {
        lli x,y,h;
        cin >> x >> y >> h;
        vector<lli> v{x,y,h};
        hs.push_back(v);
    }
    lli cx,cy,ah;
    rep(x,101)rep(y,101) {
        lli eh;
        rep(i,n) {
            if (hs[i][2] > 0) {
                eh = abs(x-hs[i][0]) + abs(y-hs[i][1]) + hs[i][2];
            }
        }
        if (eh <= 0) continue;
        bool ng = false;
        rep(i,n) {
            int ch = abs(x-hs[i][0]) + abs(y-hs[i][1]) + hs[i][2];
            int d = abs(x-hs[i][0]) + abs(y-hs[i][1]);
            if (d > eh && hs[i][2] == 0) {
                // nothing
            } else {
                if (ch != eh) {
                    ng = true;
                }
            }
        }
        if (!ng) {
            cx = x;
            cy = y;
            ah = eh;
        }
    }
    printf("%lld %lld %lld\n", cx,cy,ah);
    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n;
int main() {
    cin >> n;
    int a[n];
    rep(i,0,n){
        cin >> a[i];
    }
    rep(i,1,n+1){
        per(j,i,1){
            if(a[j] < a[j-1]) swap(a[j],a[j-1]);
        }
        rep(i,0,n){
            printf("%d",a[i]);
            if(i != n-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

// ================================================= //

/*
 update : k を x に変更
 query : [s,t) の最小(大)を出力する
 */
const ll INIT = INT_MAX;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
    }
    
    void update(int k, ll val) {
        k += N - 1;
        node[k] = val;
        while (k) {
            k = (k - 1) / 2;
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return node[k];
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
    ll rmq(int a, int b) { return query(a, b, 0, 0, N); }
};


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    SegTree ST(n);
    while(q--){
        int com,x,y; cin >> com >> x >> y;
        if(com == 0){
            ST.update(x,y);
        }else{
            cout << ST.rmq(x,y+1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4972
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int t, x;
	cin >> t >> x;
	PRI((double)t / (double)x);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x;
  cin >> x;
  ll cnt = 0, ans = 0;

  ans = 2 * (x / 11);
  if (x % 11 > 6 )
    ans += 2;
  else if (x % 11 >= 1 )
    ans += 1;
  // for (int i = 0; cnt < x; ++i) {
  //   if (i % 2 == 0)
  //     cnt += 6;
  //   else
  //     cnt += 5;
  //   ans++;
  // }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n; cin>>n;
	string ret;
	while(n){
		n--;
		char d = (n % 26) +'a';
		ret = d + ret;
		n /= 26;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string str;
  cin >> str;
  for(int i = 0; i <= 7; ++i){
    string str2 = str.substr(0, i) + str.substr(str.size()-7+i, 7-i);
    if (str2.compare("keyence") == 0){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

/*/---------------------------Defines----------------------/*/
 
#define ll long long
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(v) (v).begin(),(v).end()

typedef pair<ll,ll> pi;
/*/-----------------------Modular Arithmetic---------------/*/
 
const long long INF = 1ll << 32; 
const int mod=1e9+7;
inline int add(int x,int y){
    x+=y;
    if (x>=mod) return x-mod;
    return x;
}
inline int sub(int x,int y){
    x-=y;
    if (x<0) return x+mod;
    return x;
}
inline int mul(int x,int y){
    return (x*1ll*y)%mod;
}
inline int power(int x,int y){
    int ans=1;
    while(y){
        if (y&1) ans=mul(ans,x);
        x=mul(x,x);
        y>>=1;
    }
    return ans;
}
inline int inv(int x){
    return power(x,mod-2);
}
/*/-----------------------------Code begins----------------------------------/*/
const int N=2e5+100;


void solve()
{
	ll i,j,k;
	ll n,m;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(b*d,a*c),max(a*d,b*c))<<endl;;
}



int main()
{
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>


int main()
{

    int a,b,nd=0,x,y,z=1,i,X,sum=0;

    scanf("%d",&a);

    int A[a];

    for(i=0;i<a;i++){

        scanf("%d",&A[i]);

    }




    for(i=0;i<a;i++,z++)
    {

       if(A[i]!=z) sum++;


    }


    if(sum<=2)printf("YES\n");

    else printf("NO\n");


    return 0;

}



Measured memory_bytes: 1640
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans;
    char a,b;
    cin >>a>>b;


    {
        if(a==b)cout <<"H"<<endl;
        else cout <<"D"<<endl;
    }

    dbg cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

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

  sort(count + 1, count + n);

  int c = 0;
  for(int i = n - 1; i >= n - k; i--) {
    c += count[i];
  }

  cout << n - c << endl;
}

Measured memory_bytes: 1920
from sys import stdin

s = stdin.readline().rstrip()
N = len(s)

dp = [0]*N
dp[0] = 1
if s[0] == s[1]:
    dp[1] = 1
else:
    dp[1] = 2
for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i] = dp[i-3] + 2
    else:
        dp[i] = dp[i-1] + 1

print(dp[N-1])

Measured memory_bytes: 11240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    char arr[a][b];
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)
            cin>>arr[i][j];
    for(int i=0;i<b+2;i++)
        cout<<"#";
    cout<<endl;
    for(int i=0;i<a;i++)
    {
        cout<<"#";
        for(int j=0;j<b;j++)
            cout<<arr[i][j];
        cout<<"#";
        cout<<endl;
    }
    for(int i=0;i<b+2;i++)
        cout<<"#";
cout<<endl;
return 0;
}


Measured memory_bytes: 256
// AOJ 2923: Ravage
// 2019.2.18 bal4u

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

#define gc() getchar()

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int v; int f; } S;
S s[200002];

int cmp(const void *a, const void *b)
{
	int r = ((S *)a)->v - ((S *)b)->v;
	if (r == 0) return ((S *)b)->f - ((S *)a)->f;
	return r;
}

int main()
{
	int N, i, j, max, cnt;

	N = in();
	for (i = N, j = 0; i--; j++) {
		s[j].v = in(), s[j].f = 1;
		s[++j].v = in();
	}
	N <<= 1;
	qsort(s, N, sizeof(S), cmp);
	max = cnt = 0;
	for (i = 0; i < N; i++) {
		if (s[i].f) {
			if (++cnt > max) max = cnt;
		} else cnt--;
	}
	printf("%d\n", max);
	return 0;
}



Measured memory_bytes: 4548
abcd = input().split(' ')
a, b = int(abcd[0]), int(abcd[1])
c, d = int(abcd[2]), int(abcd[3])

hp_a = a
hp_c = c

turn = "T"

while hp_a > 0 and hp_c > 0:
  if turn == "T":
    hp_c -= b
    turn = "A"
  elif turn == "A":
    hp_a -= d
    turn = "T"

if turn == "A":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61660
import math
A,B= map(int,input().split())
# min_x = math.ceil(max(A/8,B/10)*100)
min_x = max(A//0.08,B//0.10) +1
max_x = (min((A+1)/8,(B+1)/10)*100)

if max_x-min_x>0:
    ans = int(min_x)
else:
    ans = -1
print(ans)

Measured memory_bytes: 3060
const fs = require('fs');
const input: string[] = fs.readFileSync('/dev/stdin', 'utf-8').split('\n');
const n: number = parseInt(input[0]);
const L: number = input[1].split(' ').map(v => parseInt(v)).sort((a,b) => a > b ? 1 : -1);

function find(i: number, j: number): number {
  let k = Math.floor(j/2);
  let max = j;
  let min = 0;
  if (L[j] + L[j - 1] <= L[i]) {
    return 0;
  }
  while (min < max) {
    if (L[j] + L[k] > L[i]) {
      max = k;
      k = Math.floor((k + min) / 2);
    } else {
      min = k + 1;
      k = Math.ceil((k + max) / 2);
    }
  }
  return (j - min)
}

let count: number = 0;
for (let i = 2; i < n; ++i) {
  for (let j = 1; j < i; ++j) {
    if (L[j] < L[i] / 2) {
      continue;
    }
    count += find(i, j);
  }
} 
 
console.log(count);

Measured memory_bytes: 11844
# A - One out of Three

# 入力された整数A,B,Cのうち、2つは等しく1つは異なる
# 1つだけ異なる整数の値を出力する


A,B,C = map(int,input().split())

if A == B:
    print(C)
elif A == C:
    print(B)
elif B == C:
    print(A)


Measured memory_bytes: 9084
n, x = map(int, input().split())

while n + x != 0:
    count = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1

    print(count)

    n, x = map(int, input().split())

Measured memory_bytes: 7628
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        List<Integer> lst = new LinkedList<Integer>();
        while(input.hasNext()){
        	int a = input.nextInt();
        	if(a == 0){
        		System.out.println(lst.get(lst.size()-1));
        		lst.remove(lst.size()-1);
        	}else{
        		lst.add(a);
        	}
        }
    }    
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long double s;
    cin >> s;
    long double o;
    o = pow(s / 3, 3);
    printf("%.10Lf\n", o);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

/*long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};*/


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	bool N=false;
	bool W=false;
	bool S=false;
	bool E=false;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='N')N=true;
		if(s[i]=='S')S=true;
		if(s[i]=='E')E=true;
		if(s[i]=='W')W=true;
	
	}if(S!=N || W!=E){
		cout<<"No"<<endl;
		return 0;
		}
	cout<<"Yes"<<endl;
}


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

int main(){
	int n,i;
	long long a,sum=0,min=1000001,max=-1000001;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		if(a<min)min=a;
		if(a>max)max=a;
		sum+=a;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3092