akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 110
#define SZ 100010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
int A[SIZE][SIZE];
int dp[1<<21];
int func(int mask)
{
    //cout<<mask<<endl;
    if(!mask)
        return 1;
    if(dp[mask] != -1)
        return dp[mask];
    int fans = 0;
    int howMany = N - bitc(mask) + 1;
    for(int i=1;i<=21;i++){
        if(A[howMany][i]){
            if((mask>>(i-1))&1){
                mask ^= (1<<(i-1));
                fans = (fans + func(mask))%MOD;
                mask ^= (1<<(i-1));
            }
        }
    }
    dp[mask] = fans;
    return fans;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    cin>>N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin>>A[i][j];
        }
    }
    mem(dp,-1);
    cout<<func((1<<N)-1)<<endl;
    return 0;
}

Measured memory_bytes: 8448
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int ans=0;
    int n,m;
    cin >> n >> m;
    vector<pair<int,bool>> v;
    rep(i,n){
        int a;
        cin >> a;
        v.push_back({a,true});
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        if(v[a-1].first>=v[b-1].first){
            v[b-1].second = false;
        }if(v[a-1].first<=v[b-1].first){
            v[a-1].second = false;
        }
    }
    for(auto x:v){
        if(x.second){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


const int mod=1e9+7;
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}
inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 


const int M = 3e3 + 15;
int dp[M][M][3];

int X(int a, int b){
	if(a>b) return 0;
	else if (a<b) return 2;
	else return 1;
}
int pp[M][3];
int qq[M][3];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int N, Q;
	cin>>N>>Q;
	vi A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		for(int j=0;j<i;j++){
			dp[j][i][X(A[j], A[i])] = 1;		
		}
	}
	int i2 = inv(2); 
	int p2q = power(2,Q);
	while(Q--){
		int p, q;
		cin>>p>>q ; p--; q--;
		if(p>q) swap(p, q);
		// trace(p, q);
		for(int i=0;i<N;i++)
			for(int j=0;j<3;j++)
				pp[i][j] = dp[min(p,i)][max(p, i)][j];
		for(int i=0;i<N;i++)
			for(int j=0;j<3;j++)
				qq[i][j] = dp[min(i, q)][max(q, i)][j]; 
		for(int i=p+1;i<q;i++){
			for(int j=0;j<3;j++){
				dp[p][i][j] = add(dp[p][i][j], qq[i][2-j]); dp[p][i][j] = mul(dp[p][i][j], i2);
				dp[i][q][j] = add(dp[i][q][j], pp[i][2-j]); dp[i][q][j] = mul(dp[i][q][j], i2);
			}
		}
		for(int i=0;i<N;i++){
			if(p<=i && i<=q) continue;
			for(int j=0;j<3;j++){
				dp[min(i, p)][max(p, i)][j] = mul(i2, add(dp[min(i, p)][max(p, i)][j], qq[i][j]));
				dp[min(i, q)][max(q, i)][j] = mul(i2, add(dp[min(i, q)][max(q, i)][j], pp[i][j]));
			}
		}
		for(int j=0;j<3;j++){
			dp[p][q][j] = add(dp[p][q][j], qq[p][2-j]); dp[p][q][j] = mul(dp[p][q][j], i2);
		}
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<i;j++){
			// trace(i, j, dp[j][i][0], dp[j][i][1], dp[j][i][2]);
			ans = add(ans, dp[j][i][0]);
		}
	}
	ans = mul(ans,  p2q);
	cout<<ans<<"\n";
}


Measured memory_bytes: 106752
N = int(input())
S = input()


class RollingHash:
    base1 = 1007
    base2 = 2009
    mod1 = 10 ** 9 + 7
    mod2 = 10 ** 9 + 9
    
    def __init__(self, s):
        self.s = s
        
        n = len(s)
        self.hash1 = [0] * (n + 1)
        self.hash2 = [0] * (n + 1)
        self.power1 = [1] * (n + 1)
        self.power2 = [1] * (n + 1)
        for i in range(n):
            self.hash1[i + 1] = (self.hash1[i] * self.base1 + ord(s[i])) % self.mod1
            self.hash2[i + 1] = (self.hash2[i] * self.base2 + ord(s[i])) % self.mod2
            self.power1[i + 1] = (self.power1[i] * self.base1) % self.mod1
            self.power2[i + 1] = (self.power2[i] * self.base2) % self.mod2
            
    def get_hash(self, l, r):
        """Gets hash of S[left:right]"""
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.mod1
        if res1 < 0:
            res1 += self.mod1
        res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.mod2
        if res2 < 0:
            res2 += self.mod2
            
        return (res1, res2)
    
    def get_lcp(self, a, b):
        """Gets lcp of S[a:] and S[b:]"""
        low = 0
        high = min(len(self.hash1) - a, len(self.hash1) - b)
        
        while high - low > 1:
            mid = (low + high) >> 1
            if self.get_hash(a, a + mid) != self.get_hash(b, b + mid):
                high = mid
            else:
                low = mid
                
        return low


def check(d):
    ctr = {}
    for i in range(N - d + 1):
        p = rh.get_hash(i, i + d)
        if p in ctr:
            if i - ctr[p] >= d:
                return True
        else:
            ctr[p] = i
            
    return False


rh = RollingHash(S)
left = 0
right = N // 2 + 1
while right - left > 1:
    mid = (left + right) >> 1
    if check(mid):
        left = mid
    else:
        right = mid

print(left)


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

int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);
  vector<long long> b(N);
  for(int i=0;i<N;i++)  cin >> b.at(i);

  long long cntB=0;
  for(int i=0;i<N;i++){
    if(a.at(i)<b.at(i)){
      long long tmp=(b.at(i)-a.at(i)+1)/2;
      cntB+=tmp;
      a.at(i)+=tmp*2;
    }
  }
  for(int i=0;i<N;i++){
    cntB-=a.at(i)-b.at(i);
  }

  if(cntB>=0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int appeared[26]={};
int main(void){
	char S[100001];
	scanf("%s",S);
	int Slen = strlen(S);
	int i;
	for(i=0;i<Slen;i++){
		appeared[S[i]-'a']++;
	}
	for(i=0;i<26;i++){
		if(appeared[i]==0){
			printf("%c",i+'a');
			return 0;
		}
	}
	printf("None");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [-1] * n
c = [None] * n
dp = [-1] * n
h = [None] * n
sb = [-1] * n
k = [None] * n
deg = [-1] * n

for i in range(n):
    id, l, r = map(int, input().split())
    c[id] = [l, r]

for i in range(n):
    l, r = c[i]
    if l>=0:
        p[l] = i
    if r>=0:
        p[r] = i

for i in range(n):
    d = 0
    pr = p[i]
    while pr>=0:
        d += 1
        pr = p[pr]
    dp[i] = d
    
def get_height(idx):
    if sum(c[idx]) == -2:
        return 0
    else:
        return max(get_height(c[idx][0]), get_height(c[idx][1])) + 1

h = [get_height(i) for i in range(n)]

for l, r in c:
    if l>=0 and r>=0:
        sb[l] = r
        sb[r] = l
for i in range(n):
    if p[i]==-1:
        k[i]='root'
    elif sum(c[i]) == -2:
        k[i]='leaf'
    else:
        k[i]='internal node'
        
for i in range(n):
    l, r = c[i]
    if l==-1 and r==-1:
        deg[i]=0
    elif l>=0 and r>=0:
        deg[i]=2
    else:
        deg[i]=1
    print('node %i: parent = %i, sibling = %i, degree = %i, depth = %i, height = %i, %s'%(i, p[i], sb[i], deg[i], dp[i], h[i], k[i]))




Measured memory_bytes: 5620
n, x, m = gets.split.map(&:to_i)

a = []
h = {}
n.times do |i|
  if h.key?(x)
    j = h[x]
    ans = (0...j).sum{|e| a[e]}
    ans += (j...i).sum{|e| a[e]} * ((n-j)/(i-j))
    ans += (j...(j + (n-j) % (i-j))).sum{|e| a[e]}
    puts ans
    exit
  else
    a << x
    h[x] = i
    x = x*x%m
  end
end

puts a.sum

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

int gcd(int a, int b) {
  while(true){
    if(a < b) swap(a,b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {
  int N, ans;
  cin >> N;
  vector<int> A(N), g(N), rg(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  g.at(0) = A.at(0);
  rg.at(N-1) = A.at(N-1);
  for(int i = 1; i < N; i++) {
    g.at(i) = gcd(g.at(i-1), A.at(i));
  }
  for(int i = N-2; i >= 0; i--) {
    rg.at(i) = gcd(rg.at(i+1), A.at(i));
  }
  ans = max(g.at(N-2), rg.at(1));
  for(int i = 1; i < N-1; i++) {
    ans = max(ans, gcd(g.at(i-1), rg.at(i+1))); 
  }
  cout << ans;
}

Measured memory_bytes: 1408
from itertools import product

D, G = map(int, input().split())
pc = [[int(x) for x in input().split()] for _ in range(D)]

C = [0] * D
for i in range(D):
    p, c = pc[i]
    C[i] = 100 * (i + 1) * p + c

ans = float('inf')
for ptn in product([0, 1], repeat=D):
    point, cnt = 0, 0
    for i in range(D):
        p, c = pc[i]
        cnt += p * ptn[i]
        point += C[i] * ptn[i]

    if 0 in ptn:
        index = D - 1 - ptn[::-1].index(0)
        p, _ = pc[index]
        for i in range(p):
            if point >= G:
                break            
            point += 100 * (index + 1)
            cnt += 1

    if point >= G:
        ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<stack>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second

int N, K;
int T[100009];
int mt[100009];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	int BEGIN = T[0], END = T[N - 1] + 1;
	for (int i = N - 1, j = 0; i > 0; i--, j++) {
		mt[j] = T[i] - T[i - 1] - 1;
		/*
		cout << j << " " << mt[j] << endl;
		*/
	}
	sort(mt, mt + (N - 1));
	reverse(mt, mt + (N - 1));
	int ans = END - BEGIN;
	/*
	cout << ans << endl;
	*/
	for (int i = 0; i < K - 1; i++) {
		ans -= mt[i];
	}
	cout << ans << endl;

	return 0;
}

//碁石並べ
/*
int n, ans = 0;
int c[100009];
stack<int>C;

int main() {// 0,- >> white | 1,+ >> black
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
		if (i == 1) {
			if (c[1] == 0)C.push(-1);
			else C.push(1);
		}
		else if (i % 2 == 1) {//odd
			if (c[i] != c[i - 1]) {
				if (c[i] == 0)C.push(-1*i);
				else C.push(i);
			}
		}
		else {//even
			if (c[i] = !c[i - 1]) {
				if (abs(C.top()) == 1)C.top() *= -1;
				else C.pop();
			}
		}
	}
	while (!C.empty()) {
		if (C.top() > 0) {
			int bs = C.top();
			C.pop();
			int ws = C.top();
			ans += n + C.top();
		}
		else {
			ans += n + 1 - C.top();
		}
		C.pop();
	}
	cout << ans << endl;
	return 0;
}
*/


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size() + t.size();
  for (int i = 0, j = 0, k = 0; i < n; ++i) {
    char ch = i % 2 == 0 ? s[j++] : t[k++];
    printf("%c", ch);
  }
  printf("\n");
  return 0;
}


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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int A, B, C;
  cin >> A >> B >> C;

  C = min(C, A + B + 1);
  cout << B + C << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define PB push_back
#define ub upper_bound
#define lb lower_bound
#define ins insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
int main()
{
    ll a,flag=0;
    cin>>a;
    while(a!=0)
    {
        ll r=a%10;
        if(r==7)
        {
            cout<<"Yes";
            flag=1;
            break;
        }
        a/=10;
    }
    if(flag==0)
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3584
class BIT:
    def __init__(self, n):
        self.node = [ 0 for _ in range(n+1) ]

    def add(self, idx, w):
        i = idx
        while i < len(self.node) - 1:
            self.node[i] += w
            i |= (i + 1)

    def sum_(self, idx):
        ret, i = 0, idx-1
        while i >= 0:
            ret += self.node[i]
            i = (i & (i + 1)) - 1
        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)

n, q = map(int, input().split())
tree = BIT(n)

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        tree.add(x-1, y)
    if com == 1:
        print(tree.sum(x-1, y))


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

int main(){
    bool nonprime[1000000] = {};
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i < 1000000; i++){
        if(!nonprime[i]){
            for(int j = i+i; j < 1000000; j+=i) nonprime[j] = true;
        }
    }

    int a, d, n;
    while(cin >> a >> d >> n, a+d+n){
        while(1){
            if(!nonprime[a])    n--;
            if(n == 0)  break;
            a += d;
        }
        cout << a << endl;
    }
    return 0;
}


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

typedef long long int ll;
typedef long double ld;

using namespace std;


int main()
{
    ll n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3==0 && i%5==0){
            sum+=0;
        }
        else if(i%3==0){
            sum+=0;
        }else if(i%5==0){
            sum+=0;
        }
        else{
            sum+=i;
        }
    }
    cout<<sum<<endl;

    //cout<<"Case "<<cn<<": "<<"good"<<endl;
    return 0;
}


Measured memory_bytes: 3676
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;


int main()
{
  ll x,k,d,ans;
  cin>>x>>k>>d;
  x=abs(x);
  //ll s=llround(((double)x)/((double)d));
  ll s=x/d;
  s++;
  if(k<s) ans=x-(k*d);
  else
  {
   ll v0=x-(d*s);
   ll v1=v0+d;
    //cout<<v0;
   s=k-s;
   if(s%2) ans=v1;
   else ans=v0;
  }
  ans=abs(ans);
  pf(abs(ans));
}


Measured memory_bytes: 3284
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int d,e;
        cin >> d >> e;
        if(d==e){
            cnt++;
        }else{
            cnt=0;
        }

        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(13<=a){
		printf("%d\n",b);
	}
	else if(6<=a&&12>=a){
		printf("%d\n",b/2);
	}
	else{
		printf("0\n");
	}
	return 0;
}


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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	if(s[0] == s[s.size()-1]){
		if(s.size()%2) cout << "Second" << endl;
		else cout << "First" << endl;
	}
	else{
		if(s.size()%2) cout << "First" << endl;
		else cout << "Second" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

bool chk(ll N, ll A, ll B, const vector<ll> &h, ll T) {
  ll check = 0;
  REP(i, N) {
    if (h[i] - B * T <= 0)
      continue;
    check += (h[i] - B * T + A - B - 1) / (A - B);
  }
  // cout << T << " " << check << endl;
  return check <= T;
}

void solve(long long N, long long A, long long B, vector<long long> h) {
  ll b = 1L << 30;
  ll ans = (b * 2L) - 1;

  for (; b; b >>= 1) {
    ll t = ans - b;
    if (chk(N, A, B, h, t))
      ans = t;
    // cout << ans << endl;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long A;
  long long N;
  long long B;
  cin >> N;
  vector<long long> h(N - 1 + 1);
  cin >> A;
  cin >> B;
  for (int i = 0; i <= N - 1; i++) {
    cin >> h[i];
  }
  solve(N, A, B, h);
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    int a[11];
    memset(a, 0, sizeof a);
    int A, B, C;
    cin >> A >> B >> C;
    a[A]++;
    a[B]++;
    a[C]++;
    if(a[5] == 2 && a[7] == 1) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1;
        
        while(true){
            int a = sc.nextInt();
            if(a == 0)
                break;
            System.out.println("Case " + i + ": " + a);
            i++;
        }
    }
}


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

int main(){
  int n;
  long hoge, sum = 0, sum1 = 0, sum2 = 0;
  std::vector<long> a;
  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::cin >> hoge;
    a.push_back(hoge);
  }
  std::sort(a.begin(), a.end(), std::greater<long>());

  for(int i = 0; i < n; i++){
    if(n % 2 == 0){
      if(i < n / 2 - 1) sum += a[i] * 2;
      else if(i == n / 2 - 1) sum += a[i];
      else if(i == n / 2) sum -= a[i];
      else sum -= a[i] * 2;
    }
    else{
      if(i < (n - 1) / 2 - 1) sum1 += a[i] * 2;
      else if(i == (n - 1) / 2 - 1) sum1 += a[i];
      else if(i == (n - 1) / 2) sum1 += a[i];
      else sum1 -= a[i] * 2;

      if(i < (n - 1) / 2) sum2 += a[i] * 2;
      else if(i == (n - 1) / 2) sum2 -= a[i];
      else if(i == (n - 1) / 2 + 1) sum2 -= a[i];
      else sum2 -= a[i] * 2;

      sum = std::max(sum1, sum2);
    }
  }
  std::cout << sum << std::endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;
int64 N, X;
vector<int64> lay, pat;

int64 dfs(int64 lev, int64 rest){
	if(lev < 0) return 0;
	if(rest <= 0) return 0;
	if(rest == 1) return lev == 0;
	if(lay[lev] <= rest) return pat[lev];
	return dfs(lev-1, rest-1)+dfs(lev-1, rest-lay[lev-1]-2)+(rest >= lay[lev-1]+2 ? 1 : 0);
}

int main(void){
	cin >> N >> X;
	lay.resize(N+1); pat.resize(N+1);
	lay[0] = 1; pat[0] = 1;
	FOR(i, 1, N+1){
		lay[i] = lay[i-1]*2+3;
		pat[i] = pat[i-1]*2+1;
	}
	cout << dfs(N, X) << endl;
}


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

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

/*
クエリN<=K<=2N を試す

Kまでの大きいほうからN個の和、K以降の小さいほうからN個の和を取りたい



*/

int main() {

    int N; cin >> N;
    vector<int> a(3*N);
    for (int i = 0; i < 3 * N; i++) cin >> a[i];
    vector<ll> S1(N+1,0), S2(N+1,0);

    ll s1 = 0, s2 = 0;
    priority_queue<int> que;
    priority_queue<int, vector<int>, greater<int> > QUE;
    for (int i = 0; i < N; i++) {
        s1 += a[i]; QUE.push(a[i]);
        s2 += a[3*N-i-1]; que.push(a[3*N-i-1]);
    }
    S1[0] = s1; S2[N] = s2;
    for (int i = 0; i < N; i++) {
        s1 += a[i+N]; QUE.push(a[i+N]);
        s1 -= QUE.top(); QUE.pop();
        S1[i+1] = s1;
    }
    for (int i = N-1; i >= 0; i--) {
        s2 += a[i+N]; que.push(a[i+N]);
        s2 -= que.top(); que.pop();
        S2[i] = s2;
    }
    ll res = -1e18;
    for (int i = 0; i <= N; i++) {
        chmax(res,S1[i] - S2[i]);
    }
    cout << res << endl;








}


Measured memory_bytes: 3964
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

const int INF = 1<<30;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        char mat[m][n];
        int si, sj;
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                cin >> mat[i][j];
                if(mat[i][j]=='&')  mat[i][j] = '.', si = i, sj = j;
            }
        }
        vector<vector<bool>> visit(m, vector<bool>(n, 0));
        vector<vector<int>> d(m, vector<int>(n, INF));
        queue<pair<int,pair<int,int>>> pq;
        pq.push({0,{si,sj}});
        while(!pq.empty()){
            auto p = pq.front();    pq.pop();
            int cost = p.first, i = p.second.first, j = p.second.second;
            if(d[i][j] <= cost)   continue;
            d[i][j] = cost;
            for(int k = 0; k < 4; k++){
                int ni = i+di[k], nj = j+dj[k];
                if(!inRange(ni,0,m)||!inRange(nj,0,n))  continue;
                int ncost = cost + (mat[i][j]=='.'&&mat[ni][nj]=='#');
                if(d[ni][nj] > ncost)   pq.push({ncost,{ni,nj}});
            }
        }
        int ans = 1<<30;
        for(int i = 0; i < m; i++)  ans = min({ans, d[i][0], d[i][n-1]});
        for(int j = 0; j < n; j++)  ans = min({ans, d[0][j], d[m-1][j]});
        cout << ans << endl;
    }
    return 0;
}


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

int n;
string s;
set<string> ss;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    while (n--){
        cin >> s;
        ss.insert(s);
    }
    cout << (int)ss.size() << "\n";
    return 0;
}

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<vector<int>> num_ways(n + 1, vector<int> (k + 1, 0));
	for (int i = 0; i <= n; i++) {
		num_ways[i][0] = 1;
	}
	num_ways[0][0] = 1;
	for (int j = 1; j <= k; j++) {
		num_ways[0][j] = 0;
	}
	vector<int> prev_prefix(k + 1, 0);
	prev_prefix[0] = num_ways[0][0];
	for (int i = 1; i <= k; i++) {
		prev_prefix[i] = prev_prefix[i - 1] + num_ways[0][i];
		prev_prefix[i] %= MOD;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			num_ways[i][j] += prev_prefix[j];
			num_ways[i][j] %= MOD;
			if (max(j - a[i - 1], 0ll) - 1 >= 0) {
				num_ways[i][j] -= prev_prefix[max(j - a[i - 1], 0ll) - 1];
				if (num_ways[i][j] < 0) {
					num_ways[i][j] += MOD;
				}
			}
		}
		prev_prefix[0] = num_ways[i][0];
		for (int pos = 1; pos <= k; pos++) {
			prev_prefix[pos] = prev_prefix[pos - 1] + num_ways[i][pos];
			prev_prefix[pos] %= MOD;
		}
	}
	cout << num_ways[n][k] << endl;

	return 0;
}

Measured memory_bytes: 82972
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k){
    cout << s << endl;
  }else{
    cout << s.substr(0,k) << "...\n";
  }
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main()
{
    int a[100],b[100];
    char op[100];

    for(int i=0;;i++){
        cin>>a[i]>>op[i]>>b[i];
        if(op[i]=='?')  break;
    }

    for(int i=0;;i++){
        if(op[i]=='+')  cout<<a[i] + b[i]<<'\n';
        if(op[i]=='-')  cout<<a[i] - b[i]<<'\n';
        if(op[i]=='*')  cout<<a[i] * b[i]<<'\n';
        if(op[i]=='/')  cout<<a[i] / b[i]<<'\n';
        if(op[i]=='?')  break;
    }
}


Measured memory_bytes: 3116
#include<bits/extc++.h>
#ifndef __unix__
#define fread_unlocked fread
#endif
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define pb emplace_back
#define rep(_n) for(int __i = _n;__i--;)
#define rep0(_i, _n) for(int _i = 0; (_i)<(_n) ;++_i)
#define rep1(_i, _n) for(int _i = 1; (_i)<=(_n) ;++_i)
#define yn(i) ((i)?"Yes" : "No")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define multi int _T;for(read(_T);_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
inline char readchar(){static const unsigned bufsize = 1 << 16; static unsigned p = 0, end = 0; static char buf[bufsize]; if (p == end) end = fread_unlocked(buf, sizeof(char), bufsize, stdin), p = 0; return p == end ? EOF : buf[p++]; }
inline void read(char &a){while(isspace(a = readchar()));}
inline void read(char *a){while(isspace(*a = readchar()));++a; while(isgraph(*a = readchar()))++a;}
inline void read(string &a){static char p; while(isspace(p = readchar())); a = p; while(isgraph(p = readchar()))a.push_back(p);}
template<typename T> inline void read(T& a){static char p; static bool b;while (!isdigit(p = readchar()))b = p == '-'; a = p ^ '0'; while (isdigit(p = readchar())) a *= 10, a += p ^ '0'; if(b)a *= -1, b = false; }
template<typename T1, typename T2> inline void read(pair<T1, T2> &a){read(a.first), read(a.second);}
template<typename T> inline void read(T begin, const T &end){while(begin != end)read(*begin), ++begin;}
inline void R(){} template<class T1, class... T2> inline void R(T1 &h, T2 &... e){read(h), R(e...);}
template<typename T> inline void write(T begin, const T &end){while(begin != end)cout << *begin << " \n"[next(begin) == end], ++begin;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
int m, d;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	R(m, d);
	vector<int>res{31,28,31,30,31,30,31,31,30,31,30,31};
	rout((res[m-1] == d));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    if(A==B && B==C) ans = (A%2 ? 0 : -1);
    else{
        while(!(A%2 || B%2 || C%2)){
            int tA = A, tB = B, tC = C;
            A = (tB+tC)/2;
            B = (tC+tA)/2;
            C = (tA+tB)/2;
            ans++;
        }
    } 

    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(x[k-1])

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, H[100000], ans=0, t[100000] = {}, c = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	} 

	for (int i = 0; i < N-1; i++)
	{
		if (H[i] >= H[i + 1]) {
			t[c]++;
		}
		else {
			c++;
			
		}
	}
	for (int i = 0; i < N; i++)
	{
		ans = max(ans, t[i]);
	}

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

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final long N = Integer.parseInt(sc.next());
        char[] ch = sc.next().toCharArray();
        char pre = ch[0];
        long ans = 1;
        
        for (int i = 0; i < N; i++) {
            if (pre != ch[i]) {
                pre = ch[i];
                ans++;
            }
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 28624
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-04T03:50:03+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-17T01:04:01+09:00
 */



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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/


/******** User-defined Function *******/
void solve(){
    while(1){
        int n,x; cin >> n >> x;
        if(n==0 && x==0) break;

        int ans = 0;
        rep1(i,n){
            FOR(j,i+1,n+1,1){
                FOR(k,j+1,n+1,1){
                    if(i+j+k==x)  ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return;
}
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  solve();

  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 3176
n = int(input())
plist = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
    if max(plist[i-1], plist[i], plist[i+1]) != plist[i] and min(plist[i-1], plist[i], plist[i+1]) != plist[i]:
        ans += 1
print(ans)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li a[3];
    rep(i, 3)cin >> a[i];
    sort(a, a + 3);
    cout << a[2] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for k in range(n):
  for i in range(n-1):
    for j in range(i+1,n):
      if a[i][j] > a[i][k] + a[k][j]:
        print(-1); exit(0)

for i in range(n-1):
  for j in range(i+1,n):
    for k in range(n):
      if k == i or k == j: continue
      elif a[i][j] == a[i][k] + a[k][j]:
        cnt += a[i][j]
        break
tot = sum(sum(x) for x in a)//2
print(tot-cnt)

Measured memory_bytes: 45020
a = list(input())
b = list(input())
c = list(input())
po = a.pop(0)

while True:
    if po == 'a':
        if len(a) == 0:
            ans = 1
            break
        else:
            po = a.pop(0)
    elif po == 'b':
        if len(b) == 0:
            ans = 2
            break
        else:
            po = b.pop(0)
    elif po == 'c':
        if len(c) == 0:
            ans = 3
            break
        else:
            po = c.pop(0)
    

if ans == 1:
    print('A')
elif ans == 2:
    print('B')
elif ans == 3:
    print('C')
    
    


Measured memory_bytes: 3064
n = int(input())
S = input()
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):
    for j in range(i+1, n):
        cur = j-i
        if j+cur <= n-1:
            if S[i] != S[j] and S[j] != S[j+cur] and S[j+cur] != S[i]:
                ans -= 1
print(ans)


Measured memory_bytes: 73624
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{	
	int N, L;
	bool b = false;
	cin >> N >> L;
	vector<int> v(N);
	REP(i, N) v[i] = L+i;
	REP(i, N) if(v[i] == 0) b = true;
	
	if(!b){
		if(v[N-1] > 0) cout << accumulate(ALL(v), 0) - v[0] << endl;
		else if(v[N-1] < 0) cout << accumulate(ALL(v), 0) - v[N-1] << endl;
	}
	else cout << accumulate(ALL(v), 0) << endl;



}


Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
// all_of

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
string s;
int K;

int co(char a) {
	return a == 'a' ? 0 : 'z' - a + 1;
}

int main() {
	cin >> s >> K;
	REP(i, 0, s.size()) {
		int c = co(s[i]);
		if (c <= K) {
			s[i] = 'a';
			K -= c;
		}
	}
	int b = s.back() - 'a';
	s.back() = 'a' + (b + K) % 26;
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	a, b, c := 0, 1, 2
	h := make([][3]int, n+1)
	for i := 1; i <= n; i++ {
		h[i][a] = readInt()
		h[i][b] = readInt()
		h[i][c] = readInt()
	}

	dp := make([][3]int, n+1)
	for i := 1; i <= n; i++ {
		for j := range h[i] {
			k := (j + 1) % 3
			l := (j + 2) % 3
			dp[i][j] = h[i][j] + max(dp[i-1][k], dp[i-1][l])
		}
	}
	println(max(dp[n][a], max(dp[n][b], dp[n][c])))
}

// -----------------------------------------------------------------------------

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 7040
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

const ll INF = 1LL << 60;

void solve() {
    inl(N, M);

    vector<vector<ll>> d(N, vector<ll>(N, INF));
    rep(i, N) d[i][i] = 0;
    rep(i, M) {
        inl(a, b, c);
        a--; b--;
        d[a][b] = d[b][a] = c;
    } 
    vector<vector<ll>> costs(d);

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
            }
        }
    }

    ll used = 0;
    rep(i, N) {
        for(ll j = i + 1; j < N; j++) {
            if (d[i][j] == costs[i][j])
                used++;
        }
    }
    out(M - used);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    int k; cin >> k;
    int res=0;
    //for(int i=1; i<=max(a,b); i++){
    for(int i=min(a,b); i>=0; i--){
        if(a%i==0 && b%i==0) res++;
        if(res==k){
            cout<<i<<endl;
            return 0;
        }
    }
}

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


int main(void) {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> vs(h, vector<char>(w));
  rep(j, h) {
    rep(i, w) {
      cin >> vs[j][i];
    }
  }

  vector<vector<char>> ans(h, vector<char>(w));
  rep(j, h) {
    rep(i, w) {
      if (vs[j][i] == '#') {
        ans[j][i] = '#';
        continue;
      }
      int count = 0;
      for (int y = j - 1; y <= j + 1; ++y) {
        for(int x = i - 1; x <= i + 1; ++x) {
          if (y < 0 || y >= h || x < 0 || x >= w) continue;
          if (vs[y][x] == '#') {
            count++;
          }
        }
      }
      ans[j][i] = '0' + count;
    }
  }

  rep(j, h) {
    rep(i, w) {
      cout << ans[j][i];
    }
    cout << endl;
  }
  
  return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

////////////////////////////////////////////////////////////////

int main(void) {
	ll N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A.begin(), A.end());

	const ll MAX = A.back();
	vector<ll> vec(MAX+1, 0);
	for(ll a : A){
		for(ll i=1; i*a<=MAX; i++){
			vec[i*a]++;
		}
	}

	ll ans = 0;
	for(ll a : A){
		if(vec[a] == 1) ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 12636