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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};


ll N,M;
mint fac[600000];
mint inv[600000];

mint comb(ll a, ll b){
    return fac[a] * inv[a-b] * inv[b];
}

mint pat(ll a, ll b){
    return fac[a] * inv[a-b];
}

int main(){
    cin >> N >> M;
    fac[0] = inv[0] = mint(1);
    for(int i=1;i<=M;i++){
        fac[i] = mint(i) * fac[i-1];
        inv[i] = fac[i].inv();
    }
    mint ans(0);
    for(int k=0;k<=N;k++){
        mint t = comb(N,k) * pat(M-k,N-k);
        if(k%2 == 0) ans += t;
        else ans -= t;
    }
    cout << ans * pat(M,N) << endl;
    return 0;
}

Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

ll dp[55][5300][55]; // [i番目までの累積][合計がJ][k枚使っている]

int main()
{
    ll n, a;
    cin >> n >> a;
    vector<ll> x(n);

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1; // 初期化
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i];
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 5200; ++j)
        {
            for (int k = 0; k <= i; ++k)
            {
                // i番目のものを使う場合
                dp[i + 1][j + x[i]][k + 1] += dp[i][j][k];
                // i番目のものを使わない場合
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for (int k = 1; k <= n; k++)
    {
        ans += dp[n][a * k][k];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 128864
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n, m) = scan "%d %d" Tuple2.make


let () =
  (if n mod 2 = 1 then
     ListL.map (1++(n/2)) ~f:(fun i -> (i, n-i))
   else
     (1,2)::(List.take (n/4 - 1) @@ zip (3++n) (n++-1)) @
     (List.drop (n/4) @@ zip (2++n) (n++-2)))
  |> List.take m
  |> ListL.iter ~f:(fun (i,j) -> Printf.printf "%d %d\n" i j)


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

int main()
{
    vector<long long> v(3);
    cin >> v.at(0) >> v.at(1) >> v.at(2);
    if(v.at(0)%2==0||v.at(1)%2==0||v.at(2)%2==0){
        cout << 0 << endl;
    }else{
        sort(v.begin(),v.end());
        cout << v.at(1)*v.at(0) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll a, b; cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
	return 0;
}


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

int main(){
   int n, m; cin >> n >> m;
   int mati[n];

   for (int i=0; i < n; i++) {
      mati[i] = 0;
   }

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

      mati[a-1] ++;
      mati[b-1] ++;
   }

   for(int i=0; i < n; i++) {
      cout << mati[i] << endl;
   }
   return 0;
}


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

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

  char c;
  while(cin >> c, c != '=') {
    cin >> n;
    if(c == '+') ans += n;
    else if(c == '-') ans -= n;
    else if(c == '*') ans *= n;
    else ans /= n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int cnt[2001][2001];

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int x,y;
        char c;
        cin>>x>>y>>c;
        if(c=='W')cnt[(x+k)%(2*k)+1][y%(2*k)+1]++;
        else cnt[x%(2*k)+1][y%(2*k)+1]++;
    }
    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k;j++){
            cnt[i+1][j+1]+=cnt[i][j+1]+cnt[i+1][j]-cnt[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            int s=0;
            s+=2*cnt[i][j+k]+2*cnt[i+k][j]-2*cnt[i][j]+cnt[2*k][j+k]-cnt[i+k][j+k]-cnt[2*k][j]+cnt[i+k][2*k]-cnt[i+k][j+k]-cnt[i][2*k];
            ans=max({ans,s,n-s});
        }
    }
    cout<<ans<<endl;
}


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

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

int n , m;

string s[] = {"Sunny", "Cloudy", "Rainy"};

void solve(int cs){
    string tmp;
    cin >> tmp;

    for(int i = 0 ; i < 3 ; i ++){
        if(s[i] == tmp){
            printf("%s\n" , s[ (i+1)%3 ].c_str());
            break;
        }
    }
}

main(){
    int t = 1;
    //("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MAXVAL = 1e4;

int main () {
	int n;
	cin >> n;
	vector <int> ans(MAXVAL+1);
	for (int x = 1; x <= 100; x++)
		for (int y = 1; y <= 100; y++)
			for (int z = 1; z <= 100; z++) {
				int val = x * x + y * y + z * z + x * y + y * z + x * z;
				if (val <= MAXVAL) ans[val]++;
			}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 3656
A, B, Q = gets.chomp.split.map(&:to_i)
as = 0.upto(A-1).map{|i| gets.to_i}
bs = 0.upto(B-1).map{|i| gets.to_i}
qs = 0.upto(Q-1).map{|i| [gets.to_i, i]}.
  sort{|q1, q2| q1[0] <=> q2[0]}

qsH = Hash.new{|h,k| h[k] = {}}

ai = bi = 0
qs.each do |x, i|
  if as[ai] <= x
    while ai <= A - 2
      ai += 1
      if x < as[ai]
        break
      end
    end
  end
  if x < as[ai]
    if ai == 0
      qsH[i]["westa"] = nil
    else
      qsH[i]["westa"] = as[ai-1]
    end
    qsH[i]["easta"] = as[ai]
  else      
    qsH[i]["westa"] = as[ai]
    qsH[i]["easta"] = nil
  end
  if bs[bi] <= x
    while bi <= B - 2
      bi += 1
      if x < bs[bi]
        break
      end
    end
  end
  if x < bs[bi]
    if bi == 0
      qsH[i]["westb"] = nil
    else
      qsH[i]["westb"] = bs[bi-1]
    end
    qsH[i]["eastb"] = bs[bi]
  else      
    qsH[i]["westb"] = bs[bi]
    qsH[i]["eastb"] = nil
  end    
end

#p qsH

ans = Array.new(Q)
qs.each do |x, i|
  wa = qsH[i]["westa"]; ea = qsH[i]["easta"]
  wb = qsH[i]["westb"]; eb = qsH[i]["eastb"]
  if wa.nil?
    if wb.nil? # [x o] [x o]
      ans_ww = ans_we = ans_ew = 10**11
      ans_ee = [ea, eb].max - x
    else # [x o] [o -]
      if eb.nil? # [x o] [o x]
        ans_ww = ans_ee = 10**11
        ans_we = (x - wb) + (ea - wb)
        ans_ew = (ea - x) + (ea - wb)
      else # [x o] [o o]
        ans_ww = 10**11
        ans_we = (x - wb) + (ea - wb)
        ans_ee = [ea, eb].max - x
        ans_ew = (ea - x) + (ea - wb)
      end
    end
  else # [o -] [- -]
    if wb.nil? # [o -] [x o]
      if ea.nil? # [o x] [x o]
        ans_ww = ans_ee = 10**11
        ans_we = (x - wa) + (eb - wa)
        ans_ew = (eb - x) + (eb - wa)
      else # [o o] [x o]
        ans_ww = 10**11
        ans_we = (x - wa) + (eb - wa)
        ans_ee = [ea, eb].max - x
        ans_ew = (eb - x) + (eb - wa)
      end
    else # [o -] [o -]
      ans_ww = x - [wa, wb].min
      if ea.nil? # [o x] [o -]
        if eb.nil? # [o x] [o x]
          ans_we = ans_ee = ans_ew = 10**11
        else # [o x] [o o]
          ans_ee = 10**11
          ans_we = (x - wa) + (eb - wa)
          ans_ew = (eb - x) + (eb - wa)
        end
      else # [o o] [o -]
        if eb.nil? # [o o] [o x]
          ans_ee = 10**11
          ans_we = (x - wb) + (ea - wb)
          ans_ew = (ea - x) + (ea - wb)
        else # [o o] [o o]
          ans_we = [(x - wa) + (eb - wa), (x - wb) + (ea - wb)].min
          ans_ee = [ea, eb].max - x
          ans_ew = [(ea - x) + (ea - wb), (eb - x) + (eb - wa)].min
        end
      end
    end
  end
  ans[i] = [ans_ww, ans_we, ans_ee, ans_ew].min
end

puts ans

Measured memory_bytes: 56040
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

  int64_t l = 1001, r = -1;
  for (auto i : irange(0L, n)) {
    int64_t a;
    cin >> a;
    l = min(a, l);
    r = max(a, r);
  }

  cout << r - l << endl;
}

Measured memory_bytes: 256
def xgcd(a,b)
  px = 1
  x = 0
  py = 0
  y = 1
  while b > 0
    q = a/b
    x, px = px - q*x, x
    y, py = py - q*y, y
    a, b = b, a%b
  end
  puts "#{px} #{py}"
end

a, b = gets.split(" ").map(&:to_i)
xgcd(a, b)



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

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

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

const double eps = 1e-6;

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

const int64 mod = 1777777777;
using PIC = pair<int32, char>;

int main(void){
	int32 n, m;
	vector<int64> a;
	vector<int64> sum;
	vector<PLL> v;
	cin >> n >> m;
	sum.resize(3*m+2);
	a.resize(n);
	REP(i, n){
		cin >> a[i];
	}
	REP(i, n-1){
		if(a[i] > a[i+1]){
			v.emplace_back(a[i]+1, a[i+1]+m);
			v.emplace_back(a[i]+m+1, a[i+1]+2*m);
			sum[a[i]+1]++;
			sum[a[i+1]+m]--;
			sum[a[i]+m+1]++;
			sum[a[i+1]+2*m]--;
		}else{
			v.emplace_back(a[i]+1, a[i+1]);
			sum[a[i]+1]++; sum[a[i+1]]--;
			v.emplace_back(a[i]+m+1, a[i+1]+m);
			sum[a[i]+m+1]++; sum[a[i+1]+m]--;
			v.emplace_back(a[i]+2*m+1, a[i+1]+2*m);
			sum[a[i]+2*m+1]++; sum[a[i+1]+2*m]--;
		}
	}
	REP(i, sum.size()-1) sum[i+1] += sum[i];
	REP(i, v.size()) sum[v[i].sc] -= v[i].sc-v[i].fs;
	REP(i, sum.size()-1) sum[i+1] += sum[i];
	int64 res = 0;
	REP(i, sum.size()) res = min(res, -sum[i]);
	REP(i, n-1){
		if(a[i] < a[i+1]) res += a[i+1]-a[i];
		else res += a[i+1]+m-a[i];
	}
	cout << res << endl;
}

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

int main()
{
  int n, ans = 0, max = 0;
  cin >> n;
  for(int i = 0; i < n; ++i)
  {
    int t;
    cin >> t;
    ans += t;
    if(max < t)
    {
      max = t;
    }
  }
  cout << ans - max / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k, a, b; cin >> k >> a >> b;
	ll ans = 0;
	if (b - a > 2)
	{
		ll rest = k - (a - 1);
		ll x = rest / 2;
		ans += a + x * (b - a);
		ans += rest % 2;
	}
	else
	{
		ans += k + 1;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
/* ITP1_10_C */
import java.io.*;

class Main
{
  public static int student;
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      while((student = Integer.parseInt(br.readLine())) != 0){
        String[] str = br.readLine().split(" ");
        double[] score = new double[student];
        double mean = 0;
        double variance = 0;

        for(int i = 0; i < student; i++){
          score[i] = Integer.parseInt(str[i]);
          mean += score[i];
        }
        mean /= student;

        for(int i = 0; i < student; i++){
          variance += Math.pow((score[i] - mean), 2);
        }
        variance = variance / student;
        
        System.out.println(Math.sqrt(variance));
      }
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 25028
#include <math.h>
#include <stdio.h>
int main(void) {
  int n, x[100], i, y = 0, z = 0;
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    y += x[i];
  }
  y = (double)y / (double)n + 0.5;
  for (i = 0; i < n; i++) {
    z += pow(y - x[i], 2);
  }
  printf("%d\n", z);
  return 0;
}


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

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

    int res = 1;
    for (int i = 1; i < N; ++i)
    {
        bool flag = true;
        for (int j = 0; j < i; ++j)
        {
            if (H[i] - H[j] < 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            res++;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;

const int DATA = 10;

int main() {
  int max=-1, mid=-1, min=-1;
  for(int i=0; i<DATA; i++) {
    int d = to!(int)(chomp(readln));
    if(max < d) {
      min = mid;
      mid = max;
      max = d;
    }
    else if(mid < d) {
      min = mid;
      mid = d;
    }
    else if(min < d) {
      min = d;
    }
  }
  writeln(max, "\n", mid, "\n", min);

  return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s,t;cin>>s>>t;
  char y;
  bool flag=true;
  for(char x = 'a';x<='z';x++){
    flag=true;
    for(int i=0;i<(int)s.size();i++){
      if(s[i]==x && flag){
        y=t[i];
        flag=false;
      }
      if(s[i]==x && !flag){
        if(t[i]!=y){
          P("No");
          return 0;
        }
      }
    }
  }
  for(char x = 'a';x<='z';x++){
    flag=true;
    for(int i=0;i<(int)t.size();i++){
      if(t[i]==x && flag){
        y=s[i];
        flag=false;
      }
      if(t[i]==x && !flag){
        if(s[i]!=y){
          P("No");
          return 0;
        }
      }
    }
  }
  P("Yes");
  return 0;
}


Measured memory_bytes: 916
d, n = map(int, input().split())
count = 0
i = 1

while True:
    c = 0
    num = i
    while num >= 100:
        if num%100==0:
            num = num//100
            c += 1
        else:
            break
    if c==d:
        count += 1
    if count == n:
        print(i)
        break
    i += 1

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

int main() {
  int N,a=0,Z=0;
  cin>>N;
  vector<int> p={3,5,7};
  while(a<p.size()){
    if(p.at(a)<=(N-3)/10){
      p.push_back(p.at(a)*10+3);
    }
    if(p.at(a)<=(N-5)/10){
      p.push_back(p.at(a)*10+5);
    }
    if(p.at(a)<=(N-7)/10){
      p.push_back(p.at(a)*10+7);
    }
    a++;
  }
  for(int x:p){
    int A=0,B=0,C=0,D=x;
    while(D>0){
      if(A==0&&D%10==3){
        A++;
      }
      if(B==0&&D%10==5){
        B++;
      }
      if(C==0&&D%10==7){
        C++;
      }
      D/=10;
    }
    if(A==1&&B==1&&C==1){
      Z++;
    }
  }
  cout<<Z<<endl;
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ll long long
int main(){
    string s; cin >> s;
    int ans =0;
    REP(i,6){
        if(s[i]=='1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int n,m,p,q;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int t;
  int x;
  cin>>n>>x>>t;
  cout<<(n+x-1)/x*t<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,k;
	cin >> n >> k;
	int ans=1;
	REP(i,n){
		if(ans<k) ans*=2;
		else ans+=k;
	}
	cout << ans << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 10005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int n;
    cin>>n;
    vector<pair<double,double>>v;
    rep0(i,n){
        double x,y;
        cin>>x>>y;
        v.pb({x,y});
    }
    double ans=0;
    rep0(i,n-1)repp(j,i+1,n){
        double xx=(v[i].F-v[j].F)*(v[i].F-v[j].F)+(v[i].S-v[j].S)*(v[i].S-v[j].S);
        ans+=sqrt(xx);
    }
    ans*=2;
    ans/=n;
    pr(ans);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    cout<<fixed<<setprecision(10);
   // cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 2 * 100'000 + 5;

i64 n;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    i64 a, b, c, k;

    cin >> a >> b >> c >> k;
    i64 S = 0;

    i64 va = min(a, k);
    k -= va;
    S += va;

    if (k == 0) {
        cout << S << endl;
        return 0;
    }

    i64 vb = min(b, k);
    k -= vb;
    if (k == 0) {
        cout << S << endl;
        return 0;
    }

    i64 vc = min(c, k);
    k -= vc;
    S -= vc;
    cout << S << endl;


    return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int[][][] buildings = new int[4][3][10];

            final int n = Integer.parseInt(in.readLine());
            for (int i = 0; i < n; i++) {
                int[] input = Arrays.stream(in.readLine().split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray();
                int b = input[0] - 1;
                int f = input[1] - 1;
                int r = input[2] - 1;
                int v = input[3];
                buildings[b][f][r] += v;
            }

            StringBuilder sb = new StringBuilder();
            for (int b = 0; b < 4; b++) {
                for (int f = 0; f < 3; f++) {
                    for (int r = 0; r < 10; r++) {
                        sb.append(" ");
                        sb.append(buildings[b][f][r]);
                    }
                    sb.append("\n");
                }
                if (b != 3) {
                    sb.append("####################\n");
                }
            }

            System.out.print(sb);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 31280
N,M,Q = (int(x) for x in input().split())
abcd  = [[]]*Q
for T in range(0,Q):
    abcd[T] = [int(x) for x in input().split()]
    
def PointCal(A,Q,abcd,MaxP):
    Point = 0
    for TT in range(0,Q):
        if A[abcd[TT][1]-1]-A[abcd[TT][0]-1]==abcd[TT][2]:
            Point += abcd[TT][3]
    return max(Point,MaxP)

MaxP  = 0
for A1 in range(1,M+1):
    for A2 in range(A1,M+1):
        if N==2:
            A    = [A1,A2]
            MaxP = PointCal(A,Q,abcd,MaxP)
        else:
            for A3 in range(A2,M+1):
                if N==3:
                    A    = [A1,A2,A3]
                    MaxP = PointCal(A,Q,abcd,MaxP)
                else:
                    for A4 in range(A3,M+1):
                        if N==4:
                            A    = [A1,A2,A3,A4]
                            MaxP = PointCal(A,Q,abcd,MaxP)
                        else:
                            for A5 in range(A4,M+1):
                                if N==5:
                                    A    = [A1,A2,A3,A4,A5]
                                    MaxP = PointCal(A,Q,abcd,MaxP)
                                else:
                                    for A6 in range(A5,M+1):
                                        if N==6:
                                            A    = [A1,A2,A3,A4,A5,A6]
                                            MaxP = PointCal(A,Q,abcd,MaxP)                                    
                                        else:
                                            for A7 in range(A6,M+1):
                                                if N==7:
                                                    A    = [A1,A2,A3,A4,A5,A6,A7]
                                                    MaxP = PointCal(A,Q,abcd,MaxP)
                                                else:
                                                    for A8 in range(A7,M+1):
                                                        if N==8:
                                                            A    = [A1,A2,A3,A4,A5,A6,A7,A8]
                                                            MaxP = PointCal(A,Q,abcd,MaxP)   
                                                        else:
                                                            for A9 in range(A8,M+1):
                                                                if N==9:
                                                                    A    = [A1,A2,A3,A4,A5,A6,A7,A8,A9]
                                                                    MaxP = PointCal(A,Q,abcd,MaxP)
                                                                else:
                                                                    for A10 in range(A9,M+1):
                                                                        A    = [A1,A2,A3,A4,A5,A6,A7,A8,A9,A10]
                                                                        MaxP = PointCal(A,Q,abcd,MaxP)
print(MaxP)

Measured memory_bytes: 72444
N, M = [int(i) for i in input().split()]
K = []
S = []
for _ in range(M):
    k, *s = [int(i)-1 for i in input().split()]
    K.append(k)
    S.append(set(s))

P = [int(i) for i in input().split()]


res = 0
for bit in range(2**N):
    ok = True
    for i in range(M):
        c = 0
        for v in S[i]:
            if bit & (2**v):
                c += 1
        if c % 2 != P[i]:
            ok = False
    if ok:
        res += 1

print(res)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    FOR(i, 0, n) cin >> x[i];
    FOR(i, 0, n) cin >> y[i];
    double p1 = 0, p2 = 0, p3 = 0, pmugen = 0;
    FOR(i, 0, n){
        p1 += fabs(x[i]-y[i]);
        p2 += pow(fabs(x[i]-y[i]), 2);
        p3 += pow(fabs(x[i]-y[i]), 3);
        pmugen = max(pmugen, fabs(x[i]-y[i]));
    }
    p2 = pow(p2, 0.5);
    p3 = pow(p3, 0.3333333333);
    printf("%.05lf\n", p1);
    printf("%.05lf\n", p2);
    printf("%.05lf\n", p3);
    printf("%.05lf\n", pmugen);
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	string s, ss, sss;
	cin >> s >> ss >> sss;
	if (s[s.length() - 1] == ss[0] && ss[ss.length() - 1] == sss[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

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

  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }

  sort(v.begin(), v.end(), greater<ll>());

  vector<vector<ll>> com = comb(50, 50);

  double max_avr = 0.0;
  for(int i = 0; i < A; i++){
    max_avr += v[i];
  }

  max_avr = max_avr / A;

  int p, q;
  p = 0;
  q = 0;
  for(int i = 0; i < N; i++){
    if(v[i] == v[A-1]){
      p++;
      if(i < A){
        q++;
      }
    }
  }

  ll cnt = 0LL;
  if(q == A){
    for(q = A; q <= B; q++){
      cnt += com[p][q];
    }
  }else{
    cnt += com[p][q];
  }

  cout.precision(20);

  cout << fixed << max_avr << endl;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
      ll n,l;
      cin>>n>>l;
      vector<ll>v;
      ll f=0;
      ll f1=0;
      ll f2=0;
      ll sum=0;
      ll mx1=1e18;
      ll mx2=-1e18;
      for(int i=1;i<=n;i++)
      {
          ll p=l+i-1;
          v.pb(p);
          sum+=p;
          if(p>0 && mx1>p)
          mx1=p;
          if(p<0 && mx2<p)
          mx2=p;
          if(p==0) f=1;
          if(p>0) f1=1;
          if(p<0) f2=1;
      }
      if(f==1)
      cout<<sum<<endl;
      else
      {
          ll q=sum;
          ll q1=sum-mx1;
          ll q2=sum-mx2;
          if(abs(q-q1)>abs(q-q2))
          cout<<q2<<endl;
          else
          cout<<q1<<endl;
      }
      
    
    
    
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}


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

int main(){
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct Testify {
    pid: u32,
    is_honest: u32,
}
struct Person {
    a: u32,
    testifies: Vec<Testify>,
}

fn main() {
    let n: u32 = read();
    let mut persons: Vec<Person> = Vec::new();
    for _ in 0..n {
        let mut p = Person{a: read(), testifies: Vec::new()};
        for _ in 0..p.a {
            p.testifies.push(Testify{pid: read::<u32>()-1, is_honest: read()});
        }
        persons.push(p)
    }
    let n2 = i32::pow(2, n);
    let mut cmax = 0;
    'outer:
    for k in 0..n2 {
        let mut c = 0;
        for i in 0..n {
            if (0x01 & (k>>i)) != 1 {continue;}
            c += 1;
            let p = persons.get(i as usize).unwrap();
            for t in p.testifies.iter() {
                if ((0x01 & (k>>t.pid)) as u32) != t.is_honest {
                    continue 'outer
                }
            }
        }
        cmax = std::cmp::max(cmax, c);
    }
    println!("{}", cmax);
}


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

int main() {
  int n,m;cin>>n>>m;
  vector<vector<char>> a(n,vector<char>(n)),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];
  rep(i,n-m+1)rep(j,n-m+1){
    bool ans=true;
    rep(k,m)rep(l,m){
      if(a[i+k][j+l]!=b[k][l])ans=false;
    }
    if(ans){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using P = std::pair<int, int>;

constexpr int MAX = 1e5 + 10;

std::vector<P> g[MAX];

bool used[MAX];
int x[MAX];

bool dfs(int v)
{
    used[v] = 1;

    for (auto ch : g[v])
    {
        if (!used[ch.first])
        {
            x[ch.first] = x[v] + ch.second;
            if (!dfs(ch.first))
                return 0;
        }
        else if (x[ch.first] != x[v] + ch.second)
            return 0;
    }

    return 1;
}

int n, m;

int main()
{

    std::cin >> n >> m;

    for (int i = 0; i < m; ++i)
    {
        int l, r, d;
        std::cin >> l >> r >> d;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    for (int i = 1; i <= n; ++i)
    {
        if (!used[i])
        {
            x[i] = 1;
            if (!dfs(i))
            {
                std::cout << "No" << std::endl;
                return 0;
            }
            //std::cerr << "de" << std::endl;
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

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

typedef struct {
	int *numbers;
	int count;
	int length;
} STACK;

void stack_init(STACK *stack);
void stack_push(STACK *stack, int number);
int stack_pop(STACK *stack);
void stack_finalize(STACK *stack);

int main()
{
	int i;
	int number;
	STACK stack;

	stack_init(&stack);
	while (scanf("%d", &number) != -1) {
		if (number == 0) {
			printf("%d\n", stack_pop(&stack));
		} else {
			stack_push(&stack, number);
		}
	}

	return 0;
}

void stack_init(STACK *stack)
{
	stack->length = 16;
	stack->numbers = calloc(stack->length, sizeof(int));
	stack->count = 0;
}

void stack_finalize(STACK *stack)
{
	free(stack->numbers);
	memset(stack, 0, sizeof(stack));
}

void stack_push(STACK *stack, int number)
{
	if (stack->length == stack->count) {
		stack->length *= 2;
		stack->numbers = realloc(stack->numbers, stack->length * sizeof(int));
	}
	stack->numbers[stack->count++] = number;
}

int stack_pop(STACK *stack)
{
	return stack->numbers[--(stack->count)];
}

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

ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

ll ans[100];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    ll ans = 1;
    reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end());

    for(int i = 0; i < n; i++){
        if(s1[i] == s2[i]){
           if(i > 0){
           if(s1[i-1] == s2[i-1]) ans = (ans*1LL*2)%mod;
           }
           else ans = 3;
        }
        else{
            if(i == 0){
               ans = 6;
            }
            else{
            if(s1[i-1] == s2[i-1])
            ans = (ans*1LL*2)%mod;
            else ans = (ans*1LL*3)%mod;
            }
            i++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<cstdio>
#define popcnt __builtin_popcount
typedef long long LoveLive;
const int N=15,M=32768,md=1e9+7;
int f[M],n,m,e[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u-1]|=1<<(v-1);
	}
	const int C=1<<n;
	f[0]=1;
	for(int S=3;S<C;++S)if((S&1)==(S>>1&1))
	for(int U=S;U;U=(U-1)&S)if((U&1)==(U>>1&1)){//sg=0
		int T=S^U;
		int T_U=1,U_T=1;
		for(int i=0;i<n;++i){
			if(U>>i&1)U_T=U_T*(1LL<<popcnt(e[i]&T))%md;else
			if(T>>i&1)T_U=T_U*((1LL<<popcnt(e[i]&U))-1)%md;
		}
		f[S]=(f[S]+(LoveLive)U_T*T_U%md*f[T])%md;
	}
	int ans=1;
	for(int i=1;i<=m;++i)ans=ans*2%md;
	ans=(ans-f[C-1]+md)%md;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import collections
n,*a=map(int,open(0).read().split())
l=[i+1+a[i] for i in range(n)]
r=[i+1-a[i] for i in range(n)]
L=collections.Counter(l)
R=collections.Counter(r)
print(sum(L[i]*R[i] for i in L.keys()))

Measured memory_bytes: 63320
import sys

X, N = map(int, input().split())

if N != 0:
    p = list(map(int, input().split()))
else:
    print(X)
    sys.exit()

for i in range(150):
    if (X - i) not in p:
        print(X - i)
        sys.exit()
    elif (X + i) not in p:
        print(X + i)
        sys.exit()


Measured memory_bytes: 61848
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 1000; i++) {
		string T;
		if (i >= 100) T = to_string(i);
		else {
			if (i < 10) {
				T.push_back('0');
				T.push_back('0');
				T.push_back(i + '0');
			}
			else {
				int tmp = i;
				T.push_back('0');
			    int ch = tmp % 10;
				tmp /= 10;
				T.push_back(tmp + '0');
				T.push_back(ch + '0');
			}
		}
		int k = 0;
		for (int j = 0; j < N; j++) {
			if (k < 3) {
				if (S.at(j) == T.at(k)) k++;
			}
		}
		if (k == 3) ans++;
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  int sum = 1;
  for(int i = 0; i < N - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      continue;
    }
    if (S.at(i) != S.at(i + 1)) {
      sum += 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int l,r;
    R(l,r);
    int v=(r-l)%2019;
    if(l+v+2019<=r)r=l+v+2019;
    LL an=1e9;
    FOR(i,l,r)FOR(j,i+1,r){
        an=min(an,(LL)i*j%2019);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256