akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N, M; cin >> N >> M;
    vector<bool> ac(N + 1, false);
    map<int, int> wa;

    ll acc = 0;
    rep(i, M) {
        ll p; string S; cin >> p >> S;
        if (S == "WA" && !ac[p]) wa[p]++;
        else if (S == "AC" && !ac[p]) {
            ac[p] = true; acc++;
        }
    }

    ll wrn = 0;
    reps(i, N) {
        if (ac[i]) wrn += wa[i];
    }
    cout << acc << " " << wrn << endl;
}

Measured memory_bytes: 8224
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????§????????????????????????
		 Scanner sc = new Scanner(System.in);
		 //??°?????????
		while(true){
		//x??????
		int x = sc.nextInt();
		//y??????
		int y = sc.nextInt();
		//?????¶???  ??????0????????°?????? x??¨y???0????????????
		if(x ==0 && y ==0){
			break;
		}
		//?????¶??? x???????????????????°?????????´???
		if(x < y){
			System.out.println(x + " " + y);
			}else{
				System.out.println(y + " " + x);
			}
		}
	}
}

Measured memory_bytes: 36928
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll> > vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    if(a+b<mod)return a+b;
    else return a+b-mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll modinv(ll a)
{
    return modexp(a,mod-2,mod);
}

bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,k; cin>>n>>k;
if(n>=k)
{
    n = n%k;
    cout<<min(n,k-n)<<endl;
}
else
{
    cout<<min(n,k-n)<<endl;
}
return 0;
}
/*
6
1 2 3 4 5 -6
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vector<string> vec(3);
    REP(i, 3) {
        cin >> vec.at(i);
    }
    string ans;
    REP(i, 3) {
        ans.push_back(vec.at(i).at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
k = int(input())
c = 0
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
i = 0
while True:
    i = q.popleft()
    c += 1
    if c == k:
        break
    else:
        e = int(str(i)[-1])
        if e == 0:
            q.append(int(str(i)+str(e)))
            q.append(int(str(i)+str(e+1)))
        elif e == 9:
            q.append(int(str(i)+str(e-1)))
            q.append(int(str(i)+str(e)))
        else:
            q.append(int(str(i)+str(e-1)))
            q.append(int(str(i)+str(e)))
            q.append(int(str(i)+str(e+1)))

print(i)

Measured memory_bytes: 10968
(() -> begin
  n,k = readline() |> split |> x->parse.(Int,x)
  ans = 0
  for i in k:n+1
    ans += Int((i * (n + (n-i+1)))/ 2 - (i * (0 + i-1)) /2 + 1)
    ans = mod(ans, 10^9 + 7)
  end
  println(ans)
end)()


Measured memory_bytes: 175172
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
    int x;
    cin >> x;
    while(1){
        if (IsPrime(x)){
            cout << x << endl;
            break;
        }
        x++;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;

int main()
{
    ll n,c,k;
    cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n)
    {
        cin>>t[i];
    }
    sort(t.begin(),t.end());

    ll bus=1;
    ll num=0;
    ll first=t[0]+k;
    double time=0.0;
    rep(i,n)
    {
     //   cout<<i<<" "<<bus<<" "<<first<<endl;
        if(t[i]>first || num+1>c)
        {
            bus++;
            first=t[i]+k;
            num=1;
            continue;
        }
        num++;

    }
    cout<<bus;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

long long bubun[11][11];
map<pair<int, int>, pair<int, long long>> memo;

//   1  2  3  4  5  1  2  3  4  5
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
//  0  1  2  3  4  5  6  7  8  9 10
// 上記のように隙間に番号をつける

// スタート隙間とエンド隙間を指定し、パターン数と合計値を返す
void saiki(int s, int e, int* count, long long* sum) {
	// スタート隙間とエンド隙間が1しか離れていない場合、
	// 結果は自明なのでさっさと返す
	if (e - s == 1) {
		*sum = bubun[s][e];
		*count = 1;
		return;
	}

	// 既に計算済みの値はメモ化してあるので、さっさと返す
	pair<int, int> target = make_pair(s, e);
	if (memo.count(target)) {
		*sum = memo[target].second;
		*count = memo[target].first;
		return;
	}

	// メイン処理。再帰。
	*sum += bubun[s][e];
	*count = 1;
	for (int kugiri = e - 1; kugiri > s; kugiri--) {
		int tmpCount = 0;
		long long tmpSum = 0;
		saiki(kugiri, e, &tmpCount, &tmpSum);
		*count += tmpCount;
		*sum += tmpCount * bubun[s][kugiri] + tmpSum;
	}

	// メモ化
	memo[target] = make_pair(*count, *sum);
	return;
}

int main() {
	char S[11];
	int dummy;
	dummy = scanf("%s", &S);

	int len = strlen(S);

	// 部分文字列を取り出しやすいように準備しておく
	// ファイル上部の例の場合、bubun[1][3]とすると23が取り出せる
	for (int s = 0; s < len; s++) {
		for (int e = s + 1; e < len + 1; e++) {
			bubun[s][e] = 0;
			for (int tmp = s; tmp < e; tmp++) {
				bubun[s][e] *= 10;
				bubun[s][e] += S[tmp] - '0';
			}
		}
	}

	int count = 0;
	long long ans = 0;
	saiki(0, len, &count, &ans);
	
	printf("%lld\n", ans);
	
	return 0;
}


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



signed main(){
    int n,a,b,c;
    cin >>n>>a>>b>>c;
    int l[n];
    for(int i=0;i<n;i++)cin >>l[i];
    int m=1,a0[4],b0[4],i0;
    int mp=1000000;
    for(int i=0;i<n;i++)m*=4;
    for(int i=0;i<m;i++){
        i0=i;a0[0]=0;a0[1]=0;a0[2]=0;a0[3]=0;b0[0]=-1;b0[1]=-1;b0[2]=-1;b0[3]=-1;
        for(int j=0;j<n;j++){
            a0[i0%4]+=l[j];
            b0[i0%4]++;
            i0=i0/4;
            
        }

     if(b0[0]!=-1&&b0[1]!=-1&&b0[2]!=-1)   mp=min(mp,abs(a-a0[0])+abs(b-a0[1])+abs(c-a0[2])+10*(b0[0]+b0[1]+b0[2]));
       // if(abs(a-a0[0])+abs(b-a0[1])+abs(c-a0[2])+10*(max(0,b0[0])+max(0,b0[1])+max(0,b0[2]))==120)  cerr<< a0[0]<<' '<<a0[1]<<' '<<a0[2]<<' '<<a0[3]<<endl;
    }
    cout << mp;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
#include<utility>
using namespace std;

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

	string S;
	cin >> S;

	vector<int> num;
	int cnt = 0;
	int now = 1;
	for (int i = 0; i < N; i++) {
		if (S[i] == (char)(now + '0'))
			cnt++;
		else {
			num.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
	if (cnt != 0)
		num.push_back(cnt);

	if (num.size() % 2 == 0)
		num.push_back(0);

	int ans = 0;
	int left, right;
	left = right = 0;
	int sum = 0;
	for (int i = 0; i < (int)num.size(); i += 2) {
		int nextLeft = i;
		int nextRight = min((int)num.size(), i + 2 * K + 1);

		while (left < nextLeft) {
			sum -= num[left];
			left++;
		}

		while (right < nextRight) {
			sum += num[right];
			right++;
		}

		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


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

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

  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int sum = 0;
  int sign = 1;
  for (int i=0; i<N; i++) {
    sum += sign * cards.at(i);
    sign *= -1;
  }

  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 3; i++) {
    if ((a * b * i) % 2 == 1) {
      Yes;
      return 0;
    }
  }
  No;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace modular_space {
	long long mod;
	struct umod {
		long long val;
		umod(): val(0ll){}
		umod(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
		umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
		umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
		umod& operator *= (umod oth){ val = val * oth.val % mod; return *this; }
		umod& operator /= (umod oth){ return *this *= oth.inverse(); }
		umod& operator ^= (long long oth){ return *this = pwr(*this, oth); }
		umod operator + (umod oth) const { return umod(*this) += oth; }
	       	umod operator - (umod oth) const { return umod(*this) -= oth; }
		umod operator * (umod oth) const { return umod(*this) *= oth; }
		umod operator / (umod oth) const { return umod(*this) /= oth; }
		umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
		bool operator < (umod oth) const { return val < oth.val; }
		bool operator > (umod oth) const { return val > oth.val; }
		bool operator <= (umod oth) const { return val <= oth.val; }
		bool operator >= (umod oth) const { return val >= oth.val; }
		bool operator == (umod oth) const { return val == oth.val; }
		bool operator != (umod oth) const { return val != oth.val; }
		umod pwr(umod a, long long b) const {
			umod r = 1;
			for(; b; a *= a, b >>= 1)
				if(b&1)
					r *= a;
			return r;
		}
		umod inverse() const {
			long long a = val, b = mod, u = 1, v = 0;
			while(b){
				long long t = a/b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}
			if(u < 0)
				u += mod;
			return u;
		}
		friend istream& operator >> (istream &is, umod &oth);
		friend ostream& operator << (ostream &os, const umod& oth);
	};
	ostream& operator << (ostream &os, const umod &oth){
		os << oth.val;
		return os;
	}
	istream& operator >> (istream &is, umod &oth){
		long long x; is >> x;
		oth = umod(x);
		return is;
	}
	struct binprime_kit {
		int sz;
		vector<umod> fat, ifat;
		void init(int s){
			sz = s;
			fat.resize(sz + 1);
			ifat.resize(sz + 1);
			fat[0] = 1;
			for(int i = 1; i <= sz; i++) fat[i] = fat[i - 1] * i;
			ifat[sz] = fat[sz] ^ (mod - 2);
			for(int i = sz - 1; i >= 0; i--) ifat[i] = ifat[i + 1] * (i + 1);
		}
		umod coef(int n, int r){
			if(n < r) return 0;
			return fat[n] / (ifat[r] * ifat[n - r]);
		}
	};
};
using umod = modular_space::umod;
int main(){
	modular_space::mod = 1'000'000'007;
	int n; umod k; cin >> n >> k;
	vector<int> divs;
	for(int i = 1; i * i <= n; i++){
		if((n%i) == 0){
			divs.push_back(i);
			if(i * i != n) divs.push_back(n / i);
		}
	}
	sort(divs.begin(), divs.end());
	vector<umod> f(divs.size());
	int len = divs.size();
	umod ans = 0;
	for(int i = 0; i < len; i++){
		f[i] = k ^ ((divs[i] + 1) / 2);
		for(int j = 0; j < i; j++){
			if(divs[i] % divs[j]);
			else f[i] -= f[j];
		}
		if(divs[i]&1) ans += f[i] * divs[i];
		else ans += f[i] * (divs[i] / 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

const int INF = 1000000000;

int dp[100][100][100] = {0};
int dfs(int a, int b, int c, int d) {
    if (dp[a][b][c] != 0) return dp[a][b][c];
    if (a == b && b == c && c == a) return d;
    if (a > 52 || b > 52 || c > 52) return INF;
    int ret = INF;
    ret = min(ret, dfs(a + 1, b + 1, c, d + 1));
    ret = min(ret, dfs(a, b + 1, c + 1, d + 1));
    ret = min(ret, dfs(a + 1, b, c + 1, d + 1));
    ret = min(ret, dfs(a + 2, b, c, d + 1));
    ret = min(ret, dfs(a, b + 2, c, d + 1));
    ret = min(ret, dfs(a, b, c + 2, d + 1));
    return dp[a][b][c] = ret;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << dfs(A, B, C, 0) << endl;
}

Measured memory_bytes: 1536
N=int(input())
ans = 0
d=0
def calc(n):
    a = 0
    while(1):
        if n==0:
            return a
        if n%2==0:
            a+=1
            n = n//2
        else:
            return a
for i in range(1,N+1):
    a = calc(i)
    ans = max(ans,a)
for i in range(1,N+1):
    b=calc(i)
    if b==ans:
        d = i
print(d)

Measured memory_bytes: 3064
//AtCoder Beginner Contest 133 目指せ3冠、勝ち取れ内定(⊙ꇴ⊙)

#include <stdio.h>
int main(void){
    //変数宣言ここから٩(ˊᗜˋ*)و
    
    char s[256];
    int n,i,j,count;
    int a,b;
    
    //入力処理ここから٩(ˊᗜˋ*)و
    
    scanf("%d %d %d",&n,&a,&b);
    
    //処理部分ここから٩(ˊᗜˋ*)و
    
    if ((a * n) > b){
        count = b;
    }else{
        count = a * n;
    }
    
    //出力処理ここから٩(ˊᗜˋ*)و
    
    printf("%d",count);
    
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
using namespace std;
using ll = long long;

int main() {
	ll N, K; cin >> N >> K;
	ll ans = 0;
	if (K % 2 == 0) {
		ll half = 0; ll zero = 0;
		zero = (N / K);
		half = (2*N/K+1)/2;

		ans = zero * zero * zero + half * half * half;
	}
	else {
		ll zero = 0;
		zero = (N / K);
		ans = zero * zero * zero;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int dist = 0;
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
			dist += Math.min(x[i], k-x[i]) * 2;
		}
		System.out.println(dist);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    //N+1!!!!!!!!!!!!!!!!!!!
    int n;
    cin >> n;
    VL v(n + 1);
    VL num(n + 1, 0);
    rep(i, n + 1)
    {
        cin >> v[i];
    }
    ll cur = 0;
    for (int i = n; i >= 0; i--)
    {
        cur += v[i];
        num[i] += cur;
    }
    cur = 1;
    ll ans = 0;

    rep(i, n)
    {
        ans += min(cur, num[i]);

        cur -= v[i];
        if (cur <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        if (cur < (1ll << 50))
            cur *= 2;
    }
    if (cur < v[n])
    {
        cout << -1 << endl;
        return 0;
    }
    ans += num[n];
    cerr << num[n] << endl;
    cout << ans << endl;
    return 0;
}

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

int n;
vector<set<int>> g;

bool solve();

int main() {
  cin >> n;
  g.resize(n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].insert(--b);
    g[b].insert(a);
  }
  if (solve())
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}

bool solve() {
  vector<int> ch;
  queue<int> bl, wh;
  ch.assign(n, 0);
  for (int i = 0; i < n; ++i)
    if (g[i].size() == 1) bl.push(i);
  while (bl.size() || wh.size()) {
    while (bl.size()) {
      int now = bl.front();
      bl.pop();
      for (auto to : g[now]) {
        g[to].erase(now);
        if (ch[to]) return 1;
        ch[to] = 1;
        if (g[to].size() == 1) wh.push(to);
      }
    }
    while (wh.size()) {
      int now = wh.front();
      wh.pop();
      if (!ch[now]) return 1;
      for (auto to : g[now]) {
        g[to].erase(now);
        if (g[to].size() == 1) {
          if (ch[to])
            wh.push(to);
          else
            bl.push(to);
        }
        if (g[to].size() == 0 && !ch[to]) return 1;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 18012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long[] ab = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

            if(ab[0] < 10 && ab[1] < 10)
            {
                Console.WriteLine(ab[0] * ab[1]);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        for(int j = 1; j <= D; j += a) {
            ++cnt;
        }
    }
    cout << cnt + X << endl;
    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
    cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>

using namespace std;

template <class T>
class segment_tree {
    public:
    segment_tree(int n, function<T(const T&, const T&)> func, const T& init = T());
    segment_tree(T* array, int n, function<T(const T&, const T&)> func, const T& init = T());
    ~segment_tree();
    void add(int x, const T& value);
    void update(int x, const T& value);
    T get(int x, int y) const; // [x, y)
    
    private:
    int size;
    function<T(const T&, const T&)> func;
    T init;
    T* data;
};

template <class T> segment_tree<T>::segment_tree(int n, function<T(const T&, const T&)> func, const T& init) : size(1 << (32 - __builtin_clz(n - 1))), func(func), init(init) {
    data = (T *)malloc(sizeof(T) * size * 2);
    for (int i = 0; i < size * 2; i++) data[i] = init;
}

template <class T> segment_tree<T>::segment_tree(T* array, int n, function<T(const T&, const T&)> func, const T& init) : segment_tree(n, func, init) {
    for (int i = 0; i < n; i++) data[size + i] = array[i];
    for (int i = size - 1; i > 0; i--) data[i] = func(data[i * 2], data[i * 2 + 1]);
}

template <class T> segment_tree<T>::~segment_tree() {
    free(data);
}

template <class T> void segment_tree<T>::add(int x, const T& value) {
    update(x, data[x + size] + value);
}

template <class T> void segment_tree<T>::update(int x, const T& value) {
    data[x += size] = value;
    while (x >>= 1) data[x] = func(data[x * 2], data[x * 2 + 1]);
}

template <class T> T segment_tree<T>::get(int x, int y) const {
    T vl = init, vr = init;
    for (x += size, y += size; x < y; x >>= 1, y >>= 1) {
        if (x & 1) vl = func(vl, data[x++]);
        if (y & 1) vr = func(data[--y], vr);
    }
    return func(vl, vr);
}

int main() {
    int n, q, a, b, x, i;
    long long ans = 1e18, sum = 0;
    
    scanf("%d %d %d %d", &n, &q, &a, &b);
    
    segment_tree <long long> s1(n + 1, [](long long x, long long y) { return min(x, y); }, 1e18);
    segment_tree <long long> s2(n + 1, [](long long x, long long y) { return min(x, y); }, 1e18);
    
    x = a;
    s1.update(b, b);
    s2.update(b, -b);
    
    for (i = 0; i < q; i++) {
        int y;
        long long z = 1e18;
        
        scanf("%d", &y);
        
        z = min(z, s1.get(y + 1, n + 1) - y + sum);
        z = min(z, s2.get(0, y + 1) + y + sum);
        
        sum += abs(x - y);
        
        s1.update(x, z - sum + x);
        s2.update(x, z - sum - x);
        
        x = y;
    }
    
    for (i = 0; i <= n; i++) ans = min(ans, s1.get(i, i + 1) - i + sum);
    
    printf("%lld\n", ans);
    
    return 0;
}


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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()

  l=['dream','dreamer','erase','eraser']

  while True:
    a=s[-5:]
    b=s[-7:]
    c=s[-6:]

    if a==l[0]:
      s=s[:-5]
    elif b==l[1]:
      s=s[:-7]
    elif a==l[2]:
      s=s[:-5]
    elif c==l[3]:
      s=s[:-6]
    else:
      if s=='':
        return 'YES'
      else:
        return 'NO'

print(main())


Measured memory_bytes: 6552
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    cout << max({2*a-1,2*b-1,a+b}) << endl;
    return 0;
}


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

using namespace std;

int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;int i=1;
	while(1){
		if(i%2==1)c-=b;
		else a-=d;
		i++;
		if(a<=0){
			cout<<"No";
			return 0;
		}
		if(c<=0){
			cout<<"Yes";
			return 0;
		}
	}
	return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> cnt(m,0);
	
	rep(i,n){
		int k;
		cin >> k;
		
		rep(j,k){
			int a;
			cin >> a;
			--a;
			
			++cnt[a];
		}
	}
	int ans = 0;
	rep(i,m){
		if(cnt[i] == n){
			++ans;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    set<ll> st;

    rep(i, n){
        ll a; cin >> a;
        st.insert(a);
    }

    if(st.size() == n){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#define N 100000
 
int Partition(int,int);
int A[N];
 
int main(void){  
  int i,n,p=0,r,mid;
     
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
     
  r=n-1;
  mid=Partition(p,r);
     
   
  for(i=0;i<mid;i++) printf("%d ",A[i]);   
  
  printf("[%d] ",A[mid]);
  
  for(i=mid+1;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
     
  return 0;
}

int Partition(int p,int r){
  int x,i,j,y;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[r];
  A[r]=y;
  return i+1;
}



Measured memory_bytes: 2068
//abc165-D//

//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
//#include <string.h>
using namespace std;

int main(){
    int n,k;
    cin >> n>>k;
    vector<int>data(n);
    rep(i,k){
        int num;
        cin>>num;
        rep(j,num){
            int a;
            cin>>a;
            data[a-1]++;
        }
    }
    int ans =0;
    rep(i,n){
        if(data[i]==0)
            ans++;
    }
    cout << ans <<endl;
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}


int main() {

//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif



  ll n, k;
  cin >> n >> k;
  ll m = 1e9 + 7;
  ll sum[n + 1];
  for (int i = 0; i <= n; i++)
    sum[i] = i;

  ll pre[n + 1]; pre[0] = 0;
  ll suff[n + 1]; suff[n] = n;

  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + sum[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = suff[i + 1] + sum[i];
  }

  // print(sum, n + 1);
  // print(pre, n + 1);
  // print(suff, n + 1);

  ll ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ll mns = pre[i - 1];
    ll mxs = suff[n - i + 1];
    ll diff = mxs - mns + 1;
    // cout << diff << "  i==" << i << endl;
    ans = (ans + diff) % m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
using namespace std;
using VI = vector<int>;

int as[101010];
VI adj[101010];
int color[101010];
int color_count = 0;
map<int, int> unvisited;

void dfs(int v) {
    if (color[v] != -1) return;
    color[v] = color_count;
    unvisited.erase(v);
    for (int i: adj[v]) {
        dfs(i);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        unvisited[i] = 1;
        color[i] = -1;
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    while (unvisited.size()) {
        int i = (*unvisited.begin()).first;
        dfs(i);
        color_count++;
    }
    
    vector<VI> items(color_count);
    for (int i = 0; i < n; i++) {
        items[color[i]].push_back(as[i]);
    }
    
    for (int i = 0; i < color_count; i++) {
        sort(items[i].begin(), items[i].end());
    }
    
    if (color_count == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    if (n < 2 * (color_count - 1)) {
        cout << "Impossible" << endl;
        return 0;
    }
    
    long ans = 0;
    VI rem;
    int adds = (color_count - 1) * 2;
    for (int i = 0; i < color_count; i++) {
        ans += items[i].front();
        adds--;
        for (int j = 1; j < items[i].size(); j++) {
            rem.push_back(items[i][j]);
        }
    }
    assert(adds >= 0);
    sort(rem.begin(), rem.end());
    for (int i = 0; i < adds; i++) {
        ans += rem[i];
    }
    cout << ans << endl;
}




Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  long int N,ans=1,p=1e9+7;
  cin >> N;
  FOR(i,1,N+1)ans = (ans*i)%p;
  cout << ans << endl;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    cur = a[i]
    ans += b[a[i]-1]
    if i < n-1 and a[i+1] == cur+1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 38452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ll n, W;
    cin >> n >> W;
    ll w[n], v[n];
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    map<ll, ll> mp;
    mp[0LL] = 0LL;
    for (int i = 0; i < n; i++) {
        map<ll, ll> mp2;
        for (map<ll, ll>::iterator ite = mp.begin(); ite != mp.end(); ite++) {
            mp2[(*ite).first] = max(mp2[(*ite).first], (*ite).second);
            if ((*ite).first + w[i] <= W) {
                mp2[(*ite).first + w[i]] = max(mp2[(*ite).first + w[i]], (*ite).second + v[i]);
            }
        }
        swap(mp, mp2);
    }

    ll ans = 0;
    for (map<ll, ll>::iterator ite = mp.begin(); ite != mp.end(); ite++) {
        ans = max(ans, (*ite).second);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    int n; cin >> n;
    map<char,int> mp;
    string s; cin >> s; 
    for(char c : s) mp[c]++;
    for(int i = 1; i < n; ++i){
        string t; cin >> t;
        map<char,int> tmp;
        for(int j = 0; j < t.size(); ++j){
            tmp[t[j]]++;
        }
        for(auto it = mp.begin(); it != mp.end(); ++it){
            it->second = min(it->second, tmp[it->first]);
        }
    }
    for(auto it = mp.begin(); it != mp.end(); ++it){
        int rep = it->second;
        for(int i = 0; i < rep; ++i){
            cout << it->first;
        }
    }
    cout << endl;
    return 0;
}
//Saw the editorial

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i = n; i > 0; i--){
        int tmp = floor(sqrt((float)i));

        if(tmp * tmp == i){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

int main() {

    int n, x, l, sum, count;
    sum = count = 0;
    cin >> n >> x;
    rep(i, n + 1){
        cin >> l;
        if(sum <= x){
            count++;
            sum += l;
        }
    }
    cout << count;    

}




Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in); 
		String s=sc.next();
		int i=0;
		if(Integer.parseInt(s)<=(s.charAt(i)-'0')*111)
		    System.out.print((s.charAt(i)-'0')*111);
		else
		    System.out.print((s.charAt(i)-'0'+1)*111);
		
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> L, R;
    rep(i, n) {
        if (s[i] == 'o') L.push_back(i + 1), i += c;
        if ((int)L.size() == k) break;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') R.push_back(i + 1), i -= c;
        if ((int)R.size() == k) break;
    }
    reverse(all(R));
    rep(i, k) if (L[i] == R[i]) cout << L[i] << endl;
}

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


Measured memory_bytes: 5676
#include<bits/stdc++.h>
const int MN=300000+5;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,V;
int l[20][MN],r[20][MN];
int x[MN],fr[MN],fl[MN],s[MN];
void input(){
	IN(n),IN(V);
	for(int i=1;i<=n;++i)IN(x[i]);
	int k;//x[0]=INT_MIN/10,x[n+1]=INT_MAX/10;
	for(k=0;V;++k,V>>=1){
		l[k][1]=1;
		for(int i=2;i<=n;++i)l[k][i]=x[i]-x[i-1]>V?i:l[k][i-1];
		r[k][n]=n;
		for(int i=n-1;i>=1;--i)r[k][i]=x[i+1]-x[i]>V?i:r[k][i+1];
		l[k][0]=1,r[k][n+1]=n;
	}
	l[k][1]=1;
	for(int i=2;i<=n;++i)l[k][i]=x[i]-x[i-1]>V?i:l[k][i-1];
	r[k][n]=n;
	for(int i=n-1;i>=1;--i)r[k][i]=x[i+1]-x[i]>V?i:r[k][i+1];
	l[k][0]=1,r[k][n+1]=n;
	fr[0]=n+1;
	for(int st=1;st<(1<<k);++st){
		fr[st]=n;
		for(int i=0;i<k;++i)if(st>>i&1){
			fl[st]=max(fl[st],r[i+1][fl[st^(1<<i)]+1]);
			fr[st]=min(fr[st],l[i+1][fr[st^(1<<i)]-1]);
		}
	}
	for(int st=0;st<(1<<k);++st){
		int L=l[0][fr[((1<<k)-1)^st]-1],R=r[0][fl[st]+1];
		if(L<=R)s[L]++,s[R+1]--;
	}
	for(int i=1;i<=n;++i){
		s[i]+=s[i-1];
		puts(s[i]?"Possible":"Impossible");
	}
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 53248
import numpy as u
N,K,*A=map(int,open(0).read().split())
M,S,X=10**9+7,1,u.matrix(A,"O").reshape(N,N)
exec("S*=[1,X][K&1];K//=2;X=X*X%M;"*60)
print(S.sum()%M)

Measured memory_bytes: 13888
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin>>N>>D;
    int range = 2*D + 1;
    int ans = ceil((double)N / range);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cstring>
using namespace std;
int x[150],y[150];
char a[200010],b[200010];
int main()
{
	scanf("%s %s",&a,&b);
	int lena=strlen(a),lenb=strlen(b);
	if(lena!=lenb) {printf("No");return 0;}
	for(int i=0;i<lena;i++)
	{
		if(!x[a[i]]||x[a[i]]==b[i]) x[a[i]]=b[i];
		else {printf("No");return 0;}
		if(!y[b[i]]||y[b[i]]==a[i]) y[b[i]]=a[i];
		else {printf("No");return 0;}
	}
	printf("Yes");
	return 0;
}


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


int main() {
    int n; cin >> n;
    vector<int> vec(n-1);
    rep(i, n-1) cin >> vec.at(i);
    vector<int> vec_c(n);
    vec_c.at(0) = vec.at(0);
    vec_c.at(n-1) = vec.at(n-2);
    for(int i = 1; i < n-1; i++){
        vec_c.at(i) = min(vec.at(i), vec.at(i-1));
    }
    int sum = accumulate(vec_c.begin(), vec_c.end(), 0);
    cout << sum << endl;
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int rc=0;
	for(int i=0;i<s.length();i++){
	    if(s[i]=='R')
	    rc++;
	}
	int ans=0;
	for(int i=0;i<rc;i++){
	    if(s[i]=='W')
	    ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;
import java.util.Stack;
public class Main {
	Stack<Integer> stack = new Stack<Integer>();
	public static void main(String[] args) {
		new Main().run();
	}

	void run(){
		Scanner sc =  new Scanner(System.in);
		while(true){
			if(!sc.hasNext()){
				break;
			}
			int a = sc.nextInt();
			int[] b = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
			solve(a,b,b.length-1);
			StringBuilder sb = new StringBuilder();
			while(!stack.empty()){
				sb.append(stack.pop()+" ");
			}
			System.out.println(sb.deleteCharAt(sb.length()-1));
		}
	}

	void solve(int a, int[] b, int i){
		if(a >= b[i] && a != 0){
			a -= b[i];
			stack.push(b[i]);
		}
		if(i != 0){
			solve(a, b, --i);
		}
	}
}

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

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			int ab = a*b;
			int cd = c*d;

			System.out.println(Math.max(ab, cd));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 8276
N,K=map(int,input().split())
D=list(map(int,input().split()))
def solve():
  for i in range(10*N):
    if i >= N:
      s = str(i)
      for j in range(len(s)):
        if int(s[j]) in D:
          break
      else:
        print(i)
        return 0
solve()

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {

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

        int n = scan.nextInt();
        int a[] = new int[5000];

        while (n != 0) {
            for (int i = 0; i < n; i++) {
                a[i] = scan.nextInt();
            }

            int best = -1000000;
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];

                    if (sum > best) {
                        best = sum;

                    }
                }
            }
            System.out.println(best);
            n = scan.nextInt();
        }

    }
}


Measured memory_bytes: 34864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll x;
  cin >> x;
  if(x >= 30){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
MOD = 10**9 + 7
for i in range(60):
    z = 0
    o = 0
    for j in range(N):
        if A[j]&(2**i):
            o += 1
        else:
            z += 1
    ans += z*o*(2**i)
    ans %= MOD
print(ans)

Measured memory_bytes: 122936
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
IA = lambda: [int(x) for x in input().split()]

A,B = IA()
if A == B:
    print(A*2)
elif A > B:
    print(A*2 - 1)
else:
    print(B*2 - 1)

Measured memory_bytes: 2940
n = gets.to_i
a = gets.split.map(&:to_i)

s = 0
e = 1
b = 1000
st = 0

while s < n-1 do
  if a[s] < a[e]
    # 底値からスタートして高値まで待つ
    while e < n-1 && a[e] <= a[e+1] do
      e += 1
    end
    # buy min and sell max
    st, b = b.divmod a[s]
    b = b + st * a[e]
    st = 0
    s = e
    e += 1
  else
    # 底値まで待つ
    while e < n-1 && a[e] >= a[e+1] do
      e += 1
    end
    s = e
    e += 1
  end
end

puts b


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

struct KnuthMorrisPratt {
    string ptn;
    vector<int> kmp, mp;
    KnuthMorrisPratt(const string &ptn) : ptn(ptn) {
        int m = ptn.size();
        mp.assign(m + 1, -1), kmp.assign(m + 1, -1);
        for (int i = 0, j = -1; i < m; i++) {
            while (j >= 0 && ptn[i] != ptn[j]) j = kmp[j];
            kmp[i + 1] = mp[i + 1] = ++j;
            if (i + 1 < m && ptn[i + 1] == ptn[j]) kmp[i + 1] = kmp[j];
        }
    }
    int period(int i) { return i - mp[i]; }
    vector<int> match(const string &s) {
        int m = ptn.size(), n = s.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; i++) {
            while (k >= 0 && s[i] != ptn[k]) k = mp[k];
            if (++k == m) res.emplace_back(i - m + 1);
        }
        return res;
    }
};

vector<long long> enum_divisors(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i);
        if (i != n / i) res.emplace_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    string s; cin >> s;
    int n = s.length();
    KnuthMorrisPratt kmp(s);
    if (s == string(n, s[0])) return !(cout << n << endl << 1 << endl);
    if (kmp.period(n) == n || n % kmp.period(n) != 0) {
        return !(cout << 1 << endl << 1 << endl);
    }
    string s_r = s;
    reverse(begin(s_r), end(s_r));
    KnuthMorrisPratt kmp_r(s_r);
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (kmp.period(i) < i && i % kmp.period(i) == 0) continue;
        int j = n - i;
        if (kmp_r.period(j) < j && j % kmp_r.period(j) == 0) continue;
        cnt++;
    }
    cout << 2 << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 10008
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    double t,x;
    cin >> t >> x;

    printf("%.8f\n", t/x);

    return 0;
}



Measured memory_bytes: 256