akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

vector<vector<array<int,2>>> v(200020);
int c[200020];

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }
    int size(int A){
        return -parent[root(A)];
    }
    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 
        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

const int MAX = 210000;
const int mod = 1000000007;

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

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

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

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


    int n,x,y;
    cin>>n>>x>>y;
    UnionFind uni(n);
    array<int,3> b[n];
    for(int i=0;i<n;i++){
        int a,w;
        cin>>a>>w;
        a--;
        v[a].push_back({w,i});
        c[i] = a;
        b[i] = {w,a,i};
    }

    // same color
    for(int i=0;i<n;i++){
        if(v[i].size()==0) continue;
        sort(v[i].begin(),v[i].end());
        int r = 0;
        for(int j=0;j<v[i].size();j++){
            while(r<v[i].size() && v[i][r][0] + v[i][j][0] <= x){
                uni.unite(v[i][j][1],v[i][r][1]);
                r++;
            }
        }
    }

    // different color
    sort(b,b+n);
    queue<int> q;
    int r = 0;
    for(int i=0;i<n;i++){
        if(q.size() && b[i][1]!=b[i-1][1]){
            while(q.size()){
                int p = q.front();
                q.pop();
                if(b[p][0] + b[i][0] <= y) uni.unite(b[i][2],b[p][2]);
            }
        }
        while(r<n && b[r][0]+b[i][0] <= y){
            if(b[i][1] == b[r][1]) q.push(r);
            else uni.unite(b[r][2],b[i][2]);
            r++;
        }
    }
    map<int,ll> mp[n];
    for(int i=0;i<n;i++){
        mp[uni.root(i)][c[i]]++;
    }
    ll ans = 1;
    COMinit();
    for(int i=0;i<n;i++){
        if(i != uni.root(i)) continue;
        ll ret = 1;
        ll sum = 0;
        for(auto j:mp[i]){
            sum += j.second;
            ret *= finv[j.second];
            ret %= mod;
        }
        ret *= fac[sum];
        ret %= mod;
        ans *= ret;
    }
    cout << ans << endl;

}

Measured memory_bytes: 40064
N_data = STDIN.gets.to_i
a_data = STDIN.gets

a_data = a_data.split(" ")
a_data = a_data.map(&:to_i)

i = -100
j = scoa = 0

tensu = Array.new(200)

loop{
    if i > 100
        break
    else
        a_data.each{ |data|
            scoa = scoa + (data - i) * (data - i)
        }
        tensu[j] = scoa
        scoa = 0
    end
    i = i + 1
    j = j + 1
}

p tensu.min

Measured memory_bytes: 1788
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long K = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        sc.close();

        long sum = 1+K;
        if(A < B){
            long sum1 = 1;
            if(A > sum1){
                K -= (A-sum1);
                sum1 = A;
            }
            sum1 += (B-A)*(K/2);
            if(K%2 == 1)
                sum1 += 1;
            sum = Math.max(sum, sum1);
        }
        System.out.println(sum);
   }
}

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

int main ()
{
	int n, cnt;
  	cin >> n;
  	string lucky;
  	cin >> lucky;
  	cnt == 0;
  	for (int i = 0; i < 1000; i++)
    {
    	vector<int> f(3);
      	f = {i / 100,(i / 10) % 10, i % 10};
      	int c = 0;
      	for (int j = 0; j < n; j++)
        {
        	if (lucky.at(j) == '0' + f.at(c))
            {
            	c++;
            }
          	if (c == 3)
            {
            	break;
            }
        }
      	if (c == 3)
        {
        	cnt++;
        } 
    }
  	cout << cnt << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        if (N == 1) {
            System.out.println("Yes");
            return;
        }

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

        for (int i=N-1;i>0;i--) {
            if (H[i-1] - H[i] > 1) {
                System.out.println("No");
                return;
            }
            if (H[i-1] - H[i] > 0) {
                H[i-1] -= 1;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 49844
fn main() {
  proconio::input! {
    a:usize,
    mut b:usize,
    mut c:usize,
    k:usize,
  }
  for _ in 0..k {
    if a>=b {
      b*=2;
    } else if b>=c {
      c*=2;
    } else {
      break;
    }
  }
  println!("{}",if a<b && b<c {"Yes"} else {"No"});
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll h,w;
  while(cin>>h>>w){
    if(h==0&&w==0)break;

    rep(i,0,h){
      rep(j,0,w)cout<<'#';
      cout<<endl;
    }
    cout<<endl;
  }


  return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
int main(void)
{
	int a[3];
	int i,j,x,min;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	x=0;
	min=100;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	printf("%d\n",a[0]+a[1]);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 9223372036854775807
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int n,k;
  cin >> n >> k;
  vint x(n);
  vint y(n);
  vint xary(n);
  vint yary(n);
  rep(i,0,n){
    cin >> x[i] >> y[i];
    xary[i] = x[i];
    yary[i] = y[i];
  }
  int ans = INF;
  sort(xary.begin(),xary.end());
  sort(yary.begin(),yary.end());
  rep(xi,0,n){
    rep(xj,xi+1,n){
      rep(yi,0,n){
        rep(yj,yi+1,n){
          int tmp = 0;
          rep(s,0,n){
            if(xary[xi] <= x[s] && x[s] <= xary[xj] && yary[yi] <= y[s] && y[s] <= yary[yj]){
              tmp++;
            }
            if(tmp >= k){
              ans = min(ans,(xary[xj] - xary[xi])*(yary[yj] - yary[yi]));
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
C = []
for i in range(3):
    C.append(list(map(int, input().split())))
A = [0]
B = [C[0][i] - A[0] for i in range(3)]
for i in range(1, 3):
    A.append(C[i][0] - B[0])
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if a + b != C[i][j]:
            print("No")
            exit()
print("Yes")

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

def gcd(s,t):
  if(s>=t):
    m = s
    n = t
  else:
    m = t
    n = s
  while True:
    if(m%n == 0):
      return n
    else:
      temp = n
      n = m % n
      m = temp

f = int(a*b/gcd(a,b))
print(f)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main()
{
    int n;
    cin >> n;
    vector<int> stones(n);
    for (int &a : stones)
    {
        cin >> a;
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j : {i + 1, i + 2})
        {
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    bool f = false;
    for(int i=A[N-1]+1; i<=B[0]; i++) {
        if(i>X && i<Y) {
            f = true;
            break;
        }
    }

    if(f) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int W,H,x,y,r,a,b,c,d;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    a=x-r;
    b=x+r;
    c=y-r;
    d=y+r;
    
    if(a >= 0 && b <= W && c >= 0 && d <= H) printf("Yes\n");
    else printf("No\n");
    
    return(0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
typedef unsigned long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

int n,k;
cin>>n>>k;
lli ans=k;
//if(n==1){cout<<k;return 0;}
for(int i=1;i<n;i++){
    ans*=k-1;
}
cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 2e5 + 7;
struct info
{
    LL val;
    int idx;
    bool operator<(const info &rhs)const
    {
        return val < rhs.val || (val == rhs.val && idx < rhs.idx);
    }
};
info P[N];
int arr[N], T[N];

void add(int k, int v)
{
    while (k < N)
    {
        T[k] += v;
        k += (k & -k);
    }
}
int getsum(int k)
{
    int r = 0;
    while (k)
    {
        r += T[k];
        k -= (k & -k);
    }
    return r;
}
int main(void)
{
    int n, k, i;
    scanf("%d%d", &n, &k);
    for (i = 1; i <= n; ++i)
    {
        scanf("%d", &arr[i]);
        arr[i] -= k;
    }
    LL pre = 0LL;
    for (i = 1; i <= n; ++i)
    {
        pre = pre + arr[i];
        P[i].val = pre;
        P[i].idx = i;
    }
    sort(P + 1, P + 1 + n);
    LL ans = 0LL;
    for (i = 1; i <= n; ++i)
    {
        if (P[i].val >= 0LL)
            ++ans;
        add(P[i].idx,1);
        ans+=getsum(P[i].idx-1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, re = 0, ac = 0, wa = 0, tl = 0;
  cin >> n;
  vector<string> s(n);
  REP(i, n) { cin >> s[i]; }
  REP(i, n) {
    if (s[i] == "AC") ac++;
    if (s[i] == "WA") wa++;
    if (s[i] == "TLE") tl++;
    if (s[i] == "RE") re++;
  }
  cout << "AC x " << ac << "\n";
  cout << "WA x " << wa << "\n";
  cout << "TLE x " << tl << "\n";
  cout << "RE x " << re << "\n";
  return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll mul(ll x,ll y){
    return x*y%MOD;
}
ll add(ll x,ll y){
    ll ret = x+y;
    if (ret >= MOD) ret -= MOD;
    return ret;
}
ll fpow(ll a,ll b){
    ll ret = 1;
    while (b) {
        if (b&1) ret = mul(ret,a);
        a = mul(a,a);
        b >>= 1;
    }
    return ret;
}
ll cnt(ll l,ll r){
    return (l+r) * (r-l+1) / 2;
}
int main(){
    IOS();
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i=k;i<=n+1;i++) {
        ll l = cnt(0,i-1), r = cnt(n-i+1,n);
        ll gain = (r-l+1)%MOD;
        ans = add(ans,gain);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#メモ化したもの(修正版)
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
   dp.append([-1]*(w+1))
def rec(i,j):
   if dp[i][j]>=0:
       return dp[i][j]
   if i==n:
       res=0
   elif j<a[i][0]:
       res=rec(i+1,j)
   else:
       res=max(rec(i+1,j),rec(i+1,j-a[i][0])+a[i][1])
   dp[i][j]=res
   return res
print(rec(0,w))


Measured memory_bytes: 141956
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 999999999999999999
#define endl "\n"
#define MOD 1000000007


 
void func(){

ll n;
cin>>n;

cout<<setprecision(10)<<2*3.14*n<<endl;
}




    
int main(){
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
     
          /*#ifndef ONLINE_JUDGE
          freopen("input.txt", "r" , stdin);
          freopen("output1.txt", "w" , stdout);
          #endif*/
     
       ll t=1;
       //cin>>t;
       while(t--)
       func();
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,k;
    cin >> n >> k;
    int a = 1,b = 1,ans = 1;
    if(abs(n - k) >= 2){
        cout << 0 << endl;
        return 0;
    }
    if(abs(n - k) == 1){
        for(int i = 1; i <= n; i++)
            a = a * i % (int)(1e9 + 7);
            for(int i = 1; i <= k; i++)
            b = b * i % (int)(1e9 + 7);
            ans = a * b % (int)(1e9 + 7);
    }
    if(n == k){
        for(int i = 1; i <= n; i++)
        a = a * i % (int)(1e9 + 7);
        for(int i = 1; i <= k; i++)
        b = b * i % (int)(1e9 + 7);
        ans = (a * b % (int)(1e9 + 7)) * 2 % (int)(1e9 + 7);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

macro_rules! line {
    () => {{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf
    }};
}
macro_rules! line_as_vec {
    ( $t:ty ) => {
        line!()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    };
}

fn main() {
    let v = line_as_vec!(u32);
    let (m, k) = (v[0], v[1]);

    if 2u32.pow(m) <= k {
        println!("-1");
    } else if m == 1 && k == 1 {
        println!("-1");
    } else if m == 1 && k == 0 {
        println!("1 0 0 1");
    } else {
        for i in 0..2u32.pow(m) {
            if i != k {
                print!("{} ", i);
            }
        }
        print!("{} ", k);
        for i in (0..2u32.pow(m)).rev() {
            if i != k {
                print!("{} ", i);
            }
        }
        println!("{}", k);
    }
}


Measured memory_bytes: 5884
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.next().split("");
    String[] T = sc.next().split("");
    String ret = "Yes";
    for (int i = 0; i < S.length; i++) {
      if (!S[i].equals(T[i])) {
        ret = "No";
        break;
      }
    }
    System.out.println(ret);
  }
}


Measured memory_bytes: 27008
l = input().split(' ')
N = int(l[0])
Y = int(l[1])
J = 0
L = [-1,-1,-1]
if N*10000 < Y:
    J = 1

if J == 0:
    n1=0
    y = Y // 10000
    while n1 <= y:
        n2 = (Y - 1000 * N - 9000 * n1)/4000
        if (n2 %1 == 0) and (n1+n2 <= N) and n2 >= 0:
            L[0] = n1
            L[1] = n2
            L[2] = N - n1 - n2
            break
        else:
            n1 += 1

print(str(int(L[0]))+' '+str(int(L[1]))+' '+str(int(L[2])))

Measured memory_bytes: 3064
n=input()
k=int(input())

n1,n2,n3=int(n[-1]),0,0
a1,a2,a3=9,0,0
for i in n[-2::-1]:
    i=int(i)
    if i!=0:
        n1,n2,n3=i+a1,(i-1)*a1+n1+a2,(i-1)*a2+n2+a3
    a1,a2,a3=9+a1,9*a1+a2,9*a2+a3
print([n1,n2,n3][k-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main(){
    int a;
    ll b,n;
    cin >> a >> b >> n;
    ll m;
    if(n >= b)m = b-1;
    else m = n;
    cout << (ll) (a*m)/b << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,l;
  cin >> n >> l;
  ll ans = 0;
  ll mi = 1e9;
  ll less;
  REP(i,n){
    ans += l+i;
    if(mi>abs(l+i)){
      mi = abs(l+i);
      less = l+i;
    }
  }
  ans -= less;
  cout << ans<< endl;
  return 0;
}


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

int res[200001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,t;

	cin >> n;

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

	for(int i=1;i<=n;i++)
	{
		cout << res[i] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 4388
//inlclude前用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<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	string s;

	if (a + b == 15) {
		s += "+";
	} else if (a*b == 15) {
		s += "*";
	} else {
		s += "x";
	}
	cout << s << endl;

	return 0;
	
}





Measured memory_bytes: 256
from sys import stdin
import operator
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def ccw(a, b, c):
    b -= a
    c -= a
    if cross(b, c) > 0:  # counter clockwise
        return 1
    elif cross(b, c) < 0:  # clockwise
        return -1
    elif dot(b, c) < 0:  # c--a--b on line
        return -2
    elif abs(b) < abs(c):  # a--b--c on line
        return 2
    return 0


# http://www.prefield.com/algorithm/geometry/convex_hull.html
def convex_hull(ps):
    n = len(ps)
    k = 0
    ps.sort(key=operator.attrgetter('imag'))
    ch = [None] * 2 * n
    # lower-hull
    for i in range(n):
        while k >= 2 and ccw(ch[k-2], ch[k-1], ps[i]) <= 0:
            k -= 1
        ch[k] = ps[i]
        k += 1
    # upper-hull
    t = k + 1
    for i in reversed(range(n - 1)):
        while k >= t and ccw(ch[k-2], ch[k-1], ps[i]) <= 0:
            k -= 1
        ch[k] = ps[i]
        k += 1
    return ch[:k - 1]


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]

p = convex_hull(p)
print(len(p))
for pi in p:
    print(int(pi.real), int(pi.imag))

Measured memory_bytes: 62348
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(A, B, C, K));

        sc.close();
    }

    static int solve(int A, int B, int C, int K) {
        return A + B + C + Math.max(Math.max(A, B), C) * ((1 << K) - 1);
    }
}

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

int main(){

    int N, M = 0;
    cin >> N >> M;

    int ans = N * (N-1) / 2 + M * (M-1) / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, $k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
f = gets.split.map(&:to_i).sort.reverse
$cost = []
n.times do |i|
  $cost << [a[i], f[i], a[i] * f[i]]
end
$cost.sort_by! { |c| -c[2] }

def check(x) # x以下のコストにできるか
  cnt = 0
  $cost.each do |c|
    if c[2] > x
      cnt += (c[0] - x / c[1])
    else
      break
    end
  end
  cnt <= $k
end

ok = 10**18
ng = -1
while (ok - ng).abs > 1
  mid = (ok + ng) / 2
  if check(mid)
    ok = mid
  else
    ng = mid
  end
end
p ok


Measured memory_bytes: 46776
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; long long D, A; 	
	cin >> N >> D >> A; 
	pair<long long, long long> M[200010]; 
	for(int i = 0; i < N; i++) cin >> M[i].first >> M[i].second; 
	sort(M, M+N); 
	long long H[200010] = {}; 
	long long X[200010] = {}; 
	for(int i = 1; i <= N; i++){
		X[i] = M[i-1].first; H[i] = M[i-1].second; 
	}
	X[0] = -1e18; 
	long long num[200010] = {}; 
	long long sum[200010] = {}; 
	for(int i = 1; i <= N; i++){
		int a = i-1; 
		int b = lower_bound(X, X+N+1, X[i] - D*2) - X; 
		long long c = sum[a] - sum[b-1];
		if(H[i] <= c * A){
			sum[i] = sum[i-1]; continue; 
		}
		else{
			num[i] = (H[i] - c * A + A - 1) / A; 
			sum[i] = sum[i-1] + num[i]; 
		}
	}
	cout << sum[N] << endl; 
	/*for(int i = 0; i <= N; i++) cout << num[i] << " " << sum[i] << endl; */
}

Measured memory_bytes: 8064
S = input()
count = 0
nowW = 0
WB = 0
for i in range(len(S)):
    if S[i] == 'W':
        count += 1
for i in range(len(S)):
    if S[i] == 'W':
        nowW += 1
    elif S[i] == 'B':
        WB += count - nowW
print(WB)


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];

    sort(ALL(d));
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int sum[200010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    rep(i, N) sum[i + 1] += sum[i] + A[i];
    int ans = INF2;
    REP(i, 2, N - 2) {
        int L = sum[i];
        int R = sum[N] - sum[i];
        auto itr1 = upper_bound(sum, sum + i, L/2);
        auto itr2 = upper_bound(sum + i, sum + N, L + R/2);
        --itr1; --itr2;
        rep(s, 2) {
            rep(t, 2) {
                //cout << *(itr1 + s) << " " << L - *(itr1 + s) << " " << *(itr2 + t) - L << " " << R - (*(itr2 + t) - L) << endl;
                int X1 = max({*(itr1 + s), L - *(itr1 + s), *(itr2 + t) - L, R - (*(itr2 + t) - L)});
                int X2 = min({*(itr1 + s), L - *(itr1 + s), *(itr2 + t) - L, R - (*(itr2 + t) - L)});
                ans = min(ans, X1 - X2);
            }
        }
    }
    cout << ans << endl;

    return 0;
}
// 3 5 | 2 6

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

int main() {

  int X;

  cin >>X;
  

 if(X<600){

   cout << 8 << endl;
 }
 else if(X<800){

   cout << 7 << endl;
 }
   else if(X<1000){

   cout << 6 << endl;
 }
  
   else if(X<1200){

   cout << 5 << endl;
 }
   else if(X<1400){

   cout << 4 << endl;
 }
   else if(X<1600){

   cout << 3 << endl;
 }
   else if(X<1800){

   cout << 2 << endl;
 }
   else if(X<2000){

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


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

      
 public static void main(String[] args) {
    
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int K = in.nextInt();
    long sum = 0;
    for(int i = 1; i <= K; i++) {
      for(int j = 1; j <= K; j++) {
          for(int k = 1; k <= K; k++) {
              sum += gcd(i, gcd(j, k));
          }
      }
    }
    
    System.out.println(sum);
    
  }
  
  private static int gcd(int a, int b) {
      while( a != b) {
          if(a > b){
              a = a - b;
          }
          else {
              b = b - a;
          }
      }
      
      return a;
  }
  
  
}

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

using namespace std;

typedef long long ll;

int a[100005],b[100005],n;

namespace Heap {

int ch[200005][2],num[200005],tot;
int d[200005];

int newnode(int x) {
  num[++tot]=x;
  ch[tot][0]=ch[tot][1]=0;
  d[tot]=1;
  return tot;
}

int merge(int x,int y) {
  if (!x) return y;
  if (!y) return x;
  if (a[num[x]]>a[num[y]]) swap(x,y);
  ch[x][1]=merge(ch[x][1],y);
  if (d[ch[x][0]]<d[ch[x][1]]) swap(ch[x][0],ch[x][1]);
  d[x]=d[ch[x][1]]+1;
  return x;
}

int pop(int x) {
  return merge(ch[x][0],ch[x][1]);
}

}

int root[100005];

namespace SETS {

int fa[100005],size[100005];
ll sum[100005];

void init(int n) {
  for(int i=1;i<=n;i++) {
  	fa[i]=i;
  	size[i]=1;
  	sum[i]=b[i];
  }
}

int find_father(int x) {
  return (fa[x]==x)?x:fa[x]=find_father(fa[x]);
}

bool check(int x,int y) {
  x=find_father(x);y=find_father(y);
  return x!=y;
}

void merge(int x,int y) {
  x=find_father(x);y=find_father(y);
  if (x==y) return;
  fa[y]=x;
  sum[x]+=sum[y];
  size[x]+=size[y];
  root[x]=Heap::merge(root[x],root[y]);
}

}

bool vis[100005];

bool bfs(int s,int d) {
  vis[s]=1;
  while (root[s]) {
  	int x=Heap::num[root[s]];
  	if (!SETS::check(s,x)) {
  		root[s]=Heap::pop(root[s]);
  		continue;
	  }
  	if (a[x]>d+SETS::sum[s]) break;
  	vis[x]=1;
  	root[s]=Heap::pop(root[s]);
  	SETS::merge(s,x);
  }
  return SETS::size[s]==n;
}

vector <int> e[100005];

bool check(int d) {
  memset(vis,0,sizeof(vis));
  Heap::tot=0;
  SETS::init(n);
  for(int i=1;i<=n;i++) {
  	root[i]=0;
  	for(int j=0;j<e[i].size();j++) {
  		int u=Heap::newnode(e[i][j]);
  		root[i]=Heap::merge(root[i],u);
	  }
  }
  for(int i=1;i<=n;i++)
    if (a[i]<=d&&!vis[i]&&bfs(i,d)) return 1;
  return 0; 
}

int main() {
  int m;
  scanf("%d%d",&n,&m);
  int l=0,r=0;
  ll s=0;
  for(int i=1;i<=n;i++) {
    scanf("%d%d",&a[i],&b[i]);
    a[i]-=b[i];
    s+=b[i];
    r=max(r,a[i]);
  }
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[x].push_back(y);
  	e[y].push_back(x);
  }
  while (l<r) {
  	int mid=((l+r)>>1);
  	if (check(mid)) r=mid; else l=mid+1;
  }
  printf("%lld\n",s+l);
  return 0;
}

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

long long MOD = 1e9 + 7;

vector<vector<long long> > matrix;

vector<vector<long long> > mul(vector<vector<long long> > a, vector<vector<long long> > b)
{
    int n = a.size();
    vector<vector<long long> > ans;
    
    for (int i = 0; i < n; i++)
    {
        vector<long long> v;
        for (int j = 0; j < n; j++)
        {
            v.push_back(0);
            for (int k = 0; k < n; k++)
            {
                long long f = (a[i][k] * b[k][j]) % MOD;
                v[j] += f;
                v[j] %= MOD;
            }
        }
        ans.push_back(v);
    }
    return ans;
}

vector<vector<long long> > binpow(long long p)
{
  if (p == 1) return matrix;
  if (p % 2 == 0)
  {
    vector<vector<long long> > v = binpow(p / 2);
    return mul(v, v);
  }
  else
  {
    return mul(binpow(p - 1), matrix); 
  }
}

void solve()
{
  int n; cin >> n;
  long long k; cin >> k;
  
  for (int i = 0; i < n; i++)
  {
    vector<long long> v;
    for (int j = 0; j < n; j++)
    {
      int x; cin >> x;
      v.push_back(x);
    }
    matrix.push_back(v);
  }
  
  long long total = 0;
  
    vector<vector<long long> > b = binpow(k);
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            total += b[i][j];
            total %= MOD;
            //cout << b[i][j] << ' ';
        }
        //cout << endl;
    }
    
    cout << total << endl;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 1664
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int N = nextInt();
			int M = nextInt();
			int P = nextInt();
			if (N == 0) {
				break;
			}

			int[] tickets = new int[N];// 売れたチケットの数
			int sum_tickets = 0;
			for (int i = 0; i < tickets.length; i++) {
				tickets[i] = nextInt();
				sum_tickets += tickets[i];
			}

			if (tickets[M - 1] == 0) {
				System.out.println(0);
			} else {
				int award = sum_tickets * (100 - P) / tickets[M - 1];
				System.out.println(award);
			}
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

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

struct road {
	int cost;
	int city1;
	int city2;
};

int root[100000];


int getRoot(int city)
{
	if (root[city] == city) return city;
	return getRoot(root[city]);
}

void setRoot(int city, int to)
{
	if (root[city] != city) {
		setRoot(root[city], to);
	}
	root[city] = to;
	return;
}

bool cost_sort(const road& a, const road& b)
{
	return a.cost < b.cost;
}

int main(void) {
	int N;
	cin >> N;
	vector <pair<int, int> > X;
	vector <pair<int, int> > Y;
	long long cost[2] = {0};
	for (int i = 0; i < N; i++) {
		int x, y;		
		cin >> x >> y;
		X.push_back(make_pair(x, i));
		Y.push_back(make_pair(y, i));
	}

	std::sort(X.begin(), X.end());
	std::sort(Y.begin(), Y.end());

	vector <road> R;
	for (int i = 0; i < N-1; i++) {
		road r;
		r.cost  = X[i+1].first - X[i].first;
		r.city1 = X[i+1].second;
		r.city2 = X[i].second;
		R.push_back(r);

		r.cost  = Y[i+1].first - Y[i].first;
		r.city1 = Y[i+1].second;
		r.city2 = Y[i].second;
		R.push_back(r);
	}

	std::sort(R.begin(), R.end(), cost_sort);

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

	long long total_cost = 0;
	for (int i = 0; i < R.size(); i++) {
		int rootA = getRoot(R[i].city1);
		int rootB = getRoot(R[i].city2);

		if (rootA == rootB) continue;

		total_cost += R[i].cost;
		setRoot(R[i].city1, rootB);
	}
	cout << total_cost << endl;
	return 0;
}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){
  

  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  
  int tmp1=60*h1+m1;
  int tmp2=60*h2+m2;
  
 
  if (tmp1>=tmp2){
    tmp2+=1440;
  }
  
  cout<<(tmp2-tmp1-k)<<endl;
  
  
  
  

}























Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1e18;
int main() {
	int n;
	cin >> n;
	vector<ll> a(n+10);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1;
	rep(i, n) {
		double limit = INF / a[i];
		if (ans > limit) {
			//cout << limit << endl;
			ans = -1;
			break;
		}
		ans *= a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3984
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <string>

#define SCAN_INT(i) scanf("%d", i)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define PRINT_INT(i) printf("%d\n", i)
#define PRINT_TWO_INT(i, j) printf("%d %d\n", i, j)
#define PRINT_THREE_INT(i, j, k) printf("%d %d %d\n", i, j, k)

int main()
{
    char b;
    char ans;
    scanf("%c", &b);
    if (b == 'A')
        ans = 'T';
    if (b == 'T')
        ans = 'A';
    if (b == 'G')
        ans = 'C';
    if (b == 'C')
        ans = 'G';

    printf("%c", ans);
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      m: usize,
      k: usize,
    }
    if m == 1 && k >= 1 {
        if k >= 1 {
            return println!("-1");
        }
    }
    let mm = 2usize.pow(m as u32);
    if k == 0 {
        for i in 0..mm {
            print!("{} ", i);
            print!("{} ", i);
        }
        println!();
        return;
    }
    if k >= mm {
        return println!("-1");
    }

    use std::collections::VecDeque;
    let mut q = VecDeque::new();
    q.push_back(k);
    for i in 1..mm {
        if i == k {
            continue;
        }
        q.push_front(i);
        q.push_back(i);
    }
    let ans = q.into_iter().collect::<Vec<usize>>();

    print!("{} {} {} ", 0, k, 0);
    for a in ans {
        print!("{} ", a);
    }
    println!();
}


Measured memory_bytes: 8952
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int t = 1;
	//cin>>t;
	while(t--)
	{
		int a,b;
		cin>>a>>b;
		cout<<(a*b)<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3692
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		System.out.println(Math.pow(s.nextInt()/3.0,3));
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return (cur+d==to)||(d<0^cur+d<to);
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, M;
    cin >> N >> M;
    map<ll, ll> amari;
    amari[0] = 1;
    ll wa = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll A;
        cin >> A;
        wa = (wa + A) % M;
        ans += amari[wa];
        amari[wa]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll h,w;
    in>>h>>w;
    if(h==1||w==1) cout<<1<<endl;
    else cout<<(h*w+1)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> ans;
  while(ans.size()<N){
    for(int i=N-1-ans.size();i>=0;i--){
      if(v[i]==i+1){
        ans.push_back(v[i]);
        for(int j=i;j<N;j++)v[j]=v[j+1];
        break;
      }
      if(i==0){cout<<-1<<endl;return 0;}
    }
  }
  reverse(ans.begin(),ans.end());
  for(int p:ans)cout<<p<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

struct UnionFind{
  vector<int> Par;

  //N個の独立した根として初期化
  UnionFind(int N) : Par(N) {
    for(int i = 0; i < N; i++) Par[i] = i;
  }

  //どこの根に属するか得る再帰関数
  int root(int X){
    if( Par.at(X) == X ) return X;
    else return Par.at(X) = root(Par.at(X));
  }

  //XとYが同じ根に属するか判定
  bool same(int X, int Y){
    return root(X) == root(Y);
  }

  //XとYの木を合体
  void unite(int X, int Y){
    X = root(X);
    Y = root(Y);
    if( X == Y ) return;
    Par.at(X) = Y;
  }
};


signed main(){
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for( int i = 0; i < M; i++ ){
    int A, B;
    cin >> A >> B;
     A--; B--;
     UF.unite(A, B);
  }

  map<int, int> num;
  for( int i = 0; i < N; i++ ){
    num[UF.root(i)]++;
  }
  int ans = 0;
  for( auto p : num ){
    ans = max(ans, p.second);
  }
  cout << ans << endl;
}


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

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> v(n);
  ll ans=0;
  rep(i,n){
    cin >> a[i] >> b[i];
    v[i]=a[i]+b[i];
    ans-=b[i];
  }
  sort(all(v));
  int i=0;
  while(v.size()){
    if(i%2==0) ans+=v[v.size()-1];
    v.pop_back();
    i++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K, C;
ll pow2[2010];
ll dp[2010][2010];

void solve() {
	cin >> N >> K;
	pow2[0] = 1;
	C = N - K;
	rep(i, 0, N) {
		pow2[i + 1] = pow2[i] * 2 % mod;
	}
	rep(i, 0, C + 1) {
		dp[i][0] = pow2[max(C - 1, 0)];
	}
	rep(k, 1, K) {
		ll tmp = 0;
		rep(i, 1, C + k) {
			ADD(tmp, dp[i][k - 1]);
			dp[i][k] = tmp;
		}
		dp[C + k][k] = (tmp + dp[C + k - 1][k - 1]) % mod;
	}
	// rep(j, 0, K + 1) {
	// 	rep(i, 0, N + 1) {
	// 		debug(i, j, dp[i][j]);
	// 	}
	// }
	cout << dp[N - 1][K - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 31104