akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int dx[] = {-1,0,1};

void saiki(int x,int y) {
  if(y >= h-1) memo[y][x]++;
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = x+dx[i], ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;

      if(nx <0|| nx >= w ||mp[ny][nx] == 1) continue;
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) memo[y][x] += memo[ny][nx];
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	memo[y][x] += memo[ny][nx];
      }
    }
    if(memo[y][x] == 0) mp[y][x] = 1;
  }
}
  
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
 
    for(int i=0;i<w;i++) 
      if(mp[0][i] !=1) saiki(i,0);
    
    int cnt = 0;
    for(int i=0;i<w;i++)
      if(memo[0][i] > 0) cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
int nn=N%10;
if(nn==2||nn==4||nn==7||nn==5||nn==9)
    cout<<"hon"<<endl;
else if(nn==3)
    cout<<"bon";
else
    cout<<"pon";
return 0;
}


Measured memory_bytes: 3632
const Main = input => {
  
    const arr = input.split(" ")
    const num1 = parseInt(arr[0])
    const num2 = parseInt(arr[1])
  
  if ((num1 * num2) % 2 == 0) {
  	console.log('Even')
  } else {
    console.log('Odd')
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#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>;

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int a;
    cin >> a;
    rep(j,a) {
      int x, y;
      cin >> x >> y;
      x--;
      g[i][x] = y;
    }
  }
  int ans = 0;
  rep(i,1<<n) {
    bool ok = true;
    vector<int> d(n);
    rep(j,n) if((i>>j)&1) {
      d[j] = 1;
    }
    rep(j,n) {
      if(d[j]) {
        rep(k,n) {
          if(g[j][k] == -1) continue;
          if(d[k] != g[j][k]) ok = false;
        }
      }
    }
    if(ok) {
      bitset<15> bit(i);
      int count = bit.count();
      ans = max(ans, count);
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));

#define int ll

void solve() {
    int x;
    cin >> x;
    for (int a = -1e3; a <= 1e3; a++) {
        for (int b = -1e3; b <= 1e3; b++) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << ' ' << b << endl;
                exit(0);
            }
        }
    }
}

signed main() {
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while (t--) {
        solve();
    }
    return 0;
}

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

int gcd(int m, int n){
    int r = m % n;
    if (r == 0){
        return n;
    }
    return gcd(n, r);
}

int gcd(int l, int m, int n){
    return gcd(gcd(l, m), n);
}

int main() {
    int K;
    cin >> K;
    long ans = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                ans += gcd(i, j, k);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    if(S[S.size() - 1] == 's') cout << S << "es" << endl;
    else cout << S << 's' << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    ll S = 0;
    rep(i, N) { 
        cin >> A[i];
        B[i] = 0;
        S += A[i];
    }
    B[0] = S;
    for(ll i = 1; i < N; i += 2) {
        B[0] -= 2 * A[i];
    }
    for(ll i = 1; i < N; i++) {
        B[i] = 2 * A[i-1] - B[i-1];
    }
    rep(i, N){
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
  	string S;
	cin >> N >> S;
	int i,j;
 
	int ans = 1;
	for(j=0;j < N-1;j++){
      if(S[j] != S[j+1]) ans++;
    }
        
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  int C[10][10];
  for(int i=0;i<10;++i) {
    for(int j=0;j<10;++j) {
      cin>>C[i][j];
    }
  }
  for(int k=0;k<10;++k) {
    for(int i=0;i<10;++i) {
      for(int j=0;j<10;++j) {
        C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
      }
    }
  }
  int ans = 0;
  int tmp;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      cin>>tmp;
      if(tmp>-1) ans += C[tmp][1];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        if (n<=2) {
            out.println(1);
            exit(0);
        }
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans=0;
        for (int i = 1; i < n-1; i++) {
            long difL=a[i]-a[i-1];
            difL/=max(1,abs(difL));
            long difR=a[i+1]-a[i];
            difR/=max(1,abs(difR));
            if(difR==0){
                a[i+1]=a[i];
                a[i]=a[i-1];
            }
            if(difL*difR<0){
                ans++;
                a[i]=a[i+1];
            }
        }
      out.println(ans+1);
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll dp[2020][2020];
pll A[2020];
ll mk[2020];
ll i, j, k;
ll ans;

void mxin(ll& a,ll b){
    if(a<b)
        a = b;
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        ll a;
        scanf("%lld", &a);
        A[i] = {a, i};
    }
    sort(A, A + N);
    dp[0][0] = 1e17;
    fornum(i,0,N){
        ll ii = N - 1 - i;
        fornum(j,0,i+1){
            ll a;
            a = dp[i][j] + abs(j-A[ii].second) * A[ii].first;
            mxin(dp[i + 1][j + 1], a);
            a = dp[i][j] + abs(N - 1 - i + j - A[ii].second) * A[ii].first;
            mxin(dp[i + 1][j], a);
        }
    }
    fornum(i,0,N+1){
        mxin(ans, dp[N][i]);
    }
    ans -= (ll)1e17;
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 26472
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl


int main()
{
	SPEED;

	int k;
	cin>>k;

	int p10=1;
	int cur=0;

	for(int i=1;i<=1000000;i++)
	{
		cur=(cur+((p10*7)%k))%k;
		if(cur==0)
			return cout<<i<<endl,0;
		p10=(p10*10)%k;
	}

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

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Char a = Char.Parse(Console.ReadLine());
            if (Char.IsUpper(a))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }
    }
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i, S.size()) {
    cout << (alpha[S[i] - 'A' + N]);
  }
  cout << endl;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    ll ret = 0;
    ll sub = 0;
    ll left= 0,right = n;
    for(i=1;i<=n+1;i++){
        if(i>=k){
            (ret+=right-left+1)%=MOD;
            //cout << left << " " << right << endl;
        }
        left += i;
        right += n-i;
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a > b) cout << "Alice";
  else if(a < b) cout << "Bob";
  else cout << "Draw";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim  //
// Tanbir Ahmed  << RibNat >>  //
// University of Barisal       //

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     End             return 0
#define     ll              long long int
#define     Pair            pair<ll,ll>
#define     F               first
#define     S               second
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     Max             1000000000000000014
#define     Min             -1000000000000000014
#define     mod             1000000007
#define     range           100007

#define     pb              push_back
#define     Vector          vector<ll>
#define     mp              make_pair
#define     PI              3.1415926535897
#define     min_heap        priority_queue <ll, vector<ll>, greater<ll> >
#define     ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>  //*(x.find_by_order(k)),x.order_of_key(k)

/*************** #Template FUNCTIONS# **************/

 ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
//  ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
// ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
// ll Check(ll n,ll i){return (n&(1LL<<i));}
// ll Set(ll n,ll i){return (n|(1LL<<i));}
// ll status[(ll)range/64+5];Vector primes;void sieve(){for(ll i=3;i<=sqrt(range);i+=2){if(Check(status[i/64],i%64)==0){for(ll j=i*i;j<range;j+=2*i){status[j/64]=Set(status[j/64],j%64);}}}primes.pb(2);for(ll i=3;i<range;i+=2)if(Check(status[i/64],i%64)==0)primes.pb(i);}

// ll dx[] = {-2, -1, 1, 2,  2,  1, -1, -2};
// ll dy[] = { 1,  2, 2, 1, -1, -2, -2, -1};

// ll X[]= {0,0,1,-1,1,1,-1,-1};
// ll Y[]= {1,-1,0,0,1,-1,1,-1};

/********************** START **********************/

int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[m];
    ll s=0,i,j;
    for(i=0; i<m; i++) {
        cin>>a[i];
        s+=a[i];
    }

    if(s>n){
        cout<<-1<<endl;
    }
    else{
        cout<<n-s<<endl;
    }


}



/*******      ALHAMDULILLAH     *********/  
/*******      Happy Coding      *********/


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        char[] c = str.toCharArray();
        int index = sc.nextInt()-1;
        char ok = c[index];
        
        for (int i = 0; i < n; i++) {
            if (c[i] != ok) {
                c[i] = '*';
            }
            System.out.print(c[i]);
        }
        System.out.println();
    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using LD = long double;
const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<LL> a(n), b(n);
    for (auto& i : a) cin >> i;
    b = a;
    for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] ^= b[i - 1];
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        auto check = [&](int k) {
            if (i) return (a[k] - a[i - 1]) == (b[k] ^ b[i - 1]);
            else return a[k] == b[k];
        };
        int l = i, r = n;
        while (l < r) {
            int mid = (l + r) / 2;
            if (check(mid)) l = mid + 1;
            else r = mid;
        }
        ans += r - i;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3328
my $X = 0;
my $N = 0;
my $cnt = 0;
while(<STDIN>)
{
  chomp $_;
  my @cols = split(" ", $_);
  if($cnt == 0) {
    $X = $cols[0];
    $N = $cols[1];
    if($N == 0) {
      print $X;
      exit;
    }
    $cnt++;
  }elsif($cnt == 1) {
    my @vals = sort {$a <=> $b} @cols;
    my $min = $vals[0];
    my $max = $vals[$N - 1];
    if($X <= $min) {
      print $X - 1;
    }elsif($X > $min) {
      my %ps;
      foreach my $val (@vals) { $ps{$val} = 1; }
      my $min_diff = 10000;
      my $Y = $max + 1;
      for(my $i=($max+1); $i >= ($min-1); $i--) {
        if( exists($ps{$i}) ) {}else {
          my $cur_diff = abs($i - $X);
          if($cur_diff <= $min_diff) {
            $min_diff = $cur_diff;
            $Y = $i;
          }
        }
      }
      print $Y;
    }
  }
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 110;
int wei[MAXN], val[MAXN];
ll dp[MAXN][(int) 1e5 + 10];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, w;
	cin >> n >> w;
	rep (i, 1, n) {
		cin >> val[i] >> wei[i];
	}
	int ans = 0;
	const int MAXV = 1e5;
	rep (i, 1, MAXV) {
		dp[0][i] = 1e18;
	}
	rep (i, 1, n) {
		rep (j, 0, MAXV) {
			dp[i][j] = dp[i - 1][j];
			if (j >= wei[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - wei[i]] +val[i]);
			if (dp[i][j] <= w) ans = max(ans, j);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80128
#include<stdio.h>
#include<cmath>
#include<complex>
using namespace std;
#if 0
50??????????????????????????????????????£??¨?????????????????¨??????????????????????????????????????£????????¨?????£???????????????????????\???????????¨?????????????????\?????¨????????¨??????????°??????????????????§???????????????????????????????????°???????????°???<iostream>??§????????????<stdio.h>??????????????£????????§??????
#endif

typedef complex<double> xy_t;
xy_t P[20];
double cross_product(xy_t a,xy_t b)
{
    return (conj(a)*b).imag();
}

int main()
{
    int N=0;
    double x,y;
    while(scanf("%lf,%lf",&x,&y) != EOF)
    {
        P[N++] = xy_t(x,y);
    }
    double sum = 0.0;
    for(int i=0;i+2<N;++i)
    {
        xy_t a=P[i+1]-P[0],b=P[i+2]-P[0];
        sum+=cross_product(a,b)/2.0;
    }

        printf("%.6f\n",abs(sum));

}

Measured memory_bytes: 2684
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s int
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		s ^= as[i]
	}
	for i := range as {
		fmt.Printf("%d ", s^as[i])
	}
	fmt.Println()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 7224
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        String S = scanner.next();
        char[] split_S = new char [S.length()];
        for(int i=0;i<S.length();i++){
            split_S[i] = S.charAt(i);
        }
        if(S.length() <= K){
            for(int i=0;i<S.length();i++){
                if(i != i-1){
                    System.out.print(split_S[i]);
                }
                else{
                    System.out.println(split_S[i]);
                }
            }
        }
        else{
            for(int i=0;i<S.length();i++){
                if(i != K-1){
                    System.out.print(split_S[i]);
                }
                else{
                    System.out.println(split_S[i]+"...");
                    break;
                }
            }
        }

        scanner.close();
    }
}

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;


void solve(){
    int n,q;cin >> n >> q;
    string s;cin >> s;
    vector<int>pre(n+1,0);
    for(int i = 0;i<n-1;i++){
        pre[i+2] = pre[i+1];
        if(s[i]=='A'&&s[i+1]=='C') pre[i+2]++;
    }
    while(q--){
        int l,r;cin >> l >> r;
        cout << pre[r] - pre[l]<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


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

ab = [list(map(int,input().split()))for i in range(n)]
cd = [list(map(int,input().split()))for i in range(m)]

for i in range(n):
    dim, num = 10**9,-1
    for j in range(m):
        if abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]) < dim:
            dim = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
            num = j
    print(num +1)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long LL;
const int M=2e5+5;

int k;
int add(int x,int y)
{
	x+=y;
	if(x>=k) x-=k;
	return x;
}
int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=k;
	return x;
}
int a[M],sum[M];

unordered_map<int,int> ma;

// a        1 4 2  3  5
// sum    0 1 5 7 10 15
// mod    0 1 1 3  2  3
// id     0 1 2 3  4  5
// mod-id 0 0 3 0  2  2

int main()
{
	int n; 
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	// if(k==1)
	// {
	// 	printf("0\n");
	// 	return 0;
	// }
	LL ans=0;
	ma[0]++;
	for(int i=1;i<=n;i++)
	{
	    // length of window < k
		if(i>=k)
			ma[sub(sum[i-k],(i-k)%k)]--;
		sum[i]=add(sum[i-1],a[i]%k);
		ans+=ma[sub(sum[i],i%k)];
		ma[sub(sum[i],i%k)]++;
		
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a) cout << k << endl;
  else if(k<=a+b) cout << a << endl;
  else if(k<=a+b+c) cout << a - (k-a-b) << endl;
}


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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    long long L[N];
    if(N<3){
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<N;i++)cin >> L[i];
    for(int p=0;p<N-2;p++){
        for(int q=p+1;q<N-1;q++){
            for(int r=q+1;r<N;r++){
                if(L[p]!=L[q] && L[q]!=L[r] && L[r]!=L[p] ){
                    if(L[p]+L[q]>L[r] && L[q]+L[r]>L[p] && L[r]+L[p]>L[q])ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long h[200009];
long long dp[109];

long long mod = 1e9+7;
vector< pair<long long,long long> > v[109];
long long exp(long long b){
    if(!b) return 1;
    if(b&1) return 2*exp(b-1)%mod;
    long long k = exp(b/2);
    return k*k%mod;
}
main(){
    long long n;
    cin >> n;
    for(long long i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(long long i = 1; i <= n; i++){
        if(h[i-1] > h[i]) continue;
        long long lo = max((long long)2,h[i-1]+1), hi = h[i];
        for(long long j = i; j <= n; j++){
            if(max((long long)0,hi - max(lo,h[j]+1)+1)) v[i].push_back({j-1,max((long long)0,hi - max(lo,h[j]+1)+1)});
            hi = min(hi,h[j]);
        }
        if(max((long long)0,hi-lo+1)) v[i].push_back({n,max((long long)0,hi-lo+1)});
    }
    for(long long i = n; i >= 1; i--){
        for(long long j = i; j <= n; j++){
        long long A = 0;
            for(long long k = i; k <= j; k++){
                for(long long t= 0; t < v[k]. size(); t++){
                    long long r = v[k][t].first, N =  v[k][t].second;
                    if(r <= j) A+= N;
                }
            }
        if(j == n) dp[i] = (dp[i] + exp(A)) % mod;
        else dp[i] = (dp[i] + dp[j+1] * exp(A))% mod;
        }
    }
    cout<<  dp[1] * 2 % mod << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARINGS
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <fstream>
#include <map>
#include <unordered_map>

using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;

#define andrew ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i *PI / 180.0)
#define cos(i) (long double)cos(i * PI/ 180.0)

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int dy8[] = { 0, 0, 1, -1, 1, -1, -1, 1 };
int dx8[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int id8[] = { 0, 1, 2, 3, 4, 5, 6, 7 };

int main()
{
    andrew;
    int n;
    cin >> n;
    vector<ll>v(n + 1);
    v[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> v[i];

    vector<ll>mem(100005, 1e9);
    
    mem[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + 2; j++)
        {
            if (j < n)
                mem[j] = min(mem[j], mem[i] + abs(v[i] - v[j]));

        }
    }

    cout << mem[n - 1] << endl;

    




}


Measured memory_bytes: 4776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int A = in.nextInt();
        	int B = in.nextInt();
        	String ans = ":(";
        	if(A <= 8 && B <= 8) {
        		ans = "Yay!";
        	}
        	out.println(ans);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        //kの倍数
        int k = int.Parse(Console.ReadLine());
        int[] ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var ans = new List<int>();

    for(var i=ab[0]; i<=ab[1]; i++)
        {
            if (i % k == 0)
            {
                ans.Add(i);
            }
        }

        if (ans.Count() >= 1)
        {
            Console.WriteLine("OK");
        }
        else
        {
            Console.WriteLine("NG");
        }
    }
}




Measured memory_bytes: 28248
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))

template <typename T>
void FILL_(void* ptr, size_t size, T value) {
  std::fill((T*)ptr, (T*)ptr + size, value);
}

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n] = {};
  int bit_count[32] = {};
  for(int i=0;i<n;++i)
  {
    cin >> a[i];
    for(int j=0;j<32;++j)
    {
      if(a[i] & (1 << j))
      {
        bit_count[j] += 1;
      }
    }
  }
  int mask = 0;
  for(int i=0;i<32;++i)
  {
    if(bit_count[i] % 2 == 1)
    {
      mask |= (1 << i);
    }
  }

  for(int i=0;i<n;++i)
  {
    cout << (a[i] ^ mask);
    if(i != n-1)
    {
      cout << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 4384
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

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

	void solve(){
		int n=gInt();
		long[] a=new long[n+1];
		for(int i:rep(1,n))
			a[i]=gInt();
		Arrays.parallelPrefix(a,Long::sum);
		System.err.println(Arrays.toString(a));
		HashMap<Long,Long> h=new HashMap<>(n);
		for(long i:a)
			h.merge(i,1L,Long::sum);
		System.out.println(
				h.values().stream()
						.mapToLong(o->o*(o-1)/2)
						.sum());
	}

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

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

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::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(Main::gInt).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||(cur!=to&&(cur<to==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: 73016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	string s, t; cin >> s >> t;	
	string ans;
	rep(i, n) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int x, a;
    cin >> x >> a;

    if(x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;

    return 0;
}


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

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

  vector<int> number(N);
  for(int i = 0; i < N; i++){
    cin >> number.at(i);
  }

  bool flag = true;
  int count = 0;
  while(flag == true){
    for(int i = 0; i < N; i++){
      if(number.at(i) % 2 != 0){
        flag = false;
        break;
      }
      else{
        count++;
        number.at(i) /= 2;
      }
    }
  }

  cout << count / N << endl;
}


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

struct node{
	int p, sz, v, best, midx;
	node* l;
	node* r;
	node(int v): best(v), midx(0), v(v), p(rand()), l(NULL), r(NULL), sz(1){}
};
int best(node *t){
	if(t == NULL) return 1e7;
	return t->best;
}

int sz(node *t){
	if(t == NULL) return 0;
	return t->sz;
}

int midx(node *t){
	if(t == NULL) return 0;
	return t->midx;
}
void updsz(node *t){
	if(t == NULL) return;
	t->sz = sz(t->l)+sz(t->r)+1;
	t->best = min(t->v,min(best(t->l),best(t->r)));
	if(t->best == t->v){
		t->midx = sz(t->l);
	} else if(t->best == best(t->l)){
		t->midx = midx(t->l);
	} else if(t->best == best(t->r)){
		t->midx = sz(t->l) + 1 + midx(t->r);
	}
}
void split(node *t, node *& l, node *& r, int k){//k on left
	if(t == NULL){
		l = r = NULL;
	} else if(sz(t->l) >= k){
		split(t->l,l,t->l,k);
		r = t;
	} else {
		split(t->r, t->r, r, k-1-sz(t->l));
		l = t;
	}
	updsz(t);
}
void merge(node *&t, node *l, node *r){
	if(l == NULL){
		t = r;
	} else if(r == NULL){
		t = l;
	} else if(l -> p <= r -> p){
		merge(l->r,l->r,r);
		t = l;
	} else {
		merge(r->l,l,r->l);
		t = r;
	}
	updsz(t);
}
void ins(node *&t, node *c, int k){
	if(t == NULL){
		t = c;
	} else if(c->p >= t->p){
		split(t,c->l,c->r,k);
		t = c;
	} else if(sz(t->l) >= k){
		ins(t->l,c,k);
	} else {
		ins(t->r,c,k-1-sz(t->l));
	}
	updsz(t);
}
void del(node *&t, int k){
	if(t == NULL){
		return;
	}
	if(sz(t->l) == k){
		merge(t,t->l,t->r);
	} else if(sz(t->l) > k){
		del(t->l,k);
	} else {
		del(t->r,k);
	}
	updsz(t);
}
void pt(node *t){
	if(t == NULL) return;
	pt(t->l);
	cout << t->v << " ";
	pt(t->r);
}

vector<node*> evens;
vector<node*> odds;
set<pair<int,int> > f;
void add(node * even, node * odd){
	if(sz(even) == 0) return;
	f.insert(make_pair(best(even),evens.size()));
	evens.push_back(even);
	odds.push_back(odd);
}

int main(){
	int n;
	cin >> n;
	int a[n];
	node * even = NULL;
	node * odd = NULL;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		node * f = new node(a[i]);
		if(i % 2 == 0){
			ins(even,f,i/2);
		} else {
			ins(odd,f,i/2);
		}
	}
	vector<int> ans;

	add(even,odd);
	while(ans.size() < n){
		pair<int,int> g = *f.begin();
		f.erase(f.begin());
		int a = midx(evens[g.second]);
		ans.push_back(best(evens[g.second]));
		node *a1, *a2, *a3, *b1, *b2, *b3;
		split(evens[g.second], a1, a2, a);
		split(odds[g.second], b1, b2, a);

		int z = midx(b2);
		ans.push_back(best(b2));
		split(a2,a2,a3,z+1);
		split(b2,b2,b3,z+1);
		node *trash1, *trash2;
		split(a2,trash1,a2,1);
		split(b2,b2,trash1,sz(b2)-1);

		add(a1,b1);
		//pt(a1); pt(b1); cout << endl;
		add(b2,a2);
		//pt(a2); pt(b2); cout << endl;
		add(a3,b3);
		//pt(a3); pt(b3); cout << endl;
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 16616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  int n,m;cin>>n>>m;

  vector<vector<int>> g(n);
  rep(i,m){
    int a,b;cin>>a>>b;
    a--,b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  vector<int> dist(n,-1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);

  vector<int> ans(n);
  while(!que.empty()){
    int v = que.front();que.pop();

    for(auto&& one: g[v]){
      if(dist[one] != -1)continue;
      ans[one] = v;
      dist[one] = dist[v] + 1;
      que.push(one);
    }
  }

  rep(i,n)if(dist[i] == -1){
    print("No");
    return 0;
  }

  print("Yes");
  rep(i,n)if(i)print(ans[i]+1);
  return 0;
}


Measured memory_bytes: 10568
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n,*a;

	scanf("%d",&n);
	a=(int*)malloc(n*sizeof(int));

	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	for(int i=0;i<n;i++){
		printf("%d",a[n-1-i]);
		if(i!=(n-1)){
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2056
/*
 *  Created by Andrei Arhire 02/08/2020
 *  Copyright © 2020 Andrei Arhire. All rights reserved.
 */
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long
#define llf __float128
#define lld long double
using namespace std;
const lll NR = 1e5 + 10  ,oo = 2e9 + 10, MOD = 1e9 + 7 ;
const long double pi = 2*acos(0.0);

lld x ;

signed main () {


    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0) ;
    cin >> x ;
    if ( x >= 30  ) cout << "Yes\n" ;
    else            cout << "No\n" ;

    return 0 ;
}


Measured memory_bytes: 3740
def to_cumsum(arr):
    """
    1次元配列を累積和の1次元配列に変換する
    """
    cumsum = 0
    new = list()
    for e in arr:
        cumsum += e
        new.append(cumsum)
    return new


N, K = map(int, input().split())
S = input()

# 連続する1の数、連続する0の数を交互に並べた配列を計算
# 両端に1がない場合は"0個の1"があるものとして、必ず両端は1を示す要素にしておく

nums = list()
if S.startswith('0'):
    nums.append(0)

cnt = 0
cur = S[0]
for c in S:
    if c == cur:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        cur = '1' if cur == '0' else '0'
nums.append(cnt)

if S.endswith('0'):
    nums.append(0)

# 要素の和のうち最大のものを求めるので累積和を計算して高速化する
cumsum = to_cumsum(nums)

# 0, 2, 4,...番目から始まる2K + 1要素の和で最大のものを求める
l = -1
ans = 0
while l < len(cumsum):
    r = l + (2 * K) + 1
    if r >= len(cumsum):
        r = len(cumsum) - 1
    if l == -1:
        ans = cumsum[r]
    else:
        ans = max(ans, cumsum[r] - cumsum[l])
    l += 2
print(ans)

Measured memory_bytes: 47284
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>

#define rep(i,n) for (int i =0; i<(n); ++i)
using namespace std;
int main() {
	int N, D,ans;
	cin >> N >> D;
	int d = 2 * D + 1;
	if (N%d == 0) {
		 ans = N / d;
	}
	else {
		ans = N / d + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int x[4];
    rep(i,4) cin >>x[i];
    int a = x[0]*x[1];
    int b = x[2]*x[3];
    cout << max(a,b) << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  for(int C = 1;C <= N;C++){
    int n = N - C;
    for(int A = 1; A * A <= n;A++){
      if(n % A == 0){
        if(A * A == n) ans++;
        else ans += 2;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
use std::io::stdin;

fn main() {
    let mut s = String::new();
    let mut buffer = String::new();
    stdin().read_line(&mut s).unwrap();
    stdin().read_line(&mut buffer).unwrap();
    buffer = buffer.trim().to_string();
    let arg = s.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>();
        buffer = buffer.chars().enumerate().map(|(i,x)| if i == (arg[1]-1) {
            x.to_lowercase().nth(0).unwrap()
        } else { x }).collect::<String>();
    println!("{}", buffer);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<arr[k-1]<<endl;
	return 0;	

}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main () { 
	int a, b ;
	cin >> a >> b ;
	while (( a > 0 )||( b > 0 )) {
		if ( a < b ) {
			cout << a << " " << b << endl ;
		} else if ( b < a ) { 
	  		cout << b << " " << a << endl ;
    	} else {
    		cout << a << " " << b << endl ;
		}cin >> a >> b ;
	    
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100*2;

int main() {
	int n;cin>>n;
	ll a[alength]={};
	fori(n){
		cin>>a[i];
	}
	sort(a,a+n,greater<ll>());

	unsigned long long ans=a[0];
	for(int i=1;i*2<n-n%2;++i){
		ans+=a[i]*2;
	}
	if(n%2!=0){
		ans+=a[n/2];
	}
	cout<<ans;
}

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

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if(s == "A") {
        cout << "T" << endl;
    } else if(s == "T") {
        cout << "A" << endl;
    } else if(s == "C") {
        cout << "G" << endl;
    } else {
        cout << "C" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, m;
	int a[100][100];
	int b[100];
	long ans[100];
	int ii, jj;
	char c;

	memset(&a[0][0], (int)0, sizeof(int) * 100 * 100);
	memset(&b[0],    (int)0, sizeof(int) * 100);
	memset(&ans[0],  (int)0, sizeof(long) * 100);

	scanf("%d %d", &n, &m);
	scanf("%c", &c);

	for (ii = 0; ii < n; ii++) {
		for (jj = 0; jj < m; jj++) {
			scanf("%d", &a[ii][jj]);
			scanf("%c", &c);
		}
	}
	for (ii = 0; ii < m; ii++) {
		scanf("%d", &b[ii]);
		scanf("%c", &c);
	}

	for (ii = 0; ii < n; ii++) {
		for (jj = 0; jj < m; jj++) {
			ans[ii] += a[ii][jj] * b[jj];
		}
		printf("%d\n", ans[ii]);
	}

	return 0;
}

Measured memory_bytes: 648
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = []
for _ in range(N+1):
    dp.append([0] * (W+1))

for i in range(N):
    for j in range(W+1):
        if j >= wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 120044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>
#define N 101
#define PLL pair<ll, ll>
#define MP make_pair
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
}
using namespace std;
const int P = 1e9 + 7;
int ftot;
ll f[N];
PLL pr[N][N];
inline void work() {
  ll n, m, res = 0; read(n), read(m);
  if (n > m)  swap(n, m);
  if (n == 1) {
    printf("1 %lld\n", m % P);
    return ;
  }
 
  int p;
  p = upper_bound(f + 1, f + 1 + ftot, n) - f - 1;
  if (f[p + 1] > m) --p;
  printf("%d ", p);
  if (p == 1) res = n % P;
  for (int i = 1; i <= p; ++i)
    if (pr[p][i].first <= n && pr[p][i].second <= m)
      res = (res + (m - pr[p][i].second) / pr[p][i].first + 1) % P;
  swap(n, m);
  for (int i = 1; i <= p; ++i)
    if (pr[p][i].first <= n && pr[p][i].second <= m)
      res = (res + (m - pr[p][i].second) / pr[p][i].first + 1) % P;
  printf("%lld\n", (res % P + P) % P);
}
int main() {
  f[0] = f[1] = 1;
  for (int i = 2; f[i - 1] <= 3e18; ++i)  f[i] = f[i - 1] + f[i - 2], ftot = i;
//  printf("f[%d] = %lld\n", ftot, f[ftot]);
  pr[1][1] = MP(1, 2);
  for (int i = 2; i <= 91; ++i) {
    for (int j = 1; j < i; ++j) pr[i][j] = MP(pr[i - 1][j].second, pr[i - 1][j].first + pr[i - 1][j].second);
    ll a = pr[i - 1][1].first, b = pr[i - 1][1].second;
    pr[i][i] = MP(a + b, a + a + b);
    for (int j = 1; j <= i; ++j) {
    	if (pr[i][j].first > 2e18)	pr[i][j].first = 2e18;
    	if (pr[i][j].second > 2e18)	pr[i][j].second = 2e18;
    }
  }
//  for (int i = 1; i <= 91; ++i) {
//  	for (int j = 1; j <= i; ++j) {
//  		printf("(%lld, %lld) ", pr[i][j].first, pr[i][j].second);
//  	}
//  	puts("");
//  }
  int _; read(_);
  while (_--)
    work();
  return 0;
}

Measured memory_bytes: 4488
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n];
    int flag=0,tag=0,count=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]==b[i]){
            if(flag==0) {
                flag=1;
                count++;
            }
            else if(flag==1){
                if(count>=2) tag=1;
                count++;
            }
        }
        else{
            flag=0;
            count=0;
        }
    }
    if(tag==0) cout<<"No"<<"\n";
    else cout<<"Yes"<<"\n";
    return 0;
}

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

int main(){
	ll x;
	cin >> x;
	ll a = (x/500);
	ll temp = x - a*500;
	ll ans = a*1000 + (temp/5)*5;
	cout << ans << endl;
    return 0;
}



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

#define INF (INT32_MAX/4)
#define MOD (1000000000+7)
#define MAX 100000

typedef pair<int, int> P;

int N, M;
P A[MAX];

long long d[MAX + 1];

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
	cin >> N >> M;
	for( int i = 0; i < M; i++ ) {
		int a, b;
		cin >> a >> b;
		A[i].first = a;
		A[i].second = b;
	}

	UnionFind uf( N + 1 );
	d[M] = (long long)N * ( N - 1 ) / 2;
	for( int i = M - 1; i >= 0; i-- ) {
		if( uf.find( A[i].first ) != uf.find( A[i].second ) ) {
			d[i] = d[i + 1] - (long long)uf.size( A[i].first ) * uf.size( A[i].second );
		}
		else {
			d[i] = d[i + 1];
		}
		uf.unite( A[i].first, A[i].second );
	}

	for( int i = 1; i < M + 1; i++ ) {
		cout << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3328