akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (int)1e9+1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
int N;
ll x;
vector<ll> a;
vector<ll> b;

//n回魔法使ったときの時間
ll calc(int n) {
    for (int i = 0; i < N; i++) {
        b[i] = min(a[(i - n + N) % N], b[i]);
    }
    return accumulate(b.begin(), b.end(), 0LL) + n * x;
}

int main() {
    cin >> N >> x;
    a = vector<ll>(N);
    b = vector<ll>(N, INF);
    REP(i, 0, N) cin >> a[i];
    ll cost = calc(0);
    REP(i,1,N){
        cost = min(cost,calc(i));
    }
//    int begin = 0;
//    int end = N;
//    int eps = 2;
//    while (begin + eps < end) {
//        int first = (end - begin) / 3 + begin;
//        int second = end - (end - begin) / 3;
//
//        ll first_calc = calc(first);
//        ll second_calc = calc(second);
//        if (first_calc < second_calc) {
//            end = first;
//        } else {
//            begin = second;
//        }
//
//    }
//
//    ll ans = min({calc(begin), calc(begin + 1), calc(end)});
//
//    cout << ans << endl;

    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    sums = [0]
    maxsum = 0
    for i in range(0, N):
        sums.append(p[i] + sums[i])

    for i in range(0, N - K + 1):
        maxsum = max(sums[i + K] - sums[i], maxsum)
    print((maxsum + K) / 2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 33012
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, sz[MAX_N+5]; lnt s[MAX_N+5], tot;
map <lnt, int> id; vector <int> G[MAX_N+5];
void DFS(int u, int d) {tot += d; for (int v : G[u]) DFS(v, d+1);}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(s[i]), id[s[i]] = i, sz[i] = 1;
	sort(s+1, s+n+1, greater<lnt>());
	for (int i = 1; i < n; i++) {
		int u = id[s[i]];
		lnt sf = s[i]-n+2*sz[u];
		if (sf >= s[i] || !id.count(sf))
			return puts("-1"), 0;
		int f = id[sf];
		sz[f] += sz[u];
		G[f].push_back(u);
	}
	DFS(id[s[n]], 0);
	if (tot != s[n])
		return puts("-1"), 0;
	for (int u = 1; u <= n; u++)
		for (int v : G[u]) printf("%d %d\n", u, v);
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int dp[110000];
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    rep(i,n+1)dp[i] = INF;
    dp[0] = 0;
    rep(i,n-1){
        rep(j,k+1){
            if(j == 0)continue;
            if(j+i < n)dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j] - h[i]));

        }
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[] for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i].append((x-1,y))

cnt = 0
for i in range(2**N):
    flag = True
    for j in range(N):
        if (i>>j)&1 == 1:
            for x,y in tes[j]:
                if (i>>x)&1 != y:
                    flag = False
                    break
    if flag:
        cnt = max(cnt,bin(i)[2:].count("1"))
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int n,m;
int a[50],b[50];
bool g[50][50];
bool used[50];

void dfs(int v){
	used[v]=1;
	for(int i=0;i<n;i++){
		if(g[v][i]){
			if(used[i])continue;
			dfs(i);
		}
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		g[a[i]][b[i]]=g[b[i]][a[i]]=1;
	}
	int ans=0;
	for(int i=0;i<m;i++){
		g[a[i]][b[i]]=g[b[i]][a[i]]=0;
		for(int  j=0;j<n;j++){
			used[j]=0;
		}
		dfs(0);
		bool ok=0;
		for(int j=0;j<n;j++){
			if(!used[j])ok=1;
		}
		if(ok)ans++;
		g[a[i]][b[i]]=g[b[i]][a[i]]=1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
E = []
O = []
T = [[0,i] for i in range(10**5+1)]
U = [[0,i] for i in range(10**5+1)]
for i in range(n):
    if i%2 == 0:
        E.append(L[i])
        T[L[i]][0] += 1
    else:
        O.append(L[i])
        U[L[i]][0] += 1
T.sort()
U.sort()
if T[10**5][1] != U[10**5][1]:
    print(n-(T[10**5][0]+U[10**5][0]))
else:
    print(min(n-(T[10**5-1][0]+U[10**5][0]), n-(T[10**5][0]+U[10**5-1][0])))

Measured memory_bytes: 73720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI 3.141592653589793

int main() {
	string s, t;
	cin >> s >> t;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 3912
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    r, g, b = gets.chomp.split.map(&:to_i)

    n = g * 10 + b
    if n % 4 == 0
      puts "YES"
    else
      puts "NO"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  // ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  string s; cin >> s;
  // vector<ll> a(n); REP(i, n) cin >> a[i];
  // ll ans = 0;
  bool ok = false;
  REP(i, s.size()-1) {
    if(s[i] == 'A' && s[i+1] == 'C') ok = true;
  }
  // cout << ans << endl;
  cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

int main() {
    int q, n;
    cin >> q;
    while(q--){
        cin >> n;
        set<int> s;
        int cnt = 0;
        while(n >= 10){
            if(s.count(n)){
                cnt = -1;
                break;
            }
            s.insert(n);
            string t = to_string(n);
            int ans = 0;
            for (int i = 1; i < t.size(); ++i) {
                int x = stoi(t.substr(0, i)), y = stoi(t.substr(i, 10));
                ans = max(ans, x*y);
            }
            n = ans;
            cnt++;
        }
        cout << cnt << "\n";
    }
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


// 階乗や組合わせの場合の数を求める
ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%2019;}
  else return mpow(a,b-1)*a%2019;
}


signed main(){
	string s; cin>>s;
	int n = s.size();
	VI a(n);
	a[0]=s[n-1]-'0';
	VL cnt(2019,0LL);
	cnt[a[0]]++;
	rep(i,n){
		if(i==0) continue;
		int next = s[n-i-1]-'0';
		a[i] = a[i-1]+mpow(10,i)*next;
		a[i] %= 2019;
		cnt[a[i]]++;
		cerr<<a[i]<<' ';
	}
	cerr<<endl;
	ll ans = 0;
	rep(i,2019){
		if(i==0) ans += cnt[i];
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4352
<?php
    list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
    if($a == $b && $a == $c && $b == $c){
        echo 1;
    }
    elseif($a != $b && $a != $c && $b != $c){
        echo 3;
    }
    else{
        echo 2;
    }
?>

Measured memory_bytes: 4604
#include <stdio.h>
#include <iostream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define lt(A,B) ((A>B)?B:A)
#define gt(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

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

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

	for (int i = 0; i < n; ++i) {
		int mini = i;
		for (int j = i; j < n; ++j) {
			if( el[j] < el[mini]){
				mini = j;
			}
		}
		if(i!=mini){
			int c;
			c = el[i];
			el[i] = el[mini];
			el[mini] = c;
			cnt++;
		}
	}

	for (int i = 0; i < n; ++i) {
		if(i > 0) cout << " ";
		cout << el[i];
	}
	cout << endl;
	println(cnt);


	return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p = -1;
    vector<int> v;
    for (int i = 0, x; i < n; i++)
    {
        cin >> x;
        if (x > 0 && p == -1)
            v.pb(0), p = i;
        v.pb(x);
    }
    if (p == -1)
        v.pb(0), p = n;
    int ans = 2e9, st = p;
    while(st >= 0)
    {
        if (st + k > n){
            st--; continue;
        }
        int val = (0 - v[st]) + (v[st + k] == 0 ? 0 : (v[st + k] - v[st]));
        ans = min(ans, val);
        st--;
        if (v[st + k] == 0)
            break;
    }
    st = p;
    while(st <= n)
    {
        if (st - k < 0){
            st++; continue;
        }
        int val = (v[st]) + (v[st - k] == 0 ? 0 : (v[st] - v[st - k]));
        ans = min(ans, val);
        st++;
        if (v[st - k] == 0)
            break;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    map<char, int> s,t;
    for(char c = 'a'; c <='z'; c++){
        s[c]=-1;
        t[c]=-1;
    }
    REP(i, S.size()){
        s[S[i]]++;
        t[T[i]]++;
    }
    bool flag = true;
    for(char c = 'a'; c <='z'; c++){
        int cnt=0;
        for(char d = 'a'; d <='z'; d++){
            if(s[c]==t[d] && c!=d && t[d]!=0 &&s[c]!=1)cnt++;
            if(cnt>1){
                cout<<c<<'-'<<d<<endl;
                flag=false;
            }
        }
        if(cnt==0)flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main() { 
    string S, T; cin >> S >> T;
    map<char, char> st;
    map<char, char> ts;

    REP(i, S.size()) {
        char x = S[i];
        char y = T[i];
        if (st.count(x) == 0) {
            st[x] = y;
        } else {
            if (st[x] != y) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (ts.count(y) == 0) {
            ts[y] = x;
        } else {
            if (ts[y] != x) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
int main(void)
{
    double d;
    cin >> d;
    d = 2 * 3.1415926535 * d;
    cout << fixed << setprecision(15) << d <<  endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

constexpr double concentration(double a,double b){
  return (b==0.0?0:100.0*b/(a+b));
}

main(){
  double a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  a*=100.0;
  b*=100.0;
  vector<double> x,y;
  for(double i=0.0;i*a<=f;++i)
    for(double j=0.0;j*b+i*a<=f;++j)
      x.emplace_back(a*i+b*j);
  for(double i=0.0;i*c<=f;++i)
    for(double j=0.0;j*d+i*c<=f;++j)
      y.emplace_back(c*i+d*j);

  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  double ansx = 0.0;
  double ansy = 0.0;
  double ansc = 0.0;
  for(auto const& water:x){
    for(auto const& sugar:y){
      if(water+sugar>f)break;
      double conce = concentration(water,sugar);
      if(water/100.0*e<sugar)break;
      if(chmax(ansc,conce)){
        ansx = water;
        ansy = sugar;
      }
    }
  }
  cout<<(ansx+ansy==0?(a<f?a:b):(ansx+ansy))<<" "<<ansy<<endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#define rep(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef unsigned long long ll;

int main() {
    string a;
    cin >> a;
    if (a[0] == 'R' && a[1] == 'R' && a[2] == 'R') {
        cout << 3;
    }
    else if (a[0] == 'R' && a[1] == 'R') {
        cout << 2;
    }
    else if ( a[1] == 'R' && a[2] == 'R') {
        cout << 2;
    }
    else if (a[0] == 'R' || a[1] == 'R' || a[2] == 'R') {
        cout << 1;
    }
    else {
        cout << '0';
    }
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
  }

  vector<double> B(N);
  for(int i = 0;i < N;i++){
    B.at(i) = 1 / A.at(i);
  }

  double total = 0.0;

  for(int i = 0;i < N;i++){
    total += B.at(i);
  }

  double ans = 1 / total;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    tmp1 = input[1].split(" ")
    N = Number(tmp0[0])
    p = []
    for(var i=0; i<N; i++)
    {
      p.push(Number(tmp1[i]))
    }

    var diff_cnt = 0
    for(i=0; i <p.length; i++)
    {
      if(p[i] !== (i+1))
      {
        diff_cnt++
      }
    }
    if(diff_cnt === 2 || diff_cnt === 0){
      console.log("YES")
    }else{
      console.log("NO")
    }
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("998244353 99824435\n");

Measured memory_bytes: 21064
#include <stdio.h>
int main(){
    int n, m, i;
    double x = 0;
    int y = 0;
    int a[1000];
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
        x += a[i];
    }
    x = x / (4 * m);
    for (i = 0; i < n; i++){
        if (a[i] >= x){
            y++;
        }
    }
    if (y >= m){
        printf("Yes"); 
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort()

if N == 1:
    print (2 * C[0] % MOD)
    exit()

ANS = 0
for i, c in enumerate(C):
    ANS += c * (N + 1 - i)

ANS *= pow(2, N - 2, MOD)
ANS %= MOD
ANS *= pow(2, N, MOD)
print (ANS % MOD)

Measured memory_bytes: 27108
s=input()
k=int(input())
A={}
for i in range(26):
  A[chr(ord('a')+i)]=26-i
C=[]
for ss in s:
  C.append(A[ss])
ans=""
for i in range(len(s)):
  if i==len(s)-1:
    k%=26
    if ord(s[-1])+k>122:
      ans+=chr(ord(s[-1])+k-26)
    else:
      ans+=chr(ord(s[-1])+k)
  elif s[i]!="a" and k>=C[i]:
    ans+="a"
    k-=C[i]
  else:
    ans+=s[i]
print(ans)

Measured memory_bytes: 4340
/* for vjudge contest anu-cpc a */
#include <stdio.h>

#define MAX 1000000000000000000

int main(int argc, char** argv)
{
    long long x, y;
    long long i;
    
    scanf("%ld %ld", &x, &y);
    if (x % y == 0)
    {
        printf("-1\n");
        return 0;
    }

    for (i = 2; i < MAX / x; ++i)
    {
        if (x * i % y)
        {
            printf("%ld\n", x * i);
            return 0;
        }
    }

    printf("-1\n");
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <stack>
using namespace std;

int main() {
	int A, B, N; cin >> A >> B >> N;
	pair<int, int>S;
	vector<int>C(1000, 0);
	for (int i = 0; i < N; i++) {
		cin >> S.first >> S.second;
		for (int j = S.first; j < S.second; j++)
		{
			C.at(j) = 1;
		}
	}
	int ans = 0;
	for (int i = A; i < B; i++) {
		ans += C.at(i);
	}
	if (ans == 0)cout << ans << endl;
	else cout << 1 << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a,b,c;
  cin >> a;
  
  cout << a.substr(0,a.length()-8) <<endl;
  
   return 0;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */
import java.util.Scanner;
import java.io.*;
import java.lang.*;


class Main {
	public static void main (String[] args) {
	    Scanner in = new Scanner(System.in);
	    int k = in.nextInt();
	    String s = in.next();

	    if(s.length() <= k)
	        System.out.println(s);
	    else {
	        System.out.println(s.substring(0,k) + "...");
	    }
	}
}

Measured memory_bytes: 38724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>

int main (){
	int a, b;

	std::cin >> a >> b;

	if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
		std::cout << a * b << std::endl;
	}
	else {
		std::cout << -1 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

struct Tree {

  int to[N<<1], nxt[N<<1], head[N], cnt;

  Tree() {
    cnt = 0;
    memset(to, 0, sizeof to);
    memset(nxt, 0, sizeof nxt);
    memset(head, 0, sizeof head);
  }

  void insert(int x, int y) {
    to[++ cnt] = y; nxt[cnt] = head[x]; head[x] = cnt;
    to[++ cnt] = x; nxt[cnt] = head[y]; head[y] = cnt;
  }

} red, blue;

int dep[N], fa[N];

void dfs(int x, int f) {
  fa[x] = f;
  dep[x] = dep[f] + 1;
  for (int i = blue.head[x]; i; i = blue.nxt[i]) {
    if (blue.to[i] == f) continue;
    dfs(blue.to[i], x);
  }
}

int rx[N], ry[N];
bool nige[N];

// check if distance btw x and y <= 2
bool check(int x, int y) {
  if (dep[x] > dep[y]) {
    swap(x, y);
  }
  if (dep[y] == dep[x]) {
    return fa[y] == fa[x];
  }
  if (dep[y] - dep[x] == 1) {
    return fa[y] == x;
  }
  if (dep[y] - dep[x] == 2) {
    return fa[fa[y]] == x;
  }
  return false;
}

bool vis[N];

void escape(int x, int f, int d) {

  if (dep[x] <= d) return;
  vis[x] = 1;
  for (int i = red.head[x]; i; i = red.nxt[i]) {
    if (red.to[i] == f) continue;
    escape(red.to[i], x, d + 1);
  }
}

int main(int argc, char const *argv[]) {
  // freopen("../../temp/.in", "r", stdin);

  int n = read(), x = read(), y = read();
  
  for (int i = 1; i < n; ++ i) {
    rx[i] = read();
    ry[i] = read();
    red.insert(rx[i], ry[i]);
  }
  
  for (int i = 1; i < n; ++ i) {
    blue.insert(read(), read());
  }

  dfs(y, 0);
  
  for (int i = 1; i < n; ++ i) {
    if (!check(rx[i], ry[i])) {
      nige[rx[i]] = nige[ry[i]] = true;
    }
  }

  escape(x, 0, 1);

  int ans = 0;

  for (int i = 1; i <= n; ++ i) {
    if (vis[i] && nige[i]) {
      return puts("-1"), 0;
    }
    if (vis[i]) {
      ans = max(ans, dep[i] - 1);
    }
  }

  printf("%d\n", ans << 1);

  return 0;
}
/*

当 A 到达一条红树上的边 (x, y) 的端点时（这条边满足 x 和 y 在蓝树的距离大于 2），B 还没抓到 A，显然就 -1 了。

除了这种情况 A 都会被抓到。

以 B 的初始点为根，发现 A 每次就是往子树逃，或往兄弟逃，或往父亲逃。
只要 B 步步下潜，就能抓到 A。

删除红树上满足 A 一旦到达就会 -1 的那些边，然后做 bfs 求出 A 能能跑到的点（即到达该点前不会被 B 抓），
A 一定会选择在蓝树中深度最大的，然后待在那弃疗。

*/

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int x;
  cin >> x;
  if(x<1200) {
    cout << "ABC";
  } else {
    cout <<"ARC";
  }
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

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

  if (N == 1) {
    cout << "1\n";
    return 0;
  }

  vector<ll> factors;
  rep(i, 2, sqrt(N) + 1)  {
    if (N % i == 0) {
      factors.push_back(i);
      while (N % i == 0) {
        N /= i;
      }
    }
    if (N == 1) break;
  }
  if (N > 1) factors.push_back(N);

  ll ans = 0;
  ll s = factors.size();
  N = N2;

  rep(i, 1, 1 << s) {
    ll d = 0;
    ll f = 1;
    rep0(j, s) {
      if ((i >> j) & 1) {
        d++;
        f *= factors[j];
      }
    }
    if (d % 2 == 1) {
      ans += (N / f);
    } else {
      ans -= (N / f);
    }
  }

  cout << (N - ans) << BR;
  return 0;
}


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

static const int MAX = 200000;

int main(int argc, char** argv) {
	
	int n;
	int r[MAX];
	int i;
	int maxv, minv;
	
	maxv = -2000000000;
	
	cin >> n;
	
	for (i = 0; i < n; i++)
		cin >> r[i];
		
	minv = r[0];
		
	for (i = 1; i < n; i++) {
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 3840
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	for i := 0; i < len(ls); i++ {
		fmt.Scan(&ls[i])
	}

	cs := make([]int, n)
	for i, v := range ls {
		for j := 0; ; j++ {
			if v%2 != 0 {
				cs[i] = j
				break
			}
			v = v / 2
		}
	}

	sort.Ints(cs)
	ans := cs[0]

	fmt.Println(ans)

}


Measured memory_bytes: 512
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define inf 20021225
#define ll long long
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int main()
{
	ll a,b; scanf("%lld%lld",&a,&b); ll ans=0;
	if(a==b)	return puts("1"),0;
	for(int i=60;~i;i--)
		if((a>>i&1)!=(b>>i&1))
		{
			a&=(1ll<<i+1)-1; b&=(1ll<<i)-1;
			ll p=1ll<<i; ans+=p-a;
			for(;~i;i--)	if(b>>i&1)	break;
			i++; ans+=1ll<<i; a=max(1ll<<i,a);
			//printf("%lld %lld %lld\n",ans,i,a);
			ans+=p-a;
			break;
		}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int n, ans = 0, h, k, c,t; string s;
vector<int> d = { 0,1,2,3,4,5,6,7,8,9 };
queue<int> q;
int main() {
    cin >> n >> k;
    rep(i, k) {
        cin >> c; c -= i;
        d.erase(d.begin() + c);
    }
    rep(i, d.size()) q.push(d[i]);
    for (;;) {
        h = q.front(); q.pop();
        if (h >= n) break;
        rep(i, d.size()) {
            q.push(h * 10 + d[i]);
        }
    }
    cout << h << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; ++i) {
        if (i * 2 + (X - i) * 4 == Y) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(solve(a, b));

        sc.close();
    }

    static int solve(int a, int b) {
        return a - 1 + ((a <= b) ? 1 : 0);
    }
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
		
	}
	
	private static void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(reader.readLine());
		int[] list = new int[2 * N];
		int sum = 0;
		
		String str = reader.readLine();
		int index1 = -1;
		int index2 = -1;
		
		for (int i = 0; i < 2 * N; ++i) {
			index2 = str.indexOf(" ", index1 + 1);
			if (index2 == -1) {
				index2 = str.length();
			}
			
			list[i] = Integer.parseInt(str.substring(index1 + 1, index2));
			// System.out.println(list[i]);
			
			index1 = index2;
			
		}
		
		Arrays.sort(list);
		
		for (int i = 0; i < 2 * N; i += 2) {
			sum += list[i];
			
		}
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 8020
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

cnt = 0
for a in range(10):
    for b in range(10):
        n = 0
        ab = [a,b]
        for i in range(N):
            if int(s[i]) == ab[n]:
                n += 1
            if n == 2:
                for c in range(10):
                    for j in range(i+1,N):
                        if int(s[j]) == c:
                            cnt += 1
                            break
                else:
                    break
print(cnt)

Measured memory_bytes: 42588
def swap!(list, a, b)
    list[a], list[b] = list[b], list[a]
  end

word = gets
alphabets = "abcdefghijklmnopqrstuvwxyz".split("")
words = word.split("")
ans = 0
found1 = 0

if (word == "zyxwvutsrqponmlkjihgfedcba\n") then
  ans = -1
elsif (words.length < 26) then
  alphabets.each{|c|
    if(!words.include?(c))then
      words.delete("\n")
      words.push(c)
      words.push("\n")
      ans = words.join("")
      break
    end
  }
else
  biggers = Array.new
  #(words.length-1).downto(0) { |i|
  #  done = false
  #  (words.length-1).downto(0) { | j |
  #    puts "i=" + i.to_s + " j=" + j.to_s
  ##    if(words[i] < words[j]) then
  #      biggers.push(j)
  #      found1 = i
  #      done = true
  #    end
  #    }
#
  #  if(done) then
  #    break
  #  end
  (25).downto(0) { |i|
    if(words[i-1] < words[i]) then
      found1 = i
      break
    end
  }
  for i in found1..25 do
    if(words[found1-1] < words[i]) then
      biggers.push(words[i])
    end
  end
  rep = biggers.min
  repindex = words.find_index{|i| i == rep}
  #puts repindex.to_s

  swap!(words, found1-1, repindex)

  findx = words.find_index{|i| i == rep}

  zenhan = words.slice(0..found1-1)
  kouhan = words.slice(found1..findx)
  kouhan.sort!

  tmp = Array.new
  tmp.concat(zenhan)
  tmp.concat(kouhan)
  ans = tmp.join("")
end

puts ans

Measured memory_bytes: 1788
infinity = float('inf')
n = int(input())
a = []

for i in range(n):

    line = list(map(int, input().split()))

    for i in range(len(line)):
        if line[i] == -1:
            line[i] = infinity
    a.append(line)

checked = [False] * n
d = [infinity] * n
checked[0] = True
ansswer = 0
next = 0

for i in range(n - 1):
    for j in range(n):
        if a[next][j] < d[j]:
            d[j] = a[next][j]

    minimumNeightbor = 0
    minimumWeight = infinity

    for j in range(n):
        if not checked[j] and d[j] < minimumWeight:
            minimumNeightbor = j
            minimumWeight = d[j]

    checked[minimumNeightbor] = True
    next = minimumNeightbor
    ansswer += minimumWeight

print(ansswer)



Measured memory_bytes: 5888
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int N, K, A[1010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	sort(A, A + N);
	cout << accumulate(A, A + K, 0);
}

Measured memory_bytes: 3608
n = int(input())
s = input()

"""
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
"""
# gagsg
r = 0
g = 0
b = 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2 * j - i
        if k < n:
            if s[i] == s[j]:
                continue
            if s[j] == s[k]:
                continue
            if s[k] == s[i]:
                continue
            ans -= 1
print(ans)


Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n,m;
int a,b;
vector<int> v[N];
int in[N];
int dp[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	m=read();

	for(int i=1;i<=m;++i){
		a=read();
		b=read();
		v[a].pb(b);
		in[b]++;
	}

	queue<int> q;
	for(int i=1;i<=n;++i){
		if(!in[i]) q.push(i);
	}

	while(!q.empty()){
		int now=q.front();
		q.pop();

		for(auto w:v[now]){
			in[w]--;
			if(!in[w]){
				q.push(w);
				dp[w]=dp[now]+1;
			}
		}
	}

	int ans=0;

	for(int i=1;i<=n;++i){
		ans=max(ans,dp[i]);
	}

	printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 30820
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val arr = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val sorted = arr.sorted()
    var cnt = 0
    for(i in arr.indices) if(arr[i] != sorted[i]) cnt++
    if(cnt == 0) {
        println(0)
        return
    }
    val q = readLine()!!.toInt()
    for(i in 0 until q) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() - 1 }
        if(arr[x] != sorted[x]) cnt--
        if(arr[y] != sorted[y]) cnt--
        val tmp = arr[x]
        arr[x] = arr[y]
        arr[y] = tmp
        if(arr[x] != sorted[x]) cnt++
        if(arr[y] != sorted[y]) cnt++
        if(cnt == 0) {
            println(i + 1)
            return
        }
    }
    println(-1)
}


Measured memory_bytes: 150724
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int s;
    cin >> s;
    vector<ll> dp(s+1,0);
    vector<ll> prefix(s+1,0);
    dp[0] = 1;
    prefix[0] = 1;
    int M = 1e9 + 7;
    for (int i=3;i<=s;i++){
        dp[i] = (dp[i] + prefix[i-3])%M;
        prefix[i-2] = (prefix[i-3] + dp[i-2])%M;
    }
    cout << dp[s] << "\n";
}



Measured memory_bytes: 3552
#include <iostream>
#include <cstring>
#include <vector>

#include <cmath>

using namespace std;

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

	vector<long long> a;
	long long temp_a;
	for (long long  i = 0; i < n; i++) {
		cin >> temp_a;
		a.push_back(temp_a);
	}
	long long mass_minas = 0;
	for (long long i = 0; i < n; i++) {
		if (a.at(i) < 0) {
			mass_minas++;
		}
	}

	vector<long long> a_sub;

	for (long long i = 0; i < n; i++) {
		a_sub.push_back(abs(a.at(i)));
	}

	long long ans = 0;
	if (mass_minas % 2 == 0) {
		for (long long i = 0; i < n; i++) {
			ans = ans + a_sub.at(i);
		}
	}

	else {
		long long min;
		min = abs(a_sub.at(0));
		for (long long i = 0; i < n; i++) {
			if (min > a_sub.at(i)) {
				min = a_sub.at(i);
			}
		}
		for (long long i = 0; i < n; i++) {
			ans = ans + a_sub.at(i);
		}
		ans = ans - min * 2;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 2548
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	int a[26] = {};
	for (int i = 0; i < h * w; i++) {
		char c;
		cin >> c;
		a[c - 'a']++;
	}
	bool ok = true;
	if (h % 2 == 0 && w % 2 == 0) {
		for (int i = 0; i < 26; i++) {
			ok &= a[i] % 4 == 0;
		}
	} else if (h % 2 == 1 && w % 2 == 1) {
		int x = h / 2 + w / 2;
		int cnt1 = 0, cnt2 = 0;
		for (int i = 0; i < 26; i++) {
			cnt1 += a[i] % 2 == 0 && a[i] % 4 != 0;
			cnt2 += a[i] % 2 == 1;
		}
		if (cnt2 != 1) ok = false;
		if (cnt1 > x ) ok = false;
	} else {
		if (h % 2 == 1) swap(h, w);
		int x = h / 2;
		int cnt = 0;
		for (int i = 0; i < 26; i++) {
			if (a[i] % 4 != 0) {
				if (a[i] % 2 == 0) cnt++;
				else ok = false;
			}
		}
		if (cnt > x) ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;

	int count = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i)) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3472
#include <stdio.h>

#define ll long long

int main(void){
    ll x, i = 0;
    ll sum = 100;

    (void)scanf("%lld", &x);

    while(1){
        sum += sum * 0.01;
        i++;
        if(sum >= x) break;
    }

    printf("%lld\n", i);

    return 0;

}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

bitset <4000005> dp ;
int a[2005] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;
   // n = 2000 ;
  //  for(i=1 ; i<=n ; i++) a[i] = 2000 ;

    int sum = 0 ;

    for(i=1 ; i<=n ; i++) sum+= a[i] ;

    sort(a+1,a+n+1) ;

    dp[0] = 1 ;

    dp.set(0) ;
    for(i=1 ; i<=n ; i++)
    {
        dp |= (dp<<a[i]) ;
    }

    m = sum/2 ;
    for(i=m ; i>=0 ; i--)
    {
        if( dp[i]==1 ) break ;
    }

    printf("%d\n",sum-i) ;

    return 0 ;
}


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

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

    int n;
    cin >> n;
    int h[30];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int maxh = h[0], ans = 1;
    for(int i = 1; i < n; i++){
        if(h[i] >= maxh){
            ans++;
            maxh = h[i];
        }
    }
    cout << ans;
    return 0;
}

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

int main()
{
	char c;
	cin >> c;
	if(c=='A' ||c=='B' ||c=='C' ||c=='D' ||c=='E' ||c=='F' ||c=='G' ||c=='H' ||c=='I' ||c=='J' ||c=='K' ||c=='L' ||c=='M' ||c=='N' ||c=='O' ||c=='P' ||c=='Q' ||c=='R' ||c=='S' ||c=='T' ||c=='U' ||c=='V' ||c=='X' ||c=='Y' ||c=='Z'){
		cout<< 'A' << endl;
	}
	if(c=='a' ||c=='b' ||c=='c' ||c=='d' ||c=='e' ||c=='f' ||c=='g' ||c=='h' ||c=='i' ||c=='j' ||c=='k' ||c=='l' ||c=='m' ||c=='n' ||c=='o' ||c=='p' ||c=='q' ||c=='r' ||c=='s' ||c=='t' ||c=='u' ||c=='v' || c=='w' ||c=='x' ||c=='y' ||c=='z'){
		cout<< 'a' << endl;
	}
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
P = list(map(int,input().split()))

sum_acc = []
tmp = 0
for i in range(N):
  tmp += (P[i]+1)/2
  sum_acc.append(tmp)
  
#print(sum_acc)
sum_max = 0  
for i in range(N):
  if(i == K-1):
   sum_tmp = sum_acc[i]
   sum_max = max(sum_tmp,sum_max)
  elif(i >= K): 
   sum_tmp = sum_acc[i]-sum_acc[i-K]
   sum_max = max(sum_tmp,sum_max)

print(sum_max)

Measured memory_bytes: 24804
#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;

LL N, A, B, sum, lastN, inCnt, allCnt, ans;

void make_comb(std::vector<std::vector<LL>>&v)
{
	rep(i, v.size()) v[i][0] = v[i][i] = 1;
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main()
{
	in >> N >> A >> B;
	std::vector<LL>v(N);
	std::vector<std::vector<LL>>comb(N + 1, std::vector<LL>(N + 1, 0));
	rep(i, N) in >> v[i];
	make_comb(comb);
	std::sort(v.rbegin(), v.rend());
	rep(i, A)
	{
		sum += v[i];
		if (i == A - 1) lastN = v[i];
	}
	rep(i, N)
	{
		if (v[i] == lastN)
		{
			if (i <= A - 1) ++inCnt;
			++allCnt;
		}
	}
	if (v[0] == lastN)
	{
		for (LL i = inCnt; i <= std::min(allCnt, inCnt + (B - A)); ++i) ans += comb[allCnt][i];
	}
	else ans = comb[allCnt][inCnt];
	out << std::fixed << std::setprecision(6);
	out << (long double)sum / A << std::endl << ans << std::endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
s = rr()
for i in range(a):
    if s[i] not in '0123456789':
        print('No')
        exit()
for i in range(b):
    if s[a+1+i] not in '0123456789':
        print('No')
        exit()
if s[a] != '-':
  print('No')
  exit()
print('Yes')














Measured memory_bytes: 27116
/*
https://drken1215.hatenablog.com/entry/2019/06/22/224100
*/
#include <iostream>
using namespace std;

long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }
long long num(long long n, long long c, long long d) {
    long long G = GCD(c, d);
    long long L = c / G * d;
    return n - n / c - n / d + n / L;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << num(b, c, d) - num(a-1, c, d) << endl;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int dp[110][110][310];

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

	int N, W;
	cin >> N >> W;
	Vi w(N), v(N);
	int w1;
	cin >> w1 >> v[0];
	w[0] = 0;
	for (int i = 1; i < N; ++i) {
		int wi, vi;
		cin >> wi >> vi;
		w[i] = wi - w1;
		v[i] = vi;
	}

	for (int i = 0; i < N + 1; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= N * 3; ++k) {
				dp[i][j][k] = -I_INF;
			}
		}
	}
	dp[0][0][0] = 0;

	for (int i = 1; i < N + 1; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= N * 3; ++k) {
				if (j - 1 >= 0 && k - w[i - 1] >= 0) {
					dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - w[i - 1]] + v[i - 1]);
				}
				else {
					dp[i][j][k] = dp[i - 1][j][k];
				}
			}
		}
	}

	int ans = 0;
	for (int j = 0; j <= N; ++j) {
		for (int k = 0; k <= N * 3; ++k) {
			if ((ll)w1 * j + k <= W) ans = max(ans, dp[N][j][k]);
		}
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 * 1000 + 13;

int n;
int MOD;
vector<int> g[N];

bool read () {
	if (scanf("%d%d", &n, &MOD) != 2)
		return false;
	forn(i, n)
		g[i].clear();
	forn(i, n - 1){
		int x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		g[x].pb(y);
		g[y].pb(x);
	}
	return true;
}

int dp[N];

int add(int a, int b){
	a += b;
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b){
	return a * li(b) % MOD;
}

void init(int v, int p = -1){
	dp[v] = 1;
	for (auto u : g[v]) if (u != p){
		init(u, v);
		dp[v] = mul(dp[v], add(dp[u], 1));
	}
}

int ans[N];
int vals[N];

void dfs(int v, int p = -1){
	ans[v] = dp[v];
	
	forn(i, sz(g[v]))
		vals[i] = add(dp[g[v][i]], 1);
	
	vector<int> pr(sz(g[v]) + 1), su(sz(g[v]) + 1);
	pr[0] = 1;
	forn(i, sz(g[v]))
		pr[i + 1] = mul(pr[i], vals[i]);
	su[sz(g[v])] = 1;
	for (int i = sz(g[v]) - 1; i >= 0; --i)
		su[i] = mul(su[i + 1], vals[i]);
	
	forn(i, sz(g[v])) if (g[v][i] != p){
		int u = g[v][i];
		
		int tmpv = dp[v];
		int tmpu = dp[u];
		dp[v] = mul(pr[i], su[i + 1]);
		dp[u] = mul(dp[u], add(dp[v], 1));
		
		dfs(u, v);
		
		dp[v] = tmpv;
		dp[u] = tmpu;
	}
}

void solve() {	
	init(0);
	dfs(0);
	forn(i, n)
		printf("%d\n", ans[i]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 18816