akhauriyash/Code-Regression huggingface dataset:
<?php
list($h, $w) = ints();
list($si, $sj) = ints();
list($gi, $gj) = ints();
for ($i = 0; $i < $h; ++$i) list($c[]) = strs();
$score = bfs($h, $w, $c, $si - 1, $sj - 1);
echo $score[$gi - 1][$gj - 1] !== INF ? $score[$gi - 1][$gj - 1] : -1;
function bfs($h, $w, $c, $si, $sj)
{
    $score = array_fill(0, $h, array_fill(0, $w, INF));
    // dequeがPHPにないのでqueue2つで代用
    $q_top = new SplQueue(); // 先頭（通常移動）
    $q_end = new SplQueue(); // 末尾（ワープ移動）
    $q_top->enqueue([$si, $sj]);
    $score[$si][$sj] = 0;
    while (!$q_top->isEmpty() || !$q_end->isEmpty()) {
        list($i, $j) = !$q_top->isEmpty() ? $q_top->dequeue() : $q_end->dequeue();
        if (isset($visited[$i][$j])) continue;
        for ($di = -2; $di <= 2; ++$di) {
            for ($dj = -2; $dj <= 2; ++$dj) {
                if ($di === 0 && $dj === 0) continue;
                $ni = $i + $di;
                $nj = $j + $dj;
                // 範囲外であればコンテニュー
                if ($ni < 0 || $ni > $h - 1 || $nj < 0 || $nj > $w - 1) continue;
                // 壁であればコンティニュー
                if ($c[$ni][$nj] === '#') continue;
                $warpFrag = (abs($di) + abs($dj)) > 1;
                if ($warpFrag) {
                    if ($score[$ni][$nj] <= $score[$i][$j] + 1) continue;
                    // 末尾に追加
                    $q_end->enqueue([$ni, $nj]);
                    $score[$ni][$nj] = $score[$i][$j] + 1;
                } else {
                    if ($score[$ni][$nj] <= $score[$i][$j]) continue;
                    // 先頭に追加
                    $q_top->enqueue([$ni, $nj]);
                    $score[$ni][$nj] = $score[$i][$j];
                }
            }
        }
        $visited[$i][$j] = true;
    }
    return $score;
}

function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 81360
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

main :: IO ()
main = do
  [n, m] <- readInts
  ass <- sortOn last <$> replicateM m readInts
  print $ solve 0 0 ass

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> Int -> [[Int]] -> Int
solve !n _ [] = n
solve !n !p ([a, b]:ass)
  | a >= p
    = solve (n + 1) b ass
  | a < p
    = solve n p ass


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

const int infi = (int)1e+9 + 7;

struct Ing{
    int a, b, c;
};

int n, ma, mb;
Ing ing[41];
int dp[41][401][401];

int main(){
    for(int i = 0; i < 41; ++i){
        for(int j = 0; j < 401; ++j){
            for(int k = 0; k < 401; ++k)dp[i][j][k] = infi;
        }
    }
    
    std::cin >> n >> ma >> mb;
    
    for(int i = 0; i < n; ++i){
        int a, b, c;
        std::cin >> a >> b >> c;
        ing[i] = {a, b, c};
    }
    
    dp[0][0][0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 401; ++j){
            for(int k = 0; k < 401; ++k){
                if(dp[i][j][k] == infi)continue;
                
                dp[i + 1][j + ing[i].a][k + ing[i].b] = std::min(dp[i + 1][j + ing[i].a][k + ing[i].b], dp[i][j][k] + ing[i].c);
                dp[i + 1][j][k] = std::min(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
    }
    
    int min = infi;
    int ta = ma, tb = mb;
    while(ta <= 400 && tb <= 400){
        min = std::min(min, dp[n][ta][tb]);
        ta += ma, tb += mb;
    }
    std::cout << (min == infi ? -1 : min) << std::endl;
    
    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n, k;
    cin >> n>> k;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    sort(RALL(h));
    ll ans = 0;
    for(int i = k; i < n; i++) {
        ans += h[i];
    }

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

Measured memory_bytes: 1792
n,m = map(int, input().split())
l = [2,5,5,4,5,6,3,7,6]

a = list(map(int, input().split()))
a.sort(reverse=True)
key = set([l[i-1] for i in a])

dp = [-float("inf")]*(n+1)
dp[0] = 0
for i in range(n):
    for j in key:
        if i+j <= n:
            dp[i+j] = max(dp[i+j], dp[i]+1)

i = n
ans = []
while i > 0:
    for ai in a:
        if i-l[ai-1] >= 0 and dp[i]-dp[i-l[ai-1]] == 1:
            ans.append(ai)
            i -= l[ai-1]
            break
print("".join(map(str, ans)))

Measured memory_bytes: 41328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

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

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    ll X, K, D; cin >> X >> K >> D;

    ll XX = abs(X);
    ll A = XX / D;

    if (X == 0) {
        if (K % 2 == 0) {
            cout << 0 << endl;
        }
        else {
            cout << D << endl;
        }
    }
    else if (X > 0) {
        if (K <= A) {
            cout << X - D * K << endl;
        }
        else {
            if ((K - A) % 2 == 0) {
                cout << abs(X - D * A) << endl;
            }
            else {
                cout << abs(X - D * A - D) << endl;
            }
        }
    }
    else if (X < 0) {
        if (K <= A) {
            cout << abs(X + D * K) << endl;
        }
        else {
            if ((K - A) % 2 == 0) {
                cout << abs(X + D * A) << endl;
            }
            else {
                cout << abs(X + D * A + D) << endl;
            }
        }
    }

}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

long double rootD(long double a) {
    long double b = a;
    while (b * b - a >= 0.00000000000000000000000000000000000000000000000000000000000000000001) {
        b = (b * b + a) / (2.0 * b);
    }
    return b;
}

int main() {
    long long int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    
    bool r = a + (2 * rootD(a * b)) + b < c;
    
    if (r)
    {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	string s,t;
	ll cnt = 0;
	cin >> s >> t;
	
	rep(i,0,3) if(s[i] == t[i]) cnt++;
	cout << cnt << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
vector<vector<int>> g;
vector<vector<int>> dp;
void dfs(int u, int pu = -1) {
  dp[u][0] = dp[u][1] = 1;
  for (int v : g[u]) {
    if (v == pu)
      continue;
    dfs(v, u);
    dp[u][1] = (dp[u][1] * dp[v][0]) % mod;
    dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % mod;
  }
}
void init() {
  int n;
  cin >> n;
  g.resize(n);
  dp = vector<vector<int>>(n, vector<int>(2));
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].pb(v);
    g[v].pb(u);
  }
  dfs(0);
  cout << (dp[0][0] + dp[0][1])%mod << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A!=C){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>

using namespace std;

int n, q;
string s;

bool check(int &x, vector<pair<char, char>> &da, int po) {
	char no = s[po];
	for (int i = 0;i < q;i++) {
		if (no == da[i].first) {
			if (da[i].second == 'L') {
				po--;
			}
			else {
				po++;
			}
		}
		if (po == x) {
			return false;
		}
		if (po == n - 1 - x) {
			return true;
		}
		no = s[po];
	}
	return true;
}

int nibutan(int x, int le, int ri, vector<pair<char, char>> &da) {
	if (ri - le == 1) {
		return le;
	}
	if (check(x, da, (ri + le) / 2) ^ (x == -1)) {
		le = (ri + le) / 2;
	}
	else {
		ri = (ri + le) / 2;
	}
	return nibutan(x, le, ri, da);
}

int main() {
	cin >> n >> q >> s;
	vector<pair<char, char>> da(q);
	for (int i = 0;i < q;i++) {
		cin >> da[i].first >> da[i].second;
	}
	cout << nibutan(n, -1, n, da) - nibutan(-1, -1, n, da) << endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int T[N];
	for(int i=0;i<N;i++){
		cin >> T[i];

	}
	int M;
	cin >> M;
	int P[M], X[M];
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
	}
	int sum = 0;
	for(int i = 0; i < N; i++) {
		sum += T[i];
	}
	for (int i = 0; i < M; i++) {
		int ans = sum;
		ans -= T[P[i] - 1] - X[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int x,a,b;
  cin >> x>>a>>b;
 
  if((x-a)*(x-a)>=(x-b)*(x-b)) {
  cout << "B" << endl;
  }
  
  else {
  cout << "A" << endl; 
  }
  
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vl a,b;

int main(){
	cin>>n;
	a=b=vl(n);
	for(int i=n-1;i>=0;i--) cin>>a[i]>>b[i];
	ll ans=0;
	for(int i=0;i<n;i++) if(a[i]){
		a[i]+=ans;
		ll tmp=a[i]/b[i];
		if(a[i]%b[i]!=0) tmp++;
		ans+=tmp*b[i]-a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
    ll N, M;
    cin>>N>>M;
    vector<ll> S(N), T(M);
    for(ll i=0; i<N; i++){
        cin>>S[i];
    }
    for(ll i=0; i<M; i++){
        cin>>T[i];
    }
    vector<vector<ll>> dp(N+1, vector<ll>(M+1, 0));
    for(ll i=0; i<N+1; i++){
        dp[i][0]=1;
    }
    for(int i=0; i<M+1; i++){
        dp[0][i]=1;
    }
    for(ll i=1; i<=N; i++){
        for(ll j=1; j<=M; j++){
            dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
          	dp[i][j]+=MOD;
            dp[i][j]%=MOD;
            if(S[i-1]==T[j-1]){
                dp[i][j]+=dp[i-1][j-1];
              	dp[i][j]+=MOD;
                dp[i][j]%=MOD;
              	//cout<<"!";
            }
          	//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
    }
    cout<<dp[N][M]<<endl;
  	return 0;
}

Measured memory_bytes: 31616
n = gets.to_i
array = gets.split(" ").map(&:to_i)

array.sort!

loop do
  if array.length > 1
    a, b = array.shift(2)
    array.push((a + b).to_f / 2)
    array.sort!
  else
    break
  end
end

puts array[0]

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

int main()
{
    int n,count = 0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        int num = 0;
        cin>>a;
        while(a%2 == 0){
            num++;
            a /= 2;
        }
        if(i == 0){
            count = num;
        }else if(num <= count){
            count = num;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
mod = 1000000007
n,k = map(int, input().split())
d = [0]*(k+1)
for i in range(1,k+1):
    d[i] = pow(k//i,n,mod)
for i in range(k,0,-1):
    for j in range(2*i,k+1,i):
        d[i] -= d[j]
        d[i] %= mod
ans = 0
for i in range(1,k+1):
    ans += d[i]*i
    ans %= mod
print(ans)

Measured memory_bytes: 11188
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    a <- strToInt <$> getLine
    b <- strToInt <$> getLine
    h <- strToInt <$> getLine
    -- 出力
    putStrLn . show $ (a + b) * h `div` 2


Measured memory_bytes: 508
//Optimize
#pragma GCC optimize("Ofast")

//Head File
#include<bits/stdc++.h>
using namespace std;

#define il inline

//Variable
#define ll long long
#define ull unsigned long long
#define db double
#define lb long double
#define ui unsigned int

//Debug
#define B cerr<<"Break Point"<<endl;
#define P(x) cerr<<#x<<' '<<"="<<' '<<(x)<<endl;
#define p(x) cerr<<#x<<' '<<"="<<' '<<(x)<<' ';
#define ml(x) cerr<<"Size of array is "<<x*4/1024/1024<<" MB"<<endl;

//Vector
#define vc vector
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define vbe(x) x.begin(),x.end()

//Memset
#define ms(x) memset(x,0,sizeof(x))
#define MS(x) memset(x,0x3f3f3f3f,sizeof(x))

//Pair
#define fi first
#define se second

//File

#define fin(x) freopen(x,"r",stdin)
#define fou(x) freopen(x,"w",stdout)
void fio()
{
    #ifndef ONLINE_JUDGE
    freopen("sample.in","r",stdin);
    freopen("sample.out","w",stdout);
    #endif
}
void pti()
{
    double timeuse = clock()*1000.0/CLOCKS_PER_SEC;
    cerr<<"Timeuse "<<timeuse<<"ms"<<endl;
}
void end()
{
    pti();
    exit(0);
}

//Inf
#define INF 0x3f3f3f3f
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))

//IO
#define pc(s) putchar(s)
#define say(s) cout<<s<<endl
namespace io
{
    const int SIZ=55;int que[SIZ],op,qr;char ch;
    template<class I>
    il void gi(I &w)
    {
        ch=getchar(),op=1,w=0;
	while(!isdigit(ch)){if(ch=='-') op=-1;ch=getchar();}
        while(isdigit(ch)){w=w*10+ch-'0';ch=getchar();}w*=op;
    }
    template<typename T,typename... Args>
    il void gi(T& t,Args&... args){gi(t);gi(args...);}
    template<class I>
    il void print(I w)
    {
        qr=0;if(!w) putchar('0');if(w<0) putchar('-'),w=-w;
	while(w) que[++qr]=w%10+'0',w/=10;
        while(qr) putchar(que[qr--]);
    }
}
using io::gi;
using io::print;

const int N=2e5+5;
const ll mod=1e9+7;

int n,k;
ll fac[N];

ll qpow(ll x,ll y)
{
    ll res=1;
    while(y)
    {
	if(y&1) res=res*x%mod;
	x=x*x%mod;
	y>>=1;
    }
    return res;
}
ll inv(ll x)
{
    return qpow(x,mod-2);
}
ll calc(int x,int y)
{
    return fac[x]*inv(fac[y])%mod*inv(fac[x-y])%mod;
}
int main()
{
    gi(n,k),fac[0]=1;
    for(int i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod;
    ll res=0;
    for(int i=0;i<=min(n-1,k);++i)
	res=(res+calc(n,i)*calc(n-1,n-i-1)%mod)%mod;
    print(res);
    end();
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;


class Networkflow {
private:
	struct edgedata {
		int to, weight, capacity;
		edgedata* dual_p;
	};
	struct node {
		int id;
		bool done;
		list<edgedata> edge;
	};
	vector<node> nodes;
	int n;
	int source, sink;
public:
	int result;
	Networkflow(vector<vector<pair<int, P>>> data, int s, int t) {
		n = data.size();
		source = s;
		sink = t;
		nodes.resize(n);
		Loop(i, n) {
			nodes[i] = { i, false, {} };
		}
		edgedata* dummy = new edgedata;
		Loop(i, n) {
			Loop(j, data[i].size()) {
				nodes[i].edge.push_back({
					data[i][j].first,
					data[i][j].second.first,
					data[i][j].second.second,
					dummy
				});
				nodes[data[i][j].first].edge.push_back({
					i,
					data[i][j].second.first,
					0,
					&(nodes[i].edge.back())
				});
				nodes[i].edge.back().dual_p = &(nodes[data[i][j].first].edge.back());
			}
		}
		delete dummy;
	}
	void maxflow() {
		result = 0;
		vector<pair<int, edgedata*>> stk;
		int a; // the node which is focused on
		int df; // how much flow in one operation
		while (1) {
			a = source;
			Loop(i, n) nodes[i].done = false;
			nodes[source].done = true;
			while (a != sink) {
				int b = -1;
				edgedata* p;
				for (auto itr = nodes[a].edge.begin(); itr != nodes[a].edge.end(); ++itr) {
					if ((*itr).capacity > 0) {
						b = (*itr).to;
						if (nodes[b].done) b = -1;
						else {
							p = &(*itr);
							stk.push_back(make_pair(a, p));
							nodes[b].done = true;
							a = b;
							break;
						}
					}
				}
				if (b == -1) {
					if (stk.empty()) break;
					a = stk.back().first;
					stk.pop_back();
				}
			}
			if (stk.empty()) break;
			df = INT_MAX;
			Loop(i, stk.size()) {
				df = min(df, (*(stk[i].second)).capacity);
			}
			while (stk.size()) {
				(*(stk.back().second)).capacity -= df;
				(*((*(stk.back().second)).dual_p)).capacity += df;
				stk.pop_back();
			}
			result += df;
		}
		return;
	}
};

int main() {
	int v, e;
	cin >> v >> e;
	vector<vector<pair<int, P>>> data(v);
	Loop(i, e) {
		int u, v, c; cin >> u >> v >> c;
		data[u].push_back(make_pair(v, make_pair(1, c)));
	}
	Networkflow networkflow(data, 0, v - 1);
	networkflow.maxflow();
	cout << networkflow.result << endl;
	return 0;
}

Measured memory_bytes: 3236
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h=sc.nextLong();
        long w=sc.nextLong();
        if(h==1||w==1){
            System.out.println(1);
            return;
        }
        if(h%2==0||w%2==0){
            System.out.println(h*w/2);
        }else{
            System.out.println((h*w+1)/2);
        }
        
        
        
 
    }



}

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

using ll = long long;
using P = pair<int, int>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define zarray(x,n) x[n+1]; rep1(i,n) {x[i]=0;} 

int main() {
    int n;
    cin >> n;
    map<string,int> a;
    rep0(i,n) {
        string s;
        cin >> s;
        a[s]++;
    }
    int ans = a.size();
    cout << ans << endl;
}


Measured memory_bytes: 19156
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100010;
const int N = 100;

int du[MAX],dv[MAX];
vi G[MAX];

void bfs(int s, int d[]) {
	queue<int> Q;
	Q.push(s);
	d[s]=0;
	while(!Q.empty()){
		int i=Q.front();Q.pop();
		for(auto j:G[i]){
			if(d[j]>d[i]+1){
				Q.push(j);
				d[j]=d[i]+1;
			}
		}
	}
}

int main() {
	int n,u,v;cin>>n>>u>>v;u--;v--;
	rep(i,n-1) {
		int a,b;cin>>a>>b;a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,n) {du[i]=INF;dv[i]=INF;}
	bfs(u,du);
	bfs(v,dv);
	int ans=-1;
	rep(i,n) if(du[i]<dv[i]) ans=max(ans,dv[i]-1);
	cout<<ans<<endl;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#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 rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={};
    ll cnt[n+1]={};
    ll ans=0;
    ll ac=0;
    rep(i,0,m)
    {
        ll x;
        string s;
        cin>>x>>s;
        if( a[ x ] == 1 )
        cont;
        else
        {
            if( s=="AC" )
            {
                a[x]=1;
                //ac++;
            }
            else
            {
                cnt[x]++;
            }
        }
    }
    rep(i,1,n+1)
    {
        if( a[i]==1 )
        {
            ac++;
            ans+=cnt[i];
        }
    }
    cout<<ac<<" "<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int N = pow(10,5);

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

int main() {
  long long N,T;
  long long a[N];
  cin>>N>>T;
  long long counter=0;
  for(int i=0; i<N; i++){
  cin>>a[i];}
  for(int i=0; i<N-1; i++){
  if(T+a[i]>=a[i+1]){
  counter+=a[i+1]-a[i];}
  else
  counter+=T;}
  counter+=T;
  cout<<counter<<endl;}
  


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1,t2,a1,a2,b1,b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (a1 < b1){
        ll l = (b1-a1)*t1,r = (a2-b2)*t2;
        if (r < l) PRINT(0);
        else if (l == r) PRINT("infinity");
        else{
            ll d = r-l;
            if (l%d == 0){
                PRINT(1+(l/d-1)*2+1);
            }
            else{
                PRINT(1+(l/d)*2);
            }
        }
    }
    else{
        ll l = (a1-b1)*t1,r = (b2-a2)*t2;
        if (r < l) PRINT(0);
        else if (l == r) PRINT("infinity");
        else{
            ll d = r-l;
            if (l%d == 0){
                PRINT(1+(l/d-1)*2+1);
            }
            else{
                PRINT(1+(l/d)*2);
            }
        }
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll num=sum/(n*(n+1)/2);
	vl b(n);
	for(int i=0;i<n;i++) b[i]=a[(i+1)%n]-a[i];
	ll tmp=0;
	bool flag=0;
	for(int i=0;i<n;i++){
		if((num-b[i])%n!=0||num-b[i]<0) flag=1;
		tmp+=(num-b[i])/n;
	}
	if(tmp==num&&!flag&&sum%(n*(n+1)/2)==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

struct Point{
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator +(Point p){
        return Point(x+p.x,y+p.y);
    }
    Point operator -(Point p){
        return Point(x-p.x,y-p.y);
    }
    Point operator *(double a){
        return Point(a*x,a*y);
    }
    Point operator /(double a){
        return Point(x/a,y/a);
    }

    double Abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }

    bool operator <(const Point &p) const{
        return equals(x,p.x)?(y<p.y):(x<p.x);
    }

    bool operator ==(const Point &p) const{
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;
struct Segment{
    Point p1,p2;
};

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool is0rthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return is0rthogonal(Vector(a1-a2),Vector(b1-b2));
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

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

    int q;
    cin>>q;

    for(int i=1;i<=q;i++){
        Point p0,p1,p2,p3;
        cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;

        if(isOrthogonal(p0,p1,p2,p3)){
            cout<<1<<"\n";
        }

        else if(isParallel(p0,p1,p2,p3)){
            cout<<2<<"\n";
        }

        else{
            cout<<0<<"\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <cassert>
using namespace std;
#define INF 100000010

void solve(int N, int* purse,int* retval);
int pay(int N, int* purse, int* retval);
int change(int N, int* retval);


int main(void){
  int N;
  bool start=true;
  while(1){
    cin>>N;
    if(N==0){
      break;
    }
    if(start==false){
      cout<<endl;
    }
    int retval[4];
    int purse[4];
    for(int i=0;i<4;i++){
      cin>>purse[i];
      retval[i]=0;
    }
    solve(N,purse,retval);
    if(retval[0]!=0){
      cout<<"10 "<<retval[0]<<endl;
    }
    if(retval[1]!=0){
      cout<<"50 "<<retval[1]<<endl;
    }
    if(retval[2]!=0){
      cout<<"100 "<<retval[2]<<endl;
    }
    if(retval[3]!=0){
      cout<<"500 "<<retval[3]<<endl;
    }
    start=false;
  }
}

void solve(int N, int* purse,int* retval){
  int _retval=INF;
  for(int cache=0;cache<=20*(10+50+100+500);cache+=10){
    bool dup=false;
    int changes[4];
    int pays[4];
    int pay_amount=pay(N+cache,purse,pays);
    int change_amount=change(cache,changes);
    for(int i=0;i<4;i++){
      if(pays[i]==changes[i] and pays[i]!=0){
        dup=true;
      }
    }
    if(dup==false and _retval>purse[0]+purse[1]+purse[2]+purse[3]-pay_amount+change_amount){
      for(int i=0;i<4;i++){
        retval[i]=pays[i];
      }
      _retval=purse[0]+purse[1]+purse[2]+purse[3]-pay_amount+change_amount;
    }
  }
}

int pay(int N, int* purse, int* retval){
  for(int i=0;i<4;i++){
    retval[i]=0;
  }

  if(N<=purse[0]*10){
    retval[0]=N/10;
    return retval[0]+retval[1]+retval[2]+retval[3];
  }

  N-=purse[0]*10;
  retval[0]=purse[0];
  while(N%50!=0){
    N+=10;
    retval[0]-=1;
    if(retval[0]<0){
      return -1*INF;
    }
  }
  assert(N%50==0);

  if(N<=purse[1]*50){
    retval[1]=N/50;
    return retval[0]+retval[1]+retval[2]+retval[3];
  }

  N-=purse[1]*50;
  retval[1]=purse[1];
  while(N%100!=0){
    N+=50;
    retval[1]-=1;
    if(retval[1]<0){
      return -1*INF;
    }
  }
  assert(N%100==0);

  if(N<=purse[2]*100){
    retval[2]=N/100;
    return retval[0]+retval[1]+retval[2]+retval[3];
  }

  N-=purse[2]*100;
  retval[2]=purse[2];
  while(N%500!=0){
    N+=100;
    retval[2]-=1;
    if(retval[2]<0){
      return -1*INF;
    }
  }
  assert(N%500==0);

  if(N<=purse[3]*500){
    retval[3]=N/500;
    return retval[0]+retval[1]+retval[2]+retval[3];
  }
  else{
    return -1*INF;
  }
}

int change(int N,int* retval){
  retval[3]=N/500;
  N=N%500;
  retval[2]=N/100;
  N=N%100;
  retval[1]=N/50;
  N=N%50;
  retval[0]=N/10;
  N=N%10;// must be zero.
  return retval[0]+retval[1]+retval[2]+retval[3];
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;



int main(){
    int a, b, k;
        cin >> a >> b >> k;
        if(b<a) swap(a, b);
    vec v;
        for(int i=1; i<=a; i++)
            if(a%i==0 && b%i==0)
                v.push_back(i);
    reverse(v.begin(), v.end());
    cout << v.at(k-1) << endl;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void sw(string& s, int l, int r) {
    REP(i, (r - l + 1) / 2) {
        swap(s[l + i], s[r - i]);
    }
}

void solve() {
    string s;
    cin >> s;
    if (s == "SUN") cout << 7 << EOL;
    else if (s == "MON") cout << 6 << EOL;
    else if (s == "TUE") cout << 5 << EOL;
    else if (s == "WED") cout << 4 << EOL;
    else if (s == "THU") cout << 3 << EOL;
    else if (s == "FRI") cout << 2 << EOL;
    else if (s == "SAT") cout << 1 << EOL;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
	int n;
	scanf("%d", &n);
	int i, j;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int now = 1;
	for (i = 0; i < n; i++) {
		if (a[i] == now) {
			now++;
		}
	}
	if (now == 1) {
		printf("-1\n");
	}
	else printf("%d\n", n - now + 1);
	return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const ll MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c <<" "<< a <<" "<< b<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int mod = 1e9 + 7;
const long double PI = 3.141592653589793;

void solve(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  ld theta = (ld) h / 12.0 + ((ld) m / 60.0) / 12.0 -(ld) m / 60.0;
  theta *= PI * 2;
  ld rsq = (ld) (a*a + b*b) - (ld)(2*a*b)*cosl(theta);
  rsq = sqrtl(rsq);
  cout << setprecision(20) << fixed << rsq << endl; 
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4084
n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]

dp = [0]*(ma+1)

for i in range(1,n):
    if a[i]==a[i-1]:
        dp[a[i]]=1

for i in a:
    for j in range(i*2,ma+1,i):
        #if dp[j]==1:
            #break
        dp[j]=1
        
ans = 0
for i in a:
    if dp[i]==0:
        ans+=1
        
print(ans)

Measured memory_bytes: 32376
def examA():
    S, T = LSI()
    ans = T+S
    print(ans)
    return

def examB():
    A, B, K = LI()
    if A>K:
        A -=K
        print(A,B)
        return
    if A+B>K:
        B -=(K-A)
        A = 0
        print(A,B)
        return
    A = 0; B = 0
    print(A,B)
    return

def examC():
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 3444
using System;
using System.Linq;

namespace dotnet_test
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var nums =
                Console.ReadLine()
                .Split(' ')
                .Select(UInt64.Parse)
                .ToArray();
            UInt64 a = nums[0], b = nums[1], c = nums[2];



            UInt64 rhs_sqrt = c - a - b;
            UInt64 lhs = 4 * a * b;


            if (c < a + b || lhs >= rhs_sqrt * rhs_sqrt)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    cout<<N*N*N<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	for i := 1; i <= 100; i++ {
		x := a * i
		if x%b == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
n,a,b=(int(x) for x in input().split())
amount=0
for i in range(1,n+1):
  append = 0
  num = list(str(i))
  for j in range(len(num)):
    append+=int(num[j])
  if append>=a and append<=b:
    amount+=i
print(amount)

Measured memory_bytes: 3060
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[] line = new String[h];
    int[][] field = new int[w+2][h+2];
    int[][] mine = new int[w+2][h+2];

    for(int i=0;i<h;i++){
      line[i] = sc.next();
    }

    //mine は#がある場所を-1で記憶
    for(int i=0;i<h+2;i++){
      for(int j=0;j<w+2;j++){
        if(0<i && i<h+1 && 0<j && j<w+1){
          if(line[i-1].charAt(j-1) == '#'){
            mine[j][i] = -1;
          }
        }
        field[j][i] = 0;    //fieldの初期化
      }
    }

    for(int i=0;i<h+2;i++){
      for(int j=0;j<w+2;j++){
        // #かどうか判別
        if(mine[j][i] == -1){
          // # の周り3*3全てをプラス１
          for(int l=i-1;l<i+2;l++){
            for(int m=j-1;m<j+2;m++){
              field[m][l] = field[m][l] + 1;
            }
          }
        }
      }
    }

    for(int i=1;i<h+1;i++){
      for(int j=1;j<w+1;j++){
        if(mine[j][i] == -1){
          System.out.print('#');
        }else{
          System.out.print(field[j][i]);
        }
      }
      System.out.println("");
    }

  }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  int sRight = *lower_bound(all(s), x);
  int sLeft = *(upper_bound(all(s), x) - 1);
  int tRight = *lower_bound(all(t), x);
  int tLeft = *(upper_bound(all(t), x) - 1);

  int ret = INF;

  // (s, t) -> (t, s) -> x
  chmin(ret, abs(min(sLeft, tLeft) - x));

  // s -> x -> t
  chmin(ret, abs(tRight - sLeft) + abs(min(x - sLeft, tRight - x)));

  // t -> x -> s
  chmin(ret, abs(sRight - tLeft) + abs(min(x - tLeft, sRight - x)));

  // x -> (s, t) -> (t, s)
  chmin(ret, abs(max(tRight, sRight) - x));

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると値が見つからなかったときの処理が楽になる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> a) {
  map<int,int> cnt;
  for (ll i: a) cnt[i]++;
  ll res = 0;
  for (auto p: cnt) {
    if (p.first > p.second) res += p.second;
    else res += p.second - p.first;
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 6272
def find_max(a):
    n = len(a)

    if n <= 3:
        return max(a)

    dp = [[-(1 << 64)] * (2 + n % 2) for _ in range(n)]

    for i in range(2 + n % 2):
        dp[i][i] = a[i]
        dp[i + 1][i] = a[i]

    for i in range(2, n):
        for j in range(2 + n % 2):
            for extra_space in range(j + 1):
                curr_sum = dp[i - (2 + extra_space)][j - extra_space] + a[i]
                if curr_sum > dp[i][j]:
                    dp[i][j] = curr_sum

    return dp[-1][1 + n % 2]


def main():
    _ = int(input())
    a = list(map(int, input().split()))

    print(find_max(a))


main()


Measured memory_bytes: 66608
N, C = gets.split.map(&:to_i)
STCs = readlines.map{|l| l.split.map(&:to_i)}

rcd = STCs.sort.each_with_object([]) do |p, r|
  if i = r.index{|s, t, c| c == p[2] || t < p[0]}
    r[i] = p
  else
    r << p
  end
end
puts rcd.size

Measured memory_bytes: 18296