akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

ll inf = 1e9+7;
ll func[200010] = {0};
ll inv[200010] = {0};

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			func[i] = 1;
			inv[i] = 1;
		}
		else{
			func[i] = (i*func[i-1])%inf;
			inv[i] = mult(func[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(k==0 || n==k) return 1;
	else return (((func[n]*inv[k])%inf)*inv[n-k])%inf;
}

int H,W,N,r,c,R[3010],C[3010];
vector<pair<int,int>> v;

int main(){
	cin >> H >> W >> N;
	factorial(H+W);
	for(int i=1;i<=N;i++){
		cin >> r >> c;
		v.push_back({r,c});
	}
	sort(v.begin(),v.end());
	v.push_back({H,W});
	ll dp[N+1] = {};
	for(int i=0;i<=N;i++){
		int ri = v[i].first,ci = v[i].second;
		dp[i] = comb(ri+ci-2,ri-1);
		ll sub = 0;
		for(int j=0;j<i;j++){
			int rj = v[j].first,cj = v[j].second;
			if(rj<=ri && cj<=ci) (sub += dp[j]*comb(ri-rj+ci-cj,ri-rj))%=inf;
		}
		(dp[i] += -sub+inf)%=inf;
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 3456
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{



  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long MOD=1000000007l;
  static int INF=10000000;
  static int[] rr=new int[]{1, 0, -1, 0};                                 //rook row move
  static int[] rc=new int[]{0, 1, 0, -1};                                 //rook col move

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes()); }
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //static variables

  //


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    long[][] dp=new long[n][4];
    dp[0][0]=8;dp[0][1]=0;dp[0][2]=1;dp[0][3]=1;
    for(int i=1;i<n;i++){
        dp[i][0]=(dp[i-1][0]*8)%mod;
        dp[i][1]=(((dp[i-1][1]*10)%mod+dp[i-1][2])%mod+dp[i-1][3])%mod;
        dp[i][2]=((dp[i-1][2]*9)%mod+dp[i-1][0])%mod;
        dp[i][3]=((dp[i-1][3]*9)%mod+dp[i-1][0])%mod;
    }
    nl(dp[n-1][1]);

    out.flush();
  }


  public static long powMOD(long n,long k){                 //n-pow(k)
      if(k==1){
          return n%MOD;
      }
      if(k==0){
          return 1;
      }
      long val=powMOD(n,k/2)%MOD;
      if(k%2==0)return ((val%MOD)*(val%MOD))%MOD;
      else return (((val*val)%MOD)*n)%MOD;
  }


}

class Pair{
  int x; int y;
  Pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}


Measured memory_bytes: 102568
#include<stdio.h>
int main()
{
	int n,h[101],a;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(int i=0;i<n+1;i++)
			scanf("%d",&h[i]);
		if(h[1]-h[0]==h[2]-h[1]&&h[3]-h[2]==h[2]-h[1]){
			a=h[1]-h[0];
			for(int i=2;i<n+1;i++){
				if(h[i+1]-h[i]!=a){
					printf("%d\n",h[i+1]);
					break;
				}
			}
		}
		else{
			if(h[4]-h[2]==h[1]-h[0])
				printf("%d\n",h[3]);
			else if(h[4]-h[3]==h[1]-h[0])
				printf("%d\n",h[2]);
			else if(h[4]-h[3]==h[2]-h[0])
				printf("%d\n",h[1]);
			else
				printf("%d\n",h[0]);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

int main(void){
	
	int i,j,n,m;
	char c,s[5]={'S','H','C','D','\0'};
	static int card[4][13];
	scanf("%d\n",&n);
	
	for(i=0;i<n;i++){
		scanf("%c %d\n",&c, &m);
		for(j=0;j<4;j++)
			if(s[j]==c)
				card[j][m-1]=1;
	}
	
	for(i=0;i<4;i++)
		for(j=0;j<13;j++)
			if(card[i][j]==0)
				printf("%c %d\n",s[i],j+1);
	
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

vector <int> prime;
bool sieve[10000000+10]; // 0 means prime
void primeSieve ( int n ) {
    sieve[0] = sieve[1] = 1; 
 
    prime.push_back(2); 
    for(int i = 4; i <= n; i += 2)sieve[i] = 1; 
 
    int sqrtn = sqrt ( n );
    for ( int i = 3; i <= sqrtn; i += 2 ) {
        if ( sieve[i] == 0 ) {
            for ( int j = i * i; j <= n; j += 2 * i ) sieve[j] = 1;
        }
    }
 
    for ( int i = 3; i <= n; i += 2 ) if ( sieve[i] == 0 ) prime.push_back(i);
}
int NOD ( int n ) {
    if(sieve[n] == 0) return 2;
    int sqrtn = sqrt ( n );
    int res = 1;
    for ( int i = 0; i < prime.size() && prime[i] <= sqrtn; i++ ) {
        if ( n % prime[i] == 0 ) {
            int p = 0; // Counter for power of prime
            while ( n % prime[i] == 0 ) {
                n /= prime[i];
                p++;
            }
            sqrtn = sqrt ( n );
            p++; // Increase it by one at end
            res *= p; // Multiply with answer
        }
    }
    if ( n != 1 ) {
        res *= 2; // Remaining prime has power p^1. So multiply with 2/
    }
    return res;
}

void solve()
{
    int n; cin >> n;
    primeSieve(n+5);
    long long ans = 1;
    for(int i = 2; i <= n; i++){
        ans += (long long)i*(long long)NOD(i);
    }
    cout << ans;
    
}
//new line is printed in main()

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


Measured memory_bytes: 17132
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)

Measured memory_bytes: 48484
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; ll D, A; cin >> N >> D >> A;

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

  vector <int> From(N);
  int now = 1;
  for (int i = 0; i < N; i++){
    while (XH[now].first - XH[i].first <= 2 * D){
      now++;
    }
    From[i] = now - 1;
  }

  vector <ll> ans(N), cnt(N);
  for (int i = 0; i < N; i++){
    if (i > 0) cnt[i] += cnt[i - 1];
    ll Rest = XH[i].second - cnt[i] * A;
    
    if (Rest <= 0) continue;

    ans[i] = Rest / A;
    if (Rest % A != 0) ans[i]++;

    cnt[i] += ans[i];
    if (From[i] + 1 < N) cnt[From[i] + 1] -= ans[i];
  }
  
  ll sum = 0;
  for (int i = 0; i < N; i++){
    sum += ans[i];
  }
  cout << sum << endl;

  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  int ans = a*b;
  ans--;
  ans-=a-1;
  ans-=b-1;
  cout << ans << endl;
  
  return 0;
}


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

int main(){
        int n;
        cin >> n;
        vector <int> l(2*n,0);
        int i;
        for(i=0; i<2*n; i++) {
                cin >> l[i];
        }
        sort(l.begin(),l.end());
        int ans=0;
        for(i=0; i<n; i++) ans+=min(l[2*i],l[2*i+1]);
        cout << ans << endl;



        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int a=0,b=0;
  for(int &i:A){
    cin>>i;
    if(i>0)a++;
    else b++;
  }
  sort(A.begin(),A.end());
  vector<pair<int,int>> B;
  if(a==N){
    for(int i=2;i<N;i++){
      B.push_back({A[0],A[i]});
      A[0]-=A[i];
    }
    B.push_back({A[1],A[0]});
    A[1]-=A[0];
    cout<<A[1]<<endl;
    for(pair<int,int> p:B)cout<<p.first<<' '<<p.second<<endl;
    return 0;
  }
  if(b==N){
    for(int i=0;i<N-1;i++){
      B.push_back({A[N-1],A[i]});
      A[N-1]-=A[i];
    }
    cout<<A[N-1]<<endl;
    for(pair<int,int> p:B)cout<<p.first<<' '<<p.second<<endl;
    return 0;
  }
  for(int i=1;i<a;i++){
    B.push_back({A[b-1],A[N-i]});
    A[b-1]-=A[N-i];
  }
  for(int i=0;i<b;i++){
    B.push_back({A[b],A[i]});
    A[b]-=A[i];
  }
  cout<<A[b]<<endl;
  for(pair<int,int> p:B)cout<<p.first<<' '<<p.second<<endl;
}

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

int main() {
    string S;
    cin >> S;
    string yes = "YES";
    string no = "NO";

    string A = "dream";
    // dream, dreamer, erase, eraser
    string pre = "";
    string t = "";
    for (auto s: S) {
        switch (s) {
            case 'd':
            case 'r':
            case 'e':
            case 'a':
            case 'm':
            case 's':
                t.push_back(s);
                break;
            default:
                cout << no << endl;
                return 0;
        }
        if (pre == "" && t == A) {
            pre = A;
            t = "";
        } else if (pre == A) {
            if (t == "erd") {
                pre = "";
                t = "d";
            } else if (t == "era") {
                pre = "";
                t = "era";
            } else if (t == "ere") {
                pre = "";
                t = "e";
            } else if (t == "d") {
                pre = "";
                t = "d";
            }
        } else if (pre == "" && t == "eras") {
            pre = "eras";
            t = "";
        } else if (pre == "eras") {
            if (t == "ed") {
                pre = "";
                t = "d";
            } else if (t == "er") {
                pre = "";
                t = "";
            } else if (t == "ee") {
                pre = "";
                t = "e";
            }
        }
    }
    string remain = pre + t;
    if (remain == "" || remain == "dream" || remain == "dreamer" || remain == "erase" || remain == "eraser") {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
    int N,L;
    int start,end;
    int sum;
    
    cin >> N >> L;
    start = L;
    end = L + N - 1;
    sum = ( N*(start + end) )/2;
    if( start > 0 && end > 0 ){
        sum -= start;
    }else if( start < 0 && end < 0 ){
        sum -= end;
    }
    
    cout << sum << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
S = input()
ans = False
for bit in range(2**(len(S)-1)):
  s = ""
  for i in range(len(S)):
    s += S[i]
    if i<len(S)-1:
      if (bit>>i) & 1:
        s += "+"
      else:
        s += "-"
  ans = eval(s) == 7
  if ans:
    break
print(s+"=7")

Measured memory_bytes: 3060
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

# 累積和を求める
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
# bを全部読む
j = M

for i in range(N + 1):
    # aは0冊から始まる
    if a[i] > K:
        break

    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
    
    
print(ans)


Measured memory_bytes: 47312
#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
    }
    let mut v = vec![a, b, c, d, e];
    v.sort_by_key(|vi| if vi % 10 == 0 { 10 } else {vi % 10});
    let mut sum = v[0];
    for i in 1..v.len() {
        sum += v[i] / 10 * 10;
        if v[i] % 10 > 0 {
            sum += 10;
        }
    }
    println!("{}", sum);
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int h[30];

void solve() {
  string s; cin >> s;
  for (int i = 0; i < (int)s.size(); ++i) {
    ++h[s[i]-'a'];
  }
  long long ans = 1LL*s.size()*(s.size()-1)/2;
  for (int i = 0; i < 30; ++i) {
    if (!h[i]) continue;
    ans -= 1LL*h[i]*(h[i]-1)/2;
  }
  printf("%lld", ans+1);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, s;

int calc(int b, int n)
{
    if(n == 0)return 0ll;
    return n % b + calc(b, n / b);
}

signed main()
{
    cin >> N >> s;
    if(s == N){
        printf("%lld\n", N + 1ll);
        return 0;
    }
    else if(s > N){
        printf("-1\n");
        return 0;
    }
    for(int i = 2ll; i * i <= N; i++){
        int res = calc(i, N);
        if(res == s){
            printf("%lld\n", i);
            return 0;
        }
    }
    int ans = -1ll;
    for(int i = 1; i * i <= N; i++){
        int b = (N - s) / i + 1ll;
        if(b > 1ll){
            int res = calc(b, N);
            if(res == s){
                ans = b;
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}
/*


*/




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

int main() {
	int n;
	int a,b;
	int ta,tb;
	scanf("%d",&n);
	while(n){
		ta=tb=0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				ta+=a+b;	
			}else if(a<b){
				tb+=a+b;
			}else{
				ta+=a;
				tb+=b;
			}
		}
		printf("%d %d\n",ta,tb);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  string s;
  cin >> s;
  for (int i = 0; i + 1 < (int) s.size(); i++) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int p;
  p = n * a;
  if ( p < b) {
  	cout << p << endl;
  }
  else {
  	cout << b << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vals;
    vector<int> sum;
    sum.push_back(0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        vals.push_back(a);
        sum.push_back(sum.back() + a);
    }

    int s = 0;
    for (int i = 0; i < N; i++) {
        s += vals[i]*(sum[N] - sum[i + 1]);
    }

    cout << s << endl;
    
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long h;
    cin >> h;
    
    long n = 1;
    long s = 0;
    while (h > 0) {
        s += n;
        n *= 2;
        h /= 2;
    }
    cout << s << "\n";

    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()
a = sorted(a, reverse=True)
ai = [i for i in range(0,n,2)]
bi = [i for i in range(1,n,2)]
alice = 0
bob = 0
for i in ai:
    alice += a[i]
for i in bi:
    bob += a[i]
print(alice-bob)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, ll b) {
	return a.pow(b);
}

int main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> cnt(60);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 60; j++) {
			cnt[j] += (a[i] >> j) & 1;
		}
	}
	Mint ans = 0;
	for (int i = 0; i < 60; i++) {
		ans += Mint(cnt[i])*Mint(n - cnt[i])*pow(Mint(2), (ll)i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            cnt += 1
        if cnt > 0:
            g[tmp] = max(g[tmp], cnt)
        tmp += 1
    if a > 1:
        if a not in g:
            g[a] = 1

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 45532
import java.util.*;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int c = 0;
        for( int i = 0; i < H; i++ ) {
            String s = sc.next();
            for( int j = 0; j < W; j++ )
                if( s.charAt( j ) == '#' ) c++;
        }
        if( c == H + W - 1 ) System.out.println( "Possible" );
        else                 System.out.println( "Impossible" );
    }
}


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


int main() {
	int a, b;
	cin >> a >> b;
	string str;
	cin >> str;
	bool ans = true;
	for(int i=0; i<a; i++){
		if(!isdigit(str.at(i))){
			ans = false;
		}
	}
	if(str.at(a) != '-'){
		ans = false;
	}
	for(int i=a+1; i<=a+b; i++){
		if(!isdigit(str.at(i))){
			ans = false;
		}
	}

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


Measured memory_bytes: 256
N = gets.to_i
A1 = gets.split.map(&:to_i)
A2 = gets.split.map(&:to_i)
max = 0

0.upto(N-1) do |i|
  c = A1[0..i].inject(:+) + A2[i..N-1].inject(:+)
  max = c if max < c
end
puts max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int h[200000][4];
int dp[200000][4];

int happiness(int i,int a)
{
	if(dp[i][a]!=-1)
	{
		return dp[i][a];
	}
	if(i == 1)
	{
		dp[i][a] = h[i][a];
		return h[i][a];
	}

	dp[i][a] = max( happiness(i-1,(a+1)%3), happiness(i-1,(a+2)%3) ) + h[i][a];

	return dp[i][a];

	
}


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

	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i][0]>>h[i][1]>>h[i][2];
		dp[i][0] = -1;
		dp[i][1] = -1;
		dp[i][2] = -1;
	}

	int ans = max( happiness(n,0) , happiness(n,1)  );
	ans = max( ans , happiness(n,2));

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 10624
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();

		sc.close();

		int tmp = 1;
		tmp = a + b;
		if(tmp%2==0) {
			System.out.println(tmp/2);
		}else {
			System.out.println("IMPOSSIBLE");
		}


	}
}

Measured memory_bytes: 23252
n, m, k = map(int, input().split())

MOD = 998244353

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = MOD
N = 2 * 10 ** 5 + 10
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

res = 0
for i in range(k + 1):
    res += m * pow(m - 1, n - i - 1, MOD) * cmb(n - 1, i, MOD)
    res %= MOD

res %= MOD
print(res)

Measured memory_bytes: 112508
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int count = 0;
        long total = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'W') {
                total += i - count;
                count++;
            }
        }
       System.out.println(total);
    }
}


Measured memory_bytes: 26672
#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 1101010101010101010
#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; }

vint dx = {-1,0,0,1};
vint dy = {0,-1,1,0};
const int MAX = 410;
vector<vbool> seen(MAX,vbool(MAX));

int h,w;
vector<string> mass;

int numb = 0;
int numw = 0;

void dfs(int x,int y){
  seen[x][y] = true;
  if(mass[x][y] == '#') ++numb;
  else ++numw;

  rep(dir,0,4){
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
    if(mass[x][y] == mass[nx][ny])continue;
    if(seen[nx][ny]) continue;
    dfs(nx,ny);
  }
}

signed main(){
  cin >> h >> w;
  mass.resize(h);
  rep(i,0,h) cin >> mass[i];

  int res = 0;
  rep(x,0,h){
    rep(y,0,w){
      if(mass[x][y] == '.') continue;
      if(seen[x][y]) continue;
      numb = 0;
      numw = 0;
      dfs(x,y);
      res += numb*numw;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 13056
#include<stdio.h>
#include<string.h>
int main()
{
  int   x,cnt=0;
  scanf("%d",&x);
  int arr[3];
  arr[0]=x/100;
  arr[1]=x%10;
   int temp=x/10;
  arr[2]=temp%10;
  for(int i=0;i<3;i++)
  {
      if(arr[i]==7)
       cnt++;
  }
if(cnt>=1)
    printf("Yes");
else
    printf("No");



    return 0;
}


Measured memory_bytes: 1732
N = int(input())
X = list(map(int,input().split()))

average = [sum(X)//N,(sum(X)//N)+1]

ans = 0

check = [[],[]]

for i in range(2):
    for j in X:
        a = (abs(j-average[i]))**2
        check[i].append(a)

if sum(check[0]) <= sum(check[1]):
    print(sum(check[0]))
else:
    print(sum(check[1]))


Measured memory_bytes: 3064
from collections import deque

H, W = map(int, input().split())
C=list(list(input()) for _ in range(H))

def bfs():
	sx, sy= 0, 0
	gx, gy= H-1, W-1
	dx = [1, 0, -1, 0]
	dy = [0, 1, 0, -1]

	work_queue=deque([])
	work_queue.append((sx, sy))
	visited=[[float("inf")]*W for _ in range(H)]
	visited[sx][sy]=1

	while work_queue:
		x, y = work_queue.popleft()

		for i in range(4):
			nx, ny = x+dx[i], y+dy[i]

			if 0<=nx<H and 0<=ny<W and visited[nx][ny]==float("inf") and C[nx][ny]!="#":
				work_queue.append((nx, ny))
				visited[nx][ny]= visited[x][y]+1
	return visited[gx][gy]


temp=bfs()

black=0
white=0
for i in range(H):
	for j in range(W):
		if C[i][j]==".":
			white+=1
		else:
			black+=1

if temp==float("inf"):
	print(-1)
else:
	print(white-temp)






Measured memory_bytes: 9520
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
#define ll long long
string s1, s2, s3;
ll n1, n2;
int main()
{
	cin >> s1 >> s2;
	cin >> n1 >> n2;
	cin >> s3;
	if(s1 == s3) n1--;
	else if(s2 == s3) n2--;
	cout << n1 << " " << n2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
s = int(input())
n = 1
tmp = s
if s == 1 or s == 2:
    print(4)
else:
    for i in range(1, 1000000):
        if tmp == 4:
            n = i
            break
        elif tmp % 2 == 0:
            tmp = tmp//2
        else:
            tmp = 3*tmp + 1
    print(n+3)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  short input_int;
  char input_string[101];

  scanf("%hd", &input_int);
  scanf("%s", input_string);

  char output_string[104];
  short is_overflow = 0;

  for(short i = 0; i < input_int; i += 1) {
    output_string[i] = input_string[i];
    if (input_string[i] == '\0') {
      break;
    }

    if (i == input_int - 1) {
      if (input_string[i + 1] == '\0') {
        output_string[i + 1] = '\0';
      } else {
        is_overflow = 1;
      }
    }
  }

  if (is_overflow == 1) {
    output_string[input_int] = '.';
    output_string[input_int + 1] = '.';
    output_string[input_int + 2] = '.';
    output_string[input_int + 3] = '\0';
  }

  printf("%s", output_string);

  return 0;
}


Measured memory_bytes: 1728
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] A = readln.chomp.split.to!(int[]);

  size_t p;
  foreach (i, a; A) {
    if (a == 1) {
      p = i;
      break;
    }
  }

  size_t g;

  for (;;) {
    if (g * (K - 1) <= p && p <= (g + 1) * (K - 1)) {
      break;
    }
    g++;
  }

  size_t ans;

  foreach_reverse (i; 0..g+1) {
    ans++;
    foreach (j; 0..K) {
      A[i * (K - 1) + j] = 1;
    }
  }

  import std.math;
  foreach (i; g+1..ceil((N.to!real-1f)/(K.to!real-1f) - 1f)+1) {
    ans++;
    foreach (j; 0..K) {
      A[N - K + j] = 1;
    }
  }

  writeln(ans);
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll ans = 0;
    int i;

    sort(h.rbegin(), h.rend());
    for(i=k;i<n;i++){
        ans += h[i];
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    string S;
    cin >> S;
    bool judge = true;
    for (int i = 0; i < S.size() - 1; i++)
    {
        for (int j = i + 1; j < S.size(); j++)
        {
            if (S[i] == S[j])
            {
                judge = false;
                break;
            }
        }
    }
    if (judge)
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, a, b;
    scan(n, a, b);
    auto x = readln.split.to!(int[]);

    long ans;

    foreach (i ; 1 .. n) {
        long d = x[i] - x[i - 1];

        if (d * a > b) {
            ans += b;
        }
        else {
            ans += d * a;
        }
    }

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 3964
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;
 
class Program
{
    public struct Point
    {
        public int X;
        public int Y;
    }
    static void Main(string[] args)
    {
        label:
        int n = Parse(ReadLine());
        var points = new Point[n];
        int gusuKisuFail = 0;
        int maxDiff = 0;
        for (int i = 0; i < points.Length; ++i)
        {
            var sp = ReadLine().Split();
            points[i].X = Parse(sp[0]);
            points[i].Y = Parse(sp[1]);
            var tmp = Abs(points[i].X) + Abs(points[i].Y);
            if (i == 0) gusuKisuFail = tmp % 2;
            else if (gusuKisuFail != tmp % 2) gusuKisuFail = 2;
            maxDiff = Max(maxDiff, tmp);
        }
        if (gusuKisuFail == 2)
        {
            WriteLine("-1");
        }
        else
        {
            maxDiff /= 2;
            int tmp = 1;
            while (tmp < maxDiff) tmp *= 2;
            var arms = new List<int>();
            while (0 < tmp)
            {
                arms.Add(tmp);
                tmp /= 2;
            }
            arms.Add(1);
            arms.Add(1);
            arms.Add(1);
            if (gusuKisuFail == 1) arms.Add(1);
            WriteLine(arms.Count);
            WriteLine(string.Join(" ", arms.Select(a => a.ToString())));
            for (int j = 0; j < points.Length; ++j)
            {
                var p = points[j];
                var array = new char[arms.Count];
                for (int i = 0; i < arms.Count; ++i)
                {
                    if (Abs(p.X) < Abs(p.Y))
                    {
                        if (0 < p.Y)
                        {
                            array[i] = 'U';
                            p.Y -= arms[i];
                        }
                        else
                        {
                            array[i] = 'D';
                            p.Y += arms[i];
                        }
                    }
                    else
                    {
                        if (0 < p.X)
                        {
                            array[i] = 'R';
                            p.X -= arms[i];
                        }
                        else
                        {
                            array[i] = 'L';
                            p.X += arms[i];
                        }

                    }
                }
                WriteLine(new string(array));
                //WriteLine($"({p.X},{p.Y}");
            }
        }
        //goto label;
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long a, b, c, k;
    long long max_value;
    
    cin >> a >> b >> c >> k;
    
    max_value = max(a, max(b, c));
    
    cout << a + b + c - max_value + max_value * (long long)pow(2, k) << endl;
    
    return 0;
}

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

using namespace std;
#define taskname "A"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e3 + 5;
int n ,m , deg[maxn];
vector<int> adj[maxn];
int res = 1e9;
string s;
int sub[maxn];
int f[maxn] , g[maxn];//f<=choose<=g;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
	}
    cin >> n >> s;
    for(int i = 1 ; i < n ; ++i){
        int u , v;cin >> u >> v;--u;--v;
        adj[u].pb(v);adj[v].pb(u);
    }
    for(int i = 0 ; i < n; ++i){
        function<void(int,int)> dfs = [&](int u,int par){
            sub[u] = (s[u] == '1');
            f[u] = g[u] = 0;
            int mx = 0;
            for(int c : adj[u]){
                if(c != par){
                    dfs(c,u);
                    sub[u] += sub[c];
                    f[c] += sub[c];
                    g[c] += sub[c];
                    g[u] += g[c];
                    mx = max(mx,g[c]+f[c]);
                }
            }
            f[u] = max(f[u],mx-g[u]);//max(f[child v]- g[left])
        };
        dfs(i,-1);
        if(f[i]==0&&g[i]%2==0)res = min(res,g[i]/2);
    }
    if(res == 1e9)cout << -1;
    else cout << res;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<string, pair<int,int> > > z;    // name, -pt, index
    int i;
    for(i=0; i<n; i++) {
        char str[12]={0};
        int tmp;
        scanf("%s %d", str, &tmp);
        z.push_back(make_pair(string(str), make_pair(-tmp, i)));
    }
    sort(z.begin(), z.end());

    for(i=0; i<n; i++) {
        printf("%d\n", z[i].second.second+1);
    }

    return 0;
}


Measured memory_bytes: 256
//  ~~kassablanca~~  \\                                                                                                                                                                                              //look down



#include <bits/stdc++.h>

//#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;

mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("dead", "r", stdin); freopen("tmp.out", "w", stdout);
#define s second
#define f first
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template<class T>
ll upmax(T &a, T b) { return (b > a) ? a = b, 1 : 0; }

template<class T>
ll upmin(T &a, T b) { return (b < a) ? a = b, 1 : 0; }

template<class T>
ll gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

const ll INF = 1e18;
constexpr ll mod = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, 0), b(n, 0);
    int wa = 0, ac = 0;
    int id;
    string x;
    for (int i = m - 1; ~i; i--) {
        cin >> id >> x;
        id--;
        if (!b[id]) {
            if (x == "WA")a[id]++;
            else b[id] = 1, ac++;
        }
    }
    for (int i = n - 1; ~i; i--) if(b[i])wa+=a[i];
    cout<<ac<<' '<<wa<<'\n';

}

signed main() {
    //ioss
    //clock_t time = clock();
    //if ((double) (clock() - time) / CLOCKS_PER_SEC > 0.96) {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int N;
  scanf("%d",&N);
  int d[N];
  int i,sum,j;
  sum=0;
  for(i=0;i<N;i++){scanf("%d",&d[i]);}
  for(i=0;i<N;i++){for(j=i+1;j<N;j++){sum=sum+(d[i]*d[j]);}}
    printf("%d",sum);
    return 0;
  }
  


Measured memory_bytes: 1708
/*
created on 21/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
int N;
int const maxlen = 3005;
typedef long double ld;
ld p[maxlen];
ld memo[maxlen][maxlen];
ld findans(int pos, int head, int tail){
  if(pos==N)
    return head>tail;
  ld& ret = memo[head][tail];
  if(ret!=-1)
    return ret;
  return memo[head][tail] = p[pos]*findans(pos+1, head+1, tail) + (1-p[pos])*findans(pos+1, head, tail+1);

}
void solve(){
  cin>>N;
  for(int i=0;i<maxlen;i++)
    for(int j=0;j<maxlen;j++)
      memo[i][j] = -1.0;
  for(int i=0;i<N;i++)
    cin>>p[i];
  ld ans = findans(0, 0, 0);
  printf("%.10Lf\n", ans);
}


Measured memory_bytes: 141696
#include <iostream>
#include <vector>
#include <string>
int main(){
    using namespace std;
    vector<char> v;
    char c;
    string s,p;
    cin >> s >> p;
    int size = s.size();
    int sizep = p.size();
    for(int i=0;i<size;i++){
        c = s[i];
        v.push_back(c);
    }
    for(int i=0;i<size;i++){
        c = s[i];
        v.push_back(c);
    }

    int j = 0;
    int k;
    while(j<size){
        if(v[j]==p[0]){
            for(k=0;k<sizep;k++){
                if(v[j+k]!=p[k]){break;}
            }
            if(k==sizep){
                cout << "Yes" << endl;
                return 0;
            }
        }
        j++;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3228
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()

    val r = (1..n)
    val sum = r.asSequence().filter { it % 2 == 1 }.count()
    val len = r.count()
    println(sum.toDouble() / len.toDouble())
}



Measured memory_bytes: 31656
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
using namespace std;

#define INF 1e9
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define ll long long
#define lint long int
#define llint long long int
#define atoz abcdefghijklmnopqrstuvwxyz
#define atoZ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
#define AtoZ ABCDEFGHIJKLMNOPQRSTUVWXYZ
#define mapSI map<string, int>
#define mapII map<int, int>
#define mapSS map<string, string>
#define pb push_back

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, n) for(int i = 0; i < (n); i += 2)
#define repv(i, n, v) for(int i = 0; i < (n); i += v)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define sortN(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define sortI(i, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<int>)
#define sortS(s, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<char>)
#define all(a) a.begin(), a.end()

int digitSum(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int N;
  cin >> N;
  
  //配列の入力
  int A[N+1];
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    A[tmp] = i+1;
  }
  
  //何人登校していたかが少ない順に出力
  for(int i = 0; i < N; i++){
    cout << A[i+1] << " ";
  }
  cout << endl;
  
  return 0;
}

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

int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    int max_x, max_y, min_x, min_y;
    max_x = x + r;
    max_y = y + r;
    min_x = x - r;
    min_y = y - r;
    if ( min_x < 0 || min_y < 0 || max_x > W || max_y > H )
    {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[2001][2001];
ll check(vector<pair<ll,ll> >v,ll l,ll r,ll i)
{ 
   //cout<<l<<" "<<r<<endl;
   if(l>r)
    return 0; 
   if(dp[l][r]!=-1)
    return dp[l][r]; 
   ll ans=0;
   ll p1=v[i].first;
   ll p2=v[i].second;
   ans=max(p1*(p2-l)+check(v,l+1,r,i+1),p1*(r-p2)+check(v,l,r-1,i+1));
   return dp[l][r]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
       string s;
       cin>>s;
       if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
       else
       {
           cout<<"No";
       }
        
    }
}


Measured memory_bytes: 3640
unittest
{
	assert( [ "2 3 3", "2 2", "RRL", "LUD" ].parse.expand.solve == "YES" );
	assert( [ "4 3 5", "2 2", "UDRRR", "LLDUD" ].parse.expand.solve == "NO" );
	assert( [ "5 6 11", "2 1", "RLDRRUDDLRL", "URRDRLLDLRD" ].parse.expand.solve == "NO" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwn = input.front.split.to!( long[] );
	input.popFront;
	auto rc = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( hwn[ 0 ], hwn[ 1 ], rc[ 0 ], rc[ 1 ], s, t );
}

auto solve( long h, long w, long r, long c, dchar[] s, dchar[] t )
{
	// 縦と横は別に考えて良い
	if( solve2!( 'U', 'D' )( h, r, s, t ) && solve2!( 'L', 'R' )( w, c, s, t ) ) return "YES";
	else                                                                         return "NO";
}

auto solve2( dchar L, dchar R )( long w, long p, dchar[] s, dchar[] t )
{
	// 駒を取り除けることが確定する範囲を計算
	auto ll = 0L;
	auto rr = w + 1;
	auto l  = ll;
	auto r  = rr;
	foreach( sc, tc; zip( s, t ).retro )		// 逆順で考える
	{
		switch( tc )
		{
			case L: r += ( r < rr ); break;
			case R: l -= ( ll < l ); break;
			default: /* nop */       break;
		}
		switch( sc )
		{
			case L: l++;       break;
			case R: r--;       break;
			default: /* nop */ break;
		}
		if( l + 1 == r ) break;
	}
	return ( l < p && p < r );
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/20  Problem: ABC 134 B / Link: http://abc134.contest.atcoder.jp/tasks/abc134_b  ----- */


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

	LL N, D; cin >> N >> D;
	LL ans = (N + 2 * D) / (2 * D + 1);
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256