akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, Alice = 0, Bob = 0;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  for(int i = 0; i < N; i++){
    int max1 = 0, max2 = 0;
    
    for(int j = 0; j < N; j++){
      if(a.at(j) > max1){
        max1 = a.at(j);
      }
    }
    for(int j = 0; j < N; j++){
      if(a.at(j) == max1){
        a.at(j) = 0;
        break;
      }
    }
    
    for(int j = 0; j < N; j++){
      if(a.at(j) > max2){
        max2 = a.at(j);
      }
    }
    for(int j = 0; j < N; j++){
      if(a.at(j) == max2){
        a.at(j) = 0;
        break;
      }
    }
    
    Alice += max1;
    Bob += max2;
  }
  
  cout << Alice - Bob << endl;
  
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int Q; scanf("%d", &Q);
  while (Q-- > 0) {
    ll A, B; scanf("%lld %lld", &A, &B);
    if (A > B) { swap(A, B); }
    ll ans = 2 * (A - 1);
    ll low = 0, high = 1e10, mid = -1;
    while (high - low > 1) {
      mid = (high + low) / 2;
      bool ok = true;
      if (A + mid >= B) { ok = false; }
      for (ll m = mid / 2 - 2; ok and m <= mid / 2 + 2; ++m) {
        if (m <= 0 or (A + mid - m) >= B) { continue; }
        if ((A + m) * (A + mid - m) >= A * B) {
          ok = false;
          break;
        }
      }
      if (ok) { low = mid; }
      else { high = mid; }
    }
    ans += low;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
x=input().split()
n=int(x[0])
a=int(x[1])
b=int(x[2])

def fast_expo(b,n,p):
    if n==0:
        return 1
    if n==1:
        return b%p
    if n%2==0:
        return fast_expo(((b%p)*(b%p))%p,n//2,p)
    else:
        return (b*fast_expo(((b%p)*(b%p))%p,n//2,p))%p
def combi(n,k,p):
    X=1
    Y=1
    for i in range(k):
        X=(X*(n-i))%p
        Y=(Y*(k-i))%p
    Z=fast_expo(Y,p-2,p)
    return (X*Z)%p

p=10**9+7
res=fast_expo(2,n,p)
res=(res-1)%p
res=(res-combi(n,a,p))%p
res=(res-combi(n,b,p))%p
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
#define int long long
int N,K;
long long ans;
long long res=0;
signed main(){
  cin>>N>>K;
  if(K==0){
    cout<<N*N<<endl;
    return 0;
  }
  for(int i=K+1;i<=N;i++){
    ll x = N /i;
    ll y = i-K;
    ll z = max(0LL,(ll)N%i-K+1);
    ans+= x*y+z;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
// 基本テンプレート
#define _GLIBCXX_DEBUG // for STL debug
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[110][110][110];
signed main() {
    int L, K; cin >> L >> K;
    dp[0][0][0] = 1;

    int ans = 0;
    for(int i=0; i<=L; i++) {
        for(int j=0; j<=L; j++) {
            for(int k=0; k<=L; k++) {
                if(dp[i][j][k] == 0) continue;

                if(j % 2 == 1) ans += dp[i][j][k];
                if(j % 2 == 0) {
                    dp[i+1][j+1][k+1] += dp[i][j][k];
                    if(k+K <= L) dp[i+1][j+1][k+K] += dp[i][j][k];
                }
                else {
                    dp[i+1][j+1][k+1] += dp[i][j][k];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3528
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    L=list(map(int,input().split()))
    L.sort()
    ans=0
    for b in range(n):
        c=b+1
        for a in range(b):
            while(1):
                if(c>=n or L[a]+L[b]<=L[c]): break
                c+=1
            ans+=c-(b+1)
    print(ans)
resolve()

Measured memory_bytes: 42604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define int long long
#define double long double
using namespace std;
#define PI  3.1415926535898
#define eqs 1e-10
const long long max_ = 3e5 + 7;
int mod = 998244353;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
signed main() {
	double a, b, c;
	cin >> a >> b >> c;
	if (a + b + 2 * sqrtl(a * b) < c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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


int main(int argc, char *argv[])
{
	int n;
	string s;
	cin >> n >>s;

	int ret=0;
	for (int i=0;i<=n-3;i++)
	{
		if (s.substr(i,3)=="ABC") ret++;
	}
	cout<<ret<<endl;
	return 0;
}


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

int a[100005];

signed main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	int op;
	int ans = 1145141919;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			op = i;
			break;
		}
	}

	for (int i = min(0,op-k+1); i <= min(n-k,op); i++) {
			int s = i, g = i + k - 1;
			ans = min(ans, (s + k - 2) / (k - 1) + (n - g + k - 3) / (k - 1) + 1);
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int count = 0;
    for (int i = 1; i <= N; i++) {
      if (i % 2 != 0) {
        int c = 0;
        for (int j = 1; j <= i; j++) {
          if (i % j == 0) { c++; }
        }
        if (c == 8) { count++; }
      }
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

ll sum, a[N], n, q, x, y;

int main() {
   cin>>n;
   for1(i, n) {
      scanf("%lld", &x);
      a[x]++, sum += x;
   }
   cin>>q;
   while(q--) {
      scanf("%lld%lld", &x, &y);
      if(a[x]) {
         a[y] += a[x];
         sum += a[x]*(y-x);
         a[x]=0;
      }
      printf("%lld\n", sum);
   }
}

Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,M;
	cin>>N>>M;
	if(N==M)
	    cout<<"Yes";
	   else
	   cout<<"No";
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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


int main()
{

	int n; cin >> n;

	long double res = 0;

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

		long double x; cin >> x;
		x = 1/x;
		res += x;

	}

	long double nres = 1/res;

	cout << nres;

	
	return 0;

}

Measured memory_bytes: 3756
# -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return map(int, input().split())
N = int(input())

X = []
Y = []

for i in range(N):
    x, y = inpl()
    X.append((i, x))
    Y.append((i, y))

X = sorted(X, key=lambda x: x[1])
Y = sorted(Y, key=lambda y: y[1])

G = [[] for _ in range(N)]
for i in range(N-1):
    Xa, Xb = X[i], X[i+1]
    Ya, Yb = Y[i], Y[i+1]
    G[Xa[0]].append([Xb[0], Xb[1]-Xa[1]])
    G[Xb[0]].append([Xa[0], Xb[1]-Xa[1]])
    
    G[Ya[0]].append([Yb[0], Yb[1]-Ya[1]])
    G[Yb[0]].append([Ya[0], Yb[1]-Ya[1]])

visited = [False]*N
Q = [(0, 0)]
ans = 0

while Q:
    c, n = heappop(Q)
    if visited[n]:
        continue
    visited[n] = True
    ans += c
    
    for m, d in G[n]:
        if visited[m]:
            continue
        else:
            heappush(Q, (d, m))

print(ans)

Measured memory_bytes: 127960
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func makeAKIHABARA(n int) string {
	s := []string{"", "KIH", "B", "R"}
	t := ""
	for i := range s {
		t += s[i]
		if (n>>uint(i))&1 == 1 {
			t += "A"
		}
	}
	return t
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	for i := 0; i < 16; i++ {
		if makeAKIHABARA(i) == s {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 640
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,m;
char r[600][600],b[600][600],a[600][600];
int sleep() {
	int j=0;
	for(int i=1; i<2000001; i++) j++;
	return j;
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j++)
			r[i][j]='#';
	for(int i=2; i<=n; i+=2)
		for(int j=1; j<=m; j++) {
			r[i][j]='.';
		}
	for(int i=2; i<=n; i+=2)
		for(int j=1; j<=m; j++)
			b[i][j]='#';
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j++) {
			b[i][j]='.';
		}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			char cur;
			cin>>cur;
			if(cur=='#') {
				r[i][j]='#';
				b[i][j]='#';
			}
		}
	}
	for(int i=1; i<=n; i++)
		r[i][1]='#',b[i][1]='.';
	for(int i=1; i<=n; i++)
		r[i][m]='.',b[i][m]='#';
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++)
			cout<<r[i][j];
		cout<<endl;
	}
	cout<<endl;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++)
			cout<<b[i][j];
		cout<<endl;
	}
	sleep();
	return 0;
}

Measured memory_bytes: 1280
import math
import collections

#Max = 210000
Mod = 1000000007
"""
fac = [0] * Max
finv = [0] * Max
inv = [0] * Max
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, Max):
        fac[i] = fac[i-1] * i % Mod 
        inv[i] = Mod - inv[Mod%i] * (Mod//i) % Mod
        finv[i] = finv[i-1] * inv[i] % Mod """
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
def COMinit():
    for i in range(2, N+111):
        fac.append(fac[-1]*i%Mod)
        inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
        finv.append(finv[-1] * inv[-1] % Mod)
    

def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

N, M = map(int, input().split())
prime_count = collections.Counter()
for i in range(2, math.ceil(math.sqrt(M))+1):
    while M % i == 0:
        M /= i
        prime_count[i] += 1
if M > 1:
    prime_count[M] += 1

ans = 1
COMinit()
for i, b in prime_count.items():
    tmp = COM(b+N-1, N-1)
    ans = (ans * tmp) % Mod 
print(ans)


Measured memory_bytes: 15380
# 入力 : A B
A, B = map(int, input().split())

# 出力　Aliceが勝つならAliceを、Bobが勝つならBobを、引き分けならDrawを出力せよ。

if A == B :
    print("Draw")
else :
    if A == 1 :
        print("Alice")
    elif B == 1 :
        print("Bob")
    elif A > B :
        print("Alice")
    else :
        print("Bob")


Measured memory_bytes: 2940
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n, k; cin >> n >> k;
    vector<double> p(n);
    rep(i, n) cin >> p[i];
    vector<double> p_sum(n + 1);
    p_sum[0] = 0;
    _rep(i, 1, n + 1) p_sum[i] = p_sum[i - 1] + (p[i - 1] + 1) / 2;
    double MAX = 0;
    for(int i = k; i <= n; i++){
        double sum = p_sum[i] - p_sum[i - k];
        MAX = max(sum , MAX);
    }
    cout << setprecision(15) << MAX << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
  typedef long long ll;
int main()
{
   string s,ss;
   cin>>s>>ss;
   int c=0;
   for(int i=0;i<3;i++)
   {


               if(s[i]==ss[i])
               {
                     c++;
               }
         }

   cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int mx=max(a,max(b,c));
  int x=mx*3-a-b-c;
  if(x%2==0) cout << x/2 << endl;
  else cout << (x+1)/2+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(true){
    int n;
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;++i){
      int m,e,j;
      cin>>m>>e>>j;
      if(m==100 || e==100 || j==100) cout<<"A"<<endl;
      else if((m+e)/2>=90) cout<<"A"<<endl;
      else if((m+e+j)/3>=80) cout<<"A"<<endl;
      else if((m+e+j)/3>=70) cout<<"B"<<endl;
      else if((m+e+j)/3>=50 && (m>=80 || e>=80)) cout<<"B"<<endl;
      else cout<<"C"<<endl;
    }
  }
  return 0;
}



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

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new PrintStream(System.out));
        int n=Integer.parseInt(f.readLine());
        long[]arr=new long[n];
        StringTokenizer st=new StringTokenizer(f.readLine());
        HashMap<Long,Integer>hs=new HashMap<>();

        for(int i=0;i<n;i++){
            arr[i]=Long.parseLong(st.nextToken());
            if(!hs.containsKey(arr[i])){
                hs.put(arr[i],1);
            }
            else
            hs.put(arr[i],hs.get(arr[i])+1);
        }
        Arrays.sort(arr);
        long ans=0;
        for(int i=n-1;i>=0;i--){
            if(!hs.containsKey(arr[i]))continue;
            if(hs.get(arr[i])==1)
            hs.remove(arr[i]);
            else hs.put(arr[i],hs.get(arr[i])-1);
            long j=1;
            while(j<=arr[i]){

                j*=2;
            }
            if(hs.containsKey(j-arr[i])){
                ans++;
                if(hs.get(j-arr[i])==1)
                    hs.remove(j-arr[i]);
                else hs.put(j-arr[i],hs.get(j-arr[i])-1);
            }

        }
        System.out.print(ans);
        f.close();
        out.close();
    }
}

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

using namespace std;

const int MOD=1e9+7;

int p10[11];
int main(){
        p10[0]=1;
        for(int i=1;i<=10;i++) p10[i]=p10[i-1]*10;

        int sum;
        cin>>sum;

        long long ans=0;
        ///maybe more than 3
        for(int L=1,R=1,vL=1,vR=1,csum=0;R<p10[8];R++){
                if (R==p10[vR]) vR++;
                csum+=vR;
                while (csum>sum){
                        if (L==p10[vL]) vL++;
                        csum-=vL;
                        L++;
                }
                ans+=sum==csum;
//                if (sum==csum) cout<<L<<" "<<R<<'\n';
        }

        ///case that we use 2 number(the later >=9) ((a+b)x==sum+b) (x<=9*10**7)
        for(int x=9;x<=sum;x++){
                int R=(sum-1)/(x-1)-1;
                int L=x-(sum%x);
                if (R>=L){
//                        cout<<x<<" "<<L<<" "<<R<<" "<<(R-L)/x+1<<'\n';
                        ans=(ans+(R-L)/x+1)%MOD;
                }
        }
//        cout<<ans<<'\n';
        ///only 1 num start from 8
        for(int x=9,cp10=p10[8];x<=sum;x++,cp10=cp10*10LL%MOD) if (sum%x==0){
                int len=sum/x;
//                cout<<x<<" "<<len<<" "<<cp10<<'\n';
                ans=(ans+9LL*cp10-len+1)%MOD;
        }
        cout<<(ans+MOD)%MOD;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, n, map[16][16];

	while(true)
	{
		scanf("%d%d", &a, &b);
		if(a == 0 && b == 0)
			break;
		scanf("%d", &n);
		for(int i = 0; i < a; ++i)
		{
			for(int j = 0; j < b; ++j)
				map[i][j] = 0;
		}
		map[0][0] = 1;

		for(int i = 0; i < n; ++i)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			map[x - 1][y - 1] = -1;
		}

		for(int x = 0; x < a; ++x)
		{
			for(int y = 0; y < b; ++y)
			{
				if(map[x][y] == -1)
					continue;

				if(x != 0 && map[x - 1][y] != -1)
					map[x][y] += map[x - 1][y];
				if(y != 0 && map[x][y - 1] != -1)
					map[x][y] += map[x][y - 1];
			}
		}

		if(map[a - 1][b - 1] == -1)
			map[a - 1][b - 1] = 0;
		printf("%d\n", map[a - 1][b - 1]);
	}

	return 0;
}

Measured memory_bytes: 0
use proconio::{fastout, input};

use std::cmp::{min, Reverse};
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! {
            n: usize,
            mut klr: [(usize, i64, i64); n],
        }
        let mut ans = 0;
        klr.sort_by_key(|&(k, _, _)| k);
        for (_, l, r) in klr.iter() {
            ans += min(l, r);
        }
        let (a, b): (Vec<_>, Vec<_>) = klr.into_iter().partition(|&(_, l, r)| l >= r);
        let mut s = BinaryHeap::new();
        let mut idx = 0;
        for i in 1..=n {
            while idx < a.len() && a[idx].0 == i {
                let (_, l, r) = a[idx];
                s.push(Reverse(l - r));
                idx += 1;
            }
            while s.len() > i {
                s.pop();
            }
        }
        while let Some(Reverse(lr)) = s.pop() {
            ans += lr;
        }
        let mut idx = b.len();
        for i in 1..=n {
            while idx > 0 && b[idx - 1].0 == n {
                idx -= 1;
            }
            while idx > 0 && b[idx - 1].0 == n - i {
                let (_, l, r) = b[idx - 1];
                s.push(Reverse(r - l));
                idx -= 1;
            }
            while s.len() > i {
                s.pop();
            }
        }
        while let Some(Reverse(rl)) = s.pop() {
            ans += rl;
        }
        println!("{}", ans);
    }
}


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

int main()
{
    int t, c=0;

    cin >> t;

      int a[t],i;
      int b[t];
      for(i=0;i<t;i++)
      {
          cin>> a[i];
          b[i] = a[i];
      }
      sort(b,b+t);
      for(i=0;i<t;i++)
      {
          if(a[i]!=b[i])
            c=c+1;
          if(c>2)
          {
              cout<<"NO";
              return 0;
          }
      }
      cout << "YES";

}


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

template <class T>
struct BIT {
	int n;
	vector<T> x;
	BIT(int n_ = 0) : n(n_), x(n + 1, 0) {}
	int size() const { return n; }
	T sum(int r) const {
		T S = 0;
		for(r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
		return S;
	}
	T sum(int l, int r) const { return sum(r) - sum(l); }
	void add(int k, const T &a) {
		for(; k < n; k |= k + 1) x[k] += a;
	}
	void set(int k, const T &a) { add(k, a - sum(k, k + 1)); }
};

typedef pair<int, int> P;

int x[500000];
int q, lim;

int f(BIT<int>& b, int x) {
	int ng = -1, ok = q - 1;
	while(abs(ng - ok) > 1) {
		int mid = (ng + ok) / 2;
		if(b.sum(0, mid + 1) >= x) ok = mid;
		else ng = mid;
	}
	return ok;
}

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

	while(cin >> q >> lim, q | lim) {
		BIT<int> b(q + 10);
		set<P> s;
		map<int, int> tmap;
		for(int i = 0; i < q; i++) {
			int type;
			cin >> type >> x[i];
			//cerr << "type : " << type << ", x : " << x[i] << endl;
			if(type == 0) {
				if(s.size() == lim) {
					b.add(s.begin()->first, -1);
					tmap.erase(s.begin()->second);
					s.erase(s.begin());
				}
				b.add(i, 1);
				tmap[x[i]] = i;
				s.insert({ i, x[i] });
			}
			else if(type == 1) {
				int t = f(b, x[i]);
				//assert(b.sum(t, t + 1) == 1);
				b.add(t, -1);
				s.erase({ t, x[t] });
				tmap.erase(x[t]);
			}
			else if(type == 2) {
				int t = f(b, x[i]);
				//assert(b.sum(t, t + 1) == 1);
				cout << x[t] << endl;
			}
			else {
				b.add(tmap[x[i]], -1);
				s.erase({ tmap[x[i]], x[i] });
				tmap.erase(x[i]);
			}
		}
		cout << "end" << endl;
	}
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


#include "bits/stdc++.h"
struct UnionFind {
	std::vector<int> par;
	std::vector<int> sizes;

	UnionFind(int n) {
		par.resize(n);
		sizes.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		if (sizes[x] < sizes[y]) std::swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pll> v(n);
	int ans = n;
	REP(i, n)cin >> v[i].first >> v[i].second;
	REP(i, n)FOR(j, i + 1, n) {
		ll dx = v[j].first - v[i].first, dy = v[j].second - v[i].second;
		UnionFind uf(n);
		int tmp = n;
		REP(a, n)REP(b, n) {
			if (v[a].first + dx == v[b].first && v[a].second + dy == v[b].second) {
				if (!uf.same(a, b))tmp--;
				uf.unite(a, b);
			}
		}
		chmin(ans, tmp);

	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    vector<ll> ans;
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    rep(i, x) ans.push_back(p[i]);
    rep(i, y) ans.push_back(q[i]);
    rep(i, c) ans.push_back(r[i]);

    sort(ans.begin(), ans.end(), greater<int>());

    ll marv=0;
    rep(i, x+y) marv += ans[i];

    cout << marv << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;
const ll MOD = 998244353;

int N;
pair <int, int> p[MAXN];
int nreach[MAXN]; // right-most guy i can reach

ll dp[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> p[i].first >> p[i].second;
    sort (p, p + N);

    for (int i = 0; i < N; i++)
        nreach[i] = i;

    for (int i = N - 2; i >= 0; i--)
    {
        int xend = p[i].first + p[i].second;
        int cloc = i;

        while (cloc < (N - 1) && p[cloc+1].first < xend)
            cloc = nreach[cloc+1];
        nreach[i] = cloc;
    }


    for (int i = 0; i < MAXN; i++)
        dp[i] = 0;
    dp[0] = 1;

    for (int i = 0; i < N; i++)
    {
        dp[i] %= MOD;
        dp[i+1] += dp[i];
        dp[nreach[i]+1] += dp[i];
    }
    cout << dp[N] % MOD << "\n";
}

Measured memory_bytes: 4224
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-12-01 21:10:49
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n; cin >> n;

  //cerr << 999 * 1.08 << endl;

  for (double i = 1; i <= 50000; ++i) {
    if (floor(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;

  return 0;
}

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

int main(){
	ll x, y;
	cin >> x >> y;

	int ans = 0;
	ll a = x;
	while (a <= y) {
		a *= 2;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int cnt =0;
  
  for(int i=0;i<N;i++){
    //cnt ++;
    H = H - A.at(i);
  }
  
  if(H<=0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	string s;
	cin >> s;

	vector<Int> R(2*N, 0);
	vector<int> L;
	Int cnt = 0;
	for (int i = 0; i < 2*N; ++i) {
		if (cnt < 0) {
			cout << 0 << endl;
			return 0;
		}

		if ((s[i] == 'B' && cnt % 2 == 0) || (s[i] == 'W' && cnt % 2 == 1)) {
			L.push_back(i);
			R[i] = -1;
			++cnt;
		} else {
			R[i] = 1;
			--cnt;
		}
	}
	for (int i = 2*N - 2; i >= 0; --i) { R[i] += R[i + 1]; }
	
	Int ans = (cnt == 0 ? 1 : 0);
	for (Int i = 1; i <= N; ++i) { (ans *= i) %= MOD; }

	for (int i = L.size() - 1; i >= 0; --i) {
		(ans *= R[L[i] + 1]) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll s,idx=0;
    cin>>s;
    map<ll,ll>m;
    vi v;
    v.pb(s);
    m[s]=1;
    for(int i=1;;i++)
    {
        ll x=v[i-1],a2=0;
        if(x%2==0)
        {
           a2=(x)/2;
        }
        else
        {
            a2=3*(x)+1;
        }
        if(m[a2])
        {
            idx=i;
            break;
        }
        else
        {
            m[a2]=1;
            v.pb(a2);
        }


    }
    cout<<idx+1<<endl;
}
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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


Measured memory_bytes: 26404
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, q;
  cin >> n >> q;
  vll bit(n+1, 0);
  auto add = [&](ll t, ll w){
    for(int i = t; i <= n; i+=i&-i){
      bit.at(i) += w;
    }
  };
  auto sum = [&](ll r){
    ll ans = 0;
    for(int i = r; i > 0; i-=i&-i){
      ans += bit.at(i);
    }
    return ans;
  };
  while(q--){
    ll qq, x, y;
    cin >> qq >> x >> y;
    if(qq == 0){
      add(x, y);
    }
    else{
      cout << sum(y) - sum(x-1) << endl;
    }
  }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int i = 0;
    int j = n-1;
    while (s[i]!='A') i++;
    while (s[j]!='Z') j--;
    int ans = j-i+1;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5;

struct NODE{
	int val,id;
}E[N+3];
bool cmpNODE(NODE A,NODE B){
	return A.val<B.val;
}
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&E[i].val);
		E[i].id=i;
	}
	sort(E+1,E+1+n,cmpNODE);
	for(int i=1;i<=n;i++){
		printf("%d",E[i].id);
		if(i==n) printf("\n");
		else printf(" ");
	}
	return 0;
}

Measured memory_bytes: 1536
/*
Author Shivam
*/
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007 
#define int			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii> 
#define ve          vector
#define endl		"\n"
#define double 		long double
#define couts		cout<<setprecision(12)<<fixed					
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;					

int f(string s)
{
	int cnt=0;
	rep(i,1,sz(s)){
		if(s[i]==s[i-1]) s[i]='#', cnt++;;
	}

	return cnt;
}
void solve()
{
	string s, ans;
	cin>>s;
	int k;
	cin>>k;
	rep(i,0,min(100ll, k))
	{
		ans+=s;
	}

	int cnt = f(ans);
	//cout<<cnt<<" "<<ans<<endl;
	ans+=s;
	ans+=s;
	int cnt1 = f(ans);
	//cout<<cnt1<<" "<<ans<<endl;
	//cout<<cnt<<" "<<cnt1<<endl;
	if(k<100) cout<<cnt;
	else
	{
		cout<<cnt+(k-100)*(cnt1-cnt)/2;
	}
}
signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t;
		t=1;
		while(t--)
		{
			solve();
		}
}	

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int[] input = cin.ReadIntArray(2);
            int n = input[0];
            int x = input[1];
            List<int> m = new List<int>();

            for (int i = 0; i < n; i++)
            {
                m.Add(cin.ReadInt);
            }
            
            int res = n + ((x - m.Sum()) / m.Min());

            WriteLine(res);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<string>
//#define MAX 101
#define INFTY (1<<21)

using namespace std;

static const int N = 100;


/*int min(int a, int r[], int c[]) {



	for(int i=1; i<=a; i++){
		if(r[i] == c[i+1]){
			int s = r[i]*c[i]*r[i+1];
		}
}*/

int main() {
	int n;
	

	int M[N+1][N+1];
	int p[N+1];

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

	for (int i = 1; i <= n; i++) {
		M[i][i] = 0;
	}

	for (int j = 2; j <= n; j++) {
		for (int i = 1; i <= n - j + 1; i++) {
			int k = i + j - 1;

			M[i][k] = INFTY;

			for (int a = i; a <= k - 1; a++) {
				int b = M[i][a] + M[a + 1][k] + p[i - 1] * p[a] * p[k];
				M[i][k] = min(M[i][k], b);

			}
		}
	}

	cout << M[1][n] << endl;
	/*int R[MAX];
	int C[MAX];

	int r, c;
	for(int i = 1; i<=n; i++){
		cin >> r >> c;
		R[i] = r;
		C[i] = c;

	}*/

	return 0;
}



Measured memory_bytes: 3136
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)

lst = list(range(1,N+1))
l_str = [str(i).zfill(5) for i in lst]
l_int = []

for j in l_str:
  array = list(map(int,j))
  l_sum = sum(array)
  #print(l_sum)
  if A<=l_sum and l_sum<=B:
    k = int(j)
    l_int.append(k)
print(sum(l_int))

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define vll             vector<ll>
#define vpll            vector<pll>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1e6 + 10;

int n, k, m, query;

ll ans;
int nx[N];

void Solve(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        int x;
         cin >> x;
         if (x >= k) ans++;

    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
}

















Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  string s;
  cin>>s;
  for(int i=0;;i++){
    //cout<<s;
    s.pop_back();
    if(s.size()%2==0&&i!=0){
      string tmp="";
      int num=s.size();
      while(s.size()!=num/2){
	tmp=tmp+s[0];
	s.erase(s.begin());
	//cout<<s<<" "<<tmp<<endl;
      }
      if(s==tmp)break;
      s=tmp+s;
    }
  }
  cout<<s.size()*2<<endl;
}


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

void run() {
    int x, y;
    cin >> x >> y;
    if (y - 2 * x >= 0 && (y - 2 * x) % 2 == 0) {
        int b = (y - 2 * x) / 2;
        int a = x - b;
        if (a >= 0) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    run();
    return 0;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll x;

void input(){
    cin >> x;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans;
    ans = 2 * (x / 11);
    if(x % 11 > 6) ans += 2;
    else if(x % 11 > 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, a, b;
    cin >> n >> a >> b;
    lint max_sum = b * (n - 1) + a;
    lint min_sum = a * (n - 1) + b;
    lint ans = max((lint)0, max_sum - min_sum + 1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;


int main(){

  int c[50]={};
  int N,M,a,b;
  cin >> N >> M;
  for(int i=0;i<M;i++){
      cin >> a >> b;
      c[a-1]++;
      c[b-1]++;
  }
  for(int i=0;i<N;i++) cout << c[i] <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mo 998244353
map <string,int>f,g;string st;
int calcf(const string &st);
int calcg(const string &st);
int calcf(const string &st)
{
	if (st.length()==1) return st[0]-'0'+1;
	if (f.count(st)) return f[st];
	int ans=calcg(st);
	for (int i=1;i<st.length();++i)
		ans=((long long)calcg(st.substr(0,i))*calcf(st.substr(i,st.length()-i))+ans)%mo;
	return f[st]=ans;
}
int calcg(const string &st)
{
	if (st.length()==1) return st[0]-'0'+1;
	if (g.count(st)) return g[st];
	int len=st.length(),ans=0;
	for (int i=1;i<len;++i) if (len%i==0)
	{
		string ls=st.substr(0,i);
		for (int j=0;j<len;++j) if (st[j]=='0') ls[j%i]='0';
		ans=(ans+calcf(ls))%mo;
	}
	return g[st]=ans;
}

int main()
{
	cin>>st;
	cout<<calcf(st)<<endl;
}

Measured memory_bytes: 12800