akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}
    val s = Array(H + 2) {
        if (it == 0 || it == H + 1) {
            String(CharArray(W + 2) { '*' })
        } else {
            "*" + readLine()!! + "*"
        }
    }

    val dd = arrayOf(-1, 0, 1, 0)
    val g = Graph<Long>((H + 2) * (W + 2), 0L, 1e15.toLong()) {a, b -> a + b}

    for (i in 1..H) for (j in 1..W) {
        if (s[i][j] != '.') continue
        for (k in dd.indices) {
            if (s[i][j] != '.') {
                continue
            }

            val ni = i + dd[k]
            val nj = j + dd[3 - k]

            val u = i * (W + 2) + j
            val v = ni * (W + 2) + nj
            g.edges[u].add(Edge(u, v, 1L))
        }
    }

    val res = dijkstra(g, (W + 2) + 1).first
    val dist = res[(W + 2) * (H + 1) - 2]

    if (dist == g.inf) {
        println(-1)
    } else {
        println(H * W - dist - 1 - s.map { it.count { it == '#' } }.sum())
    }
}

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

inline fun <reified T: Comparable<T>>dijkstra(g: Graph<T>, s: Int): Pair<Array<T>, Array<Int>> {
    val N = g.n
    val dist = Array(N) { g.inf }
    val prev = Array(N) {-1}

    val Q = PriorityQueue<Edge<T>>()

    dist[s] = g.zero
    Q.add(Edge(-2, s, g.zero))

    while(Q.isNotEmpty()) {
        val e = Q.peek()
        val v = e.to
        Q.poll()

        if (prev[v] != -1) continue
        prev[v] = e.from
        for (i in g.edges[v]) {
            val d = g.plus(dist[v], i.weight)
            if (dist[i.to] > d) {
                dist[i.to] = d
                Q.add(Edge(i.from, i.to, d))
            }
        }
    }

    return Pair(dist, prev)
}


Measured memory_bytes: 37864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n, 0);
    rep1(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 1e10;
    rep1(i, n-k+1){
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long K, vector<long long> a){
	vector<ll> zsum(N+1);
	repn(i, N) {
		zsum[i] = zsum[i-1] + max(a[i-1], 0LL);
	}
	ll res = 0, ksum = 0;
	rep(i, K) {
		ksum += a[i];
	}
	rep(i, N-K+1) {
		ll other = zsum[N]-zsum[i+K]+zsum[i];
		// cout << i << ": " << ksum << " " << other << endl;
		res = max(res, max(other, ksum+other));
		ksum -= a[i];
		if (i != N-K) ksum += a[i+K];
	}
	cout << res << endl;
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, K, a);
	return 0;
}



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

using namespace std;

typedef long long ll;


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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b) cout <<  "delicious" << endl;
    else if((b - a) <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}



Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    a = [SS() for _ in range(H)]

    print('#' * (W + 2))
    for i in a:
        print('#' + i + '#')
    print('#' * (W + 2))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9972
s = input()
t = input()
dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1)
        dp[i][j] = max(dp[i][j], dp[i][j-1])
        dp[i][j] = max(dp[i][j], dp[i-1][j])

ans = ''
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += t[j-1]
        i -= 1
        j -= 1
   
print(ans[::-1])

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

int main() {
  int N;
  cin >> N;
  
  long a = 2;
  long b = 1;

  if (N == 1) {
    cout << 1 << endl;
  }
  else {
    for (int i = 0; i < (N - 1); i++) {
      b += a;
      a = b - a;
    }
  }
  if (!(N == 1))
  	cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define INF ((1LL<<62)-(1LL<<31))  // 浮動小数点型
#define bit(n,m)(((n)>>(m))&1)  // nのmビット目が1
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
    int n, x, t; cin >> n >> x >> t;
    cout << (n-1+x)/x * t << endl;
    
}

/*
g++ c.cpp
./a.out


oj d
g++ c.cpp
oj t
*/


Measured memory_bytes: 3604
import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

prcs :: IO (String, Int)
prcs = do
  (nm : tm : _) <- words <$> getLine
  return (nm, read tm)

ex
  :: Int
  -> Int
  -> [(String, Int)]
  -> State ([String], [(String, Int)]) [(String, Int)]
ex q tms [] = do
  (rs, ts) <- get
  case ts of
    [] -> return []
    _  -> do
      put (rs, [])
      ex q tms (reverse ts)
ex q tms ((nm, tm) : ts)
  | q < tm = do
    (rs, sts) <- get
    put (rs, (nm, tm - q) : sts)
    ex q (tms + q) ts
  | otherwise = do
    (rs, sts) <- get
    put ((nm ++ " " ++ show (tms + tm)) : rs, sts)
    ex q (tms + tm) ts

main = do
  (n : q : _) <- map read . words <$> getLine
  ts          <- replicateM n prcs
  mapM_ putStrLn (reverse $ fst $ execState (ex q 0 ts) ([], []))


Measured memory_bytes: 54312
l = input().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if (x >= r and y >= r) and (x <= (W - r) and y <= (H - r)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	cout << (a+b-3)/(a-1) << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

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

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

int N,K;
ll X[101], Y[101];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,N) cin >> X[i] >> Y[i];

    set<int> xx, yy;
    rep(i,N) xx.insert(X[i]);
    rep(i,N) yy.insert(Y[i]);
    ll ans = -1;
    for(auto &sx : xx) for(auto &sy : yy) for(auto &tx : xx) for(auto &ty : yy) if(sx <= tx and sy <= ty){
      ll sm = 1LL * (tx - sx) * (ty - sy);
      int c = 0;
      rep(i,N) if(sx <= X[i] and X[i] <= tx and sy <= Y[i] and Y[i] <= ty) c++;
      if(K <= c){
        if(ans < 0) ans = sm;
        ans = min(ans,sm);
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1e16
#define MOD 1e9+7
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


int main(){
    string s;
    int n,q,i,j,ans, l, r;
    bool a = false;
    cin >> n >> q >> s;
    int cnt[n] = {};
    for(int i = 1; i < n; i++){
        cnt[i] = cnt[i - 1];
        if(s[i] == 'C' && s[i - 1] == 'A'){
            cnt[i]++;
        }
    }
    for(i=0 ; i<q ; i++){
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }

}



Measured memory_bytes: 1408
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = sorted(LI())
    if n <= m:
        return 0

    return sum(a[:n-m])


print(main())





Measured memory_bytes: 29428
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=[]
for i in range(n):
    k=int(input())
    tem=[]
    for j in range(k):
        x,y=mp()
        tem.append([x-1,y])
    a.append(tem)

ans=[0]
for i in range(2**n):
    ch=1
    for k in range(0,n):
        if ((i>>k)&1):
            for q in a[k]:
                if ((i>>q[0])&1)==(q[1]^1):
                    ch=0

    if ch==1:
        ans.append(bin(i).count("1"))
print(max(ans))

Measured memory_bytes: 80388
#include <iostream>

using namespace std;

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

	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// ABC042_A 和風いろはちゃんイージー

#include <stdio.h>

int main(void) {
    
    int input = 0;
    int five = 0;
    int seven = 0;
    int i = 0;

    // input
    for (i = 0; i < 3; i++) {
        scanf("%d", &input);
        if (input == 5) {
            five++;
        } else if (input == 7) {
            seven++;
        }
    }

    // output
    if (five == 2 && seven == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = NextInt()
        Dim X As Integer = NextInt()

        Dim up, down As Integer

        For i As Integer = 0 To M - 1
            Dim Ai As Integer = NextInt()

            If Ai < X Then
                down += 1
            Else
                up += 1
            End If
        Next

        WriteLine(Math.Min(up, down))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main()
{
	int a, b;
	char buf[1024];

	while ( fgets( buf, sizeof( buf ) - 1, stdin ) != NULL )
	{
		if ( buf[0] == '\n' )
			return 0;

		sscanf( buf, "%d %d", &a, &b );
		printf("%d\n", ( int )( log10( a + b ) + 1 ) );
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
using namespace std;

ll dp[2010][2010];


ll ncr(ll n,ll r)
{
    ll i,j,p;

    for(i=0;i<=n;i++)
    {
       for(j=0;j<=min(i,r);j++)
       {
           if(i==0 || j==0)dp[i][j]=1;
           else
           {
               dp[i][j]=(dp[i-1][j-1]%md+dp[i-1][j]%md)%md;

           }
       }
    }

    return dp[n][r];
}

int main()
{


    ll n,k,i,j,p,d;

    scanf("%lld %lld",&n,&k);
    ncr(n,n);


    for(i=1;i<=k;i++)
    {
        p=(dp[n-k+1][i]%md*dp[k-1][i-1]%md)%md;

        printf("%lld\n",p);
    }



    return 0;
}


Measured memory_bytes: 30208
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int d[200];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>d[i];
    int ans=0;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            ans+=d[i]*d[j];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    vector<vector<int>> f(n, vector<int> (10));
    REP(i,n) REP(j,10) cin >> f[i][j];
    vector<vector<int>> p(n,vector<int>(11));
    REP(i,n) REP(j,11) cin >> p[i][j];
    ll ans = INF; ans *= -1;
    bool flag = true;
    for(int bit = 1; bit < (1<<10); ++bit) {
        vector<int> s(n, 0);
        REP(i,n) {
            REP(j,10) {
                if(bit & (1<<j)) s[i] += f[i][j];
            }
        }
        ll tmp = 0;
        REP(i,n) tmp += p[i][s[i]];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int x, y, z;
  std::cin >> x >> y >> z;
  if(x>=y && y>=z){
    std::cout << z << " " << y << " " << x << std::endl;
  }else if(x>=z && z>=y){
    std::cout << y << " " << z << " " << x << std::endl;
  }else if(y>=x && x>=z){
    std::cout << z << " " << x << " " << y << std::endl;
  }else if(y>=z && z>=x){
    std::cout << x << " " << z << " " << y << std::endl;
  }else if(z>=x && x>=y){
    std::cout << y << " " << x << " " << z << std::endl;
  }else if(z>=y && y>=x){
    std::cout << x << " " << y << " " << z << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3056
//#pragma GCC optimize("Ofast")   	//Comment optimisations for interactive problems (use endl)
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back

#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;
 
const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  2e+3+500;
const ll   MAXN1  =  1e+6+8;

string P[100];

 
int main()
{		
 	int x;
 	cin >> x;
 	int res = 8;

 	if(x < 600)
 		cout << res << endl;
 	else
 	{
 		x-=600;
 		res--;
 		res-=(x/200);
 		cout << res << endl;
 	}

}

Measured memory_bytes: 3632
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                boolean[] prime = new boolean[10001];
                prime[0] = prime[1] = true;
                for (int i = 2; i < 10001; i++) {
                        if (prime[i] == false) {
                                int j = 2;
                                while (i * j < 10001) {
                                        prime[i * j] = true;
                                        j++;
                                }
                        }
                }
                while (true) {
                        int N = sc.nextInt();
                        if (N == 0) {
                                return;
                        }
                        while (true) {
                                if (prime[N] == false && prime[N - 2] == false) {
                                        System.out.println(N-2 + " " + N);
                                        break;
                                }
                                N--;
                        }
                }
        }
}

Measured memory_bytes: 45624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> a(10);
    for(int i=0; i<10; ++i)
        cin >> a[i];
    sort(a.rbegin(), a.rend());
    for(int i=0; i<3; ++i)
        cout << a[i] << endl;
}

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

int main(void) {
    int s;
    cin >> s;
    int h, m;
    h = s/3600;
    m = (s - h*3600)/60;
    s = s - h*3600 - m*60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

int main(){
    int H,W;
    cin >> H >> W;
    int h,w;
    cin >> h >> w;
    cout << (H-h)*(W-w) << endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vll ans(n + 2);
    ans[0] = 2;
    ans[1] = 1;
    REP(i, 2, n + 1)
    {
        ans[i] = ans[i - 1] + ans[i - 2];
    }
    cout << ans[n] << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextLong
    val B = sc.nextLong
    val K = sc.nextLong

    if (A > K) {
      "%d %d".format(A - K, B)
    } else if (A + B > K) {
      "0 %d".format(A + B - K)
    } else "0 0"
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A + B) > (C + D)){
    cout << "Left" << endl;
  }else if((A + B) == (C + D)){
	cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const ll MAXN = 1e9;

int main()
{
	ll A,B,Q;
	cin>>A>>B>>Q;
	vector<ll>s(A),t(B);
	for(ll i = 0; i < A; i++){
		cin>>s[i];
	}
	for(ll i = 0; i < B; i++){
		cin>>t[i];
	}

	sort(all(s));
	sort(all(t));

	for(ll i = 0; i < Q; i++){
		ll q;
		cin >> q;
		ll ss[2]={0};
		auto its = lower_bound(all(s),q);
		ss[0] = *its;
		if(its != s.begin()) its--;
		ss[1] = *its;

		ll tt[2];
		auto itt = lower_bound(all(t),q);
		tt[0] = *itt;
		if(itt != t.begin()) itt--;
		tt[1] = *itt;

		ll ans = INF;
		for(ll i = 0; i < 2; i++){
			for(ll j = 0; j < 2; j++){
				ll res = min(abs(ss[i]-q)+abs(ss[i]-tt[j]),abs(tt[j]-q)+abs(ss[i]-tt[j]));
				ans = min(ans,(ll)res);
			}
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
    int c[3][3];
    int N = 3;

    for ( int i = 0; i < N; i++ ){
        for ( int j = 0; j < N; j++){
            cin >> c[i][j];
        }
    }
    int a[3], b[3];
    for (int i = 0; i < N; i++ ){
        b[i] = c[0][i] - a[0];
    }
    for (int i = 1; i < N; i++ ){
        a[i] = c[i][1] - b[1];
    }
    int tmp;
    int ans = 0;
    for (int i = 0; i < N ; i++ ){
        for (int j = 0; j < N; j++ ){
            tmp = a[i]+b[j];
            if ( c[i][j] == tmp ) ans++;
        }
    }
    if ( ans == 9 ) cout << "Yes" << endl;
    else cout << "No" << endl;;
    /*
    int a[3], b[3];
    for (int i = 0; i <= 100; i++ ){
        a[0] = i;
        b[0] = c[0][0] - a[0];
    }
    for (int i = 0; i <= 100; i++ ){
        a[1] = i;
        b[1] = c[1][1] - a[1];
    }
    for (int i = 0; i <= 100; i++ ){
        a[2] = i;
        b[2] = c[2][2] - a[2];
    }

    int tmp;
    for ( int i = 0; i < N; i++ ){
        for ( int j = 0; j < N; j++){
            tmp = a[i] + b[j];
            //if( c[i][j] == tmp ) cout << i + j << "OK" << endl;;
            cout << 
        }
    }
    
    
    for ( int i = 0; i < N; i++ ){
        for ( int j = 0; j < N; j++){
            cout << c[i][j] << endl;
        }
    }
    */
   
   
   
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);		
  		int h = in.nextInt();		
  		int gomi = in.nextInt();		
		String[] hw = new String[h];
		in.nextLine();
		for (int i = 0; i < h; i++) {
			hw[i] = in.nextLine();
		}

		for (int i = 0; i < h; i++) {
			System.out.println(hw[i]);
			System.out.println(hw[i]);
		}
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int K = 50;
ll dp[K][2][2];
int main() {
  int n;
  cin >> n;
  ll a,b,s,x=0;
  cin >> a >> b;
  s = a+b;
  rep(i,n-2){
    ll a;
    cin >> a;
    x ^= a;
  }
  ll ans = a;

  rep(i,K)rep(j,2)rep(k,2) dp[i][j][k] = -1;
  dp[0][0][0] = 0;
  rep(i,K-1){
    int dx=x&1,ds=s&1,da=a&1;
    rep(j,2)rep(k,2){
      if(dp[i][j][k]==-1) continue;
      rep(a,2)rep(b,2){
        if((a^b)!=dx) continue;
        int s=a+b+j;
        if((s&1)!=ds) continue;
        int ni = i+1;
        int nj = s>=2?1:0;
        int nk = da<a ? 1 : da>a ? 0 : k;
        dp[ni][nj][nk] = max(dp[ni][nj][nk],dp[i][j][k]|(ll(a)<<i));
      }
    }
    x>>=1,s>>=1,a>>=1;
  }
  ll t = dp[K-1][0][0]; 
  if(t==-1||t==0){
    cout << -1 << endl;
  }else{
    ans -= t;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

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

Measured memory_bytes: 256
class Processor
  attr_reader :score

  def initialize()
    @score = 0
    @leastLength = 3
  end

  def process(array)
    ansArray = []
    for i in 0 .. array.length - 1
      ansArray[i] = array[i]
    end

    for i in 0 .. ansArray.length - @leastLength
      if ansArray[i] == nil
        next
      end
      counter = 1
      while (i + counter < ansArray.length) && (ansArray[i] == ansArray[i + counter])
        counter += 1
      end
      if counter >= @leastLength
        for j in 0 .. counter - 1
          @score += ansArray[i + j]
          ansArray[i + j] = nil
        end
      end
    end
    return ansArray
  end
end

class Field
  attr_reader :fieldArray, :continuable, :processor

  def initialize(array)
    @fieldArray = array
    @height = @fieldArray[0].length
    @width = @fieldArray.length
    @processor = Processor.new()
    @continuable = true
  end

  def update()
    for i in 0 .. @height - 1
      rawArray = []
      processedArray = []
      for j in 0 .. @width - 1
        rawArray << @fieldArray[j][i]
      end

      processedArray = @processor.process(rawArray)

      if rawArray != processedArray
        for j in 0 .. @width - 1
          @fieldArray[j][i] = processedArray[j]
        end
      end
    end

    continuable = nil

    for i in 0 .. @width - 1
      continuable |= @fieldArray[i].compact!
    end

    @continuable = continuable
  end

end

while height = gets.to_i
  if height == 0
    break
  end

  inputArray = []

  for i in 0 .. height - 1
    inputArray << gets.chomp.split(" ").map{ |x| x.to_i}
  end

  inputField = Array.new(inputArray[0].length){Array.new(inputArray.length)}

  for i in 0 .. inputArray.length - 1
    for j in 0 .. inputArray[0].length - 1
      inputField[j][inputArray.length - 1 - i] = inputArray[i][j]
    end
  end

  field = Field.new(inputField)
  while field.continuable
    field.update()
  end

  p field.processor.score
end

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n; cin >> n; 
    vector<int> h(n+1, 0), ans(n+1, 0);
    for(int i = 1; i <= n ; i++) 
        cin >> h[i];
  	ans[2] = abs(h[2] - h[1]);
    for(int i = 3; i <= n; i++) {
        ans[i] = min(ans[i-1] + abs(h[i] - h[i-1]), ans[i-2] + abs(h[i] - h[i-2]));
    }
    cout << ans[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	int64_t kRem = 131072;

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int64_t n, k; cin >> n >> k;

	int64_t ans_a = 0;
	int64_t th = min(n, k);
	for (int i = 1; i <= th; i++) {
		int64_t c = (k + i - 1) / i;
		int64_t r = 1;
		while (r < c) {
			r *= 2;
		}


		ans_a += (kRem / r);
		//cout << i << " " << r << " " << ans_a << endl;
	}

	if (th < n) {
		ans_a += kRem * (n - th);
	}

	double ans = ((double)ans_a) / ((double)(kRem * n));


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

	return 0;
}

Measured memory_bytes: 256
h, w, K = map(int, input().split())
#h, w, K = 1, 3, 2
mod = 1000000007

# count when rope number is i+1
count_pattern = [0 for i in range(9)]
count_pattern_boundary = [0 for i in range(9)]
for i in range(9):
    for j in range(2**i):
        bin_str = '{:b}'.format(j)
        flag = True
        for k in range(len(bin_str)-1):
            if bin_str[k]=='1' and bin_str[k+1]=='1':
                flag = False
                break
        if flag:
            count_pattern[i] += 1
            if bin_str[-1]!='1':
                count_pattern_boundary[i] += 1



# row i, col j
count = [[0 for i in range(w)] for j in range(h+1)]
count[0][0] = 1
if w!=1:
    for i in range(h):
        j = 0
        count[i+1][j] = count[i][j]*count_pattern[w-j-2] + count[i][j+1]*count_pattern_boundary[w-j-2]
        for j in range(1, w-1):
            count[i+1][j] = count[i][j-1]*count_pattern_boundary[j-1]*count_pattern[w-j-2]\
                    + count[i][j+1]*count_pattern[j-1]*count_pattern_boundary[w-j-2]\
                    + count[i][j]*count_pattern[j-1]*count_pattern[w-j-2]
        j = w-1
        count[i+1][j] = count[i][j]*count_pattern[j-1] + count[i][j-1]*count_pattern_boundary[j-1]
else:
    for i in range(h):
        count[i+1][0] = count[i][0]
print(count[h][K-1]%mod)


Measured memory_bytes: 3064
package main

import "fmt"

var A, B, C, X, Y int

func main() {
	fmt.Scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y)

	ans := 0
	if A/2+B/2 >= C {
		m := Min(X, Y)
		ans += m * 2 * C
		X -= m
		Y -= m
	}

	ans += Min(A*X, C*2*X)
	ans += Min(B*Y, C*2*Y)

	fmt.Println(ans)
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)
 
int H, W, size;
char map[101][101];
void dfs(int i, int j) {
    char c = map[i][j];
    map[i][j] = '.';
    if(j+1<W && map[i][j+1]==c) dfs(i, j+1);
    if(j>0 && map[i][j-1]==c) dfs(i, j-1);
    if(i+1<H && map[i+1][j]==c) dfs(i+1, j);
    if(i>0 && map[i-1][j]==c) dfs(i-1, j);
}
int main() {
    while(cin >> H >> W && H!=0 && W!=0) {
        rep(i, H) {
            rep(j, W) {
                cin >> map[i][j];
            }
        }
        bool isFinished = false;
        size = 0;
        while(isFinished==false) {
            isFinished = true;
            rep(i, H) {
                rep(j, W) {
                    if(map[i][j]!='.') {
                        ++size;
                        dfs(i, j);
                        isFinished = false;
                    }
                }
            }
        }
        cout << size << endl;
        }
    return 0;
}

Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define N 100005
using namespace std;
const int mod=1e9+7;
int n;
struct msg{
	int pos,val;
	bool operator <(const msg &b)const{
		return pos<b.pos;
	}
}a[N*2];
int ans;
int main(){
	scanf("%d",&n);ans=1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i].pos),a[i].val=1;
	for(int i=n+1;i<=n+n;i++) scanf("%d",&a[i].pos),a[i].val=-1;
	sort(a+1,a+n*2+1);
	int tot=0;
	for(int i=1;i<=n*2;i++){
		if(tot*a[i].val>=0) tot+=a[i].val;
		else ans=ans*1LL*abs(tot)%mod,tot+=a[i].val;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
geta = lambda fn: map(fn, readline().split())
gete = lambda fn: fn(readline())

# sys.setrecursionlimit(10**5)

def main():
    N = gete(int) 
    A = list(geta(int))
    B = list(geta(int))

    ans = 0
    for i, b in enumerate(B):
        if A[i] + A[i+1] < b:
            ans += A[i] + A[i+1]
            A[i+1] = 0
        else:
            ans += b 
            if b > A[i]:
                A[i+1] -= b - A[i]
    
    print(ans)
	
if __name__ == "__main__":
    main()

Measured memory_bytes: 62856
def solve(n, m, AB):
    AB.sort()
    count, total = 0, 0
    for a, b in AB:
        if count + b >= m:
            total += a * (m - count)
            break
        else:
            count += b
            total += a * b
    return total

_n, _m = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _m, _AB))

Measured memory_bytes: 27880
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1 
l = inp.shift().split(' ').map(x => +x)
j = 0
for (i=0; i<M; i++) {
  j += l[i]
}
console.log(Math.max(-1, N - j))

Measured memory_bytes: 30756
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		

		int n=sc.nextInt();		//数字列
		int a[]=new int[n];
		ArrayList<Integer> list = new ArrayList<>();
		
		for(int i=0; i<n; i++) {
			a[i]= sc.nextInt();
			list.add(a[i]);
		}
		//昇順に並び替える
		Collections.sort(list);
		
		for(int i=0; i<n; i++) {
			if(a[i]==list.get(n-1)) {
				System.out.println(list.get(n-2));
			}else {
				System.out.println(list.get(n-1));
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 61316
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int a, b, c, x, y;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  mins(a, c);
  mins(b, c);
  if(x > y){
    swap(a, b);
    swap(x, y);
  }
  ll ans = 0;
  if(a + b > c){
    y -= x;
    ans += x * c;
  }else{
    ans += x * a;
  }
  ans += y * b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

A = list(map(lambda x:int(x)-1, input().split()))
B = list(map(lambda x:int(x), input().split()))
C = list(map(lambda x:int(x), input().split()))

sum = 0
for i in range(N):
  sum += B[A[i]]
  if i > 0 and A[i] == A[i-1]+1:
    sum += C[A[i-1]]
    
print(sum)

Measured memory_bytes: 3064
cnt = 0

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    G = [1]
    while G[-1]*3+1 < n:
        G.append(G[-1]*3 + 1)

    for i in range(len(G)-1, -1, -1):
        insertionSort(A, n, G[i])

    G.reverse()

    print len(G)
    print " ".join(map(str, G))
    print cnt


N = int(raw_input())
L = [int(raw_input()) for i in range(N)]

shellSort(L, N)


for i in L:
    print i

Measured memory_bytes: 69944
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  ll cur = 0;
  rep(i, s.length()) {
    cur += s[i] - '0';
  }
  if (cur % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3756
c = [[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))
    
flag = 0
a = [0]*6
b = [0]*6
    
for i in range(3):
    for j in range(2):
        a[i*2+j] = c[i][j+1] - c[i][j]
        b[i*2+j] = c[j+1][i] - c[j][i]
        
if a[0] == a[2] == a[4]:
    flag += 1
if a[1] == a[3] == a[5]:
    flag += 1    
if b[0] == b[2] == b[4]:
    flag += 1
if b[1] == b[3] == b[5]:
    flag += 1
    
if flag == 4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
alp1 = list('abcdefghijklmnopqrstuvwxyz'[::-1])
num = [i for i in range(1,26)]
alp = {}
for a,n in zip(alp1,num):
    alp[a] = n
s = input()
K = int(input())
ans =''
now = 0
while True:
    if s[now] == 'a':
        ans += 'a'
    elif K >= alp[s[now]]:
        K -= alp[s[now]]
        ans += 'a'
    else:
        ans += s[now]
    now += 1
    if now == len(s):
        break
if K:
    alp1 = alp1[::-1]
    last = ans[-1]
    ans = ans[:-1]
    ind = alp1.index(last)
    ind = (ind+K)%26
    ans += alp1[ind]
    print(ans)
else:
    print(ans)

Measured memory_bytes: 3572
n, u, v = map(int, input().split())
u, v = u-1, v-1

g = [[] for i in range(n)]

for i in range(n-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  g[b].append(a)
  
  
dt = [-1]*n
da = [-1]*n

from collections import deque
def dfs(g, s, d_list):
  stack = deque()
  stack.append(s)
  d_list[s] = 0
  while stack:
    x = stack.pop()
    for new_x in g[x]:
      if d_list[new_x] == -1:
        stack.append(new_x)
        d_list[new_x] = d_list[x]+1
  return d_list

dt = dfs(g, u, dt)
da = dfs(g, v, da)

d = 0
for i in range(n):
  if dt[i] < da[i]:
    d = max(d, da[i])
    
print(d-1)

Measured memory_bytes: 29360
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> A(n);
    vector<ll> B(n);
    for(auto &x:A)
    {
        cin>>x;
    }
    for(auto &x:B)
    {
        cin>>x;
    }
    vector<pll> v2(n);
    for(ll i=0;i<n;i++)
    {
        v2[i] = {B[i],A[i]};
    }
    sort(v2.begin(),v2.end());
    for(ll i=0;i<n;i++)
    {
        A[i] = v2[i].se;
    }
    vector<ll> temp(A);
    sort(temp.begin(),temp.end());
    sort(B.begin(),B.end());
    for(ll i=0;i<n;i++)
    {
        if(temp[i]>B[i])
        {
            cout<<"No";
            return 0;
        }
    }
    map<ll,priority_queue<ll,vector<ll>,greater<ll> > > m;
    for(ll i=0;i<n;i++)
    {
        m[A[i]].push(i);
    }
    ll sw=0;
    for(ll i=0;i<n;i++)
    {
        pair<ll,priority_queue<ll,vector<ll>,greater<ll> > > p = (*m.begin());
        if(p.fi == A[i])
        {
            m[A[i]].pop();
            if(m[A[i]].empty())
            {
                m.erase(m.find(A[i]));
            }
        }
        else
        {
            ll val = p.fi;
            ll in = p.se.top();
            m[A[i]].pop();
            m[A[i]].push(in);
            m[p.fi].pop();
            swap(A[in],A[i]);
            if(m[p.fi].empty())
            {
                m.erase(m.find(p.fi));
            }
            sw++;
        }

    }
    for(ll i=1;i<n;i++)
    {
        if(A[i]<=B[i-1])
        {
            sw--;
        }
    }
    if(sw<n-1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

    return 0;
}































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

int print_range_array(deque<pair<int,int>> &r);

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

	vector<int> x(n);
	vector<int> l(n);
	for (int i=0;i<n;++i)
	{
		cin >> x.at(i) >> l.at(i);
	}

	deque<pair<int,int>> r;
	for (int i=0;i<n;++i)
	{
		r.push_back(make_pair(x[i]+l[i],x[i]-l[i]));
		//r.at(i).first=x[i]-l[i]+1;
		//r.at(i).second=x[i]+l[i]-1;
	}

	sort(r.begin(),r.end());
	//print_range_array(r);
	//fprintf(stderr,"deque size: %d\n",r.size());

	int count=0;
	int last=-1000000000; 
	for (;;)
	{
		while ((r.size()>0)&&(r.front().second<last))
		{
			r.pop_front();
		}

		if (r.size()<=0)
		{
			break;
		}

		++count;
		pair<int,int> p=r.front();
		r.pop_front();
		last=p.first;

		while ((r.size()>0)&&(r.front().first<last))
		{
			r.pop_front();
		}
	}

	cout << count << endl;

}

int print_range_array(deque<pair<int,int>> &r)
{
	for (int i=0;i<r.size();++i)
	{
		fprintf(stderr,"%d %d\n",r.at(i).first,r.at(i).second);
	}
	return 0;
}

	



Measured memory_bytes: 1920
#include <stdio.h>
int main(){
  int n,ab[81]={},i,j;
  for(i=0;i<9;i++){
    for(j=0;j<9;j++){
      ab[i*9+j]=(i+1)*(j+1);
    }
  }
  scanf("%d",&n);
  for(i=0;i<81;i++){
    if(n==ab[i]){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
a.sort()
d=[0]*n
d[0]=1
s=[0]*n
s[0]=a[0]

for i in range(1,n):
  s[i]=s[i-1]+a[i]
for i in range(1,n):
    if a[i]>2*s[i-1]:
        d[i]=1
    else:
        d[i]=d[i-1]+1
print(d[n-1])

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main (){
    ll a, b ,c ;
    cin >> a >> b >> c ;
    ll x, y ;
    cin >> x >> y ;
    if(2*c >= a+b){
        cout << a*x + b*y << endl ;
    }
    else {
        ll num = INF ; 
        if(x > y){
            rep(i, x + 1){
                if(y - i < 0){
                    b = 0 ;
                }
                if(num > a*(x - i) + b*(y - i) + 2*c*i){
                    num = a*(x - i) + b*(y - i) + 2*c*i ;
                }
            }
        }
        else {
            rep(i, y + 1){
                if(x - i < 0){
                    a = 0 ;
                }
                if(num > a*(x - i) + b*(y - i)+ 2*c*i){
                    num = a*(x - i) + b*(y - i) + 2*c*i ;
                }
            }
        }
        cout << num << endl ;
    }
}

Measured memory_bytes: 3556