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

int main() {
  int N, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
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();
    int t = a;
    int x = c;
    a = b;
    b = t;
    c = a;
    a = x;
    System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 23764
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
#    t, a, b = map(int, input().split())
    t = 1
    
    for _ in range(1, t+1):
    #    print("Case #{}: ".format(_), end = '')
        
        a, b = map(int, input().split())
        print(a*b)
        
        
main()

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

#define ll int64_t
using namespace std;
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll N=1000005;

ll primes[N];
void sieve()
{
  
  
  for(ll i=2;i<=N;i++)
  {
    if(primes[i]==-1)
    {
        for(ll j=i;j<=N;j+=i) primes[j]=i;
        
     }
   }

}


int main(){
    IOS
    fo(i,1000005) primes[i]=-1;
    sieve();

    ll n;
    cin>>n;
    if(n==2) {
    	cout<<1<<endl;
    	return 0;
    }
    map<ll,ll> mp;
    ll ans=0;
    FOR(i,2,sqrt(n)){
    	if(primes[i]==i&&n%i==0){
    		while(n%i==0){
    			n=n/i;
    			mp[i]++;
    		}
    	}
    }
    if(n>1) mp[n]=1;
    for(auto pp:mp){
    	ll tt=1;
    	ll cnt=1;
    	//dbg2(pp.first,pp.second);
    	while(tt<pp.second){
    		cnt++;
    		tt+=cnt;
    	}
    	ans+=cnt;
    	if(tt>pp.second) ans--;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 11488
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, C;
int L[6];
LL dp[311][1<<5][311];
int idx[6];

void MAIN() {
    scanf("%d%d", &N, &C);
    REP (i, N) scanf("%d", L+i);
    sort(L, L+N);

    int P2 = 1<<(N-1);
    REP (i, N-1) idx[i] = i;
    LL sum = 0;
    do {
	memset(dp, 0, sizeof dp);
	dp[0][0][L[N-1]*N] = 1;
	REP (i, C*N+1) REP (s, P2) REP (j, C*N+1) if (dp[i][s][j]) {
	    if (i < j) {
		dp[i+1][s][j] += dp[i][s][j];
		int k = i % N;
		if (k != 0) {
		    k--;
		    if (~s>>k&1) {
			int len = L[idx[k]];
			dp[i+1][s|(1<<k)][min(C*N, max(j, i+len*N))] += dp[i][s][j];
		    }
		}
	    }
	}

	LL val = dp[C*N][P2-1][C*N];
	sum += val;
    } while (next_permutation(idx, idx+N-1));

    double ans = sum;
    ans /= pow(C, N-1);
    REP (i, N-1) ans /= i+1;
    printf("%.20f\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

namespace Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int taro = 0;
            int hanako = 0;

            for (int i = 0; i < num; ++i)
            {
                var input = Console.ReadLine().Split(' ');
                int result = input[0].CompareTo(input[1]);
                if (result == 0)
                {
                    ++taro;
                    ++hanako;
                }
                else if (result > 0)
                {
                    taro += 3;
                }
                else
                {
                    hanako += 3;
                }
            }
            Console.WriteLine("{0} {1}", taro, hanako);
        }
    }
}


Measured memory_bytes: 9924
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

vector<vector<int>> G;
vector<int> res;

vector<int> dist;


int main() {
	int N, M;

	cin >> N >> M;

	G.resize(N+1);
	res.assign(N+1, -1);
	dist.assign(N+1, -1);

	rep(i, M){
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<int> que;

	dist[1] = 0;
	que.push(1);

	while (!que.empty()) {
        int v = que.front();
        que.pop();


        rep(i, G[v].size()){
			int nv = G[v][i];
            if(dist[nv] != -1){
				continue;
			}

            dist[nv] = dist[v] + 1;
            que.push(nv);
			res[nv] = v;
        }
    }

	bool flag = true;
	for(int i=2; i<N+1; i++){
		if(res[i] == -1){
			flag = false;
		}
	}

	if(!flag){
		cout << "No";
	}else{
		cout << "Yes" << endl;

		for(int i=2; i<=N; i++){
			cout << res[i] << endl;
		}
	}

		
	return 0;
}

Measured memory_bytes: 10640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;
int a[100010];
int main(void)
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
        a[i]--;
    }

    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
        if (i == a[i])
        {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int s=1<<n;
  vector<Int> a(s);
  for(Int i=0;i<s;i++) cin>>a[i];

  priority_queue<Int> pq(a.begin(),a.end());
  Int r=0;
  r+=pq.top();pq.pop();
  r+=pq.top();pq.pop();
  
  Int ans=0;
  for(Int b=1;b<s;b++){
    if(ans<r){
      Int p=-1,q=-1;
      for(Int x=b;;x=(x-1)&b){
	if(a[x]>=p){
	  chmax(q,p);
	  p=a[x];
	}else chmax(q,a[x]);
	if(x==0) break;
      }
      //cout<<p<<" "<<q<<endl;
      chmax(ans,p+q);
    }
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 7168
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int N = 1e7;
vector<ll> spf(N + 1);
void fast_sieve() {
  for (ll i = 0; i <= N; i++) spf[i] = i;

  for (ll i = 4; i <= N; i += 2) {
    spf[i] = 2;
  }
  ll i;
  for (i = 3; i <= N; i++) {
    if (spf[i] == i) {
      for (ll j = i * i; j <= N; j += 2 * i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;
  fast_sieve();
  while (testcases--) {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      int j = i;
      int t;
      int pq = 1;
      while (j != 1) {
        t = spf[j];
        int cnt = 0;
        while (j % t == 0) {
          j = j / t;
          cnt++;
        }
        pq = pq * (cnt + 1);
      }
      ans = ans + pq * i;
    }
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 81216
#include<stdio.h>
#define size 100000

int main()
{
    int ar[size];
    int h,n,s=0,i,j,k=0,count=0;
    scanf("%d",&h);
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&ar[i]);
    for(i=0;i<n;i++)
    {
        s=s+ar[i];
    }
    k=h-s;
    
    if(k<=0)
        printf("Yes\n");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 2068
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
using namespace std;

int main() {
  int a,n,b;
  int cnt = 0;
  cin >> n;
  cin >> a;
  b = n % 500;
  if(b == 0 || b <= a){
    cout << "Yes" << '\n';
  }
  else{
    cout << "No" << '\n';
  }
    return 0;
}

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

int main()
{
	long long A, B, C, K, ans = 0;

	cin >> A >> B >> C >> K;

	for (int i = 0; i < K; i++) {
		ans = max(ans, max(A, max(B, C)))*2;
	}

	ans += -max(A, max(C, B)) + A+C+B;

	cout << ans << endl;

	return 0;
}


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

int main() {
	string s;
    int i;
  	int ans = 0;
	cin >> s; 
for(i = 0;i<3;i++){
      if(s[i] == '1'){
        ans++;
      }
    }
    cout << ans << endl;
}

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

int main()
{
  string s;
  cin>>s;
  int odd0=0,even0=0,odd1=0,even1=0;
  int i=0;
  while(s[i])
  {
    if(i%2!=0)
    {
      if(s[i]=='0')
        even0++;
      else
        even1++;
    }
    else
    {
      if(s[i]=='0')
        odd0++;
      else
        odd1++;
    }
  i++;
  }
  int n=s.length();
  int oddpos=n-n/2;
  int change1=oddpos-odd1+n/2-even0;
  int change2=oddpos-odd0+n/2-even1;
  int min=change1<change2?change1:change2;
  cout<<min;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d,e,f;
	cin >> a >> b >> c;
	d = a+b;
	e = b+c;
	f = c+a;
	if(d==c || e==a || f==b){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;
 
long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}
 
ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  while (q-- >0) {
    int n,m,k;
    cin >> n >> m >> k;
    int a[n];
    int b[m];

    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    ll cur = 0ll;
    int i = 0;
    int bestans = 0;
    for (; i < n;) {
      if (cur + a[i] <= k) { 
        cur += a[i]; 
        ++i;
        ++bestans;
      } else {
       break; 
      }
    }
    //cout << " cur " << cur << endl;
    int best = 0;
    int j = 0;
    for (; j < m;) {
      if (cur + b[j] <= k) { 
        cur += b[j];
        ++bestans;
        ++j;
      } else {
        break; 
      }
    }
    //cout << " cur " << cur << endl;
    best = bestans;
    //cout << "cur best " << best << endl;
    while (i >= 0 && j < m) {
      if (i > 0) { 
        --i;
        cur -= a[i];
        --bestans;
      }  else {
        --i; 
      }
      while (j < m && cur + b[j] <= k) {
        cur += b[j]; 
        ++j;
        ++bestans;
      }
      best = max(best, bestans);
    }
    cout << best << "\n";



  }

 
  return 0;
}


Measured memory_bytes: 5220
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    var cnt = 0
    var arr = Array(n, {i -> sc.nextInt()})
    arr.sort()
    arr.reverse()
    for (i in 1..k) {
        cnt += arr[i-1]
    }
    println(cnt)
}




Measured memory_bytes: 35784
/*input
4 7


*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const ll mod = 1000000007;
const int N = 3e5, M = N;
const int MAX = 1e5;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x = n/k;
    if(k>n)cout<<min(k-n,n)<<endl;
    else
    cout<<min(n-x*k,(x+1)*k-n)<<endl;
    return 0;
}		

Measured memory_bytes: 256
function Main(input){
  inputs=input.split("\n");
  bos=inputs[1].split(" ").map(x=>parseInt(x)).sort((a,b)=>a-b);

  var num=0,a,b,c,l=inputs[0];
  for(a=0;a<l;++a){
    for(b=a+1;b<l;++b){
      for(c=l-1;c>b;--c){
        if(bos[c]<bos[a]+bos[b]){
          num+=c-b;break;
        }
      }
    }
  }

  console.log(num);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    map<int,int> ma;
    REP(i,n){
        int t;
        cin>>t;
        ma[t]++;
    }
    int ans=0;
    for(auto itr:ma){
        if(itr.se>=itr.fi){
            ans+=itr.se-itr.fi;
        }else{
            ans+=itr.se;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<vector>
#include<list>
#include<deque>
#include<functional>
#include<sstream>
#include<numeric>
#include<complex>

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DUMP(x) if(DBG){cerr << #x << " = " << (x) << endl;}
#define CLR(a) memset((a), 0 ,sizeof(a))
#define rep(i,n) for(int i=0;i<(int)n;i++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define EPS 1e-8
#define DBG 0

using namespace std;

inline int to_int(string s) {int v; istringstream istr(s);istr>>v;return v;}
template<class T> inline string to_string(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;

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

int main()
{
    ll n, f;
    vector<ll> cap(5), m(5);

    cin >> n;
    rep(i, 5) cin >> cap[i];

    f = cap[0];
    rep(i, 5) f = min(f, cap[i]);

    ll g = ((n / f) * f + (n%f==0?0:f)) / f;
    cout << (g - 1) + 5 << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = input()
a = [int(s) for s in input().split()]
r = 0

def checkNum(l, c):
    for i in l:
        if (i % 2 != 0):
            return c

    c += 1
    return checkNum([j / 2 for j in l], c)

print(checkNum(a, r))

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i <N; i++) {
    cin >> a.at(i);
  }
  
  int lump=0, push=0;
  
  for (int j = 0; j < N; j++) {
    push ++;
    lump = a.at(lump) - 1;
    if (lump == 1) {
      cout << push << endl;
      break;
    }
  }
  
  if (push == N)
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B == C+D){
        cout << "Balanced";
    }
    else if(A+B > C+D){
        cout << "Left";
    }
    else{
        cout << "Right";
    }

}

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

int main()
{
  int N;
  cin >> N;
  vector<int> card(N);
  for (auto &i : card){
    cin >> i;
  }
  sort(card.begin(), card.end());
  int sum = 0;
  for (int i=0; i<N; i++){
    if (i % 2 == 0)
      sum += card.at(i);
    else
      sum -= card.at(i);
  }
  cout << max(sum, -sum);
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n){
      cin>>h[i];
    }
    int ans=1;
    FOR(i,0,n){
      FOR(j,0,i){
        if(h[i]<h[j]){
          break;
        }
        if(j==i-1){
          ans++;
        }
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    vector<int> ans;
    for(int i=0,a=1; i<10; i++,a*=2){
      if(n%2 == 1) ans.push_back(a);
      n/=2;
    }
    for(int i=0; i<ans.size(); i++){
      if(i !=0) cout <<" ";
      cout <<ans[i];
    }
    cout <<endl;
  }
  return 0;
}

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

int main()
{
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int x, y, b, p;

		cin >> x >> y >> b >> p;

		int t = (x * max(b, 5) + y * max(p, 2)) * 4 / 5;
		cout << min(x * b + y * p, t) << endl;
	}

	return 0;
}



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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

int main(){

    int n, m, k;
    cin >> n >> m >> k;

    vector<ModInt> m_1v(n);
    m_1v[n - 1] = ModInt(1, MODN2);

    for(int i = n - 2; i >= 0; i--){
        m_1v[i] = m_1v[i + 1] * ModInt(m - 1, MODN2);
    }

    vector<ModInt> combi(n);
    combi[0] = ModInt(1, MODN2);

    for(int i = 1; i <= n - 1; i++){
        combi[i] = combi[i - 1] * ModInt(n - i, MODN2) / ModInt(i, MODN2);
    }

    ModInt ans = ModInt(0, MODN2);

    for(int i = 0; i <= k; i++){
        ans = ans + ModInt(m, MODN2) * m_1v[i] * combi[i];
    }

    cout << ans.n << endl;

    return 0;
}


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

#define INFTY 1000000001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int compcount = 0;

int main()
{
  int i, n, S[500000];

  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&S[i]);
  }
  
  mergeSort(S, 0, n);
    
  for(i = 0; i < n; i++) {
    if(i) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n%d\n",compcount);

  return 0;
}

void merge(int *A, int left, int mid, int right)
{
  int i, j, k, n1, n2, *L, *R;
  n1 = mid - left;
  n2 = right - mid;

  L = (int *)malloc((n1+1) * sizeof(int));
  R = (int *)malloc((n2+1) * sizeof(int));

  for(i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;

  i = j = 0;
  for(k = left; k < right; k++) {
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
    compcount++;
  }
  
  free(L);
  free(R);
}

void mergeSort(int *A, int left, int right)
{
  int mid;
  
  if(left + 1 < right) {
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A,left, mid, right);
  }
}



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


int main()
{
	ll n,cnt=0;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<s.length()-2;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

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

char ban[8][8];
int gyo[30],ret[30],U[30],X[30];

void checkmate(int y){
  int i,j,m;
  if(y==8){
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
        printf("%c",ban[i][j]);
      }
      printf("\n");
    }
    exit(0);
  }
  if(gyo[y]==1){
    checkmate(y+1);
  }
  for(i=0;i<8;i++){
    m=7-i;
    if(ret[i]==0 && U[i+y]==0 && X[y+m]==0){
      ban[y][i]='Q';
      ret[i]=U[y+i]=X[y+m]=1;
      checkmate(y+1);
      ban[y][i]='.';
      ret[i]=U[y+i]=X[y+m]=0;
    }
  }
}

int main(){
  int k,i,j,r,c,x,m;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      ban[i][j]='.';
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    m=7-c;
    ban[r][c]='Q';
    gyo[r]=ret[c]=1;
    U[r+c]=X[r+m]=1;
  }
  checkmate(0);
  return 0;
}



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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) { cin >> p[i]; }
  int ans = 0;
  rep(i, n - 2) {
    if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ans++;
    if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
S = input()
N = len(S)
K = int(S)
num = 0


def dfs(k, a, b, c):
    global num
    if min(a, b, c) > 0 and int(k) <= K:
        num += 1
    if int(k) > K:
        return

    dfs(k + '3', 1, b, c)
    dfs(k + '5', a, 1, c)
    dfs(k + '7', a, b, 1)


dfs('3', 1, 0, 0)
dfs('5', 0, 1, 0)
dfs('7', 0, 0, 1)
print(num)


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  vector<pair<double,double>> p(N);
  rep(i,N){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end());
  double sum = 0;
  do{
    for(int i = 0;i<N-1;i++){
      double dx = p[i].first - p[i+1].first;
      double dy = p[i].second - p[i+1].second;
      sum += sqrt(dx*dx + dy*dy);
    }
  }while(next_permutation(p.begin(),p.end()));
  
  cout << fixed << setprecision(12);
  cout << sum/factorial(N) << endl;
 }

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    int N;
    cin >> N;
    vi a(N);
    for (auto &&e:a) cin >> e;
    vector<pair<int, int>> pos(N);
    REP(i, N) {
        pos[i] = make_pair(a[i], i);
    }
    sort(all(pos));

    vector<pair<int, int>> near(N);
    set<int> ls, rs;

    REP(_i, N) {
        int p = pos[_i].second;
        ls.insert(-p);
        rs.insert(p);

        near[p] = make_pair(-1, N);
        auto lit = ls.upper_bound(-p);
        if (lit != end(ls)) near[p].first = -1 * *lit;
        auto rit = rs.upper_bound(p);
        if (rit != end(rs)) near[p].second = *rit;
    }


    ll res = 0;
    REP(i, N) {
        ll l = i - near[i].first;
        ll r = near[i].second - i;
        res += l * r * a[i];
    }

    return res;
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 22912
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, h, s=0;
	cin >> n;
	int a, b;
	cin >> a >> b;
	for(int i=1;i<=n;i++)
	{
		int p=0;
		h=i;
		while(h!=0)
		{
			p+=h%10;
			h/=10;
		}
		if(p>=a&&p<=b)
		{
			s+=i;
		}
	}
	cout << s <<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main( void ) {
    int n, sum, key;
    const char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
 
    for ( scanf( "%d ", &n ); n--; putchar( '\n' ) )
        while ( ( key = getchar() ) != '\n' ) {
            if ( key == '0' )
                continue;
 
            for ( sum = 0; getchar() != '0'; sum++ ) ;
 
            putchar( ch[ key - '1' ][ sum % strlen( ch[ key - '1' ] ) ] );
        }
 
    return 0;
}

Measured memory_bytes: 572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a;
  cin>>a;
  vector<pair<double,double>> b(a);
  rep(i,a){
    cin>>b[i].first>>b[i].second;
 
  }
  sort(all(b));
  double d=0;
  do{
    rep(i,a-1)
   d+=sqrt(pow(abs(b[i].first-b[i+1].first),2)+pow(abs(b[i].second-b[i+1].second),2));
  }while(next_permutation(all(b)));
  int e=1;
  rep1(i,a){
    e*=i;
  }
  cout<<setprecision(13)<<d/e<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int i,j;
	string s1, s2;
	cin >> s1 >> s2;
	int n=s1.length(), m=s2.length();
	int dp[n+1][m+1];
	for(i=0;i<=n;i++)for(j=0;j<=m;j++){
		if(i && j){
			if(s1[i-1]==s2[j-1])dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
		else
			dp[i][j]=0;
	}
	stack<char>cugaram;
	i--;j--;
	while(i&&j){
		if(dp[i][j]==dp[i-1][j]){
			i--;
			continue;
		}
		else if(dp[i][j]==dp[i][j-1]){
			j--;
			continue;
		}
		else{
			cugaram.push(s1[i-1]);
			i--;
			j--;
		}
	}
	while(cugaram.size()){
		cout<<cugaram.top();
		cugaram.pop();
	}
	return 0;
}

Measured memory_bytes: 35456
import copy
N = int(input())
A = list(map(int, input().split()))
K = [0]*21
bin_num = format(A[0], 'b')
bin_num = bin_num[::-1]
for i in range(len(bin_num)):
    if bin_num[i] == "1":
        K[i] = 1
start = 0
end = 0
ans = 0
while(True):
    if start == N:
        break
    t = 0
    for j in range(end+1, N):
        K_ex = K.copy()
        bin_num = format(A[j], 'b')
        bin_num = bin_num[::-1]
        for l in range(len(bin_num)):
            if bin_num[l] == "1" and K[l] == 1:
                t = 1
            if bin_num[l] == "1":
                K[l] = 1
        if t == 1:
            K = K_ex.copy()
            bin_num = format(A[start], 'b')
            bin_num = bin_num[::-1]
            for p in range(len(bin_num)):
                if bin_num[p] == "1":
                    K[p] = 0
            end = j - 1
            break
    if t == 0:
        end = N - 1
    ans += end - start + 1
    start += 1
print(ans)

Measured memory_bytes: 103964
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if (i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cin_fit() cin.tie(nullptr);ios::sync_with_stdio(false)
#define rep(i, N) for(int i=0; i<(N); i++)
#define reps(i, N) for(int i=1; i<=(N); i++)
#define rrep(i, N) for(int i=(int)(N)-1; i>=0; i--)
#define rreps(i, N) for(int i=(int)(N); i>=1; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n, m;

int main() {
    cin_fit();
    cin >> n >> m;
    ll id_min = 1, id_max = n;
    rep(i, m) {
        ll l, r; cin >> l >> r;
        id_min = max({l, id_min});
        id_max = min({r, id_max});
    }
    ll ans = max({id_max - id_min + 1, 0LL});
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a;
  a=0;
  for(int i=0;i<s.size();i++){
      if(s[i]=='1'){
          a++;
      }
  }
  cout<<a<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  ll a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  ll sum = 0;
  for(int i=0;i<N;i++){
    sum += (a[i] - 1);
  }
  cout << sum << endl;
}

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

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int main() {
    LL N;
    cin >> N;
    if (N % 2) {
        cout << 0 << endl;
        return 0;
    }
    LL ans = 0;
    for (LL i = 10; i <= N; i *= 5) {
        ans += N / i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    ll ar[n];
    ll c=0;
    for(ll i=0;i<n;++i) cin>>ar[i];
    sort(ar,ar+n);
    for(ll i=n-1;i>=0;--i){
        ll l=0,r=i-1;
        while(l<r){
            if(ar[l]+ar[r]>ar[i]){
                c+=(r-l);
                --r;
            }
            else{
                ++l;
            }
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,count = 0;
    int n[3000];
    int flg = 0;
    int i,j,x;

    for(;;){

        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0){

            break;
        }else if(flg == 1) printf("\n");
        for(i = 0; i < 3000; i++) n[i] = i;
        for(i = a; i <= b; i++){
            x = n[i];
            n[i] = 0;
            if(x % 4 == 0) n[i] = 3000;
            if(x % 400 == 0) n[i] = 3000;
            else if(x % 100 == 0) n[i] = x;
            if(n[i] == 3000) count++;
        }
        for(i = a; i <= b; i++){
            if(n[i] == 3000) printf("%d\n",i);
        }
        if(count == 0) printf("NA\n");
        count = 0;
        flg = 1;
    }

    return 0;
}

Measured memory_bytes: 624
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


ll findgcd(ll,ll);
ll findlcm(ll,ll);


int main(){
    
    int N;
    cin >> N;
    vector<P> work(N); // 締め切り, 工数
    
    for(int i=0;i<N;i++) cin >> work[i].second >> work[i].first;
    sort(work.begin(),work.end());
    
    int time=0;
    
    for(int i=0;i<N;i++){
        time += work[i].second;
        if(work[i].first < time){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    
    return 0;
}



ll findlcm(ll a,ll b){
    
    ll g = findgcd(a,b);
    
    ll l = a*b/g;
    
    return l;
}


ll findgcd(ll a,ll b){
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b==0) return a;
    // 0とのgdcはその数そのものと定義
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


Measured memory_bytes: 1792
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
typedef pair<int,int> pi;
const int N=2e5+5;
int a[N],b[N],c[N],d[N],f[N],n,m,lim,top,res;pi p[N];
inline void chg(R int x,R int y){for(;x<=lim;x+=x&-x)upd(c[x],y);}
inline int qr(R int x){R int r=0;for(;x;x-=x&-x)upd(r,c[x]);return r;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,m)scanf("%d",&b[i]);
	fp(i,1,n)if(a[i]>b[1]&&a[i]<b[m]){
		R int l=lower_bound(b+1,b+1+m,a[i])-b-1,r=l+1;
		assert(a[i]!=b[r]);
		p[++top]=pi(a[i]-b[l],b[r]-a[i]),d[++lim]=b[r]-a[i];
	}
	sort(d+1,d+1+lim),lim=unique(d+1,d+1+lim)-d-1;
	sort(p+1,p+1+top),top=unique(p+1,p+1+top)-p-1;
	for(R int i=1,j=1;i<=top;i=j){
		while(j<=top&&p[j].fi==p[i].fi)++j;
		fp(k,i,j-1){
			p[k].se=lower_bound(d+1,d+1+lim,p[k].se)-d;
			f[k]=qr(p[k].se-1)+1;
		}
		fp(k,i,j-1)chg(p[k].se,f[k]);
	}
	fp(i,1,top)upd(res,f[i]);
	printf("%d\n",res+1);
	return 0;
}

Measured memory_bytes: 4096
n,h=map(int,input().split())
slash=[]
throw=[]
for i in range(n):
    x,y=map(int,input().split())
    slash.append(x)
    throw.append(y)

slash.sort(reverse=True)
throw.sort(reverse=True)
attack=0
for i in range(n):
    if throw[i]>=slash[0]:
        h-=throw[i]
        attack+=1
        if h<=0:
            print(attack)
            exit()
    else :
        break

attack+=int((h+slash[0]-1)/(slash[0]))
print(attack)


Measured memory_bytes: 11348
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    map<string,int> mp;
    int mx=0;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);
    }
    for(const auto& it:mp){
        if(it.second==mx){
            cout<<it.first<<endl;
        }
    }
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int P = 998244353;
int A, B, C, D, dp[3010][3010][2];

void solve() {
  cin >> A >> B >> C >> D;
  dp[A][B][1] = 1;
  rep(i, A, C) rep(j, B, D) if (i > A || j > B) {
    dp[i][j][0] = (1ll * j * (dp[i - 1][j][0] + dp[i - 1][j][1])) % P;
    dp[i][j][1] = (1ll * i * dp[i][j - 1][1] + dp[i][j - 1][0]) % P;
  }
  cout << (dp[C][D][0] + dp[C][D][1]) % P << endl;
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 74156
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL N, K, S;
  cin >> N >> K >> S;
  VEC<LL> A(N, S);
  REP(i, K, N) {
    if (S == 1e9) {
      A[i] = S - 1;
    } else {
      A[i] = S + 1;
    }
  }
  REP(i, 0, N) { cout << A[i] << " "; }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> array(h+2, vector<bool>(w+2, false));
    array[0][1] = true;
    array[h+1][w] = true;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char c;
            cin >> c;
            if(c == '#'){
                array[i][j] = true;
            }
        }
    }

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(array[i][j]){
                if(!((array[i-1][j] ^ array[i][j-1]) && (array[i+1][j] ^ array[i][j+1]))){
                    cout << "Impossible" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Possible" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

var c = 0

func main() {
	sc.Split(bufio.ScanWords)
	s := stringLineScan()
	n, _ := strconv.Atoi(s)
	for i := 1; i <= len(s); i++ {
		stringPermutations("753", i, "", n)
	}
	fmt.Println(c)
}
func stringPermutations(iterString string, iterNum int, seed string, lim int) {
	if len(seed) == iterNum {
		if x, _ := strconv.Atoi(seed); judge753(seed) && x <= lim {
			c++
		}
	} else {
		for _, s := range iterString {
			stringPermutations(iterString, iterNum, seed+string(s), lim)
		}
	}
}
func judge753(numString string) bool {
	a := 0
	b := 0
	c := 0
	for i := 0; i < len(numString); i++ {
		if string(numString[i]) == "3" {
			a = 1
		} else if string(numString[i]) == "5" {
			b = 1
		} else if string(numString[i]) == "7" {
			c = 1
		}
	}
	if a+b+c == 3 {
		return true
	} else {
		return false
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, m = 10e6;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		int s1 = 0, s2 = 0;

		for (int j = 0; j < i; j++)
			s1 += a[j];
		for (int j = i; j < n; j++)
			s2 += a[j];

		if (abs(s1 - s2) < m)
			m = abs(s1 - s2);
	}

	cout << m << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool a[1000000]; 
#define int long long
main(){
  vector<int>p;
  for(int i=2;i<10000;i++){
    if(!a[i]){
      p.push_back(i);
      for(int j=i;j<10000;j+=i)
        a[j]=1;
    }
  }
  int a,b,m;
  while(cin>>m>>a>>b,m){
    vector<pair<int,pair<int,int> > >v;
    for(int i=p.size()-1;i>=0;i--)
      for(int j=p.size()-1;j>=0;j--){
        int pp=p[i],qq=p[j];
       if(pp*qq<=m&&(double)a/b<=(double)pp/qq&&(double)pp/qq<=1)
          v.push_back(make_pair(qq*pp,make_pair(pp,qq)));
      }
    sort(v.begin(),v.end());
    cout<<v[v.size()-1].second.first<<' '<<v[v.size()-1].second.second<<endl;
  }
}

Measured memory_bytes: 3624