akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, X);
    int t = 1;
    i64 cur = 0;
    while (cur < X) {
        cur += t;
        ++t;
    }

    print(t - 1);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

set<ll> shrines;
set<ll> temples;

void solve(ll x) {
  vector<ll> a, b;
  auto it = shrines.lower_bound(x);
  a.push_back(*it); it--; a.push_back(*it);
  it = temples.lower_bound(x);
  b.push_back(*it); it--; b.push_back(*it);
  ll ret = 1e18;
  for(ll out: a) {
    for(ll out2: b) {
      ret = min(ret, abs(out - x) + abs(out2 - out));
      ret = min(ret, abs(out2 - x) + abs(out2 - out));
    }
  }
  cout << ret << "\n";
}

void solve() {
  shrines.insert(-1e18);
  shrines.insert(1e18);
  temples.insert(-1e18);
  temples.insert(1e18);
  int a, b, q;
  cin >> a >> b >> q;
  while(a--){ll t;cin >> t;shrines.insert(t);}
  while(b--){ll t;cin >> t;temples.insert(t);}
  while(q--) {
    ll t;
    cin >> t;
    solve(t);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 10752
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m;
//int fr[maxn][205];
//map<int,int> m;
long long i,n,k,l,r,sum=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(i=k;i<=n+1;i++){
		l=(0+i-1)*i/2;
		r=(n-i+1+n)*i/2;
//		cout<<l<<" "<<r<<" "<<(r-l+1)<<endl;
		sum=(sum+(r-l+1)%mod)%mod;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3652
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);


    for(ll cs = 1; cs <= 5; cs++)
    {
		slld(input);

		if(input == 0) cout << cs << endl;
    }


}




Measured memory_bytes: 3648
#include <stdio.h>
#include <vector>
using namespace std;
#define U_Fsize 100000
int U_Fx[U_Fsize];
int U_Fs[U_Fsize];
int U_Fq[U_Fsize];
int U_Ff;
int root(int U_Fc) {
	if (U_Ff == 0) {
		for (int i = 0; i < U_Fsize; i++) {
			U_Fx[i] = -1;
			U_Fs[i] = -1;
		}
		U_Ff = 1;
	}
	int U_Ft = 0;
	while (U_Fx[U_Fc] >= 0) {
		U_Fq[U_Ft] = U_Fc;
		U_Fc = U_Fx[U_Fc];
		U_Ft++;
	}
	for (int i = U_Ft - 2; i >= 0; i--) {
		U_Fx[U_Fq[i]] = U_Fc;
	}
	return U_Fc;
}
void merge(int U_Fa, int U_Fb) {
	U_Fa = root(U_Fa);
	U_Fb = root(U_Fb);
	if (U_Fa == U_Fb)return;
	if (U_Fx[U_Fa] < U_Fx[U_Fb]) {
		U_Fs[U_Fa] += U_Fs[U_Fb];
		U_Fx[U_Fb] = U_Fa;
	}
	else if (U_Fx[U_Fa] == U_Fx[U_Fb]) {
		U_Fx[U_Fa]--;
		U_Fs[U_Fa] += U_Fs[U_Fb];
		U_Fx[U_Fb] = U_Fa;
	}
	else {
		U_Fs[U_Fb] += U_Fs[U_Fa];
		U_Fx[U_Fa] = U_Fb;
	}
}
int sa(int U_Fd) {
	U_Fd = root(U_Fd);
	return -U_Fs[U_Fd];
}
int n, m;
long long x[100000];
int l, r;
long long d, e, f;
int l2[200000];
int r2[200000];
long long d2[200000];
int se[100000];
vector<int>g[100000];
void dfs(int now, int pa) {
	se[now] = 1;
	for (int i = 0; i < g[now].size(); i++) {
		r = g[now][i] % 100000;
		d = g[now][i] / 100000;
		d -= 10000;
		if (r != pa) {
			x[r] = x[now] + d;
			dfs(r, now);
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%lld", &l, &r, &d);
		l--;
		r--;
		l2[i] = l;
		r2[i] = r;
		d2[i] = d;
		if (root(l) != root(r)) {
			merge(l, r);
			e = (d + 10000) * 100000 + r;
			g[l].push_back(e);
			e = (10000 - d) * 100000 + l;
			g[r].push_back(e);
		}
		else {

		}
	}
	for (int i = 0; i < n; i++) {
		if (se[i] == 0) {
			dfs(i, -1);
		}
	}
	for (int i = 0; i < m; i++) {
		if (x[l2[i]] + d2[i] != x[r2[i]])f++;
	}
	if (f)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 18148
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut even: HashMap<usize,usize> = HashMap::new();
    let mut odd: HashMap<usize,usize> = HashMap::new();
    even.insert(0,0);
    odd.insert(0,0);
    for i in 0..n {
        if i % 2 == 0 {
            let c = even.entry(v[i]).or_insert(0);
            *c += 1;
        } else {
            let c = odd.entry(v[i]).or_insert(0);
            *c += 1;
        }
    }
    let mut e: Vec<(usize,usize)> = even.iter().map(|x| (*x.0, *x.1)).collect();
    let mut o: Vec<(usize,usize)> = odd.iter().map(|x| (*x.0, *x.1)).collect();
    e.sort_by(|x,y| y.1.cmp(&x.1));
    o.sort_by(|x,y| y.1.cmp(&x.1));
    if e[0].0 == o[0].0 {
        let c1 = e[0].1 + o[1].1;
        let c2 = e[1].1 + o[0].1;
        println!("{}", n - std::cmp::max(c1, c2));
    } else {
        println!("{}", n - e[0].1 - o[0].1);
    }
}


Measured memory_bytes: 12540
def main():
    n,m=map(int,input().split())
    Ans=[0]*n
    Flag=[False]*n
    for _ in range(m):
        s,c=map(int,input().split())
        s-=1
        if n!=1 and s==0 and c==0:
            return -1
        if Flag[s]==False:
            Ans[s]=c
            Flag[s]=True
        else:
            if Ans[s]!=c:
                return -1
    if n!=1 and Ans[0]==0:
        Ans[0]=1
    ans=''
    for a in Ans:
        ans+=str(a)
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int result = 0;

			for (int i = 105; i <= n; i++) {
				if (i % 2 == 0) {
					continue;
				}
				int count = 0;
				for (int j = 1; j <= i; j+=2) {
					if (i % j == 0) {
						count++;
					}
				}
				if (8 <= count) {
					result++;
				}
			}

			System.out.println(result);
		}
	}
}


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

int main(){
    int n, m, i, p, x, sum = 0;
    cin >> n;
    int t[n];
    for(i=0; i<n; i++){
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    for(i=0; i<m; i++){
        cin >> p >> x;
        cout << sum + x - t[p-1] << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

int main(void){
    double a,b,c,d,e,f;
    double x,y,det;
    
    while (scanf("%lf", &a) != EOF){
        scanf("%lf %lf %lf %lf %lf", &b, &c, &d, &e, &f);
        det = a*e - b*d;
        x = (e*c - b*f) / det;
        y = (-d*c + a*f) / det;
        
        x = floor(x*1000 + 0.5) / 1000;
        y = floor(y*1000 + 0.5) / 1000;
        printf("%.3lf %.3lf\n", x, y);
    }
}

Measured memory_bytes: 1080
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_3_C
//p100.cpp

#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next; //番兵の次の要素から辿る
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while (1) {
		if( cur == nil)break;
		if (isf++ > 0)printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if (t == nil)return; //tが番兵の場合は処理しない
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	// 検索したノードを削除
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	// 番兵の直後に要素を追加
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++) {
		scanf("%s%d", com, &key); // より高速な入力関数を使用
		if (com[0] == 'i') { insert(key); np++; size++ ; }
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F')deleteFirst();
				else if (com[6] == 'L')deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	printList();

	return 0;
}



Measured memory_bytes: 33872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = n; i >= 0; --i) {
		if (s.substr(n - i) == t.substr(0, i)) {
			cout << 2 * n - i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N, M, Q = gets.split(' ').map(&:to_i)
cities = Array.new(N + 2){Array.new(N + 2, 0)}
M.times do
  l, r = gets.split(' ').map(&:to_i)
  cities[l][r] += 1
end

N.downto(1) do |i|
   i.upto(N) do |j|
    cities[i][j] += cities[i + 1][j]
  end
end
N.downto(1) do |i|
   i.upto(N) do |j|
    cities[i][j] += cities[i][j - 1]
  end
end

Q.times do
  p, q = gets.split(' ').map(&:to_i)
  puts cities[p][q]
end

Measured memory_bytes: 4732
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
    a,b,c,k = ints()
    if k<=a:
        print(k)
    elif k<=a+b:
        print(a)
    elif k<=a+b+c:
        print(2*a+b-k)


if __name__ == '__main__':
    main()

Measured memory_bytes: 67588
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

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

template <typename T>
T gcd(T m, T n)
{
  return n == 0 ? m : gcd(n, m % n);
}
template <typename T>
T lcm(T m, T n) { return n * m / gcd(n, m); }

const int MOD = 1e9 + 7;

signed main(void)
{
  int num;

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

  num = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      num += d[i] * d[j];
    }
  }

  cout << num << endl;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
  
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    
    public static void main (String[] args) {
        FastReader ob = new FastReader();
        int n = ob.nextInt();
        int x = ob.nextInt();
        long arr[] = new long[n];
        for (int i=0;i<n ;i++ ) {
            arr[i] = ob.nextLong();
        }
        long sum=0;
        for (int i=0;i<n-1 ;i++ ) {
            if(arr[i]+arr[i+1]>x){
                sum+=(arr[i]+arr[i+1])-x;
                long diff = (arr[i]+arr[i+1])-x;
                arr[i+1]=Math.max(0,arr[i+1]-diff);
            }
        }
        System.out.println(sum);
        
    }
    
}

Measured memory_bytes: 42640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll N , A, B , C;
    vector<ll> bamboo;
    cin >> N >> A >> B >> C;
    rep(i, N){
        ll inp; cin >> inp;
        bamboo.pb(inp);
    }

    ll ans = 100000000000000;
    rep(i, 1 << bamboo.size()){
        vector<ll> a, resta;
        rep(j, bamboo.size()){
            if(i & (1<< j)) a.pb(bamboo[j]);
            else resta.pb(bamboo[j]);
        }

        if(resta.size() < 2) continue;
        if(a.size() < 1) continue;

        rep(j, 1 << resta.size()){
            vector<ll> b, restb;
            rep(k, resta.size()){
                if(j & (1 << k))b.pb(resta[k]);
                else restb.pb(resta[k]);
            }

            if(restb.size() < 1) continue;
            if(b.size() < 1) continue;

            rep(k, 1 << restb.size()){
                vector<ll> c, restc;
                rep(l, restb.size()){
                    if(k & (1<<l))c.pb(restb[l]);
                    else restc.pb(resta[l]);
                }

                if(c.size() <1) continue;


                ll res = 0 ;
                ll suma = 0;
                ll sumb = 0;
                ll sumc = 0;
                rep(i, a.size()){suma += a[i];}
                rep(i, b.size()){sumb += b[i];}
                rep(i, c.size()){sumc += c[i];}

                res = a.size() - 1 + b.size() -1 + c.size() -1;

                res *= 10;
                res += abs(A-suma) + abs(B-sumb) + abs(C-sumc);

                ans = min(ans, res);
            }
        }

    }

    cout << ans << endl;
	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math

h1,h2 =map(int,input().split())
k1,k2 =map(int,input().split())
a,b,c,d =map(int,input().split())

hp = a * h1 + b * h2 + c * math.floor(h1/10) + d * math.floor(h2/20)
kp = a * k1 + b * k2 + c * math.floor(k1/10) + d * math.floor(k2/20)

if hp > kp:
    print("hiroshi")
elif hp == kp:
    print("even")
else:
    print("kenjiro")



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

int main(){
  int n,ans=0;
  cin>>n;
  
  vector<int> lis;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    lis.emplace_back(tmp);
  }

  sort(lis.begin(),lis.end(),greater<int>());
  rep(i,0,n){
    if(i%2==0){ans+=lis[i];}
    else{ans-=lis[i];}
  }
  
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long ans = 2;
        for(int i = 0; i < x; i++){
            ans = ans * 2 + 2;
        }
        System.out.println(ans);
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}


/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;

signed main(){
  string s;
  cin >> s;
  int n = sz(s);

  vvi cnt(26, vi(n+1));
  rep(i, 0, 26) rep(j, 0, n){
    cnt[i][j+1] = cnt[i][j];
    if(s[j]-'a' == i) cnt[i][j+1]++;
  }

  rep(i, 0, 26){
    // [l, r)
    int r = 2;
    rep(l, 0, n){
      while(r < n+1 and cnt[i][r]-cnt[i][l] >= (r-l+1)/2){
        if(cnt[i][r]-cnt[i][l] >= (r-l+2)/2){
          cout << l+1 << " " << r << endl;
//          cout << (char)(i+'a') << endl;
//          cout << cnt[i][r] << " " << cnt[i][l] << endl;
          return 0;
        }
        r++;
      }

      if(r-l < 3) r = l+3;
    }
  }

  cout << "-1 -1" << endl;

  return 0;
}



Measured memory_bytes: 21632
from collections import Counter
N, K, L = map(int, input().split())
u1, u2 = list(range(N+1)), list(range(N+1))

def root(u, r):
    if u[r] == r:
        return r
    u[r] = root(u, u[r])
    return u[r]

def update(u, r, n):
    rr = root(u, r)
    nr = root(u, n)
    if rr > nr:
        rr, nr = nr, rr
    u[nr] = rr

for i in range(K):
    p, q = map(int, input().split())
    update(u1, p, q)

for i in range(L):
    r, s = map(int, input().split())
    update(u2, r, s)

rs = [(root(u1, i), root(u2, i)) for i in range(1, N+1)]
c = Counter(rs)
 
print(' '.join(map(str, [c[r] for r in rs])))


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef unsigned int uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

typedef long long Int;
//int n,m;

template<class T>
struct FenwichTree{
	struct range{
		int l,r;
	};
	vector<T> data;

	FenwichTree (int n){
		data.assign(n+5,0);
	}
	//point-query
	T get(int t){
		T ret(0);
		for(int x=t+1;x<data.size();x+=x&-x)ret+=data[x];
		return ret;
	}
	T range_add(int a,int d){
		for(int x=a+1;x>0;x-=x&-x){
			data[x]+=d;
		}
	}
	//range-query
	void range_add(const range &p, int d){
		if(p.l>=p.r)return;
		range_add(p.r-1,d);
		range_add(p.l-1,-d);
	}
};

void solve(int n, int m, vector<int> a){
	FenwichTree<Int> fval(m*2), fct(m*2);
	Int sum = 0;
	REP(i,n)a[i]--;
	REP(i,n-1){
		int s = a[i],t = a[i+1];
		if(a[i]>a[i+1]){
			t += m;
		}
		sum+=t-s;
		fval.range_add({s+1,t+1},s+1);
		fct.range_add({s+1,t+1},1);
	}
	Int mini = 1e+18;
	for(int x=0;x<m;x++){
		auto p00 = fval.get(x), p01 = fct.get(x);
		auto p10 = fval.get(x+m), p11 = fct.get(x+m);
		Int result = p00-p01*x+p10-p11*(x+m);
		mini = min(result,mini);
	}
	cout<<sum+mini<<endl;
}

int main(){	
	int m;
	int n;
	scanf("%d",&n);
	vector<int> a(n-1+1);
	scanf("%d",&m);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%d",&a[i]);
	}
	solve(n, m, a);
	return 0;
}



Measured memory_bytes: 4096
a = list(list(map(int,input().split())) for _ in range(3))
n = int(input())
b = list(int(input()) for _ in range(n))

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] or a[0][i] == a[1][i] == a[2][i] or a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
        print("Yes")
        break
else:
     print("No")

Measured memory_bytes: 61484
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((b * 10 + c) % 4 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#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()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int n,k,X[200001],Y[200001],C[200001];
int A[1001][1001][2],B[1001][1001][2]={0};
int main(){
    char c;
    cin>>n>>k;
    rep(i,n){
        cin>>X[i]>>Y[i]>>c;
        C[i]=(c=='B');
    }
    rep(i,n) C[i]=(X[i]/k+Y[i]/k+C[i])%2,X[i]%=k,Y[i]%=k;
    rep(i,n) A[X[i]][Y[i]][C[i]]++;
    rep(i,k)rep(j,k)rep(k,2) B[i+1][j+1][k]=B[i][j+1][k]+B[i+1][j][k]-B[i][j][k]+A[i][j][k];
    int ans=0;
    rep(i,k)rep(j,k){
        int a=B[i][j][0]-B[0][0][0];
        a+=B[k][k][0]-B[i][k][0]-B[k][j][0]+B[i][j][0];
        a+=B[i][k][1]-B[i][j][1];
        a+=B[k][j][1]-B[i][j][1];
        ans=max({ans,a,n-a});
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 17408
#include <iostream>
#include <cstdlib>

int main() {

    int N = 0;
    std::cin >> N;

    int A[N] = {0};
    for (int i = 0; i < N; i++) { std::cin >> A[i]; }

    int result = 0, comp = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            comp = A[i] - A[j];
            comp = std::abs(comp);
            if (result < comp) {
                result = comp;
            }
        }
    }
    std::cout << result << std::endl;
    return 0;
}


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

#define pb push_back
#define loop(i,l,r) for(int i = (l); i < (r); i++)
#define rloop(i,r,l) for(int i = (r-1); i >= (l); i--)
#define refloop(x, v) for(auto& x : (v))
#define exists(m,e) if((m).find(e) != (m).end())
#define nexists(m,e) if((m).find(e) == (m).end())
#define sortaka(v) sort((v).begin(), (v).end())
#define rsort(v) sort((v).rbegin(), (v).rend())
#define lower_bound_index(v, x) (lower_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] >= x
#define upper_bound_index(v, x) (upper_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] > x
#define scanint(x) scanf("%d", &(x))
#define scanfloat(x) scanf("%f", &(x))
#define scanll(x) scanf("%lld", &(x))
#define scanchar(x) scanf("%c", &(x))
#define scanstring(x) scanf("%s", &(x))
#define printint(x) printf("%d", x)
#define printfloat(x) printf("%.9f", x)
#define printll(x) printf("%lld", x)
#define printchar(x) printf("%c", x)
#define printstring(x) printf("%s", x)
#define printintnewline(x) printf("%d\n", x)
#define printfloatnewline(x) printf("%.9f\n", x)
#define printllnewline(x) printf("%lld\n", x)
#define printcharnewline(x) printf("%c\n", x)
#define printstringnewline(x) printf("%s\n", x)
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))

typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<string> vs;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<vector<pair<long long, long long>>> vvpll;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);

    string s; cin >> s;
    int n = s.length();
    if(s[n-1] == 's'){
        cout<<s<<"es";
    }else{
        cout<<s<<"s";
    }
}

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

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

    for(int i = 0; i < S.size(); ++i) {
        if(S[i] + N > 'Z') {
            int tmp = 'Z' - S[i];
            S[i] = 'A' + N - tmp - 1;
        } else {
            S[i] = S[i] + N;    
        }
    }

    cout << S << endl;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
_map = [[1 if s=='.' else 0 for s in str(input())] for i in range(H)]
_mod = (10**9)+7
dp = [[0 for j in range(W)] for i in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if _map[i][j] == 1:
            if i < H-1 and _map[i+1][j] == 1:
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % _mod
            if j < W-1 and _map[i][j+1] == 1:
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % _mod
print(dp[H-1][W-1])

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] -= 'A' - 'a';
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll a,b,c;cin >> a >> b >> c;
    if(b>=c||c+b-a<=0)cout << "No" <<endl,exit(0);
    if(2*(a*b+b*c+c*a)<a*a+b*b+c*c)cout << "Yes" <<endl;
    else cout <<"No" <<endl;
}

Measured memory_bytes: 256
/*
//Official solution
"
Let’s try to label the N vertices with labels A, B, C such that:
For each of the M edges, the labels of the endpoints of the edge is (A → B) or (B → C)
or (C → A).

When the labelling is possible, and not all of A, B, C are used
You can’t perform any operations and the set of edges remain unchanged.

When the labelling is possible, and all of A, B, C are used
You can add an edge between all pairs with labelling (A → B), (B → C), and (C → A).
You can’t add any other edges.

When the labelling is impossible
You can add an edge between any pair of vertices, including self loops.
"
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+7;
int n,m;
int rot[4];//rotate
int pre[4]={0,3,1,2};
int nxt[4]={0,2,3,1};
int cntx,cnty;
int ok;
int col[maxn];
LL ans;
vector<int> vec[maxn],v[maxn];
void dfs(int pos,int to){
	if(col[pos]){
		if(col[pos]!=to) ok=1;
		return;
	}
	++rot[col[pos]=to];
	++cntx;
	cnty+=vec[pos].size();
	for (int i=0;i<vec[pos].size();++i) dfs(vec[pos][i],nxt[to]);
	for (int i=0;i<v[pos].size();++i) dfs(v[pos][i],pre[to]);
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1,a,b;i<=m;++i){
		scanf("%d%d",&a,&b);
		vec[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i=1;i<=n;++i){
		if(!col[i]){
			rot[1]=rot[2]=rot[3]=0;
			cntx=cnty=ok=0;
			dfs(i,1);
			if (ok) ans+=1ll*cntx*cntx;
			else if (rot[1]&&rot[2]&&rot[3]) ans+=1LL*rot[1]*rot[2]+1LL*rot[2]*rot[3]+1LL*rot[3]*rot[1];
			else ans+=cnty;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int a=sc.nextInt();
			String op=sc.next();
			int b=sc.nextInt();
			if(op.equals("?"))break;
			int ans=0;
			switch(op) {
			case "+":
			ans=a+b;
			break;
			case "-":
				ans=a-b;
				break;
			case "*":
				ans=a*b;
				break;
			case "/":
				ans=a/b;
				break;
			}
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 26148
#include<bits/stdc++.h>
using namespace std;
#define maxn 500010
deque<int> dq;
int n,k;
char s[maxn],t[maxn];
int sum[maxn];
int dp[maxn];
int f(int i){return 2*dp[i]-sum[i+1];}
main()
{
    scanf("%d%d",&n,&k);
    scanf("%s%s",s+1,t+1);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(t[i]!=t[i-1]);
    dq.push_back(0);
    for(int i=1;i<=n;i++)
    {
        while(!dq.empty() && dq.front()+k<i)dq.pop_front();
        int id=dq.front();
        if(s[i]==t[i])dp[i]=dp[i-1];
        else dp[i]=(sum[i]+f(id)+3)/2;
        while(!dq.empty() && f(dq.back())>=f(i))dq.pop_back();
        dq.push_back(i);
    }
    printf("%d\n",dp[n]);
    return 0;
}



Measured memory_bytes: 8172
// AOJ 0328: Metal Recycling
// 2017.10.14

#include <stdio.h>

char buf[32], *p;
int f[200020];

int getInt()
{
	int n = 0;
	if (*p == ' ') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, max;
	int *q;

	fgets(p=buf, 16, stdin); n = getInt();
	max = 0; while (n--) {
		fgets(p=buf, 32, stdin);
		i = getInt() + getInt();
		if (i > max) max = i;
		f[i]++;
	}
	for (q = f, i = 0; i <= max; i++, q++) {
		if (*q > 0) {
			*(q+1) += *q >> 1;
			if (*q & 1) printf("%d 0\n", i);
			if (i == max) max++;
		}
	}
	return 0;
}

Measured memory_bytes: 2404
#include<iostream>
using namespace std;
int i,n,m,a,k[9999][999];
main(){for(i=1;i<=999;i++){k[0][i]=i;}cin>>n>>m;
for(int i=1;i<=m;i++){cin>>a;
if(a>=1){for(int j=a+1;j<=n*2;j++){k[i][j-a]=k[i-1][j];}
for(int j=1;j<=a;j++){k[i][j+(2*n-a)]=k[i-1][j];}}
else{for(int j=1;j<=n;j++){k[i][j*2-1]=k[i-1][j];}
for(int j=1;j<=n;j++){k[i][j*2]=k[i-1][j+n];}}}
for(int i=1;i<=2*n;i++){cout<<k[m][i]<<endl;}}

Measured memory_bytes: 5252
use std::cmp::min;
#[warn(unused_mut)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[warn(unused_mut)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[warn(unused_mut)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        x: [i32; n],
    }

    let mut ans = 1_000_000_000;
    for i in 1..101 {
        let mut tmp = 0;
        for p in x.iter() {
            tmp += (i-p)*(i-p);
        }
        ans = min(ans, tmp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    string in; cin >> in;
    int n = in.size();
    vi a(n);
    rep(i, n){
        a[i] = (26 - (in[i] - 'a')) % 26;
    }
    int K; cin >> K;

    string res;
    rep(i, n){
        char cur = in[i];
        if(a[i] <= K){
            cur = 'a';
            K -= a[i];
        }

        res.push_back(cur);
    }

    res[n - 1] = 'a' + (res[n - 1] - 'a' + K) % 26;
    cout << res << endl;

    return 0;
}


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

int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    ll sum_A = 0;
    for(int i=0; i<N; i++){
        sum_A += A[i];
    }

    if(sum_A >= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int N;
int X[128];
int M;
int A[128];

char sugoroku[2048];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &X[i]) != 1) return 1;
		sugoroku[X[i]] = 1;
	}
	sugoroku[2020] = 1;
	if (scanf("%d", &M) != 1) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		if (!sugoroku[X[A[i]] + 1]) {
			sugoroku[X[A[i]]] = 0;
			sugoroku[X[A[i]] + 1] = 1;
			X[A[i]]++;
		}
	}
	for (i = 1; i <= N; i++) {
		printf("%d\n", X[i]);
	}
	return 0;
}



Measured memory_bytes: 2144
/*
 * Matheus Oliveira
 * 09:10:12 02/06/2019
 * a.cpp
*/

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

#define EPS
#define INF
#define MAXN 200100
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');

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

char inp[MAXN];

int main() {
	bool possible = true, flag = false;
	
	int n, a, b, c, d, aux;
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	a--, b--, c--, d--;

	getchar();
	scanf("%s", inp);

	aux = 0;
	for(int i = b; i <= d; i++) {
		if(inp[i] == '#') aux++;
		else aux = 0;

		if(aux == 2) possible = false;
		
		if(i-1 >= 0 and i+1 < n) {
			if(inp[i-1] == '.' and inp[i] != '#' and inp[i+1] == '.') flag = true;
		}
	}

	aux = 0;
	for(int i = a; i <= c; i++) {
		if(inp[i] == '#') aux++;
		else aux = 0;

		if(aux == 2) {
			possible = false;
			break;
		}
	}

	if(c > d and !flag) possible = false;

	if(possible) printf("Yes\n");
	else printf("No\n");

	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> s.at(i);
  }
  vector<int> alpha(26, 0);
  vector<int> alpha2(26, 0);
  for(i = 0; i < n; i++)
  {
    if(i == 0)
    {
      for(j = 0; j < s.at(i).length(); j++)
      {
        alpha.at(s.at(i).at(j)-'a')++;
      }
    }
    else
    {
      for(j = 0; j < s.at(i).length(); j++)
      {
        alpha2.at(s.at(i).at(j)-'a')++;
      }
      for(j = 0; j < 26; j++)
      {
        alpha.at(j) = min(alpha.at(j), alpha2.at(j));
        alpha2.at(j) = 0;
      }
    }
  }
  for(i = 0; i < 26; i++)
  {
    while(alpha.at(i) != 0)
    {
      cout << (char)('a' + i);
      alpha.at(i)--;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100001

int main(){
  int n,i;
  int A[MAX];

  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
  }

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2 >= 1)printf("parent key = %d, ",A[i/2]);
    if(2*i <= n)printf("left key = %d, ",A[i*2]);    
    if(2*i+1 <= n)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int n;
Graph G;

//答え
vector<int> ans;

void dfs(int v, int p, int c) {
  ans[v] = c;
  for (auto e : G[v]) {
    if (e.first == p) continue;
    if (e.second & 1)
      dfs(e.first, v, 1 - c);
    else
      dfs(e.first, v, c);
  }
}

int main() {
  cin >> n;
  G.assign(n, vector<Edge>());
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }
  ans.assign(n, 0);
  dfs(0, -1, 1);
  for (auto v : ans) cout << v << endl;
}


Measured memory_bytes: 8960
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
const int MOD = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
ostream& operator<< (ostream& os, const mint& value) {
  os << value.x;
  return os;
}

#pragma endregion library

const int MX = 3005;
mint dp[MX][MX];
int main(){
    int n,s; cin >> n >> s;
    vi a(n); rep(i,n) cin >> a[i];
    dp[0][0]=((mint)2).pow(n);
    rep(i,n)rep(j,s+1){
        dp[i+1][j]=dp[i][j];
        if(j-a[i]>=0) dp[i+1][j]+=dp[i][j-a[i]]/2;
    }
    cout << dp[n][s] << '\n';
    
}

Measured memory_bytes: 74168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
const int N=2e5+10,inf=1e9;
int dp[N][2];
char s[N];

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

    if(k==1){
        ans = 0;
    }else{
        ans = n-k;
    }

	cout << ans << endl;
}


Measured memory_bytes: 256
using System;


namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                double n = double.Parse(Console.ReadLine());
                if (n == 0)
                    break;
                string[] input = Console.ReadLine().Split(' ');
                double sum = 0;
                for (int x = 0; x < n; x++)
                {
                    int s = int.Parse(input[x]);
                    sum = sum + s;
                }
                sum = sum / n;
                double sum2 = 0;
                for(int y = 0; y < n; y++)
                {
                    double s = double.Parse(input[y]);
                    double ss = s - sum;
                    double sss = Math.Pow(ss, 2);
                    sum2 = sum2 + sss;
                }
                sum2 = sum2 / n;
                double ans = Math.Sqrt(sum2);
                Console.WriteLine("{0:f8}" , ans);
            }
        }
    }
}

Measured memory_bytes: 9624
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc057/tasks/abc057_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B):
    return (A + B) % 24


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064