akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
  string s; cin >> s;
  int num = 753;
  int minS;
  int tmp;
  int ans = 100000;
  int sum;
  for ( int i = 0; i < s.size()-2; i++ ) {
    int keta = 100;
    tmp = 0;
    sum = 0;
    for ( int j = i; j < i + 3; j++ ) {
      tmp = s[j] - '0';
      sum += tmp * keta;
      keta /= 10;
    }
    if ( sum >= 753 ) {
      ans = min(ans,sum - 753 );
    } else {
      ans = min(ans, 753 - sum );
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using vi = vector<int>;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define rrep(i,n) for(long long i=(n);i>=0;--i)

template<int MOD> struct MInt {
  long long val;
  constexpr MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
constexpr int MOD = 1e9+7;
using mint = MInt<MOD>;

int main() {
  int N, M;
  ins(N, M);

  vi A(N), B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  all(sort, A); all(sort, B);

  // 自明なケースを捌く
  rep(i, N-1)
    if (A[i] == A[i+1]) {
      cout << "0\n";
      return 0;
    }
  rep(i, M-1)
    if (B[i] == B[i+1]) {
      cout << "0\n";
      return 0;
    }

  if (N == 1) {
    cout << (A[0] == M) << "\n"; return 0;
  }
  if (M == 1) {
    cout << (B[0] == N) << "\n"; return 0;
  }

  mint ans = 1;
  rrep(i, N*M) {
    if (i == 0) break;
    int a = A.end() - all(lower_bound, A, i),
        b = B.end() - all(lower_bound, B, i);
    bool found_in_a = all(binary_search, A, i),
         found_in_b = all(binary_search, B, i);
    if (a*b <= N*M-i) {
      cout << "0\n";
      return 0;
    }
    if (found_in_a && found_in_b)
      continue;
    if (found_in_a) {
      ans *= b; continue;
    }
    if (found_in_b) {
      ans *= a; continue;
    }
    if (!(all(binary_search, A, i) && all(binary_search, B, i)))
      ans *= a*b - (N*M-i);
  }
  cout << ans << endl;


  return 0;
}


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()

using namespace std;
typedef long long ll;

int main()
{

    string S;
    cin >> S;
    sort(all(S));
    vector<int> A = {0,0,0};
    
    rep(i,int(S.length())){
        if(S[i] == 'a') A[0]++;
        if(S[i] == 'b') A[1]++;
        if(S[i] == 'c') A[2]++;
    }
    
    sort(all(A));
    
    if(A[0] == 0 && A[1] == 0){
        if(A[2] == 1) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else if(A[0] == 0){
        if(A[1] == 1 && A[2] == 1){
            cout << "YES" << endl;
            
        }else{
            cout << "NO" << endl;
            
        }
    }else if(A[0] == A[1] && A[0]+1 == A[2]){
        cout << "YES" << endl;
        
    }else if(A[0]+1 == A[1] && A[1] == A[2]){
        cout << "YES" << endl;
        
    }else if(A[0] == A[1] && A[1] == A[2]){
        cout << "YES" << endl;
        
    }else{
        cout << "NO" << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll dp[N],n,k;
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void solve()
{
    cin>>n>>k;
    ll ans=0;
    ll x=0;
    for(int i=k;i>0;i--)
    {
        dp[i]=expo((k/i),n,hell);
        x=0;
        for(int j=2*i;j<=k;j+=i)
        {
            x=(x+dp[j])%hell;
        }
        dp[i]=(dp[i]-x+hell)%hell;
    }
    rep(i,1,k+1)
    {
        ans=(ans+(i*dp[i])%hell)%hell;
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


int X,N;
bool used[105];
signed main(){
	cin>>X>>N;
	rep(i,N){
		int a;cin>>a;used[a]=true;
	}
	int mn=inf,ans;
	rep(i,102){
		if(used[i])continue;
		if(chmin(mn,abs(i-X))){
			ans=i;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3624
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust\n";
	else cout << "win\n";
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

template<typename INT>
INT gcd_with_coef(INT x, INT y, INT* outCX, INT* outCY) {
	if (x < 0) {
		INT d = gcd_with_coef(-x, y, outCX, outCY);
		*outCX *= -1;
		return d;
	}
	if (y < 0) {
		INT d = gcd_with_coef(x, -y, outCX, outCY);
		*outCY *= -1;
		return d;
	}
	if (x > y) {
		return gcd_with_coef(y, x, outCY, outCX);
	}
	if (x == 0) {
		if (outCX != nullptr && outCY != nullptr) {
			*outCX = 0;
			*outCY = 1;
		}
		return y;
	}
	INT q = y / x;
	INT r = y % x;
	INT d = gcd_with_coef(r, x, outCY, outCX);
	if (outCX != nullptr && outCY != nullptr) {
		*outCX -= q * *outCY;
	}
	return d;
}

int main() {
	ll Y;
	cin >> Y;
	rep(y,0,Y) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B) {
			cout << "No" << endl;
			continue;
		}
		if (A%B > C) {
			cout << "No" << endl;
			continue;
		}
		if (D < B) {
			cout << "No" << endl;
			continue;
		}
		if (D == B) {
			cout << "Yes" << endl;
			continue;
		}
		ll E = D - B;
		ll bad_end;
		if (B <= C + 1) {
			bad_end = 1;
		} else if (B >= C + E + 1) {
			bad_end = E + 1;
		} else {
			bad_end = B - C;
		}
		ll J = gcd_with_coef<ll>(B, E, nullptr, nullptr);
		ll X = ((A - C) % E + E) % E;
		if (X == 0) {
			X = E;
		}
		X = X % J;
		if (X == 0) {
			X += J;
		}
		if (X < bad_end) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
		continue;
	}
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll mod=1000000009;
const ll INF=(ll)1000000007*1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int h[1 << 17];
int main(){
  int N; cin >> N; int K; cin >> K;
  rep(i,N){
    cin >> h[i];
  }
  sort(h,h+N);
  int ans = mod;
  rep(i,N-K+1){
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=2100;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<=b;i++)
    {
        if(i<a+k||i>b-k)
            cout<<i<<endl;
    }
    return 0;
}


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

int main(){
    int i,N,H,W;
    int a[1000];
    int b[1000];
    int ans=0;

    scanf("%d", &N);
    scanf("%d", &H);
    scanf("%d", &W);
    for(i=0;i<N;i++){
        scanf("%d %d", &a[i], &b[i]);
    }

    for(i=0;i<N;i++){
        if( a[i]-H >= 0 && b[i]-W >= 0 ) ans++;
    }
    printf("%d", ans);

    return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    VVI dp(n + 1, VI(m + 1, 0));
    vector<VP> prev(n + 1, VP(m + 1));
    FOR(i, 1, n)FOR(j, 1, m) {
        vector<pair<int, P>> candidate;
        if(s[i - 1] == t[j - 1])
            candidate.push_back(make_pair(dp[i - 1][j - 1] + 1, P(i - 1, j - 1)));
        else
            candidate.push_back(make_pair(dp[i - 1][j - 1], P(i - 1, j - 1)));
        candidate.push_back(make_pair(dp[i - 1][j], P(i - 1, j)));
        candidate.push_back(make_pair(dp[i][j - 1], P(i, j - 1)));
        sort(ALL(candidate));
        dp[i][j] = candidate.back().first;
        prev[i][j] = candidate.back().second;
    }
    
    string ans;
    P next_p = P(n, m);
    int cnt = dp[next_p.first][next_p.second];
    do {
        int i = next_p.first;
        next_p = prev[next_p.first][next_p.second];
        if(cnt > dp[next_p.first][next_p.second]) ans += s[i - 1];
        cnt = dp[next_p.first][next_p.second];
    } while(dp[next_p.first][next_p.second] > 0);
    reverse(ALL(ans));
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define all(a) (a).begin(), (a).end() 
#define MAXN 200005
using namespace std;

ll n;
string s;
map<string,ll> m;

int main(ll argc, char const *argv[])
{
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		sort(s.begin(),s.end());
		// cout<<s<<endl;
		m[s]++;
	}
	ll ans=0;
	for(auto it = m.begin();it!=m.end();it++)
	{
		ll p=it->ss;
		ans+=((p*(p-1))/2);
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 7;

namespace Fenw {
	int f[N];

	void add(int x, int val) {
		for (int i = x; i < N; i = (i | i + 1)) {
			f[i] += val;
		}
	}

	int sum(int x) {
		int ans = 0;
		for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
			ans += f[i];
		}
		return ans;
	}

	int sum(int l, int r) {
		return sum(r) - sum(l - 1);
	}
}

int ans[N];
vector<int> br[N];
vector<int> dv[N];

void init() {
	for (int i = 2; i < N; i++) {
		for (int j = i; j < N; j += i) {
			dv[j].push_back(i);
		}
	}
}

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

	init();
	cerr << "init ok" << endl;

	int n, M;
	cin >> n >> M;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		br[r].push_back(l);
	}
	fill(ans, ans + N, n);
	for (int i = 1; i + 1 < N; i++) {
		for (auto l : br[i]) {
			Fenw::add(l, 1);
		}
		for (auto x : dv[i + 1]) {
			//[i + 2 - x, i]
			ans[x] -= Fenw::sum(i + 2 - x, i);
		}
	}
	for (int i = 1; i <= M; i++) {
		cout << ans[i] << '\n';
	}
}


Measured memory_bytes: 30080
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        int c=sc.nextInt();
        int c1=0,c2=0;
        for(int i=0;i<c;i++){
            String s1=sc.next(),s2=sc.next();
            if(s1.compareTo(s2)>0){
                c1+=3;
            }else if(s1.compareTo(s2)<0){
                c2+=3;
            }else{
                c1++;c2++;
            }
        }
        ln(c1+" "+c2);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 29752
import sys

def solve():
    input = sys.stdin.readline
    S = list(input().strip("\n"))
    for i, s in enumerate(S):
        if s == "?":
            if i > 0 and S[i-1] == "P": S[i] = "D"
            else:
                if i < len(S) - 1:
                    if S[i+1] != "P": S[i] = "P"
                    else: S[i] = "D"
                else: S[i] = "D"
    print("".join(S))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10856
# Generated by AtcoderGreedy on 2018-05-20
# AGC024 A
# Your code here

a, b, c, k = gets.chomp.split(' ').map(&:to_i)

a_b = a - b

if a_b.abs > 1_000_000_000_000_000_000
  puts 'Unfair'
else
  a_b *= -1 if k % 2 != 0
  puts a_b
end


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int a = NextInt, b = NextInt;
            System.Console.WriteLine(Math.Max(Math.Max(a + b, a - b), a * b));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

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

	scanf("%d %d %d", &a, &b, &c);

	if(a==b && b==c) printf("1");
	else if(a==b || b==c || c==a) printf("2");
	else printf("3");

   	return 0;
}


Measured memory_bytes: 2068
while true
  a, b, c = gets.split.map(&:to_i)
  break if a == 0 and b == 0 and c == 0

  states = Array.new(a + b + c + 1, 2)
  failed_lists = []

  n = gets.to_i
  n.times do
    i, j, k, r = gets.split.map(&:to_i)
    if r == 1
      states[i] = states[j] = states[k] = 1
    else
      failed_lists << [i, j, k]
    end
  end


  failed_lists.each do |failed_list|
    failed_list.delete_if{|n| states[n] == 1 }
    if failed_list.size == 1
      states[failed_list[0]] = 0
    end
  end

  puts states[1..-1]
end

Measured memory_bytes: 6128
N,A,B = map(int,input().split())
S =input()
rank = 1
gai_rank = 1
i = 0
for s in S:
    if s == 'a':
        if rank <= A+B:
            print('Yes')
            rank+=1
        else:
            print('No')
    elif s == 'b':
        if rank <= A+B and gai_rank <= B:
            print('Yes')
            rank += 1
            gai_rank += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF (int)1e18


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}


signed main()
{
	fio
	inp(n)
	inpa(a,n)
	int tot=0;
	fo(i,n)
		tot+=a[i];
	int curr=0;
	int ans=tot;
	fo(i,n)
	{
		curr+=a[i];
		ans=min(ans,abs(tot-2*curr));
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 1792
// ABC079
// A - Good Integer
#include<bits/stdc++.h>

using namespace std;

int main(){
    string n;
    cin >> n;
    if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]))
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

vector<vector<int>> dist;
int levenshtein_distance(string a, string b) {
    // init : 長さ0の文字列と比較した場合の距離は長さと一致する
    for (auto i = 0; i <= (int)a.size(); i++) dist[i][0] = i;
    for (auto i = 0; i <= (int)b.size(); i++) dist[0][i] = i;

    // dp
    for (auto i = 1; i <= (int)a.size(); i++) {
        for (auto j = 1; j <= (int)b.size(); j++) {
            dist[i][j] = dist[i][j - 1] + 1; // insert
            dist[i][j] = min(dist[i][j], dist[i - 1][j] + 1); // delete
            dist[i][j] = min(dist[i][j], dist[i - 1][j - 1] + (a[i - 1] != b[j - 1])); // replace
        }
    }

    // print
//    for (auto i = 0; i <= (int)a.size(); i++) {
//        if(i == 0) {
//            cout << "  ";
//            for (auto j = 0; j <= (int)b.size(); j++) cout << b[j - 1] << " ";
//            cout << endl;
//        }
//        for (auto j = 0; j <= (int)b.size(); j++) {
//            if(j == 0) cout << a[i - 1] << " ";
//            cout << dist[i][j] << " ";
//        }
//        cout << endl;
//    }

    return dist[a.size()][b.size()];
}

int main(){
    string s1, s2;
    cin >> s1 >> s2;

    dist.assign(s1.size() + 1, vector<int>(s2.size() + 1, 0));
    cout << levenshtein_distance(s1, s2) << endl;

    return 0;
}


Measured memory_bytes: 6820
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int days = scan.nextInt();
		int total = scan.nextInt();
		int count = 0;
		for(int i=0;i<total;i++){
			count+= scan.nextInt();
		}
		days -= count;
		if(days<0)
			System.out.println(-1);
		else
			System.out.println(days);

	}

}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

long double inp[3000];

long double dp[3000][3000];

long double solve(int ind, int heads) {

    if(ind == -1) {
        if(heads == 0) return 1;
        else return 0;
    }

    if(dp[ind][heads] != -1) return dp[ind][heads];

    long double res = 0;

    if(heads) {
        res = res + inp[ind] * solve(ind - 1, heads - 1);
    }
    res = res + (1-inp[ind]) * solve(ind - 1, heads);

    dp[ind][heads] = res;

    return res;

}

int main(){

    int n;
    cin>>n;

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

    for(int i = 0; i < 3000; i++) {
        for(int j = 0; j < 3000; j++) {
            dp[i][j] = -1;
        }
    }

    long double ans = 0;

    for(int i = 1; i <= n; i++) {
        int heads = i;
        int tails = n - i;
        if(heads > tails) ans += solve(n-1, heads);
    }

    cout<<setprecision(15)<<ans<<endl;


}


Measured memory_bytes: 141184
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<pair<int, int>> v;
	rep(i, n)
	{
		int a, b; cin >> a >> b;
		v.push_back({ a,b });
	}
	sort(all(v), greater<pair<int, int>>());
	int res = 0;
	res = v[0].first + v[0].second;
	cout << res << endl;
}

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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    int res = INF;
    rep(i, (int)s.size() - (int)t.size() + 1) {
        int tmp = 0;
        rep(j, (int)t.size()) {
            if (s[i + j] != t[j]) ++ tmp;
        }
        res = min(res, tmp);
    }

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

Measured memory_bytes: 3656
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
dif = a.zip(b).map{ |aa, bb| aa - bb }.sort.reverse
ans = 0
if i = dif.index{ |x| x < 0 }
  minus = dif[i..-1].reduce(:+)
  ans = -1
  (0...i).each do |j|
    minus += dif[j]
    if minus >= 0
      ans = n - i + 1 + j
      break
    end
  end
end

puts ans

Measured memory_bytes: 22272
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){

  int n;
  int ma,mv;
  int a,v;

  scanf("%d",&n);
  mv=0;
  ma=1;
  for(int i=0;i<n;i++){
    scanf("%d %d",&a,&v);
    if(v>mv){
      ma=a;
      mv=v;
    }
    else if(v==mv && a<ma){
      ma=a;
      mv=v;
    }
  }

  printf("%d %d\n",ma,mv);

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    long double a, b;
    cin(a); cin(b);

    print(ll(floor(a * b)));
    return 0;
}

Measured memory_bytes: 3680
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;
const int maxn = 100000;
int pre[maxn + 10];
int a[maxn + 10];
void solve(long long n, long long l, long long t, vector<long long> x, vector<long long> w)
{
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        if (w[i] == 1) {
            a[i] = (x[i] + t) % l;
            cur += (x[i] + t) / l;
        } else if (w[i] == 2) {
            a[i] = (x[i] - t) % l;
            cur += (x[i] - t) / l;
            if (a[i] < 0) {
                a[i] += l;
                cur--;
            }
        }
    }
    cur = (cur % n + n) % n;
    sort(a, a + n);
    for (int i = cur; i < n; ++i) {
        printf("%d\n", a[i]);
    }
    for (int i = 0; i < cur; ++i) {
        printf("%d\n", a[i]);
    }
}

int main()
{
#ifdef WAAUTOMATON
    // freopen("in.txt","r",stdin);
#endif
    long long L;
    long long T;
    long long N;
    scanf("%lld", &N);
    vector<long long> W(N - 1 + 1);
    vector<long long> X(N - 1 + 1);
    scanf("%lld", &L);
    scanf("%lld", &T);
    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &W[i]);
    }
    solve(N, L, T, X, W);
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

ll a[100010],d[100010];

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

	const ll tsum=1LL*n*(n+1)/2LL;
	rep(i,n) cin >> a[i];
	ll asum=0LL;
	rep(i,n) asum+=a[i];
	
	bool ok=true;
	if(asum%tsum) ok=false;
	ll k=asum/tsum;

	rep(i,n) d[i]=a[(i+1)%n]-a[i];

	rep(i,n) if(d[i]>k or (k-d[i])%n) ok=false;

	
	if(ok)
		puts("YES");
	else
		puts("NO");

	
	return 0;
}

Measured memory_bytes: 1792
D = gets.to_i
c = gets.split.map &:to_i
s = Array.new
D.times do
  s << gets.split.map(&:to_i)
end
t = []
D.times do
  t << gets.to_i
end

last = Array.new(26){[0, false]}



def cal_dec(c, last, day)
  sum = 0
  for i in 0..25
    sum += c[i] * (day - last[i][0])
  end
  sum
end



point = 0
for day in 1..D
  point += s[day-1][t[day-1]-1]
  last[t[day-1]-1][1] = true
  last[t[day-1]-1][0] = day
  point -= cal_dec(c, last, day)
  puts point
end


Measured memory_bytes: 14468
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();

    let mut i = 1;
    loop {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            i += 1;
            if i <= n {
                continue;
            } else {
                break;
            }
        }
        loop {
            if x % 10 == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x == 0 {
                break;
            }
        }
        i += 1;
        if i <= n {
            continue;
        } else {
            break;
        }
    }
    println!("");
}


Measured memory_bytes: 5036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    cout << (1000 - N%1000)%1000 << endl;

    return 0;
}


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

int64_t N, A, B;
vector<int64_t> hs;

/// Returns ceil(x / y).
int64_t ceilDiv(int64_t x, int64_t y) { return (x + y - 1) / y; };

bool enough(int64_t T) {
  int64_t n_needs = 0;
  for (auto& h : hs) {
    if (h > B * T) {
      n_needs += ceilDiv(h - B * T, A - B);
    }
  }
  // cout << boolalpha << (n_needs <= T) << endl;
  return n_needs <= T;
}

int main() {
  cin >> N >> A >> B;
  hs = vector<int64_t>(N);
  for (auto& h : hs) cin >> h;
  int64_t left = 0;
  int64_t right = *max_element(hs.begin(), hs.end()) + 1;
  int64_t mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    // cout << "mid=" << mid << endl;
    // print64_tf("%d %d %d\n", mid, left, right);
    if (enough(mid))
      right = mid;
    else
      left = mid;
  }
  cout << right << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <bitset>
using namespace std;
bitset<2000025> sum1, sum2;
int a[2005];
int main()
{
    int n, i, rea = 0, j = 2000005, ans;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i)
    {
        scanf("%d", a + i);
        rea += a[i];
    }
    sum1[0] = 1, sum2[0] = 1;
    for(i = 1; i <= n / 2; ++i)
        sum1 |= sum1 << a[i];
    for(i = n; i > n / 2; --i)
        sum2 |= sum2 << a[i];
    i = 0, ans = rea;
    while(i < 2000005 && ~j)
    {
        if(!sum1[i]) ++i;
        else if(!sum2[j]) --j;
        else if(i + j < (rea + 1) / 2) ++i;
        else
        {
            if(ans > i + j) ans = i + j;
            --j;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

#define M 1000005
#define MOD 1000000007
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;

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

//    freopen("input.txt","rt",stdin);

    int s,w;
    cin>>s>>w;
    
    if(w>=s)
        cout<<"unsafe\n";
    else
        cout<<"safe\n";

}



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


int main(){
  
  ll x,k,d; cin>>x>>k>>d;
  if(x<0) x*=-1;
  double lk = log10(k);
  double ld = log10(d);
  double lx = log10(x);
  if(lk + ld > lx + 0.01){
    k -= x/d;
    x = x%d;
    if(k%2){
      cout << d-x <<endl;
    }
    else cout << x << endl;
  }
  else if(d*k<x){
    cout << x-d*k<<endl;
  }
  else {
    k -= x/d;
    x = x%d;
    if(k%2){
      cout << d-x <<endl;
    }
    else cout << x << endl;
  }
  
  
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n,k;
  	ci(n>>k);
  vll A(n);
  ll one=0;
  FOR(i,0,n){
    ci(A[i])
    if(A[i]==1){
      one=i;
    }
  }  
  ll ans=1;
  vll B(k);  
  FOR(i,0,k){
    if((one+k-i)>n||(one-i)<0){
      continue;
    }
    else{
    B[i]+=(one+k-2-i)/(k-1);
    B[i]+=(n-one-2+i)/(k-1);
      B[i]++;
    }
  }  
  SORT(B);
      FOR(i,0,n){
        if(B[i]==0){
          continue;
        }
        else{
          co(B[i])
            break;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  vector<int> S(N);  //12...Nの並び
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    S[i] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  int count = 0;
  int p, q;
  vector<bool> check = {false, false};
  do {
    count++;
    if (P == S) {
      p = count;
      check[0] = true;
    }
    if (Q == S) {
      q = count;
      check[1] = true;
    }
    if (check[0] && check[1]) {
      break;
    }
  } while(next_permutation(S.begin(), S.end())); //Sで全列挙
  cout << abs(p - q) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 1123456789;
LL N, K, cou, ans;

int main()
{
	in >> N >> K;
	std::vector<LL>x(N), y(N);
	rep(i, N) in >> x[i] >> y[i];
	ans = 4123456789012345678;
	rep(i, N)
	{
		rep(j, N)
		{
			rep(k, N)
			{
				rep(l, N)
				{
					LL minX = std::min({ x[i],x[j],x[k],x[l] });
					LL maxX = std::max({ x[i],x[j],x[k],x[l] });
					LL minY = std::min({ y[i],y[j],y[k],y[l] });
					LL maxY = std::max({ y[i],y[j],y[k],y[l] });
					cou = 0;
					rep(m, N)
					{
						if (minX <= x[m] && x[m] <= maxX && minY <= y[m] && y[m] <= maxY) ++cou;
					}
					if (cou >= K) ans = std::min(ans, (maxX - minX)*(maxY - minY));
				}
			}
		}
	}
	out << ans << std::endl;
	return 0;
}


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

int D, N;

int main(void){
    
    cin >> D >> N;
    
    if(D == 0) cout << ((N == 100) ? 101 : N) << endl;
    else if(D == 1) cout << ((N == 100) ? 10100 : N * 100) << endl;
    else cout << ((N == 100) ? 1010000 : N * 10000) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;

public class Main {



    public static void main(String[] args) throws Exception {
        IO io = new IO(null, null);
        int n = io.getNextInt();
        long [] A = new long[n];
        long [] B = new long[n];
        for (int i = 0;i < n;i++) {
            A[i] = io.getNextLong();
            B[i] = io.getNextLong();
        }
        long ans = 0;
        for (int i = n-1;i >= 0;i--) {
            long a = A[i] + ans,b = B[i];
            if (a%b != 0)
                ans += b-a%b;
        }
        io.println(ans);
        io.close();
    }

    private static final int onebillion7 = 1000000007;
}



class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}

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

int main(){
  int N; 
  cin >> N;
  vector<int> A(N);
  int n=0;
for(int i=0;i<A.size();i++){
  cin >> A.at(i);
for(int j=0;j<=i;j++){
  if(A.at(i)<A.at(j)){
    break;
  }
  if(j==i){
  n++;
  }
  }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,X = 0;
  string S;
  cin >> N >> S;
  map<char,ll> Aq;
  map<char,ll> Bq;
  rep(I,S.size()-1){
    ll ans = 0;
    Aq.clear();
    Bq.clear();
    rep(J,I+1){
      Aq[S[J]]++;
    }
    rep(K,N-1-I){
      Bq[S[K+I+1]]++;
    }
    if(Aq['a'] > 0 && Bq['a'] > 0)ans++;
    if(Aq['b'] > 0 && Bq['b'] > 0)ans++;
    if(Aq['c'] > 0 && Bq['c'] > 0)ans++;
    if(Aq['d'] > 0 && Bq['d'] > 0)ans++;
    if(Aq['e'] > 0 && Bq['e'] > 0)ans++;
    if(Aq['f'] > 0 && Bq['f'] > 0)ans++;
    if(Aq['g'] > 0 && Bq['g'] > 0)ans++;
    if(Aq['h'] > 0 && Bq['h'] > 0)ans++;
    if(Aq['i'] > 0 && Bq['i'] > 0)ans++;
    if(Aq['j'] > 0 && Bq['j'] > 0)ans++;
    if(Aq['k'] > 0 && Bq['k'] > 0)ans++;
    if(Aq['l'] > 0 && Bq['l'] > 0)ans++;
    if(Aq['n'] > 0 && Bq['n'] > 0)ans++;
    if(Aq['o'] > 0 && Bq['o'] > 0)ans++;
    if(Aq['p'] > 0 && Bq['p'] > 0)ans++;
    if(Aq['q'] > 0 && Bq['q'] > 0)ans++;
    if(Aq['r'] > 0 && Bq['r'] > 0)ans++;
    if(Aq['s'] > 0 && Bq['s'] > 0)ans++;
    if(Aq['t'] > 0 && Bq['t'] > 0)ans++;
    if(Aq['u'] > 0 && Bq['u'] > 0)ans++;
    if(Aq['v'] > 0 && Bq['v'] > 0)ans++;
    if(Aq['w'] > 0 && Bq['w'] > 0)ans++;
    if(Aq['x'] > 0 && Bq['x'] > 0)ans++;
    if(Aq['y'] > 0 && Bq['y'] > 0)ans++;
    if(Aq['z'] > 0 && Bq['z'] > 0)ans++;
    if(Aq['m'] > 0 && Bq['m'] > 0)ans++;
    X = max(X,ans);
  }
  cout << X;
}

Measured memory_bytes: 3572
import math as m
A,B,H,M = map(int,input().split())
hour_angle =(30*H+0.5*M)
minute_angle =(6*M)
hour_X = float('{:.12f}'.format(m.sin(m.radians(hour_angle))))*A
hour_Y = float('{:.12f}'.format(m.cos(m.radians(hour_angle))))*A
minute_X = float('{:.12f}'.format(m.sin(m.radians(minute_angle))))*B
minute_Y = float('{:.12f}'.format(m.cos(m.radians(minute_angle))))*B
#print(hour_X,hour_Y,minute_X,minute_Y)
print(m.sqrt((hour_X-minute_X)**2+(hour_Y-minute_Y)**2))

Measured memory_bytes: 9480
from __future__ import division, print_function
import sys
from collections import deque
INFTY = 1<<30
a = [None] * 2000001
h = 0
ret = deque([]) 

def maxHeapify(i):
    global a, h
    l = 2 * i
    r = 2 * i + 1
    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapify(largest)

def extract():
    global a, h
    if h < 1:
        return -INFTY
    maxv = a[1]
    a[1] = a[h]
    h -= 1
    maxHeapify(1)
    return maxv
    
def increaseKey(i, k):
    global a
    if k < a[i]:
        return
    a[i] = k
    while i > 1 and a[i//2] < a[i]:
        a[i], a[i//2] = a[i//2], a[i]
        i = i // 2

def insert(k):
    global a, h
    h += 1
    a[h] = -INFTY
    increaseKey(h, k)

for com in sys.stdin.readlines():
    if com[0] == "i":
        insert(int(com[7:]))
    elif com[1] == "x":
        ret.append(extract()) 
    else:
        print("\n".join([str(s) for s in list(ret)]))
        # print()

Measured memory_bytes: 214516
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1 == m2)
        cout<<0;
    else
        cout<<1;
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ''
ans += 'R'*x
ans += 'U'*y
ans += 'L'*x
ans += 'D'*y
ans += 'DR'
ans += 'R'*x
ans += 'U'*y
ans += 'UL'
ans += 'UL'
ans += 'L'*x
ans += 'D'*y
ans += 'DR'
print(ans)

Measured memory_bytes: 3064
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "d.cpp"

// https://ei1333.github.io/luzhiled/snippets/math/divisor.html
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
 
int main() {
  ll n;
  cin >> n;
  vl a(n);
  cin >> a;

  vl cnt(1e6+1);
  for (auto&& i : a) {
    cnt[i]++;
  }
 
  ll ans = n;
  for (auto&& i : a) {
    auto v = divisor(i);
    for (auto&& j : v) {
      if (cnt[j] >= 2 or (cnt[j] == 1 and i != j)) {
        ans--;
        break;
      }
    }
  }
  cout << ans << el;
}


Measured memory_bytes: 12708
N=gets.to_i
a=Array.new(10,0).map{|i| i=Array.new(10,0)}
count=0
(1..N).each do |i|
  a[i.to_s[0].to_i][i.to_s[-1].to_i]+=1
  if i.to_s[0]==i.to_s[-1]
    count+=(a[i.to_s[-1].to_i][i.to_s[0].to_i]*2)-1
  else
    count+=(a[i.to_s[-1].to_i][i.to_s[0].to_i]*2)
  end
end

puts count

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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  if( a <= 5  ){
    
    cout << 0 << endl;
    
  }
  
  else if( a >= 6 && a <= 12 ){
    
    cout << b/2 << endl;
    
  }
  
  else{
    
    cout << b << endl;
    
  }
  
}

Measured memory_bytes: 3604