akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

#define LL long long
using namespace std;

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans1, ans2;
  ans1 = a*b;
  ans2 = c*d;
  if (ans1 > ans2) {
    cout << ans1 << endl;
  } else {
    cout << ans2 << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)

using namespace std;

long long int m, n, ans = 1;

int main(){
	cin >> m >> n;
	while (n > 0){
		if (n & 1) ans = ans*m % 1000000007;
		m = m*m % 1000000007;
		n >>= 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1156
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        //int[] NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string w = Console.ReadLine();
        int[] ch = new int[26];
        foreach (var c in w)
        {
            ch[c - 'a']++;
        }
        Console.WriteLine(ch.Count(x => x % 2 == 1) == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <typeinfo>
#include <string>
using namespace std;

#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)

vector< int > dp;

int main()
{
  int N; cin >> N;
  vector<int> cost(N, 0); REP(i, N){ cin >> cost[i]; }

  dp.resize(N);
  dp[0] = 0; dp[1] = abs(cost[1]-cost[0]);

  REP(i, N-2){
    dp[i+2] = min( dp[i] + abs(cost[i+2]-cost[i]), 
                   dp[i+1] + abs(cost[i+2]-cost[i+1]) );
  }

  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
while True:
    m, f, r = map(int, input().split())
    if m==-1 and f==-1 and r==-1: break
    
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65:
        print('B')
    elif m+f>=50:
        print('C')
    elif m+f>=30:
        if r>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
eval'K,X,Y='+`dd`.split*?,
l=1
x,y,*s=X.abs,Y.abs
d=x+y
x,y=y,x if f=x<y
K%2-d%2<0&&p(-1)+exit
d!=K&&(l+=[~-d/K,1].max
l+=1&d-K*l
v=K>(t=K*l-d>>1)?0:t-t=K
a=K-t
2.upto(l){s<<(u=f ?-t:a)<<a-t-u
a+=q=[x+v-a,K].min
t-=K-q})
puts l,s.map{|a|a*=((l=!l)?Y: X)<=>0.1},X,Y

Measured memory_bytes: 10244
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << a[n-1];
    return 0;
}


Measured memory_bytes: 256
import collections
class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in xrange(n)]
    def add_edge(self, fr, to, cap):
        self.g[fr].append([to, cap, len(self.g[to])])
        self.g[to].append([fr, 0, len(self.g[fr])-1])
    def add_multi_edge(self, v1, v2, cap1, cap2):
        self.g[v1].append([v2, cap1, len(self.g[v2])])
        self.g[v2].append([v1, cap2, len(self.g[v1])-1])
    def bfs(self, s):
        level = [-1]*self.n
        deq = collections.deque()
        level[s] = 0
        deq.append(s)
        while deq:
            v = deq.popleft()
            for e in self.g[v]:
                if e[1]>0 and level[e[0]]<0:
                    level[e[0]] = level[v] + 1
                    deq.append(e[0])
        self.level = level
    def dfs(self, v, t, f):
        if v==t: return f
        es = self.g[v]
        level = self.level
        for i in xrange(self.it[v], len(self.g[v])):
            e = es[i]
            if e[1]>0 and level[v]<level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d
                    self.g[e[0]][e[2]][1] += d
                    self.it[v] = i
                    return d
        self.it[v] = len(self.g[v])
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0: break
            self.it = [0]*self.n
            while True:
                f = self.dfs(s, t, 10**9+7)
                if f>0:
                    flow += f
                else:
                    break
        return flow
V, E = map(int, raw_input().split())
dinic = Dinic(V)
for i in xrange(E):
    u, v, c = map(int, raw_input().split())
    dinic.add_edge(u, v, c)
print dinic.max_flow(0, V-1)

Measured memory_bytes: 7000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	vector<vector<char>>c(3,vector<char>(3));
	rep(i,3)rep(j,3)cin>>c.at(i).at(j);
	rep(i,3)cout<<c.at(i).at(i);
	cout<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll X; cin >> X;
  ll result = X/500*1000 + (X%500)/5*5;
  cout << result << endl;
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	bool flag = 0;
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])  flag = 1;
	else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])  flag = 1;
	else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])  flag = 1;
	if (flag)  cout << "Yes" << endl;
	else  cout << "No" << endl;
}

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

using namespace std;

const int INF = 1e9 + 7;

int n;
int s[100], dp[100][10001];

int dfs(int now, int score)
{
  if(n == now) {
    return score % 10 ? score : 0;
  }
  if (~dp[now][score]) return dp[now][score];
  return dp[now][score] = max(dfs(now + 1, score), dfs(now + 1, score + s[now]));
}

void solve()
{
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  memset(dp, -1, sizeof dp);
  cout << dfs(0, 0) << "\n";
}

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

Measured memory_bytes: 4224
# 4 5
# 0 5
# -2 4
# 3 4
# 4 -4

n,d=map(int,input().split())
lst=[list(map(int,input().split())) for _ in range(n)]
# print(n,d,lst)

cnt=0
for x,y in lst:
    if d>=(x**2+y**2)**0.5:
        cnt+=1
print(cnt)

Measured memory_bytes: 45756
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    int k=-1;
    for(int i=2;i*(i-1)/2<=n;++i){
        if(i*(i-1)/2==n)k=i;
    }
    if(k==-1){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        cout<<"Yes"<<endl;
        cout<<k<<endl;
    }
    int cnt=1;
    vector<vector<int>> ans(k);
    rep(i,k){
        for(int j=i+1;j<k;++j){
            ans[i].push_back(cnt);
            ans[j].push_back(cnt++);
        }
    }
    rep(i,k){
        cout<<ans[i].size()<<" ";
        for(int x:ans[i]){
            cout<<x<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> l(2*n);
  for(int i = 0;i < 2*n;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int ans = 0;
  for(int i = 0;i < 2*n;i+=2){
    ans += l[i];
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

int main() {
  int N;
  scanf("%d", &N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }

  vector<ll> sum(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    sum[i] = sum[i-1] + a[i-1];
  }

  vector<vector<ll>> dp(N, vector<ll>(N + 1, LLINF));
  for (int i = 0; i < N; i++) {
    dp[i][i] = 0;
    dp[i][i+1] = 0;
  }
  for (int len = 2; len <= N; len++) {
    for (int i = 0; ; i++) {
      int j = i + len;
      if (j > N) break;
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + sum[j] - sum[i]);
      }
    }
  }

  printf("%lld\n", dp[0][N]);
}


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Priority Queue
type Item struct {
	priority, value, index int
}

type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

func main() {
	sc.Split(bufio.ScanWords)

	K, T := getInt(), getInt()
	pq := make(PQ, 0)
	heap.Init(&pq)

	for i := 0; i < T; i++ {
		a := getInt()
		heap.Push(&pq, &Item{a, i, 0})
	}

	if K == 1 {
		out(0)
		return
	}

	item0 := heap.Pop(&pq).(*Item)
	item0.priority--

	for pq.Len() > 0 {
		item1 := heap.Pop(&pq).(*Item)
		item1.priority--
		if item0.priority != 0 {
			heap.Push(&pq, &Item{item0.priority, item0.value, 0})
		}
		item0 = item1
	}

	ans := item0.priority
	out(ans)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
#define ld long double
ld dp[3001][3001][2];
ld ar[3001][2];
int n;
ld solve(int i,int c,int h){
  if(i==n){
    return (ld)(c<=n/2?1:0);
  }
  if(dp[i][c][h]>=0)return dp[i][c][h];
  ld ans=0.0000;
  ans+=ar[i][h]*solve(i+1,c+(h==1),0);
  if(i<n-1)ans+=ar[i][h]*solve(i+1,c+(h==1),1);
  dp[i][c][h]=ans;
  return ans;
}
int32_t main(){
   cin>>n;
  rep(i,0,n){
    cin>>ar[i][0];
    ar[i][1]=1-ar[i][0];
  }
  rep(i,0,n+1)rep(j,0,n+1)dp[i][j][0]=-1,dp[i][j][1]=-1;
  ld ans=solve(0,0,0)+solve(0,0,1);
  cout<<fixed<<setprecision(11)<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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

int main(){
    char a,b,c;
    cin >> a >> b  >> c;
    if(a=='7'||b=='7'||c=='7')
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#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; }
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));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a*b%2) PRINT("Odd");
    else PRINT("Even");
}


Measured memory_bytes: 256
k=int(input())

alllist=[0,1,2,3,4,5,6,7,8,9]
maelist=[0,1,2,3,4,5,6,7,8,9]
tobilist=[]

for i in range(9):
    atolist=[]
    for j in maelist:
        sentou = j // (10**(i))
        jousuu = 10**(i+1)
        if sentou == 1:
            atolist.append(1 * jousuu + j)
            atolist.append(2 * jousuu + j)
            tobilist.append(j)
        elif sentou == 9:
            atolist.append(8*jousuu+j)
            atolist.append(9*jousuu+j)
        elif sentou == 0:
            atolist.append(jousuu + j)
            tobilist.append(j)
        else:
            atolist.append((sentou - 1)*jousuu+j)
            atolist.append(sentou*jousuu+j)
            atolist.append((sentou + 1)*jousuu+j)

    alllist.extend(atolist)
    maelist=[]
    for l in atolist:
        maelist.append(l)
    maelist.extend(tobilist)

kusolist=list(set(alllist))
kusolist.sort()
print(kusolist[k])

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll comb(ll a, ll b){
  ll ret = 1;
  REP(i, b){
    ret *= (a - b + i + 1); ret %= MOD;
    ret *= pow(i + 1, MOD - 2, MOD); ret %= MOD;
  }
  return ret;
}
int main(){
  ll n, m, k; cin >> n >> m >> k;
  ll ans = comb(n + 1, 3) * (m * m % MOD) + comb(m + 1, 3) * (n * n % MOD); ans %= MOD;
  ans *= comb(n * m - 2, k - 2); ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, m, k;
	bool flag = false;
	cin >> n >> m >> k;
	if (k%n == 0||k%m == 0)flag = true;
	if (!flag) {
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int ans = j*n + i*(m - j * 2);
				if (k ==ans)flag = true;
			}
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int h,w,d;
  cin>>h>>w>>d;
  unordered_map<int, pair<int,int>> mp;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      int a;
      cin>>a;
      mp[a]={i,j};
    }
  }
  auto diff=[](pair<int,int> l, pair<int,int> r){
    return abs(l.first-r.first)+abs(l.second-r.second);
  };
  unordered_map<int, int> cost;
  for (int start = 1; start <= d; ++start)
  {
    for (int i = start; i+d <= h*w ; i+=d)
    {
      cost[i+d]=cost[i]+diff(mp[i],mp[i+d]);      
    }
  }
  int q; cin>>q;
  for (int i = 0; i < q; ++i)
  {
    int l,r;
    cin>>l>>r;
    cout<<cost[r]-cost[l]<<endl;
  }

}

Measured memory_bytes: 10828
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int dat[100];
ll dp[100][2][2];
int main()
{
	int num;
	scanf("%d", &num);
	int ttttt = 0;
	for (int p = 0;; p++)
	{
		if (num == 0)break;
		dat[p] = num % 10;
		num /= 10;
		ttttt = p + 1;
	}
	ll ans = 0;
	for (int p = 1; p <= 20; p++)
	{
		if (p < ttttt)continue;
		for (int i = 0; i < 100; i++)for (int j = 0; j < 2; j++)for (int k = 0; k < 2; k++)dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		for (int i = 0; i < p / 2; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				for (int k = 0; k < 10; k++)
				{
					if (i == 0 && k == 0)continue;
					for (int s = 0; s < 2; s++)
					{
						for (int t = 0; t < 2; t++)
						{
							if (dp[i][s][t] == 0)continue;
							int d1, d2;
							int ns = 0;
							if (k - j - s >= 0)d1 = k - j - s;
							else d1 = k - j - s + 10, ns = 1;
							for (int nt = 0; nt < 2; nt++)
							{
								if (j - k - nt >= 0)
								{
									if (t != 0)continue;
									d2 = j - k - nt;
									if (d1 == dat[i] && d2 == dat[p - 1 - i])dp[i + 1][ns][nt] += dp[i][s][t];
								}
								else
								{
									if (t != 1)continue;
									d2 = j - k - nt + 10;
									if (d1 == dat[i] && d2 == dat[p - 1 - i])dp[i + 1][ns][nt] += dp[i][s][t];
								}
							}
						}
					}
				}
			}
		}
		if (p % 2 == 0)ans += dp[p / 2][0][0] + dp[p / 2][1][1];
		else
		{
			if (dat[p / 2] == 0)ans += dp[p / 2][0][0] * 10;
			if (dat[p / 2] == 9)ans += dp[p / 2][1][1] * 10;
		}
		//printf("%d %lld\n", p, ans);
	}
	printf("%lld\n", ans);
}

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

int main() {
  int M, D;
  cin >> M >> D;
  int max_d = min(99, D);
  int answer = 0;
  for(int d = 22; d <= max_d; d++) {
    int d1 = d % 10;
    if ( d1 < 2 ) {
      continue;
    }
    int d10 = (d-d1)/10;
    if ( d10 < 2 ) {
      continue;
    }
    int p = d1 * d10;
    if ( p >= 1 && p <= M ) {
//      cout << p << " " << d << endl;
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
def num(k):
    n = (N)*(N+1)//2%inf - (N-k)*(N-k+1)//2%inf - k*(k-1)//2%inf +1
    return n

N,K = map(int,input().split())
inf = 10**9+7
ans = 0
for k in range(K,N+2):
    ans += num(k)%inf

print(ans%inf)

Measured memory_bytes: 9172
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=list(map(int,input().split()))
g=UnionFind(n)
ans=0
for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1;b-=1
    g.union(a,b)

for i in range(n):
    ans=max(ans,g.size(i))
print(ans)

Measured memory_bytes: 14728
N=int(input())
H=list(map(int,input().split()))
cnt=0
ans=0
for i in range(len(H)-1):
  if H[i]>=H[i+1]:
    cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 14224
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1ll)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e10,M=1e9+7;
const int N=1;

void solve()
{
    int n,a,b;
    cin>>n>>a>>b;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int beg=0,en=inf;
    int mid,ans;
    int cnt,tmp,d=a-b;
    while(beg<=en)
    {
        mid=(beg+en)/2;

        cnt=0;
        for(int i=0;i<n;++i)
        {
            tmp=v[i]-b*mid;
            if(tmp>0)
                cnt+=(tmp+d-1)/d;
        }

        if(cnt<=mid)
        {
            ans=mid;
            en=mid-1;
        }
        else
            beg=mid+1;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
struct Edge {
	int from;
	int to;
	int cost;
};

pair<int, int>dfs(int start,int from,const vector<vector<Edge>>&edges,int now, vector<int>&used) {

	pair<int, int>ans(0, 0);
	if (from != -1 && now == start) {
		return ans;
	}
	used[now] = true;
	for (auto e : edges[now]) {
		if (e.to != from) {

			auto p = dfs(start, e.from,edges, e.to, used);
			if (p.first < e.cost) {
				return make_pair(e.cost, 1);
			}
			else if (p.first == e.cost) {
				p.second++;
				return p;
			}
			else {
				return p;
			}
		}
		
	}
}

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<Edge>>edges(N);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 2; ++j) {
				int a, b; cin >> a >> b;
				edges[i].push_back(Edge{ i,a,b });
			}
		}
		long long int ans = 1;
		vector<int>used(N);
		for (int i = 0; i < N; ++i) {
			if (!used[i]) {
				auto p = dfs(i,-1,edges, i, used);
				ans *= p.second;
				ans %= 10007;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

bool pairCompare(const pair< int, int >& a, const pair< int, int >& b) {
    return a.second < b.second;
}

int main() {
    int N, M;
    cin >> N >> M;

    vector< pair< int, int > > ab(M);

    for (int i = 0; i < M; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end(), pairCompare);

    int ans = 0;
    int cur = 0;
    for (int i = 0; i < M; i++) {
        if (ab[i].first > cur) {
            cur = ab[i].second - 1;
            ans++;
        }
    }

    cout << ans << endl;
}

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

struct str
{
    ll w,val;
};
ll dp[107][MAX],n;
vector<str>v;

ll solve(ll pos,ll rem)
{
    if(rem==0 || pos>n)
        return 0;
    if(dp[pos][rem]!=-1)
        return dp[pos][rem];
    ll res=0;
    if(v[pos-1].w<=rem)
        res=v[pos-1].val+solve(pos+1,rem-v[pos-1].w);
    res=max(res,solve(pos+1,rem));
    dp[pos][rem]=res;
    return res;
}

int main()
{
    ll w,a,b,ans,i;
    cin >> n >> w;
    for(i=0; i<n; i++)
    {
        cin >> a >> b;
        str st= {a,b};
        v.push_back(st);
    }
    memset(dp,-1,sizeof(dp));
    ans=solve(1,w);

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 83840
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int b = a.size();
  string answer;
  for(int i=0;i<b;i++){
    if(a.at(i) == '0')
      answer.push_back('0');
    if(a.at(i) == '1')
      answer.push_back('1');
    if(a.at(i) == 'B'){
      if(answer.size() != 0)
      	answer.erase(answer.size()-1);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
/*==========================================================================*/
/*
    AUTHOR:    BPZ
	CREATED:   08.09.2020 17:36:01

*/
/*--------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 	int n, m;
 	cin >> n >> m;
 	vector<vector<int>> adj(n + 1);
 	int a, b;
 	for (int i = 0; i < m; i++) {
 		cin >> a >> b;
 		adj[a].push_back(b);
 		adj[b].push_back(a);
 	}
 	vector<bool> visited(n + 1, false);
 	int cnt;
 	function<void(int)> dfs = [&] (int s) {
 		if (visited[s]) {
 			return;
 		}
 		visited[s] = true;
 		cnt++;
 		for (auto u : adj[s]) {
 			dfs(u);
 		}
 	};
 	int ans = -1;
 	for (int i = 1; i < n + 1; i++) {
 		if (visited[i]) continue;
 		cnt = 0;
 		dfs(i);
 		ans = max(cnt, ans);
 	}
 	cout << ans << '\n';
  return 0;
}
 

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

struct node{
	int p,y;
}x[100005];

bool cmp(node a,node b)
{
	if(a.p==b.p) return a.y<b.y;
	return a.p<b.p;
}

int a[100005],b[100005];

map<pair<int , int >,int >m1;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		x[i].p=a[i];
		x[i].y=b[i];	
	}
	sort(x+1,x+m+1,cmp);
	int t=0,tt=1;
	for(int i=1;i<=m;i++)
	{
		if(x[i].p==t){
			m1[make_pair(x[i].p,x[i].y)]=tt;
			tt++;
		}
		else{
			m1[make_pair(x[i].p,x[i].y)]=1;
			tt=2;
			t=x[i].p;
		}
	}
	for(int i=1;i<=m;i++)
	{		
		printf("%06d%06d\n",a[i],m1[make_pair(a[i],b[i])]);
	}
	return 0;
} 

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>

using namespace std;

namespace {

}

int main()
{
	string S;

	cin >> S;

	set<char> setS(S.cbegin(), S.cend());

	if (setS.size() == S.size()){
		cout << "yes" << endl;
		return 0;
	}

	cout << "no" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int a[N];
int main(){
	int n,q,k;
	while(cin >> n >> q >> k){
		memset(a,0,sizeof(a));
		for(int i=0;i<k;i++){
			int s;
			cin >> s;
			a[s]++;
		}
		for(int i=1;i<=n;i++){
			a[i]+=q;
			a[i]-=k;
			if(a[i]>0) cout << "Yes\n";
			else cout << "No\n";
		}
	}
}

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

int n, a[200001];
map<int, int> m;

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

    cin >> n;
    for(int i = 1; i <= n; i++) {
        int h;
        cin >> h;
        a[i] = i - h;
        m[i + h]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(m.find(a[i]) != m.end())
            ans += m[a[i]];
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 13780
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    if(c<d){
        int ng=0;
        for(int i=a+1;i<c;i++){
            if(s[i]=='#'&&s[i+1]=='#') ng++;
        }
        for(int i=b+1;i<d;i++){
            if(s[i]=='#'&&s[i+1]=='#') ng++;
        }
        if(ng==0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{

        int ng=0;
        for(int i=a-1;i<c-2;i++){
            if(s[i]=='#'&&s[i+1]=='#') ng++;
        }
        for(int i=b-1;i<d-2;i++){
            if(s[i]=='#'&&s[i+1]=='#') ng++;
        }

        int ok=0;
        for(int i=max(0LL,b-2);i<d-1;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') ok++;
        }

        if(ng==0&&ok!=0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    
}

Measured memory_bytes: 5328
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static int[] h;
	static List<int>[] li;
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int n=s[0],m=s[1];
		h=new int[n+1];
		li=new List<int>[n+1];
		for(int i=1;i<=n;i++){
			li[i]=new List<int>();
			h[i]=-1;
		}
		for(int i=0;i<m;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			li[q[0]].Add(q[1]);
		}
		int ans=0;
		for(int i=1;i<=n;i++){
			ans=Math.Max(fu(i),ans);
		}
		Console.WriteLine(ans);
	}
	static int fu(int a){
		if(h[a]!=-1){return h[a];}
		int p=0;
		for(int i=0;i<li[a].Count;i++){
			if(h[li[a][i]]==-1){
				h[li[a][i]]=fu(li[a][i]);
			}
			p=Math.Max(h[li[a][i]]+1,p);
		}
		return p;
	}
}

Measured memory_bytes: 28684
def how_many_times_divisible(n):
    ans1 = ~-(n & -n).bit_length()
    ans2 = bin(int(n))[::-1].index('1')
    res = 0
    while n % 2 == 0:
        n /= 2
        res += 1
    assert res == ans1 == ans2
    return res

N, *A = map(int, open(0).read().split())
ans = min(map(how_many_times_divisible, A))
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		if(a>b&&a>c)System.out.println(b+c);
		else if(b>a&&b>c)System.out.println(a+c);
		else System.out.println(a+b);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		string s=Console.ReadLine()+"X";
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		List<int>[] li=new List<int>[2];
		int[] g=new int[]{0,0};
		li[0]=new List<int>();
		li[1]=new List<int>();
		int k=0;
		bool b=false;
		for(int i=0,j=0;i<s.Length;i++){
			if(s[i]=='F'){j++;}
			else if(!b){
				g[0]=j;
				j=0;
				b=true;
			}
			else{
				li[k%2].Add(j);
				k++;
				j=0;
			}
		}
		li[0].Sort((u,v)=>v-u);
		li[1].Sort((u,v)=>v-u);
		for(int i=0;i<k;i++){
			if(a[(i%2)^1]>g[(i%2)^1]){g[(i%2)^1]+=li[i%2][i/2];}
			else{g[(i%2)^1]-=li[i%2][i/2];}
		}
		Console.WriteLine("{0}",(g[0]==a[0]&&g[1]==a[1])?"Yes":"No");
	}
}

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

int main(void) {
	int N;
	cin >> N;
	for (int i=0; i<=N/4; i++) {
		for (int j=0; j<=N/7; j++) {
			if (i*4+j*7==N) {cout << "Yes" << endl; return 0;}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 34000, mod = 1e9 + 7;
int arr[18], s = 0;
int to[maxn][10], link[maxn], term[maxn], sz = 1;
struct aho {
	void add() {
		int cur = 0;
		for(int i = 0; i < s; i++) {
			if(!to[cur][arr[i]]) to[cur][arr[i]] = sz++;
			cur = to[cur][arr[i]];
		}
		term[cur] = 1;
	}
	void push_links() {
		int q[maxn], s = 0, e = 0;
		q[e++] = 0;
		while(s < e) {
			int V = q[s++];
			int U = link[V];
			for(int i = 0; i < 10; i++) {
				if(!to[V][i]) {
					to[V][i] = to[U][i];
				} else {
					q[e++] = to[V][i];
					link[to[V][i]] = V ? to[U][i] : 0;
				}
			}
		}
	}
};
int n, x, y, z;
aho r;
void ins(int m, int n) {
	for(int c = 0, i = 0; i < n; i++) {
		++c;
		if((m>>i)&1) arr[s++] = c-1, c = 0;
	}
}
void gen() {
	for(int a = 1<<(x-1); a < 1<<x; a++) {
		for(int b = 1<<(y-1); b < 1<<y; b++) {
			for(int c = 1<<(z-1); c < 1<<z; c++) {
				s = 0;
				ins(a, x);
				ins(b, y);
				ins(c, z);
				r.add();
			}
		}
	}
	r.push_links();
}
int dp[44][34000];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> x >> y >> z;
	gen();
	dp[0][0] = 1;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < sz; j++) {
			if(!dp[i][j]) continue;
			for(int k = 0; k < 10; k++) {
				if(!term[to[j][k]]) add(dp[i+1][to[j][k]], dp[i][j]);
			}
		}
	int ans = 1;
	for(int i = 0; i < n; i++) ans = ans*10ll%mod;
	for(int i = 0; i < sz; i++) if(dp[n][i]) add(ans, mod-dp[n][i]);
	cout << ans;
}


Measured memory_bytes: 7424
import math
N, M = map(int, input().split())

MOD = 10 ** 9 + 7

d = []

for i in range(2, int(math.sqrt(M))+2):
    if M % i == 0:
        d.append(0)
    while M % i == 0:
        d[-1] += 1
        M //= i
if M != 1:
    d.append(1)

def comb(n, k):
    a = 1
    for i in range(k):
        a *= (n-i)
    for i in range(k):
        a //= (i+1)
    return a

answer = 1
for i in d:
    answer *= comb(i+N-1, i)
    answer %= MOD

print(answer)

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

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}


int main() {
    int n;
    scanf("%d", &n);

    int base = 1;
    while(base <= n) {
        base *= 2;
    }
    // base is the smallest power of 2 that is not smaller than n
    vector<ll> tree(2 * base);

    vector<int> h(n), a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    vector<ll> dp(n + 1);
    // dp[i] - the max total beauty so far if the last taken flower has height i
    for(int flower = 0; flower < n; ++flower) {

        // max dp[i] for i in [0, h[flower]-1]
        int x = h[flower] + base-1;
        ll best = 0;
        while(x > 1) {
            if(x % 2 == 1) {
                max_self(best, tree[x-1]);
            }
            x /= 2;
        }
        dp[h[flower]] = best + a[flower];

        for(int i = base + h[flower]-1; i >= 1; i /= 2) {
            max_self(tree[i], dp[h[flower]]);
        }

        //~ for(int i = 0; i < h[flower]; ++i) {
            //~ max_self(dp[h[flower]], dp[i] + a[flower]);
        //~ }
    }
    ll answer = 0;
    for(int i = 0; i <= n; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 7424
#include <iostream>

int main()
{
    int X, A, B;
    std::cin >> X >> A >> B;

    int diff = B - A;
    if (diff <= 0) {
        std::cout << "delicious\n";
    } else if (diff <= X) {
        std::cout << "safe\n";
    } else {
        std::cout << "dangerous\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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 ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
using MPb = map<Pl, bool>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll h, w, m;
  cin >> h >> w >> m;
  vector<ll> hh(m), ww(m);
  MPb mpb;
  rep(i, m) {
    cin >> hh[i] >> ww[i];
    hh[i]--; ww[i]--;
    mpb[Pl(hh[i], ww[i])] = true;
  }

  ll ans = 0;

  ll row[h] = {};
  ll col[w] = {};

  rep(i, m) {
    row[hh[i]]++;
    col[ww[i]]++;
  }

  ll rowmax = *max_element(row, row+h);
  ll colmax = *max_element(col, col+w);

  set<ll> rowset;
  set<ll> colset;

  rep(i, m) {
    if (row[hh[i]] == rowmax) rowset.insert(hh[i]);
    if (col[ww[i]] == colmax) colset.insert(ww[i]);
  }

  ans = rowmax + colmax -1;

  for( auto i = rowset.begin(); i != rowset.end(); ++i ) {
    for (auto j = colset.begin(); j != colset.end(); ++j) {
      if (!mpb[Pl(*i, *j)]) {
        ans = rowmax + colmax;
        cout << ans << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 59364
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) scanf("%lld", &a[i]);
    VL s(n+1), sp(n+1);
    ll sump = 0;
    REP(i,n){
        s[i+1] = s[i] + a[i];
        sp[i+1] = sp[i];
        if (a[i] > 0){
            sp[i+1] += a[i];
            sump += a[i];
        }
    }
    ll ans = -1e18;
    REP(i,n-k+1){
        ll res = sump - (sp[i+k] - sp[i]);
        res = max(res, res + s[i+k] - s[i]);
        ans = max(ans, res);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int len = s.length();
  if(s[len-1] == 's')
  {
    s=s+"es";
  }else{
    s=s+"s";
  }
  cout<<s<<'\n' ;
  return 0;
}

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

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout); 
    // #endif
    
    fastio(); 

    int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(auto &it: p) cin >> it;
    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < k; ++i)
    {
        ans += p.at(i);
    }

    cout << ans << "\n";

    return;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;
 
void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>>h;
    rep(i,n){
        int x;
        cin>>x;
        h.eb(x,i+1);
    }
    sort(begin(h),end(h));
    rep(i,n){
        if(i)cout<<" ";
        cout<<h[i].second;
    }
    cout<<endl;
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main() {
    string ss;
    while(cin>>ss){

        if(ss=="SUN")
            cout<<7<<endl;
        else if(ss=="MON")
            cout<<6<<endl;
        else if(ss=="TUE")
            cout<<5<<endl;
        else if(ss=="WED")
            cout<<4<<endl;
        else if(ss=="THU")
            cout<<3<<endl;
        else if(ss=="FRI")
            cout<<2<<endl;
        else if(ss=="SAT")
            cout<<1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var N = readInt()
    var L = readIntList().sorted()

    var ans = 0L
    for (i in 0 until N-2) {
        var a = L[i]
        for (j in i+1 until N-1){
            var b = L[j]
            for (k in j+1 until N){
                var c = L[k]
                if (c < a+b ) ans++
                else break
            }
        }
    }

    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	long n, t;
	cin >> n >> t;
	long l = 1000000001;
	long h = 0;
	long dmax = 0;
	vector<long> mins = {};
	vector<long> maxs = {};

	for (size_t i = 0; i < n; i++) {
		long a;
		cin >> a;
		bool isLowUpdate = false;
		if (a < l) {
			h = 0;
			l = a;
			isLowUpdate = true;
		}
		h = max(h, a);
		long d = h - l;
		if (d <= 0) {
			continue;
		}
		if (d > dmax) {
			mins = {l};
			maxs = {h};
			dmax = d;
		} else if (d == dmax) {
			if (find(mins.begin(), mins.end(), l) == mins.end()) {
				mins.push_back(l);
			}
			if (find(maxs.begin(), maxs.end(), h) == maxs.end()) {
				maxs.push_back(h);
			}
		}
	}
	// cout << "min";
	// for (size_t i = 0; i < mins.size(); i++) {
	// 	cout << ", " << mins[i];
	// }
	// cout << endl;
	// cout << "max";
	// for (size_t i = 0; i < maxs.size(); i++) {
	// 	cout << ", " << maxs[i];
	// }
	// cout << endl;

	cout << min(mins.size(), maxs.size()) << endl;
}


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

int main(){
	int n, tn, count;
	while(cin >> n){
		count = 0;
		for(int a = ( 27 < n ) ? (n - 27) : 0; a < 10; a++){
			int na = n - a;
			for(int b = ( 18 < na ) ? (na - 18) : 0; b < 10; b++){
				int nb = na - b;
				for(int c = ( 9 < nb ) ? (nb - 9) : 0; c < 10; c++){
					int nc = nb - c;
					if(0 <= nc && nc < 10)
						count++;
				}
			}
		} 
	cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(N>M) swap(N,M);
  
  if(N == 1){
    if(M == 1){
      cout << 1 << endl;
    }
    else if(M == 2){
      cout << 0 << endl;
    }
    else{
      cout << M-2 << endl;
    }
  }
  else if(N == 2){
    cout << 0 << endl;
  }
  else{
    cout << (N-2)*(M-2) << endl;
  }
  return 0;
}


Measured memory_bytes: 384