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

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

int main(void){

	int n;

	while (cin >> n , n){

		vector<int> x, y;
		x.push_back(0);
		y.push_back(0);
		for (int i = 0; i < n - 1; i++){
			int num, way; cin >> num >> way;
			x.push_back(x[num] + dx[way]);
			y.push_back(y[num] + dy[way]);
		}

		int x_max = 0, x_min = 0, y_max = 0, y_min = 0;
		for (int i = 0; i < n; i++){
			x_max = max(x_max, x[i]);
			x_min = min(x_min, x[i]);
			y_max = max(y_max, y[i]);
			y_min = min(y_min, y[i]);
		}

		cout << x_max - x_min + 1 << " " << y_max - y_min + 1 << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const LL MOD = 1e9+7;
const LL INF = (1e18);
const double EPS=1.0e-9;
const double PI=atan2(0,-1);



int main()
{
    int n;
    cin>>n;
    vector<LL> a(n);
    REP(i,n)
        cin>>a[i];
        
    LL minp=1;
    LL cnt=0;
    cnt+=(a[0]-1);
    minp++;
    FOR(i,1,n)
    {
        cnt+=(a[i]-1)/minp;
        if(a[i]==minp)
            minp++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
from fractions import gcd

def main():
    n = input()
    aa = list(map(int, raw_input().split()))
    g = 1
    for a in aa:
        g *= a // gcd(a, g)
    ans = 0
    MOD = 10 ** 9 + 7
    g %= MOD
    for a in aa:
        ans = (ans + g * pow(a, MOD - 2, MOD)) % MOD
    print(ans)


main()


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 210000;
const i64 P = 1000000000 + 7;
i64 dp[2][2][maxn];

void add(i64 &x, i64 y) {
    x += y;
    x %= P;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, l;
    string s;
    cin >> n >> l >> s;
    char c0 = s[0], c1 = c0 ^ 'R' ^ 'B';
    if (s == string(l, c0)) {
        forn(i, 2) dp[i][i][1] = 1;
        for1(i, n - 1) forn(f, 2) forn(j, 2) forn(k, 2) {
            if (j && k) continue;
            add(dp[f][k][i + 1], dp[f][j][i]);
        }
        i64 ans = 0;
        forn(f, 2) forn(j, 2) {
            if (f && j) continue;
            add(ans, dp[f][j][n]);
        }
        cout << ans << '\n';
        return 0;
    }

    if (n % 2) {
        cout << 0 << '\n';
        return 0;
    }

    vector<pair<int, char> > cl;
    pii p = {1, c0};
    for1(i, l - 1) {
        if (s[i] == p.se) ++p.fi;
        else cl.pb(p), p = {1, s[i]};
    }

//    for (auto w: cl) cerr << w.fi << ' ' << w.se << '\n';

    int ub = n;
    if (cl[0].fi % 2 == 0) ub = cl[0].fi + 1;
    for (auto w: cl) if (w.se == c0 && w.fi % 2) uin(ub, w.fi);
    ub /= 2;

    vi64 vals(n / 2 + 1), svals(n / 2 + 2);
    vals[0] = 1;
    svals[1] = 1;
    cerr << ub << '\n';
    for1(i, n / 2) {
        vals[i] = svals[i] - svals[max(i - ub - 1, 0)];
        vals[i] %= P;
//        cerr << i << ' ' << vals[i] << '\n';
        svals[i + 1] = (svals[i] + vals[i]) % P;
    }

    i64 ans = vals[n / 2];
    for1(i, ub) if (i + 1 <= n / 2) add(ans, vals[n / 2 - i - 1] * i);
    ans *= 2;
    ans %= P;
    if (ans < 0) ans += P;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 6992
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

#[allow(dead_code)]
fn main() {
    let x = read::<usize>();
    let y = read::<usize>();
    let z = read::<usize>();
    let k = read::<usize>();
    use std::collections::BinaryHeap;
    let mut ans = BinaryHeap::new();

    let mut a = (0..x).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut b = (0..y).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut c = (0..z).map(|_| read::<usize>()).collect::<Vec<_>>();
    a.sort();
    b.sort();
    c.sort();
    a.reverse();
    b.reverse();
    c.reverse();

    for xi in 0..x {
        for yi in 0..y {
            for zi in 0..y {
                if (xi + 1) * (yi + 1) * (zi + 1) <= k {
                    ans.push(a[xi] + b[yi] + c[zi])
                } else {
                    break;
                }
            }
        }
    }
    for _ in 0..k {
        println!("{}", ans.pop().unwrap())
    }
}


Measured memory_bytes: 4352
from operator import attrgetter


class City:
    def __init__(self, p, y):
        self.p = p
        self.y = y

    def set_num(self, n):
        self.n = '{0:06d}'.format(self.p) + '{0:06d}'.format(n)


N, M = map(int, input().split())
cities = []
for _ in range(M):
    p, y = map(int, input().split())
    cities.append(City(p, y))

pref_map = {}
for city in cities:
    if city.p in pref_map:
        pref_map[city.p].append(city)
    else:
        pref_map[city.p] = [city]

for v in pref_map.values():
    _cities = sorted(v, key=attrgetter("y"))
    cnt = 1
    for _city in _cities:
        _city.set_num(cnt)
        cnt += 1

for city in cities:
    print(city.n)


Measured memory_bytes: 50044
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<pair<Int, Int>> a(n), b(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    for (Int i = 0; i < n; i++) {
        cin >> b[i].fi >> b[i].se;
    }
    sort(all(a));
    sort(all(b));
    vector<bool> b_used(n, false);
    Int cnt = 0;
    for (Int i = n - 1; i >= 0; i--) {
        Int mi = INF;
        Int index = -1;
        for (Int j = 0; j < n; j++) {
            if (b[j].fi < a[i].fi) continue;
            if ((not b_used[j]) and b[j].se > a[i].se and mi > b[j].se) {
                mi = b[j].se;
                index = j;
            }
        }
        if (mi != INF) {
            //dump(i);
            b_used[index] = true;
            cnt++;
        }
    }
    dump(cnt);
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000;

ll x;
int A[N],res[N];
int c,l1,r1,l2,r2;
Vi V;

void Plus1(){
	c++;
	res[--l1]=c;
	res[++r2]=c;
}
void Mul2(){
	c++;
	res[++r1]=c;
	res[++r2]=c;
}

int main(){
	l1=500,r1=l1-1;
	l2=1000,r2=l2-1;
	cin>>x;
	for (++x;x;x>>=1) A[++*A]=x&1;
	for (int i=*A-1;i;i--){
		Mul2();
		if (A[i]) Plus1();
	}
	For(i,l1,r1+1) V.pb(res[i]);
	For(i,l2,r2+1) V.pb(res[i]);
	assert(V.size()<=200);
	assert(c<=100);
	printf("%d\n",V.size());
	For(i,0,V.size()) printf("%d ",V[i]);puts("");
}

Measured memory_bytes: 256
(* O(n log n) *)
Scanf.scanf "%d %d" @@ fun n x ->
  let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (-) a_s;
  let rest = ref x in
  let f i a =
    if a > !rest then (Printf.printf "%d\n" i; exit 0)
    else rest := !rest - a in
  Array.iteri f a_s;
  Printf.printf "%d\n" @@ if !rest = 0 then n else n - 1

Measured memory_bytes: 384
class Card
  attr_accessor :suit, :num
  def initialize(s)
    @suit = s[0]
    @num = s[1].to_i
  end
  def val
    return @suit + " " + @num.to_s
  end
end

def partition(a,p,r)
  x = a[r]
  i = p
  (p..r-1).each do |j|
    if a[j].num <= x.num
      a[i],a[j] = a[j],a[i]
      i = i+1
    end
  end
  a[i],a[r] = a[r],a[i]
  return i
end

def quickSort(a,p,r)
  if p < r
    q = partition(a,p,r)
    quickSort(a,p,q-1)
    quickSort(a,q+1,r)
  end
end

def isStable(a,b,n)
  for ai in 0..n-2 do
    for bi in 1..n-1 do
      if a[ai]!=b[bi]
        next
      end
      for aj in ai+1..n-1 do
        if a[ai].num!=a[aj].num
          next
        end
        for bj in 0..bi-1 do
          if a[aj]==b[bj]
            return "Not stable"
          end
        end
      end
    end
  end
  return "Stable"
end 

n = gets.to_i
a = []
(0...n).each do |i|
  a[i] = Card.new(gets.split)
end

b = a.clone
quickSort(b,0,n-1)
printf("%s\n%s\n",isStable(a,b,n),b.map(&:val).join("\n"))


Measured memory_bytes: 27704
#include <stdio.h>
int main(void){
    // Your code here!
    
    int n,q;
    scanf("%d %d",&n,&q);
    char c[100000];
    scanf("%s",c);
    
    int h[100000]={};
    for(int i=0;i<n-1;i++){
        if(c[i]=='A'&&c[i+1]=='C'){
            h[i]=h[i-1]+1;
        }else{
            h[i]=h[i-1];
        }
        //printf("h[%d]=%d, ",i,h[i]);
    }
    
    int l,r;
    for(int i=0;i<q;i++){
        scanf("%d %d",&l,&r);
        
        if(l==1){
            printf("%d\n",h[r-2]);
        }else{
            printf("%d\n",h[r-2]-h[l-2]);
        }
        
        
        
    }
    
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define mod 1000000007
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define adb2(a) for(auto i:a) cout << i.first << " " << i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define N 100010
using namespace std;

int main()
{
    fastIO;
    long long n, k;
    cin >> n >> k;

    set<long long> cnt;
    long long dk, dki;
    for(int i=0; i<k; i++)
    {
        cin >> dk;
        for(int j=0; j<dk; j++)
        {
            cin >> dki;
            cnt.insert(dki);
        }
    }

    cout << n - cnt.size() << endl;
}

Measured memory_bytes: 3672
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);


int n;
char s, t, b;
pair<int, int> S, T, B;
double dp[16][3][3];

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

int main() {
	while (cin >> n&&n) {
		cin >> s >> t >> b;
		S = make_pair((s - 'A') / 3, (s - 'A') % 3);
		T = make_pair((t - 'A') / 3, (t - 'A') % 3);
		B = make_pair((b - 'A') / 3, (b - 'A') % 3);
		for (int i = 0; i < 16; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][S.first][S.second] = 1;
		for (int i = 0; i < n; i++) {
			for (int y = 0; y < 3; y++) {
				for (int x = 0; x < 3; x++) {
					if (dp[i][y][x] == 0)continue;
					for (int d = 0; d < 4; d++) {
						int ny = y + dy[d], nx = x + dx[d];
						if (0 <= nx&&nx < 3 && 0 <= ny&&ny < 3 && make_pair(ny, nx) != B)dp[i + 1][ny][nx] += dp[i][y][x] * 0.25;
						else dp[i + 1][y][x] += dp[i][y][x] * 0.25;
					}
				}
			}
		}
		cout << fixed << setprecision(10) << dp[n][T.first][T.second] << endl;
	}
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 100010
#define mod 1000000007
int f[maxn];
int pe[maxn];
struct cv{
    int x,y;
}a[100010];
bool cmp(cv p,cv q){
    if(p.x!=q.x) return p.x<q.x;
    return p.y<q.y;
}
int fi(int x){
    if(f[x]==x) return x;
    f[x]=fi(f[x]);
    return f[x];
}
int c[maxn][3];
int main(){
    ll n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    int ff=1,x,y;
    for(int i=0;i<n;i++) f[i]=i;
    for(int i=0;i<q;i++){
        scanf("%d%d%d",&c[i][0],&c[i][1],&c[i][2]);
        if(c[i][2]==0){
            x=fi(c[i][0]);
            y=fi(c[i][1]);
            if(x!=y){
                f[x]=y;
            }
        }
    }
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(f[i]==i) cnt++;
        pe[i]=1;
    }
    if(n-1+(cnt-1)*cnt/2-(cnt-1)<m){
        ff=0;
    }
    ll sum=0;
    for(int i=0;i<q&&ff;i++){
        if(c[i][2]==1){
            if(cnt==2){
                ff=0;
                break;
            }
            x=fi(c[i][0]);
            y=fi(c[i][1]);
            if(x==y){
                ff=0;
                break;
            }
            a[sum].x=min(x,y);
            a[sum].y=max(x,y);
            sum++;
        }
    }
    // sort(a,a+sum,cmp);
    // int su=1;
    // for(int i=1;i<sum;i++){
    //     if(a[i].x==a[i-1].x&&a[i].y==a[i].y){
    //         ;
    //     }
    //     else{
    //         a[su++]=a[i];
    //     }
    // }
    // if(sum==0) su=0;
    // sum=su;
    ll z=0;
    if(sum) z=1;
    // for(int i=0;i<sum;i++){
    //     x=fi(a[i].x),y=fi(a[i].y);
    //     if(x!=y){
    //         pe[x]+=pe[y];
    //         f[y]=x;
    //     }
    // }
    // for(int i=0;i<n;i++){
    //     if(f[i]==i){
    //         z+=(pe[i])/2;
    //     }
    // }
    if(n-1+z>m){
        ff=0;
    }
    if(ff) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

signed main(){


  int n;
  cin >> n;

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

  sort(a, a+n);


  cout << a[n-1] - a[0] << endl;


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

Measured memory_bytes: 3608
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x, k, d = nm()
    x = abs(x)
    if x - (k * d) >= 0:
        print(x - (k * d))
    else:
        k -= x // d
        if k % 2 == 0:
            print(x % d)
        else:
            print(d - x % d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN, MM;

  std::cin >> NN>>MM;

  ll L[MM], R[MM];
  for (size_t i = 0; i < MM; i++) {
    std::cin >> L[i]>>R[i];
  }

  ll max_L = 0, min_R = 1000000;

  for (size_t i = 0; i < MM; i++) {
    if (max_L < L[i]) {
      max_L = L[i];
    }
    if (min_R > R[i]) {
      min_R = R[i];
    }
  }

  ll ans = min_R - max_L + 1;
  if (ans < 0) {
    ans = 0;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#![allow(dead_code)]
macro_rules! debug {
    ($($arg:tt)*) => (if cfg!(debug_assertions) {print!("[DEBUG] "); println!($($arg)*)});
}

fn f(b: i64, n: i64) -> i64 {
    return if n < b {
        n
    } else {
        f(b, n / b) + n % b
    };
}

const MOD: i64 = (1e9 + 7.) as i64;

fn calc(a: Vec<i64>) -> i64 {
    let n = a.len() - 1;
    let mut x = vec![0i64; n];
    for i in 0..n {
        x[i] = a[i + 1] - a[i];
        debug!("x[{}]={}", i, x[i]);
    }

    let mut xs = vec![0i64; n + 1];
    let mut xss = vec![0i64; n + 1];
    let mut xsum: i64 = 0;
    for i in 0..n {
        xs[i + 1] = xs[i] + x[i];
        xss[i + 1] = (xss[i] + xs[i + 1]) % MOD;
        debug!("xs[{}]={}, xss[{}]={}", i + 1, xs[i + 1], i + 1, xss[i + 1]);
    }
    for i in 0..n {
        xsum += (xss[n] - xss[i] + MOD) - xs[i] * (n - i) as i64 % MOD;
        xsum = (xsum + MOD) % MOD;
        debug!("i={}, xsum={}", i, xsum);
    }
    xsum
}

fn main() {
    let mut rd = reader::Reader::new();

    let n: usize = rd.next();
    let m: usize = rd.next();

    let x: Vec<i64> = rd.next_n(n);
    let y: Vec<i64> = rd.next_n(m);

    println!("{}", calc(x) * calc(y) % MOD);
}

mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    pub struct Reader {
        buf: VecDeque<String>,
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}


Measured memory_bytes: 18368
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = 6 - a - b;
	cout << ans;*/


	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans;
	rep(i, n) {
		ans += s[i];
		ans += t[i];
		
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,cnt,D1,D2;
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>D1>>D2;
        cnt=(D1==D2?cnt+1:0);
        if(cnt==3){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}

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

const long long M = 1000000007;

bitset<30> b;

long long my_pow(long long x, long long y) {
    b = y;
    long long p = x;
    long long ans = 1;
    for (int i = 0; i < b.size(); i++) {
        if (b.test(i)) {
            ans = (ans * p) % M;
        }
        p = (p * p) % M;
    }
    return ans;
}

int main() {
    long long n;
    cin >> n;
    long long ans = my_pow(10, n) - 2 * my_pow(9, n) + my_pow(8, n);
    while (ans < 0) {
        ans += M;
    }
    cout << ans % M << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	//a：時針のながさ
	//b；分針の長さ
	//h時m分
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	//theta=|m/60-h/12|*360
	double a_angle = h / 12.0 * 360 + m / 60.0 *30; 
	double b_angle = m / 60.0 * 360;
	// cout << "a_angle: " << a_angle << endl;
	// cout << "b_angle: " << b_angle << endl;
	double diff_1 = abs(b_angle - a_angle);
	double diff_2 = 360 - diff_1;
	double diff = min(diff_1, diff_2);
	// cout << "diff: " << diff <<endl;
	double angle = (double)diff/180.0*M_PI;
	// cout << "cos(angle): " << cos(angle) <<endl;
	double d = 2 * a * b * cos(diff/180.0*M_PI);
	// cout << "d: " << d <<endl;
	double pre_ans = pow(a,2) + pow(b,2) - d;
	// cout << "pre_ans: " << pre_ans <<endl;
	double ans = sqrt(pre_ans);
	cout << setprecision(20) << ans << endl;
    return 0;
}


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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
#define hash(n) unordered_map<int,int>mp(n)

 
int main() 
{ 
	JJ;
    long n; cin>>n;
    string name;
    char key[26];
    // key[0]='\0';
    char ch='a';
    FOR(i,0,26){
    	key[i]=ch;
    	ch++;
    }
    while(n>0){
    	n-=1;
    	name=key[n%26]+name;
    	n/=26;
    }
    cout<<name<<endl;
    
} 

Measured memory_bytes: 3580
#include<stdio.h>
int main(){
int A[4][4]={};
int B[101]={};
int i=0,j=0,N=0,num=0,BOOL=0;
for(i=1;i<=3;i++){
  for(j=1;j<=3;j++){
scanf("%d",&A[i][j]);    
  }
}
scanf("%d",&N);
   for(i=1;i<=N;i++){
scanf("%d",&B[i]);    
  }
 for(num=1;num<=N;num++) 
 {for(i=1;i<=3;i++)
  {for(j=1;j<=3;j++)
   {
    if(A[i][j]==B[num]){A[i][j]=0;}
   }
  }
 }
 
  if(A[1][1]==0&&A[2][1]==0&&A[3][1]==0){BOOL=1;}
  if(A[1][2]==0&&A[2][2]==0&&A[3][2]==0){BOOL=1;}
  if(A[1][3]==0&&A[2][3]==0&&A[3][3]==0){BOOL=1;}
  if(A[1][1]==0&&A[1][2]==0&&A[1][3]==0){BOOL=1;}
  if(A[2][1]==0&&A[2][2]==0&&A[2][3]==0){BOOL=1;}
  if(A[3][1]==0&&A[3][2]==0&&A[3][3]==0){BOOL=1;}
  if(A[1][1]==0&&A[2][2]==0&&A[3][3]==0){BOOL=1;}
  if(A[1][3]==0&&A[2][2]==0&&A[3][1]==0){BOOL=1;}
  if(BOOL==1){printf("Yes");}
  else printf("No");
return 0;
}

Measured memory_bytes: 2156
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> S(n);
    REP(i, n) cin >> S[i];
    sort(S.begin(), S.end());
    REP(i, n){
        cout << S[i];
        if(i == n - 1) cout << endl;
    }


    return 0;
}

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

const double PI = 3.141592;

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  double nRad = 60 * PI / 180; 
  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos(nRad) 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin(nRad);
  rvoRtnPnt[2].m_nx += rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin(nRad)
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos(nRad);
  rvoRtnPnt[2].m_ny += rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

Measured memory_bytes: 1392
using System;

class alds13a
{
    static void Main()
    {
        System.Collections.Generic.Stack<int> stk=new System.Collections.Generic.Stack<int>(); 
        String[] input = Console.ReadLine().Split(' ');
        foreach (string data in input)
        {
            if (data == "+")
            {
                stk.Push(stk.Pop() + stk.Pop());
            }
            else if (data == "-")
            {
                stk.Push(-stk.Pop() + stk.Pop());
            }
            else if (data == "*")
            {
                stk.Push(stk.Pop() * stk.Pop());
            }else
            {
                stk.Push(int.Parse(data));
            }
        }
        Console.WriteLine(stk.Pop());
    }
}

Measured memory_bytes: 20228
N,M,Q=map(int,input().split())
from itertools import combinations_with_replacement
a=[i for i in range(1,M+1)]
A=list(combinations_with_replacement(a,N))
#print(A)
ans=[]
for i in range(Q):
    W,X,Y,Z=map(int,input().split())
    #print(X,W)
    for j in A:
        if j[X-1]-j[W-1]==Y:
            ans.append(Z)
        else:
            ans.append(0)
#print(ans)
C=len(A)
Ans=[]

for i in range(C):
    tmp=0
    F=ans[i::C]
    tmp=sum(F)
    Ans.append(tmp)
#print(Ans)
print(max(Ans))


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

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

    ll x=0,y=0,z;

    for(ll i = 0;i < n-1;i ++){
        if(a.at(i) == a.at(i+1)){
            x = a.at(i);
            z = i + 2;
            break;
        }
    }

    for(ll i = z;i < n-1;i ++){
        if(a.at(i) == a.at(i+1)){
            y = a.at(i);
            break;
        }
    }

    cout << x * y << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define magic ios_base::sync_with_stdio(false);cin.tie(nullptr)
using namespace std;
#define forn(i,n) for(int i=1;i<=n;i++)
#define forRn(i,n) for(int i=n;i>=1;i--)
#define forz(i,n) for(int i=0;i<n;i++)
#define forRz(i,n) for(int i=n-1;i>=0;i--)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define mod 1000000007
#define INF 1023456789
#define pii pair<int,int>

int arr[100005];
int main(void){
    magic;
    int N,R;
    cin>>N>>R;
    if(N>=10) cout<<R;
    else{
        cout<<(R+(100*(10-N)));
    }
}


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

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

using namespace std;

const int INF=1<<29;

int n;
vector<int> T[100000];
int num[100000];
int parity[100000],l[100000],r[100000];

bool dfs1(int u,int p){
	if(num[u]!=-1){
		if(parity[u]!=num[u]%2) return false;
		l[u]=num[u];
		r[u]=num[u]+1;
	}
	else{
		l[u]=-INF;
		r[u]=INF;
	}

	for(int v:T[u]) if(v!=p) {
		parity[v]=(parity[u]+1)%2;
		if(!dfs1(v,u)) return false;
		l[u]=max(l[u],l[v]-1);
		r[u]=min(r[u],r[v]+1);
	}
	if(l[u]>=r[u]) return false;

	return true;
}

void dfs2(int u,int p){
	if(num[u]==-1){
		if(l[u]<=num[p]-1 && num[p]-1<r[u]) num[u]=num[p]-1;
		else                                num[u]=num[p]+1;
	}

	for(int v:T[u]) if(v!=p) dfs2(v,u);
}

int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}
	int k; scanf("%d",&k);
	rep(u,n) num[u]=-1;
	rep(i,k){
		int u; scanf("%d",&u); u--;
		scanf("%d",num+u);
	}

	int root;
	rep(u,n) if(num[u]!=-1) root=u;
	parity[root]=num[root]%2;

	if(!dfs1(root,-1)){ puts("No"); return 0; }

	dfs2(root,-1);

	puts("Yes");
	rep(u,n) printf("%d\n",num[u]);

	return 0;
}


Measured memory_bytes: 14336
k = gets.to_i

n = 0

(1 .. k).each do |i1|
  (1 .. k).each do |i2|
    gn = i1.gcd(i2)
    (1 .. k).each do |i3|
      n += gn.gcd(i3)
    end
  end
end

puts n

Measured memory_bytes: 14372
from operator import itemgetter
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
l2=sorted(l,key=itemgetter(1))
cnt=0
for i in range(n):
  cnt+=l2[i][0]
  if cnt>l2[i][1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 55156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    bool all9 = true;
    for (ll i = 1; i <= ll(1e18); i *= 10) {
        if (N / 10 == 0) {
            cout << ans + (all9 ? N : N - 1) << endl;
            return 0;
        }

        ans += 9;
        all9 &= N % 10 == 9;
        N /= 10;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,m;
ll s=0;
priority_queue<int> pq;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>m;
	for (int i=0,t;i<n;i++){
		cin>>t;
		pq.push(t);
	}
	for (;m;m--){
		int t=pq.top();
		pq.pop();
		if (t==0)
			break;
		else {
			t>>=1;
			pq.push(t);
		}
	}
	for (;!pq.empty();s+=pq.top(),pq.pop());
	cout<<s;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}
 
ll binpow(ll a, ll b) {ll res = 1;while (b > 0) {if (b & 1) res = res * a;a = a * a;b >>= 1;}return res;}

int main(){
	adiii
	ll n;cin>>n;
	vector <ll> h(n+1,0);
	vector <ll> dp(n+1,0);
	rep(i,1,n+1) cin>>h[i];
	if(n>=2) dp[2] = abs(h[1] - h[2]);
	rep(i,3,n+1){
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]),dp[i-1] + abs(h[i] - h[i-1]));
	}
	
	cout<<dp[n]<<endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
   
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  long long n,a,b;
  cin>>n>>a>>b;

  if(a>b){
    swap(a,b);
  }

  if((a%2==0 && b%2==0) || (a%2==1 && b%2==1)){
    cout<<(a+b)/2-a<<'\n';
  }
  else if(b-a==1){
    cout<<min(n-a,b-1)<<'\n';
  }
  else{
    long long sum;
    if(n-a<=b-1){
      sum=n-b+1;
      a+=sum;
      b=n;
      cout<<sum+b-(a+b)/2<<'\n';
    }
    else{
      sum=a;
      b-=sum;
      a=1;
      cout<<sum+(a+b)/2-a<<'\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n-r+1;
	int sum = 1;
	for(int i =s;i<=n;i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int K, N;
	cin >> K >> N;
	cout << K - N + 1;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t ans = 0;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        ans += t-1;
    }


    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
<?php

define('EPS', 1e-8);
while (true) {
    $a = fscanf(STDIN, '%f %f %f %f %f %f %f %f');
    if (feof(STDIN)) {
        break;
    }
    $line = array();
    $line[] = $a[1] - $a[3] === 0.0 ? INF : ($a[0] - $a[2]) / ($a[1] - $a[3]);
    $line[] = $a[5] - $a[7] === 0.0 ? INF : ($a[4] - $a[6]) / ($a[5] - $a[7]);
    if (max($line) === INF && min($line) === 0 || abs($line[0] * $line[1] + 1.0) < EPS) {
        echo 'YES';
    } else {
        echo 'NO';
    }
    echo PHP_EOL;
}

Measured memory_bytes: 6652
#include <cstdio>
#include <cfloat>
#include <cmath>
#include <iostream>

int main()
{
    double a, b, c, d, e, f;
    while (std::cin >> a >> b >> c >> d >> e >> f) {
        double x = (c * e - b * f) / (a * e - b * d);
        double y = (c * d - a * f) / (b * d - a * e);
        if (fabs(x) < DBL_EPSILON) {
            x = 0.0;
        }
        if (fabs(y) < DBL_EPSILON) {
            y = 0.0;
        }
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#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++)
#define ll long long

int main() {
	int a,b,c,k;

	cin >> a >> b >> c >> k;

	int cnt = 0;
	while (b <= a) {
		b *= 2;
		++cnt;
	}
	while (c <= b) {
		c *= 2;
		++cnt;
	}
	string ans = "No";
	if (k >= cnt)
		ans = "Yes";

	//答え
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s;
    cin>>s;
    int cnt=0,sh;
    for(int i=0;i<SZ(s);i++)
    {
        int x=s[i]-'0';
        cnt+=x;
    }
    stringstream ss;
    ss<<s;
    ss>>sh;
    if(sh%cnt==0)
    {
        cout<<"Yes"<<NL;
    }
    else
    {
        cout<<"No"<<NL;
    }
    return 0;
}



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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

typedef double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};
D dot(P a,P b){ return (conj(a)*b).X; }
D cross(P a,P b){ return (conj(a)*b).Y; }
P crosspoint(L l,L m) {
  D A=cross(l[1]-l[0],m[1]-m[0]);
  D B=cross(l[1]-l[0],l[1]-m[0]);
  if (abs(A)<eps&&abs(B)<eps) return m[0]; // same line
  if (abs(A)<eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0]+B/A*(m[1]-m[0]);
}
int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}
vector<P> convex_cut(const vector<P>& poly,L l) {
  vector<P> Q;
  int sz=poly.size();
  for (int i = 0; i < sz; i++) {
    P A = poly[i], B = poly[(i+1)%sz];
    if(ccw(l[0], l[1], A) != -1)Q.push_back(A);
    if(ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0){
      Q.push_back(crosspoint(L(A, B), l));
    }
  }
  return Q;
}
L half_line(P a,P b){
  P m=(a+b)*(D)0.5;
  P dir=b-a;
  return L(m,m+P(-dir.Y,dir.X));
}
D calc_area(vector<P>& poly) {
  D res = 0;
  int sz=poly.size();
  for (int i = 0; i < sz; i++){
    res += cross(poly[i], poly[(i+1)%sz]);
  }
  return res/2.0;
}

int M,N;
vector<P> poly,ps;

int main(){
  cin>>M>>N;
  rep(i,M){
    int x,y;
    cin>>x>>y;
    poly.push_back(P(x,y));
  }
  rep(i,N){
    int x,y;
    cin>>x>>y;
    ps.push_back(P(x,y));
  }
  D res=0.0;
  rep(i,N){
    vector<P> crtpoly=poly;
    rep(j,N){
      if(i==j)continue;
      L h=half_line(ps[i],ps[j]);
      if(ccw(h[0],h[1],ps[i])==-1)swap(h[0],h[1]);
      crtpoly=convex_cut(crtpoly,h);
    }
    assert(crtpoly.size()>2);
    D totarea=calc_area(poly);
    rep(j,crtpoly.size()){
      P p0=crtpoly[j]-ps[i],p1=crtpoly[(j+1)%crtpoly.size()]-ps[i];
      vector<P> tri;
      tri.push_back(P(0,0)); tri.push_back(p0); tri.push_back(p1);
      D area=calc_area(tri);
      D p=p1.X-p0.X,q=p1.Y-p0.Y;
      D a=p*p+q*q, b=2*(p*p0.X+q*p0.Y), c=p0.X*p0.X+p0.Y*p0.Y;
      res+=((2*a+3*b+6*c)/12.0)*(area/totarea);
    }
  }
  printf("%.10f\n", res);

  return 0;
}



Measured memory_bytes: 3240
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N, K;
ll ans = 0;

int main() {
    cin >> N >> K;
    for (ll k = K - 1; k <= N; k++) {
        ans += -k * k + (N - 1) * k + N + 1;
        ans %= ll(1e9) + 7;
    }
    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	int n, m; cin >> n >> m;

	vector<vector<int>>g(n);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;

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

	/*
	rep(i, n) {
		rep(j, g[i].size()) {
			cout << g[i][j] << endl;
		}
		cout << endl;
	}
	*/

	rep(i, n) {
		bool stt = false;
		bool goal = false;
		rep(j, g[i].size()) {
			if (g[i][j] == 0)stt = true;
			if (g[i][j] == n - 1)goal = true;
			}
		if (stt && goal) {
			cout << "POSSIBLE" << endl;
			return 0;
			}
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 12016
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n = in.nextInt();
        int a=in.nextInt();
        int b=in.nextInt();
        System.out.println(Math.min(a*n,b));


    }
}


class Fast {
    BufferedReader br;
    StringTokenizer st;

    public Fast() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 20564
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int a[n];
    for(int i = 0; n > i; i++){
        cin>>a[i];
        cout << a[i];
        if(i+1!=n)cout << " ";
    }
    cout << endl;
    for(int i = 1; n > i; i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
          a[j+1]=a[j];
          j--;
        }
        a[j+1]=v;
        for(int j = 0; n > j; j++){
          cout << a[j];
          if(j+1!=n)cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;


int main(void) {
    int k,s;
    cin >> k >> s;

    int ans = 0;
    int zdiff = 0;

    for(int xi = 0; xi <= k; ++xi) {
        for(int yi = 0; yi <= k; ++yi) {
            // for(int zi = 0; zi <= k; ++zi) {
                zdiff = s - (xi + yi);

                if(0<= zdiff && zdiff <= k) {
                    ans++;
                // }
                }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}

ll inverse(ll n)
{
	return exp(n,MOD-2);
}

int LIM=2e5+100;
void solve()
{
//Read Comments below main
	ll m,n;
	cin>>n>>m;
	ll sum=0;
	vp64 arr(n+1);
	for (int i=1; i<=n; i++)
	{
		cin>>arr[i].fi;
		arr[i].se=i;
		sum+=arr[i].fi;
	}
	sort(arr.begin()+1,arr.end(),greater<p64>());
	// cout
	// cout<<arr[2].fi<<endl;
	if (arr[m].fi*4*m<sum)
	{
		cout<<"No"<<endl;
	}
	else
		cout<<"Yes"<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algo

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K;
    cin >> N >> K;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = K; i < N; i++) {
        if (A[i] <= A[i - K]) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5168
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(S, T):
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    S = input()
    T = input()
    # N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(S, T)



Measured memory_bytes: 9416