akhauriyash/Code-Regression huggingface dataset:
while 1:
    n=int(input())
    if n==0:break
    code=[]
    slmax=0
    for i in range(n):
        s=input()
        s_code=s[0]
        flag=0
        for j in range(len(s)-1):
            if s[j]=="a" or s[j]=="i" or s[j]=="u" or s[j]=="e" or s[j]=="o":s_code+=s[j+1]
        slmax=max(slmax,len(s_code))
        code.append(s_code)
    l_c=len(code)
    if l_c!=len(list(set(code))):
        print(-1)
    else:
        flag=0
        for i in range(1,slmax+1):
            if flag==1:break
            c_code=[]
            for j in code:
                c_code.append(j[:i])
                if len(list(set(c_code)))==l_c:
                    print(i)
                    flag=1
                    break


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

ll n,a[444],pre[444];
ll dp[444][444];
ll sum(ll l,ll r){
    return pre[r]-pre[l-1];
}
ll solve(ll l,ll r){
    if(l==r)return 0;
    ll &ans=dp[l][r];
    if(ans!=-1)return ans;
    ans=1e14;
    for(ll i=l;i<r;i++){
        ans=min(ans,sum(l,r)+solve(l,i)+solve(i+1,r));
    }
    return ans;
}
int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=a[i]+pre[i-1];
    }

    memset(dp,-1,sizeof dp);
    cout<<solve(1,n);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "NO" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ld,ll>;
//--GLOBAL---------------------------------
const ll MAX = 202020;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() { // O(nlogn)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    reps(i, 2, MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll c(int n, int k){ // 二項係数計算
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n=MOD-2, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {

    ll N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    cinit();
    ll dp[N+1][N+1]={}; //j人使ってi人までのグループ作る
    dp[A-1][0]=1;
    reps(i,A-1,B){
        rep(j,N+1){
            ll x=i+1;
            // i+1人を0グループ作る
            dp[x][j]+=dp[i][j];
            dp[x][j]%=MOD;
            // i+1人をkグループ作る
            if(j+x*C>N) continue;
            ll now=1;
            reps(k,1,C){
                now*=c(N-j-x*(k-1),x);
                now%=MOD;
            }
            for(ll k=C; j+x*k<=N and k<=D; ++k){
                now*=c(N-j-x*(k-1),x);
                now%=MOD;
                dp[x][j+x*k]+=(dp[i][j]*now%MOD)*finv[k];
                dp[x][j+x*k]%=MOD;
            }
        }
    }
    cout<< dp[B][N] <<"\n";

}
 
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------

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




int main()
{
   string s,t;
  
   ll i,n,flag=0;
   cin>>n;
   ll arr[n];
   for(i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  for(i=1;i<n;i++)
    if(arr[i]-arr[i-1]==0)
    {
      flag=1;
      break;
    }

    if(flag==1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
   
   
  

return 0;

}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    if(S[0] == S[1] && S[1] == S[2]) PRINT("No");
    else PRINT("Yes");
    return 0;
}

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

struct node {
	struct node *r;
	struct node *l;
	struct node *p;
	int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}

	z->p = y;
	if (y == NIL) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;

	return;
}

void inorder(Node x) {
	if (x == NIL) return;
	inorder(x->l);
	printf(" %d",x->key);
	inorder(x->r);
	return;
}

void preorder(Node x) {
	if (x == NIL) return;
	printf(" %d",x->key);
	preorder(x->l);
	preorder(x->r);
	return;
}

int main() {
	int i,n, key;
	char s[10];

	scanf("%d", &n);

	for (i = 0;i < n;i++) {
		scanf("%s", s);
		if (s[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		} else {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}


	return 0;
}

Measured memory_bytes: 24036
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e18
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n, h;
    cin >> n >> h;
    vector<int> w(n);
    vector<int> v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<int>> dp(n + 1, vector<int>(h + 1, -INF));
    rep(i, h + 1) dp[0][i] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= h; j++) {
            if (j - w[i - 1] >= 0)
                chmax(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            chmax(dp[i][j], dp[i - 1][j]);
        }
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 83168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
int main() {
	ios::sync_with_stdio(0);
	ll k,x,y;
	cin >> k >> x >> y;
	bool rx = false,ry = false,sw = false;
	if(x < 0) {x *= -1;rx = true;}
	if(y < 0) {y *= -1;ry = true;}
	if(x < y) {swap(x,y);sw = true;}
	ll d = x+y;
	if(!(k%2)) {
		if(d%2) {
			cout << "-1\n";
			return 0;
		}
	}
	vpl res;
	if((d%2) && (d<k)) {
		res.push_back({x,x-k});
		res.push_back({x+(k+x-y)/2,x-(k+x-y)/2});
		res.push_back({x,y});
	} else {
		ll bs;
		if((d < k) && (!(d%2))) {
			bs = 2;
		} else {
			ll bt = (k-(d%k))%k;
			if(!(bt%2)) {
				bs = (d+k-1)/k;
			} else {
				bs = (d+k-1)/k+1;
			}
		}
		ll a = 0,b = 0;
		ll dec = (d-bs*k)/2;
		while(b-k >= dec) {
			b -= k;
			res.push_back({a,b});
		}
		if(b > dec) {
			a += k-(b-dec);
			b = dec;
			res.push_back({a,b});
		}
		while(a+k <= x) {
			a += k;
			res.push_back({a,b});
		}
		if(a < x) {
			b += k-(x-a);
			a = x;
			res.push_back({a,b});
		}
		while(b+k <= y) {
			b += k;
			res.push_back({a,b});
		}
	}
	cout << res.size() << '\n';
	for(int i=0;i<res.size();i++) {
		if(sw) {swap(res[i].first,res[i].second);}
		if(rx) {res[i].first *= -1;}
		if(ry) {res[i].second *= -1;}
		cout << res[i].first << " " << res[i].second << '\n';
	}
}

Measured memory_bytes: 5488
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)
#define rep_reverse(i, init, n) for(int i = (init); i > n; --i)

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

	vector<vector<char>> A(N, vector<char>(N));
	vector<vector<char>> B(M, vector<char>(M));

	rep(i, N)
	{
		rep(j, N)
		{
			cin >> A[i][j];
		}
	}

	rep(i, M)
	{
		rep(j, M)
		{
			cin >> B[i][j];
		}
	}

	bool isMatch = false;
	rep(i, N-M+1)
	{
		rep(j, N-M+1)
		{
			bool b = true;
			rep(k, M)
			{
				rep(l, M)
				{
					if (A[i+k][j+l] != B[k][l])
					{
						b = false;
						break;
					}
				}

				if (!b) break;
			}

			if (b) isMatch = true;
		}

		if (isMatch) break;
	}

	cout << (isMatch ? "Yes" : "No") << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3664
s = int(input())
m = 10**10
a = s
d = {}
d[a] = True
for i in range(2, 10**10):
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1
    if a in d:
        break
    d[a] = True
print(i)


Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {

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

			while (s.hasNextInt()) {
				BigInteger[] num = { s.nextBigInteger(), s.nextBigInteger() };
				Arrays.sort(num, Collections.reverseOrder());
				System.out.println(gcd(num) + " " + lcm(num));
			}

		} finally {
			s.close();
		}

	}

	private static BigInteger gcd(BigInteger[] num) {
		return num[0].gcd(num[1]);
	}

	private static BigInteger lcm(BigInteger[] num) {
		return (num[0].multiply(num[1])).divide(gcd(num));
	}
}

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

int main() {
    int a, b; cin >> a >> b;
    if (a > 0) {
        cout << "Positive";
    } else if (b < 0) {
        cout << ((b - a + 1) % 2 == 1 ? "Negative" : "Positive");
    } else {
        cout << "Zero";
    }
    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long r) {
  cout << r * r * 3 << endl;
}

int main() {
  long long r;
  scanf("%lld", &r);
  solve(r);
  return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <vector>
using namespace std;

int sieve(int n) {
    if (n <= 1) return 0;
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    int res = 0;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            res++;
            for (int j = i+i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

int main() {
    while (1) {
        int n;
        int ret = scanf("%d", &n);
        if (ret < 0) break;
        printf("%d\n", sieve(n));
    }
    return 0;
}

Measured memory_bytes: 1148
class Dice

  def initialize (given_ary)
    @ary = given_ary
  end

  def roll (direction)
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end

  def top
    @ary[0]
  end

end

  dice = Dice.new(gets.split.map(&:to_i))
  gets.split('').each do |which|
    dice.roll(which)
  end

  puts dice.top

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

#define mp              make_pair
#define pb              push_back
#define ff              first
#define ss              second
#define inc(A,B)        A=(A+(B))%MOD
#define mul(A,B)        (ll(A)*ll(B)%ll(MOD))
#define sub(a,b)        (((a)-(b)+MOD)%MOD)

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

const int MAX_N = 200005;
const int MOD = 1e9 + 7;

int n, pnt;
ll arr[MAX_N];
pll lftRgt[MAX_N], rgtLft[MAX_N];
ll sum, sumPnt;
ll aux[4];

void save ( ll fVal, ll sVal, ll cVal, int ind, pll *arr ) {
  ll fDif = abs ( fVal-sVal ), sDif = abs ( fVal-2LL*cVal-sVal );
  if ( fDif < sDif )
    arr[ind] = mp ( fVal, sVal );
  else
    arr[ind] = mp ( fVal-cVal, sVal+cVal );
}

int main() {

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

  scanf ( "%d", &n );
  for ( int i = 0; i < n; ++i )
    scanf ( "%lld", arr+i );

  sum = arr[0];
  for ( int i = 1; i < n; ++i ) {
    sum += arr[i];
    while ( sumPnt < sum-sumPnt )
      sumPnt += arr[pnt++];
    save ( sumPnt, sum-sumPnt, arr[pnt-1], i, lftRgt );
  }

  sum = arr[n-1];
  sumPnt = 0;
  pnt = n-1;
  for ( int i = n-2; i >= 0; --i ) {
    sum += arr[i];
    while ( sumPnt < sum-sumPnt )
      sumPnt += arr[pnt--];
    save ( sumPnt, sum-sumPnt, arr[pnt+1], i, rgtLft );
  }

  ll mini = LLONG_MAX;
  for ( int i = 1; i < n-2; ++i ) {
    aux[0] = lftRgt[i].ff;
    aux[1] = lftRgt[i].ss;
    aux[2] = rgtLft[i+1].ff;
    aux[3] = rgtLft[i+1].ss;
    mini = min ( mini, *max_element ( aux, aux+4 ) - *min_element ( aux, aux+4 ) );
  }

//  for ( int i = n-2; i >= 0; --i ) {
//    printf ( "%lld %lld\n", rgtLft[i].ss, rgtLft[i].ff );
//  }

  printf ( "%lld\n", mini );

  return 0;

}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);

int main(){
    ll k, x, y, now = 0; sc(k)
    queue<ll> que;
    for (int i = 1; i <= 9; i++) que.push(i);
    while (now != k){
        now += 1;
        x = que.front(); que.pop();
        y = x % 10;
        if (y != 0) que.push(10*x+y-1);
        que.push(10*x+y);
        if (y != 9) que.push(10*x+y+1);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 998244353

func Solve() {
  var N int
  NextInt(&N)
  X := make([]int, N)
  for i, x := range NextLine() {
    if x == '1' { X[i]++ }
  }
  B := make([]int, N + 1)
  B[1] = 1
  for i := range B[2:] { B[i + 2] = 2 * B[i + 1] % p }
  F := func(n int) int {
    A := 0
    for i := n - 1; 0 <= i; i-- {
      A = (A + B[n - i] * X[i]) % p
    }
    return A
  }
  LE := func(Y []int) bool {
    for i := 0; i < N; i++ {
      if X[i] != Y[i] { return Y[i] < X[i] }
    }
    return true
  }
  C := 2 * N * (F(N) + 1) % p
  D := make([][]int, 0)
  for k := 1; 3 * k <= N; k++ {
    if N % (2 * k) == k { D = append(D, []int{k, 0}) }
  }
  Y := make([]int, N)
  for i, d := range D {
    D[i][1] = F(d[0])
    for i := range Y { Y[i] = X[i % d[0]] ^ ((i / d[0]) % 2) }
    if LE(Y) { D[i][1]++ }
    for _, d2 := range D[:i] {
      if d[0] % d2[0] == 0 { D[i][1] = (D[i][1] - d2[1] + p) % p }
    }
    C = (C - (2 * (N - d[0]) * D[i][1] % p) + p) % p
  }
  Write(C)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 6144
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int MAX(int a,int b){
    return a>b?a:b;
}
int main()
{   int s,i;
    scanf("%d",&s);
    int a[1000001];
    a[0]=s;
    for(i=1;i<1000001;i++){
        if(a[i-1]%2==0){
            a[i]=a[i-1]/2;
        }else{
            a[i]=a[i-1]*3+1;
        }
        for(int j=0;j<i;j++){
            if(a[j]==a[i]){
                printf("%d",i+1);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
n,m=list(map(int, input().split()))
D=[]
for _ in range(m):
    tmp=list(map(int, input().split()))
    D.append(tmp)
P=list(map(int, input().split()))
ans=0
import itertools
for flags in itertools.product([0,1], repeat=n):
    total = 0
    for i in range(m):
        tmp=0
        for sw in D[i][1:]:
            tmp+=flags[sw-1]
        mod=tmp%2
        if mod==P[i]:
            total+=1
    if total==m:
        ans+=1
print(ans)

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

const int N = 211;

int a[N];

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	for(int i = 0; i < 2 * n; i ++)
		cin >> a[i];
	sort(a, a + 2 * n);
	int ans = 0;
	for(int i = 0; i < 2 * n; i += 2)
		ans += a[i];
	cout << ans << '\n';
}

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

using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
bool distan(ll a, ll b, ll d)
{
    a = abs(a);
    b = abs(b);

    unsigned ll q = d * d;
    unsigned ll w = a * a;
    unsigned ll y = b * b;
    if (a > d || b > d)
    {
        return false;
    }
    else
    {
        unsigned ll p = w + y;
        if (p <= q)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

int main()
{
    int n, d;
    cin >> n >> d;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (distan(a, b, d))
        {
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={-1,0,1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n;
    cin>>n;
    
    ll ans=0;
    for(ll r=1; r<=sqrt(n); r++) {
        if(n%r!=0) continue;
        ll m=n/r-1;
        if(r>=m) continue;
        ans+=m;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,temp,h;
  int m[3] = {0,0,0};
  while(scanf("%d",&h) != EOF){
    for(i=0;i<3;i++){
      if(m[i]<h && i<3){
        temp = m[i];
        m[i] = h;
        h = temp;
      }
    }
  }
  for(i=0;i<3;i++){
      printf("%d\n", m[i]);
  }
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,i=1,maxi=OO,choice=OO;
scanf("%d",&n);
while(1){
    int sum=i*(i+1)/2;
    if(sum>n){
        break;
    }
    if(sum==n){
        break;
    }
    i++;
}
printf("%d",i);



    return 0;
}


Measured memory_bytes: 3776
from collections import deque
import copy

n, m = map(int, input().split())
arr = [[False] * 60 for x in range(60)]
ab = []

for _ in range(m):
    a, b = map(int, input().split())
    arr[a - 1][b - 1] = True
    arr[b - 1][a - 1] = True
    ab.append([a - 1, b - 1])


def dfs(x):
    if visited[x]:
        return
    else:
        visited[x] = True
        for i in range(n):
            if graph[x][i]:
                dfs(i)


connected = [True] * m
for i in range(m):
    graph = copy.deepcopy(arr)
    graph[ab[i][0]][ab[i][1]] = False
    graph[ab[i][1]][ab[i][0]] = False
    visited = [False] * 60
    dfs(0)

    for j in range(n):
        if not visited[j]:
            connected[i] = False
            break


print(m - sum(connected))

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

using namespace std;

int main() {
    int K, X;
    cin >> K >> X ;
    if ((500 * K) >= X) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

const MD = 1000000007

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { _, _ = fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { _, _ = fmt.Fscanf(reader, f, a...) }

// BinPow evaluates (base ^ deg) % rem
func BinPow(base int, deg int, rem int) int {
	var res = 1
	for deg > 0 {
		if (deg & 1) > 0 {
			res = int(int64(res) * int64(base) % int64(rem))
		}
		base = int((int64(base) * int64(base)) % int64(rem))
		deg >>= 1
	}
	return res
}

func main() {
	defer writer.Flush()

	var n, k int
	scanf("%d %d", &n, &k)

	a := make([]int, k+1)

	for i := k; i >= 1; i-- {
		var goodCount int = k / i
		a[i] = BinPow(goodCount, n, MD)
		for j := 2; j*i <= k; j++ {
			a[i] = (a[i] - a[j*i]) % MD
			a[i] = (a[i] + MD) % MD
		}
	}
	var ans int = 0
	for i := 1; i <= k; i++ {
		ans = int((int64(a[i])*int64(i) + int64(ans)) % int64(MD))
	}

	printf("%d", ans)

}


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

int main(){
    int n;
    cin >> n;
    int b[n-1];
    rep(i,n-1) cin >> b[i];
    int ans = 0;
    rep(i,n){
        if(i == 0) ans += b[0];
        else if(i == n-1) ans += b[n-2];
        else ans += min(b[i],b[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,n, c,i;
	scanf("%d %d", &a, &b);
	c= (a*100)/8;
	for(i = c; i<c+11; i++)
	{
		if((i*8)/100==a && i/10==b)
		{
			printf("%d\n", i);
			break;
		}
	}
	if(i==c+11) printf("-1\n");
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        100005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


void solve(){ 
    string s,t;
    cin >> s >> t;
    int tot = 0;
    FOR(i,0,sz(s))if(s[i] != t[i])++tot;
    cout << tot << "\n";
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3788
import java.util.*;
import java.io.*;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    if(a==1)
    {
      System.out.print(1);
    }
    else if(a==2)
    {
      System.out.print(8);
    }
    else{
      int c=0,m=0,n=0;
      m=a*(a-1);
      m=m/2;
      n=a*(a-1)*(a-2);
      n=n/6;
      m=m*8;
      n=n*6;
      c=m+n;
      c=c-(a*(a-2));
      System.out.print(c);
    }
    

  }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,n;cin>>h>>w>>n;
  ll cnt[10];fill(cnt,cnt+10,0);
  map<pair<ll,ll>,ll>mp;
  for(ll i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    pair<ll,ll> p=make_pair(a,b);
    mp[p]++;
    for(ll j=a-2;j<=a;j++){
      for(ll k=b-2;k<=b;k++){
        ll c=0;
        ll jud=0;
        for(ll l=j;l<=j+2;l++){
          for(ll m=k;m<=k+2;m++){
            if(l<1||l>h||m<1||m>w){
              jud=1;
              break;
            }
            if(mp[make_pair(l,m)]>0)c++;
          }
          if(jud==1)break;
        }
        if(jud==0){
          if(c==1)cnt[1]++;
          else{
            cnt[c-1]--;
            cnt[c]++;
          }
        }
      }
    }
  }
  ll sum=0;
  for(ll i=1;i<=9;i++)sum+=cnt[i];
  cnt[0]=(h-2)*(w-2)-sum;
  for(ll i=0;i<=9;i++){
    cout<<cnt[i]<<endl;
  }
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define toBinary(name, num) string name = bitset<8>(num).to_string();
#define toDecimal(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
#define INF LONG_MAX
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h, n;
    cin >> h >> n;
    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; ++i) cin >> arr[i].first >> arr[i].second;
    int dp[n][h+1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= h; ++i)
        dp[0][i] = arr[0].second * ceil(i / (double)arr[0].first);
    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= h; ++j)
        {
            int cur = arr[i].second;
            if (j-arr[i].first > 0) cur += dp[i][j - arr[i].first];
            dp[i][j] = min(dp[i-1][j], cur);
        }
    }
    cout << dp[n-1][h] << '\n';
    return 0;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("file.in");
//ofstream fout("file.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int n,L;
vector <int> arr;


int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> L;
    for(int i=1;i<=n;i++) arr.pb(L+i-1);
    int sum=0,maxi=1e18,ans=0;
    for(int i=0;i<arr.size();i++) sum+=arr[i];
    for(int i=0;i<arr.size();i++){
        int d=sum-arr[i];
        if(abs(sum-d)<=maxi){
            maxi=abs(sum-d);
            ans=d;
        }
    }
    rc(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int A, B; cin >> A >> B;
    int res = 0;
    rep(i, 1, n+1){
        int cur = 0;
        int x = i;
        while(x > 0) cur += x % 10, x /= 10;
        if(A <= cur and cur <= B){
            res += i;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

N=int(input())
S=[input() for _ in range(N)]

print("AC x ",S.count("AC"))
print("WA x ",S.count("WA"))
print("TLE x ",S.count("TLE"))
print("RE x ",S.count("RE"))

Measured memory_bytes: 87936
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef queue<int> QI;
typedef long long LL;

int n, ans = 0;

bool ch(LL y) {
	string x = to_string(y);
	int c3 = 0, c5 = 0, c7 = 0;
	REP(i, SZ(x)) {
		if (x[i] == '3')c3++;
		if (x[i] == '5')c5++;
		if (x[i] == '7')c7++;
	}
	if (c3 != 0 && c5 != 0 && c7 != 0) {
		return true;
	}
	else {
		return false;
	}
}

void dfs(LL x){
	if (x <= n && ch(x))ans++;
	else if (x > n)return;
	
	dfs(x*10+3);
	dfs(x*10+5);
	dfs(x*10+7);
}

int main() {
	cin >> n;
	dfs(3);
	dfs(5);
	dfs(7);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	int x = 0, ara[n+9];
	for(int i=0; i<n; i++){
		cin>>ara[i];
		x^=ara[i];
	}
	for(int i=0; i<n; i++){
		cout<<(x^ara[i])<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4340
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static int V, E;
	static boolean[][] edge1, edge2;
	static int[] group;
	static boolean[] visited;
	static PriorityQueue<State> pq=new PriorityQueue<>();
	
	static class State implements Comparable<State>{
		int e, t;
		State(int e, int t){
			this.e=e;
			this.t=t;
		}
		public int compareTo(State s) {
			return s.t-this.t;
		}
	}
	
	static int count=1;
	
	static void dfs1(int now){
	    visited[now]=true;
	    for(int i=0; i<V; i++){
	        if(edge1[now][i] && !visited[i]){
	            dfs1(i);
	        }
	    }
	    pq.add(new State(now, count));
	    count++;
	}
	
	static void dfs2(int now, int c){
	    visited[now]=true;
	    group[now]=c;
	    //System.out.println("group["+now+"]="+group[now]);
	    for(int i=0; i<V; i++){
	        if(edge2[now][i] && !visited[i]){
	            dfs2(i, c);
	        }
	    }
	}
	
	static void bfs(){
	    Arrays.fill(visited, false);
	    count=0;
	    while(! pq.isEmpty()){
	        State state=pq.poll();
	        if(visited[state.e])    continue;
	        count++;
	        dfs2(state.e, count);
	    }
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			V=sc.nextInt();
			E=sc.nextInt();
			edge1=new boolean[V][V];
			edge2=new boolean[V][V];
			group=new int[V];
			visited=new boolean[V];
			for(int i=0; i<E; i++) {
				int s=sc.nextInt();
				int t=sc.nextInt();
				edge1[s][t]=true;
				edge2[t][s]=true;
			}
			for(int i=0; i<V; i++) {
				if(!visited[i]) {
					dfs1(i);
				}
			}
			bfs();
			int Q=sc.nextInt();
			for(int i=0; i<Q; i++) {
				int s=sc.nextInt();
				int t=sc.nextInt();
				System.out.println((group[s]==group[t])? 1:0);
			}

		}
	}
}


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

const int MAX_N=100005;
int n;
int a[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	while(cin>>n){
		int Max=0,Min;
		for(int i=0;i<n;++i)
		{
			cin>>a[i];
			Max=max(Max,a[i]);
		}
		sort(a,a+n);
		int k=lower_bound(a,a+n,Max/2)-a;
		
		int m1=Max,h1=(Max+1)/2,h2=(Max/2),p=Max;
		if(a[k-1]+a[k]<Max){
			p=a[k];
		}else	p=a[k-1];
//		for(int i=0;i<n;++i){
//			if(m1>=abs(h1-a[i])){
//				m1=abs(h1-a[i]);	p=min(p,a[i]);
//			}
//			if(m1>=abs(h2-a[i])){
//				m1=abs(h2-a[i]);	p=min(p,a[i]);
//			}
//		}
		cout<<Max<<" "<<p<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, x, y);
  ll ans;
  if (x < y) {
    ans = min(y - x, abs(x + y) + 1);
  } else {
    ans = min(1 + x - y, abs(x + y)) + 1;
  }
  print(ans);
}


Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class T>
ostream& operator<<(ostream& os, queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <typename T, typename U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <typename T, typename U>
T mpow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * b % MOD;
        n >>= 1;
        b = b * b % MOD;
    }
    return ret;
}

int main() {
    string S;
    cin >> S;
    vector<int> cnt(2, 0);
    for (char c : S) ++cnt[c - '0'];

    cout << min(cnt[0], cnt[1]) * 2 << endl;
    return 0;
}


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

#define ntest 0

using namespace std;

string s;
void solve() {
    int sum = 0;
    cin >> s;
    for (char &i: s) sum += i - '0';
    if (sum % 9) cout << "No\n";
    else cout << "Yes\n";
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"IMPOSSIBLE"<<endl
#define YES() cout<<"Yes"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define mod 1000000007;  
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

void solve()
{
    ll i,j,n,k,m,w,q;
    cin>>n>>m>>k;
    if(n<=m*k) cout<<"Yes"<<ee;
    else cout<<"No"<<ee;
}

int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    for(i=1;i<=t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 3652
N=int(input())
A=list(map(int,input().split()))
a=A[0]
b=sum(A)-A[0]
cnt=abs(a-b)
for i in range(1,N-1):
  a+=A[i]
  b-=A[i]
  c=abs(a-b)
  cnt=min(cnt,c)
print(cnt)

Measured memory_bytes: 24812
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	int check(vector<vector<int>>A);
	vector<vector<int>>A(3, vector<int>(3));

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			
			cin >> A[i][j];
			
		}
	}
	int N;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;	
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (b == A[i][j]) {
					A[i][j] = 0;
				}
				
			}
		}

	}

	

	if (check(A) == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

int check(vector<vector<int>>A) {

	for (int i = 0; i < 3; i++) {
		int j = 0;
		while (1) {
			
			if (A[i][j] == 0) {
				j++;
			}
			else {
				break;
			}
			if (j == 3) {
				return 1;
			}
		}
	}

	for (int j = 0; j < 3; j++) {
		int i = 0;
		while (1) {
			
			if (A[i][j] == 0) {
				i++;
			}
			else {
				break;
			}
			if (i == 3) {
				return 1;
			}
		}
	}
	int i = 0;
	while(1){
		
		if (A[i][i] == 0) {
			i++;
		}
		else {
			break;
		}
		if (i == 3) {
			return 1;
		}

	}
	 i = 0;
	while (1) {
		
		if (A[i][2-i] == 0) {
			i++;
		}
		else {
			break;
		}
		if (i == 3) {
			return 1;
		}

	}

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll sl = len(s);
    ll ans = sl;
    rep(i, sl - 1) {
        if (s[i] != s[i + 1]) {
            ans = min(ans, max(i + 1, sl - i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;

#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)

template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

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

	for(int n, m, h, k; cin >> n >> m >> h >> k, n;) {
		vector<int> points(n);
		for(int i = 0; i < n; ++i)
			cin >> points[i];

		set<pair<int, int> > line;
		for(int i = 0; i < m; ++i) {
			int a, b;
			cin >> a >> b;
			line.insert(make_pair(b, a));
		}

		vector<int> which;
		which.reserve(n);
		for(int i = 0; i < n; ++i)
			which.push_back(i);

		vector<pair<int, int> > can_swap;
		can_swap.reserve(m);

		FOR(it, line) {
			if(which[it->second - 1] <= which[it->second]) {
				can_swap.push_back(make_pair(which[it->second - 1], which[it->second]));
				swap(which[it->second - 1], which[it->second]);
			}
			else {
				swap(which[it->second - 1], which[it->second]);
				can_swap.push_back(make_pair(which[it->second - 1], which[it->second]));
			}
		}

		vector<int> dest(n);
		for(int i = 0; i < n; ++i)
			dest[which[i]] = i;

		int sum = 0;
		for(int i = 0; i < k; ++i)
			sum += points[dest[i]];

		int ans = sum;
		for(int i = 0; i < m; ++i)
			if(can_swap[i].first < k && can_swap[i].second >= k)
				chmin(ans, sum - points[dest[can_swap[i].first]]+ points[dest[can_swap[i].second]]);

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
	int H, W;
	
	while(1){
		cin >> H >> W;
		if ( H == 0 && W == 0 ) break;
		
		for ( int i = 0; i < H; i++ ){
			for ( int j = 0; j < W; j++ ){
				if ( ( i + j ) % 2 == 0 ) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3076
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

let K = read int ()
let (A,B) = readPair int int ()
[A..B]
|> List.exists (fun x -> x % K = 0)
|> function
  | true -> "OK"
  | false -> "NG"
|> printfn "%s"

Measured memory_bytes: 29716