akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }



int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_v(h, w, INF<int>);
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if(s[j] == 'c'){
                for (int k = j; k < w; ++k) {
                    if(s[k] == 'c' && j != k)  {
                        j = k-1;
                        break;
                    }
                    v[i][k] = min(v[i][k], k-j);
                }
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(j) cout << " ";
            cout << (v[i][j] == INF<int> ? -1 : v[i][j]);
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3272
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

N = input()

for i in range(N):
    lst = []
    while len(lst) < 9:
        lst_ = raw_input().split()
        for S in lst_:
            lst.append(int(S, 16))
    res = lst[8]
    lst = lst[:8]
    diff = (sum(lst) - res) % (1 << 32)
    diff_lst = []
    for i in range(32):
        D = 0
        for j in lst + [((1 << 32) - 1) ^ res]:
            if j & (1 << i) == 0:
                D += (1 << i)
            else:
                D -= (1 << i)
        D %= (1 << 32)
        diff_lst.append((D, 1 << i))
    L1 = [(diff, 0)]
    for i in range(16):
        P = diff_lst[i]
        L = []
        for p in L1:
            L.append(((p[0] + P[0]) % (1 << 32), p[1] + P[1]))
        L1 += L
    L2 = [[0, 0]]
    for i in range(16, 32):
        P = diff_lst[i]
        L = []
        for p in L2:
            L.append(((p[0] + P[0]) % (1 << 32), p[1] + P[1]))
        L2 += L
    L1.sort()
    L2.sort()
    if L1[0][0] == 0:
        print hex(L1[0][1])[2:]
        continue
    pos = len(L2) - 1
    for p in L1:
        while p[0] + L2[pos][0] > (1 << 32):
            pos -= 1
        if p[0] + L2[pos][0] == (1 << 32):
            print hex(p[1] + L2[pos][1])[2:]
            break


Measured memory_bytes: 22500
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll a = N / K;
    cout << min(N, min(abs(N - K * a), abs(N - K * (a + 1)))) << endl;
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int rsl = 0;
  rep(i, 0, 1000) {
    int c[3] = {i / 100, (i / 10) % 10, i % 10};
    int idx = 0;
    rep(j, 0, n) {
      if(s[j] == ('0' + c[idx])) ++idx;
      if(idx == 3) break;
    }
    if(idx == 3) ++rsl;
  }
  cout << rsl << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <map>

using namespace std;

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

    int x, y;
    pair<int, int> P[N];
    for(int i = 0; i < N; i++) {
        cin >> x >> y;
        P[i] = make_pair(x, y);
    }

    int x_diff, y_diff, cnt=0;
    map<pair<int, int>, int> dic;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(i == j) continue;
            x_diff = P[i].first - P[j].first;
            y_diff = P[i].second - P[j].second;
            if(dic.find(make_pair(x_diff, y_diff)) == dic.end()) {
                dic[make_pair(x_diff, y_diff)] = 1;
            } else {
                dic[make_pair(x_diff, y_diff)] += 1;
            }
            cnt = max(cnt, dic[make_pair(x_diff, y_diff)]);
        }
    }

    cout << N - cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
class lazy_segment_tree{
    private:
        static int calc_size(int n){
            int m = 1;
            while(m < n){
                m *= 2;
            }
            return m;
        }

        void eval(int i, int l, int r){
            if(lazy[i] != 0){
                node[i] += lazy[i];
                if(r - l > 1){
                    lazy[i * 2 + 1] += lazy[i] / 2;
                    lazy[i * 2 + 2] += lazy[i] / 2;
                }
                lazy[i] = 0;
            }
        }

        void add(int s, int t, int x, int i, int l, int r){
            eval(i, l, r);

            if(t <= l || r <= s){
                return;
            }

            if(s <= l && r <= t){
                lazy[i] += (r - l) * x;
                eval(i, l, r);
                return;
            }

            int m = l + (r - l) / 2;
            add(s, t, x, 2 * i + 1, l, m);
            add(s, t, x, 2 * i + 2, m, r);
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }

        T query(int s, int t, int i, int l, int r){
            eval(i, l, r);

            if(t <= l || r <= s){
                return init;
            }

            if(s <= l && r <= t){
                return node[i];
            }

            int m = l + (r - l) / 2;
            T vl = query(s, t, i * 2 + 1, l, m);
            T vr = query(s, t, i * 2 + 2, m, r);
            return f(vl, vr);
        }

    public:
        int n;
        vector<T> node, lazy;
        T init;
        function<T(T, T)> f;

        lazy_segment_tree(int n, T init, function<T(T, T)> f)
            : n(calc_size(n)), node(calc_size(n) * 2, init) , lazy(calc_size(n) * 2, 0), init(init), f(f) {}

        void update(int i, const T& x){
            node[i + n] = x;
            for(int j = (i + n) / 2; j > 0; j /= 2){
                node[j] = f(node[j * 2], node[j * 2 + 1]);
            }
        }

        T query(int s, int t){
            return query(s, t, 0, 0, n);
        }

        void add(int s, int t, int x){
            add(s, t, x, 0, 0, n);
        }
};

signed main(){
    int n, q;
    cin >> n >> q;

    lazy_segment_tree<int> lst(n+1, 0, [](int a, int b){return a+b;});
    rep(i, q){
        int que, s, t;
        cin >> que >> s >> t;

        if(que == 0){
            int x;
            cin >> x;
            lst.add(s, t+1, x);
        }else{
            cout << lst.query(s, t+1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 7080
#include <stdio.h>

int cnt;

void dp(char fld[20][20], int y, int x)	{
	
	fld[y][x] = '#';
	cnt++;
	///
	//printf("%d %d\n", x, y);
	///
	
	for (int dy = -1; dy <= 1; dy++)	{
		for (int dx = -1; dx <= 1; dx++)	{
			if (dy != 0 && dx != 0)	continue;
			if (y + dy < 0 || y + dy >= 20 || x + dx < 0 || x + dx >= 20)	continue;
			
			if (fld[y+dy][x+dx] == '.')	{
				dp(fld, y+dy, x+dx);
			}
		}
	}	
}

int main()	{
	
	int w, h, cy, cx;
	char temp;
	char fld[20][20];
	
	while (true)	{
		
		scanf("%d %d%*c", &w, &h);
		if (w == 0)	break;
		
		// initialize
		for (int y = 0; y < 20; y++)	{
			for (int x = 0; x < 20; x++)	{
				fld[y][x] = '#';
			}
		}
		
		for (int i = 0; i < h; i++)	{
			///
			//printf("%d列目\n", i);
			///
			for (int j = 0; j < w; j++)	{
				scanf("%c", &temp);
				fld[i][j] = temp;
				
				if (temp == '@')	{
					cy = i;
					cx = j;
				}
			}
			scanf("%*c");
		}
		
		/*
		for (int y = 0; y < 20; y++)	{
			printf("%2d: ", y);
			for (int x = 0; x < 20; x++)	{
				printf("%c", fld[y][x]);
			}
			printf("\n");
		}
		*/
		
		cnt = 0;
		
		dp(fld, cy, cx);
		
		printf("%d\n", cnt);
	}
	
	return 0;
}


Measured memory_bytes: 2624
import collections
n = int(input())
s = str(input())
rn = collections.Counter(s)['R']
gn = collections.Counter(s)['G']
bn = collections.Counter(s)['B']
ans = rn*gn*bn
if ans == 0:
     print(0)
elif n==3 and ans ==1:
     print(0)
elif n%2==0:
     for i in range(1,n//2):
          for j in range(n-2*i):
               if s[j] != s[j+i] and s[j+2*i] != s[j+i] and s[j] != s[j+2*i]:
                    ans-=1
     print(ans)
else:
     for i in range(1,n//2+1):
          for j in range(n-2*i):
               if s[j] != s[j+i] and s[j+2*i] != s[j+i] and s[j] != s[j+2*i]:
                    ans-=1
     print(ans)

Measured memory_bytes: 9476
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    set<int> ds;
    for(int i = 0; i < n; i++){
        int d; cin >> d;
        ds.insert(d);
    }
    cout << ds.size() << '\n';
}


Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int t = 0;
    while (b <= a) {
        b *= 2;
        ++t;
    }
    while (c <= b) {
        c *= 2;
        ++t;
    }
    if (t <= k) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



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


Measured memory_bytes: 3044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        int[] member = new int[n[0]];
        for(int i = 0; i < n[1]; i++)
        {
            int nn = int.Parse(ReadLine());
            var m = ReadLine().Split().Select(int.Parse).ToArray();
            for(int j = 0; j < nn; j++)
            {
                member[m[j] - 1]++;
            }
        }
        int count = member.Count(a => a == 0);
        WriteLine($"{count}");
    }
}


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

int main() {

    char s[101];
    scanf("%s", s);

    int l = strlen(s);
    for (int i = 0; i < l; i++) {
        printf("%c", 'x');
    }


    return 0;

}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, A, B;
  std::cin >> N >> A >> B;
  std::cout << (std::abs(A - B) % 2 == 0 ? "Alice" : "Borys") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e12
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;
  
 if(n>=30)
 cout<<"Yes\n";
 else
 cout<<"No\n";
  
  
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3648
main :: IO()
main = do
    let arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    n <- readLn
    print $arr !! (n-1)

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	map<ll, ll> cnt;
	for (int i = 1; i <= n; i++) {
		ll x = i, k = 2;
		while (x > 1) {
			while (x % k == 0) {
				cnt[k]++;
				x /= k;
			}
			k++;
		}
	}
	ll res = 1;
	for (auto x : cnt) {
		res = ((res % mod) * ((x.second + 1) % mod)) % mod;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}


ll power(ll base, ll exp) {
	ll ans = 1;
	base %= MOD;
	while (exp > 0) {
		if (exp & 1) ans = (ans * base) % MOD;
		exp >>= 1;
		base = (base * base) % MOD;
	}
	return ans;
}

ll modInverse(ll a) { return power(a, MOD - 2); }

const int N = 2000010;
ll fact[N];

void init() {
	fact[0] = 1;
	for (int i = 1; i < N; ++i) fact[i] = (fact[i - 1] * 1LL * i) % MOD;
}

ll nCr(ll n, ll r) {
	return (fact[n] * modInverse(fact[r] * 1LL * fact[n - r])) % MOD;
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double angle1 = h * 30;
	angle1 += m / 60.0 * 30;
	double angle2 = m * 6;
	double angle = abs(angle1 - angle2);
	if (angle > 180) angle = 360 - angle;
	//cout << angle << endl;
	printf("%0.20f\n", sqrt(a*a + b*b - 2 * a*b*cos(angle*PI / 180.0)));
	


	return 0;
}


Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)
#define ll long long

int main()
{
    string s;
    cin >> s;
    if(s.size()%2==0){
        for(int i=0;i<s.size();i+=2){
            if(s[i]=='h' && s[i+1]=='i'){
                continue;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
AB=[]
C=[]

for i in range(M):
    AB.append(list(map(int,input().split())))
    C.append(list(map(int,input().split())))
    
DP=[float("inf")]*((1<<N))
DP[0]=0
for i in range(M):
    for j in range(1<<N):
        bitscore=0
        for k in C[i]:
            bitscore+=(1<<(k-1))

        DP[j|bitscore]=min(DP[j]+AB[i][0],DP[j|bitscore])

if DP[-1]==float("inf"):
    print(-1)
else:
    print(DP[-1])


Measured memory_bytes: 46428
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    int k; cin >> k;
    rep(i,n) {
        if (s[i] == 'a') continue;
        int plus = 'z' - s[i] + 1;
        if (k >= plus) {
            k -= plus;
            s[i] = 'a';
        } 
    }
    k %= 26;
    s[n-1] += k;
    cout << s << endl;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main{

	public static void main(String[] arg){
    
      	Scanner sc=new Scanner(System.in);
      
      	int a=sc.nextInt();
      	int b=sc.nextInt();
      
      	int mult=a*b;
      
      	if(mult%2==0){
        	System.out.println("Even");
        }else{
        	System.out.println("Odd");
        }
    
    }
  
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int a;
	a = (B - A) % 2;
	if (a == 1) {
		cout << "Borys" << endl;

	}
	else {
		cout << "Alice" << endl;
	}

}

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

// Union-Find
vector<int> par(100010); //親の番号

// 初期化
void init(int n){
  for(int i=0; i<n; i++) par[i] = i;
}

// 頂点xに対応する木の根を見つける
int root(int x){
  if (par[x] == x){
    return x;
  } else {
    return par[x] = root(par[x]);
  }
}

// 頂点xの木と頂点yの木を統合
void unite(int x, int y){
  x = root(x); y = root(y);
  if (x == y) return;

  par[x] = y;
}

int main(){
  int N, M; cin >> N >> M;
  init(N);

  for(int i=0; i<M; i++){
    int x, y, z; cin >> x >> y >> z;
    unite(x-1,y-1);
  }

  set<int> A;
  for(int i=0; i<N; i++){
    A.insert(root(i));
  }

  cout << A.size() << endl;
}

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

int main(void){
    int rate, kyu;
    cin >> rate;
    
    for(int r = 600, k = 8;k > 0;r += 200, k -= 1) {
        if (rate < r) {
            kyu = k;
            break;
        }
    }
    
    cout << kyu << endl;
    return 0;    
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    //答えansを仮置きする。
    //これが十分に大きくないと不正解となるので、
    //この値なら絶対に正しい答えが出る、という値を仮置きすること
    int ans = T.size();
 
    //Sの何文字目から調べるかを全探索する
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << "\n";
    return(0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

int mindiv[1000100];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    mindiv[2] = 2;
    for (int i=4; i<1000100; i+=2) mindiv[i] = 2;
    for (int i=3; i<1000100; i+=2) {
        if (mindiv[i]) continue;
        mindiv[i] = i;
        for (int j=i*i; j<1000100; j+=i*2) {
            mindiv[j] = i;
        }
    }
    int n; cin>>n;
    int res = 0;
    for (int i=1; i<n; i++) {
        int a = n-i;
        int tmp = 1;
        while (a > 1) {
            int d = mindiv[a];
            int cnt = 0;
            while (a % d == 0) {
                a /= d;
                cnt++;
            }
            tmp *= cnt+1;
        }
        res += tmp;
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 11456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int a = Integer.parseInt(br.readLine());
            int b = Integer.parseInt(br.readLine());
            int c = Integer.parseInt(br.readLine());
            int x = Integer.parseInt(br.readLine());
            int ans = 0;
            for (int i = 0; i <= a; i++) {
                for (int j = 0; j <= b; j++) {
                    for (int k = 0; k <= c; k++) {
                        int temp = 500 * i + 100 * j + 50 * k;
                        if (x == temp) {
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
            {
                WriteLine("Bad");
            }
            else
            {
                WriteLine("Good");
            }
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        static long fibonacci(int n)
        {
            switch (n)
            {
                case 0:
                case 1:
                    return n;
                default:
                    return fibonacci(n - 2) + fibonacci(n - 1);
            }
        }
    }
}


Measured memory_bytes: 11092
def main():
    mod = 10**9+7
    n, c = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    dp = [0]*(c+1)
    dp[0] = 1
    ans = 0

    p = [[0]*(401) for _ in [0]*401]  # p[i][j]でj^i
    for i in range(401):
        for j in range(401):
            p[i][j] = pow(j, i, mod)

    for a, b in zip(A, B):
        dp2 = [0]*(c+1)
        q = [0]*(c+1)
        for i in range(c+1):
            q[i] = sum(p[i][a:b+1]) % mod
        for i in range(c+1):
            temp = 0
            for j in range(i+1):
                temp += dp[i-j]*q[j]
            dp2[i] = temp % mod
        dp = dp2
    ans += dp[-1]
    print(ans % mod)


main()

Measured memory_bytes: 60764
//Similar to matrix multiplication

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

using ll = long long;

const int nax = 405;
const ll INF = 1e18L + 5; // 10^18+5
ll dp[nax][nax];
// dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    auto sum = [&](int L, int R) {
        ll s = 0;
        for(int i = L; i <= R; ++i) {
            s += a[i];
        }
        return s;
    };
    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = 0;
            }
            else {
                dp[L][R] = INF;
                ll s = sum(L, R);
                for(int i = L; i <= R - 1; ++i) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
                }
            }
        }
    }
    
    printf("%lld\n", dp[0][n-1]);
}

Measured memory_bytes: 5028
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
int ze,on,tw;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		if(m%4==0){
			tw++;
		}else if(m%2==0){
			on++;
		}else{
			ze++;
		}
	}
	if(on==0){
		if(tw+1>=ze){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(tw>=ze){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import math


def main():
    a = list(input())
    b = defaultdict(int)

    for ele in a:
        b[ele] += 1

    if len(b) == 2:
        aaa = list(b.values())
        if aaa[0] == aaa[1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')






if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
  int R, C;
  string S[128];
  int hash[1 << 16];
  for(int i = 0; i < 1 << 16; i++) hash[i] = __builtin_popcount(i);

  cin >> R >> C;
  for(int i = 0; i < R; i++) cin >> S[i];

  int dp1[1 << 16], dp2[1 << 16];
  memset(dp1, -1, sizeof(dp1));
  int *latte = dp1, *malta = dp2;
  latte[0] = 0;
  for(int y = 0; y < R; y++) {
    for(int x = 0; x < C; x++) {
      for(int j = 0; j < 1 << C; j++) malta[j] = -1;
      for(int j = 0; j < 1 << C; j++) {
        if(latte[j] == -1) continue;

        auto ch = [&](int &a, int b)
        {
          a = max(a, b);
        };

        const int beet = hash[j & ((1 << x) - 1)];
        if(beet + C - x > S[y].size()) {
          ch(malta[j & ~(1 << x)], latte[j]);
        }
        if(beet < S[y].size()) {
          int point = 0;
          if(x && (j >> (x - 1)) & 1) {
            if(beet && S[y][beet] == S[y][beet - 1]) ++point;
          }
          if(y && (j >> x) & 1) {
            int pos = (int) S[y - 1].size() - hash[j >> x];
            if(pos >= 0 && S[y - 1][pos] == S[y][beet]) ++point;
          }
          ch(malta[j | (1 << x)], latte[j] + point);
        }
      }
      swap(latte, malta);
    }
  }
  cout << *max_element(begin(dp1), end(dp1)) * 2 << endl;
}

Measured memory_bytes: 3944
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w,k=map(int,input().split())
    S=[input() for _ in range(h)]
    final_ans=10**10
    for row_lis in range(1<<(h-1)):
        lst=[0]*h
        q,ans=0,0
        for r in range(h-1):
            if (row_lis>>r)&1==0:
                lst[r+1]=q
            else:
                q+=1
                lst[r+1]=q
                ans+=1
        data=[0]*h
        for j in range(w):
            for i in range(h):
                data[lst[i]]+=int(S[i][j])
                if data[lst[i]]>k:
                    ans+=1
                    break
            else:
                continue
            data=[0]*h
            for i in range(h):
                data[lst[i]]+=int(S[i][j])
                if data[lst[i]]>k:
                    break
            else:
                continue
            break
        else:
            final_ans=min(final_ans,ans)
    print(final_ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

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

const int N = 2e5+5;

void solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int cnt=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				vector<int>v={a[i],a[j],a[k]};
				sort(all(v));
				if(i^j && i^k && j^k && v[0]+v[1]>v[2] && v[0]^v[1] && v[0]^v[2] && v[1]^v[2])cnt++;
			}
		}
	}
	cout<<cnt;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while (T--)solve();
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;char op;cin >> a >> op >> b;
    cout << (op == '+' ? a+b : a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;

int main(void){
    int n;
    int a=0,w=0,t=0,r=0;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(s == "AC")a++;
        if(s == "WA")w++;
        if(s == "TLE")t++;
        if(s == "RE")r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

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

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

const int INF = 1001001001;

int d[2010][2010];
int cnt[2010];

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;

  REP(i, 0, n-2){
    REP(j, i+1, n-1){
      d[i][j] = j - i;
      if(i <= x && x < j){
        chmin(d[i][j], (x-i)+1+abs(y-j));
      }
      if(i > x){
        chmin(d[i][j], (i-x)+1+abs(y-j));
      }
      cnt[d[i][j]]++;
    }
  }

  REP(k, 1, n-1){
    cout << cnt[k] << endl;
  }

  return 0;
}


Measured memory_bytes: 15360
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    print("Possible" if (a + b) % 3 == 0 or a % 3 == 0 or b % 3 == 0 else "Impossible")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int N = 1000000 + 5;

int main(){
    fast;
    ll n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; ++i)
        cin >> s[i];
    sort(s, s+n);
    ll c = 0;
    for(int i = 0; i < n-1; ++i){
        if(s[i] != s[i+1])
            ++c;
    }
    cout << c+1;
    return 0;
}
//                                     #!!{*[$um1t_Kum@r]*}!!#


Measured memory_bytes: 9908
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define FOR(i,s,n) for(ll (i)=(s);(i)<=(n);(i)++)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
  string s;
  cin >> s;
  if(s=="ABC"){
      cout << "ARC" << endl;
  }else{
      cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3592
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        char[] t = in.ns().toCharArray();
        int ans = 0;
        for (int i = 0; i < s.length; i++) {
            if(s[i]!=t[i])ans++;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 37784
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a,b,p[105],c1,c2,c3;
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		if(p[i]<=a)
			c1++;
		else if(p[i]>a&&p[i]<=b)
			c2++;
		else
			c3++;
	}
	cout<<min(c1,min(c2,c3));
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
int main()
{

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

    stack<int>s;
    vector<int>p;

    long long int l = 0;
    for(int i = 0;i<n;i++)
    {

        if(s.empty() || s.top()<= arr[i])
        {
            s.push(arr[i]);
            p.push_back(arr[i]);
        }
        else
        {

            int ans = arr[i];
            //cout<<s.size()<<"\n";
            while(!s.empty() && s.top()>arr[i])
            {

                ans = max(ans,s.top());
                s.pop();
            }
            ans = max(ans,arr[i]);
            p.push_back(ans);

            s.push(ans);

        }
    }


    l = 0;
    for(auto i = 0;i<n;i++)
    {
        l = l+(p[i]-arr[i]);
    }
    cout<<l;
    return 0;
}


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

int main(void){
    int a,b,c,t;
    cin >> a >> b >> c;
    
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    if (a > c){
        t = b;
        b = a;
        a = c;
        c = t;
    }else if(b > c){
        t = b;
        b = c;
        c = t;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll dp[200000][2];
vector<int>E[200000];

void dfs(int v,int p){
	int cnt=0;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v);
		cnt++;
	}
	if(cnt==0){
		dp[v][0]=dp[v][1]=1;
		return;
	}
	dp[v][0]=dp[v][1]=1;
	for(int u:E[v]){
		if(u==p)continue;
		(dp[v][0]*=dp[u][1])%=MOD;
		(dp[v][1]*=(dp[u][0]+dp[u][1]))%=MOD;
	}
}
int main(){
	int n;scanf("%d",&n);
	rep(i,n-1){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	dfs(0,-1);
	cout<<(dp[0][0]+dp[0][1])%MOD<<endl;
}

Measured memory_bytes: 16512
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N;
    cin >> N;
    int m = 0,n = 0,i = 0,x;
    while(i < N){
        cin >> x;
        if(x >= m){
            m = x;
            n++;
        }
        i++;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002

map<int,int> dp[MAX_N];
vector<edge> G1[MAX_N],G2[MAX_N],G3[1000002];
int dp1[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;

int main() {

	int n,m;
	cin>>n>>m;
	rep(i,MAX_N)dp1[i]=inf;
	rep(i,m){
		int c1,p1,q1;
		scanf("%d %d %d",&p1,&q1,&c1);
//		cin>>p1>>q1>>c1;
		G1[p1].push_back(edge{-1,q1,c1,1});
		G1[q1].push_back(edge{-1,p1,c1,1});
		G2[p1].push_back(edge{c1,q1,c1,0});
		G2[q1].push_back(edge{c1,p1,c1,0});
		G3[c1].push_back(edge{p1,q1,c1,0});
		G3[c1].push_back(edge{q1,p1,c1,0});
		dp[p1][c1]=inf;
		dp[q1][c1]=inf;
	}
	que.push(P2(0,P1(1,-1)));
	while(!que.empty()){
		P2 pp=que.top();que.pop();

		int cost=pp.first;
		P1 pp2=pp.second;
		int to =pp2.first;
		int c1=pp2.second;

		if(to==n){
			cout<<cost<<endl;
			return 0;
		}
		//		cout<<dp[to][c1]<<" "<<cost<<" "<<to<<" "<<c1<<endl;;
		if(c1!=-1){
			if(dp[to][c1]>cost){
				dp[to][c1]=cost;
				if(G2[to].size()<G3[c1].size()){
					for(auto it:G2[to]){
						if(it.myc!=c1)continue;
						que.push(P2(cost,P1(it.to,it.c)));
					}
				}else{
					for(auto it:G3[c1]){
						if(it.myc!=to)continue;
						que.push(P2(cost,P1(it.to,it.c)));
					}
				}
				que.push(P2(cost,P1(to,-1)));
			}
		}else{
			if(dp1[to]>cost){
				dp1[to]=cost;
				for(auto it:G1[to]){
					que.push(P2(cost+it.cost,P1(it.to,it.c)));
				}
			}
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 87900
#include<stdio.h>

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);
  
  int cnt = 0;
  for (int i = A; i <= B; i++) {
    int a, b, c, d, e;
    a = i/10000;
    b = (i/1000)%10;
    c = (i/100)%10;
    d = (i/10)%10;
    e = i%10;
    if (a == e && b == d) cnt++;
  }
  
  printf("%d", cnt);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split(",");
		sc.close();
		StringBuilder sb = new StringBuilder();
		sb.append(s[0] + " ");
		sb.append(s[1] + " ");
		sb.append(s[2]);
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<cstdio>
using namespace std;
int n;
long long a[120000];
int main()  
{
cin>>n;
for(int i=0;i<n;i++){
	cin>>a[i];
}
long long nowa=0;
long long sum=0;
for(int i=0;i<n;i++){
	sum=sum+a[i];
	if(i%2==0){
		if(sum<=0)
			nowa=nowa+1-sum,sum=1;
	}
	else{
		if(sum>=0)
			nowa=nowa+sum+1,sum=-1;
	}
}
long long ans=nowa;
nowa=0;
sum=0;
for(int i=0;i<n;i++){
	sum=sum+a[i];
	if(i%2==1){
		if(sum<=0)
			nowa=nowa+1-sum,sum=1;
	}
	else{
		if(sum>=0)
			nowa=nowa+sum+1,sum=-1;
	}
}
ans=min(ans,nowa);
cout<<ans;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

#define pi acos(-1)
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double ak = h*30 - m*5.5;
  double res = 0.0;

  res = sqrt(a*a + b*b - 2*a*b*cos(ak*pi/180));
  printf("%.20lf\n", res);
  return 0;
}



Measured memory_bytes: 4172
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;

    double ret = 0;
    for (int i = 1; i <= N; i++){
        double tmp = 1.0 / N;
        int now = i;
        while (now < K){
            now *= 2;
            tmp /= 2;
        }
        ret += tmp;
    }

    printf("%.12f\n", ret);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
S = [0] * N

for i in range(1, N):
  S[i] = min(S[_] + abs(h[i] - h[_]) for _ in range(max(0, i-K), i))

print(S[N-1])


Measured memory_bytes: 20688