akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100),bufio.NewWriterSize(os.Stdout,100)}
  n := io.NextInt()
  t := make([][]int,n)
  e := make([]Edge,2*(n-1))
  for i:=0;i<n-1;i++ {
    a,b := io.NextInts()
    a,b = a-1,b-1
    e[2*i] = Edge{a,b,i}
    t[a] = append(t[a],2*i)
    e[2*i+1] = Edge{b,a,i}
    t[b] = append(t[b],2*i+1)
  }
  x := 0
  for i:=1;i<n;i++ {
    if len(t[x]) < len(t[i]) { x = i }
  }
  ans := make([]int,n-1)
  var dfs func(int,int,int)
  dfs = func(v,p,c int) {
    k := 1
    for _,i := range t[v] {
      u := e[i]
      if u.to == p { continue }
      if k == c { k++ }
      ans[u.id] = k
      dfs(u.to,v,k)
      k++
    }
  }
  dfs(x,-1,-1)
  io.Println(len(t[x]))
  for i:=0;i<n-1;i++ { io.Println(ans[i]) }
  io.Flush()
}

type Edge struct { fm,to,id int }

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Print(a ...interface{}) (int,error) {
  return fmt.Fprint(io.writer,a...)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInt() int {
  n,_ := strconv.Atoi(io.NextLine())
  return n
}
func(io *IO) NextInts() (int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 38528
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
typedef long long ll;

int main() {
	ll a, b; cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int d[5];
  int k;cin>>d[0]>>d[1]>>d[2]>>d[3]>>d[4]>>k;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(abs(d[i]-d[j])>k){
        cout<<":("<<endl;
        return 0;
      }
    }
  }
  cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int a,b;
string s;
bool yymm,mmyy;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>s;
  a=10*(s[0]-'0')+s[1]-'0';
  b=10*(s[2]-'0')+s[3]-'0';
  if((a==0 && b==0) || (a>12 && b>12) || (a==0 && b>12) || (a>12 && b==0)){
    cout<<"NA"<<endl;
    return 0;
  }
  if(a>0 && a<=12){
    if(b>0 && b<=12)cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }
  else cout<<"YYMM";
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  vector<ll>v(5,0);
  ll k;
  for(ll i=0;i<5;i++){
    cin>>v[i];
  }
  cin>>k;
  if(v[4]-v[0]>k){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    ll a_sum=0,b_sum=0;
    rep(i,n){
        cin >> a[i];
        a_sum += a[i];
    }
    rep(i,n){
        cin >> b[i];
        b_sum += b[i];
    }
    if(a_sum<b_sum){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> c(n);
    rep(i,n){
        c[i] = a[i] - b[i];
    }

    sort(c.begin(),c.end());
    ll need=0;
    int cnt=0;
    int i=0;
    while(c[i]<0){
        need -= c[i];
        cnt++;
        i++;
    }
    i = n-1;
    while(need>0){
        need -= c[i];
        cnt++;
        i--;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=2e5+1;
int n, carry[N], pw[13], tmp[531441], ans[531441], add[531441];
char t[N];
int main() {
	scanf("%d%s", &n, t);
	int m=strlen(t);
	pw[0]=1;
	for(int i=1; i<=n; ++i) pw[i]=pw[i-1]*3;
	for(int i=0; i<n; ++i) {
		int flip=0;
		memset(add, 0, pw[i]*sizeof(int));
		for(int j=0; j<m; ++j) {
			if(t[j]=='S') {
				flip^=1;
			} else {
				int x=carry[j];
				add[x]=(add[x]+(flip?2:1))%3;
				carry[j]+=(3-add[x])%3*pw[i];
			}
		}
		memcpy(tmp, ans, pw[i]*sizeof(int));
		for(int c=0; c<3; ++c) {
			for(int j=0; j<pw[i]; ++j)
				ans[c*pw[i]+j]=tmp[j]+(flip?2:1)*(c+add[j])%3*pw[i];
		}
	}
	for(int i=0; i<pw[n]; ++i) printf("%d ", ans[i]);
	return 0;
}


Measured memory_bytes: 8416
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

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

    if (a > 8 || b > 8)
        cout << ":(";
    else
        cout << "Yay!";
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void) {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(c - a) <= d) {
		cout << "Yes";
	}
	else if (abs(b - a) <= d && abs(c - b) <= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char S[11];
  int T=0,sum=0;
  int i;
  scanf("%s",&S);
    for(i=0; i<S[i]!='\0'; i++){
      if(S[i]=='A' || S[i]=='T' || S[i]=='G'|| S[i]=='C')
         sum++;
      else
        sum=0;
      if(sum>T)
        T=sum;
    }
  printf("%d",T);
         
  return 0;
}

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

int n,last[200010];
long long ans=0;

int main(){
	scanf("%d",&n);
	int bound=0;
//	memset(last,-1,sizeof(last));
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		for(int j=0;j<20;j++){
			if(x&(1<<j)){
				bound=max(bound,last[j]);
				last[j]=i+1;
			}
		}
		ans+=i-bound+1;
	}
	printf("%lld\n",ans);
	return 0;
} 


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>

#define For(a, b, c) for(int a = b; a <= c; ++a)
using namespace std;
char s[51];

inline int read(){
	int u = 0;
	char x = getchar();
	while(x < '0' || x > '9') x = getchar();
	while(x >= '0' && x <= '9') u = (u << 3) + (u << 1) + (x ^ 48), x = getchar();
	return u;
}

int main(){
	cin >> s;
	int l = strlen(s);
	For(i, 0, l - 9) putchar(s[i]);
	return 0;
}

Measured memory_bytes: 256
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

num=0
for i in range(1,n+1,2):

    cnt=0
    for j in range(1,i+1):
        
        if i % j==0:
            
            cnt+=1

    if cnt==8:
        
        num+=1
        
print(num)
    

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

ifstream in("test.in");
ofstream out("test.out");

int main(void) {
    ios :: sync_with_stdio(false);
    cin.tie(); cout.tie();
    
    int n, m, k;
    cin >> n >> m >> k;
    
    if (n > m)
        swap(n, m);
    
    bool ok = false;
    for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
        ok |= (i * m + j * (n - (i << 1)) == k);
    
    cout << (ok ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
#include<assert.h>
#include<complex.h>
#include<ctype.h>
#include<errno.h>
#include<fenv.h>
#include<float.h>
#include<inttypes.h>
#include<iso646.h>
#include<limits.h>
#include<locale.h>
#include<math.h>
#include<setjmp.h>
#include<signal.h>
#include<stdalign.h>
#include<stdarg.h>
#include<stdatomic.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdnoreturn.h>
#include<string.h>
#include<tgmath.h>
#include<time.h>
#define SIZE 200000

int main(){
    int K,N;
    int A[SIZE];
    scanf("%d %d",&K,&N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&A[i]);
    }
    int max = K - A[N-1] + A[0];
    for(int i = 1 ; i <= N-1 ; i++){
        if(max < A[i] -A[i-1]){
            max = A[i]-A[i-1];
        }
    }
    printf("%d",K-max);
    return 0;
}

Measured memory_bytes: 896
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    if n == 1:
        return 0
    a = LI_()
    b = [0]
    c = [[None] * 18]
    for i in range(n-1):
        t = a[i]
        b.append(b[t] + 1)
        d = [None] * 18
        d[0] = t
        for j in range(1,18):
            if c[d[j-1]][j-1] is None:
                break
            d[j] = c[d[j-1]][j-1]
        c.append(d)

    ii = [2**i for i in range(19)]
    def f(i,j):
        if i == j:
            return 0
        if b[i] > b[j]:
            sa = b[i] - b[j]
            for k in range(1,18):
                if sa < ii[k]:
                    return ii[k-1] + f(c[i][k-1], j)
        if b[i] < b[j]:
            sa = b[j] - b[i]
            for k in range(1,18):
                if sa < ii[k]:
                    return ii[k-1] + f(c[j][k-1], i)
        for k in range(1,18):
            if c[i][k] == c[j][k]:
                return ii[k] + f(c[i][k-1], c[j][k-1])

    ba = sorted(zip(b, range(n)))
    aa = [0]
    aai = {}
    aai[0] = 0
    i = 1
    while i < n:
        j = i + 1
        bi = ba[i][0]
        while j < n and bi == ba[j][0]:
            j += 1
        aa.extend(list(map(lambda x: x[1], sorted([[aai[c[_][0]], _] for k,_ in ba[i:j]]))))
        for k in range(i,j):
            aai[aa[k]] = k
        i = j
    r = 1
    for i in range(1,n-1):
        r += f(aa[i],aa[i+1])

    return r


print(main())



Measured memory_bytes: 60944
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int num = A[0];
	int judge = INF;
	int cnt = 0;
	rep(i, N - 1) {
		if (judge == INF) {
			if (A[i + 1] > num) {
				judge = 1;
				num = A[i + 1];
			}
			else if(A[i + 1] < num) {
				judge = -1;
				num = A[i + 1];
			}
		}
		else if (judge == 1) {
			if (A[i + 1] < num) {
				cnt++;
				judge = INF;
				num = A[i + 1];
			}
			else num = A[i + 1];
		}
		else if (judge == -1) {
			if (A[i + 1] > num) {
				cnt++;
				judge = INF;
				num = A[i + 1];
			}
			else num = A[i + 1];
		}
	}
	cout << cnt + 1;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define m3(a, b, c) min(c, min(a, b))
#define m4(a, b, c, d) min(d, min(c, min(a, b)))
#define test long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const ll maxn=1e16+100;
 


 int main()
 {  IOS;
   ll n,k;
   cin>>n>>k;
   ll a[n];
   for(auto &i:a) cin>>i;
vector<ll>dp(n,maxn);
dp[0]=0;

for(int i=0;i<n;i++)
{
    for(int j=i+1;j<=i+k;j++)
    {
        if(j<n)
        {  
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }
}
cout<<dp[n-1];
   
 }

Measured memory_bytes: 4752
#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 main() {

    int N;
    cin >> N;
    string S[N];
    for(int i = 0; i < N; i++) cin>>S[i];

    map<string, int> M;
    for(int i = 0; i < N; i++){
        M[S[i]]++;
    }

    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;
    return 0;
}

Measured memory_bytes: 6704
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int A[2010];
    long N,K;
    long MOD = 1e9+7;
    long ans = 0;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    array<pair<int,int>,2010> v;
    //<sum,after>
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[j]<A[i]){
                v[i].first ++;
                if(j>i){
                    v[i].second ++;
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        ans += v[i].second * K;
        ans %= MOD;
        long current = (((K-1)*K)/2)%MOD;
        ans += v[i].first * current;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

city = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    city[a-1][b-1] += 1
    city[b-1][a-1] += 1

for i in range(n):
    print(sum(city[i]))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int main () {
    int n, r;
    while (cin >> n >> r) {
        if (n >= 10) {
            cout << r << "\n";
        }
        else {
            cout << r + 100 * (10 - n) << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = [input() for _ in range(n)]
dic = {}
for x in a:
    if x not in dic:
        dic[x] = 0
for x in a:
    dic[x] += 1
dic = sorted(dic.items(),reverse = True ,key = lambda x : x[1])
res = []
maxv = dic[0][1]
for i in range(len(dic)):
    if maxv == dic[i][1]:
        res.append(dic[i][0])
resN = sorted(res)
[print(x) for x in resN]

Measured memory_bytes: 44684
n, m = map(int, input().split())
lst = [[0, 0] for _ in range(n)]

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        lst[p-1][0] = 1
    elif lst[p-1][0] == 0:
        lst[p-1]    [1] += 1

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

if __name__=="__main__":
    a,b=map(int,input().split())
    b//=gcd(a,b)
    a,c=2,1
    while a**2<=b:
        if b%a==0:
            c*=a
            while b%a==0: b//=a
        a+=1
    print(c if b==1 else c*b)

Measured memory_bytes: 7748
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e8
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y){
    return y?gcd(y,x%y):x;
}

ll lcm(ll x, ll y){
    return x/gcd(x,y)*y;
}
int main() {
    ll n, m; cin >> n >> m;
    vector<ll> v(n);
    rep(i,n) {
        cin >> v[i];
        v[i] /= 2;
    }

    ll gcdnum = 1;
    rep(i,n) {
        gcdnum = lcm(gcdnum,v[i]);
        if(m<gcdnum) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i,n) {
        if((gcdnum/v[i])%2==0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = m / gcdnum;
    ans = (ans+1)/2;
    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]


class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


uf = UnionFind(N)
for a, b in AB:
    uf.union(a - 1, b - 1)

max_ = 0
roots = uf.roots()

for r in roots:
    max_ = max(max_, uf.size(r))

print(max_)


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

int N;
int P[8], Q[8];
int v[8];

bool checkP() {
    for (int i = 0; i < N; i++) {
        if (P[i] != v[i]) return false;
    }
    return true;
}
bool checkQ() {
    for (int i = 0; i < N; i++) {
        if (Q[i] != v[i]) return false;
    }
    return true;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        v[i-1] = i;
    }
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }
    int flag1, flag2, cnt = 0;
    do {
        if (checkP()) flag1 = cnt;
        if (checkQ()) flag2 = cnt;
        cnt++;
    }
    while(next_permutation(v, v + N));
    cout << abs(flag1 - flag2) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl A(N);
    ll ans=1;
    ll now=1;
    ll cnt=N;
    rep(i,N){
        cin >> A[i];
        if(A[i]<now){
            ans*=(i+1-(N-cnt));
            ans%=MOD;
            cnt--;
            now-=2;
        }
        now+=2;
    }
    FOR(i,1,cnt+1){
        ans*=i;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
import sys
argVec = sys.argv
if len(argVec) > 1:
    GBN_DEBUG = True
else:
    GBN_DEBUG = False

#S = input()
N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
S = [input() for _ in range(N)]
#A = A = list(map(int, input().split()))

def dprn(s, i):
    if GBN_DEBUG:
        print(", " + s + " = " + str(i), end = "")

def dprns(s):
    if GBN_DEBUG:
        print(", " + s, end = "")

def dprni(i):
    if GBN_DEBUG:
        print(str(i), end=" ")

def puts(s):
    print(s)

def puti(i):
    print(str(i))

startM = 0
startA = 0
startR = 0
startC = 0
startH = 0

for i in range(N):
    if S[i][0] == 'M':
        startM += 1
    if S[i][0] == 'A':
        startA += 1
    if S[i][0] == 'R':
        startR += 1
    if S[i][0] == 'C':
        startC += 1
    if S[i][0] == 'H':
        startH += 1

mar = startM * startA * startR
mac = startM * startA * startC
mah = startM * startA * startH
mrc = startM * startR * startC
mrh = startM * startR * startH
mch = startM * startC * startH
arc = startA * startR * startC
arh = startA * startR * startH
ach = startA * startC * startH
rch = startR * startC * startH

ans = mar + mac + mah + mrc + mrh + mch + arc + arh + ach + rch
puti(ans)

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

//flagを用いたバブルソート
int bubbleSort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				//隣接要素を交換する
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main() {
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	sw = bubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
char sig[3]={'-','+','*'};
char g[50];
void swap(int *x,int *y){
	int z;
	z=*x;*x=*y;*y=z;
}
char* sign(char *x,char *y,int c){
	if(c<3)sprintf(g,"(%s %c %s)",x,sig[c%3],y);
	else sprintf(g,"(%s %c %s)",y,sig[c%3],x);
	return g;
}
int calc(int x,int y,int c){
	switch(c){
	case 0:return x-y;
	case 1:return x+y;
	case 2:return x*y;
	case 3:return y-x;
	}
	return 0;
}
int check(int a,int b,int c,int d,int o){
	int i,j,k;
	char p[50],q[50],r[50],s[50];
	sprintf(p,"%d",a);
	sprintf(q,"%d",b);
	sprintf(r,"%d",c);
	sprintf(s,"%d",d);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			for(k=0;k<4;k++){
				if(o){
					if(calc(calc(a,b,i),calc(c,d,j),k)==10){
						if(i==3)swap(&a,&b);
						if(j==3)swap(&c,&d);
						if(k==3){swap(&a,&c);swap(&b,&d);swap(&i,&j);}
						printf("((%d %c %d) %c (%d %c %d))\n",a,sig[i%3],b,sig[k%3],c,sig[j%3],d);
						return 1;}
				}

				if(calc(calc(calc(a,b,i),c,j),d,k)==10){
					strcpy(p,sign(p,q,i));
					strcpy(p,sign(p,r,j));
					strcpy(p,sign(p,s,k));
					printf("%s\n",p);return 1;}
			}
		}
	}
	return 0;
}
int main(void){
	int a,b,c,d;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF){
		if(a==0 && b==0 && c==0 && d==0)break;
		if(check(a,b,c,d,1))continue;
		if(check(a,c,b,d,1))continue;
		if(check(a,d,c,b,1))continue;
		if(check(c,d,a,b,0))continue;
		if(check(b,d,a,c,0))continue;
		if(check(b,c,a,d,0))continue;
		if(check(a,b,d,c,0))continue;
		if(check(a,c,d,b,0))continue;
		if(check(a,d,b,c,0))continue;
		if(check(c,d,b,a,0))continue;
		if(check(b,d,c,a,0))continue;
		if(check(b,c,d,a,0))continue;
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 628
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> ans;
    set<int> used;

    int start = N / 2;
    int end = N / 2 + 1;
    int cnt = 0;
    ans.push_back({start, end});
    used.insert(1 + end - start);
    used.insert(N - (end - start - 1));
    cnt++;
    start--;
    end++;
    while (cnt < M) {
        while (1) {
            // int x = start + N - end;
            // printf("start: %d, end: %d, x: %d\n", start, end, x);
            if (used.find(1 + end - start) != used.end()
                    || used.find(N - (end - start - 1)) != used.end()
                    || end - start == start + N - end) {
                if (end < N) {
                    end++;
                } else {
                    start--;
                }
            } else {
                break;
            }
        }
        assert(start >= 1 && end <= N);
        ans.push_back({start, end});
        used.insert(1 + end - start);
        used.insert(N - (end - start - 1));
        cnt++;
        start--;
        end++;
    }

    for (auto &p : ans) {
        cout << p.first << " " << p.second << endl;
    }

    return 0;
}


Measured memory_bytes: 12336
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N,K = MI()
P = LI()

P = sorted(P)

ans = sum(P[:K])

print(ans)

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

int main(){
  int n, m, x[100001];

  cin >> n >> m;

  for(int i=0; i<m; ++i) cin >> x[i];

  sort(x, x+m);

  for(int i=0; i<m-1; ++i){
    x[i] = x[i+1] - x[i];
  }

  sort(x, x+m-1);
  


  long long ans = 0;
  for(int i=0; i<m - 1 - n + 1; ++i){
    ans += x[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int a[32] = {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 << a[k - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	b := make([]int, n)
	ans := make([]int, 0, n)
	for i := len(a); i >= 1; i-- {
		x := 0
		for j := 2; j <= n; j++ {
			if i*j > n {
				break
			}
			x ^= b[i*j-1]
		}
		b[i-1] = x ^ a[i-1]
		if b[i-1] == 1 {
			ans = append(ans, i)
		}
	}

	fmt.Println(len(ans))
	for i, v := range ans {
		if i == len(ans)-1 {
			fmt.Println(v)
			continue
		}
		fmt.Printf("%d ", v)
	}
}


Measured memory_bytes: 6272
X,Y = map(int,input().split())

ans = 0
if(X == 3): ans += 100000
elif(X == 2): ans += 200000
elif(X == 1): ans += 300000
  
if(Y == 3): ans += 100000
elif(Y == 2): ans += 200000
elif(Y == 1): ans += 300000
  
if(ans == 600000): ans += 400000
print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  int n,W;
  cin >> n >> W;
  vector<int> v,w;
  REP(i,n){
    int x,y;cin >> x >> y;
    v.push_back(y);
    w.push_back(x);
  }
  ll dp[105][100100];
  for(int i = 0;i <= W;i++)dp[0][i] = 0;
  for(int i = 1;i <= n;i++){
    for(int j = 0;j <=W;j++){
      if(j >= w[i-1]){
        dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
      }else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  cout << dp[n][W] << endl;


  
  


  return 0;
}


Measured memory_bytes: 80896
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans = 700;
    if(S[0] == 'o') ans += 100;
    if(S[1] == 'o') ans += 100;
    if(S[2] == 'o') ans += 100;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=1505;
int a,b;
string s;
int main()
{
	cin>>a>>b;
	cin>>s;
	if(a+b+1!=s.length())
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<s.length();i++)
	{
		if(i==a)
		{
			if(s[i]!='-')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		else if(s[i]<'0'||s[i]>'9')
			{
				cout<<"No"<<endl;
				return 0;
			}
	}
	cout<<"Yes"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
def function(numbers):
    L = int(numbers[0])
    R = int(numbers[1])
    d = int(numbers[2])
    number = 0
    i = L
    while(i <= R):
        if i % d == 0:
            number += 1
        i += 1
    return number


if __name__ == '__main__':
    numbers = input().split()
    print(function(numbers))


Measured memory_bytes: 9112
import sys
input = sys.stdin.readline
N = int(input())
s = [int(input()) for _ in range(N)]

s.sort()
ans = sum(s)
if ans%10 == 0 :
    for score in s :
        if (ans-score)%10 != 0 :
            print(ans-score)
            exit()
    print(0)
else :
    print(ans)



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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < s.length(); i++) {
            int misMatchCount = 0;
            boolean  flag = true;
            for (int j = 0; j < t.length(); j++) {
                if(i + j >= s.length()){
                    flag = false;
                    break;
                }
                if(s.charAt(i+ j) != t.charAt(j)) {
                    ++misMatchCount;
                }
            }
            if(flag)
                ans = Math.min(ans,misMatchCount);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 33340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pi 2*acos(0.0)
#define mod 998244353

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

    ll n;
    cin >> n;

    ll min = INT_MAX, max = -1;

    while(n--){
        ll num;
        cin >> num;

        if(num>max)
            max = num;
        
        if(num<min)
            min = num;
    }

    cout << max-min<<endl;

    return 0;
}

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

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

	 map<string, int> s;
	for (int i = 0; i < n; i++) {
      string a;
      cin >> a;
      s[a]++;
    }
 
	int a = 1;
	for (auto p : s) {
		auto k = p.first;
		auto v = p.second;
		if (v > a) a = v;
		}
	for (auto p : s) {
		auto k = p.first;
		auto v = p.second;
      if ( v == a) cout << k << endl;
	}
}

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

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

	int ans=0,m=0;
	for(int i=0; i<n; i++){
		int p;
		cin >> p;
		ans += p;
		m = max(m,p);
	}
	ans -= m/2;
	cout << ans << endl;

	return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
#define ld long double

const int mod = 1000000007;
const ld PI = acosl(-1.0);
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    int ans = n;
    for(int i = 0; i <= n - m; i++)
    {
        temp = 0;
        for(int j = 0, k = i; j < m; j++, k++)
        {
            // cout<<s[k]<<gp<<t[j]<<endl;
            if(s[k] != t[j])
            temp++;
        }
        // cout<<i<<gp<<temp<<endl;
        ans = min(ans, temp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(123456789012345678)


unsigned GetDigit(unsigned num) {
    return std::to_string(num).length();
}


int main(void){
	ll N, M;
	cin >> N >> M;
	vector<pair<ll,ll> > pf[100001];
	int ANSP[100001];
	int ANSX[100001];

	reps(i, M)	{
		int p, y;	cin >> p >> y;
		ANSP[i] = p;
		pair<ll, ll> pa;
		pa.first = y;
		pa.second = i;
		// P[i] = a, Y[i] = b;
		pf[p].push_back(pa);
	}

	reps(p, N) {
		sort(pf[p].begin(), pf[p].end());
		rep(x, pf[p].size()) {
			ANSX[pf[p][x].second] = x+1;
		}
	}

	reps(i, M) {
		int len_p = 6 - GetDigit(ANSP[i]);
		std::string str_p(len_p, '0');
		int len_x = 6 - GetDigit(ANSX[i]);
		std::string str_x(len_x, '0');
			cout << str_p << ANSP[i] << str_x << ANSX[i];
			cout << endl;
	}

	return 0;
}


Measured memory_bytes: 7808
from collections import deque
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
neig = [(1, 0), (0, 1), (-1, 0), (0, -1)]

road = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            road.append((h, w))

ans = 0
for rh, rw in road:
    SC, q = copy.deepcopy(S), deque([(rh, rw, 0)])
    SC[rh][rw] = 0
    while len(q) > 0:
        h, w, i = q.popleft()
        for nh, nw in neig:
            if 0 <= h - nh < H and 0 <= w - nw < W and SC[h - nh][w - nw] == '.':
                SC[h - nh][w - nw] = i + 1
                ans = max(ans, i + 1)
                q.append([h - nh, w - nw, i + 1])

print(ans)


Measured memory_bytes: 55516
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    while (T--){
        cin >> n;
        int acum = 0;
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            int a, b; cin >> a >> b;
            if (a == b) acum++;
            else acum = 0;
            if (acum >= 3) ans=1;
        }
        cout << (ans ? "Yes\n": "No\n");
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n,d;
  cin>>n>>d;
  cout<<(n+2*d)/(2*d+1);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
def maxHeapify(h, a, i)
  l = left(i)
  r = right(i)
  # 左の子、自分、右の子で値が最大のノードを選ぶ
  if l <= h && a[l] > a[i]
    largest = l
  else
    largest = i
  end

  if r <= h && a[r] > a[largest]
    largest = r
  end

  if largest != i # i の子の方が値が大きい場合
    a[i],a[largest] = a[largest],a[i]
    maxHeapify(h, a, largest) # 再帰的に呼び出し
  end
end

def buildMaxHeap(h, a)
  (h/2).downto(1){|i|
    maxHeapify(h, a, i)
  }
end

def right(i);
  (i*2)
end

def left(i)
  (i*2+1)
end

h = gets.to_i
a = [0] + gets.split.map(&:to_i)

buildMaxHeap(h, a)

puts " "+a[1..-1]*" "




Measured memory_bytes: 50664
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
ans="No"
if a==b:
  if a!=c:
    ans = "Yes"
if b==c:
  if a!=c:
    ans = "Yes"
if a==c:
  if b!=c:
    ans = "Yes"
# 出力
print(ans)

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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  int count_EtoW=0;
  for(int i=1; i<N; i++) if(S[i]=='E') count_EtoW += 1;

  int ans=count_EtoW;
  int count_WtoE=0;
  for(int i=0; i<N-1; i++){
    if(S[i]=='W') count_WtoE += 1;
    if(S[i+1]=='E') count_EtoW -= 1;
    ans = min(ans, count_EtoW+count_WtoE);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m,f,b;
	cin >> m >> f >> b;
	if(f>=b-m){
		if(b-m>0){
			cout << b-m << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
	else{
		cout << "NA" << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int n;
void dfs(string s, char mx) {
  if (s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= mx + 1; c++) {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main() {
  cin >> n;
  dfs("", 'a' - 1);
}

Measured memory_bytes: 3632
n=int(input())
bl=list(map(int,input().split()))
al=[0 for i in range(n)]
al[n-1]=bl[n-2]
for i in range(n-2,-1,-1):
    if al[i+1]>bl[i]:
        al[i+1]=bl[i]
    al[i]=bl[i]
print(sum(al))


Measured memory_bytes: 2940
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parents = [i for i in range(N)]
        self.sizes = [1] * N

    def root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.root(self.parents[x])
        return self.parents[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx < ry:
            self.parents[ry] = rx
            self.sizes[rx] += self.sizes[ry]
            self.sizes[ry] = 0
        elif rx > ry:
            self.parents[rx] = ry
            self.sizes[ry] += self.sizes[rx]
            self.sizes[rx] = 0

    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return self.sizes[self.root(x)]

N, M, K = list(map(int, input().split()))
AB_list = []
for _ in range(M):
    A, B = list(map(int, input().split()))
    AB_list.append([A - 1, B - 1])
CD_list = []
for _ in range(K):
    C, D = list(map(int, input().split()))
    CD_list.append([C - 1, D - 1])

uf = UnionFind(N)
for A, B in AB_list:
    uf.unite(A, B)

friends = [0] * N
for A, B in AB_list:
    friends[A] += 1
    friends[B] += 1
blocks = [0] * N
for C, D in CD_list:
    if uf.root(C) != uf.root(D):
        continue
    blocks[C] += 1
    blocks[D] += 1
answers = [0] * N
for i in range(N):
    answers[i] = uf.size(i) - 1 - friends[i] - blocks[i]

print(" ".join(map(str, answers)))

Measured memory_bytes: 51208
import java.util.Scanner;

public class  Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		if(a<=0&&b>=0) {
			System.out.println("Zero");
		} else if(a>0) {
			System.out.println("Positive");
		} else if((b-a+1)%2==0) {
			System.out.println("Positive");
		} else {
			System.out.println("Negative");
		}
	}
}


Measured memory_bytes: 22996
#関数リスト
import sys
import bisect
input = sys.stdin.readline
def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N = I()
    A = LI()
    A.sort()
    B = LI()
    B.sort()
    B_len = len(B)
    C = LI()
    C.sort()
    C_len = len(C)
    result = 0
    A_init = A[0]
    index = 0
    next_i = index
    
    for i in B:
        tempA = bisect.bisect_left(A,i) 
        tempC = C_len - bisect.bisect_right(C,i)
        result += tempA*tempC
    print(result)

if __name__ == "__main__":
    main()


Measured memory_bytes: 98660
n = int(input())
a = list(map(int,input().split()))
x =0
for i,w in enumerate(a):
    if i % 2:
        w*=-1
    x += w
ans = [x]
for i,t in enumerate(a[:-1]):
    ans.append(int(((ans[i]/2)-t)*(-2)))
print(' '.join(map(str, ans)))

Measured memory_bytes: 19144
<?php
fscanf(STDIN,"%d%d",$L,$R);
$min=2019;
for($l=$L;$l<=$L+2019;$l++){
	for($r=$l+1;$r<=$R;$r++){
	    $mod=($l*$r)%2019;
	    if($mod<$min){
	        $min=$mod;
	    }
	    if($min==0)break;
	}
}
echo $min;


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int k;
      cin >> k;
      mp[k]++;
    }
  }
  int ans = 0;
  for (auto m : mp) {
    if (m.second == N)
      ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

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

fromLeft = [a[0]] + [None] * (n - 1)
for i in range(1, n):
    fromLeft[i] = gcd(fromLeft[i - 1], a[i])
fromRight = [None] * (n - 1) + [a[-1]]
for i in range(n - 2, -1, -1):
    fromRight[i] = gcd(fromRight[i + 1], a[i])
ret = 1
for repr in range(n):
    if repr == 0:
        curGcd = fromRight[repr + 1]
    elif repr == n - 1:
        curGcd = fromLeft[repr - 1]
    else:
        curGcd = gcd(fromLeft[repr - 1], fromRight[repr + 1])
    ret = max(ret, curGcd)
print(ret)


Measured memory_bytes: 14076
#include<bits/stdc++.h>
using namespace std;
// size_t f = string::npos
// make pair, tuple
//
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }

int main(){
      long long int a,b;cin >> a >> b;
      long long int x = min(a, b);
      long long int y = max(a, b);
      long long int c = x;
      long long int p = 2;
      while(c % x != 0 || c % y != 0){
            c = x * p++;
      }
      cout << c;
}

Measured memory_bytes: 256