akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll n;
	cin >> n;
	ll ans = 0;

	for(ll i = 2; i * i < n; i++){
		ll count = 0;
		while(n % i == 0){
			n /= i;
			count++;
		}
		ll hiku = 1;
		while(1){
			count -= hiku;
			hiku ++;
			if(count >= 0) ans++;
			else break;
		}
	}
	if(n != 1) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,K; cin>>N>>K;
	vector<int> D(N,INT_MAX),H(N);
	for(int i=0;i<N;i++) cin>>H[i];
	D[0]=0;
	for(int i=1;i<N;i++)
		for(int j=max(0, i-K);j<i;j++)
			D[i] = min(D[i], D[j]+abs(H[i]-H[j]));
	cout<<D[N-1]<<"\n";
}

Measured memory_bytes: 1024
from collections import defaultdict
mod = pow(10, 9) + 7
N = int(input())
S = input()
d = defaultdict(int)
for s in S:
  d[s] += 1
ans = 1
for c in d:
  ans *= (d[c] + 1)
  ans %= mod
print(ans - 1)

Measured memory_bytes: 3444
#B問題
N,L = map(int,input().split())
if L+N-1 < 0:
    ans = 0
    for i in range(N-1):
        ans+=L+i
elif L > 0:
    ans = 0
    for i in range(N-1):
        ans+=L+i+1
else:
    ans = 0
    for i in range(N):
        ans+=L+i
print(ans)

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

using namespace std;

int main() {
	int n, d1, d2;
	cin >> n >> d1 >> d2;
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	while (d1 % 4 == 0) d1 /= 4, cnt1++;
	while (d2 % 4 == 0) d2 /= 4, cnt2++;
	int cnt = 0;
	for (int i = 0; i < n * 2; ++i) {
		for (int j = 0; j < n * 2; ++j) {
			if (cnt == n * n) continue;
			int x, y;
			x = i / (1 << cnt1);
			y = j / (1 << cnt1);
			if (d1 % 4 == 1 && (x + y) % 2 == 1) continue;
			if (d1 % 4 == 2 && x % 2 == 1) continue;
			x = i / (1 << cnt2);
			y = j / (1 << cnt2);
			if (d2 % 4 == 1 && (x + y) % 2 == 1) continue;
			if (d2 % 4 == 2 && x % 2 == 1) continue;
			cout << i << ' ' << j << '\n';
			++cnt;
		}
	}
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int 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;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    char s[3];
    cin >> s;
    int counter = 0;
    if(s[0] == '1') counter++;
    if(s[1] == '1') counter++;
    if(s[2] == '1') counter++;
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(){
   int n;
   int cnt=0;
   char s[n];
   scanf("%d",&n);
   scanf("%s",s);
   for(int i=0; i<=n; i++){
      if((s[i]==65)&&(s[i+1]==66)&&(s[i+2]==67)){
         cnt++;
      }
   }
   printf("%d\n",cnt);
   return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include<cstdio>
#include<iomanip>
using namespace std;


int main() {
	int n;
	cin >> n;
	double s[101], sum;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sum += 1.0 / s[i];
	}
	sum = 1.0 / sum;
	cout<<fixed<<setprecision(10) << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(((a+b))%2==0){
        printf("%d",(a+b)/2);
        return 0;
    }else{
        printf("IMPOSSIBLE");
    }
}
    


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>


using namespace std;

int main(int argc, const char * argv[]) 
{
    float K,X;
    cin >> K >> X;
    if(K == 1)
    {
        cout << X << " ";
    }
    else
    {
        for(int i=0; i<(K-1)*2+1; i++)
        {
            if(-1000000 <= X -K-i && X-K-i <=1000000)
            {
                cout << X-(K-1)+i << " ";
            }
        }
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> A(N);
	REP(i, N) cin >> A[i];
	map<int64, int64> mp;
	int64 res = 0;
	REP(i, N) {
	  res += mp[i-A[i]];
	  mp[A[i]+i]++;
	}
	cout << res << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n);

  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  rep(i, n) cin >> C[i];

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long int ans = 0; 
  rep(i, n) {
    auto it_a = lower_bound(A.begin(), A.end(), B[i]);
    auto it_c = upper_bound(C.begin(), C.end(), B[i]);
    long long int d_a = distance(A.begin(), it_a);
    long long int d_c = distance(it_c, C.end());

    ans += d_a * d_c;
  }

  cout << ans << endl;
}

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

int main() {
  long long n;
  cin>>n;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long sum = 0;
  for (int i=0; i<n; i++) sum += a[i];

  long long acc = 0;
  long long ans = sum;
  for (int i=0; i<n-1; i++) {
    acc += a[i];
    ans = min(abs(acc - (sum - acc)), ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a[5],m;
  rep(i,5) R a[i];
  R m;
  if(a[4]-a[0]>m) pr(":(");
  else pr("Yay!");
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;
const int MAX = 1000000000;

ll pow_deff(ll a, ll b){
  return pow(a,5) - pow(b,5);
};

int main(){
    ll max_a  = 1;
    while (true) {
        if ((pow_deff(max_a, max_a-1)) <= MAX) max_a++;
        else break;
    }
    int x = 0;
    cin >> x;
  for (int i = 0; i <= max_a; i++) {
    for(int j = -1 * max_a; j <= max_a; j++){
      if (x == pow_deff(i, j)){
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using vi3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

main(){

    scanf("%d %d" , &n , &m);
    if(n < m){
        printf("0\n");
    }
    else printf("10\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String input[] = new String[n];
		int yellow = 0;
		for(int i= 0;i < n;i++) {
			input[i] = sc.next();
			if(input[i].equals("Y"))yellow++;
		}
		if(yellow > 0) {
			System.out.println("Four");
		}else System.out.println("Three");
		sc.close();
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;
    if (n < m) swap(n, m);
    ll res = 0;
    if (m == 1) {
        if (n == 1) res = 1;
        else res = max(n - 2, 0LL);
    } else {
        res = (n - 2) * (m - 2);
    } 
    cout << res << endl;
    
    return 0;
}



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

int main(){

	//入力、初期化
	int n,m;
	cin >> n >> m;

	int A[n][m], b[m], c[n];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> A[i][j];
		}
	}

	for(int i=0; i<m; i++){
		cin >> b[i];
	}

	//計算
	for(int i=0; i<n; i++){
		c[i] = 0;
		for(int j=0; j<m; j++){
			c[i] += A[i][j] * b[j];
		}
	}

	//表示
	for(int i=0; i<n; i++){
		cout << c[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

int main() {

    zoom; precise;
    int N; cin >> N;
    vector<long double> A(N + 1);
    for(int i = 1; i <= N; i += 1)
        cin >> A[i];
    vector<vector<long double> > dp(N + 1, vector<long double>(N + 1, 0));
    dp[1][0] = 1.0 - A[1];
    dp[1][1] = A[1];
    for(int i = 2; i <= N; i += 1) {
        dp[i][0] = dp[i - 1][0] * (1.0 - A[i]);
        for(int j = 1; j <= i; j += 1) 
            dp[i][j] = (dp[i - 1][j] * (1.0 - A[i])) + (dp[i - 1][j - 1] * A[i]);
    }
    long double ans = 0.0;
    for(int i = (N / 2) + 1; i <= N; i += 1)
        ans += dp[N][i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 141056
#include <iostream>
using namespace std;
char s[4][4];
int main()
{
     for(int i=1;i<=3;i++)
      for(int j=1;j<=3;j++)
       {
       	cin>>s[i][j];
    
       }
      for(int i=1;i<=3;i++)
       cout<<s[i][i];
       return 0;
}

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

using namespace std;

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

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> n;
    cin >> s;
    ll Q;
    cin >> Q;
    vector<set<int>> vs(26);
    for(i=0;i<n;i++){
        vs[s[i]-'a'].insert(i+1);
    }
    while(Q--){
        int x;
        cin >> x;
        if(x==1){
            int t;
            char c;
            cin >> t >> c;
            vs[s[t-1]-'a'].erase(t);
            s[t-1]=c;
            vs[c-'a'].insert(t);
        }else{
            int l,r;
            cin >> l >> r;
            int ret = 0;
            for(i=0;i<26;i++){
                if(vs[i].lower_bound(r+1)!=vs[i].lower_bound(l))ret++;
            }
            cout << ret << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))

typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	int n;
	
	while (scanf("%d", &n)) {
		if (!n)
			return 0;

		int cou = 0;
		for (int i = 1; n > i; i++) {
			for (int j = i + 1; n >= j; j++) {
				if ((i + j)*(j - i + 1) / 2 == n)cou++;
			}
		}
		printf("%d\n", cou);
	}




	return 0;
}

Measured memory_bytes: 3180
N = int(input())
numbers = list(input().split())
sum_numbers = [0] * N
sum_numbers[0] = int(numbers[0])

for i in range(N - 1):
    sum_numbers[i + 1] = sum_numbers[i] + int(numbers[i + 1])

Ans = abs(2 * sum_numbers[0] - sum_numbers[N - 1])
for j in range(N - 1):
    if Ans >= abs(2 * sum_numbers[j] - sum_numbers[N - 1]):
        Ans = abs(2 * sum_numbers[j] - sum_numbers[N - 1])
    else:
        continue

print(Ans)



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


ll dp[401][401];
ll sum[401];
ll rec(int l, int r){
    if(dp[l][r] >= 0) return dp[l][r];
    if(l == r) return 0LL;
    ll ans = LLONG_MAX;
    for(int i = l; i < r; ++i){
        ans = min(ans, rec(l, i)+rec(i+1, r));
    }
    return dp[l][r] = ans+sum[r]-sum[l-1];
}


int main(){

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

    int n;
    cin >> n;

    fill_n(*dp, 401*401, -1);
    sum[0] = 0LL;
    rep(i, n) {
        ll a;
        cin >> a;
        sum[i+1] = sum[i] + a;
    }

    ppp(rec(1, n));

    return 0;
}


Measured memory_bytes: 1536
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
	_fast_
	ll t = 1;
//	cin>>t;
	while(t--){
	ll n,m;
	cin>>n>>m;
	ll val;
	if(n%m == 0)
	{
		val = n/m;
	}
	else
	{
		val = n/m+1;
	}
	cout<<val<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n,d;
	cin>>n>>d;
	d=d*2+1;
	if(n%d==0){
		cout<<n/d<<endl;
	}else{
		cout<<n/d+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int N,c;

int main(){
	while(cin>>N){
		if(N==0)return 0;
		map<int,int> table;
		int f=0;
		for(int i=0;i<N;i++){
			cin>>c;
			table[c]++;
			if(table[c]>N/2){if(f==0)cout<<c<<endl;f=1;}
		}
		if(f==0)cout<<"NO COLOR"<<endl;
	}
}

Measured memory_bytes: 1936
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n,m=map(int,input().split())
a=make_divisors(m)
ans=0
for i in a:
    if i<=m/n and i>ans:
        ans=i
print(ans)
#解説参照済み

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long gg,n,k,ans=0;
int main(){
	cin>>n>>k;
	for (long long i=k;i<=n;i++){
		gg=(i*(n+1-i+n)/2-i*(i-1)/2+1+mod)%mod;
		ans=(ans+gg)%mod;
	}
	ans=ans%mod;
	ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define  __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define  N   100005
#define  ll  long long int
using namespace std;

vector < pair<int,int> > graph[N];

ll ans[N];

void dfs(int node,ll weight)
{
    if(ans[node] != -1) return;

    ans[node] = weight;

    for(int i=0;i<graph[node].size();i++)
    {
        int u = graph[node][i].first;

        dfs( u ,(graph[node][i].second + weight));
    }

}

int main()
{
    __;

    int n;

    fill(ans,ans+N,-1);

    cin >> n;

    for(int u,v,w, i=1;i<n;i++)
    {

        cin >> u >> v >> w;

        graph[u].emplace_back(v,w);

        graph[v].emplace_back(u,w);
    }

    dfs(1,0);

    for(int i=1;i<=n;i++)
    {
        if(ans[i]%2==0) cout<<0<<endl;
        else cout<<1<<endl;
    }

    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <cassert>
#include <numeric>
#include <random>


using namespace std;
typedef long long ll;

const int MAXN = 1e5+100;
const ll mod = 1e9+7;
int n, m;
set<int> blocked;
ll dp[MAXN];
ll go(int pos) {
  if (pos == n) {
    return 1;
  }
  if (pos > n) return 0;
  if (blocked.count(pos)) return 0;
  if (dp[pos] != -1) return dp[pos];
  ll res = (go(pos+1) + go(pos+2)) % mod;
  return dp[pos] = res;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n+1; i++) {
    dp[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    blocked.insert(x);
  }

  ll res = go(0);
  cout << res << endl;
  return 0;
}


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

int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  long long ans = 0;
  for (int i = 0; i < N - K; i++) {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string st;
  cin >> st;
  int cnt = 0;
  vector<int> spotA;
  vector<int> spotZ;
  int stringsize = 0;
  for (int i = 0; i < (int)st.size(); i++)
  {
     if(st.at(i)=='A'){
       spotA.push_back(i);
     }else if(st.at(i)=='Z'){
       spotZ.push_back(i);
     }
  }
  sort(spotA.begin(), spotA.end());
  sort(spotZ.begin(), spotZ.end());
  reverse(spotZ.begin(), spotZ.end());

  cout << spotZ.at(0)-spotA.at(0)+1 << endl;
  return 0;
}

Measured memory_bytes: 1364
#include <cstdio>

long f(int n)
{
	int a=0,b=0,c=0;
	long tmp=0,rtn=0;

	while(n){
		if(n%4==0) return -1;
		if(n%4==1) a++;
		else if(n%4==2) b++;
		else if(n%4==3) c++;
		tmp=tmp*10+n%4;
		n/=4;
	}

	if(a==0 || b==0 || c==0) return -1;

	while(tmp){
		rtn=rtn*10+2*(tmp%10)+1;
		tmp/=10;
	}

	return rtn;
}

int main()
{
	int n;
	scanf("%d",&n);

	int ans=0;
	for(int i=1;;i++){
		long tmp=f(i);
		if(tmp>0 && tmp<=n){
			ans++;
		}

		if(tmp>n) break;
	}

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

	return 0;
}


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

int main() {
  ll a,b; cin >> a >> b;
  if(a >= b*2)
    cout << a - b*2 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3632
n, m = map(int,input().split())
lst = []
for _ in range(n):
    l = list(map(int, input().split()))
    lst.append(l[1:])

ansset = set(lst[0])
for i in range(1,n):
    ansset = ansset & set(lst[i])

print(len(ansset))


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

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

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

	vector<vector<int>> g(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;

		--a;
		--b;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	int good = 0;
	for (int i = 0; i < n; ++i) {
		bool b = true;
		for (int v : g[i]) {
			if (h[v] >= h[i]) {
				b = false;
				break;
			}
		}

		if (b) {
			++good;
		}
	}

	cout << good;
	
	return 0;
}
	

Measured memory_bytes: 8752
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repp(i,m,n) for(int i=(m);i<(n);i++)

#define PUTLINE cout<<__LINE__<<endl;

vector<int> edges[110];
int dis[110];

int main() {
	int n;
	cin>>n;
	int r,k;
	rep(i,n){
		cin>>r>>k;
		while(k--){
			edges[r-1].push_back(in()-1);
		}
	}
	int p;
	cin>>p;
	rep(i,p){
		int s,d,v;
		cin>>s>>d>>v;
		s--;d--;
		rep(j,n)dis[j]=100100100;
		priority_queue<pint,vector<pint>,greater<pint> > que;
		que.push(mp(0,s));
		while(!que.empty()){
			pint v=que.top();
			que.pop();
			if(dis[v.second]<=v.first)continue;
			dis[v.second]=v.first;
			rep(j,edges[v.second].size()){
				que.push(mp(v.first+1,edges[v.second][j]));
			}
		}
		if(dis[d]>=v)cout<<"NA"<<endl;
		else cout<<dis[d]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll a(n,vll(m)) ;
	for(auto &i:a) for(auto &j:i) cin >> j ;
	for(int i=0;i<n;i++) a.at(i).push_back(0) ;
	vector<bool> use(m+1,true) ;
	ll ans = 0 ;
	vll cnt(m+1,0) ;
	ll rem = m ;
	for(int i=0;i<n;i++) cnt.at(a.at(i).at(0))++ ;
	for(int i=1;i<=m;i++) ans = max(ans,cnt.at(i)) ;
	for(int i=1;i<=m;i++){
		if(cnt.at(i)>=ans){
			use.at(i) = false ;
			rem-- ;
			cnt.at(i) = 0 ;
		}
	}
	vll pos(n,0) ;
	while(rem){
		for(int i=0;i<n;i++){
			if(use.at(a.at(i).at(pos.at(i)))==false){
				while(use.at(a.at(i).at(pos.at(i)))==false) pos.at(i)++ ;
				cnt.at(a.at(i).at(pos.at(i)))++ ;
			}
		}
		ll sub = 0 ;
		for(int i=1;i<=m;i++) sub = max(sub,cnt.at(i)) ;
		ans = min(ans,sub) ;
		for(int i=1;i<=m;i++){
			if(cnt.at(i)>=ans){
				use.at(i) = false ;
				rem-- ;
				cnt.at(i) = 0 ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 5032
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
char S[105];
int dp[2][5];
int nx[2][5];
int main(){
  int Q5VJL1cS;
  int i;
  int j;
  int k;
  int d;
  int a;
  int b;
  int na;
  int nb;
  int res = 0;
  N = rd(S);
  rd(K);
  dp[1][0] = 1;
  for(i=(0);i<(N);i++){
    S[i] -= '0';
  }
  for(Q5VJL1cS=(0);Q5VJL1cS<(N);Q5VJL1cS++){
    auto &k = S[Q5VJL1cS];
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        nx[a][b] = 0;
      }
    }
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        for(d=(0);d<(10);d++){
          na = a;
          nb = b;
          if(d){
            nb++;
          }
          if(a==1 && d > k){
            continue;
          }
          if(d < k){
            na = 0;
          }
          nx[na][nb] += dp[a][b];
        }
      }
    }
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        dp[a][b] = nx[a][b];
      }
    }
  }
  for(a=(0);a<(2);a++){
    res += dp[a][K];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int N, K; char S[105];
// int dp[2][5], nx[2][5];
// 
// {
//   int i, j, k, d, a, b, na, nb, res = 0;
//   rd(S@N,K);
// 
//   dp[1][0] = 1;
//   rep(i,N) S[i] -= '0';
// 
//   rep[S](k,N){
//     rep(a,2) rep(b,4) nx[a][b] = 0;
//     rep(a,2) rep(b,4) rep(d,10){
//       na = a;
//       nb = b;
//       if(d) nb++;
//       if(a==1 && d > k) continue;
//       if(d < k) na = 0;
//       nx[na][nb] += dp[a][b];
//     }
//     rep(a,2) rep(b,4) dp[a][b] = nx[a][b];
//   }
// 
//   rep(a,2) res += dp[a][K];
//   wt(res);
// }


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d %d", $d, $x);
$d--;
$s = 0;
while ($n--) {
	fscanf(STDIN, "%d", $a);
	$s += floor($d / $a) + 1;
}
echo $s + $x;

Measured memory_bytes: 4732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int nt = 0, nx = 0, ny = 0;
        boolean bool = true;
        for(int i = 0; i < n; i++){
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int xlen = Math.abs(nx-x);
            int ylen = Math.abs(ny-y);
            int tlen = t-nt;
            if(tlen < xlen + ylen || tlen % 2 != (xlen+ylen) % 2){
                bool = false;
                break;
            }
        }
        System.out.println(bool ? "Yes" : "No");
    }
}


Measured memory_bytes: 87060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
map<int ,int> m;
int solve(int *h,int curr,int prev,int n)
{
	//cout<<curr<<" ";
	if(curr>n-1)
	{
		return -1;
	}
	if(m.find(curr)!=m.end())
	{
		return abs(h[curr]-h[prev])+m[curr];
	}
	if(curr==n-1)
	{
		return abs(h[curr]-h[prev]);
	}
	int ans=abs(h[curr]-h[prev]);
	int a1=solve(h,curr+1,curr,n);
	int a2=solve(h,curr+2,curr,n);
	//cout<<curr<<" ";
	if(a1!=-1 && a2!=-1)
	m[curr]=min(a1,a2);
	else if(a1==-1)
	m[curr]=a2;
	else if(a2==-1)
	m[curr]=a1;
	return m[curr]+ans;
}
int main()
{
	int n;
	cin>>n;
	int h[n];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	cout<<solve(h,0,0,n);
	return 0;
}


Measured memory_bytes: 14720
S=list(map(lambda x: (27-((ord(x)-96)))%26, list(input())))
K=int(input())
#print(S)

for i,s in enumerate(S):
  if K-s>=0:
    K-=s
    S[i]=0
if K>0:
  S[-1]-=K%26
  S[-1]%=26
#print(S)

S=list(map(lambda x: 1 if x==0 else 27-x, S))
S=list(map(lambda x: chr(x+96), S))
print("".join(S))

Measured memory_bytes: 4792
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n=int(input())
t=make_divisors(n)
for i in range(len(t)):
    t[i]-=1
    if t[i]!=0:
        if n/t[i]>=t[i]:
            t[i]=0
print(sum(t))

Measured memory_bytes: 3272
(function(input) {
    var l = [];
    for (var i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
        l[String.fromCharCode(i)] = 0;
    }

    input.split('').forEach(function(e) {
        e = e.toLowerCase();
        if (e in l) {
            l[e]++;
        }
    });
    console.log(Object.keys(l).map(function(k) {
        return k + ' : ' + this[k];
    }, l).join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef long long LL;

int main(void){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    LL ans = a * x + b * y,sum = ans;
    int tmp = 0;
    if(x > y){
        int i = 1;
        for(i = 1;i <= y;i++){
            tmp = sum - (a+b) * i;
            tmp += 2*c*i;
            if(tmp < ans)ans = tmp;
        }
        for(i = y+1;i <= x;i++){
            tmp = sum - a * i - b * y;
            tmp += 2*c*i;
            if(tmp < ans)ans = tmp;
        }
    }else{
        int i = 1;
        for(i = 1;i <= x;i++){
            tmp = sum - (a+b) * i;
            tmp += 2*c*i;
            if(tmp < ans)ans = tmp;
        }
        for(i = x+1;i <= y;i++){
            tmp = sum - b * i - a * x;
            tmp += 2*c*i;
            if(tmp < ans)ans = tmp;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll N, ans;

ll a[200010], b[200010];

priority_queue<P> que;

bool jud = true;

int main()
{
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> b[i];
		que.push(P(b[i], i));
	}

	while (que.size())
	{
		P p = que.top(); que.pop();
		if (p.first == a[p.second])
		{
			continue;
		}

		ll uu = b[(p.second - 1 == -1 ? N - 1 : p.second - 1)] + b[(p.second + 1 == N ? 0 : p.second + 1)];

		if (p.first - uu < 0)
		{
			jud = false;
			break;
		}
		else
		{
			ll ww = p.first / uu;
			if (p.first - ww * uu < a[p.second])
			{
				if ((p.first - a[p.second]) % uu != 0)
				{
					jud = false;
					break;
				}
				else
				{
					ans += (p.first - a[p.second]) / uu;
					b[p.second] = a[p.second];
				}
			}
			else
			{
				ans += ww;
				b[p.second] = p.first - ww * uu;
				que.push(P(b[p.second], p.second));
			}
		}
	}

	if (jud)
	{
		cout << ans << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	int www;
	cin >> www;
}


Measured memory_bytes: 9072
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

const int K = 26;

struct Vertex {
    int next[K];
    int A[K];

    Vertex() {
        fill(begin(next), end(next), -1);
        fill(begin(A), end(A), 0);
    }
};

vector<Vertex> trie(1);

int N;
vector<string> D;string a;

void add_string(string const& s) {
    int v = 0;
    vector<int> ids;

    for (char ch : s) {
        int c = ch - 'a';
        ids.pb(v);
        if (trie[v].next[c] == -1) {
            trie[v].next[c] = trie.size();
            trie.emplace_back();
        }
        v = trie[v].next[c];
    }

    vector<int> C(26, 0);
    for(int j = s.size() - 1;j >= 0;j--) {
      C[s[j]-'a'] = 1;
      rep(i, 26) trie[ids[j]].A[i] += C[i];
    }
}

int getPairs(string &s) {
  int v = 0;
  for (int i = 0;i < s.size()-1;i++) {
      char ch = s[i];
      int c = ch - 'a';
      if (trie[v].next[c] == -1) {
          return 0;
      }
      v = trie[v].next[c];
  }

  return trie[v].A[s[s.size()-1]-'a'];
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 cin>>N;
 rep(i,N) {
   cin>>a;
   reverse(a.begin(), a.end());
   D.pb(a);
 }
 sort(D.begin(), D.end(), [](const string &l, const string &r) {
   return l.size() > r.size();
 });

 ll ans = 0;

 add_string(D[0]);
 // debug(D[0]);
 for(int i = 1;i < N;i++) {
    int tans = getPairs(D[i]);
    // debug(D[i]);
    // debug(tans);
    ans += tans;
    add_string(D[i]);
 }
 cout << ans << endl;


 return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

long long n, a[ 3 * N ];

int main() {
  cin >> n;
  for ( int i = 0 ; i < 3 * n ; ++i )
    cin >> a[ i ];
  sort( a, a + 3 * n );

  long long ans = 0;
  for ( int i = n ; i < 3 * n ; i += 2 )
    ans += a[ i ];
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>


using namespace std;
using ll=long long;


int deg_count(ll x)
{
	int ret=0;

	for(ret=0;x>0;x/=10,ret++)
		;
	return ret;
}


int main(void)
{
	ll n;

	while(scanf("%lld", &n)==1)
	{
		ll a, b;
		int ans=deg_count(n);

		for(a=1,b=n;a*a<=n;a++)
		{
			if(n%a==0) b=n/a;
			ans=min(ans, deg_count(b));
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

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

		String yyyy_mm_dd = sc.next();
		
		
		int month = Integer.parseInt(yyyy_mm_dd.substring(5, 7));

		
		String ans = (month >= 5) ? "TBD" : "Heisei";

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main() {
	int n, m, l;
	cin >> n >> m >> l;
	char map[114][514];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> map[i][j];
		}
	}
	int sum = 0;
	for (int i = 0; i < n - l + 1; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				if (map[i + k][j] == '#')goto exit1;
			}
			sum++;
		exit1:;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m - l + 1; j++) {
			for (int k = 0; k < l; k++) {
				if (map[i][j + k] == '#')goto exit2;
			}
			sum++;
		exit2:;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],sum = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int s1 = 0, s2 = sum,now = 0,ret;
  int min = 1000;
  for(int i = 0; i < n; i++){
    s1 += a[now];
    s2 -= a[now];
    ret = abs(s1 - s2);
    if (min > ret)
      min = ret;
    now++;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, m;
    while(cin>>n>>m){
        cout<<max(0, n-m+1)<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
while True:
    H,W = list(map(int,input().split()))
    if H*H + W*W == 0:
        break
    for i in range(int(H/2)):
        for j in range(int(W/2)):
            print("#.",end="")
        if W%2 == 1:
            print("#",end="")
        print("")
        for j in range(int(W/2)):
            print(".#",end="")
        if W%2 == 1:
            print(".",end="")
        print("")
    if H%2 == 1:
        for j in range(int(W/2)):
            print("#.",end="")
        if W%2 == 1:
            print("#",end="")
        print("")
    print("")


Measured memory_bytes: 6392
fun main(args: Array<String>) {
    val N = readLine()!!
    val K = readLine()!!.toInt()

    val dp = Array(N.length + 1) { Array(K + 1) { LongArray(2) { 0L } } }
    dp[0][0][1] = 1
    dp[1][0][0] = 1

    for (i in N.indices) {
        dp[i + 1][0][0] += dp[i][0][0]

        for (k in 1..K) {
            dp[i + 1][k][0] += dp[i][k][0]

            if (N[i] == '0') {
                dp[i + 1][k][1] += dp[i][k][1]
            } else {
                dp[i + 1][k][1] += dp[i][k - 1][1]
                dp[i + 1][k][0] += dp[i][k - 1][1] * (N[i] - '0' - 1)
                dp[i + 1][k][0] += dp[i][k][1]
            }

            dp[i + 1][k][0] += dp[i][k - 1][0] * 9
        }
    }

    println(dp[N.length][K][0] + dp[N.length][K][1])
}


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

int harshad(int num) {
    if (num < 10) {
        return num;
    }
    int sum = 0;
    while(num){
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

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

    if (N % harshad(N) == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff

long long N;
long long A[100005], Bi;


int main()
{
    O_O;
    long long i,j,k,l,tst=0,ans=0, csno=0;
    cin>>N;
    for(i=0; i<=N; i++) cin>>A[i];
    for(i=0; i<N; i++)
    {
        cin>>Bi;
        k=min(A[i],Bi);
        Bi-=k;
        ans+=k;
        k=min(A[i+1],Bi);
        A[i+1]-=k;
        ans+=k;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum = 0;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    if(K > x && K - x > x){
      sum += x*2;
    }else{
        sum += (K - x) * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3584
#include <iostream>

//selectionSort

using namespace std;

void printA(int x[], int n){
	for(int i=0;i<n;i++){
		cout << x[i];
		if(i==n-1)cout<<"\n";
		else cout << " ";
	}
}

void swap(int *x, int *y){
	int *tmp;
	*tmp=*y;
	*y=*x;
	*x=*y;
}

int main(){
	int n,min,count=0;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(int i=0;i<n;i++){
		min=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[min]){
				min=j;
			}
		}
		swap(a[i],a[min]);
		if(i!=min)count++;
	}
	
	printA(a,n);
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
void solve()
{
   int n;
   cin>>n;
   int ok=0;
   pair<int,int> arr[n];
   for(int i=0;i<n;i++)
   {
    cin>>arr[i].ff>>arr[i].ss;
   }
   for(int i=0;i<n-2;i++)
   {int is=1;
       for(int j=0;j<3;j++)
       {if(arr[i+j].ff!=arr[i+j].ss)
             is=0;
       }
       ok|=is;
        for(int j=0;j<3;j++)
       {
      if(arr[i].ff==arr[i+j].ff&&arr[i].ss==arr[i+j].ss);
             else
                is=0;
       }
       ok|=is;
   }
   if(ok)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;



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


Measured memory_bytes: 3648
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let D: i64 = sc.get();
    let mut ans = 0;
    for _ in 0..N {
        let X: i64 = sc.get();
        let Y: i64 = sc.get();
        if X * X + Y * Y <= D * D {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2108