akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;  
  
typedef long long LL;
const LL mod=1000000007;
LL dp[1001][1001];  
void solve(int n,int m)  
{  
    dp[0][0] = 1;  
    for (int i = 1; i <= m; i++){  
        for (int j = 0; j <= n; j++){  
            if (j - i >= 0){  
                dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % mod;
            }  
            else{  
                dp[i][j] = dp[i - 1][j];  
            }  
        }  
    }  
}  
LL mypow[1001][1001],fpow[1001][1001];
int a[1001],b[1001];
LL qukpow(int i,int j)  
{
	return mypow[i][j];
}
LL fp[1001][1001];
int main()  
{  
	for(int i=0;i<=400;++i)
	{
		mypow[i][0]=1;
		for(int j=1;j<=400;++j)
			mypow[i][j]=mypow[i][j-1]*i%mod;
	}
	solve(1000,1000);
	//dp[n][m]-dp[n][m-1] n to m
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;++i)
		for(int j=a[i];j<=b[i];++j)
			for(int k=0;k<=m;++k)
				fpow[i][k]=(fpow[i][k]+qukpow(j,k))%mod;
	
	LL tmp,ans=0;
	fp[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
			//fp[i-1][j]
			if(fp[i-1][j]==0)continue;
			for(int k=0;k<=m-j;++k)
			{
				fp[i][j+k]+=fp[i-1][j]*fpow[i][k];
				fp[i][j+k]%=mod;
			}
		}
	cout <<fp[n][m]<<endl;
    return 0;  
}  



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

int sumnumbers(int x){
    int y = 0;
    while (x > 0){
        y += x % 10;
        x /= 10;
    }
    return y;
}

int main() {
    int N;
    cin >> N;
    int min;
    for(int i = 1; i <= N / 2 + 1; i++){
        int A = i;
        int B = N - i;
        if(i == 1){
            min = sumnumbers(A) + sumnumbers(B);
        }else if(sumnumbers(A) + sumnumbers(B) < min){
            min = sumnumbers(A) + sumnumbers(B);
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int m1 = H1 * 60 + M1;
		int m2 = H2 * 60 + M2;
		Console.WriteLine(Math.Max(0, m2 - K - m1));
		
	}
	int H1,M1,H2,M2,K;
	public Sol(){
		var d = ria();
		H1 = d[0]; M1 = d[1]; H2 = d[2]; M2 = d[3]; K = d[4];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17900
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
ls=[input().split() for i in range(N)]
flg=False
alist=[[0 for p in range(M)] for q in range(2**N)]#全部の場合、2^N通りの成熟度をここに入れたい
clist=[0]*2**N #全部の場合の金額
for k in range(2**N):
    for i in range(N):
        if (k>>i) & 1:
            c=int(ls[i][0])
            clist[k]+=c
            for j in range(M):
                a=int(ls[i][j+1])
                alist[k][j]+=a
    if min(alist[k])<X:
        clist[k]=12*10**5+1
    else:
        flg=True
if flg:
    clist.sort()
    print(clist[0])
else:
    print('-1')


Measured memory_bytes: 11208
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

#define MH 20001
#define inf 1e12

ll dp[1000+1][MH];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int h,n;
  cin>>h>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,MH) dp[0][i]=inf;
  dp[0][0]=0;
  rep(i,n) {
    rep(j,MH) {
      dp[i+1][j]=dp[i][j];
      if(j-a[i]>=0) {
	dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
      }
    }
  }
  ll ans=inf;
  repeat(i,h,MH) {
    ans=min(ans,dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N,A=0,B=0,C=0,ans=0;
    cin >> N;

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

        if(S[0]=='B'){
            if(S.back()=='A'){
                C++;
            }else{
                B++;
            }
        }else{
            if(S.back()=='A'){
                A++;
            }
        }

        for(int i=1;i<S.size();i++){
            if(S[i]=='B' && S[i-1]=='A'){
                ans++;
                i++;
            }
        }
    }

    if(C==0){
        cout << ans + min(A,B) << endl;
    }else if(A==B && A==0){
        cout << ans + C - 1 << endl;
    }else{
        cout << ans + C + min(A,B) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int>v[200000];
int t[200000];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	queue<int>q;
	q.push(1);
	q.push(n);
	t[1]=1;
	t[n]=2;
    int f=0,s=0;
	while(!q.empty())
	{
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++)
		{
			int b=v[a][i];
			if(t[b]==0)
			{
				q.push(b);
				t[b]=t[a];
				if(t[b]==1)
					f++;
				else
					s++;
			}
		}
	}
	if(f>s)
		cout<<"Fennec";
	else
		cout<<"Snuke";

	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	map<int, int> cnt;
	ll ans = 0;
	rep(i, 0, N) {
		ans += cnt[i - A[i]];
		cnt[A[i] + i]++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 21356
# -*- coding: utf-8 -*-
n = int(input())
s = list(str(input()))

x = 0
ans = 0
for i in range(n):
    if s[i] == 'I':
        x += 1
    if s[i] == 'D':
        x -= 1
    if ans < x:
        ans = x
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int n,T;
	cin >> n >> T;

	vector< int > c(n);
	vector< int > t(n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> c[i] >> t[i];
	}

	int mincost = 1000;
	bool flag = true;
	
	for(int i = 0; i < n; i++)
	{
		if(t[i] <= T){
			mincost = min(mincost, c[i]);
			flag = false;
		}
	}
	
	if (flag == true){
		cout << "TLE" << endl;
	}else{
		cout << mincost << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <assert.h>
#include <functional>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first
#define  sec second
#define  SZ(x) (x.size())
#define  inf 0x3f3f3f3f
#define  PB push_back
#define  MP make_pair
#define  all(x) (x).begin(),(x).end()
#define  PII pair<int,int>
#define  E 2.7182818284590452353602874713527
using namespace std;

/**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const ll mod = 9901;
ll ksm(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
/********************************Head----Template**********************************************/

multiset<int>s;
vector<int>vec;

ll dp[100007][3];

ll a[100007],b[100007];

int main (){
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]=abs(a[i]);
    int cnt=0;
    int kk=0;
    for(int i=1;i<=n;i++){
        if(a[i]<0) cnt++;
        else if(a[i]==0) kk++;
    }
    if(cnt%2==0||kk){
        ll tmp=0;
        for(int i=1;i<=n;i++) tmp+=abs(a[i]);
        cout<<tmp<<endl;
    }
    else {
        ll Min=1000000000000,ans=0;
        for(int i=1;i<=n;i++) Min=min(b[i],Min),ans+=b[i];
        //cout<<ans<<endl;
        cout<<ans-2ll*Min<<endl;
        return 0;
    }
    return 0;
}



Measured memory_bytes: 1792
import sys
S=input()
if S[0]==S[1]:
    if S[2]==S[3] and S[0]!=S[2]:
        print("Yes")
        sys.exit()
elif S[0]==S[2]:
    if S[1]==S[3]:
        print("Yes")
        sys.exit()
elif S[0]==S[3]:
    if S[1]==S[2]:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3064
loop do
  n,q = gets.split.map(&:to_i)
  break if n==0

  conv = Array.new(100,0)
  n.times do
    _, *d = gets.split.map(&:to_i)

    next if d.nil?
    d.each do |i|
      conv[i] += 1
    end
  end

  best = conv.each_with_index.sort_by{|num,i| [-num,i]}[0]
  if best[0] < q
    puts 0
  else
    puts best[1]
  end
end

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

int main() {
    int n, m;
    priority_queue<int>q;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        q.push(x);
    }
    long long ans = 0;
    while (!q.empty() && m) {
        int temp = q.top();
        q.pop();
        q.push(temp/2);
        m--;
    }
    while (!q.empty()) {
        int temp = q.top();
        ans = ans + 1LL * temp;
        q.pop();
    }
    printf("%lld\n", ans);
    return 0;
}

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

const ll mod = 1000000007;
int cb[60][2];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        ll v; cin >> v;
        for (int j = 0; j < 60; j++)
            cb[j][(v >> j) & 1]++;
    }
    ll ans = 0;
    for (int i = 0; i < 60; i++)
        ans = (ans + (1ll << i) % mod * cb[i][0] % mod * cb[i][1]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    #N = map(int, open(0).read().split())
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    cnt = 0

    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                #print(i,j,k,sep=' - ',end=' ')
                #print(i*500 + j*100 + k*50)
                if x == i*500 + j*100 + k*50:
                    cnt += 1
    print(cnt)
main()


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var s, t string
	var ans int
	fmt.Scan(&s, &t)
	for index, key := range s {
		if string(key) != t[index:index+1] {
			ans += 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3392
#include<stdio.h>

int main(){

  int n,m,s[10000],t[500],i,j,count = 0;

  scanf("%d",&n);

  for(i = 0; i < n ;i++){

    scanf("%d",&s[i]);
  }

  scanf("%d",&m);

  for(i = 0; i < m ; i++){

    scanf("%d",&t[i]);
  }

  for(i = 0 ; i < m; i++){
    for(j = 0; j < n; j++){

      if(t[i] == s[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);

  return 0;
}
	
   



Measured memory_bytes: 2100
while True:
    n=input()
    if n==0:break
    d={}
    for i in range(n):
        num,h,w=map(int,raw_input().split())
        d[num]=w/pow(h/100.0,2)
    diff=100
    best=0
    for i in d.values():
        if abs(i-22)<diff:
            diff=abs(i-22)
            best=i
    print sorted([i for i,j in d.items() if j==best])[0]

Measured memory_bytes: 4372
#include<stdio.h>

int main(){
int n,i,j,a[100];
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++){
for(j=0;j<i;j++){
if(a[i]>a[j]){
int tmp=a[i];
a[i]=a[j];
a[j]=tmp;
}
}
}
int alice=0,bob=0;
for(i=0;i<n;i++){
if(i%2==0)alice+=a[i];
else bob+=a[i];
}
printf("%d\n",alice-bob);
return 0;
}

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

int x[MAX], y[MAX], h[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n;

    cin>>n;

    for(int i = 1; i <= n; i++){
        cin>>x[i]>>y[i]>>h[i];
    }

    int X, Y, H;

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            H = abs(i - x[1]) + abs(j - y[1]) + h[1]; 
            for(int k = 1; k <= n; k++){
                if(h[k] > 0){
                    H = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    break;
                }
            }
            bool flag = true;
            for(int k = 1; k <= n; k++){
                int temp = max(0, H - abs(x[k] - i) - abs(y[k] - j));
                if(temp != h[k]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout<<i<<" "<<j<<" "<<H<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( b % a == 0 ) cout << a + b << endl;
	else cout << b - a << endl;
	
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vi v(n), w(n);
    rep(i, n) {
        cin >> v[i] >> w[i];
    }

    vi dp(W+1);
    rep(i, n) {
        rep(j, W-w[i]+1) {
            dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
        }
    }

    rep(i, W) {
        dp[i+1] = max(dp[i+1], dp[i]);
    }

    cout << dp[W] << endl;
}


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

int main()
{
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N), S(N + 1, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    A.at(i)--;
    S.at(i + 1) = (S.at(i) + A.at(i)) % K;
  }
  map<int64_t, int64_t> mp;
  for (int i = 0; i < min(K, N + 1); i++)
  {
    mp[S.at(i)]++;
  }
  int64_t ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++)
  {
    ans += it->second * (it->second - 1) / 2;
  }
  for (int i = 0; i + K <= N; i++)
  {
    mp[S[i]]--;
    mp[S[i + K]]++;
    ans += mp[S[i + K]] - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 18776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll X,Y; cin >> X >> Y;
    
    if(X == 1) res += 300000;
    else if(X == 2) res += 200000;
    else if(X == 3) res += 100000;
    
    if(Y == 1) res += 300000;
    else if(Y == 2) res += 200000;
    else if(Y == 3) res += 100000;
    
    if(X == 1 && Y == 1) res += 400000;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,b,n,c=0;
    cin>>x>>b;
    n=x+b+1;
    char a[n];
    cin>>a;

    if(a[x]!='-') cout<<"No";
    else
    {
        for(int i=0; i<n; i++)
        {
            if(i!=x)
            {
                if(a[i]=='0' || a[i]=='1' || a[i]=='2' || a[i]=='3' || a[i]=='4' || a[i]=='5' || a[i]=='6' || a[i]=='7' || a[i]=='8' || a[i]=='9')
                {
                    c++;
                }
                else{
                    cout<<"No";
                    return 0;
                }
            }
        }
        cout<<"Yes";
    }
    return 0;
}


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

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long n; cin >> n;
    string temp;
    int ans1 = 0, ans2 = 0, ans3 = 0, ans4 = 0;
    for(long long i=0;i<n;i++){
        cin >> temp;
        if(temp == "AC") ans1 ++;
        else if(temp == "WA") ans2 ++;
        else if(temp == "TLE") ans3 ++;
        else if(temp == "RE") ans4 ++;
    }
    cout << "AC x " << ans1 <<  "\n"; 
    cout << "WA x " << ans2 <<  "\n"; 
    cout << "TLE x " << ans3 << "\n" ; 
    cout << "RE x " << ans4 <<  "\n"; 
    return 0;
}

Measured memory_bytes: 3656
n,a,b = gets.chomp.split(" ").map(&:to_i)

sum = 0
(1..n).each do |i|
  m = (i / 10000) % 10 + (i / 1000) % 10 + (i / 100) % 10 + (i / 10) % 10 + i % 10
  if m >= a && m <= b then
    sum += i
  end
end

puts sum


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

int main() {
  int N;
  cin>>N;
  int64_t Z=1;
  vector<int> T(N);
  vector<int> A(N);
  vector<int> H(N,-1);
  for(int i=0;i<N;i++){
    cin>>T.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  H.at(0)=T.at(0);
  H.at(N-1)=A.at(N-1);
  for(int i=1;i<N;i++){
    if(T.at(i)!=T.at(i-1)){
      if(H.at(i)==-1||H.at(i)==T.at(i)){
        H.at(i)=T.at(i);
      }
      else{
        Z=0;
      }
    }
  }
  for(int i=N-2;i>=0;i--){
    if(A.at(i)!=A.at(i+1)){
      if(H.at(i)==-1||H.at(i)==A.at(i)){
        H.at(i)=A.at(i);
      }
      else{
        Z=0;
      }
    }
  }
  for(int i=0;i<N;i++){
    if(H.at(i)==-1){
      Z*=min(A.at(i),T.at(i));
      Z%=1000000007;
    }
    else if(H.at(i)>min(A.at(i),T.at(i))){
      Z=0;
    }
  }
  if(N==1&&T.at(0)!=A.at(0)){
    Z=0;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr int N = 1 << 17;
vector<int> g[N];
ll dp[N][2];

void dfs(int u, int p) {
	dp[u][0] = dp[u][1] = 1;
	trav(v, g[u]) {
		if (v == p) continue;
		dfs(v, u);
		(dp[u][0] *= dp[v][0] + dp[v][1]) %= M;
		(dp[u][1] *= dp[v][0]) %= M;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	rep(i, 1, n) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v); g[v].eb(u);
	}
	dfs(0, 0);
	cout << (dp[0][0] + dp[0][1]) % M;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int d[k];
    int a_buff;
    int sum[n];
    rep(i,n) sum[i] = 0;
    int cnt = 0;
    rep(i,k){
        cin >> d[i];
        rep(j,d[i]){
            cin >> a_buff;
            sum[a_buff-1]++;
        }
    }
    
    rep(i,n){
        if(sum[i] == 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

bool isBatch( string str, int len )
{
  int cnt = 0;
  
  while ( cnt < (len - cnt - 1) ) {
    if ( str[cnt] != str[len - cnt - 1] ) {
      return false;
    }
    
    cnt++;
  }
  
  return true;
}


int main( void )
{
  string str;
  cin >> str;
  
  int len = str.length();
  
  cout << ((isBatch(str, len) && isBatch(str, len / 2)) ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int fly[]={4,1,4,1,2,1,2,1},peo[8],remainder,num=0,point=0;
    while(cin>>peo[0]){
        for(int i=1;i<8;i++)cin>>peo[i];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++)if(fly[(i+j)%8]-peo[j]<0)num+=peo[j]-fly[(i+j)%8];
            if(remainder>num||i==0){
                remainder=num;
                point=i;
            }
            else if(remainder==num){
                for(int j=0;j<8;j++){
                    if(fly[(i+j)%8]>fly[(point+j)%8])break;
                    else if(fly[(i+j)%8]<fly[(point+j)%8]){
                        point=i;
                        break;
                        }
                    }
                }
            num=0;
        }
        for(int i=0;i<7;i++)cout<<fly[(point+i)%8]<<" ";
            cout<<fly[(point+7)%8]<<endl;
            point=0;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int cnt=0;
  int ans=0;
  rep(i,s.size() ){
	if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }else{
	ans=max(ans,cnt);
      cnt=0;
    }
  }
  ans=max(ans,cnt);
  cout<<ans<<endl;

  return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

unordered_set<string > vs;
int n, m, q;

void func(int prev, string s){
    int sz = s.size();
    if(sz == n){
        vs.insert(s);
        return;
    }
    for(int i = prev; i <= m;i++){
        string s2 = s + (char)(i + 'a');
        func(i, s2);
    }
}
int main(){
    cin>>n>>m>>q;

    vs.clear();
    func(1, "");

    int Q[q][4];
    for(int i=0;i<q;i++){
        for(int j=0;j<4;j++) cin>>Q[i][j];
    }
    int max_s = 0;
    for(auto i : vs){
        int temp = 0;
        for(int j=0;j<q;j++){
            int ai = Q[j][0] - 1;
            int bi = Q[j][1] - 1;
            int ci = Q[j][2];
            int di = Q[j][3];
            if(i[bi] - i[ai] == ci) temp += di;
        }
        max_s = max(max_s, temp);
    }
    cout<<max_s<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 10044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans = 0;
    ll n; cin>>n;
    rep(i,n){
        ll a;cin>>a;
        if(i%2==0&&a%2==1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(string &s, string &t, int &ans){

    int s_size_num, t_size_num;
    s_size_num = s.size();
    t_size_num = t.size();

    int cnt{};
    int ans_buf = 1e5;
    for(int i = 0; i != s_size_num-t_size_num+1; ++i){
        for(int j = 0; j != t_size_num; ++j){
            if(s.at(i+j) != t.at(j)) ++cnt;
        }
        ans_buf = min(ans_buf, cnt);
        cnt = 0;
    }
    ans = ans_buf;

    return;
}

int main(){

    string s, t;
    cin >> s >> t;

    int ans;
    solver(s, t, ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll=long long;
using ld=long double; 
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll MOD=1e9+7;

int main(){
    int q;cin>>q;
    vector<int> prime;
    vector<bool> vec(1e5+1,true);
    for(int i=2;i<=1e5;i++){
        if(vec[i]){
            prime.push_back(i);
            int k=1;
            while(1){
                vec[i*k]=false;
                k++;
                if(i*k>1e5){
                    break;
                }
            }
        }
    }
    vector<int> res(1e5+1);
    for(int i=0;i<prime.size();i++){
        if(binary_search(prime.begin(),prime.end(),(prime[i]+1)/2)){
            res[prime[i]]++;
        }
    }
    for(int i=2;i<1e5+1;i++){
        res[i]+=res[i-1];
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<res[r]-res[l-1]<<endl;
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string S;
    cin >> S;

    // dp[n][m]: n+1桁で13で割ったあまりがmである場合
    vector<vector<ll> > dp(S.size(), vector<ll>(13));

    reverse(all(S));

    ll pow10 = 1;
    ll mod = 7LL + 1e9;

    if (S[0] == '?') {
        rep(k, 10) {
            dp[0][k] = 1;
        }
    }
    else {
        dp[0][S[0] - '0'] = 1;
    }

    repi(i, S.size()) {
        pow10 *= 10;
        pow10 %= 13;
        if (S[i] != '?') {
            ll a = (pow10 * (S[i] - '0')) % 13;
            rep(j, 13) {
                ll b = (j + a) % 13;
                dp[i][b] += dp[i-1][j];
                dp[i][b] %= mod;
            }
        }
        else {
            rep(k, 10) {
                ll a = pow10 * k % 13;
                rep(j, 13) {
                    ll b = (j + a) % 13;
                    dp[i][b] += dp[i-1][j];
                    dp[i][b] %= mod;
                }
            }
        }
    }

    ll res = 0;
    put(dp[S.size() - 1][5]);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 16700
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s;cin >> s;
    string t = s;
    reverse(ALL(t));
    for (int i = 0; i < t.length(); i++) {
        if(t[i]=='b') t[i]='d';
        else if(t[i]=='d') t[i]='b';
        else if(t[i]=='p') t[i]='q';
        else if(t[i]=='q') t[i]='p';
    }
    if(s==t) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,d[100002];
    cin >> n;
    rep(i,n) cin >> d[i];
    sort(d,d+n);
    cout << d[n/2] - d[n/2 - 1] << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N;
Graph graph;
vector<P> items;
map<P, ll> ans;

ll dfs(ll u, ll prev, ll prev_edge) {
    ll c = 1;
    ll res = 0;
    for (ll v : graph[u]) {
        if (v != prev) {
            if (c == prev_edge) c++;
            ans[{v, u}] = c;
            ans[{u, v}] = c;
            res = max(res, dfs(v, u, c));
            c++;
        }
    }
    return max(res, c-1);
}

void solve() {
    cin >> N;
    graph.resize(N);
    items.resize(N - 1);
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        items[i] = {a, b};
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cout << dfs(0, -1, -1) << '\n';
    rep(i, N - 1) {
        P p = items[i];
        cout << ans[p] << '\n';
    }
}

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


Measured memory_bytes: 23704
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(input);
            Console.WriteLine(input[0] == 5 && input[1] == 5 && input[2] == 7 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
num_list = list(map(int, list(input())))
i = 0
for i in range(2 ** 3):
    result = num_list[0]
    result += num_list[1] * (1 if (i & 0b001) != 0 else -1)
    result += num_list[2] * (1 if (i & 0b010) != 0 else -1)
    result += num_list[3] * (1 if (i & 0b100) != 0 else -1)
    if result == 7:
        break

print("{}{}{}{}{}{}{}=7".format(
    num_list[0],
    '+' if (i & 0b001) != 0 else '-',
    num_list[1],
    '+' if (i & 0b010) != 0 else '-',
    num_list[2],
    '+' if (i & 0b100) != 0 else '-',
    num_list[3]
))

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

typedef long long ll;

const ll Maxn = 1e6, Mod = 998244353;
ll N, Temp, MaxNum, Ans, TempA;
ll Cnt[Maxn + 5], Mu[Maxn + 5], Pri[Maxn + 5], S[Maxn + 5], Tot;
bool Vis[Maxn + 1];

inline void Init(const int Maxn)
{
    Mu[1] = 1;
    for (int i = 2; i <= Maxn; ++i)
    {
        if (!Vis[i]) Pri[++Tot] = i, Mu[i] = -1;
        for (int j = 1; j <= Tot && i * Pri[j] <= Maxn; ++j)
        {
            Vis[i * Pri[j]] = 1;
            if (i % Pri[j]) Mu[i * Pri[j]] = -Mu[i];
            else 
            {
                Mu[i * Pri[j]] = 0;
                break;

            }
        }
        if (Mu[i] < 0) Mu[i] += Mod;
    }
    for (int i = 1; i <= Maxn; ++i)
        for (int j = i; j <= Maxn; j += i) S[j] = (S[j] + Mu[i] * i % Mod) % Mod;
}

inline void Max(ll &X, ll Y) {X = (X > Y ? X : Y);}

inline ll Pow(ll Y, ll X = 2)
{
    ll Ans(1);
    while (Y)
    {
        if (Y & 1) Ans = Ans * X % Mod;
        X = X * X % Mod;
        Y >>= 1;
    }
    return Ans % Mod;
}

int main()
{
    scanf("%lld", &N);
    while (N--)
    {
        scanf("%lld", &Temp);
        TempA = (TempA + Temp) % Mod;
        Cnt[Temp]++;
        Max(MaxNum, Temp);
    }
    Init(MaxNum);
    for (ll T = 1; T <= MaxNum; ++T)
    {
        ll Temp(0);
        for (ll i = 1; i <= MaxNum / T; ++i) Temp = (Temp + i * Cnt[i * T] % Mod) % Mod;
        Ans = (Ans + T * Temp % Mod * Temp % Mod * S[T] % Mod) % Mod;
    }
    printf("%lld\n", (Ans - TempA + Mod) % Mod * Pow(Mod - 2) % Mod);
    system("pause");
}

Measured memory_bytes: 26496
dice = list(map(int,input().split()))
n=int(input())
for i in range(n):
    qa,qb = map(int,input().split())
    if qa==dice[0]:
        if qb==dice[1]:
            print(dice[2])
        elif qb==dice[2]:
            print(dice[4])
        elif qb==dice[4]:
            print(dice[3])
        else:
            print(dice[1])
    elif qa==dice[1]:
        if qb==dice[0]:
            print(dice[3])
        elif qb==dice[3]:
            print(dice[5])
        elif qb==dice[5]:
            print(dice[2])
        else:
            print(dice[0])
    elif qa==dice[2]:
        if qb==dice[0]:
            print(dice[1])
        elif qb==dice[1]:
            print(dice[5])
        elif qb==dice[5]:
            print(dice[4])
        else:
            print(dice[0])
    elif qa==dice[3]:
        if qb==dice[0]:
            print(dice[4])
        elif qb==dice[4]:
            print(dice[5])
        elif qb==dice[5]:
            print(dice[1])
        else:
            print(dice[0])
    elif qa==dice[4]:
        if qb==dice[0]:
            print(dice[2])
        elif qb==dice[2]:
            print(dice[5])
        elif qb==dice[5]:
            print(dice[3])
        else:
            print(dice[0])
    else:
        if qb==dice[4]:
            print(dice[2])
        elif qb==dice[2]:
            print(dice[1])
        elif qb==dice[1]:
            print(dice[3])
        else:
            print(dice[4])
            


Measured memory_bytes: 5612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<iostream>
#define llong long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 2e6;
const int P = 998244353;
llong fact[N+3],finv[N+3];

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
llong comb(llong x,llong y) {return x<0||y<0||x<y ? 0ll : fact[x]*finv[y]%P*finv[x-y]%P;}

llong calc(llong n,llong m,llong k)
{
	llong ret = 0ll;
	for(int i=0; i<=k; i++)
	{
		if((m-i)&1) continue;
		llong tmp = comb(n,i)*comb(((m-i)>>1)+n-1,n-1)%P;
		ret = (ret+tmp)%P;
	}
//	printf("calc %lld %lld %lld=%lld\n",n,m,k,ret);
	return ret;
}

int n,m;

int main()
{
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d%d",&n,&m);
	llong ans = calc(n,3*m,m);
	ans = (ans-n*(calc(n,m,m)-calc(n-1,m,m)+P)%P+P)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N,D;
    cin >> N >> D;
    long q = N / (D*2 + 1);
    long r = 0;
    if(N % (D*2 + 1) > 0) r++;
    cout << q+r << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int dp[105][MAX],w,n;
int v[105],we[105];
int fun(int idx,int val)
{
    if(idx==n)
    {
        return 0;
    }
    int &ret=dp[idx][val];
    if(ret!=-1)
    {
        return ret;
    }

    return ret=min(we[idx]+fun(idx+1,val-v[idx]),fun(idx+1,val));
}
in main()
{

 cin>>n>>w;
 int s=0;
 for(int i=1;i<=n;i++)
 {
     cin>>we[i]>>v[i];
     s+=v[i];
 }
 for(int i=0;i<=s;i++)
    for(int j=0;j<=n;j++)
    dp[j][i]=INT_MAX;
 //dp[0][0]=0;
 for(int i=0;i<=n;i++) dp[i][0]=0;
 int ans=0;
 for(int i=1;i<=n;i++)
 {
     for(int j=0;j<=s;j++)
     {
         dp[i][j]=dp[i-1][j];
         if(j-v[i]>=0)
         dp[i][j]=min(dp[i][j],we[i]+dp[i-1][j-v[i]]);
         if(dp[i][j]<=w)
         {
             ans=max(j,ans);
         }
     }
 }

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


Measured memory_bytes: 157184
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t,c;
	inline void gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			c=s==t?EOF:*s++;
		}else c=*s++;
	}
	template<class IT>inline void gi(IT &x){
		x=0;gc();while(c<'0'||c>'9')gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
	}
	char buf0[20];int a;
	template<class IT>inline void pi(IT x){
		if(x<0){putchar('-');x=-x;}
		do buf0[++a]=x%10+48;while(x/=10);
		while(a)putchar(buf0[a--]);
		putchar('\n');
	}
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005,inf=-N;
char c[N];
int main(){
	int n,i,a,b,a1=0,a2=inf,b1=0,b2=inf;
	scanf("%s",c+1);n=strlen(c+1);
	rep(i,1,n){
		a=b1;if(       c[i]!=c[i-1]                 )cmax(a,a1);++a;
		b=a2;if(i>=4&&(c[i]!=c[i-2]||c[i-1]!=c[i-3]))cmax(b,b2);++b;
//		printf("%d %d %d %d %d %d\n",a2,b2,a1,b1,a,b);
		a2=a1;a1=a;
		b2=b1;b1=b;
	}
	printf("%d",max(a,b));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<vector<int>> path(n, vector<int>(0));
    for (auto i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    vector<int> ans(n, -1);
    queue<int> q; q.push(0); ans[0] = 0;
    while(not q.empty()) {
        int index = q.front();
        q.pop();
        for (auto i = 0; i < (int)path[index].size(); i++) {
            if(ans[path[index][i]] == -1) {
                ans[path[index][i]] = index;
                q.push(path[index][i]);
            }
        }
    }

    cout << "Yes" << endl;
    for (auto i = 1; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10244
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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



class CSkillUp {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};



	void solve(std::istream& in, std::ostream& out) {
        int N, M, X;

	    in >> N >> M >> X;
        vector<int> C(N);
        vector<vector<int> > A(N, vector<int>(M));

        REP(i, N) {
            in >> C[i];
            REP(j, M) {
                in >> A[i][j];
            }
        }

        ll ans = 1e9;
        REP(i,1 << N) {
            ll money = 0;
            vector<ll> power(M, 0);
            REP(n, N) {
                if (i >> n & 1) {
                    money += C[n];
                    REP(m, M) {
                        power[m] += A[n][m];
                    }
                }
            }
            bool ok = true;
            REP(m, M) {
//                cout << power[m] << endl;
                ok &= power[m] >= X;
            }
            if (ok) {
                ans = min(ans, money);
            }
        }

        if (ans == 1e9) {
            out << -1 << endl;
        } else {
            out << ans << endl;
        }
	}
};


int main() {
    ios::sync_with_stdio(false);
	CSkillUp solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
using namespace std;
static const int NMAX = 50000;
static const int MMAX = 20;
static const int INFTY = (1 << 30);
int main()
{
    int n, m;
    int C[21], T[NMAX + 1];

    cin >> n >> m;
    
    for (int i = 1; i <= m; ++i)
    {
        cin >> C[i];
    }

    for (int i = 0; i <= NMAX; ++i) T[i] = INFTY;
    T[0] = 0;
    for(int i = 1; i <= m; ++i)
    {
        for (int j = 0; j + C[i] <= n; ++j)
        {
            T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
        }
    }

    cout << T[n] << endl;
    return 0;
}


Measured memory_bytes: 3304
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [-1] * N
dp[0] = 0
for i_from in range(N - 1):
    for j_to in range(1, min(K + 1, N - i_from)):
        if dp[i_from + j_to] == -1:
            dp[i_from + j_to] = dp[i_from] + abs(h[i_from + j_to] - h[i_from])
        else:
            dp[i_from + j_to] = min(
                dp[i_from + j_to], dp[i_from] + abs(h[i_from + j_to] - h[i_from])
            )
print(dp[-1])


Measured memory_bytes: 52448
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
	int K, S;
	cin >> K >> S;
	int cnt = 0;
	for(int i = 0; i <= K; i++){
		if(i > S){
			break;
		}
		for(int j = 0; j <= K; j++){
			if(i+j > S){
				break;
			}
			if(0 <= S-i-j && S-i-j <= K){
				cnt++;
			}
		}
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 256