akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    for(;;){
      int(n); if(!n)break;
      int(m);
      string s; cin >> s;
      Vint lis;
      for(i = 0;i < s.size() - 2;){
        if(s[i] == 'I'){
          int cnt = 0;
          for(;i < s.size() - 2;){
            if(s[i + 1] == 'O' && s[i + 2] == 'I'){
              cnt++; i += 2;
            }else{
              ++i;
              break;
            }
          }
          if(cnt > 0)lis.pb(cnt);
        }else ++i;
      }
      int res = 0;
      rep(i, lis.size())if(lis[i] >= n)res += lis[i] - n + 1;
      pri(res);
    }

/*/

//*/ break;
  }
  return 0;
}

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

namespace mondai0016
{
	class Program
	{
		static void Main(string[] args)
		{
			double	x		= 0.0;
			double	y		= 0.0;
			double	angle	= 0;
			while( true ) {
				var	s	= Console.ReadLine().Split( ',' );
				var	dist	= int.Parse( s[ 0 ] );
				var	dir		= int.Parse( s[ 1 ] );
				if( (dist == 0) && (dir == 0) ) {
					break;
				}
				var	rad	= angle / 180.0 * Math.PI;
				x	+= dist * Math.Sin( rad );
				y	+= dist * Math.Cos( rad );
				angle	+= dir;
			}
			Console.WriteLine( (int)x );
			Console.WriteLine( (int)y );
		}
	}
}

Measured memory_bytes: 5568
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []

for i in range(N-1):
    B.append(A[i+1] - A[i])
B.append(A[0] + (K - A[N-1]))

#num = B.index(max(B))
print(K - max(B))


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000 ;
  b = (N - a * 1000) / 100 ;
  c = (N - a * 1000 - b * 100) / 10 ;
  d = (N - a * 1000 - b * 100 - c * 10) ;

  if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>
 
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 3000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
// 二項係数計算
long long COM(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 add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
int N, K; //もじゃさんの写経
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K ;
	COMinit();
	FOR(i, 1, K + 1 ){
		int res1, res2;
		if (i == 1) {
			res1 = 1 ;
			res2 = mult(fac[N - K + i], finv[N - K]);
			res2 = mult(res2, finv[i]);
			int ans = mult(res1, res2);
			print(ans);
		}
		else { 
			res1 = 1 ;
			res1 = ((res1*fac[K - 1] % MOD) * finv[K - i] % MOD) *finv[i-1] % MOD;
			res1 %= MOD;
			int C = N - K ;
			res2 = 1;
			res2 = ((res2*fac[C + 1] % MOD) * finv[C - i +1] % MOD) *finv[i] % MOD;
			res2 %= MOD;
			int ans = res1 * res2%MOD;
			if( C < i - 1 ){
				print(0);
				continue;
			}
			print(ans);
		}
	}
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		char[] id = scanner.next().toCharArray();
		int m = scanner.nextInt();
		int[] a = new int[m];
		for (int i = 0; i < m; i++)
			a[i] = scanner.nextInt();
		int[][] dp = new int[10][n + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 10; j++) {
				if (id[n - i - 1] == '*')
					for (int k = 0; k < m; k++)
						dp[(j + slove(i, a[k])) % 10][i + 1] += dp[j][i];
				else
					dp[(j + slove(i, id[n - i - 1] - '0')) % 10][i + 1] += dp[j][i];
			}
		System.out.println(dp[0][n]);
	}

	private int slove(int p, int i) {
		int j = i * 2;
		return (p % 2 == 1) ? j / 10 + j % 10 : i;
	}
}

Measured memory_bytes: 28512
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i =0;i<n;i++){
        cin>>a[i];
    }
    int ans =0;
    for(int i =0;i<n;i++){
        if (a[i]%2 && (i+1)%2){
            ans++;
        }
    }
    cout<<ans;
    
}


Measured memory_bytes: 3580
satisfy n = sum [ (n `mod` (10 ^ (i+1))) `div` (10 ^ i) | i <- [0..4] ]

main = do
  [n,a,b] <- (map read . words) <$> getLine
  print . sum $ [ i  | i <- [1..n], a <= (satisfy i), (satisfy i) <= b]



Measured memory_bytes: 1020
sx, sy, tx, ty = map(int, input().split())
s = (0, 0)
t = (tx-sx, ty-sy)
ans = ""
go1 = "U"*t[1] + "R"*t[0]
back1 = "U" + "L"*t[0] + "LD" + "D"*t[1] +"R"
go2 = "R"*t[0] + "U"*t[1]
back2 = "R" + "D"*t[1] + "DL" + "L"*t[0] + "U"
ans = go1 + back1 + go2 + back2
print(ans)

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  // int N,A,B;cin>>N>>A>>B;
  string s,t;cin>>s>>t;
  sort(ALL(s));
  sort(ALL(t), greater<char>());
  OUT((s<t ? "Yes" : "No"));

  return 0;
}

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

int N;
int A[210];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int res = 0;
  
 
  while(true){
    bool exist_odd = false;
    for(int i = 0; i < N; i++){
      if(A[i] % 2 != 0){
        exist_odd = true;
      }
    }
    if(exist_odd)  break; 
    for(int i = 0; i < N; i++){
      A[i] /= 2;
    }
    res++;
   
  }
  cout << res << endl;
}
  


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXDIM = 3000;
const int MOD = 998244353;
void inc(int& a, int b) { if ((a += b) >= MOD) a -= MOD; }
void inc(int& a, int b, int c) { a = (a + (ll)b * c) % MOD; }
void dec(int& a, int b, int c) { a = (a + (ll)(MOD - b) * c) % MOD; }

int A, B, C, D;

int dp[MAXDIM + 1][MAXDIM + 1];

int solve() {
	REPE(i, C) REPE(j, D) {
		dp[i][j] = 0;
		if (i == A && j == B) inc(dp[i][j], 1);
		if (i >= A && j >= B) {
			if (i > A) inc(dp[i][j], dp[i - 1][j], j);
			if (j > B) inc(dp[i][j], dp[i][j - 1], i);
			if (i > A&& j > B) dec(dp[i][j], dp[i - 1][j - 1], (i - 1) * (j - 1));
		}
		//printf("dp[%d][%d]=%d\n", i, j, dp[i][j]);
	}
	return dp[C][D];
}


void run() {
	scanf("%d%d%d%d", &A, &B, &C, &D);
	printf("%d\n", solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 38936
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n == 0){break;}
                int[]scores = new int[n];
                for(int i = 0;i<scores.length;i++){
                    scores[i]= sc.nextInt();
                }
            double average = 0,variance = 0;
            for(int i = 0;i<scores.length;i++){
                average = (average*n+scores[i])/n;
            }for(int i = 0;i<scores.length;i++){
                variance = (variance*n+(scores[i]-average)*(scores[i]-average))/n;
            }
            
            System.out.println(Math.sqrt(variance)); 
            
            }
        }
    }
}



Measured memory_bytes: 31948
#include <iostream>
using namespace std;
#define MAX 10000

int main(){
    int n,num;
    
    while(cin >> n,n){
        int array[MAX]={0};
        for(int i = 0 ; i < n ; i++){
            cin >> num;
            array[num] = 1;
        }
        
        int s,g,flg = 0,t = 0 ,cnt = 0;
        for(int i = 1 ; i < MAX ; i++){
            if(array[i]){
                if(!t){
                    s = i;
                    t++;
                }
                g = i;
                cnt++;
            }
            else{
                if(cnt==1){
                    cnt = 0;
                    if(t&&!flg){
                        cout << s;
                        flg++;
                        t = 0;
                    }
                    else if(t&&flg){
                        cout << ' ' << s;
                        t = 0;
                    }
                }
                else{
                    cnt = 0;
                    if(t&&!flg){
                        cout << s << '-' << g;
                        flg++;
                        t = 0;
                    }
                    else if(t&&flg){
                        cout << ' ' << s << '-' << g;
                        t = 0;
                    }
                    else continue;
                }
            }
        }
        cout << endl;
    }
    
    return 0;
}

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

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

    for (int k = 0; k < N-1; k++) cout << A[k] << " ";
    cout << A[N-1] << endl;

    int v, j;
    for (int i = 1; i < N; i++){
        v = A[i];
        j = i - 1;

        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (int k = 0; k < N-1; k++) cout << A[k] << " ";
        cout << A[N-1] << endl;
    }



    return 0;
}

Measured memory_bytes: 3080
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int D = int.Parse(Console.ReadLine());

            if (D == 25)
                Console.WriteLine("Christmas");
            else if (D == 24)
                Console.WriteLine("Christmas Eve");
            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");
            else if (D == 22)
                Console.WriteLine("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

unsigned int gcd(unsigned int n1, unsigned int n2)
{
  unsigned int n3;

  while (n1 != 0){
    n3 = n2;
    n2 = n1;
    n1 = n3 % n2;
  }

  return n2;
}

int main(void)
{
  unsigned int a[1000], b[1000];
  unsigned int i, j;

  i = 0;
  while (scanf("%d%d", &a[i], &b[i]) != EOF){
    i++;
  }

  for (j = 0; j < i; j++){
    printf("%d %d\n", gcd(a[j], b[j]), (a[j] / gcd(a[j], b[j]) * b[j]));
  }
  return 0;
}

Measured memory_bytes: 604
n,x,y = map(int, input().split())
p = [[100000000 for j in range(n)] for i in range(n)]
dp = [(-1,0),(1,0),(0,-1),(0,1)]
c = [[] for i in range(n)]

for i in range(n):
  for j in range(n-i):
    j += i
    if i==j:
      p[i][j] = 0
    if abs(i-j)==1:
      p[i][j] = 1
      c[1].append((i,j))
    if i==x-1 and j==y-1:
      p[i][j] = 1
      c[1].append((i,j))
    if i==y-1 and j==x-1:
      p[i][j] = 1
      c[1].append((i,j))
    
print(len(c[1]))

for i in range(n-2):
  i += 2
  for (a,b) in c[i-1]:
    for (da,db) in dp:
      aa = a + da
      bb = b + db
      if not (0 <= aa < n and 0 <= bb < n):
        continue
      if p[aa][bb] > i:
        p[aa][bb] = i
        c[i].append((aa,bb))
  print(len(c[i]))

Measured memory_bytes: 124764
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int a, b;
    char k;

    

    while(cin >> a >> k >> b && k != '?'){
        switch(k){
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            default :
                break;
        }
    }
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define im(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    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);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin >> n;
	vector<int> res(6 * n);
	int max = sqrt(n);
	for (int i = 1; i <= max; i++) {
		for (int j = 1; j <= max; j++) {
			for (int k = 1; k <= max; k++) {
				int pom = i * i + j * j + k * k + i * j + j * k + i * k;
				res[pom]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << res[i] << nl;
	}
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

map <int ,int> ss;

int n;
int a[nax];

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

    long long ans = 0;

    for (int i = 1 ; i <= n ; ++ i) {
        int x;
        scanf("%d", &x);

        ans += ss[i - x];
        ss[i + x] ++;
    }

    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 20784
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define rep(n, i) for(int i = 0; i < n; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define INF 10000000

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

void solve(void){
    int n;
    scanf("%d\n", &n);
    int ls[n];
    rep (n, i) scanf("%d ", &ls[i]);
    int ans = 0;
    rep (n, i) if (ls[i] == i+1) {
        if (i != n-1) swap(&ls[i], &ls[i+1]);
        else swap(&ls[i], &ls[i-1]);
        ans++;
    }

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

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	ll tenp[25];
	tenp[0] = 1;
	rep(i,18) tenp[i+1] = tenp[i] * 10;
	
	ll D = in();
	if (D % 9) {
		cout << 0 << endl;
		return 0;
	}
	D /= 9;
	ll ans = 0;
	for (int K = 2; K <= 18; K++) {
		ll N = D;
		ll temp = 1;
		for (int i = K - 1; i > 0; i -= 2) {
			temp *= 10 - N % 10 - (i == K - 1);
			N -= tenp[i] / 9 * (N % 10);
			if (N < 0) N = -N;
			N /= 10;
		}
		if (N != 0) continue;
		ans += K % 2 ? temp * 10 : temp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n,d,b=0,sum=0;
       cin>>n>>d;
       ll A[n][d];
       for(ll i=0;i<n;i++)
       {
           for(ll j=0;j<d;j++)
           {
               cin>>A[i][j];
           }
       }
       for(ll i=0;i<n-1;i++)
       {
           for(ll j=i+1;j<n;j++)
           {
               sum=0;
               for(ll k=0;k<d;k++)
               {
                   sum=sum+(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
               }
               if(floor(sqrt(sum)) == ceil(sqrt(sum)))
               {
                   b++;
               }
           }
       }
       cout<<b;
    } 
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<ll,ll>
#define iii pair<pair<ll, ll>, ll >
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
using namespace std;
ll a[88];
int n;
void solveup(){
    ll have = 0, money = 1000;
    for(int i=1;i<=n;i++){
        if(i%2==1){     // buy
            ll x = money/a[i];
            if(i==n)break;
            money -= x*a[i];
            have+=x;
            continue;
        }
        ll x = a[i]*have;
        have = 0;
        money+=x;
    }
    money = max(money, 1000ll);
    cout<<money<<endl;
}
void solvedown(){
    ll have = 0, money = 1000;
    for(int i=1;i<=n;i++){
        if(i%2==0){     // buy
            ll x = money/a[i];
            if(i==n)break;
            money -= x*a[i];
            have+=x;
            continue;
        }
        ll x = a[i]*have;
        have = 0;
        money+=x;
    }
    money = max(money, 1000ll);
    cout<<money<<endl;
}
int main(){
    cin>>n;
    srand(time(0));
    for(int i=1;i<=n;i++){
        // a[i] = rand()%101 + 100;//cin>>a[i];
        a[i] = 100;
        if(i%2==0)a[i] = 200;
        cin>>a[i];
    }
    vector<int>v;
    v.pb(a[1]);
    for(int i=2;i<=n;i++){
        if(a[i]==a[i-1])continue;
        v.pb(a[i]);
    }
    for(int i=0;i<v.size();i++)a[i+1] = v[i];
    n = v.size();
    if(n==1){
        cout<<1000<<endl;
        return 0;
    }
    v.clear();
    v.pb(a[1]);
    for(int i=2;i<n;i++){
        if(a[i-1]<a[i] && a[i]>a[i+1]){
            v.pb(a[i]);
            continue;
        }
        if(a[i-1]>a[i] && a[i]<a[i+1]){
            v.pb(a[i]);
            continue;
        }
    }
    v.pb(a[n]);
    for(int i=0;i<v.size();i++)a[i+1] = v[i];
    n = v.size();
    if(a[2]>a[1])solveup();
    else solvedown();
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a[d5],dp[d5];
    for(int i=0;i<n;i++)cin>>a[i];
    //dp[i]:i番目につくまでの最小コスト
    for(int i=0;i<d5;i++)dp[i]=0;
    dp[1]=dp[0]+abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

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

    int n, m;
    cin >> n >> m;
    combination c(m);
    mint ans = 0;
    int p = 1;
    for (int i = 0; i <= n; ++i) {
        mint now = c(n, i) * c(m, i) * c.fact[i] * c(m-i, n-i) * c.fact[n-i] * c(m-i, n-i) * c.fact[n-i];
        ans += now * mint(p);
        p *= -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11056
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N,M = map(int, input().split())
    p_list = list(map(int, input().split()))

    uf = UnionFind(N)
    for i in range(M):
        x,y = map(int, input().split())
        uf.union(x-1,y-1)
        
    cnt = 0
    for i,p in enumerate(p_list):
        cnt += 1 if uf.same(p-1, i) else 0
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14452
from collections import Counter
from scipy.misc import comb

n, a, b = map(int, input().split())
v = list(map(int, input().split()))

v.sort(reverse=True)
v_cum = []
num = 0
for i in range(n):
    num += v[i]
    v_cum.append(num)

print(v_cum[a-1]/a)

if a == n:
    print(1)
else:
    if v[a-1] == v[a]:
        num = v[a-1]
        cf = Counter(v[:a])
        cb = Counter(v[a:])
        n_cf = cf[num]
        n_cb = cb[num]
        if n_cf != a:
            print(comb(n_cf+n_cb, n_cf, exact=True))
        else:
            ans = 0
            for k in range(a, min(b+1, a+n_cb+1)):
                ans += comb(a+n_cb, k, exact=True)
            print(ans)
    else:
        print(1)

Measured memory_bytes: 13284
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-25 21:12:47 +0900
# LastModified: 2020-07-25 21:24:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n-k):
#        print("a[{}]-a[{}]:{}-{}={}".format(k+i, i, a[k+i], a[i], a[k+i]-a[i]))
        if a[k+i] > a[i]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 31640
#include<bits/stdc++.h>
using namespace std;
char a[500];
int main()
{
    int n;
    while(cin>>n)
    {
        int now=0;
        for(int i=0;i<n;i++)
        {
            scanf("%c",a+i);
            if(a[i]=='Y')
            {
                now=1;
            }
        }
        if(now)
            cout<<"Four"<<endl;
        else
            cout<<"Three"<<endl;
    }

}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    string a, b; cin >> a >> b;
    string ans;
    rep(i, 0, a.size() + b.size()) {
        if (i % 2 == 0) {
            ans += a[i / 2];
        } else {
            ans += b[i / 2];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

int f(int n) {
    if (n % 2 == 0) {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}

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

    int s;
    cin >> s;

    set<int> set;

    int ans = 1;
    int prev = s;
    while (set.count(prev) == 0) {
        set.insert(prev);
        prev = f(prev);
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    PRINT(48-m);
}


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

int main(void)
{
    int N, K;
    cin >> N >> K;
    
    int rideCount = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) {
            rideCount++;
        }
    }
    cout << rideCount << endl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


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

    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];
    reverse(numbers.begin(), numbers.end());

    rep(i, n) {
        cout << numbers[i];
        if (i != n - 1) cout << ' ';
    }
    cout << endl;
}


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

const int N=2005;

int gcd(int a,int b)
{
	return !b?a:gcd(b,a%b);
}

int n,a[N],in[N];
vector<int> G[N],E[N];
bool v[N];
priority_queue<int> Q;

void DFS(int x)
{
	v[x]=true;
	for(auto &y:G[x])
		if(!v[y])
		{
			E[x].push_back(y);
			in[y]++;
			DFS(y);
		}
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
			if(gcd(a[i],a[j])!=1)
				G[i].push_back(j),G[j].push_back(i);
	for(int i=1; i<=n; i++)
		if(!v[i])
			DFS(i);
	memset(v,0,sizeof(v));
	for(int i=1; i<=n; i++)
		if(!in[i])
		{
			Q.push(i);
			v[i]=true;
		}
	while(!Q.empty())
	{
		int x=Q.top();
		Q.pop();
		printf("%d ",a[x]);
		for(auto &y:E[x])
			if(!v[y])
			{
				if(!--in[y])
				{
					Q.push(y);
					v[y]=true;
				}
			}
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;

    vector<int> cnt(2, 0);

    for (int i = 0; i < s.size(); i++) {
        cnt[s[i] - '0']++;
    }

    int ans = min(cnt[0], cnt[1]) * 2;

    cout << ans << endl;
}


Measured memory_bytes: 512
#include <utility>
#include <iostream>

using namespace std;

int main()
{
	for(int i = 1; ; i++)
	{
		int x, y;
		cin >> x >> y;
		if(x == 0 && y == 0)
			break;
		
		if(y < x)
			swap(x, y);

		cout << x << " " << y << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;

const double EPS = 1e-9;

const ll MD = 998244353;
ll step(ll a, ll st) {
    if (st == 0) return 1;
    if (st % 2 == 1) return (a * step(a, st - 1)) % MD;
    ll q = step(a, st / 2);
    return (q * q) % MD;
}
ll bak(ll x) {
    return step(x, MD - 2);
}

void solve() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    vector<ll> fak(n + 3), ofak(n + 3);
    fak[0] = ofak[0] = 1;
    for (int i = 1; i < (int)fak.size(); i++) {
        fak[i] = (fak[i - 1] * i) % MD;
        ofak[i] = bak(fak[i]);
    }

    ll ans = 0;
    for (int x = 0; x <= n; x++) {
        if (a * x > k) continue;
        if ((k - a * x) % b != 0) continue;
        ll y = (k - a * x) / b;
        if (y > n) continue;

        ll cnx = (fak[n] * ((ofak[x] * ofak[n - x]) % MD)) % MD;
        ll cny = (fak[n] * ((ofak[y] * ofak[n - y]) % MD)) % MD;
        ans = (ans + cnx * cny) % MD;
    }

    cout << ans << "\n";
}

int main() {
#ifdef FIRE_MIND
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
    solve();
    solve();
#endif
	solve();
    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
typedef pair<ll,ll> P;
#define N 2010
ll n;
ll Beta(string A,string B,ll b){
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    
    ll x[N],y[N],bef;
    lol(i,n)x[i]=y[i]=0;
    
    bef=1e9;
    lol(i,3*n){
	ll I=i%n;
	if(A[I]=='1'&&B[I]=='0'){
	    x[I]=max(x[I],i-bef);
	}
	if(B[I]=='1')bef=i+b;
    }
    
    bef=-1e9;
    for(ll i=3*n;~i;i--){
	ll I=i%n;
	if(A[I]=='1'&&B[I]=='0'){
	    y[I]=max(y[I],bef-i);
	}
	if(B[I]=='1')bef=i;
    }
    
    vector<P> v;
    lol(i,n){
	v.push_back(make_pair(x[i],y[i]));
    }
    sort(v.begin(),v.end(),greater<P>());
    
    ll res=1e9;
    ll maxi=0;
    lol(i,v.size()){
	res=min(res,v[i].first+maxi);
	maxi=max(maxi,v[i].second);
    }
    //cout<<v[0].first<<" "<<maxi<<" "<<res<<endl;
    res=min(res,maxi);
    
    res=2*res+b;
    lol(i,n)res+=(A[i]!=B[i]);
    //cout<<"b="<<b<<" "<<res<<" "<<A<<" "<<B<<endl;
    return res;
}
string Rshift(string x){
    string res="";
    res.push_back(x[x.size()-1]);
    res+=x.substr(0,x.size()-1);
    return res;
}
ll Alpha(string A,string B){
    ll ans=1e9;
    for(ll b=0;b<=n;b++){
	ans=min(ans,Beta(A,B,b));
	B=Rshift(B);
    }
    return ans;
}
bool Cand(string a,string b){
    bool zeroa=1,zerob=1;
    lol(i,n){
	if(a[i]!='0')zeroa=0;
	if(b[i]!='0')zerob=0;
    }
    if(zerob==1){
	if(zeroa)cout<<0<<endl;
	else cout<<-1<<endl;
	return 1;
    }
    return 0;
}
int main(){
    string a,b;cin>>a>>b;
    n=a.size();
    if(Cand(a,b))return 0;
    ll ans=Alpha(a,b);
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    ans=min(ans,Alpha(a,b));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct E
{
	int k, p, x;
	E(int k, int p, int x) :k(k), p(p), x(x) {}
	E() :E(0, 0, 0) {}
	bool operator<(const E& other)const
	{
		return p < other.p;
	}
};

E Es[400010];
int D[200010];

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

	int N, Q;
	cin >> N >> Q;
	int s, t, x;
	int ei = 0;
	rep(i, 0, N)
	{
		cin >> s >> t >> x;
		s -= x;
		t -= x;
		Es[ei] = E(1, s, x);
		ei++;
		Es[ei] = E(0, t, x);
		ei++;
	}
	rep(i, 0, Q)
	{
		cin >> D[i];
	}

	sort(Es, Es + ei);

	int di = 0;
	multiset<int> eset;
	rep(i, 0, ei)
	{
		while (di<Q&&D[di] < Es[i].p)
		{
			if (eset.empty())
			{
				cout << "-1" << endl;
			}
			else
			{
				cout << *eset.begin() << endl;
			}
			di++;
		}
		if (Es[i].k == 1)
		{
			eset.insert(Es[i].x);
		}
		else
		{
			auto itr = eset.find(Es[i].x);
			if (itr != eset.end())
			{
				eset.erase(itr);
			}
		}
	}

	while (di < Q)
	{
		cout << "-1" << endl;
		di++;
	}

	return 0;
}

Measured memory_bytes: 21632
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int V, E, R;
ll Dist[int(1e5 + 5)];
vector <Pil> Graph[int(1e5 + 5)];

int main(){
  scanf("%d%d%d", &V, &E, &R);
  for (int i = 0; i < E; i++){
    int S, T; ll D; scanf("%d%d%lld", &S, &T, &D);
    Graph[S].push_back(mp(T, D));
  }
  
  fill(Dist, Dist + V, -1);
  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  que.push(mp(0, R));
  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (Dist[Q.se] != -1) continue;

    Dist[Q.se] = Q.fi;
    for (int i = 0; i < Graph[Q.se].size(); i++){
      Pil next = Graph[Q.se][i];
      if (Dist[next.fi] != -1) continue;
      que.push(mp(Dist[Q.se] + next.se, next.fi));
    }
  }
  
  for (int i = 0; i < V; i++){
    if (Dist[i] == -1) printf("INF\n");
    else printf("%lld\n", Dist[i]);
  }
  
  return 0;
}



Measured memory_bytes: 21568
import java.util.Scanner;
import java.util.TreeMap;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		TreeMap<String, Integer> treeMap = new TreeMap<String, Integer>();
		for (int i = 0; i < N; i++) {
			String s = scanner.next();
			if (!treeMap.containsKey(s))
				treeMap.put(s, 1);
			else
				treeMap.put(s, treeMap.get(s) + 1);
		}

		int max = 0;
		for (String key : treeMap.keySet()) {
			if (max < treeMap.get(key))
				max = treeMap.get(key);
		}

		for (String key : treeMap.keySet())
			if (treeMap.get(key) == max)
				System.out.println(key);
	}
}

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

int c[200001];
int a[200001];
int b[200001];
int n;

int bs(int x){
    
    int l = 0, r = n-1;
   
    while(l<=r){
        
        int mid = (l+r)/2;
        
        if(c[mid] < x){ // 가능
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    return l;
    
}

int main(int argc, const char * argv[]) {

    

    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    
    }
    
    
    int T = 1;
    int ans = 0;
    
    for(int i=0;i<29;i++){
        
        
        for(int j=0;j<n;j++) c[j] = b[j]%(2*T);
        
        int cnt = 0;
        
        sort(c,c+n);
        for(int j=0;j<n;j++){
            int tmp = (a[j]%(2*T));
            cnt += bs(2*T-tmp) - bs(T-tmp);
            cnt += bs(4*T-tmp) - bs(3*T-tmp);
            cnt%=2;
        }
        if(cnt&1) ans |= T;
        T*=2;
    }
    
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
 public class Main{

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
       	    String op = sc.next();
            int b = sc.nextInt();
        if(op.equals("+")){
           System.out.println(a+b);
        }
       if(op.equals("-")){
           System.out.println(a-b);
        }
       if(op.equals("*")){
           System.out.println(a*b);
        }
        if(op.equals("/")){
           System.out.println(a/b);
        }
        if(op.equals("?")) 
            break;
        
       }
        sc.close();
	}

 }


Measured memory_bytes: 26160
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int T = stdIn.nextInt();
		int A = stdIn.nextInt();
		double[] H = new double[N];
		H[0] = Math.abs(T - stdIn.nextDouble()*0.006 - A);
		double min = H[0];
		int ans = 0;
		for(int i = 1; i < N; i++) {
			H[i] = Math.abs(T - stdIn.nextDouble()*0.006 - A);
			if(H[i] < min) {
				min = H[i];
				ans = i;
			}
		}
		System.out.println(ans+1);

	}

}

Measured memory_bytes: 27332
N, A, B = map(int, input().split())

# 各桁の和を計算する関数
def findSumOfDigits(n):
  sum = 0
  while n > 0:
    q, mod = divmod(n, 10)
    sum += mod
    n = q
  return sum

total = 0
for i in range(1, N + 1):
  sum = findSumOfDigits(i)
  if sum >= A and sum <= B:
    total += i

print(total)

Measured memory_bytes: 3060
h,k = map(int,input().split())

hh = h%2
kk = k%2

if h == 1 or k == 1:
    ans = 1
elif hh == 0 or kk == 0:
    ans = int(h*k/2)
else:
    ans = int(h*k/2)+1

print(ans)

Measured memory_bytes: 3060