akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
const long long B = 1007;

vector<int> Zalgorithm(const string & s){
    int n = s.size();
    vector<int> res(n);
    res[0] = n;
    int i = 1, j = 0;
    while(i < n){
        while(i + j < n && s[j] == s[i + j]) j++;
        res[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i + k < n && k + res[k] < j){
            res[i + k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

signed main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i,n){
        vector<int> z = Zalgorithm(s.substr(i));
        rep(j,z.size()){
            if(z[j] <= j){
                ans = max(ans, z[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, k = [int(x) for x in input().split()]
res = 0
i = 0
t = [a, b, c]
j = [1, 0, -1]
while k > 0:
  m = min(k, t[i])
  k -= m
  res += j[i] * m
  i += 1
print(res)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
ll T[110];

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }

  ll ans = 1;
  for (int i = 0; i < N; i++) {
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;

  return 0;
}

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  ll N;
  string S,ans="Yes";
  cin >> N >> S;
  if(N%2!=0) ans="No";
  else {
    ll n=N/2;
    if(S.substr(0,n)!=S.substr(n,n)) ans="No";
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    Integer[] a = new Integer[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    Arrays.sort(a, Collections.reverseOrder());

    int Alice = 0;
    int Bob = 0;

    for (int i = 0; i < N; i++) {
      if (i % 2 == 0){
        Alice += a[i];
      } else {
        Bob += a[i];
      }
    }

    System.out.println(Alice - Bob);

  }

}

Measured memory_bytes: 21844
from math import  *
a = int(input())
b = list(map(int,input().split()))
c = []
for i in range(a):
    if b[i]%2==0:
        c.append(b[i])
g = len(c)
count = 0
for k in range(g):
    if c[k]%3==0 or c[k]%5==0:
        count = count + 1
if count == g:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
def jud(n1,n2):
	if abs(n1-int(str(n2)[0]))<=1:
		return 1
	else:
		return 0

rnrn = [[1,2,3,4,5,6,7,8,9],[10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99]]

for div in range(1,10):
	rnrn.append([])
	for i in range(len(rnrn[div])):
		y = str(rnrn[div][i])
		x = int(y[-1])
		if x-1!=-1:
			rnrn[div+1].append(int(y+str(x-1)))
		rnrn[div+1].append(int(y+str(x)))
		if x+1!=10:
			rnrn[div+1].append(int(y+str(x+1)))
		
rnrn2 = []
for i in range(len(rnrn)):
	rnrn2.extend(rnrn[i])

print(rnrn2[int(input())-1])

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
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 fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
  int k,a,b;
  cin>>k>>a>>b;
  bool ok=false;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      ok=true;break;
    }
  }
  if(ok)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;
  return 0;
}




























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

int x, y;
char a;
int ans;

int main(){   
   cin >> y >> x;
  
   for(int i = 0; i < x * y; i++){
           cin >> a;
           if(a == '#')
               ans++;   
    }
   
   	if(ans == x + y - 1)
       cout << "Possible" << '\n';
  	else
      cout << "Impossible" << '\n';
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  bool flag_P=0;
  bool flag_W=0;
  bool flag_G=0;
  bool flag_Y=0;
  
  for (int i=0; i<N; i++){
    cin >> S;
    
    if(!flag_P && S == "P")
      flag_P = true;
    else if(!flag_W && S == "W")
      flag_W = true;
    else if(!flag_G && S == "G")
      flag_G = true;
    else if(!flag_Y && S == "Y")
      flag_Y = true;
    else
      continue;
  }
  
  if(flag_P && flag_W && flag_G && flag_Y)
    cout << "Four" << endl;
  else if(flag_P && flag_W && flag_G && !flag_Y)
    cout << "Three" << endl;
  
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
  if (N >= K) {
    ans += (N - K) * 1.0 / N;
  }
  for (int i = 1; i <= min(K, N); i++) {
    double x = ceil(log2(K * 1.0 / i));
    double p = pow(0.5, x);
    double q = (1.0 / N) * p;
    ans += q;
  }
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 2005;
void solve(){
	ll n,d;
	cin>>n>>d;
	
	ll cnt = 0;
	for(int i =0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		if(x*x + y*y<=d*d){
			cnt++;
		}
	}
	cout<<cnt<<'\n';

}

int main() {	
	IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 3652
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int m = 1000000007;


        long[][] dp = new long[N + 1][K + 1];
        dp[0][0] = 1;

        for (int i = 1; i <= N; i++) {
            dp[i][0] = 1;
            for (int j = 0; j < K; j++) {
                dp[i][j + 1] = (dp[i][j] + dp[i - 1][j + 1]) % m;

                if (j - a[i - 1] >= 0) {
                    dp[i][j + 1] = (dp[i][j + 1] - dp[i - 1][j - a[i - 1]] + m) % m;

                }
            }

        }
        System.out.println(dp[N][K]);
    }
}


Measured memory_bytes: 129620
/**So..a**/
#include<bits/stdc++.h>

using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(int i= a;i <=b; i++)
#define TEST  ll Test; cin >> Test; while(Test--)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define mod(a) a%1000000007

#define  ull unsigned long long
#define MAX  200010
 ll n, m;
 vector<ll> v[MAX];
 ll  visitt[MAX];
 ll a, b;
 ll cnt;
 void dfs(ll node)
 {
         cnt++;
     visitt[node] = 0;
     for(ll i=0; i< (ll)v[node].size(); i++)
     {
         if(visitt[v[node][i]]) dfs(v[node][i]);
     }
     return ;

 }


int main()
{

    FAST;
     cin >> n >> m;
     fr(i, 1, n) visitt[i] = 1;
     fr(i, 1, m)
     {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
     }
     ll ans = 0;
     fr(i, 1, n)
     {
         if(visitt[i] )
         {
                cnt = 0;
             dfs(i);
             ans = max(cnt, ans);
         }
     }
     cout << ans;

    return 0;
}


Measured memory_bytes: 22304
(let ((o (concatenate 'list (read-line)))
      (e (concatenate 'list (read-line))))

  (defun f (lst1 lst2 &optional ans)
    (if (null (car lst1))
      (reverse ans)
      (f (cdr lst1) (cdr lst2) (cons (car lst2) (cons (car lst1) ans)))))

  (format t "~A~%"
          (concatenate 'string (remove-if #'null (f o e)))))


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

int main()
{
	int w, h , x , y , r;
	cin >> w;
	cin >> h;
	cin >> x;
	cin >> y;
	cin >> r;
	if (w >= x + r && 0 <= x - r && h >= y + r && 0 <= y - r){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<vector<int>> cnt(k, vector<int>(k));
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    x %= k << 1, y %= k << 1;
    if (x / k + y / k == 1) {
      if (c == 'W')
        cnt[x % k][y % k] += 1;
      else
        cnt[x % k][y % k] -= 1;
    } else {
      if (c == 'B')
        cnt[x % k][y % k] += 1;
      else
        cnt[x % k][y % k] -= 1;
    }
  }

  vector<vector<int>> s1(k, vector<int>(k)), s2(k, vector<int>(k));
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j) {
      int ii = k - i - 1, jj = k - j - 1;
      s1[i][j] = cnt[i][j], s2[ii][jj] = cnt[ii][jj];
      if (i) {
        s1[i][j] += s1[i - 1][j];
        s2[ii][jj] += s2[ii + 1][jj];
      }
      if (j) {
        s1[i][j] += s1[i][j - 1];
        s2[ii][jj] += s2[ii][jj + 1];
      }
      if (i && j) {
        s1[i][j] -= s1[i - 1][j - 1];
        s2[ii][jj] -= s2[ii + 1][jj + 1];
      }
    }

  int d = 0;
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j) {
      int u;
      if (i && j)
        u = s1[i - 1][j - 1] + s2[i][j];
      else
        u = s2[i][j];
      d = max(d, abs(u * 2 - s2[0][0]));
    }
  printf("%d\n", (n + d) >> 1);

  return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 200010
namespace seg{
  ll dat[2*N];
  void init(){
      for(int i=0;i<2*N;i++)dat[i]=0;
  }  
  void upd(ll i,ll val){
      i+=N; dat[i]+=val;
      for(;i;i>>=1){
	  dat[i/2]=dat[i]+dat[i^1];
      }
  }
  ll sum(ll l,ll r){
      l+=N,r+=N+1;
      ll res=0;
      for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	  if(a&1)res+=dat[a++];
	  if(b&1)res+=dat[--b];
      }
      return res;
  }
};
struct str{
  ll id,score;
  bool operator<(const str&key)const{
      if(this->score==key.score){
	  return this->id>key.id;
      }
      return this->score<key.score;
  }  
};
str strs(ll id,ll score){
    str gen;gen.id=id,gen.score=score;
    return gen;
}
ll n,q;
ll type[N],a[N],b[N];
ll p[N],c[N];
vector<str> v;
int main(){
    cin>>n>>q;
    for(int i=1;i<=n;i++)v.push_back(strs(i,0));
    for(int i=0;i<q;i++){
	cin>>type[i];
	if(type[i]==0)cin>>a[i]>>b[i];
	else cin>>a[i];
    }
    for(int i=1;i<=n;i++)p[i]=0;
    for(int i=0;i<q;i++){
	if(type[i]==1)continue;
	p[a[i]]+=b[i];
	v.push_back(strs(a[i],p[a[i]]));
    }
    /*
    cout<<"---"<<endl;
    for(auto x:v){
	cout<<x.id<<" "<<x.score<<endl;
    }cout<<"---"<<endl;*/
    vector<pair<str,ll> >za;
    for(int i=0;i<v.size();i++){
	za.push_back(make_pair(v[i],i));
    }
    sort(za.begin(),za.end());
    for(int i=0;i<v.size();i++){
	c[za[i].second]=i;
    }
    //for(int i=0;i<v.size();i++)cout<<c[i]<<" ";cout<<endl;
    seg::init();
    for(int i=1;i<=n;i++){
	p[i]=n-i;
	seg::upd(p[i],+1);
    }
    ll t=n;
    for(int i=0;i<q;i++){
	if(type[i]==0){
	    seg::upd(p[a[i]],-1);
	    seg::upd(c[t],+1);
	    p[a[i]]=c[t]; t++;
	}
	if(type[i]==1){
	    ll l=-1,r=N-1,mid;
	    while(l<r-1){
		mid=(l+r)/2;
		if(seg::sum(mid,N-1)>=a[i])l=mid;
		else r=mid;
	    }
	    cout<<za[l].first.id<<" "<<za[l].first.score<<endl;
	}
    }
    return 0;
}



Measured memory_bytes: 21392
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
using namespace std;
int main()
{
  fastio;
  int n;
  cin>>n;
  vector<int> h(n);
  vector<int> d(n);
  fore(i,0,n)
    cin>>h[i];
  d[0]=0;d[1]=abs(h[1]-h[0]);
  fore(i,2,n)
    d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) );
  print(d[n-1]);
}
 


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		int a, b, area, length;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		// 1??????????????§???????????????????????????????????????????????????????´??????????
		String[] strArray = str.split(" ");

		a = Integer.parseInt(strArray[0]);
		b = Integer.parseInt(strArray[1]);

		area = a*b;
		length = (a*2) + (b*2);

		System.out.println(area + " " + length);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;

int dp[3252][3252];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, t, a[3252], b[3252], c[3252], d[3252];
  cin>>n>>t;
  REP(i, n){
    cin>>c[i]>>d[i];
  }
  vi ord(n);
  iota(ALL(ord), 0);
  sort(ALL(ord), [&c, &d](int x, int y){
    if(c[x]==c[y]) return d[x]<d[y];
    return c[x]<c[y];
  });
  REP(i, n){
    a[i]=c[ord[i]];
    b[i]=d[ord[i]];
  }
  REP(i, n+1){
    REP(j, t+1){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  int ans=0;
  REP(i, n){
    REP(j, t+1){
      if(dp[i][j]==INF){
        continue;
      }
      if(dp[i+1][j]==INF){
        dp[i+1][j]=dp[i][j];
      }
      else{
        CHMAX(dp[i+1][j], dp[i][j]);
      }
      CHMAX(ans, dp[i][j]+b[i]);
      if(j+a[i]<t){
        if(dp[i+1][j+a[i]]==INF){
          dp[i+1][j+a[i]]=dp[i][j]+b[i];
        }
        else{
          CHMAX(dp[i+1][j+a[i]], dp[i][j]+b[i]);
        }
        // CHMAX(ans, dp[i+1][j+a[i]]);
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}


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

const int mxN = 2e5;
vector<int> g[mxN];
bool vis[mxN];

int cnt = 1;
void dfs(int u) {
	vis[u] = 1;
	for(int v : g[u]) {
		if(!vis[v]) {
			cnt++;
			dfs(v);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v, --u, --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(!vis[i]) {
			dfs(i);
			ans = max(ans, cnt);
			cnt = 1;
		}
	}
	cout << ans << '\n';
}


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

void printResult(int win, int* array) {
    for (int i = 0; i < 5; i++) {
        if (array[i] == win) {
            cout << 1 << endl;
        } else {
            cout << 2 << endl;
        }
    }
}

int main() {
    while (true) {
        int hands[5];
        for (int i = 0; i < 5; i++) {
            cin >> hands[i];
            if (hands[i] == 3) {
                hands[i] = 4;
            }
        }
        if (hands[0] == 0) {
            break;
        }
        int result = hands[0] | hands[1] | hands[2] | hands[3] | hands[4];
        switch (result) {
        case 1: case 2: case 4: case 7:
            for (int i = 0; i < 5; i++) {
                cout << 3 << endl;
            }
            break;
        case 3:
            printResult(1, hands);
            break;
        case 6:
            printResult(2, hands);
            break;
        case 5:
            printResult(4, hands);
            break;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int ans=0;
	rep(i,n)
	{
		int foo, fooo;
		cin >> foo>> fooo;
		ans += fooo - foo + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,w;
long long dp[100001];
int main(){
	cin>>n>>w;
	int ww[n+1],v[n+1];
	for(int i=1;i<=n;i++)
		cin>>ww[i]>>v[i];
	for(int i=0;i<=100000;i++)
		dp[i]=10000000000000000;
	dp[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=100000;j>=v[i];j--)
			dp[j]=min(dp[j],dp[j-v[i]]+ww[i]);
	long long ans;
	for(int i=0;i<=100000;i++)
		if(dp[i]<=w)
			ans=i;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k; cin >> n >> m >> k;
    vll a(n), b(m);
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < m; i++) cin >> b[i];
    vll bsum(m + 1, 0);
    for (ll i = 0; i < m; i++) {
        bsum[i + 1] = bsum[i] + b[i];
    }
    ll ans = lower_bound(ALL(bsum), k + 1) - bsum.begin() - 1;
    ll acca = 0;
    for (ll i = 0; i < n; i++) {
        acca += a[i];
        if (acca > k) break;
        chmax(ans, i + 1 + (ll)(lower_bound(ALL(bsum), k - acca + 1) - bsum.begin()) - 1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define forn(i,n) for(int i=0; i<(int)n; i++)
ll power(ll x,ll n);
bool isprime(ll n);
ll mod=1e9+7;

void test_case()
{
    ll n;
    cin>>n;
    ll k=log(1+25*n)/log(26)-1;
    n-=(power(26,k+1)-1)/25;
    int a[k+1]={};
    for(int i=0;i<k+1;i++) {
        a[i]=n/power(26,k-i);
        n%=power(26,k-i);
        cout<<(char)('a'+a[i]);
    }

}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}
ll power(ll x,ll n)
{
    ll ans=1;
    while(n>0) {
        if(n&1)
            ans*=x;
        n>>=1;
        x*=x;
    }
    return ans;
}

bool isprime(ll n)
{
    if(n==2 || n==3)
        return true;
    if(n<=1 || n%2==0 || (n%6!=1 && n%6!=5))
        return false;
    for(int i=3;i*i<=n;i+=2) {
        if(n%i==0)
            return false;
    }
    return true;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i];

    REP(i, n) {
        b[i] = (a[i] - (i+1));
    }
    
    sort(all(b));
    int mid = (n & 1 ? b[n/2] : (b[n/2-1]+b[n/2]) / 2);
    int sum = 0;
    REP(i, n) sum += abs(b[i] - mid);
    cout << sum << endl;
}


Measured memory_bytes: 3456
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int a, b;
    cin >> a >> b;
    int ans = -2000;
    ans = max(ans, a + b);
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = [int(input()) for i in range(a)]
c = sorted(b)[-2]
d = max(b)
if b.count(d) >= 2:
  for i in range(a):
    print(d)
else:
  for i in b:
    if i == d:
      print(c)
    else:
      print(d)

Measured memory_bytes: 19092
#include <stdio.h>
#include <stdlib.h>
long long int min(long long int x, long long int y){return x<y?x:y;}
long long int max(long long int x, long long int y){return x<y?y:x;}
int main(void){
	long long h,w,i,ans=1e9,s_A,s_B,s_C,ans1,ans2,ans0,rans=1e9;
	scanf("%lld%lld",&h,&w);
	for(i=1;i<h;i++){
		s_A = w*i;
		s_B = (h-i)*(w/2);
		s_C = (h-i)*(w-w/2);
		ans1 = max(max(s_A,s_B),s_C)-min(min(s_A,s_B),s_C);
		s_B = (h-i)/2*w;
		s_C = (h-i-(h-i)/2)*w;
		ans2 = max(max(s_A,s_B),s_C)-min(min(s_A,s_B),s_C);
		ans0 = min(ans1,ans2);
		ans = min(ans,ans0);
	}
	int tmp = h;
	h = w;
	w = tmp;
	for(i=1;i<h;i++){
		s_A = w*i;
		s_B = (h-i)*(w/2);
		s_C = (h-i)*(w-w/2);
		ans1 = max(max(s_A,s_B),s_C)-min(min(s_A,s_B),s_C);
		s_B = (h-i)/2*w;
		s_C = (h-i-(h-i)/2)*w;
		ans2 = max(max(s_A,s_B),s_C)-min(min(s_A,s_B),s_C);
		ans0 = min(ans1,ans2);
		rans = min(rans,ans0);
	}
	ans = min(ans,rans);
	
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import sys,math,collections,itertools
input = sys.stdin.readline
cnt =1
K,A,B=list(map(int,input().split()))
if A+2<=B:#交換したほうがいい
    if A-1 >=K:#最低交換枚数に達しない
      cnt = 1+K
    else:
        cnt = A + (K-(A-1))//2*(B-A)+(K-(A-1))%2
else:
    cnt = 1+K
print(cnt)



Measured memory_bytes: 9408
#include<iostream>
using namespace std;
int main()
{
  long long int k, n, i, max;
  cin>>k>>n;
  int arr[n];
  int dif[n+1];
  
  for(i=0; i<n; i++)
  cin>>arr[i];
  
  for(i=0; i<n-1; i++)
  {
      dif[i] = abs(arr[i]-arr[i+1]);
  }
  dif[i] = abs(arr[i]-arr[0]);
  
  for(i=0; i<n; i++)
  {
      if(dif[i] > k/2)
      dif[i] = k- dif[i];
  }
  
  max = 0;
  for(i=0; i<n; i++)
  {
      if(dif[i] > max)
      max = dif[i];
  }
  
  cout<<k-max<<endl;
  
  return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N / R; r++) {
        for (int g = 0; g <= N / G; g++) {
            int rest = N - (r * R + g * G);
            if (rest < 0) continue;
            if (rest % B == 0) ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

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

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    int l = a[n] / 2;
    int r = l;
    if (a[n] % 2) r++;
    int res = 2000000000, vt = 0;
    FOR(i,1,n-1)
        if (a[i] <= l) {
            if (l - a[i] < res) {
                res = l - a[i];
                vt = a[i];
            }
        }
        else if (a[i] >= r) {
            if (a[i] - r < res) {
                res = a[i] - r;
                vt = a[i];
            }
        }
    cout << a[n] << ' ' << vt;
    return 0;
}

Measured memory_bytes: 640
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, x;
	while(cin >> n >> x) {
		vector<int> l(n);
		REP(i, n) cin >> l[i];
		int ans = 0;
		int d = 0;
		REP(i, n) {
			if(d <= x) ans++;
			d += l[i];
		}
		if(d <= x) ans++;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  
  char a[50];
  int count,ans,temp,i;
  scanf("%s",a);
 
  	for(i = 0; i < 10;i++){
      	
  		if(a[i] == 'A'|| a[i] == 'C'|| a[i] == 'G' || a[i] == 'T'){
          count++;
          	if(a[i+1] != 'A'&& a[i+1] != 'C'&& a[i+1] != 'G'&& a[i+1] != 'T'){
             	temp = count;
              	count = 0;
          		if (temp >= ans){
                  ans =temp;
                }
            }
  		}
    }
  
  printf("%d",ans);
  return 0;
  
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),M = sc.nextInt();
		String[] ns = new String[N];
		String[] ms = new String[M];
		for(int i = 0;i < N;i++) {
			ns[i] = sc.next();
		}
		for(int i = 0;i < M;i++) {
			ms[i] = sc.next();
		}

		boolean match = false;
		for(int i = 0; i <= N - M; i++) {
			for(int j  =0; j <= N - M;j++) {
				for(int m = 0; m < M; m++) {
					if(!ns[i+m].substring(j, j+M).equals(ms[m])) {
						match = false;
						break;
					}
					match = true;
				}
				if(match) {
					System.out.println("Yes");
						return;
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <fstream>
#include <string>
#include <map>
#include <queue>
#include <utility>
#include <stack>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int A[101010];

int main()
{
    int n; in >> n;
    REP(i, n)
    {
        int x; in >> x;
        A[x]++;
    }

    int p = 0;
    int r = 0;
    REPE(i, 1, 100000)
    {
        if(A[i] > 1) p += A[i]-1;
        if(A[i]) r++;
    }

    if(p%2) r--;

    out << r << endl;

    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-


def main():
    a, b, k = map(int, input().split())
    ans = list()

    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            ans.append(i)

    print(sorted(ans, reverse=True)[k - 1])


if __name__ == '__main__':
    main()


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

typedef pair<ll,ll> pll;


ll n,h,w;
vector<ll> g[400005];
ll p[400005];
ll used[400005];
ll sz[400005];
ll ans;
ll fs(ll x)
{
        return p[x] == x ? x : p[x] = fs(p[x]);
}
void ms(ll x, ll y)
{
        x=fs(x); y=fs(y);
        p[y]=x;
        used[x] = (used[x] | used[y]);
}
vector< pair<ll, pll> > e;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> n >> h >> w;
        for(ll i=1;i<=n;i++) {

                ll x,y,a;
                cin >> x >> y >> a;
                e.pb(make_pair(a,make_pair(x, h + y)));
        }
        sort(e.rbegin(), e.rend());
        for(ll i=1;i<=h+w;i++) {
                p[i] = i;
                used[i]=0;
                sz[i] = 1;
        }
        ans = 0;
        for(auto &i : e) {

                ll u = i.second.first;
                ll v = i.second.second;
                ll w = i.first;

                if(fs(u) == fs(v)) {

                        if(used[fs(u)] == 0) {
                                ans += w;
                                used[fs(u)]=1;
                        }
                }else {
                        if(used[fs(u)] == 0 || used[fs(v)] == 0){
                                ms(u,v);
                                ans += w;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 21616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<P> q;
    rep(i,n){
        int a;
        cin >> a;
        q.push(P(a,1));
    }
    rep(i,m){
        int b,c;
        cin >> b >> c;
        q.push(make_pair(c,b));
    }
    ll ans = 0;
    rep(i,n){
        auto p = q.top();q.pop();
        ans += p.first;
        if(p.second!=1){
            q.push(make_pair(p.first,p.second-1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
  vector<ll> v[100005];
    int main()
    {

          ios_base::sync_with_stdio(false);
          cin.tie(NULL);cout.tie(NULL);
        
          
            int t=1;
  //  cin>>t;
  while(t--){
    ll n,m;
    cin>>n>>m;
    ll a[n],b[n];
    ll i,j;
    ll mn=1e10,mx=-1e10;
    rep(i,0,n){
      cin>>a[i]>>b[i];
      v[a[i]].pb(b[i]);
      mn=min(mn,a[i]);
      mx=max(mx,a[i]);
    }
    ll dp[m+1]={};
    dp[0]=0;
    ll vis[mx+1]={};
    priority_queue<ll,vector<ll>> pq;
    rep(i,mn,m+1){
      for(auto j:v[i]){
        pq.push(j);
      }
      if(!pq.empty()){
      //  cout<<i<<" "<<pq.top()<<'\n';
      dp[i]=dp[i-1]+pq.top();
      pq.pop();
        
      }
      else
      dp[i]=dp[i-1];
    }
    cout<<dp[m]<<'\n';
  }
  return 0;
}


          

  

Measured memory_bytes: 8832
#include<cstdio>
const int N=500007,P=998244353;
int fac[N],ifac[N];
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int mod(int x){return x+(x>>31&P);}
int pow(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*a*r%P;return r;}
int C(int n,int m){return n<m||m<0? 0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
int main()
{
    int n,k,ans=0;scanf("%d%d",&n,&k);
    for(int i=fac[0]=1;i<=k;++i) fac[i]=1ll*fac[i-1]*i%P;
    ifac[k]=pow(fac[k],P-2);for(int i=k;i;--i) ifac[i-1]=1ll*ifac[i]*i%P;
    for(int i=0,f;i+i<=k&&i+n<=k;++i) f=(i+i==k),inc(ans,mod(C(k-f,i-f)-C(k-f,i+i+n-k-1-f)));
    printf("%d",ans);
} 


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	a.at(0)==0;
	for(int i=0;i<N;i++)	cin >> a.at(i+1);

	vector<int> b(N+1,0);
	int count=0;
	for(int i=N;i>=1;i--){
		int now=0;
		for(int j=2;;j++){
			if(i*j<=N)	now+=b.at(i*j);
			else	break;
		}
		if((now+a.at(i))%2==1){
			b.at(i)=1;
			count++;
		}
		else	b.at(i)=0;
	}

	cout << count << endl;
	for(int i=1;i<=N;i++){
		if(b.at(i)==1)	cout << i << " ";
	}

	return 0;
}


Measured memory_bytes: 2432
N, K = map(int, input().split())
Z = 0
H = 0
for i in range(N):
  if (i+1)%K == 0:
    Z += 1
  if K%2 == 0 and (i+1)%K == K//2:
    H += 1

print(Z**3+H**3)

Measured memory_bytes: 64772
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	register short f=1;x=0;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	x*=f;
}
template<typename T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void writeln(T x){
	write(x),putchar('\n');
}
int main(){
	string str,s;cin>>str;
	s=str;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++){
		switch(s[i]){
			case 'b':s[i]='d';break;
			case 'd':s[i]='b';break;
			case 'p':s[i]='q';break;
			case 'q':s[i]='p';break;
		}
	}
	if(s==str)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

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

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

void Knuth_Morris_Pratt(string &T, string &P, vector<int> &res){
	vector<int> pat(P.size()+1);
	pat[0] = -1;
	
	res.resize(T.size());
	
	for(int i = 0, j = -1; i < P.size(); i++){
		while(j >= 0 && P[i] != P[j]) j = pat[j];
		j++;
		if(P[i+1] == P[j]) pat[i+1] = pat[j];
		else pat[i+1] = j;
	}
	
	for(int i = 0, j = 0; i < T.size(); i++){
		while(j >= 0 && T[i] != P[j]) j = pat[j];
		j++;
		if(j == P.size()){
			res[i-P.size()+1] = true;
			j = pat[P.size()];
		}
		
	}
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	vector<int> m, used, con;
	string s, t, sd;
	int  ans = 0;
	
	cin>>s>>t;

	sd = s;
	used.resize(s.size() + t.size());
	con.resize(s.size() + t.size(),-1);

	for(int i = 0; i < (int)t.size() - 1; i++){
		s += s[i%s.size()];
	}

	Knuth_Morris_Pratt(s,t,m);
	
	// for(int i = 0; i < sd.size(); i++){
		// cout<<"i = "<<i<<" s = "<<s[i]<<" m = "<<m[i]<<endl;
	// }
	for(int i = 0; i < sd.size(); i++){
		// cout<<"i = "<<i<<" s = "<<s[i]<<" m = "<<m[i]<<endl;
		if(used[i] || !m[i]) continue;
		
		int now = i, count = 0;
		for(;; now = (now + t.size())%sd.size(), count++){
			if(!m[now]) break;
			
			if(used[now]){
				if(con[now] == -1){
					cout<<-1<<endl;
					return 0;
				} else {
					count += con[now];
					break;
				}
			}
			used[now] = true;
		}
		con[i] = count;
		ans = max(ans, count);
		// cout<<"count = "<<count<<endl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 30108
#include <stdio.h>

int main(void) {

  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &c[i][j]);
    }
  }
  if (c[1][0]-c[0][0] == c[1][1]-c[0][1] && c[1][1]-c[0][1] == c[1][2]-c[0][2] && c[2][0]-c[0][0] == c[2][1]-c[0][1] && c[2][1]-c[0][1] == c[2][2]-c[0][2]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const int chk[]={1,4,7,9};
int A[4];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	for(int i=0;i<4;i++) cin>>A[i];
	sort(A,A+4);
	for(int i=0;i<4;i++) if(A[i]!=chk[i]) {
		cout<<"NO\n";
		return 0;
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))


h = ["2","4","5","7","9"]
p = ["0","1","6","8"]
n = input()
if n[-1] in h:
    print("hon")
elif n[-1] in p:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 61680
# A - Buying Sweets


# 所持金 X 円
# ケーキ屋のケーキの値段 A 円
# ドーナツ屋のドーナツの値段 B 円

X = int(input())
A = int(input())
B = int(input())

# print(X, A, B)

# ケーキ屋で 1 つ　ケーキを買う
balance_cake = X - A
# print(balance_cake)

# ドーナツ屋で １つ B円のドーナツをたくさん買いました
# balance_cake 円 で ドーナツを何個買えるか計算

max_purchase_donut = balance_cake // B
# print(max_purchase_donut)

# ドーナツ屋で購入した分引く　⇔ 残金
answer = balance_cake - (max_purchase_donut * B)
# print(answer)

# 残金を表示
print(answer)


Measured memory_bytes: 9080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_Frog1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var h = new int[N];

            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(input[i]);
            }

            var dp = new int[N];
            for (int i = 0; i < N; i++)
            {
                dp[i] = int.MaxValue;
            }
            dp[0] = 0;
            for (int i = 1; i < N; i++)
            {
                dp[i] = Chmin(dp[i], dp[i - 1] + Math.Abs(h[i - 1] - h[i]));
                if (i > 1)
                {
                    dp[i] = Chmin(dp[i], dp[i - 2] + Math.Abs(h[i - 2] - h[i]));
                }
            }

            Console.WriteLine(dp[N - 1]);
        }

        public static int Chmin(int a, int b)
        {
            return a > b ? a = b : a;
        }
    }
}


Measured memory_bytes: 16864
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,i,j,a[mx];
	cin>>n;
	for(i=0; i< n; i++)
	cin>>a[i];
	
	ll ans=0;
	for(i=1; i< n-1; i++)
	{
	    ll k1= min(a[i-1], min(a[i], a[i+1]) );
	    ll k2= max(a[i-1], max(a[i], a[i+1]));
	    if(a[i]!=k1 && a[i]!=k2)
	    ans++;
	}
	cout<<ans;
    return 0;
}























Measured memory_bytes: 256