akhauriyash/Code-Regression huggingface dataset:
import numpy as np

n = int(input())

dp = np.full((n + 1), n + 1, dtype = int)
dp[0] = 0

loop = 0
while dp[n] > n:
    tmp1 = np.full(n + 1, n + 1, dtype = int)
    tmp6 = np.full(n + 1, n + 1, dtype = int)
    tmp9 = np.full(n + 1, n + 1, dtype = int)    
    tmp1[1:] = dp[: -1] + 1
    j = 1
    while 6 ** j <= n:
        tmp6_pre = tmp6
        tmp6[6 ** j:] = dp[:-6 ** j] + 1
        tmp6 = np.minimum(tmp6_pre, tmp6)
        j += 1
    k = 1
    while 9 ** k <= n:
        tmp9_pre = tmp9
        tmp9[9 ** k:] = dp[: -9 ** k] + 1
        tmp9 = np.minimum(tmp9_pre, tmp9)
        k += 1
    tmp1 = np.minimum(tmp1, tmp6)
    tmp1 = np.minimum(tmp1, tmp9)
    dp = np.minimum(dp, tmp1)
    loop += 1
print(dp[n])

Measured memory_bytes: 32068
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=100000;
mt19937 mt;

int D,c[26],s[200000][26],t[200000],T[200000],v,V,l[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		t[i]=uniform_int_distribution<int>(0,25)(mt);
	}
	for(int i=0;i<26;i++){
		l[i]=-1;
	}
	for(int i=0;i<D;i++){
		l[t[i]]=i;
		v+=s[i][t[i]];
		for(int j=0;j<26;j++){
			v-=c[j]*(i-l[j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			if(uniform_int_distribution<int>(0,N*10)(mt)<=N-i){
				T[j]=uniform_int_distribution<int>(0,25)(mt);
			}
			else{
				T[j]=t[j];
			}
		}
		for(int j=0;j<26;j++){
			l[j]=-1;
		}
		for(int j=0;j<D;j++){
			l[T[j]]=j;
			V+=s[j][T[j]];
			for(int k=0;k<26;k++){
				V-=c[k]*(i-l[k]);
			}
		}
		if(V>v){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


Measured memory_bytes: 3884
l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = input()
for i in range(int(n)):
    b,f,r,v = input().split()
    #l[int(b)-1][int(f)-1][int(r)-1] = v
    l[int(b)-1][int(f)-1][int(r)-1] = l[int(b)-1][int(f)-1][int(r)-1] + int(v)

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")


Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(void){
    char c;
    cin >> c;
    if(c == 'A') cout << 'T' << endl;
    if(c == 'T') cout << 'A' << endl;
    if(c == 'C') cout << 'G' << endl;
    if(c == 'G') cout << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    if(S.front() != 'A') {
        cout << "WA" << endl;
    } else {
        bool isContainC = false;
        int countCapital = 0;
        for(int i=1; i<S.size(); ++i) {
            if(i>=2 && i<S.size()-1 && S.at(i) == 'C') {
                isContainC = true;
            }
            if(isupper(S.at(i))) {
                countCapital++;
            }
        }

        if(isContainC && countCapital == 1) {
            cout << "AC" << endl;
        } else {
            cout << "WA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> ans(n,0);
    
    ans[0] = 1; ans[1] = 1;
    loop(i,1,n-1){
        if((s[i] == 'o' && ans[i] == 1) || (s[i] == 'x' && ans[i] == -1)) ans[i+1] = ans[i-1];
        else ans[i+1] = ans[i-1]*(-1);
    }
    if((s[0] == 'o' && ans[n-1]*ans[0]*ans[1] == 1) || (s[0] == 'x' && ans[n-1]*ans[0]*ans[1] == -1)){
       if((s[n-1] == 'o' && ans[n-2]*ans[n-1]*ans[0] == 1) || (s[n-1] == 'x' && ans[n-2]*ans[n-1]*ans[0] == -1)){
           string res = "";
           rep(i,n){ if(ans[i] == 1) res += "S"; else res += "W"; }
           cout << res << endl; return 0;
        }
    }
    ans[0] = 1; ans[1] = -1;
    loop(i,1,n-1){
        if((s[i] == 'o' && ans[i] == 1) || (s[i] == 'x' && ans[i] == -1)) ans[i+1] = ans[i-1];
        else ans[i+1] = ans[i-1]*(-1);
    }
    if((s[0] == 'o' && ans[n-1]*ans[0]*ans[1] == 1) || (s[0] == 'x' && ans[n-1]*ans[0]*ans[1] == -1)){
       if((s[n-1] == 'o' && ans[n-2]*ans[n-1]*ans[0] == 1) || (s[n-1] == 'x' && ans[n-2]*ans[n-1]*ans[0] == -1)){
           string res = "";
           rep(i,n){ if(ans[i] == 1) res += "S"; else res += "W"; }
           cout << res << endl; return 0;
        }
    }
    ans[0] = -1; ans[1] = 1;
    loop(i,1,n-1){
        if((s[i] == 'o' && ans[i] == 1) || (s[i] == 'x' && ans[i] == -1)) ans[i+1] = ans[i-1];
        else ans[i+1] = ans[i-1]*(-1);
    }
    if((s[0] == 'o' && ans[n-1]*ans[0]*ans[1] == 1) || (s[0] == 'x' && ans[n-1]*ans[0]*ans[1] == -1)){
       if((s[n-1] == 'o' && ans[n-2]*ans[n-1]*ans[0] == 1) || (s[n-1] == 'x' && ans[n-2]*ans[n-1]*ans[0] == -1)){
           string res = "";
           rep(i,n){ if(ans[i] == 1) res += "S"; else res += "W"; }
           cout << res << endl; return 0;
        }
    }
    ans[0] = -1; ans[1] = -1;
    loop(i,1,n-1){
        if((s[i] == 'o' && ans[i] == 1) || (s[i] == 'x' && ans[i] == -1)) ans[i+1] = ans[i-1];
        else ans[i+1] = ans[i-1]*(-1);
    }
    if((s[0] == 'o' && ans[n-1]*ans[0]*ans[1] == 1) || (s[0] == 'x' && ans[n-1]*ans[0]*ans[1] == -1)){
       if((s[n-1] == 'o' && ans[n-2]*ans[n-1]*ans[0] == 1) || (s[n-1] == 'x' && ans[n-2]*ans[n-1]*ans[0] == -1)){
           string res = "";
           rep(i,n){ if(ans[i] == 1) res += "S"; else res += "W"; }
           cout << res << endl; return 0;
        }
    }
    cout << -1 << endl; return 0;
}

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

double calcDistance(pair<int, int>& src, pair<int, int>& dst) {
    int dx = (dst.first - src.first) * (dst.first - src.first);
    int dy = (dst.second - src.second) * (dst.second - src.second);
    double distance = sqrt(static_cast<double>(dx + dy));
    return distance;
}

int main() {

    uint N;
    cin >> N;
    vector<pair<int, int>> town(N);
    vector<int> tNo(N);
    for (uint i=0; i<N; i++) {
        cin >> town[i].first >> town[i].second;
        tNo[i] = i;
    }

    double sum = 0;
    int pattern = 0;
    do {
        // for (auto &x: tNo) cout << x << ", ";
        for (uint i=0; i<N-1; i++) {
            sum += calcDistance(town[tNo[i]], town[tNo[i+1]]);
        }
        ++pattern;
        // cout << endl;
    } while (next_permutation(tNo.begin(), tNo.end()));

    double ans = sum / pattern;
    cout << setprecision(12);
    cout << ans << endl;
}



Measured memory_bytes: 3812
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    RGB = {'R': [], 'G': [], 'B': []}
    for i in range(N):
        RGB[S[i]].append(i)
    num_r = len(RGB['R'])
    num_g = len(RGB['G'])
    num_b = len(RGB['B'])
    if num_r == 0 or num_g == 0 or num_b == 0:
        print(0)
        return

    len_b = (RGB['B'][-1] + 1)
    B1 = [0]*len_b
    for b in RGB['B']:
        B1[b] = 1
    # print(R, G, B)
    ans = num_r * num_g * num_b
    for i in RGB['R']:
        for j in RGB['G']:
            ans -= calc(min(i, j), max(i, j), B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69176
A,B = [int(i) for i in input().split()]

def gcd(a,b):#a>b
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def get_sieve_of_eratosthenes(n):#n以下の素数のリストを返す
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    #plist = get_sieve_of_eratosthenes(n)
    #for p in plist:
    for p in range(2,int(n**0.5)+3):
        if n%p==0:
            ans+=1
            while n%p==0:
                n = n//p
    if n!=1:
        ans+=1
    print(ans)



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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=200000+5;
const int inf=1e9;
const ll mod=1e9+7;


ll a[MX];

int main()
{
    FasterIO;
    ll tc, n, k;
    cin>>n;
    ll sm=0;
    k=1;
    while(n>0)
    {
        sm+=k;
        n/=2;
        k*=2;
    }
    cout<<sm<<endl;
    return 0 ;
}


Measured memory_bytes: 256
using System;

class D2
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();

		int r = 0, i;
		for (int x = 0; x < 1000; x++)
		{
			var p = $"{x:D3}";
			if ((i = s.IndexOf(p[0])) == -1) continue;
			if ((i = s.IndexOf(p[1], i + 1)) == -1) continue;
			if (s.IndexOf(p[2], i + 1) > -1) r++;
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;

namespace test
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main(string[] args)
        {
            var nabc = ReadNumList();
            var n = nabc[0];
            var abc = new int[] { nabc[3], nabc[2], nabc[1] };
            var l = new int[n];
            for (var i = 0; i < n; ++i)
            {
                l[i] = int.Parse(Console.ReadLine());
            }

            var minMp = int.MaxValue;
            for (var useA = 0; useA < n - 2; ++useA)
            {
                for (var useB = useA + 1; useB < n - 1; ++useB)
                {
                    for (var useC = useB + 1; useC < n; ++useC)
                    {
                        var lList = new List<int>(l);
                        lList.RemoveAt(useC);
                        lList.RemoveAt(useB);
                        lList.RemoveAt(useA);
                        minMp = Math.Min(minMp, Exec(abc, l[useA], l[useB], l[useC], lList, 0));
                    }
                }
            }
            Console.WriteLine(minMp);
        }
        static int Exec(int[] abc, int aNum, int bNum, int cNum, List<int> lList, int mp)
        {
            var ls = new int[] { aNum, bNum, cNum };
            Array.Sort(ls);
            var minMp = mp + Math.Abs(abc[0] - ls[0]) + Math.Abs(abc[1] - ls[1]) + Math.Abs(abc[2] - ls[2]);
            if (lList.Count == 0)
            {
                return minMp;
            }
            for (var add = 0; add < lList.Count; ++add)
            {
                var tmpList = new List<int>(lList);
                tmpList.RemoveAt(add);
                minMp = Math.Min(minMp, Exec(abc, ls[0] + lList[add], ls[1], ls[2], tmpList, mp + 10));
                minMp = Math.Min(minMp, Exec(abc, ls[0], ls[1] + lList[add], ls[2], tmpList, mp + 10));
                minMp = Math.Min(minMp, Exec(abc, ls[0], ls[1], ls[2] + lList[add], tmpList, mp + 10));
            }
            return minMp;
        }
    }
}


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

using namespace std;

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

    vector<int> v(N, 0);
    for(int i = 0; i < M; ++i)
    {
        int ai, bi;
        cin >> ai >> bi;
        v[ai - 1]++;
        v[bi - 1]++;
    }

    for(const auto& e : v)
        cout << e << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long x1,y1,x2,y2,x3,y3,s;
	cin>>s;
	x1=y1=0,x2=y3=sqrt(s);
	if(x2*y3==s) y2=x3=0;
	else {
		x2++,y3++;
		x3=1;
		y2=x2*y3-s;
	}
	cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<x3<<' '<<y3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a=0,b=0,k,t,j;
    cin>>a>>b;
    if(a+b==3) cout<<"3";
    else if(a+b==4) cout<<"2";
    else cout<<"1";
}

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

int n, m, c, ans = 0;
vector<int> b(30);
vector< vector<int> > a( 30, vector<int>(30));

int main() {
    cin >> n >> m >> c;
    for (int i = 0; i < m; ++i) cin >> b.at(i);

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

    for (int i = 0; i < n; ++i)
    {
        int sum = 0;
       for (int j = 0; j < m; ++j)
       {
          sum += a.at(i).at(j)*b.at(j);
       }

       if ((sum + c) > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*

/**
 * Created on 2019/03/03.
 */



fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.next().toInt()
    val array = sc.next().toCharArray()
    val x = array.count { it == 'R' }
    println(if (x > n - x) "Yes" else "No")
}


Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll i,n; cin>>n;
    string a,b,c; cin>>a>>b;
    for(i=0;i<n;i++){
        c.append(string(1,a[i]));
        c.append(string(1,b[i]));
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, ans;
ll a, b;
ll h[100005];

bool f(ll p)
{
    ll cnt = 0;
    for(ll i = 0; i < n; i++)
    {
        ll t = h[i];
        t -= b * p;
        if(t <= 0) continue;
        cnt += (t + a - 1) / a;
    }
    if(cnt <= p) return true;
    else return false;
}

int main()
{
    scanf("%d%d%d", &n, &a, &b);
    a -= b;
    for(ll i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
    }
    ll lt = 0, rt = 1e9, mid;
    while(lt < rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid)) rt = mid, ans = mid;
        else lt = mid + 1;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
using ll = long long;
typedef pair<ll, ll> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*def*/
ll dp[100100];
ll n, k, h[100100];

int main() {
/*input*/
    cin >> n >> k;
    rep(i, n){cin >> h[i];}

    rep(i, 100100){dp[i] = LLONG_MAX;}
    dp[0] = 0;

/*main配るdp*/
    rep(i, n-1){
        for (int j = 1; j <= k; j++){
            chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

/*output*/
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 5188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152A
{
	class Program
	{
		static void Main(string[] args)
		{
			int n,m;
			var word = Console.ReadLine().Split(' ');
			n = int.Parse(word[0]);
			m = int.Parse(word[1]);
			if (n == m)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias D = Tuple!(long, "sum", int, "i", int, "j", int, "k");

void calc_pq(int K, long[] a, long[] b, long[] c) {
    a.sort!("a > b");
    b.sort!("a > b");
    c.sort!("a > b");
    auto pq = new BinaryHeap!(Array!D);
    bool[Tuple!(int, int, int)] used;
    pq.insert(D(a[0] + b[0] + c[0], 0, 0, 0));
    while (K > 0) {
        auto d = pq.front;
        pq.popFront();
        if (tuple(d.i, d.j, d.k) in used) continue;

        writeln(d.sum);
        used[tuple(d.i, d.j, d.k)] = true;
        K--;

        int i = d.i;
        int j = d.j;
        int k = d.k;
        if (i + 1 < a.length)
            pq.insert(D(a[i + 1] + b[j] + c[k], i + 1, j, k));
        if (j + 1 < b.length)
            pq.insert(D(a[i] + b[j + 1] + c[k], i, j + 1, k));
        if (k + 1 < c.length)
            pq.insert(D(a[i] + b[j] + c[k + 1], i, j, k + 1));
    }
}

// 688ms で AC
void calc(int k, long[] a, long[] b, long[] c) {
    long[] ab;
    foreach (x, y; cartesianProduct(a, b))
        ab ~= x + y;

    ab.sort!"a > b";
    c.sort!"a > b";
    long[] abc;
    foreach (x, y; cartesianProduct(c, ab.take(k)))
        abc ~= x + y;
    abc.sort!"a > b";
    foreach (e; abc.take(k)) writeln(e);
}

void calc2(int K, long[] a, long[] b, long[] c) {
    a.sort!"a > b";
    b.sort!"a > b";
    c.sort!"a > b";

    long[] t;
    for (int i = 0; i < a.length; i++) {
        for (int j = 0; j < b.length; j++) {
            for (int k = 0; k < c.length; k++) {
                if ((i + 1) * (j + 1) * (k + 1) > K) break;
                t ~= a[i] + b[j] + c[k];
            }
        }
    }
    t.sort!"a > b";
    foreach (x; t.take(K)) writeln(x);
}

void main() {
    int x, y, z, k; scan(x, y, z, k);
    auto a = reads!long;
    auto b = reads!long;
    auto c = reads!long;

    calc2(k, a, b, c);
}


Measured memory_bytes: 3324
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

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

  ll minv = LLONG_MAX;
  for (int i = 0; i < 5; i++) {
    ll a;
    cin >> a;
    minv = min(minv, a);
  }

  if (n <= minv) {
    cout << 5 << endl;
    return 0;
  }
  
  if (n % minv == 0) {
    cout << n / minv + 4 << endl;
  } else {
    cout << n / minv + 5 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

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

int main(int argc, const char * argv[]) {
  ll A, B; cin >> A >> B;
  
  int N = 1000001;
  vector<bool> isPrime(N, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for(int i=0; i*i<N; i++){
    if(not isPrime[i]) continue;
    for(int j=2*i; j<N; j+=i)
      isPrime[j] = false;
  }
  vector<ll> primes;
  for(int i=0; i<N; i++)
    if(isPrime[i])
      primes.push_back(i);
  
  ll d = gcd(A, B);
  vector<bool> used((int)primes.size(), false);
  for(int i=0; i<primes.size(); i++){
    if(d%primes[i] == 0){
      used[i] = true;
      while(d%primes[i] == 0)
        d /= primes[i];
    }
  }
  
  ll ans = 1;
  for(auto b: used)
    if(b) ans++;
  
  if(d != 1) ans++;
  
  cout << ans << endl;
  
  return 0;
}

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

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

int kfactor(int a,int k){
    vector<int>v1,v2;
    for(int i=1;i<=sqrt(a);i++)
    {
        if(a%i==0)
        {
            v1.push_back(i);
            v2.push_back(a/i);
        }
    }
    if(k<=v2.size())
    {
        k--;
        return v2[k];
    }
    if(sqrt(a)*sqrt(a)==a){
        k++;
    }
    k-=v2.size();
    k=v1.size()-k;
    return v1[k];
}

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int hcf=gcd(a,b);
    cout<<kfactor(hcf,k);
}

Measured memory_bytes: 3724
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x,y = LI()
    if x < 0:
        if y < 0:
            if x < y:
                print(y-x)
            else:
                print(x-y+2)
        else:
            if abs(x) < y:
                print(y-abs(x)+1)
            else:
                print(-y-x+(y>0))
    else:
        if y < 0:
            if x < abs(y):
                print(abs(y)-x+1)
            else:
                print(x+y+1)
        else:
            if x < y:
                print(y-x)
            else:
                print(x-y+(x>0)+(y>0))
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 41712
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll x;

int main() {
    fast_io; cout_precision;
    cin >> x;
    cout << ((x < 1200) ? "ABC" : "ARC") << endl;
}

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

int main() {
	int H, W;
	string S;
	cin >> H >> W;
	for (int i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		cin >> S;
		cout << "#" << S << "#" << endl;
	}
	for (int i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
#python3
from math import ceil
def main():
    a, b = map(int, input().split())
    a1 = 12.5*a
    a2 = 12.5*(a+1)
    b1 = 10*b
    b2 = 10*(b+1)
    if a2 <= b1:
        print('-1')
        return 
    if b2 <= a1:
        print('-1')
        return
    ans = max(ceil(a1), b1)
    print(ans)
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MEM 200005
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
typedef unsigned long long ull;
int n,m;
int a[MEM];
main()
{
    sanic; cin.tie(0);
    cin >> n;
    for(int i=1,q; i<n; i++){
        cin >> q;
        a[q]++;
    }
    for(int i=1; i<=n; i++)
        cout << a[i] << '\n';
}


Measured memory_bytes: 4440
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve() {
	int n;
	cin >> n;
	ll a = 2, b = 1;
	if (n == 1) {
		P(b);
		return;
	}
	else {
		int count = 0;
		while (count < n) {
			ll next = a + b;
			a = b;
			b = next;
			count++;
		}
	}
	P(a);
}

int main() {
	solve();
	return 0;
}


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

int f(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main(){
    int s;
    cin >> s;
    int a[1000000];
    long long ans=0;
    for(long long i=0;;i++){
        if(i==0){
            a[0]=s;
        }else{
            a[i]=f(a[i-1]);
        }
        for(long long j=0;j<i;j++){
            if(a[i]==a[j]){
                ans=i;
                break;
            }
        }
        if(ans!=0){
            break;
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  cout << round(N/2.0) << endl;

  return 0;
}


Measured memory_bytes: 3784
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
n,k= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
a = []
o = []
p = []
for i in range(n):
    c,d = (int(i) for i in input().split())
    o.append([c,d])
    a.append([d,c])
    p.append(d)
a.sort(reverse=True)

cstackd = []
nestackd = []
nestackt =[]
nneed = []
ctset = set()
sum = 0
for i in range(k):
    if a[i][1] in ctset:
        nneed.append(a[i][0])
    else : ctset.add(a[i][1])
    sum+=a[i][0]

ans = pow(len(ctset),2)+sum
for i in range(k,len(a)):
    if len(nneed) == 0: break
    if a[i][1] not in ctset: #種類がないばあい
        sum -= nneed.pop()
        sum+= a[i][0]
        ctset.add(a[i][1])
        ans = max (pow(len(ctset),2) + sum,ans)


print(ans)


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    if(n == 0) break;
    vector<int> v(n,0),v2(n,0) ;
    int prev = 0,suf = 0;
    vector<int> presuf(1,0);
    rep(i,n){
      cin >> v[i];
      if(i > 0){
        if(v[i] != prev){
          for(int k = presuf.size()-1; k >= 0; --k){
            if(prev == v[presuf[k]]){
              suf = presuf[k];
            }
            else{
              break;
            }
          }
          presuf.pb(i);
          prev = v[i];
          //         debug(suf);
          //         debug(prev);
        }
      }
      else{
        prev = v[0];
      }
      if((i+1) % 2 == 0){
        if(v[i] != v[i-1]){
          fill(v.begin()+suf,v.begin()+i,v[i]);
        }
      }
      //     debug(i);
      //     rep(j,i+1){
      //       cout << v[j];
      //     }
      //     cout << endl;
    }
    int ans = 0;
    rep(i,n){
      if(!v[i]) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4036
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 1e6 + 10;
int n, a[N];
int64_t ans;
char s[N];

int main() {
    scanf("%s", s + 1);
    n = int(strlen(s + 1)) + 1;
    for (int i = 1; i < n; i++)
        if (s[i] == '<')
            a[i] = std::max(a[i], a[i - 1] + 1);
    for (int i = n - 1; i; i--)
        if (s[i] == '>')
            a[i - 1] = std::max(a[i - 1], a[i] + 1);
    for (int i = 0; i < n; i++)
        ans += a[i];
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    while(true){
    int n,k,max=-1e9,sum=0;
    cin >> n >> k;
    if(n==0) break;
    int ar[n];
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;
        ar[i]=a;
    }
    
    for(int i=0;i<k;i++){
            sum += ar[i];
    }
    
        for(int j=0;j<n-k+1;j++){
            if(sum>max) max=sum;
            sum = sum + ar[k+j] - ar[j];
        }
    cout << max <<endl;
    }
}

Measured memory_bytes: 1548
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;

int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a / (double)b;
    cout << d << " ";
    cout << r << " ";
    cout << fixed;
    cout << setprecision(5);
    cout << f << endl;
}


Measured memory_bytes: 3340
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long a, b, c; cin >> a >> b >> c;
	int i;
	for (i = 0;; i++){
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << i << endl;
			return 0;
		}
		else if (a == b && c == b) {
			cout << -1 << endl;
			return 0;
		}
		int d = a / 2;
		int e = b / 2;
		int f = c / 2;
		a = e + f;
		b = d + f;
		c = d + e;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string in;
    int w;
    cin>>in;
    cin>>w;
    for(int i=0;; i+=w){
        if(in[i]==NULL)
            break;
        cout<<in[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
	map<int,int> mp;
    int a , b , c;
    cin >> a >> b >> c ;
    if(a==b){
    	cout << c << endl;
	}   
	else if(b==c)
	cout << a << endl;
	else cout << b << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> l(N);
    REP(i, N) cin >> l[i];
    sort(l.begin(), l.end(), greater<ll>());
    ll ans = 0;
    REP(i, K) ans += l[i];
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

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

    if (n - k >= k - 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

int main(){
	string S;
  	cin >> S;
  	if(S == "Sunny"){
    cout << "Cloudy";
    }
  else if(S == "Cloudy"){
  	cout << "Rainy";
  }else{
  	cout << "Sunny";
  }
  return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let mut h: Vec<usize> = vec(n, |_| scan(tokens));
    h.sort();
    h.reverse();
    let ans: usize = h.iter().skip(k).sum();
    println!("{}", ans);
}


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

ll a, b, x;

void solve()
{
	ll st= a/x;
	if(a%x) st++;
	ll ed = b/x;
	if(ed<st) cout<<0<<'\n';
	else cout<<ed-st+1<<'\n';
}

int main()
{
	cin >> a >> b >> x;
	solve();
	return 0;
}

Measured memory_bytes: 3612
c=[[0 for i in range(3)] for j in range(3)]


for i in range(3):
    c[i] =list(map(int,input().split()))
    
if c[0][0]+c[1][1] == c[0][1]+c[1][0] and c[0][0]+c[2][2]==c[0][2]+c[2][0] and \
c[1][1]+c[2][2]==c[1][2]+c[2][1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int i = 0, s, total = 0;
  while ( i < 10 ) {           // 繰り返し処理の範囲始まり
    scanf( "%d", &s );
    total += s;
    i++;
  }                            // 繰り返し処理の範囲終わり
  printf( "%d\n", total );
  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321
int N,M,K;
struct segTree{
	int T[100050];
	void update(int l, int r){
		for(;r>0;r-=(r&-r)) T[r]++;
		for(l--;l>0;l-=(l&-l)) T[l]--;
	}
	int query(int pos){
		int ret = 0;
		for(;pos<100050;pos+=(pos&-pos)) ret += T[pos];
		return ret;
	}
};
bool cmp(Pi a, Pi b){
	return a.Se-a.Fi < b.Se-b.Fi;
}

segTree tree;
int main(void){

	geti(N,M);
	vector<Pi> v;
	repp(i,N){
		int a,b; geti(a,b);
		v.push_back({a,b});
	}
	sort(all(v),cmp);
	int pos = 0;
	printf("%d\n",N);
	for(int i=2;i<=M;i++){
		while( pos < v.size() &&  v[pos].Se - v[pos].Fi + 1 < i ){
			//printf("%d %d\n",v[pos].Fi,v[pos].Se);
			tree.update(v[pos].Fi,v[pos].Se);
			pos++;
		}
		int ans = v.size()-pos;
		for(int j=i;j<=M;j+=i){
			ans += tree.query(j);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(N),b(1000001,0);
    set<int> s;
    int a_max = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        s.insert(a[i]);
        b[a[i]]++;
        
    }
    SORT(a);
    a_max = a[N - 1];
    /*if (s.size() == 1) {
        cout << 0 << endl;
    }*/

    for (int i = 0; i < N; ++i) {
        if (b[a[i]] == 0)continue;
        int k = 2;
        int j = a[i]*k;
        while (j <= a_max) {
            if (b[j] != 0) {
                b[j] = 0;

            }
            j /= k;
            k++;
            j *= k;
        }
    }
    cout << count(b.begin(), b.end(), 1) << endl;
    return 0;
}


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

int main(){
    int N, HP,count=0,j=0,k;
    long long throwP=0;
    cin >> N >> HP;
    int swordC[N],swordT[N];
    for (int i=0;i<N;i++){
        cin >> swordC[i] >> swordT[i];
    }
    sort(swordC,swordC+N);
    sort(swordT,swordT+N);
    for (k=N-1;k>=0;k--){
        if(swordC[N-1]>swordT[k]){
            break;
        }
    }

    for (int i=k+1;i<N;i++){
        throwP = throwP +swordT[i];
    }
    if(HP > throwP){
        HP = HP - throwP;
        while(HP>0){
            HP = HP - swordC[N-1];
            count = count +1;
        }
        cout << count + N-k-1 << endl;
    }else{
        while(HP>0){
            j++;
            HP = HP - swordT[N-j];
        }
        cout << j << endl;
    }
    return 0;
}

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

int main(){
	string s;
	int K;

	cin >> s >> K;

	for(int i=0;i<(int)s.size();i++){
		char c;
		c = s[i];

		int n = 26-(c-'a');
		if(i == s.size()-1){
			int k = (c-'a'+K)%26;
			s[i]='a'+k;
		}else if(n<26 && n<=K){
			s[i] = 'a';
			K-=n;
		}
	}

	cout << s << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

void add(ll &a,ll b){
  a+=b;
  if(a>=MOD) a-=MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  ll n=S.size();
  ll dp[100100][4]={0};
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++){
      if(S[i]=='?'){
        add(dp[i+1][j],dp[i][j]*3%MOD);
      }else{
        add(dp[i+1][j],dp[i][j]);
      }
    }
    if(S[i]=='A' || S[i]=='?')add(dp[i+1][1],dp[i][0]);
    if(S[i]=='B' || S[i]=='?')add(dp[i+1][2],dp[i][1]);
    if(S[i]=='C' || S[i]=='?')add(dp[i+1][3],dp[i][2]);
  }
  cout << dp[n][3] << endl;
  return 0;
}

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

#define NUM 1000001


int prime[NUM];
bool factor[NUM];

void seive(){
    
    for(int i=0;i<NUM;i++){
        prime[i] = -1;
        factor[i] = false;
    }

    
    for(int i=2;i*i<=NUM;i++){
        if(prime[i]==-1){
            for(int j=i*2;j<NUM;j+=i){
                if(prime[j]==-1){
                    prime[j] = i; 
                }
            }
        }
    }
    
}
bool prime_factors(int n){
    
    if(n==1)
        return true;

    set<int> temp;
    while(prime[n]!=-1){
        temp.insert(prime[n]);
        n /= prime[n];
    }
    temp.insert(n);
    for(auto itr=temp.begin();itr!=temp.end();itr++){
        if(!factor[*itr]){
            factor[*itr]=true;
        }
        else{
            return false;
        }
    }
    return true;
}

int main(){
    
    seive();
    
    int n;
    cin>>n;
    
    int temp;
    
    int gcd = 0;
    bool flag = true;
    for(int i=0;i<n;i++){
        cin>>temp;
        gcd = __gcd(temp,gcd);
        if(flag){
            flag = prime_factors(temp);
        }
    }

    
    if(flag){
        cout<<"pairwise coprime\n";
    }
    else if(gcd==1){
        cout<<"setwise coprime\n";
    }
    else{
        cout<<"not coprime\n";
    }
    
    
    return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	int n, a, b, c;

	cin >> n >> a >> b >> c;

	vector <int> l(n);

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


	int record = 1e9;

	for(int i = 0; i < (1 << (2 * n)); i++){
		bitset <16> x(i);

		int sum_a = 0, sum_b = 0, sum_c = 0;
		int cnt_a = 0, cnt_b = 0, cnt_c = 0;

		for(int j = 0; j < n * 2; j += 2){
			if(x[j]){
				if(x[j + 1]){
					sum_a += l[j / 2];
					cnt_a++;
				}else{
					sum_b += l[j / 2];
					cnt_b++;
				}
			}else{
				if(x[j + 1]){
					sum_c += l[j / 2];
					cnt_c++;
				}
			}
		}

		int cost_a = abs(sum_a - a) + (cnt_a - 1) * 10;
		int cost_b = abs(sum_b - b) + (cnt_b - 1) * 10;
		int cost_c = abs(sum_c - c) + (cnt_c - 1) * 10;

		if(cnt_a and cnt_b and cnt_c) record = min(record, cost_c + cost_b + cost_a);

	}


	cout << record << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string ans;
    if(s == "Sunny") ans = "Cloudy";
    if(s == "Cloudy") ans = "Rainy";
    if(s == "Rainy") ans = "Sunny";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def examB():
    S = SI()
    d = defaultdict(int)
    for s in S:
        d[s] +=1
    ans = "YES"
    if abs(d["a"]-d["b"])>1 or abs(d["b"]-d["c"])>1 or abs(d["c"]-d["a"])>1:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 39408
#include<stdio.h>

void sort(int* A,int* B,int* C){
	int backup;
	if(*B<=*C){
		int backup=*B;
		*B=*C;
		*C=backup;
	}
	if(*A<=*B){
		int backup=*A;
		*A=*B;
		*B=backup;
	}
	if(*B<=*C){
		int backup=*B;
		*B=*C;
		*C=backup;
	}
}

int main(void){
	int A;
	int B;
	int C;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	sort(&A,&B,&C);
	int kaisu=A-B;
	B=A;
	C+=kaisu;
	while(B-C>=2){
		C+=2;
		kaisu++;
	}
	if(B-C==0)
		printf("%d",kaisu);
	else
		printf("%d",kaisu+2);
}

Measured memory_bytes: 128
s=input()
t=input()
len_s=len(s)
len_t=len(t)
len_n=len_s-len_t
ans=100000
for i in range(0,len_n+1):
    cnt=0
    for j in range(len_t):
        if s[i+j]!=t[j]:
            cnt+=1

    ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 67812