akhauriyash/Code-Regression huggingface dataset:
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005], preGcd[100005], postGcd[100005];

int main() {
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++) {
		scanf("%lld", &arr[i]);
	}
	preGcd[0] = 0;
	postGcd[N + 1] = 0;
	ll ans = -1e18;
	ll curr = 0;

	for(int i = 1; i < N; i++) {
		preGcd[i] = __gcd(preGcd[i - 1], arr[i]);
	}
	for(int i = N; i > 0; i--) {
		postGcd[i] = __gcd(postGcd[i + 1], arr[i]);
	}
	for(int i = 1; i <= N; i++) {
		curr = __gcd(preGcd[i - 1], postGcd[i + 1]);
		ans = max(ans, curr);
	}
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 5;
const int inf = 0x3f3f3f3f;

ll a[maxn];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  ll n; cin >> n;
  For(i, 0, 4) cin >> a[i];
  ll mi = *min_element(a, a + 5);
  cout << 4 + (n - 1) / mi + 1 << '\n';
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long INF=1000000000000000000;

int main(){
  long long N;
  long long K;
  cin>>N>>K;
  long long X[N];

  for(long long i=0;i<N;i++){
    cin>>X[i];
  }
  long long ans=INF;
  for(long long i=0;i<N-K+1;i++){
    ans=min(ans,abs(X[i])+abs(X[i]-X[i+K-1]));
    ans=min(ans,abs(X[i+K-1])+abs(X[i]-X[i+K-1])); 
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4412
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    boolean[] a = new boolean[26];
    for(int i = 0; i < str.length(); i++){
      a[str.charAt(i) - 'a'] = true;
    }
    for(int i = 0; i < a.length; i++){
      if(!a[i]){
        System.out.println((char)(i + 'a'));
        System.exit(0);
      }
    }
    System.out.println("None");
  }
}


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

using namespace std;

const int MAXN = 5050;

const long long P1 = 1087;
const long long P2 = 1097;
const long long MOD1 = 1e9 + 7;
const long long MOD2 = 1e9 + 123;


int N;

char ar[MAXN];

long long int hash1[MAXN];
long long int hash2[MAXN];

long long int power1[MAXN];
long long int power2[MAXN];

inline long long get_hash( int i, int len, long long P, long long MOD, long long power[], long long hash[] ) {

	long long first = (hash[i] - hash[i + len] + MOD) % MOD;

	return (first * power[i]) % MOD;
}

inline bool check( int len ) {

	for( int i=1 ; i <= N ; i++ ) {
		for( int j = i + len ; j <= N - len + 1 ; j++ ) {
			if ( get_hash(i, len, P1, MOD1, power1, hash1) == get_hash(j, len, P1, MOD1, power1, hash1)
			 && get_hash(i, len, P2, MOD2, power2, hash2) == get_hash(j, len, P2, MOD2, power2, hash2) ) {
				// cerr << i << " " << j << " " << len << endl;
				return true;
			}
		}
	}

	return false;
}

int main() {

	string s;

	power1[0] = power2[0] = 1LL;

	for( int i=1 ; i < MAXN ; i++ ) {
		power1[i] = (power1[i - 1] * P1) % MOD1;
		power2[i] = (power2[i - 1] * P2) % MOD2;
	}

	scanf("%d%s", &N, ar + 1);

	for( int i=N ; i ; i-- ) {
		hash1[i] = (((power1[N - i] * (ar[i] - 'a')) % MOD1) + hash1[i + 1]) % MOD1;
		hash2[i] = (((power2[N - i] * (ar[i] - 'a')) % MOD2) + hash2[i + 1]) % MOD2;
	}

	int lo = 0, hi = N, result;

	cerr << hi << endl;

	while( lo <= hi ) {

		int mi = (lo + hi) / 2;

		// cerr << mi << endl;

		if (check(mi)) {
			result = mi;
			lo = mi + 1;
		} else {
			hi = mi - 1;
		}
	}

	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a=0,rem;
  cin>>n;
 while(n)
  {
	rem=n%10;
   	n=n/10;
   	if(rem==7)
    {
      a=1;
      break;
    }
  }
  if(a==1)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3588
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function flush(a::Array{Int,1},n)
	for i in 1:n
		print(Char(a[i]+97))
	end
	println("")
end

function main()
	n = readline() |> parseInt
	a = zeros(Int,n)
	while 1==1
		if a[1]==1
			break
		end
		
		flush(a,n)
		a[n]+=1
		for i in n:-1:2
			mx = 0
			for j in 1:i-1
				mx = max(mx,a[j])
			end
			if a[i]>=mx+2
				a[i-1]+=1
				a[i]=a[i]%(mx+2)
			end
		end
	end
end

main()

Measured memory_bytes: 164468
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b[] = new int[n];
		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		b[n - 1] = Integer.MAX_VALUE;
		
		int[] a = new int[n];
		a[0] = b[0];
		for (int i = 1; i < n; i++) {
			a[i] = Math.min(b[i], b[i - 1]);
		}
		
		int sum = 0;
		for (int i : a) {
			sum += i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    string S;
    cin >> S;
    
    int year = stoi(S.substr(0, 4));
    int month = stoi(S.substr(5, 2));
    string ans;
    if (year <= 2018) {
        ans = "Heisei";
    } else if (year == 2019) {
        if (month < 5) {
            ans = "Heisei";
        } else {
            ans = "TBD";
        }
    } else {
        ans = "TBD";
    }
    print(ans);
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	int yt = (((n + 999)/1000) * 1000) - n;
	cout<<yt<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3652
n,k = map(int,input().split())
A = list(map(int,input().split()))
s = sum(A)
S = []
for i in range(1,int(s**0.5)+1):
    if s%i==0:
        S.append(i)
        if i!=s//i:
            S.append(s//i)
S.sort(reverse = True)

for s in S:
    A.sort(key = lambda x:x%s)
    tmp = 0
    judge = True
    for a in A:
        if tmp + (a%s)<=k and judge:
            tmp += a%s
        else:
            judge = False
            tmp -= s-(a%s)
        if tmp<0:
            break
    if tmp>=0:
        print(s);exit()
    

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

int n;

void dfs(string s)
{
    if (s.length() == n) {
        cout << s << endl;
        return;
    }
    if (s.empty()) dfs("a");
    else {
        int k = *max_element(s.begin(), s.end()) - 'a' + 1;
        for (int i = 0; i <= k; i++) {
            dfs(s + (char)('a' + i));
        }
    }
}

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

    cin >> n;
    dfs("");
    return 0;
}


Measured memory_bytes: 1536
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "queue"

using namespace std;

#define REP(i,j) for(int i = 0;i < j; i++)

//301
int L[200000];
int R[200000];
int v[200000];

int main(void) {
	int n, m, q;
	cin >> n >> m >> q;
	
	REP(i, n) {
		v[i] = 1;
		L[i] = (i + n - 1) % n;
		R[i] = (i + 1) % n;
	}
	int now_pos = 0;
	REP(i, m) {
		
		int now_a = 0;
		cin >> now_a;
		
		if (now_a % 2 == 0) {
			REP(j, now_a)now_pos = R[now_pos];
			v[now_pos] = 0;
			int l = L[now_pos];
			int r = R[now_pos];
			R[l] = r;
			L[r] = l;
			now_pos = r;
		}
		else {
			REP(j, now_a)now_pos = L[now_pos];
			v[now_pos] = 0;
			int l = L[now_pos];
			int r = R[now_pos];
			R[l] = r;
			L[r] = l;
			now_pos = r;
		}
		

	}
	REP(i, q) {
		int ans = 0;
		cin >> ans;
		cout << v[ans] << endl;
	}
}



Measured memory_bytes: 5408
using System;

namespace abc153A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A % B == 0)
                Console.WriteLine(A / B);
            else
                Console.WriteLine(A / B + 1);
        }
    }
}


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

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

    int sum = 0;
    string s;
    int cnt;
    int B_A = 0;
    int B_ = 0;
    int _A = 0;
    for (int i = 0; i < n; i++)
    {
        cnt = 0;
        cin >> s;

        for (int i = 0; i < (int)s.size() - 1; i++)
        {
            if (s.at(i) == 'A' && s.at(i + 1) == 'B') cnt++;
        }
        sum += cnt;   

        if (s.at(0) == 'B') {
            if (s.at((int)s.size() - 1) == 'A') B_A++;
            else B_++;
        }
        else if (s.at((int)s.size() - 1) == 'A') _A++;
    }
    
    if (B_A >= 2) {
        sum += B_A - 1;
    }

    if (B_A >= 1) {
        sum += min(1, _A);
        _A -= min(1, _A);

        sum += min(1, B_);
        B_ -= min(1, B_);
    }
    
    sum += min(_A, B_);

    cout << sum << endl;
}


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

int main(){
  int N, M, R;
  cin >> N >> M >> R;
  vector<int64_t> travel(R);
  for(int i=0; i<R; i++){
    cin >> travel.at(i);
  }
  sort(travel.begin(),travel.end());
  
  int64_t INF = 100000000000;
  vector<vector<int64_t>> dist(N,vector<int64_t>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      dist.at(i).at(j) = INF;
    }
  }
  for(int i=0; i<M; i++){
    int64_t a, b, c;
    cin >> a >> b >> c;
    dist.at(a-1).at(b-1) = c;
    dist.at(b-1).at(a-1) = c;
  }
  
  for(int k=0; k<N; k++){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        dist.at(i).at(j) = min(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }
  
  int64_t cost = INF;
  
  do{
    int64_t cost_x = 0;
    for(int i=0; i<R-1; i++){
      cost_x += dist.at(travel.at(i)-1).at(travel.at(i+1)-1);
    }
    cost = min(cost,cost_x);
  }
  while(next_permutation(travel.begin(),travel.end())); 
  cout << cost << endl;
}

Measured memory_bytes: 512
N = gets.strip.to_i
A = gets.split.map(&:to_i)
res = Array.new
res << A.join(' ') + "\n"
for i in 1..(N-1)
  key = A[i]
  j = i - 1
  while j >= 0 && A[j] > key
    A[j+1] = A[j]
    j=j-1
  end
  A[j+1] = key
  res << A.join(' ') + "\n"
end
print res.join

Measured memory_bytes: 8888
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

ans,num = [],0
for i in range(n):
    num += abs(x[i] - y[i])
ans += num,

num = 0
for i in range(n):
    num += (x[i] - y[i])**2
num **= 1/2
ans += num,

num = 0
for i in range(n):
    num += (abs(x[i] - y[i]))**3
num **= 1/3
ans += num,

num = []
for i in range(n):
    num += abs(x[i] - y[i]),
num = max(num)
ans += num,

print(*ans, sep = "\n")


Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v;
    ll sum = 0;
    for (ll i = 1; sum < n; i++)
    {
        sum += i;
        v.push_back(i);
    }

    if (sum > n)
        v.erase(v.begin() + sum - n - 1);

    for (auto i : v)
    {
        cout << i << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  ll res1 = v.at(n-1), res2 = v.at(0), tmp = INF;
  if (res1%2 == 0) {
    rep(i, n-1) {
      if (tmp > abs(res1/2-v.at(i))) {
        tmp = abs(res1/2-v.at(i));
        res2 = v.at(i);
      }
    }
  } else {
    rep(i, n-1) {
      if (tmp > abs(res1/2-v.at(i))+abs(res1/2+1-v.at(i))) {
        tmp = abs(res1/2-v.at(i))+abs(res1/2+1-v.at(i));
        res2 = v.at(i);
      }
    }
  }
  cout << res1 << ' ' << res2 << endl;
}

Measured memory_bytes: 1024
N = int(input())
k = 1
while (k*(k+1))//2<N:
    k += 1
A = [i for i in range(1,k+1)]
if N==(k*(k+1))//2:
    for a in A:
        print(a)
else:
    m = (k*(k+1))//2-N
    for a in A:
        if a!=m:
            print(a)

Measured memory_bytes: 42584
#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; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
int h[100000][3];
int solve(int s[][3],int n,int curr,int i)
{
	if(curr==n-1)
	{
		return s[curr][i];
	}
	if(h[curr][i]!=0)
	{
		return h[curr][i];
	}
	int a1,a2;
	if(i==0)
	{
		a1=solve(s,n,curr+1,i+1)+s[curr][i];
	    a2=solve(s,n,curr+1,i+2)+s[curr][i];
	    h[curr][i]=max(a1,a2);
	}
	else if(i==1)
	{
		a1=solve(s,n,curr+1,i-1)+s[curr][i];
	    a2=solve(s,n,curr+1,i+1)+s[curr][i];
	    h[curr][i]=max(a1,a2);
	}
	else
	{
		a1=solve(s,n,curr+1,i-1)+s[curr][i];
	    a2=solve(s,n,curr+1,i-2)+s[curr][i];
		h[curr][i]=max(a1,a2);
	}
	return h[curr][i];
}
int main()
{
	int n,i,j;
	cin>>n;
	memset(h,0,sizeof(h));
	int s[n][3];
	for(i=0;i<n;i++)
	{
		cin>>s[i][0]>>s[i][1]>>s[i][2];
	}
	int ans=0;
	for(i=0;i<3;i++)
	{
		ans=max(ans,solve(s,n,0,i));	
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    cout << max(0, min(b,d) - max(a,c)) << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int 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-6;

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;}

const int64 mod = 1e9+7;

int main(void){
	int32 n, m;
	while(cin >> n && n){
		int32 res = 0;
		FOR(i, 1, n){
			int32 sum = i, in = i+1;
			while(sum < n) sum += (in++);
			if(sum == n && sum != i) res++;
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3088
n = gets.to_i

digicnt = 0
while 10 ** (digicnt+1) <= n
  digicnt += 1
end
cnt = 0
for i in 0..(digicnt - 1)
  if i % 2 == 0
    cnt += 10**(i+1) - 10**i
  end
end
if (digicnt+1) % 2 == 1
  cnt += n - 10 ** digicnt + 1
end
puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
ll a[N]={};
bool ok[N];

#define MOD 1'000'000'007
int main(){
	fill(ok, ok+N, true);
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int x; scanf("%d", &x);
		ok[x] = false;
	}
	a[n]=1;
	for(int i = n-1; i>=0; i--){
		if(!ok[i]) continue;
		a[i] = a[i+1]+a[i+2];
		a[i]%= MOD;
	}
	printf("%lld\n", a[0]);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,A,B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int cnt = 0;
	int b = 0;
	for(int i=0;i<N;i++){
		if(S[i]=='c')cout << "No" << endl;
		else if(S[i]=='a'&& cnt<A+B){
			cout << "Yes" << endl;
			cnt++;
		}else if(S[i] =='b'){
			b++;
			if(cnt < A+B && b<=B){
				cout << "Yes" << endl;
				cnt++;
			}else{
				cout << "No" << endl;
			}
		}else cout << "No" << endl;
	}
}

Measured memory_bytes: 848
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  Vi L(m);
  Vi R(m);
  REP(i,m){
    IN2(L[i],R[i]);
  }
  if(*min_element(ALL(R)) >= *max_element(ALL(L))) OUT(*min_element(ALL(R)) - *max_element(ALL(L)) + 1);
  else OUT(0);
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] ch = scn.nextLine().toCharArray();
		int l = ch.length;
		long ans = 0;
		long A = 0;
		boolean B = false;
		for(int i = 0;i < l;i++) {
			if(B) {
				if(ch[i] == 'C') {
					ans += A;
					B = false;
				}
				if(ch[i] == 'A') {
					A = 1;
					B = false;
				}
				if(ch[i] == 'B') {
					A = 0;
				}
			}else {
				if(ch[i] == 'A') {
					A++;
				}
				if(ch[i] == 'B') {
					B = true;
				}
				if(ch[i] == 'C') {
					A = 0;
				}
			}
		}
		System.out.println(ans);
	}

}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n;
int a[25],b[25],c[25],sum=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    rep(i,1,n)
        cin>>a[i];
    rep(i,1,n)
        cin>>b[i],sum+=b[i];
    rep(i,1,n-1)
        cin>>c[i];
    rep(i,2,n)
    {
        if(a[i]==a[i-1]+1)
            sum+=c[a[i-1]];
    }
    cout<<sum;
}




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

int top, N[1000];

void push(int);
int pop(void);

int main(){
  int x,y;
  char n[100];
  top = 0;

  while(scanf("%s", n) != EOF){
    if(n[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(n[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(n[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else{
      push(atoi(n));
    }
  }

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

  return 0;
}


void push(int x){
  N[++top] = x;
}

int pop(){
  top--;
  return N[top + 1];
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
#define fr first
#define sc second
#define EPS 1e-8
#define INF 1 << 30

int main()
{
  int n;
  int num[15], dist[15], box[15];
  int dp[1 << 15][15]; //doubleだと誤差ってるなぁ
  int prev[1 << 15][15];
  int speed[1 << 15];
  fill_n( *dp, 15 * (1 << 15), INF);
  fill_n( *prev, 15 * (1 << 15), -1);

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> num[i] >> dist[i] >> box[i];
  }
  
  for(int i = 0; i < 1 << n; i++){
    int ret = 0;
    for(int j = 0; j < n; j++){
      if(i >> j & 1) continue;
      ret += box[j];
    }
    speed[i] = 7 + ret * 2;
  }
  for(int i = 0; i < n; i++){
    dp[1 << i][i] = 0;
  }
           
  for(int bit = 0; bit < 1 << n; bit++){
    for(int i = 0; i < n; i++){
      if(!((bit >> i) & 1) || dp[bit][i] == INF) continue;
      for(int k = 0; k < n; k++){
        int power = abs( dist[i] - dist[k]) * speed[bit];
        if((bit >> k) & 1) continue;

        int nxbit = bit|(1 << k);
        if(dp[nxbit][k] > dp[bit][i] + power){
          dp[nxbit][k] = dp[bit][i] + power;
          prev[nxbit][k] = i;
        }
      }
    }
  }
  
  int pos = 0;
  int bit = (1 << n) - 1;
  for(int i = 1; i < n; i++){
    if( dp[bit][pos] > dp[bit][i]) pos = i;
  }
  queue< int > st;
  while(pos != -1){
    st.push(num[pos]);
    int foo = prev[bit][pos];
    bit ^= 1 << pos;
    pos = foo;
  }
  while(st.size() > 1){
    cout << st.front() << " ";
    st.pop();
  }
  cout << st.front() << endl;
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();


	
	while (1) {
		int a, b; cin >> a >> b;
		if (a == 0 && b == 0)break;
		int ans = 0;
		rep(i, 1, a + 1) {
			rep(j, i + 1, a + 1) {
				rep(k, j + 1, a + 1) {
					if (i + j + k == b)++ans;
				}
			}
		}
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define dd second
#define ff first
#define N 100005
#define pb push_back
#define pp pair<int,int>
using namespace std;

int n;
int tab[N];

double rem[N];

main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> tab[i];

    sort(tab, tab+n);
    int val = tab[n-1];
        int best = 2e9;
        int res = 0;
       for(int x = 0; x < n-1; ++x) {
           //cout << x << " " << tab[x] << " " << abs((tab[i]/2) - tab[x])<< " " << tab[i] << endl;
           if(abs(val/2 - tab[x]) <= best) {
               best = abs(val/2 - tab[x]);
               res = tab[x];
           }
       }
        cout << tab[n-1] << " " << res << endl;

}

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

int main() {
    string S;
    cin >> S;
    int cnt;
    int ans;
    cnt = 0;
    ans = 0;
    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == 'R') {
            cnt += 1;
            if (ans <= cnt){
                ans = cnt;
            }
        }
        else
            cnt = 0;
    }
    printf("%d\n", ans);
}

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

int main() {
	int a;
	cin >> a;
	vector<int> n(a);
	for (int i = 0; i < a; i++) {
		cin >> n.at(i);
	}
	int sum = 0;
	for (int i = 0; i < a; i++) {
		if (i == a) {
			break;
		}
		for (int j = i+1; j < a; j++) {
			sum = sum + n.at(i) * n.at(j);
		}

	}
	cout << sum << endl;
	return 0;
}

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

const int MAX=1e5+5;
int n,L[MAX],R[MAX],rs[MAX];
char s[MAX];

int main() 
{
	ios_base::sync_with_stdio(false);
	//freopen(".inp","r",stdin);
	cin>>(s+1);
	n=strlen(s+1);
	int cur=0;
	for(int i=1;i<=n;i++)
	{
		R[i]=cur;
		if(s[i]=='R')
			cur=i;
	}
	cur=n+1;
	for(int i=n;i>=1;i--)
	{
		L[i]=cur;
		if(s[i]=='L')
			cur=i;
	}
	for(int i=1;i<=n;i++)
		if(s[i]=='L'&&R[i]!=0)
		{
			if((i-R[i])%2==0)
				rs[R[i]]++;
			else
				rs[R[i]+1]++;
		}
		else
		if(s[i]=='R'&&L[i]!=0)
		{
			if((L[i]-i)%2==0)
				rs[L[i]]++;
			else
				rs[L[i]-1]++;
		}
	for(int i=1;i<=n;i++)
		cout<<rs[i]<<' ';
}

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

using namespace std;

string Calc(int n){
  if(n==0){
    return "0";
  }

  string result = "";

  while(n!=0){
    int rem = n % (-2);
    n = n / (-2);

    if(rem < 0){
      rem += 2;
      n += 1;
    }

    result = to_string(rem) + result;
  }
  return result;
}

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

  cout << Calc(N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    int k,cnt=0;
    int ans=0;
    cin>>a>>b>>k;
    while(a.size() > b.size() ){
        b='0'+b;
    }
    int borrow[10]={0};    
    for(int i=a.size()-1;i>=1;i--){
        if(a[i]-b[i]-borrow[i+1] < 0){
            //cout<<i<<endl;
            borrow[i]=1;
        }
    }
    rep(i,a.size() ){
        if( borrow[i]==1){
            if(a[i-1]-b[i-1]-borrow[i]!= -1){
                a[i-1]+=1;
                cnt++;
            }
        }
        if(cnt==k) break;
    }
    //cout<<a<<endl;
    int bo=0;
    int num;
    int c=1;
    for(int i=a.size()-1;i>=0;i--){
        num=a[i]-b[i]-bo;
        if(num<0){bo=1;num+=10;}
        else bo=0;
        ans+=num*c;
        c*=10;
    }
     
   
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())


int main()
{
  string s;
  cin >> s;
  set<char> S;
  for(auto i: s)S.insert(i);
  puts(S.size() == 2 ? "Yes" : "No");
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudge5
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pnii; /// weighted grid
typedef vector<pii>vii;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int fix (int a,int k){ return (a%k + k)%k; } // convert N mod to P mode
int * LIS_Lengths(vector<int> a) { int* lis = new int[a.size()];int b[a.size()];int maxLength = 1, lowerBound;lis[0] = 1, b[0] = a[0];for (size_t i = 1; i < a.size(); i++) {lowerBound = lower_bound(b, b + maxLength, a[i]) - b;
lis[i] = lowerBound + 1;if (lowerBound == maxLength)    b[maxLength++] = a[i];else    b[lowerBound] = a[i];}return lis;}
bool is_prime(ll n){if(n==2) return true;if(n<2 || n%2 == 0)return false;for(int i=3; i * i <= n; i+=2){if(n % i == 0)return false;}return true;}
ll LCM(ll a, ll b){return (a * b)/__gcd(a,b);}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>
string s,t;
int n,m;
int dp[3003][3003];
int solve(int i , int j)
{
    if(i == n || j == m)
        return 0;
    int &rst = dp[i][j];
    if(~rst)return rst;
    rst = 0;
    if(s[i] == t[j])
        rst = 1 + solve(i+1 , j+1);
    else
    {
        rst = solve(i+1,j);
        rst = max(rst , solve(i , j + 1));
    }
    return rst;
}
void print(int i , int j)
{
    if(i == n || j == m)
        return ;
    int rst = 0;
    if(s[i] == t[j])
    {
        cout<<s[i];
        print(i+1,j+1);
        return;
    }
    else
    {
        if(solve(i+1 , j) > solve(i , j+1))
            print(i+1,j);
        else print(i,j+1);
    }
    return ;
}
/// <<----;------------------------------------------------------------------------->>
int main()
{
    init();
    cin >> s >> t;
    n = s.size();
    m = t.size();
    clr(dp,-1);
    solve(0,0);
    print(0,0);
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	for (int i = 0; i < (s.size()+1) / 2;i++){
		if(s[i]!=s[s.size()-1-i]){
			ans++;
		}
	} cout << ans << endl;
}

Measured memory_bytes: 3608
W,H,x,y,r = map(int, input().split())

if r > x  or r > y  or r*r > x*x + y*y:
    print("No")
elif x+r > W or y+r > H or r*r > (W-x)**2 + (H-y)**2:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef std::pair<ll,ll> P;

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

ll W, H;
int N;
std::vector<P> ps;
std::vector<ll> X, Y;

ll work(ll x, ll y){
    ll cost = 0, max_d = 0;
    REP(i, N){
        ll d = std::abs(ps[i].first-x) + std::abs(ps[i].second-y);
        cost += 2 * d;
        max_d = std::max(max_d, d);
    }

    return cost - max_d;
}

int main(){
    std::cin >> W >> H >> N;

    REP(i, N){
        ll x, y;
        std::cin >> x >> y;

        ps.push_back(mp(x, y));
        X.push_back(x);
        Y.push_back(y);
    }

    std::sort(X.begin(), X.end());
    std::sort(Y.begin(), Y.end());

    ll xs[2], ys[2];
    xs[0] = X[(N-1)/2];
    xs[1] = X[(N+1)/2];
    
    ys[0] = Y[(N-1)/2];
    ys[1] = Y[(N+1)/2];
    
    ll min_cost = INF, x = INF, y = INF;
    REP(i, 2){
        REP(j, 2){
            ll cost = work(xs[i], ys[j]);
            // printf("%lld, %lld, %lld\n", xs[i], ys[j], work(xs[i], ys[j]));
            if(cost < min_cost){
                min_cost = cost;
                x = xs[i];
                y = ys[j];
            }else if(cost == min_cost){
                if(xs[i] < x){
                    x = xs[i];
                }else if(xs[i] == x){
                    if(ys[j] < y){
                        y = ys[j];
                    }
                }
            }
        }
    }

    printf("%lld\n%lld %lld\n", min_cost, x, y);
}

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

string to_string(string s) {
    return '"' + s + '"';
}
string to_string(char ch) {
    string s(1, ch);
    return '\'' + s + '\'';
}
string to_string(const char *s) {
    return to_string((string)s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int ll;
#define int ll
#define pb          push_back
#define pll         pair<int,int>
#define mll	        map<int,int>
#define F           first
#define S           second
#define lbnd(v,val) lower_bound(v.begin(),v.end(),val)
#define ubnd(v,val) upper_bound(v.begin(),v.end(),val)
#define bs(v,val)   binary_search(v.begin(),v.end(),val)
#define mp          make_pair
#define f(i,x,n)    for(int i=x;i<n;i++)
#define isup		isupper
#define islow 		islower
#define max3(a,b,c)	max(a,max(b,c))
#define endl        "\n"
#define countbits(n)	 __builtin_popcountll(n)
#define all(ar) ar.begin(), ar.end()
#define rall(ar) (ar).rbegin(), (ar).rend()
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 2e5 + 10;

typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;
vll adj[N],dp(N,0),vis(N,0);
int flag;

void dfs(int u){
	vis[u]=1;
	// debug(u,dp[u]);
	for(int v: adj[u]){
		if(!vis[v]){
			dfs(v);
		}
		dp[u]= max(dp[u],1+dp[v]);
		// debug(v,dp[v]);
	}
}

void solve(){
	int n,m;
	cin>>n>>m;
	f(i,0,m){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
	}
	// f(i,1,n+1){
	// 	debug(adj[i]);
	// }
	f(i,1,n+1){
		if(!vis[i])
			dfs(i);
	}
	// f(i,1,n+1){
	// 	debug(dp[i]);
	// }
	cout<<*max_element(all(dp))<<endl;
}

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

    

    int t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


Measured memory_bytes: 13312
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
x,y=gsmi
puts x+y/2

Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input = Reads();
        var n = input[0];
        var q = input[1];
        var s = Console.ReadLine();
        var f = new long[n+1];
        f[0] = 0;
        for(var i = 0; i < s.Length-1; i++)
        {
            if (s[i] == 'A' && s[i + 1] == 'C')
                f[i + 1] = f[i]+1;
            else
                f[i + 1] = f[i];
        }
        var answer = new long[q];
        for(int i = 0; i < q; i++)
        {

            var input0 = Reads();
            var l = input0[0];
            var r = input0[1];
            answer[i] = f[r-1]-f[l-1];


        }
        for (int i = 0; i < q; i++)
        {
            Console.WriteLine(answer[i]);
        }

        Console.Out.Flush();
    }
}

Measured memory_bytes: 17720
import java.util.Scanner;

public class Main {

    static int len;
    static String s;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        len = s.length();

        System.out.println(dfs(1, 0, 0L));
        sc.close();
    }

    private static long dfs(int idx, int prePlus, long tmpSum) {
        long ret = 0L;
        if(idx < len){
            ret += dfs(idx+1, prePlus, tmpSum);
            ret += dfs(idx+1, idx, tmpSum + Long.parseLong(s.substring(prePlus, idx)));
        }else{
            ret = tmpSum + Long.parseLong(s.substring(prePlus, idx));
        }
        return ret;
    }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514],cnt[214514];
bool f[214514];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[i]=-1;
	}
	f[1]=1;
	cnt[1]=0;
	ll now=1,num=1;
	while(1){
		if(f[a[now]])break;
		now=a[now];
		f[now]=1;
		cnt[now]=num;
		num++;
	}
	if(k>=num){
		ll roop=num-cnt[a[now]];
		k-=cnt[a[now]];
		k%=roop;
		k+=cnt[a[now]];
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]==k){
			cout<<i;
			return 0;
		}
	}
	return 0;
}


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

using namespace std;

const int INF = 1 << 30;

int V, E;
vector< pair< int, int > > g[15];
int dp[1 << 15][15];

int main()
{
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    g[s].emplace_back(t, d);
  }

  fill_n(*dp, (1 << 15) * 15, INF);
  dp[0][0] = 0;
  auto chmin = [](int &a, int b) { a = min(a, b); };

  for(int i = 0; i < (1 << V); i++) {
    for(int j = 0; j < V; j++) {
      if(dp[i][j] == INF) continue;
      for(auto &p : g[j]) {
        if((i >> p.first) & 1) continue;
        chmin(dp[i | (1 << p.first)][p.first], dp[i][j] + p.second);
      }
    }
  }

  if(dp[(1 << V) - 1][0] == INF) cout << -1 << endl;
  else cout << dp[(1 << V) - 1][0] << endl;
}

Measured memory_bytes: 5032
n,m = [int(i) for i in input().split()]
s = input()
p = n
q = []

while p!=0:
    frag = True
    for i in range(max(p-m,0),p):
        if s[i]=='0':
            q.append(p-i)
            p=i
            frag = False
            break
    if frag:
        q=[]
        print(-1)
        break
        
for i in reversed(q):
    print(i)


Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    unordered_map<string, ll> counter;
    ll res = 0;
    rep(_, n){
        string S; cin >> S;
        sort(S.begin(), S.end());
        res += counter[S];
        counter[S] += 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 10660