akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

template< typename T >
struct BIT {
  vector< T > data;

  BIT(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};



int main() {
    int N,D,A;cin >> N >> D >> A;
    vector<pll> XH(N);
    rep(i,N)cin >> XH[i].F >> XH[i].S;
    sort(all(XH));
    vector<LL> X(N+1);
    vector<LL> H(N+1);
    rep(i,N){
        X[i+1] = XH[i].F;
        H[i+1] = XH[i].S;
    }
    vector<int> bom(N+1);
    BIT<LL> q(N+1);
    // q.add(a,w);
    // q.add(b+1,-w);

    rep(i,N){
        int lb = 0; int ub = N+1;
        while(ub - lb > 1){
            int mid = (ub+lb)/2;
            if(X[i+1] + 2*D >= X[N]){
                lb = N;
                break;
            }
            if(X[i+1] + 2*D < X[mid])ub = mid;    // lb,ubは適宜変更
            else lb = mid;
        }
        bom[i+1] = lb; // lb まで被爆
    }

    LL ans = 0;

    for(int i = 1;i <= N;++i){
        if(H[i] + q.sum(i) <= 0)continue;
        LL tmp = 0;
        int num = 0;
        num = (H[i] + q.sum(i) +A-1)/A;
        ans += num;
        tmp = num * A;
        q.add(i,-tmp);
        q.add(bom[i]+1,tmp);
    }

    cout << ans << endl;



}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vi solve(int n, int a, int b) {
  if (n == 1) {
    assert(a != b);
    return {a, b};
  }
  assert(a >= 0 && b >= 0 && max(a, b) < (1 << n));
  if (a % 2 == b % 2) {
    vi v1 = solve(n-1, a / 2, b / 2);
    vi v2 = solve(n-1, a / 2, v1[1]);
    for (int& x : v2) x = 2 * x + (1 - a % 2);
    v2.insert(v2.begin(), a);
    for (int i = 1; i < v1.size(); ++i) {
      v2.push_back(v1[i] * 2 + a % 2);
    }
    return v2;
  } else {
    int neig = (a / 2) ^ 1;
    vi v1 = solve(n - 1, a / 2, neig);
    vi v2 = solve(n - 1, neig, b / 2);
    for (int& x : v1) x = 2 * x + a % 2;
    for (int x : v2) v1.push_back(x * 2 + b % 2);
    return v1;
  }
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (__builtin_popcount(a ^ b) % 2 == 0) {
    cout << "NO\n"; return 0;
  }
  cout << "YES\n";
  vi v = solve(n, a, b);
  for (int i = 0; i + 1 < v.size(); ++i) {
    assert(__builtin_popcount(v[i] ^ v[i + 1]) == 1);
  }
  for (int x : v) {
    cout << x << ' ';
  }
  cout << endl;
  return 0;
}


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

int main(void){
    string st1,st2;
    int n;
    cin>>n;
    int sc1=0,sc2=0;
    for(int i=0;i<n;i++){
        cin>>st1>>st2;
        if(st1>st2)sc1+=3;
        else if(st1<st2)sc2+=3;
        else {
            sc1++;
            sc2++;
        }
    }
    cout<<sc1<<" "<<sc2<<endl;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){

  ll i,j,n,m,a[100010],ans=1;
  ll f[100010];

  f[0]=1;
  f[1]=1;
  for(i=2;i<100010;i++){
    f[i]=f[i-1]+f[i-2];
    f[i]%=1000000007;
  }

  cin>>n>>m;

  a[0]=-1;
  a[m+1]=n+1;
  for(i=1;i<m+1;i++){
    cin>>a[i];
    if(a[i]-a[i-1]==1){
      cout<<0<<endl;
      return 0;
    }
  }

  for(i=0;i<m+1;i++){
    ans*=f[(a[i+1]-a[i]-2)];
    ans%=1000000007;
  }

  cout<<ans<<endl;

	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> h(n);
  for (ll &x : h) {
    cin >> x;
  }
  vector<set<ll>> g(n);

  for (long i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g.at(a).insert(b);
    g.at(b).insert(a);
  }

  ll ans = 0;
  for (long i = 0; i < n; i++) {
    bool ok = true;
    for (auto x : g.at(i)) {
      if (h.at(i) <= h.at(x)) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 17956
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    int D, X;
    std::cin >> D >> X;

    std::vector<int> A(N);
    for (int& a : A) {
        std::cin >> a;
    }

    int chocolates = X;
    for (int a : A) {
        chocolates += (D - 1) / a + 1;
    }
    std::cout << chocolates << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <queue>
const int N=2e5+5;
int n,m;
struct data{
	int l,r;
	friend bool operator < (const data &a,const data &b){
		return a.l==b.l?a.r<b.r:a.l>b.l;
	}
};

namespace utils{
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
}
using namespace utils;

int main(){
	std::priority_queue <int> r_que;
	std::priority_queue <data> d_que;
	n=nxi(),m=nxi();
	for(int i=1; i<=n; ++i){
		data x;
		x.l=nxi(),x.r=nxi();
		d_que.push(x);
	}
	for(int i=1; i<=m; ++i){
		while(!d_que.empty()&&d_que.top().l<i){
			r_que.push(-d_que.top().r);
			d_que.pop();
		}
		if(!d_que.empty()) d_que.pop();
		else if(!r_que.empty()&&-r_que.top()<=i) r_que.pop();
	}
	printf("%d\n",(int)(d_que.size()+r_que.size()));
	return 0;
}


Measured memory_bytes: 3568
N, K = map(int, input().split())
A = list(map(int, input().split()))

s = [-1] * N
i = 0
cur = 0
m = 0
while True:
    if s[cur] != -1 and m != 1:
        m = i - s[cur]
        K = i + (K - i) % m
    else:
        s[cur] = i
    if i == K:
        print(cur+1)
        exit()
    i += 1
    cur = A[cur] - 1


Measured memory_bytes: 32296
import math
n=int(input())
h=list(map(int,input().split()))
if n==1:
  print(0)
  exit()
maxcnt=0
cnt=0
for i in range(n-1):
  if h[i]>=h[i+1]:
    cnt+=1
  else:
    if maxcnt<cnt:
      maxcnt=cnt
    cnt=0
print(cnt if maxcnt<cnt else maxcnt)

Measured memory_bytes: 15020
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

W = H = 0
L = sorted(list(Counter(A).items()),key=lambda x:(-x[0]))
for k,v in L:
    if W == 0:
        if v >= 4:
            W = H = k
            break
        elif v >= 2:
            W = k
    elif H == 0:
        if v >= 2:
            H = k
            break

print(H*W)

Measured memory_bytes: 30056
import java.util.*;
import java.io.*;

public class Main {
	
	static int N;

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] NM = br.readLine().split(" ") ; 
		int N = Integer.parseInt(NM[0]);
		int M = Integer.parseInt(NM[1]);
		
		String[][]A = new String[N][N]; 
		String[][]B = new String[M][M]; 
		
		for(int a=0; a<N; a++) {
			A[a] = br.readLine().split("") ; 
		}
		for(int b=0; b<M; b++) {
			B[b] = br.readLine().split("") ; 
		}
		
		String ans = "No";
		//左上の点を移動させる
		for (int i=0; i<=N-M; i++) {
			for(int j=0; j<=N-M; j++) {
				boolean AequalB = true;
				for(int k=0; k<M; k++) {
					for(int l=0; l<M; l++) {
						if(!A[i+k][j+l].contentEquals(B[k][l])) {
							AequalB = false;
						}
					}
				}
				if(AequalB) {
					ans = "Yes";
				}
			}
		}
		
			
		System.out.println(ans);	
		
	}
}

Measured memory_bytes: 34312
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int p[100100];

int solve() {
    int i = 0, res = 0;
    while (i < n) {
        if (p[i] == i) {
            swap(p[i], p[i+1]);
            res++;
        }
        i++;
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 640
from collections import deque
n,q=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)

s=[0]*n
for _ in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x

que=deque([0])
f=[0]*n
f[0]=1
while que:
  v=que.popleft()
  c=s[v]
  for w in g[v]:
    if f[w]:
      continue
    f[w]=1
    s[w]+=c
    que.append(w)
  
print(*s)

Measured memory_bytes: 56080
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

tank = list(itertools.permutations(range(1,n+1)))

for i,e in enumerate(tank):
    if p == e:
        a = i
    if q == e:
        b = i
    #print(e)3
print(abs(a-b))

Measured memory_bytes: 45168
using System;
using System.Collections.Generic;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int a = cin.nextInt();
            int b = cin.nextInt();

            if (a >= 10 || b >= 10)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(a * b);
            }
        }

    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    int c[h][w];
    int i,j, ii, jj;
    int sum=0;
    char inp;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin >> inp;
            c[i][j] = (inp=='#') ? 1 : 0;
            sum += c[i][j];
        }
    }
    int p;
    int res = 0;

    for(i=0;i<(1<<h);i++){
        for(j=0;j<(1<<w);j++){
            p=0;
            for(ii=0;ii<h;ii++){
                if((1<<ii)&i)continue;
                for(jj=0;jj<w;jj++){
                    if((1<<jj)&j)continue;
                    if(c[ii][jj]==1)p++;
                }
            }
            if(p==k){
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int a;
    cin >> a;
    string s;
    cin >> s;

    if( a >= 3200 ) cout << s << endl;
    else cout << "red" << endl;

}


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

	using namespace std;

	int main(){
		int n = 0, a = 0, b = 0, c = 0, d[10001] = {}, cal,pre,cur, i;
		cin >> n >> a >> b>> c;

		for (i = 0; i < n; i++){
			cin >> d[i];
		}
		sort(d, d + n, greater<int>());
		cal = c;
		pre = cal / a;
		for (i = 0; i < n; i++){
			
			cal += d[i] ;
			cur = cal / (b*(i + 1)+a);
			if (pre > cur) {
				break;
			}
			pre = cur;
		}
		cout << pre << endl;
		return 0;
	}
	

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

using namespace std;

const double pi = 3.1415926535897;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int r;
  cin >> r;
  cout << 2.0 * r * pi << endl;
  return 0;
}

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

inline int digit_sum(int d)
{
  int s = 0;
  while (d > 0) {
    s += (d % 10);
    d /= 10;
  }

  return s;
}

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

  int n = 10000000;
  for (int a = 1; a < N; a++) {
    int b = N - a;
    int t = digit_sum(a) + digit_sum(b);
    if (t < n) n = t;
  }

  cout << n << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Stack;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Stack<Integer> stack = new Stack<Integer>();
        while (in.hasNext()) {
            if (in.hasNextInt())
                stack.push(in.nextInt());
            else {
                int total = stack.pop();
                switch(in.next()) {
                    case "+": total += stack.pop();
                        break;
                    case "-": total = stack.pop() - total;
                        break;
                    case "*": total *= stack.pop();
                        break;
                }
                stack.push(total);
            }
        }
    System.out.println(stack.pop());
    }
}



Measured memory_bytes: 26828
# include <iostream>
# include <cstdio>
# include <algorithm>
# include <queue>
using namespace std;
typedef long long LL;
const int maxn = 3e5+80;
const LL INF = 0x3f3f3f3f3f3f3f3f;
struct node
{
    LL x, y, z;
}a[maxn];
bool cmp1(node na, node nb){return na.x-na.y > nb.x - nb.y;}
struct cmp2 {bool operator ()(node na, node nb) {return na.x-na.z>nb.x-nb.z;}};
struct cmp3 {bool operator ()(node na, node nb) {return na.y-na.z>nb.y-nb.z;}};
priority_queue<node, vector<node>, cmp2>p;
priority_queue<node, vector<node>, cmp3>q;
LL l[maxn], r[maxn];
int main()
{
    int x, y, z;
    scanf("%d%d%d",&x,&y,&z);
    for(int i=1; i<=x+y+z; ++i) scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].z);
    sort(a+1, a+1+x+y+z, cmp1);
    while(!q.empty()) q.pop();
    while(!p.empty()) p.pop();
    LL sum = 0;
    for(int i=1; i<=x; ++i)
    {
        sum += (LL)a[i].x;
        p.push(a[i]);
    }
    l[x] = sum;
    for(int i=x+1; i<=x+z; ++i)
    {
        if(p.empty() || a[i].x - a[i].z < p.top().x - p.top().z)
            sum += a[i].z;
        else
        {
            sum = sum - p.top().x + p.top().z + a[i].x;
            p.pop();
            p.push(a[i]);
        }
        l[i] = sum;
    }
    sum = 0;
    for(int i=x+y+z; i>x+z; --i)
    {
        q.push(a[i]);
        sum += (LL)a[i].y;
    }
    r[x+z] = sum;
    for(int i=x+z; i>x; --i)
    {
        if(q.empty() || a[i].y - a[i].z < q.top().y - q.top().z)
            sum += a[i].z;
        else
        {
            sum = sum - q.top().y + q.top().z + a[i].y;
            q.pop();
            q.push(a[i]);
        }
        r[i-1] = sum;
    }
    LL ans = 0;
    for(int i=x; i<=x+z; ++i) ans = max(ans, l[i]+r[i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12144
N = int(input())
A = [int(x) for x in input().split(' ')]

qnt_cash = 1000
qnt_stock = 0

def buy(cash, stock, price):
  stock += cash // price 
  cash = cash % price
  return cash, stock

def sell(cash, stock, price):
  cash += stock * price
  stock = 0
  return cash, stock


for i in range(N - 1):
  if A[i] < A[i + 1]:
    qnt_cash, qnt_stock = buy(qnt_cash, qnt_stock, A[i])
  elif A[i] > A[i + 1]:
    qnt_cash, qnt_stock = sell(qnt_cash, qnt_stock, A[i])

if qnt_stock > 0:
  qnt_cash, qnt_stock = sell(qnt_cash, qnt_stock, A[N - 1])

print(qnt_cash)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define eps 1e-9
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> fst;

const int N=2e5+7;
int n,k,ar[N];

int check(int v)
{
	int s=0;
	for (int i=0;i<n;i++) s+=(ar[i]-1)/v;
	return s;
}

int binsc(int l,int r)
{
	while(l<r)
	{
		int mid=(l+r)/2;
		if (check(mid)<=k) r=mid;
		else l=mid+1;
	}
	return l;
}

void solve()
{
	cin>>n>>k;
	fin(ar,0,n);
	cout<<binsc(1,1e9);
}

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

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

int main() {
  int H, W;
  for (;;) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      return 0;
    string row = string(W, '#');
    cout << row << endl;
    for (int h = 1; h < H - 1; ++h)
      cout << '#' << string(W - 2, '.') << '#' << endl;
    cout << row << endl;
    cout << endl;
  }
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int i,j,ans=0,n;
	cin >> n;
	for(j=1;j<=n;j++) // Optimisation : changed from finding to divisors 
	{				  // to finding multiples
		for(i=j;i<=n;i+=j) // Log (n) complexity , diverging sequence
			ans+=i;
	}
	cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int ans = 0;
        for(int i = 2;i*i<=n;i++) {
            int x = 0;
            int prev = 0;
            while(n && n%i == 0) {
                n /= i;
                x++;
                if(x > prev) {
                    ans++;
                    prev = x;
                    x = 0;
                }
            }
        }
        if(n>1) ans++;
        cout<<ans;

    }
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 1e10
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll x,y;
	cin>>x>>y;
	if(y%2){
		cout<<"No";
		return 0;
	}
	bool flag=1;
	if(y<2*x||y>4*x){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
}

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

typedef int Weight;
const int INF = 1e9;

struct Edge {
  int src,dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u, vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  for(Edges::const_iterator e = g[u].begin(); e != g[u].end(); ++e)
    if (!visited[e->dst]) {
      visited[e->dst] = true;
      if (augment(g, matchTo[e->dst], matchTo, visited)) {
	matchTo[e->src] = e->dst;
	matchTo[e->dst] = e->src;
	return true;
      }
    }
  return false;
}

int bipartiteMatching(const Graph& g, int L) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  for(int u=0; u<L; ++u) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }

  return match;
}

typedef pair<int,int> P;

inline double dist(P &a, P &b) {
    return sqrt((a.first-b.first)*(a.first-b.first)
                + (a.second-b.second)*(a.second-b.second));
}

inline void add_edge(Graph &g,int from,int to) {
    g[from].push_back(Edge(from,to,1));
}

int main() {
    int n,m,x,y,v;
    while(cin>>n>>m, n|m) {
        vector<P> bases,troops;
        vector<int> speed;
        for(int i=0; i<n; ++i) {
            cin>>x>>y>>v;
            troops.push_back(P(x,y));
            speed.push_back(v);
        }

        for(int i=0; i<m; ++i) {
            cin>>x>>y;
            bases.push_back(P(x,y));
        }

        double lo = 0.0,hi = 1e9;
        for(int i=0; i<60; ++i) {
            double mid = (lo+hi)/2;

            Graph g(n+m);
            for(int j=0; j<n; ++j) {
                for(int k=0; k<m; ++k) {
                    double d = dist(troops[j],bases[k]);
                    if(d < mid * speed[j]) add_edge(g,j,k+n);
                }
            }

            int match = bipartiteMatching(g,n);
            if(match == m) hi = mid;
            else lo = mid;
        }

        printf("%.8f\n", lo);
    }
}

Measured memory_bytes: 1108
#include <stdio.h>

int main(void)
{
	int n,m;
	scanf("%d",&n);
	for(m=0;m<n;m++)
	{
		int a[10],b=0,c=0,l,ans=1;
		for(l=0;l<10;l++)
		{
			scanf("%d",&a[l]);
		}
		for(l=0;l<10;l++)
		{
			if(a[l]>b)
			{
				b=a[l];
			}
			else if(a[l]>c)
			{
				c=a[l];
			}
			else
			{
				ans=0;
				break;
			}
		}
		if(ans==0)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    long long ans(1);
    if(abs(n-m)<=1){
        for(int i(1);i<=n;i++){
            ans *= i;
            if(ans>=1000000007)ans %= 1000000007;
        }
        for(int i(1);i<=m;i++){
            ans *= i;
            if(ans>=1000000007)ans %= 1000000007;
        }
        if(n==m){
            ans *= 2;
            if(ans>=1000000007)ans %= 1000000007;
        }
        cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    w,h,n = LI()
    aa = [LI() for _ in range(n)]
    q = []
    r = [[None] * w for _ in range(h)]
    for x,y,z in aa:
        r[y-1][x-1] = z
        heapq.heappush(q, (-z, (y-1,x-1)))

    v = collections.defaultdict(bool)
    while len(q):
        k, u = heapq.heappop(q)
        if v[u]:
            continue
        v[u] = True
        y = u[0]
        x = u[1]

        for dy,dx in dd:
            uy = y+dy
            ux = x+dx
            if uy < 0 or uy >= h or ux < 0 or ux >= w:
                continue
            uv = (uy,ux)
            if v[uv]:
                continue
            vd = -k - 1
            if r[uy][ux] is None:
                r[uy][ux] = vd
                heapq.heappush(q, (-vd, uv))
            else:
                if abs(r[uy][ux] + k) > 1:
                    return 'No'

    return sum(sum(_) for _ in r)


print(main())





Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void){
    ll n, k;
    cin >> n >> k;

    COMinit();

    int upper = min(n-1, k);

    ll ans = 0;
    for(int i=0; i<=upper; i++){
        ans += COM(n, i) * COM(n-1, n-i-1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12160
//55
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<array>
#include<cstdlib>

using namespace std;
typedef pair<int,int> PII;
typedef array<PII,6> NARRAY;

NARRAY neighbor(PII p){
  static int dx[]={0,1,1,0,-1,-1};
  static int dy[]={-1,-1,0,1,1,0};
  NARRAY r;
  for(int i=0;i<6;i++){
    r[i]=PII(p.first+dx[i],p.second+dy[i]);
  }
  return r;
}

bool check(const vector<PII> &v,int d){
  //  auto nn=neighbor(v[d]);
  int nb=0;
  for(int i=0;i<d;i++){
    if(v[i]==v[d])return false;
    int yd=v[i].first-v[d].first;
    int xd=v[i].second-v[d].second;
    nb|=(max(abs(xd),abs(yd))==1&&xd*yd!=1)<<i;
    //    nb|=(find(begin(nn),end(nn),v[i])!=end(nn))<<i;
  }
  return nb==1<<d>>1;
}  

void dfs(vector<PII> v,int d,bool m,set<vector<PII> > &r){
  if(d==v.size()){
    r.insert(v);
    // for(auto e:v){
    //   cout<<'('<<e.first<<','<<e.second<<')'<<' ';
    // }
    // cout<<endl;
  }else{
    if(check(v,d)){
      dfs(v,d+1,false,r);
    }
    if(!m){
      auto n=neighbor(v[d]);
      for(auto e:n){
	vector<PII> nv=v;
	nv[d]=e;
	if(check(nv,d)){
	  dfs(nv,d+1,true,r);
	}
      }
    }
  }
}

int main(){
  for(int n;cin>>n,n;){
    vector<PII> iv;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      iv.emplace_back(x,y);
    }
    int k;
    cin>>k;
    int u[100],v[100];
    for(int i=0;i<k;i++){
      cin>>u[i]>>v[i];
    }
    int X,Y;
    cin>>X>>Y;
    set<vector<PII> > vs[22];
    vs[0].insert(iv);
    set<vector<PII> > s;
    for(int i=0;i<=20;i++){
      for(auto e:vs[i]){
	if(e[0].first==X&&e[0].second==Y){
	  cout<<i<<endl;
	  goto next;
	}
	if(!s.insert(e).second)continue;
	set<vector<PII> > res;
	dfs(e,0,false,res);
	for(auto f:res){
	  bool on_rock=false;
	  for(auto g:f){
	    for(int j=0;j<k;j++){
	      on_rock|=g.first==u[j]&&g.second==v[j];
	    }
	  }
	  if(!on_rock){
	    vs[i+1].insert(f);
	  }
	}
      }
      vs[i].clear();
    }
  next:
    ;
  }
}

Measured memory_bytes: 47664
/*************************************\
*           بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ             *
*             رَّبِّ زِدْنِى عِلْمًا                *
*   Mir Abdullah yousuf, KUET_EEE14   *
\*************************************/
#include <bits/stdc++.h>
#define LL              long long
#define PI              acos(-1.0)
#define PII             pair<int,int>
#define xx              first
#define yy              second
#define MS(a,b)         memset(a, b, sizeof (a))
#define MP(a,b)         make_pair(a, b)
#define pb              push_back
#define sf(a)           scanf("%d", &a)
#define READ()          freopen("input.txt", "r", stdin)
#define WRITE()         freopen("output.txt", "w", stdout)
#define GCD(a, b)       __gcd(a, b)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define sqr(a)          (a) * (a)
#define MOD             100000007
#define MAX             1000005
#define inf             2147483647
using namespace std;

///***********-8-direction*************/
//int fx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//int fy[] = {0, 0, 1, -1, 1, 1, -1, -1};

///***********-4-direction*************/
//int fx[] = {1, -1, 0, 0};
//int fy[] = {0, 0, 1, -1};


int main()
{
    int n, m; cin >> n >> m;

    vector< int > v[n + 1];

    while (m--) {
        int a, b; cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }

    for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());

    int len = v[1].size();
    for (int i = 0; i < len; i++) {
        int x = v[1][i];
        if (binary_search(v[x].begin(), v[x].end(), n)) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12016
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a - b >= 0){
			System.out.println("delicious");
		} else if(b - a <= x){
			System.out.println("safe");
		} else{
			System.out.println("dangerous");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(( (abs(a-b)<=d) && (abs(b-c)<=d) )|| (abs(a-c)<=d)){
		puts("Yes");
		exit(0);
	}
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define INT_MAX 2147483647

struct Process{
  std::string name;
  int time;
};

class Queue {
private:
  Process Table[100005];
  int head;
  int top;
public:
  Queue(){ head=0; top=0; };
  void Enqueue(Process P);
  Process Dequeue();
  bool isEmpty(){ return head==top; };
  void show();
};

void Queue::show(){
  std::cout << "head : " << head << '\n';
  std::cout << "top : " << top  << '\n';
};

void Queue::Enqueue(Process P){ 
  Table[top] = P; 
  top = (top+1)%100005; 
};

Process Queue::Dequeue(){ 
  Process p = Table[head]; 
  head = (head+1)%100005; 
  return p; 
};

int main(int argc, char const *argv[]) {
  int n;
  int q;
  int cumtime=0;
  Process P;
  Queue queue = Queue();
  std::cin >> n >> q;

  for (size_t i = 0; i < n; i++) {
    std::cin >> P.name;
    std::cin >> P.time;
    queue.Enqueue(P);
  }

  while (!queue.isEmpty()) {
    P = queue.Dequeue();
    P.time -= q;
    if (P.time>0) {
      queue.Enqueue(P);
      cumtime += q;
    } else {
      cumtime += (q + P.time);
      std::cout << P.name << ' ' << cumtime << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 7132
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
 
using namespace std;
  
int main() {	
	int n,m;
	cin >> n>>m;
	long long x, y, z;
	vector<vector<long long>> abc(8);
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> z;
		for (int j = 0; j < 8; j++) {
			abc[j].push_back(x*((j % 2) * 2 - 1) + y * (((j / 2) % 2) * 2 - 1) + z * ((j / 4) * 2 - 1));
		}
	}
	vector<long long> ans;
	for (auto& d:abc){
		sort(d.rbegin(), d.rend());
		ans.push_back(accumulate(d.begin(), d.begin() + m,0LL));
	}
	cout << *max_element(ans.begin(), ans.end()) << endl;;

	return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        s: [String; n],
    }
    let mut cnt = HashMap::new();
    for s_ in s {
        *cnt.entry(s_.chars().nth(0).unwrap()).or_insert(0) += 1;
    }

    let cnt_: Vec<u64> = "MARCH"
        .chars()
        .map(|c| *cnt.entry(c).or_insert(0))
        .collect();

    let res: u64 = (0..1 << 5)
        .filter(|b| (*b as u32).count_ones() == 3)
        .map(|b| -> u64 {
            (0..5)
                .filter(|i| b & (1 << i) != 0)
                .map(|i| cnt_[i])
                .product()
        }).sum();

    println!("{}", res);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    if (n == 2 || n == 0) {
        cout << 1 << endl;
    } else if (n == 1) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 3212
from bisect import bisect_left


N = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(2, N):
    c = L[i]
    for j in range(i):
        b = L[j]
        a_min_idx = bisect_left(L, c - b + 1, 0, j)
        ans += j - a_min_idx
print(ans)


Measured memory_bytes: 3316
(* O(h w) *)
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let b = ref 0
let sss = Array.init h @@ fun _ ->
  Array.init w @@ fun _ -> Scanf.scanf " %c" @@ fun c -> if c = '#' then incr b; c
let ds = Array.make_matrix h w @@ -1
let _ =
  let q = Queue.create () in
  ds.(0).(0) <- 0;
  Queue.push (0, 0) q;
  while not @@ Queue.is_empty q do
    let y0, x0 = Queue.pop q in
    let f (dy, dx) =
      let y, x = y0 + dy, x0 + dx in
      if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) = -1 && sss.(y).(x) <> '#' then
        (ds.(y).(x) <- ds.(y0).(x0) + 1;
        Queue.push (y, x) q) in
    List.iter f [0, -1; -1, 0; 0, 1; 1, 0]
  done;
  let g = ds.(h - 1).(w - 1) in
  Printf.printf "%d\n" @@ if g = -1 then -1 else h * w - !b - g - 1

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int n;
  std::cin >> n;
  VEC(int,a,n);
  sort(all(a));
  int cou=1,b=a[0];
  std::vector<pair<int,int>> dum;
  if(n==1){
    if(a[0]==1)std::cout << 0 << std::endl;
    else std::cout << 1 << std::endl;
    exit(0);
  }
  rrep(i,1,n){
    if(a[i]==a[i-1]){
      cou++;
    }
    else{
      
      pair<int,int> d;
      d.fi=a[i-1];d.se=cou;
      dum.pb(d);
      cou=1;
    }
  }
  dum.pb(make_pair(a[n-1],cou));
  int ans=0;
  rep(i,dum.size()){
   // std::cout << dum[i].fi << std::endl;
    if(dum[i].fi<=dum[i].se){
      
      ans+=dum[i].se-dum[i].fi;
    }
    else ans+=dum[i].se;
  }
  std::cout << ans << std::endl;
  
}

Measured memory_bytes: 1784
#include <iostream>

using namespace std;

int main (void) {
    int N;
    cin >> N;
    int b, a;
    b = N / 10;
    a = N % 10;
    if ( a == 9 || b == 9 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, t, a[100000];

int main() {
	scanf("%d%d", &n, &t);
	inc(i, n) { scanf("%d", &a[i]); }
	
	int mi = 1000000001, ma = 0, ans = 0;
	inc(i, n) {
		if(mi < a[i] && ma <= a[i] - mi) {
			if(ma == a[i] - mi) { ans++; }
			if(ma <  a[i] - mi) { ans = 1; ma = a[i] - mi; }
		}
		setmin(mi, a[i]);
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,ans=1;

main(){
    cin>>n;
    int used[n]={};
    rep(i,n){
        int a;
        cin>>a;
        used[a]++;
        if(used[a]>2||used[0]>1)ans=0;
    }
    rep(i,n/2){
        ans*=2;
        ans%=MOD;
    }
    dans;

}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 61976