akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int main() {
    string a;
    cin >> a;
    string str = "";
    rep(i,a.size()){
        if(i == a.size()-1){
            if(a[i] == 'A'){
                str += 'A';
            }
            else{
                str += 'Y';
            }
        }
        else{
            if(a[i] == 'A'){
                str += a[i];
            }
            else if(a[i] == 'B' && a[i+1] == 'C'){
                str += 'X';
                i++;
            }
            else{
                str += 'Y';
            }
        }
    }
    //cout << str << endl;

    ll cnt = 0;
    ll ans = 0;
    rep(i,str.size()) {
        if(str[i] == 'A'){
            ++cnt;
        }
        if(str[i] == 'X'){
            ans += cnt;
        }
        if(str[i] == 'Y'){
            cnt = 0;
        }
    }

    cout << ans << endl;

   return 0;  
}

Measured memory_bytes: 776
n=int(input())
ans=0
a=[]
for i in range(n):
    a.append(int(input()))

a.append(0)


for i in range(n):
    ans += a[i]//2

    if a[i]%2==1 and a[i+1]!=0:
        ans +=1
        a[i+1] -=1

print(ans)

Measured memory_bytes: 7324
import sys
input = sys.stdin.readline

x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = list(map(int, input().split()))

C = p[:x] + q[:y] + r
C.sort(reverse=True)

print(sum(C[:x + y]))


Measured memory_bytes: 23472
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct Mod {
    static uint64_t PRIME;
    uint64_t value = 0;
    Mod()
    : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const { return power(*this, PRIME - 2); }
    Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

vector<Mod> fact;

Mod binom(ll n, ll r) {
    if (!(0 <= n && 0 <= r && r <= n)) {
        return 0;
    } else {
        return fact[n] / fact[r] / fact[n-r];
    }
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    fact.resize(max(N*M-2, max(N+1, M+1))+1,1);
    rep(n,1,fact.size()) {
        fact[n] = fact[n-1] * n;
    }
    Mod ans = 0;
    rep(i,0,2) {
        ans += Mod(M) * Mod(M) * binom(N+1, 3) * binom(N*M-2, K-2);
        swap(N,M);
    }
    cout << ans.value << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
const double E=exp(1);
const double PI=acos(-1);
using namespace std;
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c*=a;
        a*=a;
        b>>=1;
    }return c;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int s[200003];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
   int n,a[30],b[30],sum;sum=0;
   cin>>n;
   for(int i=1;i<=n;i++)
    cin>>a[i];
    int Max=0;
   for(int i=1;i<=n;i++)
   {
      if(a[i]>=Max)
      {
          sum++;
      }
      Max=max(Max,a[i]);
   }
   cout<<sum<<endl;
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<long> A(N);
    for(auto& i : A)cin >> i;
    sort(A.rbegin(), A.rend());
    vector<long> sgn(N, 1);
    auto t = min<unsigned long>(N - 1, max(1L, lower_bound(A.rbegin(), A.rend(), 0) - A.rbegin()));
    fill(sgn.rbegin(), sgn.rbegin() + t, -1);
    cout << inner_product(A.begin(), A.end(), sgn.begin(), 0L) << endl;
    for(unsigned long i = 1; i + t < N; ++i){
        cout << A[N - t] << " " << A[i] << endl;
        A[N - t] -= A[i];
    }
    for(unsigned long i = N - t; i < N; ++i){
        cout << A[0] << " " << A[i] << endl;
        A[0] -= A[i];
    }
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n,p;
char s[10];
while(cin>>s){
if(s[0]=='S')cout<<"Cloudy"<<endl;
else if(s[0]=='C')cout<<"Rainy"<<endl;
else cout<<"Sunny"<<endl;
}
return 0;
}


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


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

  int res = 0;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      res = 1;
    }
    else if(s[i] == 'B' && res == 1){
      res++;
    }
    else if(s[i] == 'C' && res == 2){
      res = 0; cnt++;
    }
    else{
      res = 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;


int main(){

	long long a, b;
	cin>>a>>b;

	long long r0 = a, r1 = b, x0 = 1, x1 = 0, y0 = 0, y1= 1, r2, x2, y2, q1;

	while(r1 > 0){
		q1 = r0 / r1;
		r2 = r0 % r1;
		x2 = x0 - q1 * x1;
		y2 = y0 - q1 * y1;
		r0 = r1; r1 = r2;
		x0 = x1; x1 = x2;
		y0 = y1; y1 = y2;
	}

	cout<<x0<<" "<<y0<<endl;

	return 0;
}

Measured memory_bytes: 1164
from sys import stdin

input = stdin.readline
import math
from functools import lru_cache
MOD = 10**9 + 7

@lru_cache(None)
def fac(n):
    return math.factorial(n)


def comb(k,n):
    return fac(n)//fac(k)//fac(n-k)

def solve():
    s = int(input())
    if s < 3:
        print(0)
        return
    maxn = s // 3
    res = 0
    for i in range(1,s//3 + 1):
        res += (comb(i-1,s-2*i-1))%MOD
    print(res%MOD)

if __name__ == '__main__':
    solve()


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

int main() {
  int N,H;
  cin>>H>>N;
  int tmp = 0;
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    tmp += k;
  }
  if (H<=tmp)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
// In the Name of God

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const int pw = 257;

ll n, a[N], sum, b[N], m, k;

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif
	                                            	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);

    cin >> n;
    rep(i, 1, n) {
    	cin >> a[i];
    	sum += a[i];
    }

    if (sum % (n * (n + 1) / 2) != 0)
    	return cout << "NO", 0;

	k = sum / (n * (n + 1) / 2);
	rep(i, 1, n - 1)
		b[i] = a[i + 1] - a[i];
	b[n] = a[1] - a[n];

	rep(i, 1, n) {
		if ((k - b[i]) % n != 0 || (k - b[i]) / n < 0)
			return cout << "NO", 0;
		m += (k - b[i]) / n;
	}
	
	if (m != k)
		return cout << "NO", 0;

	cout << "YES";


	#ifdef Madi
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define th(x) x/180*acos(-1)
using namespace std;
struct Point{
	double x,y;
};
int n;
void dfs(Point p1,Point p2,int cnt){
	if(cnt==n){
		printf("%.8lf %.8lf\n",p2.x,p2.y);
		return;
	}
	Point s,u,t;
	s.x = (2*p1.x+p2.x)/3;
	s.y = (2*p1.y+p2.y)/3;
	t.x = (p1.x+2*p2.x)/3;
	t.y = (p1.y+2*p2.y)/3;
	double th=60.0/180*acos(-1);
	u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	dfs(p1,s,cnt+1);
	dfs(s,u,cnt+1);
	dfs(u,t,cnt+1);
	dfs(t,p2,cnt+1);
}
int main(){
	cin>>n;
	Point p1={0,0},p2={100,0};
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	dfs(p1,p2,0);
}


Measured memory_bytes: 3224
import sys
from collections import deque
input = sys.stdin.readline

S = deque(input().strip())
Q = int(input())
flag = 0

for i in range(Q):
    q = input().split()
    if q[0] == '1':
        flag = 1 if not flag else 0
    elif q[0] == '2':
        if q[1] == '1':
            S.appendleft(q[2]) if not flag else S.append(q[2])
        elif q[1] == '2':
            S.append(q[2]) if not flag else S.appendleft(q[2])

print(''.join(S)) if not flag else print(''.join(reversed(S)))


Measured memory_bytes: 8436
#include<stdio.h>
#include<string.h>
int main(void)
{
    char S1[11],S2[11],S3[11];
    int S4,S5;
    int a=0,b=0,i;
  
    scanf("%s%s",S1,S2);
    scanf("%d%d",&S4,&S5);
    scanf("%s",S3);
  
    for(i=0;i<strlen(S1);i++)
      if(S1[i]==S3[i]) a++;
     
    if(a==strlen(S1)){
      printf("%d %d\n",S4-1,S5);
      return 0;
    }
  
    for(i=0;i<strlen(S2);i++)
      if(S2[i]==S3[i]) b++;
  
    if(b=strlen(S2)){
      printf("%d %d\n",S4,S5-1);
      return 0;
    }
}

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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

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

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

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}
 
int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(i>=k){
      if(a[i-k]<a[i]) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4844
import java.util.*;

public class Main {

    static long lowerBound(List<Long> ls, long key) {
        int ng = -1;
        int ok = ls.size();

        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (key <= ls.get(mid)) ok = mid;
            else ng = mid;
        }

        return ok;
    }
    static long upperBound(List<Long> ls, long key) {
        int ng = -1;
        int ok = ls.size();

        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (key >= ls.get(mid)) ng = mid;
            else ok = mid;
        }

        return ok;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> a = new ArrayList<>();
        List<Long> b = new ArrayList<>();
        List<Long> c = new ArrayList<>();
        for (int j = 0; j < n; ++j) a.add(sc.nextLong());
        for (int j = 0; j < n; ++j) b.add(sc.nextLong());
        for (int j = 0; j < n; ++j) c.add(sc.nextLong());
        Collections.sort(a);
        Collections.sort(c);

        long res = 0L;
        for (int i = 0; i < n; ++i) {
            long lower = lowerBound(a, b.get(i));
            long upper = n - upperBound(c, b.get(i));
            res += lower * (upper);
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 102820
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N;
    cin >> N;
    char c;
    c = N.at(N.size()-1);
    if (c == '3') cout << "bon" << endl;
    else if (c == '0' || c == '1' || c == '6' || c == '8') cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

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

using namespace std;

int tab[100020];
int wynik[100020];
int roz(int x,int y)
{
   return max(x,y)-min(x,y);

}


int main()
{
    int n;
    cin >> n;
  cin >> tab[1];
  tab[0]=tab[1];


  for (int i=2;i<=n;i++)
  {
      cin>> tab[i];
      int wylicz1=roz(tab[i],tab[i-1]);
      int wylicz2=roz(tab[i],tab[i-2]);
      int wynik1,wynik2;
      wynik1=wynik[i-1]+wylicz1;
      wynik2=wynik[i-2]+wylicz2;
      wynik[i]=min(wynik1,wynik2);

       ///cout << "pos:" << i << " roz1: " << wylicz1 << " roz2: " << wylicz2 << " wynik: " << wynik[i] << "\n";
  }
cout << wynik[n];
}


Measured memory_bytes: 1024
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const double pi = acos(-1.0);
int main()
{
	int r = read();
	double ans = pi * 2.0 * (double)(r);
	printf("%.6lf\n", ans);
	return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    int ans = -1;
    for(int i=1500;i>=0;i--){
        int a_tax=i*0.08;
        int b_tax=i*0.1;
        if(a_tax==a&&b_tax==b) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	VI a(4);
	int b;
	rep(i, 6) {
		cin >> b;
		a[b-1]++;
	}

	bool flag = true;
	rep(i, 4) {
		if (a[i] > 2) {
			flag = false;
		}
	}

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;


}


 

Measured memory_bytes: 256
package main

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

func main() {
	const Mod = int(1e9) + 7
	N, K := ReadInt(), ReadInt()
	a := ReadInts(N)

	// dp[i][j] = i番目までの子供に、j個の飴を分け合う場合の数
	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, K+1)
	}
	for i := 0; i < N+1; i++ {
		dp[i][0] = 1
	}
	for i := 1; i < N+1; i++ {
		for j := 1; j < K+1; j++ {
			dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % Mod
			v := j - 1 - a[i-1]
			if v >= 0 {
				dp[i][j] = (dp[i][j] + Mod - dp[i-1][v]) % Mod
			}
		}
	}
	fmt.Println(dp[N][K])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 83068
n = int(input())
a = [int(input()) for i in range(n)]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
    
# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

# リストに対してgcd, lcm求める
import functools
result_lcm = functools.reduce(lcm, a)

print(result_lcm)

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

int main() {
	int N;
	cin >> N;
	int a_max = 0, a_min = 100000;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		a_max = max(a_max, a);
		a_min = min(a_min, a);
	}
	cout << a_max - a_min << endl;
}

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

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

#define sd(mark) scanf("%d",&mark)
#define s2d(mark,marx) scanf("%d%d",&mark,&marx)
#define s3d(mark,marx,marz) scanf("%d%d%d",&mark,&marx,&marz)
#define sf(mark) scanf("%f",&mark)
#define slf(mark) scanf("%lf",&mark)
#define sst(mark) scanf("%s",&mark)
#define sld(mark) scanf("%lld",&mark)
#define s2ld(mark,marx) scanf("%lld%lld",&mark,&marx)
#define s3ld(mark,marx,marz) scanf("%lld%lld%lld",&mark,&marx,&marz)
#define sline(mline) scanf("%[^\n]%*c",&mline)

#define pi(n) printf("%d\n",n)
#define pf(n) printf("%f\n",n)
#define plf(n) printf("%lf\n",n)
#define pst(n) printf("%s\n",n)
#define pl(n) printf("%lld\n",n)

#define pis(n) printf("%d ",n)
#define pfs(n) printf("%f ",n)
#define plfs(n) printf("%lf ",n)
#define pss(n) printf("%s ",n)
#define pls(n) printf("%lld ",n)

#define sff fflush(stdout)
#define decimal(n) cout.precision(n)
#define fix cout<<fixed
#define debug(mark) printf("check%d\n",mark)
#define in(a) cin>>a
#define out(a) cout<<a<<'\n'
#define clr(mark) memset(mark,0,sizeof(mark))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long int
#define mod 1000000007ll
#define llu unsigned long long int
#define endl '\n'
#define INF 1123456789
#define eps 1e-9
#define fo(i,a,b) for(int i=a;i<b;++i)
#define foll(i,a,b) for(ll i=a;i<b;++i)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)

#define UL 100000		//5
#define MAXN 1000000	//6
#define MAXL 10000000	//7

typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< pair<ll,ll> > vll;
typedef pair<char,char> pcc;
typedef vector< pair<int, int> > vii;


// bool mark[MAXN+5];

// int sieve()
// {
// 	int ULL = MAXN;
// 	for(int i=0;i<=ULL;i++) mark[i]=true;
// 	for(int i=2;i*i<=ULL;i++) if(mark[i]) for(int j=i*i;j<=ULL;j+=i) mark[j]=false;
// 	for(int i=2;i<=ULL;i++) if(mark[i]) p.pb(i);
// 	return p.size();
// }


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

ll modexp(ll a,ll b)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll temp = modexp(a,(b>>1));
	temp = (temp*temp);
	return (temp*modexp(a,b&1));
}

ll modexp(ll a,ll b, ll m)
{
	if(b==0) return 1;
	if(b==1) return a%m;
	ll temp = modexp(a,(b>>1),m);
	temp = (temp*temp)%m;
	return (temp*modexp(a,b&1,m))%m;
}

ll modinv(ll a, ll p)
{
	return modexp(a,p-2,p);
}

int A[3*UL+5],B[3*UL+5];
ll sA[3*UL+5],sB[3*UL+5];

int solve(int l1,int l2,int r1,int r2)
{
	if(l1>r1||l2>r2) return 0;
	int x = l1, y = l2;
	while((sA[x]-sA[l1-1])!=(sB[y]-sB[l2-1]))
	{
		if((sA[x]-sA[l1-1])<(sB[y]-sB[l2-1])) x++;
		else if((sA[x]-sA[l1-1])>(sB[y]-sB[l2-1])) y++;
	}
	return (1+solve(x+1,y+1,r1,r2));
}

int main()
{
	int a,b; s2d(a,b);
	int p = a*b;
	if(p&1) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
a,b,c=list(map(int,input().split()))
if a==5 and b==5 and c==7:
	print("YES")
elif a==5 and b==7 and c==5:
	print("YES")
elif a==7 and b==5 and c==5:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        boolean plus = true;
        int ans = 1;
        int prev = 0;
        boolean isFirst = true, isSecond = false, isZero = false;
        for(int i = 0; i < n; i++){
            if(isFirst){
                isFirst = false;
                isSecond = true;
            }else if(isSecond || isZero){
                isSecond = false;
                if(a[i-1] == a[i]){
                    isZero = true;
                }else{
                    isZero = false;
                    plus = a[i-1] < a[i] ? true : false;
                }
            }else if(plus && prev > a[i]){
                ans++;
                isSecond = true;
            }else if(!plus && prev < a[i]){
                ans++;
                isSecond = true;
            }
            prev = a[i];
        }
        System.out.println(ans);
    }
}


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

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	if (a.at(0) == 0 && a.at(n - 1) == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (n % 3 == 0) {
		if (a.at(0) == a.at(n / 3 - 1)
			&& a.at(n / 3 - 1) != a.at(n / 3)
			&& a.at(n / 3) == a.at(n * 2 / 3 - 1)
			&& a.at(n * 2 / 3 - 1) != a.at(n * 2 / 3)
			&& a.at(n * 2 / 3) == a.at(n - 1)) {
			bool xo = false;
			bitset<40>x(a.at(0));
			bitset<40>y(a.at(n / 3));
			bitset<40>z(a.at(n * 2 / 3));
			bitset<40>ze(0);
			bitset<40>ans = x ^ y;
			ans = ans ^ z;
			if (ans == ze)xo = true;
			if (xo)cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else if (a.at(0)==0
			&&a.at(0) == a.at(n / 3 - 1) 
			&&a.at(n/3-1)!=a.at(n/3)
			&& a.at(n / 3) == a.at(n - 1))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;




Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int main() {
    Int H,W;
    vvi done;
    vector<vector<char>> A;

    cin >> H >> W;
    A = vector<vector<char>>(H,vector<char>(W,0));
    done = vvi(H,vi(W,-1));
    rep(i,H){
        rep(j, W){
            cin>> A[i][j];
        }
    }

    Int ans = 0;
    queue<pii> next_points;
    rep(i,H){
        rep(j, W){
            if(A[i][j] == '#'){
                next_points.push(pii(i,j));
                done[i][j] = 0;
            }
        }
    }

    while(!next_points.empty()){
        pii now = next_points.front();
        next_points.pop();

        if(now.first+1 != H){
            if(done[now.first+1][now.second] == -1){
                done[now.first+1][now.second] = done[now.first][now.second]+1;
                ans = max(ans,done[now.first+1][now.second]);
                next_points.push(pii(now.first+1,now.second));
            }
        }

        if(now.second+1 != W ){
            if(done[now.first][now.second+1] == -1){
                done[now.first][now.second+1] = done[now.first][now.second]+1;
                ans = max(ans,done[now.first][now.second+1]);
                next_points.push(pii(now.first,now.second+1));
            }
        }

        if(now.first-1 >=0){
            if(done[now.first-1][now.second] == -1){
                done[now.first-1][now.second] = done[now.first][now.second]+1;
                ans = max(ans,done[now.first-1][now.second]);
                next_points.push(pii(now.first-1,now.second));
            }

        }
        if(now.second-1 >=0){
            if(done[now.first][now.second-1] == -1){
                done[now.first][now.second-1] = done[now.first][now.second]+1;
                ans = max(ans,done[now.first][now.second-1]);
                next_points.push(pii(now.first,now.second-1));
            }
        }

    }


    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 25524
using System;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            if(x == 7 || x == 5 || x == 3)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String sa = reader.readLine();
			String sb = reader.readLine();
			String sc = reader.readLine();
			char turn = 'a';
			char nextPerson;
			outer:while(true) {
				switch (turn) {
				case 'a':
					if (sa.length() > 0) {
						nextPerson = sa.charAt(0);
						turn = nextPerson;
						sa = sa.substring(1);
					} else {
						break outer;
					}
					break;
					
				case 'b':
					if (sb.length() > 0) {
						nextPerson = sb.charAt(0);
						turn = nextPerson;
						sb = sb.substring(1);
					} else {
						break outer;
					}
					break;
					
				case 'c':
					if (sc.length() > 0) {
						nextPerson = sc.charAt(0);
						turn = nextPerson;
						sc = sc.substring(1);
					} else {
						break outer;
					}
					break;
				}
			}
			
			System.out.println(String.valueOf(turn).toUpperCase());
			

		} catch(IOException e) {
			System.out.println(e);
		}
	}

}


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

using namespace std;

const int INF = 1e9;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for (int j = 0; j < m; j++) cin >> c[j] >> d[j];
	for (int i = 0; i < n; i++) {
		int Min = INF, idx = -1;
		for (int j = 0; j < m; j++) {
			int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (Min > tmp) {
				Min = tmp;
				idx = j + 1;
			}
		}
		cout << idx << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    private static Map<Integer, Integer> map = new HashMap<>();

    private static void increment(Integer key) {
        if (map.containsKey(key)) {
            map.put(key, map.get(key) + 1);
            return;
        }
        map.put(key, 1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> a.add(sc.nextInt()));
        for (int i = 0; i < n; i++) {
            int num = a.get(i);
            increment(num - 1);
            increment(num);
            increment(num + 1);
        }
        System.out.println(map.entrySet().stream().max(Map.Entry.comparingByValue()).get().getValue());
    }

}


Measured memory_bytes: 62092
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N, i;
	cin >> N >> i;
	int ret = N - i + 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[200005],vis[200005],sum=-1,c1;
vector<long long>v[200005],v2,v3;

void dfs (int node,int par)
{
    
    vis[node]=1;
    v2.push_back(node);
    
    for(int i=0;i<v[node].size();i++)
    {
        if(vis[v[node][i]]==0)
        {
            dfs(v[node][i],node);
        }
        else
        {
             sum=v[node][i];
        }
    }
    
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
    long long i,j,k,count=0,ans=0,x,y,l,r,n;
    cin>>n>>k;
    long long a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]--;
        v[i].push_back(a[i]);
        
    }
    dfs(0,-1);
    if(k<v2.size())
    {
        cout<<v2[k]+1; return 0;
    }
    for(i=0;i<v2.size();i++)
    {
        if(v2[i]==sum)
        break;
        else
        k--;
    }
    for(j=i;j<v2.size();j++)
    v3.push_back(v2[j]);
       
    x=v3.size();
    x=k%x;

    cout<<v3[x]+1;
	return 0;
}

Measured memory_bytes: 31316
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string s;
	cin >> s;
	printf((s[0] == s[2]) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
ll gcd (ll a, ll b) {return b==0ll? a: gcd(b, a%b);}
ll lcm (ll a, ll b) {return a*b/gcd(a, b);}
int main(){
	ll a, b, c, d; cin>>a>>b>>c>>d;
	ll m =lcm(c, d);
	ll rc = b/c - a/c, rd = b/d - a/d;
	if(a%c==0) rc++; if(a%d==0) rd++;
	ll range = b/m - a/m;
	if(a%m==0) range++;
	cout<<(b-a+1) - (rc + rd - range);
	return 0;
}


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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  string s,t;
  cin >> s >> t;

  sort(all(s));
  sort(all(t));
  reverse(all(t));

  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
# encoding: utf-8
 
 
class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]
 
        print(len(set(array_1).intersection(set(array_2))))
 
 
if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Measured memory_bytes: 8436
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) cout << b + c << endl;
	else cout << a + 2 * b+1 << endl;
	return 0;
}

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

vector<int> A;
long long n[26];

int main() {
  while(true) {
    int c = getchar();
    if(c < 'a' || 'z' < c) break;
    A.push_back(c);
    ++n[c - 'a'];
  }
  long long l = A.size();
  long long res = l * (l - 1) / 2;
  for(int i = 0; i < 26; ++i) {
    res -= n[i] * (n[i] - 1) / 2;
  }
  printf("%lld\n", res + 1);
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s == "ABC"){
    ANS("ARC");
  }else{
    ANS("ABC");
  }
  return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int res = min(b, d) - max(a, c);
	if(res<0) res= 0;
	cout<<res<<endl;
	return 0;
}


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

bool match(string s, string t) {
    rep(i, s.size()) {
        if(s.at(i) != '?' & s.at(i) != t.at(i)) {
            return false;
        }
    }
    return true;
}

int main() {
    string s, t;
    cin >> s >> t;
    vector<string> st;
    rep(i, s.size() - t.size() + 1) {
        string ans = s;
        string subs = ans.substr(i, t.size());
        if(match(subs, t)) {
            ans.replace(i, t.size(), t);
            for(int pos = ans.find("?"); pos != string::npos; pos = ans.find("?")) {
            ans.replace(pos, 1, "a");
            }
            st.push_back(ans);
        }
    }
    if(st.empty()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(st.begin(), st.end());
    cout << st.at(0) << endl;

    
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> ss;
  string sa = "";
  for(int i = 0; i < b; ++i) {
    sa += to_string(a);
  }
  ss.push_back(sa);
  string sb = "";
  for(int i = 0; i < a; ++i) {
    sb += to_string(b);
  }
  ss.push_back(sb);
  sort(ss.begin(), ss.end());
  cout << ss[0] << endl;
  return 0;
}

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

int main() {
	string b ,a; 
	cin >> b >> a;
	int d, s;
	cin >> d >> s;
	string u; 
	cin >> u;
	unordered_map<string, int>hash;
	hash[b] = d;
	hash[a] = s;
	hash[u] -= 1;
	cout << hash[b] << " " << hash[a] << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int T = scanner.nextInt();
        int minCost = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int c = scanner.nextInt();
            int t = scanner.nextInt();
            if (t <= T) minCost = Math.min(minCost, c);
        }
        if (minCost != Integer.MAX_VALUE) System.out.println(minCost);
        else System.out.println("TLE");
    }
}


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

int main(){
  ll n,i;
  cin >> n;
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  
  ll s=0,c=1;
  for(i=1;i<n;i++){
    if(a.at(i)==a.at(i-1)){
      c++;
    }else{
      if(c>=a.at(i-1)){
        s += c-a.at(i-1);
      }else{
        s += c;
      }
      c=1;
    }
    //cout << c << ',' << s << endl;
  }
  
  if(c>=a.at(n-1)){
    s += c-a.at(n-1);
  }else{
    s += c;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3972
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;

/*
int N, M;
int a[100000];
int main() {
	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a, a + N);

	for (int i = 0; i < M; i++) {
		int b, r;
		cin >> b >> r;

		for (int j = 0; j < b; j++) {
			if (a[j] > r) break;
			else {
				a[j] = r;
			}
		}

		sort(a, a + N);
	}

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += a[i];
	}

	cout << ans << endl;


	return 0;
}
*/


long long ok[100002] = {};
int main() {
	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;

		ok[l] += 1;
		ok[r + 1] += -1;
	}

	for (int i = 1; i < N; i++) {
		ok[i] += ok[i - 1];
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (ok[i] == M) {
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int H, W;
	int h, w;
	scanf("%d %d %d %d", &H, &W, &h, &w);

	int sum = H * W;
	sum -= W * h;
	H -= h;
	sum -= H * w;
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl "\n"
const int MAXN=3e5+5;
const int M= 1e9+7;

int main(){	
	
	int n,k;
	sfi(n) sfi(k)

	ll ans=0;

	for(ll i=k;i<=n+1;i++){
		ll sm=((i-1)*(i))/2;
		ll large=((2*n-i+1)*i)/2;

		ll dist=(large-sm)+1;

		//cout<<dist<<endl;

		ans=ans+dist%M;

		if(ans>M){
			ans%=M;
		}
	}

	pfln(ans)
	
	return 0;	
}

Measured memory_bytes: 3756
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
all_order=[]
def dfs(a):
  if len(a)==n:
    all_order.append(a)
  else:
    for i in range(n):
      if i in a:continue
      dfs(a+[i])
dfs([])
ans=0
for od in all_order:
  x,y=xy[od[0]]
  for i in od[1:]:
    nx,ny=xy[i]
    ans+=((x-nx)**2+(y-ny)**2)**0.5
    x,y=nx,ny
print(ans/len(all_order))


Measured memory_bytes: 83180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include <math.h>
#include<vector>
#include<stack>
#include<math.h>
#include<malloc.h>
#define INF 0x3f3f3f3f
#define maxn 2000006
#define ll long long
#define k 181
#define Is 2.00
#define im 400
using namespace std;
int s[10]={111,222,333,444,555,666,777,888,999};
int n,m;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<9;i++)
    {
        if(s[i]>=n)
            {cout<<s[i]<<endl;
            break;
            }

    }



}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");

		int answer = 3;

		if(strlist[0].equals(strlist[1])){
			answer = answer - 1;
		}

		if(strlist[1].equals(strlist[2])){
			answer = answer - 1;
		}

		if(strlist[2].equals(strlist[0])){
			answer = answer - 1;
		}

		if(answer == 0){
			answer = 1;
		}

		System.out.println(answer);

	}

}


Measured memory_bytes: 8148
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

A, B = i_l()

print(lcm(A,B))


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
  int money,change,count;
  money=1;
  while(1)
  {
    scanf("%d",&money);
    if(money==0) break;
    count=0;
    change=1000-money;
    if(change>=500){change-=500;count++;}
    while(change>=100)
    {
      change-=100;
      count++;
    }
    while(change>=50)
    {
      change-=50;
      count++;
    }
    while(change>=10)
    {
      change-=10;
      count++;
    }
    while(change>=5)
    {
      change-=5;
      count++;
    }
    while(change>=1)
    {
      change-=1;
      count++;
    }
    printf("%d\n",count);
  }
  return 0;
}



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

int main() {
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i = 0;i<n;i++)
    cin>>arr[i];
    
    sort(arr,arr+n);
    
    ll res = 0;
    for(int i = 0;i<k;i++)
    res += arr[i];
    
    cout<<res<<"\n";
    
	return 0;
}

Measured memory_bytes: 3644
n = int(input())
h = list(map(int,input().split()))

hmax_rui = [0]*n
hmax_rui[0] = h[0]
for i in range(1,n):
    hmax_rui[i] = max(hmax_rui[i-1],h[i])

cnt = 0
for i in range(n):
    if h[i]==hmax_rui[i]:
        cnt +=1
print(cnt)


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

int even(long long n){
    if(n%2 == 0){
        return 1;
    }else{
        return -1;
    }
}

int main(){
    int N;
    long long a;
    cin >> N;
    long long b_list[200010];
    int j = N/2;
    for(int i=0; i<N; i++){
        cin >> a;
        if(N%2 == 0){
            j += even(i)*i;
        }else{
            j -= even(i)*i;
        }
        b_list[j] = a;
    }
    for(int i=0; i<N-1; i++){
        cout << b_list[i] << " ";
    }
    cout << b_list[N-1];
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3712
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
const lo mod1 = 13;

int n,m,b[li],a[li],k,flag,t,tut=1,dizi[li],l,dp[li][55];
int cev;
string s;
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int add1(int x,int y){
	if(x+y>=mod1)return x+y-mod1;
	return x+y;
}

inline int mul(int x,int y){
	return (x%mod1)*(y%mod1)%mod1;
}

inline int f(int sira,int kac){
	//~ cout<<sira<<" "<<kac<<endl;
	int cevv=0;
	if(sira>=l+1){
		//~ cout<<kac<<endl;
		if(kac%13==5)return 1;
		return 0;
	}
	if(~dp[sira][kac])return dp[sira][kac];
	if(s[sira]!='?'){
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],s[sira]-'0'))));
	}
	else{
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],0))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],1))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],2))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],3))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],4))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],5))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],6))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],7))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],8))));
		cevv=add(cevv,f(sira+1,add1(kac,mul(dizi[sira],9))));
	}
	return dp[sira][kac]=cevv;
}

int main(void){
	memset(dp,-1,sizeof(dp));
	fio();
	cin>>s;
	l=(int)s.size()-1;
	for(int i=l;i>=0;i--){
		dizi[i]=tut%13;
		tut=(tut*10)%13;
	}
	printf("%d\n",f(0,0));
	return 0;
}


Measured memory_bytes: 116816
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> ans(n);
  ans[0]=0;
  rep(i,n){
    if(i%2)
      ans[0]-=a[i];
    else
      ans[0]+=a[i];
  }
  for(int i=1; i<n; i++)
    ans[i] = (a[i-1]-ans[i-1]/2)*2;
  rep(i,n){
    if(i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[1010][1010];
int dx[4]={0,0,-1,1}, dy[4]={-1,1,0,0};
int main(){
    int n, m;
    while(cin>>n>>m){
        ll ans=0;
        set<pair<int, int> > st;
        for(int i=0; i<n; ++i){
            scanf("%s",s+i);
            for(int j=0; j<m; ++j){
                if(s[i][j]=='#'){
                    st.insert(mk(i,j));
                }
            }
        }
        bool l=1;
        int xx, yy;
        while(l){
            set<pair<int, int> > st1;
            l=0;
            for(auto it:st){
                for(int i=0; i<4; ++i){
                    xx=it.fs+dx[i];
                    yy=it.sc+dy[i];
                    if(xx<0||xx>=n||yy<0||yy>m)
                        continue;
                    if(s[xx][yy]=='.'){
                        s[xx][yy]='#';
                        st1.insert(mk(xx,yy));
                    }
                }
            }
            st=st1;
            if(st1.size()){
                l=1;
                ++ans;
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 49024
n=int(input())
s=input()
st=[str(i).zfill(3)for i in range(1000)]
dp=[0]*1000
for i in s:
  for j in range(1000):
    if dp[j]<3:
      if st[j][dp[j]]==i:dp[j]+=1
print(dp.count(3))

Measured memory_bytes: 41580