akhauriyash/Code-Regression huggingface dataset:
N = int(input())
ans = 0

def dfs(x, a, b, c):
    global ans
    if x > N:
        return
    if (a & b & c):
        ans += 1
    dfs(10 * x + 3, 1, b, c)
    dfs(10 * x + 5, a, 1, c)
    dfs(10 * x + 7, a, b, 1)

dfs(0, 0, 0, 0)
print(ans)

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

int main() {
    int a, b;
    scanf("%d %d", &a, &b); 
    string s;
    if (a < b) {
        s = "<";
    }
    else if (a > b)
    {
        s = ">";
    } else
    {
        s = "==";
    }
    printf("a %s b\n", s.c_str());
    
    return 0;
}


Measured memory_bytes: 3244
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)


def search(n, m, tile, N, M):
    for dy, dx in zip([-1, -1, -1, 0, 0, 1, 1, 1], [-1, 0, 1, -1, 1, -1, 0, 1]):
        if 0 <= dy + n < N and 0 <= dx + m < M:
            if tile[dy + n][dx + m] == '1':
                tile[dy + n][dx + m] = '2'
                search(dy + n, dx + m, tile, N, M)


while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    tile = [input().split() for n in range(N)]
    ans = 0
    for n in range(N):
        for m in range(M):
            if tile[n][m] == '1':
                tile[n][m] = '2'
                search(n, m, tile, N, M)
                ans += 1
    print(ans)




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

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

	if ((N % 2) != 0 || (S.size() != N)) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < N / 2; i++) {
		if (S.at(i) != S.at(i + N / 2)) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
typedef pair<ll,P> lP;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  int a[5],t=999,s;
  bool f=0;
  fr(i,5) cin>>a[i];
  sort(a,a+5);
  do{
    s=0;
    fr(i,4) s+=(1+(a[i]-1)/10)*10;
    s+=a[4];
    t=min(t,s);
  }while(next_permutation(a,a+5));
  cout<<t<<endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    string IN;
    int K;
    cin >> IN >> K;

    vector<int> N;
    for (char &c : IN) N.push_back(c - '0');

    int n = N.size();
    
    ll ans = 0;
    bool ok = false;
    if (K == 1) {
        rep(i, n) {
            if (i == 0) ans += N[0];
            else ans += 9;
        }
    } else if (K == 2) {
        rep(i, n)rep(j, n){
            if (j <= i) continue;
            if (i == 0) {
                if (!ok) {
                    ans += (N[0] - 1) * 9;
                    ans += N[j];
                    if (N[j] != 0) ok = true;
                } else {
                    ans += N[0] * 9;
                }
            } else {
                ans += 9 * 9;
            }
        }
    } else {
        rep(i, n)rep(j, n) {
            if (j <= i) continue;
            if (i == 0) {
                if (!ok) {
                    bool okk = false;
                    for (int k = j + 1; k < n; ++k) {
                        if (!okk) {
                            ans += (N[0] - 1) * 9 * 9;
                            if (N[j] > 0) {
                                ans += (N[j] - 1) * 9;
                                ans += N[k];
                            }
                            if (N[k] != 0) okk = true;
                        } else {
                            ans += (N[0] - 1) * 9 * 9;
                            ans += N[j] * 9;
                        }
                    }
                    if (N[j] != 0) ok = true;
                } else {
                    for (int k = j + 1; k < n; ++k) ans += N[0] * 9 * 9;
                }
            } else {
                for (int k = j + 1; k < n; ++k) ans += 9 * 9 * 9;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]

mid = len(S)//2
#print(mid)
if len(S) % 2 == 0:
    pre = S[:mid]
    aft = S[mid:]
else:
    pre = S[:mid]
    aft = S[mid+1:]

#print(pre,aft)
result = 0
for i in range(mid):
    #print(pre[i],aft[mid-1-i])
    if pre[i] != aft[mid-1 - i]:
        result += 1

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int N,D,c=0;
    cin >> N >> D;
    
    int i=1;
    while(1){
        c++;
        if((2*D+1)*i >= N) break;
        i++;
    }
    
    cout << c <<endl;
}

Measured memory_bytes: 3568
from math import ceil
from collections import defaultdict, deque


def A(d, t, s):
  if t * s >= d:
    return 'Yes'
  return 'No'


def B(n):
  pass


def C(n, a):
  pass


def D(n):
  pass


def main():
  d, t, s = map(int, input().split())
  print(A(d, t, s))


if __name__ == '__main__':
  main()


Measured memory_bytes: 9464
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    xs <- getIntList
    let ys = reverse xs
    let solve a b = sum ls + sum rs - sum ms
            where ls = take a xs
                  rs = take b ys
                  i = k - a - b
                  ms = take i . takeWhile (< 0) $ sort (ls ++ rs)
    let m = min n k
    let ans = maximum [ solve a b | a <- [0..m], b <- [0..m-a]]
    print ans

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

#define N 1001

int main() {

    int X, Y, Z, K;
    long long int a[1010], b[1010], c[1010];
    cin >> X >> Y >> Z >> K;

    for (int i=0; i<X; i++) {
        cin >> a[i];
    }
    for (int i=0; i<Y; i++) {
        cin >> b[i];
    }
    for (int i=0; i<Z; i++) {
        cin >> c[i];
    }

    sort(a, a + X, greater<long long int>());
    sort(b, b + Y, greater<long long int>());
    sort(c, c + Z, greater<long long int>());

    int ai = 0;
    int bi = 0;
    int ci = 0;

    auto cc = [](vector<long long int> l, vector<long long int> r) {return l[0] < r[0];};
    priority_queue<vector<long long int>, vector<vector<long long int>>, decltype(cc)> q(cc);

    // long long int N = 1001;
    vector<bool> comb(N*N*N, true);

    q.push({a[ai] + b[bi] + c[ci], ai, bi, ci});
    comb[ai*N*N + bi*N + ci] = false;

    for (int i=0; i<K; i++) {
        cout << q.top()[0] << endl;
        ai = q.top()[1];
        bi = q.top()[2];
        ci = q.top()[3];
        q.pop();
        if (ai + 1 < X && comb[(ai + 1)*N*N + bi*N + ci]) {
            q.push({a[ai + 1] + b[bi] + c[ci], ai + 1, bi, ci });
            comb[(ai + 1)*N*N + bi*N + ci] = false;
        }
        if (bi + 1 < Y && comb[ai*N*N + (bi + 1)*N + ci]) {
            q.push({a[ai] + b[bi + 1] + c[ci], ai, bi + 1, ci });
            comb[ai*N*N + (bi + 1)*N + ci] = false;
        }
        if (ci + 1 < Z && comb[ai*N*N + bi*N + ci + 1]) {
            q.push({a[ai] + b[bi] + c[ci + 1], ai, bi, ci + 1 });
            comb[ai*N*N + bi*N + ci + 1] = false;
        }
    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    int x;
    int count = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if (a[i] > a[i + 1] && a[i + 1] > a[i + 2])
        {
            count++;
        }
        if (a[i] < a[i + 1] && a[i + 1] < a[i + 2])
        {
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A - B > 1) {
    cout << 2 * A - 1<<endl;
  }
  else if (B - A > 1) {
    cout << 2 * B - 1 <<endl;
  }
  else {
    cout << A + B <<endl;
  }
}

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


def dfs4t(a, par):
    for child in edge[a]:
        if child == par:
            continue
        else:
            cost4t[child] = cost4t[a] + 1
            dfs4t(child, a)
    return

def dfs4a(a, par):
    for child in edge[a]:
        if child == par:
            continue
        else:
            cost4a[child] = cost4a[a] + 1
            dfs4a(child, a)
    return


N, u, v = map(int, input().split())
edge = [[] for _ in range(N)]
cost4t = [10**5 for i in range(N)]
cost4a = [10**5 for i in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

u -= 1
v -= 1
cost4t[u] = 0
cost4a[v] = 0
dfs4t(u, 10**5)
dfs4a(v, 10**5)

ans = 0
for t, a, in zip(cost4t, cost4a):
    if a  >= t:
        ans = max(ans, t + a - (t + 1))
print(ans)

Measured memory_bytes: 101548
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());


int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1; 
	// cin>>t;
    while(t--)
    {	
		ll r; cin>>r;
		double ans= 2 * PI *r;
		cout<<ans<<"\n";
    }

    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
        
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
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 co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);

	co(A[0] * A[1] / 2);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i, j;
    int a[3];

    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    for(i = 0; i < 2; i++){
       for(j = 2; j > i; j--){
           if(a[j - 1] > a[j]){
              int temp = a[j];
              a[j] = a[j - 1];
              a[j - 1] = temp;
           }
       }
    }
    printf("%d %d %d\n", a[0], a[1], a[2]);
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n,b,x;
    string ans="APPROVED";
    cin>>n;
    vl a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0)ans="DENIED";
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split().ToArray().Select(int.Parse).ToList();

            var i = 0;
            var count = 0;
            while (i < N - count)
            {
                if (list[i + count] != i + 1)
                {
                    count++;
                }
                else
                {
                    i++;
                }
            }

            Console.WriteLine(N - count == 0 ? "-1" : count.ToString());
        }
    }
}


Measured memory_bytes: 37084
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<tuple<double,double>> vt;
  for(int i:irange(0,n)) {
    double x,y;
    cin>>x>>y;
    vt.emplace_back(x,y);
  }
  boost::sort(vt);
  double total = 0;
  int cnt = 0;
  do {
    double sum = 0;
    for(int i:irange(0,n-1)) {
      double x0,y0,x1,y1;
      tie(x0,y0) = vt[i];
      tie(x1,y1) = vt[i+1];
      double dx=x0-x1;
      double dy=y0-y1;
      sum += sqrt(dx*dx+dy*dy);
    }
    total += sum;
    ++cnt;
  } while (boost::next_permutation(vt));
  cout<<fixed<<setprecision(10)<<(total/cnt)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

int main(){
    int n,m;
    cin >> n>> m;
    vector<pair<int,int> > key;
    rep(i,m){
        int a,b;
        cin >> a>>b;
        int c=0;
        rep(i,b){
            int d;
            cin >> d;
            d--;
            c|=1<<d;
        }
        key.push_back(mp(c,a));
    }
    int dp[1<<n];
    rep(i,1<<n){
        dp[i]=INF;
    }
    dp[0]=0;
    rep(i,1<<n){
        rep(j,m){
            dp[i|key[j].first]=min(dp[i|key[j].first],dp[i]+key[j].second);
            int k=i|key[j].first;
            
            //cerr<<i<<' '<<k<<' '<<dp[k]<<' '<<dp[i]<<' '<<dp[i]+key[j].second<<endl;
        }
    }
    int o=1<<n;
    //cerr<<o<<endl;
    int l=(1<<n)-1;
    //cerr<<l<<endl;
    if(dp[l]==INF){
        cout<<-1<<endl;
        return 0;
    }
    cout<<dp[l]<<endl;
    return 0;
}

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

using namespace std;
int n;
long long a[111];

int main(){
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    int ans=0;
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            if (a[i]==a[j]) continue;
            for (int k=j+1; k<n; k++){
                if (a[k]==a[j]||a[k]==a[i]) continue;
                if (a[i]+a[j]>a[k]) ans++;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3616
import Data.Set as Set

main = do
    n <- readLn :: IO Int
    w <- getLine
    r <- loop (n-1) w (insert w empty)
    if r then putStrLn "Yes" else putStrLn "No"

loop :: Int -> String -> Set String -> IO Bool
loop 0 _ _ = return True
loop n ac set = do
    w <- getLine
    if feql ac w && w `notMember` set
        then loop (n-1) w (insert w set)
        else loop' (n-1)

loop' 0 = return False
loop' n = do
    _ <- getLine
    loop' (n-1)


feql :: String -> String -> Bool
feql q w = last q == head w

Measured memory_bytes: 636
now_ABC = gets.chomp!.to_i
next_ABC = now_ABC.to_s
flag = 0
count = 0

first_char = next_ABC[0]
next_ABC.chars do |c|
  if c !=  first_char then break end
  count += 1
  if count == next_ABC.length then
    flag = 1
  end
end
count = 0
while flag == 0 do
  first_char = next_ABC[0]
  count = 0
  next_ABC.chars do |c|
    if c != first_char then break end
    count += 1
    if count == next_ABC.length then
      flag = 1
    end
  end
  next_ABC = next_ABC.to_i
  if flag == 0 then next_ABC += 1 end
  next_ABC = next_ABC.to_s
end




puts next_ABC.to_i

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.size()<4){
    cout << "No" << endl;}
  else if(S.at(0)=='Y' && S.at(1)=='A' && S.at(2)=='K' && S.at(3)=='I'){
    cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+18
#define MOD 1000000007
#define int long long
using namespace std;

int mod_inv(int X){
	int a = X, b = MOD, u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += MOD;
	return u;
}

vector<int> fact,factinv;

void nCr_init(int N){
	N = min(N,(int)MOD);
	fact.resize(N + 1);
	factinv.resize(N + 1);
	fact[0] = 1;
	for(int i = 1;i <= N;i++) fact[i] = fact[i - 1] * i % MOD;
	factinv[N] = mod_inv(fact[N]);
	for(int i = N;i >= 1;i--) factinv[i - 1] = factinv[i] * i % MOD;
}

int nCr(int ncr_n,int ncr_r){
	if(ncr_n >= MOD) return nCr(ncr_n % MOD, ncr_r % MOD) * nCr(ncr_n / MOD, ncr_r / MOD) % MOD;
	return ncr_r > ncr_n ? 0 : fact[ncr_n] * factinv[ncr_n - ncr_r] % MOD * factinv[ncr_r] % MOD;
}

signed main(){
	int n,m,ans = 1;
	map<int,int> yaku;
	cin >> n >> m;
	nCr_init(100100);
	int _m = m;
	for(int i = 2;i * i <= m;i++){
		while(_m % i == 0){
			_m /= i;
			yaku[i]++;
		}
	}
	if(_m != 1) yaku[_m]++;
	for(auto p : yaku){
		ans = ans * nCr(n - 1 + p.second,p.second) % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s[8] = {"SUN","MON","TUE","WED","THU","FRI","SAT", "SUN"};

    string t;
    cin >> t;
    rep(i,7) {
        if(s[i] == t) {
            rep2(j,i+1,8) {
                if(s[j] == "SUN") {
                    cout << j - i << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
} /*atcoder*/



Measured memory_bytes: 3540
import java.util.*;

class Main {
    public static int frog(int[] h, int n) {
    	int[] dp = new int[n];

    	for(int i = 1; i < n; i++) {
    		dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1]);
    		if(i > 1)
    			dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
    	}

    	return dp[n-1];
    }

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

    	int n = sc.nextInt();
    	int[] h = new int[n];
    	for(int i = 0; i < n; i++) {
    		h[i] = sc.nextInt();
    	}

    	System.out.println(frog(h, n));
    }
}

Measured memory_bytes: 49932
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a; cin >> a;
  if (a < 1200) COUT("ABC");
  else if (a < 2800) COUT("ARC");
  else COUT("AGC");
  return 0;
}

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

int main(int argc, const char * argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if ( (a < b) && (b < c) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

int main(){

   string w;
   cin>> w;

   sort(w.begin(), w.end());
   if(w.size()%2==1){
      cout<< "No"<< endl;
      return 0;
   }
   for(int i=0; i<w.size()-1; i+=2){
      if(w[i]!=w[i+1]){
         cout<< "No"<< endl;
         return 0;
      }
   }

   cout<< "Yes"<< endl;

   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	bool *patern[2];
	bool dotti=false;
	int N;
	cin >> N;
	for (int i = 0; i < 2; ++i) {
		patern[i] = new bool[N];
	}
	for (int i = 0; i < N; ++i) {
		cin >> patern[0][i];
		if (dotti)patern[0][i] = !patern[0][i];
		dotti = !dotti;
		patern[1][i] = !patern[0][i];
	}
	vector<int> line;
	int count;
	bool now;
	int answer = 0;
	for (int i = 0; i < 2; ++i) {
		count = 0;
		if (patern[i][0] == false) {
			line.push_back(0);
			now = false;
		}
		else {
			now = true;
		}
		for (int j = 0; j < N; ++j) {
			if (patern[i][j] == now) {
				++count;
			}
			else {
				line.push_back(count);
				count = 1;
				now = !now;
			}
		}
		line.push_back(count);
		if (line.size() >= 3) {
			for (int j = 0; j < line.size() - 2; j += 2) {
				answer = max(line[j] + line[j + 1] + line[j + 2], answer);
			}
		}
		else {
			answer = max(answer, (line.size() == 2 ? line[0] + line[1] : line[0]));
		}
		line.clear();
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3380
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

class Part:

    def __init__(self, string):
        self.slope, self.floor = self.calc_slope_floor(string)

    def __repr__(self):
        return "s{} f{}".format(self.slope, self.floor)

    def __lt__(self, other):
        if self.floor > other.floor:
            return True
        if self.slope > self.slope:
            return True
        return False

    @staticmethod
    def calc_slope_floor(string):
        slope = 0
        floor = 0
        for c in string:
            if c == '(':
                slope += 1
            else:
                slope -= 1
            floor = min(floor, slope)
        return slope, floor

    def flip(self):
        self.slope *= -1
        self.floor += self.slope

    def catenate(self, other):
        assert(self.slope >= 0)
        if self.slope < abs(other.floor):
            return False
        self.slope += other.slope
        # self.floor is not needed

def sum_slope(parts):
    s = 0
    for p in parts:
        s += p.slope
    return s

def calc_flat_floor(flat):
    floor = 0
    for f in flat:
        floor = min(floor, f.floor)
    return floor

def enable(parts):
    parts = sorted(parts)
    #print('parts') # debug
    #print(parts) # debug
    chain = Part("")
    for p in parts:
        flg = chain.catenate(p)
        if flg == False:
            return False
    return True



def solve(up, down, flat):
    up_slope = sum_slope(up)
    down_slope = sum_slope(down)
    if up_slope != down_slope:
        return False
    flat_floor = calc_flat_floor(flat)
    #print('up_slope') # debug
    #print(up_slope) # debug
    #print('flat_floor') # debug
    #print(flat_floor) # debug
    if up_slope < abs(flat_floor):
        return False
    if not enable(up):
        return False
    if not enable(down):
        return False
    return True


if __name__ == '__main__':
    n = int(input())
    up = []
    down = []
    flat = []
    for _ in range(n):
        s = input()
        p = Part(s)
        if p.slope > 0:
            up.append(p)
        elif p.slope < 0:
            p.flip()
            down.append(p)
        else:
            flat.append(p)
    ans = solve(up, down, flat)
    if ans:
        print("Yes")
    else:
        print("No")


    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 199756
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node{
    int key;
    Node *parent,*left,*right;
};
Node *root,*NIL;
void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else{
        if(z->key<y->key) y->left=z;
        else y->right=z;
    }
}
Node * treeMinimum(Node *x){
    while(x->left!=NIL) x=x->left;
    return x;
}
Node * treeSuccessor(Node *x){
    if(x->right!=NIL) return treeMinimum(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}
void treeDelete(Node *z){
    Node *y;
    Node *x;
    if(z->left==NIL||z->right==NIL) y=z;
    else y=treeMinimum(z->right);

    if(y->left!=NIL) x=y->left;
    else x=y->right;

    if(x!=NIL) x->parent=y->parent;

    if(y->parent==NIL) root=x;
    else{
        if(y==y->parent->left) y->parent->left=x;
        else y->parent->right=x;
    }
    
    if(y!=z) z->key=y->key;
    free(y);
}
Node * find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}
void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
        else if(com=="find"){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
        else{
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
    return 0;
}


Measured memory_bytes: 22028
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dfs(ll s, ll *d){
    if(s == 0) return 1;
    if(s < 3) return 0;
    if(d[s]) return d[s];
    for(int i = 3; i <= s; i++) d[s] = (d[s] + dfs(s - i, d)) % MOD;
    return d[s];
}

int main()
{
    int s;
    cin >> s;
    ll d[2004]{0};
    cout << dfs(s, d) << endl;
}


Measured memory_bytes: 3636
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, a[N * 2], lb[N * 2], rb[N * 2];
std::stack<int> sl, sr;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) {
        while (!sl.empty() && a[sl.top()] > a[i]) sl.pop();
        if (sl.empty()) lb[i] = 0;
        else lb[i] = sl.top();
        sl.push(i);
    }
    for (int i = n; i >= 1; i--) {
        while (!sr.empty() && a[sr.top()] > a[i]) sr.pop();
        if (sr.empty()) rb[i] = n + 1;
        else rb[i] = sr.top();
        sr.push(i);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (ll)a[i] * (i - lb[i]) * (rb[i] - i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include<string.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{
   ll n,maxs;
   cin>>n;
   ll dp[n][3];
   ll a[n],b[n],c[n];
   for (int i = 0; i < n; ++i)
   {
       cin>>a[i]>>b[i]>>c[i];
   }
   dp[0][0]=a[0];
   dp[0][1]=b[0];
   dp[0][2]=c[0];
   for (int i = 1; i < n; ++i)
   {
       dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i];
       dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + b[i];
       dp[i][2]=max(dp[i-1][0],dp[i-1][1]) + c[i];
   }
   maxs=dp[n-1][0];
   for (int i = 1; i < 3; ++i)
   {
        if(dp[n-1][i]>maxs)
        {
            maxs=dp[n-1][i];
        }
   }
   cout<<maxs;
}

Measured memory_bytes: 8272
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    char[] x = in.next().toCharArray();
    out.println(x[2] == x[3] && x[4] == x[5] ? "Yes" : "No");
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    rep(i,n){
        int a;
        cin >> a;
        a--;
        int b;
         cin >> b;
        rep(j,b){
            int c;
            cin >> c;
            c--;
            G[a].PB(c);
        }
    }

    vector<int> dist(n, -1);
    dist[0]=0;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(int nv : G[v]){
            if(dist[nv]!=-1) continue;
            dist[nv]=dist[v]+1;
            que.push(nv);
        }
    }

    rep(i,n){
        cout << i+1 << " " << dist[i] << endl;
    }
}


Measured memory_bytes: 3224
open Printf
open Scanf

module L =
  struct
    include List
  
    let rec take n = function
        [] -> []
      | h :: t when n > 0 -> h :: take (n - 1) t
      | _ -> []

    let sum = fold_left (+) 0
  end

let id x = x

let solve n k =
  let ps = L.init n @@ fun _ -> scanf "%d " id in
  L.sum @@ L.take k @@ List.sort compare ps
          
let () =
  scanf "%d %d " solve |> printf "%d\n"


Measured memory_bytes: 4372
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	ll sum = 0;
	ll mi = inf;
	int ok = 1;
	for (int i = 0; i < N; i++) {
		ll A, B;
		cin >> A >> B;
		if (A != B)ok = 0;
		sum += A;
		if(A > B)mi = min(mi, B);
	}
	if(!ok)puts(sum - mi);
	else puts(0);
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b,c,x,z,q,d;
    cin>>a>>b>>c;
    x=a+b;
    z=a+c;
    q=b+c;
    d=min(x,z);
    cout<<min(q,d);



    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string alpha = "abcedfghijklmnopqrstuvwxyz";
        int num = rint();
        string[,] list = new string[260,100010];
        int[,] listnum = new int[260,100010];
        long total = 0;
        for(int i=0;i<num;i++){
            string read = rstr();
            char[] chan = read.ToCharArray();
            Array.Sort(chan);
            string change = new string(chan);
            int fir = 0;
            for(int j=0;j<10;j++){
                fir += alpha.IndexOf(chan[j]);
            }
            for(int j=0;j<100010;j++){
                if(list[fir,j] == null){
                    list[fir,j] = change;
                    total += listnum[fir,j];
                    listnum[fir,j]++;
                    break;
                }else if(list[fir,j] == change){
                    total += listnum[fir,j];
                    listnum[fir,j]++;
                    break;
                }
            }
        }
        WriteLine(total);
    
    
    
    
    }
    //各種読取
    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 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 int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    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] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}

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

using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int cnts=0, cntf=0;
  vector<int> abc(3);
  for (size_t i = 0; i < 3; i++) {
    cin >> abc[i];
    if (abc[i]==5) cntf++;
    else if (abc[i]==7) cnts++;
  }
  if (cnts==1 && cntf==2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
int N;
vector<pair<int,int>> Vs[100007];
int dist[100007];
bool visited[100007];
int dfs(int pos, int dist_now){
    visited[pos]=true;
    dist[pos] = dist_now%2;
    int r = dist_now;
    for(auto next:Vs[pos]){
        int next_pos = next.first;
        int next_dist = next.second;
        if(visited[next_pos])continue;
        r += dfs(next_pos, (dist_now+next_dist)%2);
    }
    return r%2;
}
int main(void){
    cin >> N;
    for(int i=0; i<N; i++){
        int u,v,w;
        cin >> u >> v >> w;
        Vs[u].push_back(make_pair(v,w));
        Vs[v].push_back(make_pair(u,w));
    }
    dist[1] = 0;
    dfs(1,0);
    
    for(int i=1; i<=N; i++){
        cout << dist[i]%2 << "\n";
    }
}

Measured memory_bytes: 8448
#include<stdio.h>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

struct xy{
  int x;
  int y;
};

struct xy to{0,0};
int ign_cnt;
struct xy ign_point[40] = {0,0};
int anser;

void serch( int x, int y){
  if(x == to.x && y == to.y){
    anser++;
    return;
  }

  rep( i, ign_cnt )
    if(x == ign_point[i].x && y == ign_point[i].y) return; 

  if(x + 1 <= to.x) serch( x + 1, y ); 

  if(y + 1 <= to.y) serch( x, y + 1 ); 
 
  return;
}

int main(){
  int ansers[5];
  rep( ds, 6 ){
    scanf( "%d%d", &to.x, &to.y );
    if( to.x == 0 && to.y == 0 ) {
      rep( i, ds) printf( "%d\n", ansers[i] );
      return 0;    
    }
    scanf( "%d", &ign_cnt );
    rep( i, ign_cnt )
      scanf( "%d%d",  &ign_point[i].x, &ign_point[i].y );
    anser = 0; 
    serch(1,1);
    ansers[ds] = anser; 
  }
  return 0;
}

Measured memory_bytes: 2724
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main(void){
  string s;
  int k;
  cin>>s>>k;
  vector<string> v;
  for(int i=0;i<k;i++){
      for(int j=0;j<s.length()-i;j++){
          v.push_back(s.substr(j,i+1));
      }
  }
  sort(v.begin(),v.end());
  unique(v.begin(),v.end());
  cout<<v[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1660
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    int N, M;
    scan(N, M);
    auto cnt = new int[](M);
    foreach (i ; 0 .. N) {
        auto ln = readln.split.to!(int[]);
        foreach (ai ; ln[1 .. $]) {
            cnt[ai - 1]++;
        }
    }
    int ans = cnt.count!(ci => ci == N).to!int;
    writeln(ans);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H)
def check(x):
    cnt = 0
    for h in H:
        if h > x * B:
            tmp = (h - x*B) // (A-B)
            #切り上げ
            if tmp * (A-B) != h - x*B: tmp += 1
            cnt += tmp
    if cnt <= x:
        return True
    else:
        return False
# (l,r]
def bisect(l,r):
    if r - l == 1: return r
    mid = (l+r) // 2
    if check(mid):
        return bisect(l,mid)
    else:
        return bisect(mid,r)
    
print(bisect(0,10**20))


Measured memory_bytes: 8260
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		ArrayList<Integer>[] list=new ArrayList[n];
		for(int i=0; i<n; i++){
			list[i]=new ArrayList<>();
		}
		for(int i=0; i<m; i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			list[a].add(b);
		}
		int mini=Integer.MAX_VALUE;
		int index=-1;
		int[] ans=new int[n];
		for(int i=0; i<n; i++){
			ArrayDeque<Integer>  que=new ArrayDeque<>();
			int[] prev=new int[n];
			int[] dist=new int[n];
			boolean[] visited=new boolean[n];
			que.add(0);
			que.add(i);
			while(!que.isEmpty()){
				int t=que.poll();
				int j=que.poll();
				dist[j]=dist[t]+1;
				prev[j]=t;
				if(visited[j]){
					if(j==i && mini>dist[j]-1){
						index=i;
						mini=dist[j]-1;
						ans=prev;
					}
					break;
				}
				visited[j]=true;
				for(int k:list[j]){
					que.add(j);
					que.add(k);
				}
			}
		}
		if(mini!=Integer.MAX_VALUE){
			System.out.println(mini);
			int i=ans[index];
			System.out.println(index+1);
			while(i!=index){
				System.out.println(i+1);
				i=ans[i];
			}
		}else{
			System.out.println(-1);
		}
	}
}


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

int main(){
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  double S;
  S=W*H/2;
  if(x==W/2&&y==H/2)
    cout<<S<<" "<<1;
  else
    cout<<S<<" "<<0;
}


Measured memory_bytes: 256