akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;

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;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

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

    Unionfind tree(n);

    vector<vector<int>> bk(n);
    vector<int> fd(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++fd[a];
        ++fd[b];
        tree.unite(a, b);
    }

    rep(i, k) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        bk[c].emplace_back(d);
        bk[d].emplace_back(c);
    }

    rep(i, n) {
        int ans = tree.size(i) - 1 - fd[i];
        for(int x : bk[i]) {
            if(tree.same(i, x)) --ans;
        }
        printf("%d ", ans);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 10816
/**
*    created: 13.05.2020 19:43:01
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    rep(i,m) {
        int a, b; cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    if (r - l + 1 < 0) cout << 0 << endl;
    else cout << r - l + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
re = []
for i in range(N):
    re.append(list(input().split()) + [i+1])
for i in range(N):
    re[i][1] = int(re[i][1])
re = sorted(re, key = lambda x: x[1], reverse = True)
re = sorted(re, key = lambda x: x[0])

for i in range(N):
    print(re[i][2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;
typedef unsigned long long ull;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c;
  cin >> a >> b >> c;
  bool ans = false;
  ull s, t;
  s = (c-a-b)*(c-a-b);
  t = 4*a*b;
  if((c-a-b)>0){
    if(t<s){
      ans = true;
    }
  }
  puts(ans?"Yes": "No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long x = scan.nextLong();
		if (a == 0) {
			System.out.println(b / x + 1);
			return;
		} else if (a == 1) {
			System.out.println(b / x);
			return;
		}
		long bm = b / x;
		long am = (a - 1) / x;
		System.out.println(bm - am);

	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int A,B;
char t[100];

void solve(int a,int b){
  if(a>A||b>B)return;
  if(a==A&&b==B){
    t[a+b]='\0';
    printf("%s\n",t);
    return;
  }
  if(a==5&&b<=3)return;
  if(b==5&&a<=3)return;
  if(a==6&&b==4)return;
  if(b==6&&a==4)return;

  t[a+b]='A';
  solve(a+1,b);
  t[a+b]='B';
  solve(a,b+1);
}

int main(){
  cin>>A>>B;
  solve(0,0);
  return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)

using namespace std;

struct hpq{
	int h, p, q;
};

int main(void){
	while(1){
		int n, m, a; cin >> n >> m >> a;
		if(!n && !m && !a) break;
		vector<hpq> bar(m);
		rep(i, m){
			int h, p, q; cin >> h >> p >> q;
			bar[i] ={h, p, q};
		}
		sort(bar.begin(), bar.end(), [](auto& l, auto& r){
			return l.h > r.h;
			});
		int pos = a;
		rep(i, bar.size()){
			if(bar[i].p == pos) pos = bar[i].q;
			else if(bar[i].q == pos) pos = bar[i].p;
		}
		cout << pos << endl;
	}
}


Measured memory_bytes: 3124
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong();
			long[] array = LongStream.range(0, 10000).map(i -> i * i * i * i * i).toArray();
			for (int i = 0; i < 10000; i++) {
				int a;
				if ((a = Arrays.binarySearch(array, x + array[i])) >= 0) {
					System.out.println(a + " " + i);
					break;
				} else if ((a = Arrays.binarySearch(array, x - array[i])) >= 0) {
					System.out.println(a + " -" + i);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 39056
L, R = map(int, input().split())
MOD = 2019
if R - L >= MOD:
  print(0)
  exit(0)
lst = [x % MOD for x in range(L, R+1)]
N = len(lst)
mi = 10e9
for i in range(N-1):
  for j in range(i+1, N):
    mi = min(mi, lst[i] * lst[j] % MOD)
print(mi)

Measured memory_bytes: 41068
#include <stdio.h>

int main(){
        int number[3], i, j, tmp;

        do{
                        scanf("%d %d %d", &number[0], &number[1], &number[2]);
        }while(!(1 <= number[0] && number[0] <= 10000 || 1 <= number[1] && number[1] <= 10000 || 1 <= number[2] && number[2] <= 10000));

        for(i = 0; i < 3; ++i) {
                 for (j = i+1; j < 3; ++j) {
                        if (number[i] > number[j]) {
                                tmp =  number[i];
                                number[i] = number[j];
                                number[j] = tmp;
                        }
                }
        }

        printf("%d ", number[0]);
        printf("%d ", number[1]);
        printf("%d\n", number[2]);
        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> cnt(N);
  REP(i, N) {
    lint A;
    cin >> A;
    cnt[A-1]++;
  }
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  sort(ALL(cnt));
  vector<lint> Scnt(N+1);
  REP(i, N) Scnt[i+1] = Scnt[i] + cnt[i];
  vector<lint> ans(N);
  lint pool = 0;
  REP(i, N) {
    lint l = -1;
    lint r = N*N;
    while(r-l > 1) {
      lint m = (l+r) / 2;
      lint ll = -1;
      lint rr = N;
      while(rr-ll > 1) {
        lint mm = (ll+rr) / 2;
        if(cnt[mm] <= m) ll = mm;
        else rr = mm;
      }
      if(ll >= i && Scnt[ll+1] - Scnt[i] + pool < m * (ll + 1 - i)) r = m;
      else l = m;
    }
    ans[N-1-i] = l;
    pool += cnt[i];
  }
  REP(i, N) cout << ans[i] << "\n";
}

Measured memory_bytes: 10276
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, z = 0;
    string s;
    cin >> a >> b >> s;
    if ((int)s.length() != a + b + 1) z = 1;
    if (s[a] != '-') z = 1;
    for (int i = 0; i < a; i++) if (s[i] == '-') z = 1;
    for (int i = a + 1; i < a + b + 1; i++) if (s[i] == '-') z = 1;
    if (z) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
	
	int d = 0;
	string s;
	cin >> s;
	if (s == "RRR") d = 3;
	else if (s == "RRS" or s == "SRR") d = 2;
	else if (s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR") d = 1;
	
	cout << d << "\n";
	
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int p[a], q[b], r[c];
    int i;
    for(i=0; i<a; i++){
        cin >> p[i];
    }
    for(i=0; i<b; i++){
        cin >> q[i];
    }
    for(i=0; i<c; i++){
        cin >> r[i];
    }
    std::sort(p, p + SIZE_OF_ARRAY(p));
    std::sort(q, q + SIZE_OF_ARRAY(q));
    std::sort(r, r + SIZE_OF_ARRAY(r));
    int z[x+y];
    memcpy(&z, &p[a-x],sizeof(int)*x);
    memcpy(&z[x], &q[b-y],sizeof(int)*y);
    std::sort(z, z + SIZE_OF_ARRAY(z));
    int r_max = r[c-1];
    int j=c-1;
    for(i=0; i<x+y; i++){
        if(z[i] < r[j]){
            z[i] = r[j];
            j--;
            if(j<0) break;
        }else{
            break;
        }
    }
    long sum = 0;
    for(i=0;i<x+y;i++){
        sum += z[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ans = 0;
    string s; cin >> s;
    for(int i = 0; i<(1<<s.size()-1); i++) {
        ll num = s[0]-'0';
        for(int j = 0; j < s.size()-1; j++) {
            if(i&(1<<j)) {
                ans += num;
                num = 0;
            }
            num = num*10 + s[j+1]-'0';
        }
        ans += num;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int n, a, b, c;

mod solve(int a, int b, int c) {
	mod p1(a), p2(b), p(c), mp(100 - c);
	mod ret(0);
	if (!c) {
		mod cnk(1);
		mod pp1 = p1 * mod(100).inv();
		mod pp2 = p2 * mod(100).inv();
		for (int i = n; i < 2 * n; i++) {
			if (i > n) {
				cnk *= mod(i - 1) * mod(i - n).inv();
			}
			ret += mod(i) * pp1.mypow(n) * pp2.mypow(i - n) * cnk;
		}
	} 
	else {
		mod cnk1;
		for (int j = 0; j < n; j++) {
			mod cur1(0), cur2;	
			if (j == 0) {
				cnk1 = mod(1);
			} else {
				cnk1 *= mod(n + j - 1) * mod(j).inv(); 
			}
			cur1 = mod(n + j) * (p * mp.inv()).mypow(n + j) * (mp * mod(100).inv()).inv() * cnk1;	
			mod cur = cur1;
			cur *= (p2 / p).mypow(j);
			ret += cur;
		}
		ret *= (p1 / p).mypow(n);
	}
	return ret;
}

int main() {
	cout << fixed << setprecision(12);	
	cin >> n >> a >> b >> c;
	cout << solve(a, b, c) + solve(b, a, c)  << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  
  cout << X+Y/2 << endl;

  return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map{|i| (i.to_f+1)/2.0}

max_num = arr[0...k].reduce(:+)
i_num = max_num

for i in 0...n-k do
  i_num =i_num - arr[i] + arr[i+k]
  if i_num > max_num
    max_num = i_num
  end
end

print(max_num)


Measured memory_bytes: 16004
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(c-a)<=d)
	  cout<<"Yes";
	 else if(abs(b-a)<=d && abs(c-b)<=d)
	 	  cout<<"Yes";
	 else
	     cout<<"No";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n=int(input())
l=[-1]*n
p=[[] for _ in range(n)]
for i in range(n-1):
    ui,vi,wi=map(int,input().split())
    p[ui-1].append([vi,wi])
    p[vi-1].append([ui,wi])

def tr1(x,y):
    #print(x)
    #print(y)
    
    if l[x-1]!=-1:
        return
    l[x-1]=y
    for i in range(len(p[x-1])):
        tr1(p[x-1][i][0],(y+p[x-1][i][1])%2)
tr1(1,0)
for j in range(n):
    print(l[j])

Measured memory_bytes: 164896
using System;
namespace ConsoleApplication4.Properties
{
    public class Class1
    {
        public static void Main()
        {
            var a =Console.ReadLine();
           String [] n= a.Split();
           double N =  int.Parse(n[0]);
           double K = int.Parse(n[1]);
           double sum = 0;
           double Sum = 0;
           double Sum2 = 0;
           double loglog = 0;
           for (int i = 1; i <= N; i++)
           {
               if (i<K)
               {
                   Sum = (K / i);
                   loglog = (int) Math.Log(Sum, 2);
                   if (Math.Pow(2, loglog)!=Sum)
                   {
                       loglog += 1;
                   }
                   sum += (1 / N) * (Math.Pow((0.5), loglog));
               }
               else
               {
                   sum += (1 / N);
               }

           }
           Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef pair<ll,int> LL_IP;

#define ARRAY_MAX 100005
int n,k;
int a[ARRAY_MAX];

bool check(int mid){//最大積載量

    int tmp = 0;
    int count = 0;
    for(int i = 0;i < n;i++){

        if(a[i] > mid){
            return false;
        }

        if(tmp + a[i] > mid){
            count++;
            tmp = a[i];
        }else{
            tmp += a[i];
        }
    }

    //cout << count << endl;
    if(count >= k){
        return false;
    }else{
        return true;
    }

}

int binary_serch(int ng,int ok){

    //[ok,ng)
    while(abs(ok - ng) > 1){
        int mid = (ok + ng)/2;
        if(check(mid)){
            //まだ小さくできる
            //cout << ok <<  " " << ng << " a " << mid << endl;
            ok = mid;
        }else{
            //大きくしないといけない
            //cout << ok << " " << ng << " b " << mid << endl;
            ng = mid;
        }
    }
    return ok;
}




int main(){

    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
    }
    
    int ans = binary_serch(0,INF);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3524
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入
b = map(int, b.split())
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)



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

using namespace std;
using ll = long long;
const ll mod = 998244353;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> L(k), R(k);
  vector<ll> sum(n + 1, 0), ans(n + 1, 0);
  ans[1] = sum[1] = 1;
  for (int i = 0; i < k; i++) {
    cin >> L[i] >> R[i];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      int l = max(0, i - L[j]), r = max(0, i - R[j] - 1);

      ans[i] += sum[l] - sum[r];
      ans[i] %= mod;
    }
    ans[i] += mod;
    ans[i] %= mod;
    sum[i] = (sum[i - 1] + ans[i]) % mod;
  }
  cout << (ans[n]+mod)%mod << endl;
}


Measured memory_bytes: 6420
import itertools

n = input()
gomen = {3:0, 4:6, 5:18, 6:54,7:162,8:486,9:1458}

if len(n) < 3:
    print(0)
    exit()
cnt = 0
for i in range(3, len(n)+1):
    c = list(itertools.product(["3", "5", "7"], repeat=i))
    for num in c:
        if int(n) >= int("".join(num)) and (num.count("3") >=1
                and num.count("5") >= 1 and num.count("7") >= 1):
            cnt += 1

print(cnt)


Measured memory_bytes: 6756
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			int inputInt = sc.nextInt();
			input[i] = Math.abs(inputInt - X);
		}
		int res = input[0];
		for (int i = 1; i < N; i++) {
			res = gcd(res, input[i]);
		}
		System.out.print(res);
	}

	private static int gcd(int res, int input) {
		int m = res;
		int n = input;
		while (m * n != 0) {
			if (m <= n) {
				n = n % m;
			} else {
				m = m % n;
			}
		}
		return Math.max(m, n);
	}
}


Measured memory_bytes: 49620
#include <stdio.h>
typedef long long ll;

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t;
  return a;
}

int main(void) {
  ll a, b, c, d, l;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d), --a;
  l = c * d / gcd(c, d);
  printf("%lld", b - a + b / l - a / l - b / c + a / c - b / d + a / d);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
// g++ hello.cpp && ./a.out
using namespace std;


int main() {
	string s;
	string t;
	cin >> s >> t;
	int ans = 0;
	int i = 0;
	// for (int i = s.begin(); i < s.size(); s++) {
	// 	if (s[i] != t[i]);
	// 	ans++;
	// }
	while (i < s.size()) {
		if (s[i] != t[i]) {
			ans++;
		}	
		i++;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3856
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    if(s.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3604
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        int m,n; cin>>m>>n;
        string s;
        cin>>s;
        s[n-1]=s[n-1]+32;
        cout<<s;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
const int N = 2e6 + 100;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

namespace Combi {
    int fact[N], inv[N];

    int bm(int b, int p, int m) {
        if(p == 0) return 1%m;
        int t = bm(b,p/2,m);
        t = (1ll*t*t)%m;
        if(p&1) return 1ll*t*b%m;
        return t;
    }

    int C(int n, int r) {
        if(n < 0 or r < 0 or r > n) return 0;
        int ret = 1ll*fact[n]*inv[r]%mod;
        ret = 1ll*ret*inv[n-r]%mod;
        return ret;
    }
    // X1 + X2 + ... + Xvar = Sum
    int no_of_eqns(int sum, int var) {
        return C(sum+var-1,var-1); // Xi >= 0
        // return C(sum-1,var-1); // Xi > 0
    }
    void init() {
        fact[0] = 1;
        for(int i = 1; i < N; i++) {
            fact[i] = 1ll*fact[i-1]*i%mod;
        }
        inv[N-1] = bm(fact[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--) {
            inv[i] = 1ll*inv[i+1]*(i+1)%mod;
        }
    }
}
 main()

{
    fast
    Combi::init();
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    int ses=0;
    f(r,r1,r2)
    {
        int x=Combi::C(r+c2+1,r+1);
        int y=Combi::C(r+c1,r+1);
        x=sub(x,y);
        ses=ad(ses,x);
    }
    cout<<ses<<endl;
    return 0;

}





































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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b<=0){
    cout << "No" << endl;
  }
  else{
    if(a*a+b*b+c*c-2*b*c-2*a*c-2*a*b<=0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define P(s)     cout<<(s)<<endl
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	if(n<10) P(n);
	else if(n<100) P(9);
	else if(n<1000) P(9+n-99);
	else if(n<10000) P(9+999-99);
	else if(n<100000) P(9+999-99+n-9999);
	else P(9+999-99+99999-9999);
}

Measured memory_bytes: 256
inf = 1001001001
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
dp = [[inf for j in range(w)] for j in range(h)]
if s[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0
for i in range(h):
    for j in range(w):
        if i+1 < h:
            count = dp[i][j]
            if s[i][j] == "." and s[i+1][j] == "#":
                count += 1
            dp[i+1][j] = min(dp[i+1][j], count)
        if j+1 < w:
            count = dp[i][j]
            if s[i][j] == "." and s[i][j+1] == "#":
                count += 1
            dp[i][j+1] = min(dp[i][j+1], count)
print(dp[h-1][w-1])

Measured memory_bytes: 42864
import math
import sys
from collections import deque
a,b=map(int,input().split())
l=[list(map(int,input().split())) for i in range(a)]
ans=10**20
for i in range(2**a):
  s=0
  count=0
  keep1=0
  keep2=0
  t=True
  for j in range(a):
    if i>>j &1:
      s+=l[a-1-j][0]*100*(a-j)+l[a-1-j][1]
      count+=l[a-1-j][0]
    else:
      if t:
        keep1=100*(a-j)
        keep2=l[a-1-j][0]-1
        t=False
  if s+keep1*keep2>=b:
    if s>=b:
      if ans>count:
        ans=count
    else:
      p=count+math.ceil((b-s)/keep1)
      if p<ans:
        ans=p
print(ans)

Measured memory_bytes: 3316
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, X, T,time;
    cin >> N >> X >> T;
    time = N / X;
    if(N%X!=0)time++;
    time = time * T;
    cout <<time<< endl;
    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(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 main() {
    double l;
    cin >> l;
    l /= 3;
    double ans = l*l*l; 
    printf("%.12f", ans);
    //cout << ans << endl;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main()
{   int n,a,b,i,ans=0;
    scanf("%d%d%d",&n,&a,&b);
    for(i=1;i<=n;i++){
        int k=i;
        int sum=0;
        while (k>0){
            sum+=k%10;
            k/=10;
            }
            if(sum>=a&&sum<=b){
                ans+=i;
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

/*
一番大きいa[i]にa[i]/N回操作->周りが(a[i]/N)増える


*/

int main(){
	int n;
	LL a[55]={};
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	sort(a,a+n);
	LL ans=0;
	while(1){
		LL tmp=0,sub[55]={};
		FORD(i,n,0){
			if(a[i]<n)continue;
			tmp+=a[i]/n;
			sub[i]+=a[i]/n;
			a[i]=a[i]%n;
		}
		ans+=tmp;
		if(tmp==0)break;
		FOR(i,0,n){
			a[i]+=tmp-sub[i];
		}
	}
	cout<<ans<<endl;
    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)



int main(){
    int m;
    int n;
    int d;
    int r;
    double f;
 
    cin >> m >> n ;
 
    d = m / n ;
    r = m % n ;
    f = (1.0 * (double)m) / (double)n ;
 
    cout << d << ' ' << r << ' ' << fixed << f <<endl; 
    return 0;   
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int main()
{
	int n,day;
	map<int,vector<int> > s;
	priority_queue<int> p;
	long long sum=0;
	cin >> n >> day;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		s[a[i]].push_back(b[i]);
	}

	
	for(int i=1;i<=day;i++){
	 	auto itr=s.find(i);
	 	
		if(itr!=s.end()) 
	    {
	    	for(int j=0;j<s[i].size();j++)
			{
				p.push(s[i][j]);
			}
	    } 
	    if (p.size()!= 0)
    	{
    		sum=sum+p.top();
    		p.pop();
    	}
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 11648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A,B;
  
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    A.PB(a);
    B.PB(b);
  }
  
  SORT(A);
  SORT(B);
  
  if(N%2==1) ans=B.at(N/2)-A.at(N/2)+1;
  else ans=(B.at(N/2)+B.at(N/2-1))-(A.at(N/2)+A.at(N/2-1))+1;
  
  co(ans);
  return 0;
}

Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i=0; i<n; i++) {
    cin >> h[i];
  }
  int k = 2;
  ll dp[n+k];
  for (int i=0; i<n; i++) {
    dp[i] = INT_MAX;
  }
  dp[0] = 0;
  for (int i=0; i<n; i++) {
    for (int j=1; j<=k; j++) {
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
      //      cout << i+j << " " << dp[i+j] << endl;
    }
  }
  cout << dp[n-1] << endl;
	     
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
    {
        s[i]='A'+(s[i]-'A'+n)%26;
    }
    cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#input
n, m = map(int, input().split())
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

#operation
pointvisited = [False] * (n + 1)
pointvisited[0] = True
pointvisited[1] = True
ans = 0
def DFS(point):
    if all(pointvisited):
        global ans
        ans += 1
    nextpoints = findnextpoint(point)
    for nextpoint in nextpoints:
        if not pointvisited[nextpoint]:
            pointvisited[nextpoint] = True
            DFS(nextpoint)
            pointvisited[nextpoint] = False

def findnextpoint(point):
    nepo = []
    for i, a in enumerate(A):
        if a == point:
            nepo.append(B[i])
    for i, b in enumerate(B):
        if b == point:
            nepo.append(A[i])
    return nepo

#output
DFS(1)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	if(a.back()==b.front()&&b.back()==c.front())
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	vector<int> v;
	rep(i, N)
	{	
		int tmp;
		cin >> tmp;
		v.pb(tmp - 1);
	}

	vector<int> re;
	while(v.size()> 0)
	{
		int i = v.size() - 1;
		for (; i >= 0; i--)
		{
			if (v[i] == i)
			{
				re.pb(v[i]);
				v.erase(v.begin() + i);
				break;
			}
		}
		if (i < 0)
		{
			break;
		}
	}
	if (v.size() == 0)
	{
		for(int i = re.size() - 1; i >= 0; i--)
		{
			cout << re[i] + 1 << endl;
		}
	}
	else
	{
		cout << -1 << endl;
	}
	

	

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a;
  ll cnt = 0;
  if (n == 0) {
    cout << 0 << '\n';
    return 0;
  }
  for (ll i = 0; n != 0; i++) {
    a.push_back(n % -2);
    if (a[i] == -1) {
      a[i] = 1;
      n = (n-1)/-2;
    }  
    else n = n / -2;
    ++cnt;
  }
  rep(i,cnt) cout << a[cnt-i-1];
  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3620
# include <cstdio>
# include <cmath>
# include <algorithm>

using namespace std;

const int MAX_N = 2048;

int n, z, w;
int a[MAX_N];

int main ()
{
    int i;
    scanf ("%d%d%d", &n, &z, &w);
    for (i = 1; i <= n; i ++)
        scanf ("%d", &a[i]);
    a[0] = w;
    printf ("%d\n", max (abs (a[n] - w), abs (a[n - 1] - a[n])));

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll H,N;	cin>>H>>N;
	ll a[10010],b[10010],dp[11010],ans=INF;
  	FOR(i,0,N)	cin>>a[i]>>b[i];
	FOR(i,1,11010)	dp[i]=INF;
	dp[0]=0;
	
	FOR(i,1,11010){
		FOR(j,0,N){
		if(a[j]<=i){
          chmin(dp[i],dp[i-a[j]]+b[j]);
        	}
		}
		if(i>=H)		chmin(ans,dp[i]);
	}
	cout.setf(ios::fixed);
  
  cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 384
s = input()
k = int(input())
d = {}
dd = {}
for i, ss in enumerate('abcdefghijklmnopqrstuvwxyz'):
    d[ss] = i
    dd[i] = ss
ans = ''

for ss in s[:-1]:
    if k >= 26 - d[ss] and ss != 'a':
        k -= 26 - d[ss]
        ans += 'a'
    else:
        ans += ss
k = (d[s[-1]] + k) % 26
ans += dd[k]
print(*ans, sep='')

Measured memory_bytes: 6384
#include<stdio.h>
#include<stdlib.h>
#define MAX 2010
#define MOD 1000000007

long long int fac[MAX]={0};
long long int inv[MAX]={0};
long long int finv[MAX]={0};
int i;

void comb_init()
{
    fac[0]=1;
    fac[1]=1;
    finv[0]=1;
    finv[1]=1;
    inv[1]=1;
    for(i=2;i<MAX;i++)
    {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


long long int comb(int n,int k)
{
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main()
{
    int n,k,b,r;
    int i;
    long long int aa,bb,ans;
    comb_init();
    scanf("%d %d",&n,&k);
    b=k;
    r=n-k;

    for(int i=0;i<b;i++)
    {
        aa=(long long int)comb((r+1),(i+1));
        bb=(long long int)comb((b-1),i);
        ans =(aa*bb)%MOD;
        printf("%lld\n",ans);
    }

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		total += a[i];
	}
	sort(a.rbegin(), a.rend());
	bool flag = true;
	for (int i = 0; i < m; i++) {
		if (a[i] < (total + (4*m) - 1) / (4 * m)) {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

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

int main() {

  int n;
  cin >> n;
  string s;
  cin >> s;

  int y = 0, x = 0;
  for (auto ch : s) {
    if ('A' <= ch and ch <= 'M') y += 1;
    if ('N' <= ch and ch <= 'Z') y -= 1;
    if ('a' <= ch and ch <= 'm') x += 1;
    if ('n' <= ch and ch <= 'z') x -= 1;
  }
  string t = "";
  auto ch = y > 0 ? 'A' : 'N';
  rep(i, abs(y)) t += ch;
  ch = x > 0 ? 'a' : 'n';
  rep(i, abs(x)) t += ch;

  cout << t.size() << endl;
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 100005;
int n;
ii a[MX];
priority_queue<ii, vii, greater<ii>> pq;

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i].fi >> a[i].se;

	sort(a, a+n, [&] (ii x, ii y) {
		if (x.fi != y.fi)
			return x.fi > y.fi;
		return x.se > y.se;
	});

	for (int i = 2; i < n; i++)
		pq.emplace(a[i].se, i);

	int res, mnfi = a[0].se;
	for (int i = 1; i < n - 1; i++)
		mnfi = min(mnfi, a[i].se);
	res = max(0, mnfi - a[0].fi + 1);
	res += a[n-1].se - a[n-1].fi + 1;

	mnfi = a[0].se;
	for (int i = 1; i < n - 1; i++) {
		while (pq.top().se <= i)
			pq.pop();

		int x = min(mnfi, pq.top().fi);
		int y = min(a[i].se, pq.top().fi);

		res = max(
			res, 
			max(0, x - a[0].fi + 1) + max(0, a[i].se - a[i].fi + 1)
		);

		res = max(
			res,
			max(0, mnfi - a[0].fi + 1) + max(0, y - a[i].fi + 1)
		);

		mnfi = min(mnfi, a[i].se);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2168
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll h,w,H,W;
    cin>>H>>W>>h>>w;
    cout<<H*W-(h*W+w*H-h*w)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, a[220000], b[220000],dp[3100][3100];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	cin >> str;
	dp[0][0] = 1;
	rep(i, n - 1) {
		rep(j, n) {
			dp[i][j + 1] += dp[i][j];
			dp[i][j] += MOD;
			dp[i][j] %= MOD;
		}
		for (int j = 0; j + i < n; j++) {
			if (str[i] == '<') {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
				dp[i + 1][n - i] +=MOD-dp[i][j];
				dp[i + 1][n - i] %= MOD;
			}
			else {
				dp[i + 1][0] += dp[i][j];
				dp[i + 1][0] %= MOD;
				dp[i + 1][j] += MOD - dp[i][j];
				dp[i + 1][j] %= MOD;
			}
		}
	}
	cout << (dp[n-1][0]+MOD)%MOD << endl;
	return 0;
}


Measured memory_bytes: 76032
(defun solve (s)
  (let ((n (length s))
	(cnt 0)
	(ans 0))
    (dotimes (i n)
      (when (equal (aref s i) #\W)
	(setq ans (+ ans (- i cnt)))
	(incf cnt)))
    ans))


(defun main()
  (let ((s (concatenate 'vector (read-line))))
    (princ (solve s))
    (fresh-line)))


(main)


Measured memory_bytes: 28556
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]
    

g = Graph()
N, M = [int(i) for i in input().split()]

for i in range(M):
    u, v = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, 1)
    g.add_edge(u-1, v-1+N, 1)

ans_n = 10 ** 6
ans_index = -1
for i in range(N):
    d = Dijkstra(g, i)
    ans_n_ = d.dist[i+N]

    if ans_n_ < ans_n:
        ans_index = i
        ans_n = ans_n_

if ans_n == 10 ** 6:
    print(-1)
else:
    d = Dijkstra(g, ans_index)
    ans = d.shortest_path(ans_index + N)
    ans.sort()
    print(ans_n)
    for j in range(ans_n):
        print(ans[j]+1)




Measured memory_bytes: 145924