akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vl v(n);
  rep(i, n) {
    cin >> v[i];
  }

  ll ans = 0;

  sort(all(v));

  ans += v[0];
  rep(i, n-1) {
    ans += (1LL << i)  * v[i+1];
  }

  double ret = ans;
  ret /= (1LL << (n-1));
  cout << ret << endl;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split(" ").map(&:to_i)
cnt = 0
odd = false

while true
  a.each_with_index do |num, i|
    if num.even?
      a[i] = num / 2
    else
      odd = true
      break
    end
  end
  break if odd
  cnt += 1
end

puts cnt

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>

long gcd(long x, long y)
{
	return y ? gcd(y, x % y) : x;
}

long lcm(long x, long y)
{
	return x * y / gcd(x, y);
}

int main(void)
{
	char S[100001], T[100001];
	long N, M, Slength, Tlength, min, tmp, i;
	scanf("%ld%ld%s%s", &N, &M, S, T);
	Slength = strlen(S);
	Tlength = strlen(T);
	tmp = lcm(N, M);
	//if (Slength / (tmp / N) < Tlength / (tmp / M)) min = Slength / (tmp / N);
	//else min = Tlength / (tmp / M);

	long LCM = lcm(tmp / N, tmp / M);

	for (i = 0; S[i / (tmp / N)] != '\0' && T[i / (tmp / M)] != '\0'; i += LCM) {
		if (S[i / (tmp / N)] != T[i / (tmp / M)]) {
			puts("-1");
			return 0;
		}
	}
	printf("%ld", tmp);
	return 0;
}

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

int main() {
  string S,T;
  cin >>S >>T;
  int A,B;
  A=0;
  B=S.size();
  for(int i=0;i<B;i++){
  if(S.at(i)==T.at(i)){A++;}
  }
   cout << B-A<< endl;
  return 0;
}

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

vector<ll> dp(51);
vector<ll> dp2(51);

ll solve(ll n, ll x){
    if(n == 0){
        if(x >= 1)
            return 1;
        else
            return 0;
    }else if(x > dp2[n-1]+1){
        return 1 + dp[n-1] + solve(n-1, x - dp2[n-1] - 2);
    }else{
        return solve(n-1, x-1);
    }
}
int main(){
    ll n, x; cin >> n >> x;
    dp[0] = 1;
    dp2[0] = 1;
    for(int i = 1; i <= n; i++){
        dp[i] = dp[i-1]*2 + 1;
        dp2[i] = dp2[i-1]*2 + 3;
    }
    ll ans = solve(n, x);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        double[] arr = new double[num];
        double max = 0;
        double sum = 0;
        for (int i = 0;i < num;i++){
            arr[i] = in.nextDouble();
            if (max < arr[i]){
                max = arr[i];
            }
        }
        for (int i = 0;i < num;i++){
            sum += max / arr[i];
        }
        System.out.println(max/sum);

        
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,c;
	cin>>a>>b>>c;
	ll sum=a+b+c;
	if(sum>=22){
		cout<<"bust"<<endl;
	}
	else{
		cout<<"win"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		
		HashMap <String, String> Hashy = new HashMap<String, String>();
		Hashy.put("A", "T");
		Hashy.put("T", "A");
		Hashy.put("G", "C");
		Hashy.put("C", "G");
		String S = sc.next();
		System.out.println(Hashy.get(S));
	}

}


Measured memory_bytes: 35640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n;
  cin >> n;
  vector<int> num(1000001);
  set<int> a;

  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    num[c]++;
    a.insert(c);
  }
  
  for (int i = 0; i < 1000001; i++) {
    if (num[i] > 1) num[i] = 0;
  }

  for (auto i: a) {
    //cout << i << endl;
    if ((i == 1) && (num[i] == 0)) {
      cout << 0 << endl;
      return 0;
    }
    if ((i == 1) && (num[i] == 1)) {
      cout << 1 << endl;
      return 0;
    }
    //if (num[i] == 0) continue;
    int index = i + i;
    while (index <= 1000000) {
      num[index] = 0;
      index += i;
    }
  }

  int cnt = 0;
  for (int i = 0; i < 1000001; i++) {
    if (num[i] == 1) { 
      //cout << i << endl;
      cnt++;
    }
  }

  cout << cnt << endl;
  
}


Measured memory_bytes: 16368
n = int(input())
a = input().split()
a = [int(s) for s in a]
b = input().split()
b = [int(s) for s in b]
c = input().split()
c = [int(s) for s in c]
hapiness = 0
for i in range(len(a)):
        hapiness += b[a[i]-1]
        if i:
                if a[i-1] + 1 == a[i]: hapiness += c[a[i-1]-1]
print(hapiness)

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


int main() {
   int n,K;
   cin>>n>>K;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }

    bool dp[K+1];
    memset(dp,0,sizeof dp);


    for(int i=1;i<=K;i++){
        for(int j=0;j<n;j++){
                
            if(a[j]>i)
                continue;
            if(dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    string s=(dp[K])?"First":"Second";
    cout<<s;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int X,Y;
  cin>>X>>Y;
  string ans="No";
  int M=X*4;
  rep(i,X+1){
    if(Y==M){
      ans="Yes";
      break;
    }
    M-=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  unsigned long long N;
  unsigned long long A;
  unsigned long long result = 1;

  scanf("%llu", &N);

  long double log_sum = 0;
  for (size_t i = 0; i < N; i++) {
    scanf("%llu", &A);
    log_sum += log10l(A);
    result *= A;
  }

  if (log_sum > 18.0 || result > 1000000000000000000) {
    printf("-1\n");
    return 0;
  }

  printf("%llu\n", result);
  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        a.push_back(num);
    }
    sort(a.begin(), a.end(), greater<int>{});
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++) {
        int num = a.front();
        a.erase(a.begin());
        if (i % 2 == 0) {
            //cout << "alice:" << num << endl;
            alice += num;
        } else {
            //cout << "bob:" << num << endl;
            bob += num;
        }
    }
    cout << alice - bob << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string S; cin >> S;
  // <<...< や >>...> を数える
  vector<pair<char, ll>> v;
  rep(i, S.size()) {
    if (v.empty() || v.back().first != S[i]) {
      v.emplace_back(S[i], 1);
    } else {
      v.back().second++;
    }
  }
  // <<...< a_i >>...> のとき a_i を不等号の数の多い方に合うように決める。
  // 不等号の小さい方は 1 個減らして 1 ~ k の和, 大きい方は減らさずに和を取る。
  ll sum = 0;
  for(int i = 0; i < v.size(); i += 2) {
    if (i == 0 && v[i].first == '>') {
      sum += v[i].second * (v[i].second + 1) / 2;
      i--;
    }
    else if (i + 1 >= v.size()) {
      sum += v[i].second * (v[i].second + 1) / 2;
    }
    else {
      assert(v[i].first == '<' && v[i + 1].first == '>');
      ll min = std::min(v[i].second, v[i + 1].second);
      ll max = std::max(v[i].second, v[i + 1].second);
      sum += (min - 1) * min / 2 + max * (max + 1) / 2;
    }
  }
  cout << sum << "\n";
}


Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli,lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ff  first
#define ss  second
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int t;cin>>t;while(t--)
#define clean(x) memset(x,0,sizeof(x))
#define FOR(x,y) for(int i=x;i<=y;i++)
const lli maxn = 2e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}

string X="IF THE CONSTRAINTS ARE LOW JUST BRUTE FORCE IT!!!!!!!!!!!!!!!!!!!!!";
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///

map<int,int>m;
void solve()
{
    int  n;cin>>n;
    int lol[n];
    bool f=false;
    for(int i=0;i<n;i++)
    {
        cin>>lol[i];
        m[lol[i]]++;
        if(m[lol[i]]>=3)f=true;
        else if(m[0]>1)f=true;
    }
    if(f)cout<<0<<endl;
    else
    {
        int res=n/2;
        cout<<power(2,res)<<endl;
    }

}
int main()
{
    solve();
}


Measured memory_bytes: 6960
#include <iostream>

int main() {
	int k[10] = {}, w[10] = {};
	int swap;
	for (int i = 0; i < 10; i++) {
		std::cin >> w[i];
	}
	for (int j = 0; j < 10; j++) {
		std::cin >> k[j];
	}

	for (int n = 1; n < 10; n++) {
		for (int m = 0; m < 10; m++) {
			if (w[n] > w[m]) {
				swap = w[m];
				w[m] = w[n];
				w[n] = swap;
			}
		}
	}
	for (int n = 1; n < 10; n++) {
		for (int m = 0; m < 10; m++) {
			if (k[n] > k[m]) {
				swap = k[m];
				k[m] = k[n];
				k[n] = swap;
			}
		}
	}

	std::cout << w[0] + w[1] + w[2] << " " << k[0] + k[1] + k[2] << std::endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    ll k;
    cin>>s>>k;
    int id = 0;
    if(k==1){
        cout<<s[0]<<endl;
        return 0;
    }
    ll cnt = 1;
    while(1){
        if(s[id]=='1'){
            if(cnt==k){
                cout<<1<<endl;
                return 0;
            }
            cnt++;
            id++;
        }else{
            cout<<s[id]<<endl;
            return 0;
        }
    }
    cout<<s[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 100000000;
typedef pair<int, int> P;

int a, b, c, d,X,Y;

int main() {
	cin >> a >> b >> c >> d;
	
	X = (a - c), Y = (d - b);

	cout << c -Y << " " << d-X << " " << a - Y<< " " << b-X << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>



int main(void){
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    long long int ans=0;
    if(K!=0){
    for(int i=K+1;i<=N;i++){
        int po=(N+1)%i;
        if(po>=K)ans+=po-K;
        int buri=(N+1)/i;
        ans+=buri*(i-K);
        //printf("%lld\n",ans);
    }
    printf("%lld",ans);
    }
    else {
        ans=N*N;
        printf("%lld",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;
int n,m;
const int inf = 1e9;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    int low = -1,high = inf;
    while(m--)
    {
        int l,r;
        cin >> l >> r;
        low = max(low,l);
        high = min(high,r);
    }
    cout << max(high-low+1,0);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int num = s.nextInt();
        int length;
        for(int i = 0 ; i<num ; i++){
            length = s.nextInt();
            int up = 0, down = 0;
            int[] a = new int[length];
            for(int j = 0 ; j < length ; j++)
                a[j] = s.nextInt();
            for(int k = 0 ; k+1 < length ; k++){
                if(a[k+1] - a[k] > up)
                    up = a[k+1] - a[k];
                if(a[k] - a[k+1] > down)
                    down = a[k] - a[k+1];
            }
            System.out.println(up + " " + down);
        }
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,last,sum;
	bool a[200001],b[200001]={0};
	cin>>N;
	for(int i=1;i<=N;i++)cin>>a[i];
	for(int i=N;i>=1;i--){
		last=N/i;
		sum=0;
		for(int j=last;j>=2;j--)sum+=b[j*i];
		b[i]= sum%2 != a[i];
	}
	sum=0;
	for(int i=1;i<=N;i++)sum+=b[i];
	cout<<sum<<endl;
	for(int i=1;i<=N;i++)if(b[i])cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var ABC = make([]int, 3)

	fmt.Scanln(&ABC[0], &ABC[1], &ABC[2])

	if ABC[0] == ABC[1] && ABC[0] != ABC[2] && ABC[1] != ABC[2] {
		fmt.Println("Yes")
	} else if ABC[0] == ABC[2] && ABC[0] != ABC[1] && ABC[2] != ABC[1] {
		fmt.Println("Yes")
	} else if ABC[1] == ABC[2] && ABC[1] != ABC[0] && ABC[2] != ABC[0] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  ll a,b,prec,x,y;
  cin5(a,b,prec,x,y);
  ll c=2*prec;
  ll ans=0;
  ll ANS=MAX;
  loop(i,114514){
    ans+=c*i;
    if(x>i)ans+=(x-i)*a;
    if(y>i)ans+=(y-i)*b;
    ANS=min(ANS,ans);
    ans=0;
  }
  putout(ANS);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 100000
#define MAX_S 30
 
double dp[MAX_N+1][MAX_S+1];
 
int main(){
    double P[MAX_N],power[MAX_S];
    dp[0][0] = 1; P[0] = 1;
    power[0] = 1;
    for(int i = 1 ; i < MAX_S ; i++){
        power[i] = power[i-1]/2;
    }
    for(int i = 0 ; i < MAX_N-1 ; i++){
        for(int j = 0 ; j < MAX_S ; j++){
            if(dp[i][j] == 0) continue;
            dp[i+1][j+1] += dp[i][j]*power[j];
            dp[i+1][0] += dp[i][j]*(1-power[j]);
        }
        double res = 0;
        for(int j = 0 ; j < MAX_S ; j++){
            res += dp[i+1][j]*power[j];
        }
        P[i+1] = res + P[i];
    }
    int n;
    while(cin >> n,n){
        printf("%.10f\n",P[n-1]);
    }
    return 0;
}

Measured memory_bytes: 28148
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct segtree {
    int n;
    vi seg;

    void init(int n_)
    {
        n = 1;
        while (n < n_) n *= 2;
        seg.resize(2 * n - 1);
        rep(i, 2 * n - 1) seg[i] = 0;
    }

    int update(int k, int a)
    {
        k += n - 1;

        seg[k] += a;

        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] += a;
        }
    }

    int query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return 0;

        if (a <= l && r <= b) return seg[k];

        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

        return vl + vr;
    }

    int query(int a, int b)
    {
        return query(a, b, 0, 0, n);
    }
};

signed main()
{
    int N, Q; cin >> N >> Q;

    segtree s;

    s.init(N + 1);

    rep(i, Q) {
        int c, x, y; cin >> c >> x >> y;

        if (c == 0) {
            s.update(x, y);
        } else {
            cout << s.query(x, y + 1) << endl;
        }
    }
}

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

int main(){
  int N;
  int a,b,c,d;
  
  cin >> N;
  
  //1の桁取得
  a = N % 10;
  
  //10の桁取得
  b = (N % 100 - a) / 10;
  
  //100の桁取得
  c = (N % 1000 - 10 * b - a) / 100;
  
  //1000の桁取得
  d = (N % 10000 - 100 * c - 10 * b - a) / 1000;
  
  //よい整数かどうかを判別
  if ( a == b && b == c){
    cout << "Yes" << endl;
  }
  else if ( b == c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double degree = scanner.nextDouble();
 
        double S = 0.5*a*b*Math.sin(Math.PI*degree/180.0);
        double c = Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.PI*degree/180.0));
 
        System.out.printf("%.10f\n",S);
        System.out.printf("%.10f\n", a+b+c);
        System.out.printf("%.10f\n", 2*S/a);
    }
}


Measured memory_bytes: 28352
#include <stdio.h>

int main(void){
  int a,b,x,y;
  scanf("%d %d",&a,&b);
  if(1<=a && b<=100){
    x=a*b;
    y=(a+b)*2;
    printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,mod;cin>>n;
    lint x,y;
    vector<lint> a(n),b(n);
    for(int i=n-1;i>=0;i--)cin>>a[i]>>b[i];
    lint added=0;
    for(int i=0;i<n;i++){
        x=a[i]+added;y=b[i];
        mod=x%y;
        if(mod==0)mod=y;
        added+=(y-mod);
    }
    cout<<added<<endl;
}


Measured memory_bytes: 4840
### constant

MOD = 10007
IDS = {"J" => 0, "O" => 1, "I" => 2}

### main

n = gets.strip.to_i
sched = gets.strip

counts = 8.times.map{0}
counts[1] = 1

for i in (0...n)
  pcounts = counts
  counts = [0]

  rbit = 1 << IDS[sched[i]]

  for cmem in (1..7)
    cnt = 0
    if (cmem & rbit) != 0
      for pmem in (1..7)
        if (cmem & pmem) != 0
          cnt = (cnt + pcounts[pmem]) % MOD
        end
      end
    end
    counts[cmem] = cnt
  end
end

sum = counts.inject(0){|s, c| (s + c) % MOD}
puts sum

Measured memory_bytes: 6192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n;
    cin >> n;
    vector<int> p[2];
    read_n(p[0], n);
    read_n(p[1], n);

    i64 x[2] = {};
    for (int k = 0; k < 2; ++k) {
        vector<int> q(n);
        iota(begin(q), end(q), 1);
        while (true) {
            if (p[k] == q) break;
            next_permutation(begin(q), end(q));
            ++x[k];
        }
    }

    cout << iabs(x[0] - x[1]) << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  long long int n,a,b;
  scanf("%lld%lld%lld",&n,&a,&b);
  if(n%(a+b)>a)
    printf("%lld",(n/(a+b))*a+a);
  else
    printf("%lld",(n/(a+b))*a+n%(a+b));

	return 0;
}



Measured memory_bytes: 128
{-# LANGUAGE FlexibleContexts #-}

module Main where

-- import Debug.Trace
import Data.List
import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
-- import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

data Edge = Edge Int Int Int deriving (Eq, Show) -- Edge <left> <weight> <right>
instance Ord Edge where
    compare (Edge la wa ra) (Edge lb wb rb) = case (la,lb,ra,rb,wa,wb) of
      _ | wa > wb -> GT  
        | wa < wb -> LT 
        | la > lb -> GT 
        | la < lb -> LT 
        | ra > rb -> GT 
        | ra < rb -> LT
        | otherwise -> EQ


solve :: Int -> [[Int]] -> Int
solve n lst = sumWeight edgesOfMST where
    sumWeight = Set.foldl' (\a (Edge _ w _) -> a + w) 0
    edgesOfMST = iter Set.empty Set.empty (Set.singleton (Edge 0 0 1)) where
        iter vertices edges adjacents
            | Set.null adjacents = edges
--            | otherwise = trace (printf "Tr0\tvtx :%s\n\tvtx':%s\n\teds :%s\n\teds':%s\n\tads :%s\n\tads':%s" (show vertices) (show vertices') (show edges) (show edges') (show adjacents) (show adjacents')) $
            | otherwise = iter vertices' edges' adjacents' where
                vertices'  = Set.insert r vertices
                edges'     = Set.insert e edges
                adjacents' = updateAdjacents s
                (e@(Edge _ _ r), s) = Set.deleteFindMin adjacents
                updateAdjacents s = iter s n where
                    iter s 0 = s
                    iter s i = iter (update s) (i-1) where 
                        update s
                            | w < 0 = s
                            | Set.member i vertices = s
                            | otherwise = iter (Set.size s -1) where
                                iter (-1) = Set.insert e s
                                iter j = case Set.elemAt j s of
                                    (Edge ls ws rs)
                                        | i == rs   -> if ws > w then Set.insert e (Set.deleteAt j s) else s
                                        | otherwise -> iter (j-1)
                                w = adjacentsMatrix!(i, r)
                                e = Edge r w i

    adjacentsMatrix = (listArray ((1,1),(n,n)) (concat lst)) // [((x,x),-1)| x<-[1..n]]

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO() 
main = do
    n  <- readIntLn
    l <- replicateM n readIntList
    print $ solve n l



Measured memory_bytes: 5860
def gcd(a,b)
  if a > b
    c = a
    d = b
  else
    c = b
    d = a
  end
  e = 0
  while c % d != 0
    e = c % d
    c = d
    d = e
  end
  return d
end

N = gets.chomp.to_i
A = gets.split

a = []

for x in 0...N
  a[x] = A[x].to_i
end

if N == 2
  if a[0] > a[1]
    puts a[0]
  else
    puts a[1]
  end
  exit
end

max = gcd(a[0],a[1])
all = gcd(max,a[2])
if max < gcd(a[0],a[2])
  max = gcd(a[0],a[2])
end
if max < gcd(a[1],a[2])
  max = gcd(a[1],a[2])
end

x = 3
maxa = 0
maxb = 0
while x < N
  maxa = gcd(all,a[x])
  maxb = gcd(max,a[x])
  all = gcd(all,a[x-1])
  if maxa > maxb
    max = maxa
  else
    max = maxb
  end
  x += 1
end
if all > max
  max = all
end

puts max

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

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

int N, D, X;
int A;

int main() {
  scanf("%d%d%d", &N, &D, &X);

  int count = X;
  REP(i,N) {
    scanf("%d", &A);
    count += (D - 1) / A + 1;
  }

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())
a = list(map(int, input().split()))
max_value = max_value_index = 0
for index, i in enumerate(zip(a[:-1], a[1:])):
    if max_value < sum(i):
        max_value = sum(i)
        max_value_index = index

print("Possible\n" + "\n".join([str(i) for i in range(1, max_value_index + 1)] + [str(i) for i in range(N - 1, max_value_index, -1)]) if max_value >= L else "Impossible")

Measured memory_bytes: 14392
from collections import deque
n , m = map(int, input().split())
keys = deque()
def trans(k):
    res = [0 for i in range(n)]
    for i in k:
        res[-i] = 1
    res = int("".join(map(str, res)), 2)
    return res

for i in range(m):
    a, b = list(map(int, input().split()))
    c = deque(list(map(int, input().split())))
    c.appendleft(a)
    keys.append(c)
inf = 10 ** 8
dp = [inf for i in range(2**n)]
dp[0] = 0
for i in range(m):
    key_value = keys[i].popleft()
    can_open = keys[i]
    p = trans(can_open)
    for j in range(2**n):
        next = j | p
        dp[next] = min(dp[next], dp[j] + key_value)
#print(dp)
if dp[-1] >= inf:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 46680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int k[50],a[50];
int ans;
int main(void){
	int n,m; cin>>n>>m;
	int k;
	int A;
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>A;
			a[A-1]++;
		}
	}
	for(int i=0;i<m;i++){
		if(a[i]==n){
			ans++;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,a,b,i,j;
  scanf("%d %d %d",&n,&a,&b);
  int sum = 0;
  for(i=1;i<=n;i++){
    int t = 0;
    int s = i;
    for(j=0;j<5;j++){
      t += (s%10);
      s /= 10;
    }
    if((t>=a)&&(t<=b))
      sum += i;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};

        // 昇順に並び替え
        Arrays.sort(a);

        int cost = 0;
        cost += a[1] - a[0];
        cost += a[2] - a[1];

        System.out.println(cost);
    }
}


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

using namespace std;
typedef long long ll;
    
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    for (ll i = 0; i < N-1; i++) {
        ll tmp;
        cin >> tmp;

        A[tmp-1]++;
    }

    for (ll i = 0; i < N; i++) {
        cout << A[i] << "\n";
    }

    return 0;
}


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

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

    int bucket[n];
    for (int i = 0; i < n; ++i) {
        bucket[i] = 0;
    }

    for (int i = 0; i < k; ++i) {
        int d; cin >> d;
        for (int j = 0; j < d; ++j) {
            int t; cin >> t;
            t--;
            bucket[t] += 1;
        }
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (bucket[i] == 0) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#define ld long double
using namespace std;
ld n,m,d;
int main(){
	cin>>n>>m>>d;
	ld a=2.0;
	if(!d) a=1.0;
	printf("%.7Lf",(a*(n-d)*(m-1))/(n*n));
	return 0;
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    

main = do
    (a, b) <- readTuple2
    if  a < 10 && b < 10 then
        print $ a * b
    else 
        putStrLn "-1"

Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b;
	int sum = 0;
	
	cin  >> a >> b;
	syc(a,2,20);
	syc(b,1,20);
	
	if(b==1){
		cout << "0" << endl;
		return 0;
	}
	
	for(int i=1;i<100;i++){
		sum = (i-1)*(a-1)+a;
		//cout << "sum =  " << sum << endl;
		if(sum >= b){
			cout << i << endl;
			return 0;
		}	
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(),b = sc.nextInt();
    if(a<9&&b<9){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 21844
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
ll a[N], h[N], bit[N];
void update(int x, ll val){
    for(int i = x; i < N; i += i & -i)
        bit[i] = max(bit[i], val);
}
ll query(int x){
    ll ans = 0;
    for(int i = x; i > 0; i -= i & -i)
        ans = max(ans, bit[i]);
    return ans;
}

int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++){
        ll temp = query(h[i] - 1);
        update(h[i], a[i] + temp);
    }
    cout << query(N - 1);
return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2236
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	char in[1000];
	while (~scanf("%s",in))
	{
		int m ,len = strlen(in), flag = 0;
		if (strcmp(in, "AKIHABARA") == 0)
		{
			printf("YES\n");
			continue;
		}
		if (strstr(in, "KIH") == NULL)
			flag = 1;
		for (int i = 0; i < len; i++)
		{
			if (!flag&&in[i] == 'A'&&in[i + 1] == 'A')
			{	
				flag = 1; 
				break;
			}
			if (in[i] == 'A')
			{
				for (int j = i; j < len - 1; j++)
					in[j] = in[j + 1];
				len--;
				i--;
			}
		}
		in[len] = '\0';
		if (strcmp(in , "KIHBR")==0&&!flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
import math

X = int(input())
count = 0
ok = 0
while ok == 0 :
    n = int(math.sqrt(X))
    for i in range(2,n+1) :
        if X % i != 0 :
            count += 1
    if count == n-1 :
        ok = 1
    else :
        X += 1
        count = 0
        
print(X)





Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    while(1){
        int i,j,h,w;
        scanf("%d %d",&h,&w);
        if(h==0&&w==0){
            break;
        }
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if(i!=1&&i!=h&&j!=1&&j!=w){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.9lf", sqrt(d));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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; }
const long long INF = 1LL << 60;
const int mod = 1000000007;

ll dp[100100];
int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i,tx-sx){
        cout << 'R';
    }
    rep(i,ty-sy){
        cout << 'U';
    }
    cout << 'R';
    rep(i,ty-sy+1){
        cout << 'D' ;
    }
    rep(i,tx-sx+1){
        cout << 'L';
    }
    cout << 'U' ;
    rep(i,ty-sy){
        cout << 'U';
    }
    rep(i,tx-sx){
        cout<<'R';
    }
    cout << 'U';
    rep(i,tx-sx+1){
        cout << 'L';
    }
    rep(i,ty-sy+1){
        cout << 'D';
    }
    cout <<'R';

}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int dp[10][30005];

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(d, 10) {
    int idx = -1;
    for (int i = n - 1; 0 <= i; i--) {
      if (s[i] == '0' + d) idx = i;
      dp[d][i] = idx;
    }
    dumpv(d, dp[d], n);
  }
  int cnt = 0;
  rep(i, 10) rep(j, 10) rep(k, 10) {
    int idx = 0;
    if (dp[i][idx] == -1) continue;
    if (idx <= dp[i][idx]) {
      idx = dp[i][idx] + 1;
      if (dp[j][idx] == -1) continue;
      if (idx <= dp[j][idx]) {
        idx = dp[j][idx] + 1;
        if (dp[k][idx] == -1) continue;
        if (idx <= dp[k][idx]) {
          cnt++;
          dump(i, j, k);
        }
      }
    }
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
// #define _GLIBCXX_DEBUG
// #ifdef DEBUG
// #define s(...) show(__VA_ARGS__);
// #define sl(...) show(__VA_ARGS__);cout<<endl;
// #else
// #define s(...)
// #define sl(...)
// #endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
#define ALL(v) v.begin(), v.end()


ll t[100010];
ll h[100010];

ll root(ll x){
    if(t[x]==x){
        return x;
    }else{
        return t[x]=root(t[x]);
    }
}

int main(){
    ll a=97;
    string S;
    ll N,M;
    cin>>S>>N;
    M=S.length();
    vector<int> s(M);
    REP(i,M){
        s[i]=S[i]-a;
    }
    REP(i,M){
        if(s[i]!=0&&25-s[i]<N){
            N-=26-s[i];
            s[i]=0;
        }
    }
    s[M-1]+=N%26;
    s[M-1]%=26;
    for(auto x:s){
        char tt=x+a;
        cout<<tt;
    }
    
    return 0;
    
    // REP(i,N){
    //     t[i]=i;//t.push_back(i);
    //     h[i]=0;//h.push_back(0);
    // }
    // REP(ttttt,Q){
    //     ll q;
    //     cin>>q;
    //     if(q==0){
    //         ll a,z;
    //         cin>>a>>z;
    //         ll mi=min(root(a),root(z));
    //         ll ma=max(root(a),root(z));
    //         if(a!=z){
    //             if(h[mi]==h[ma]){
    //                 t[ma]=mi;
    //                 h[mi]++;
    //             }else if(h[mi]>h[ma]){
    //                 t[ma]=mi;
    //             }else{
    //                 t[mi]=ma;
    //             }
    //         }
    //     }else{
    //         ll a,z;
    //         cin>>a>>z;
    //         cout<<(root(a)==root(z)?"Yes":"No")<<endl;
    //     }
    // }
    // REP(i,N){
    //     sl(i,":",t[i],h[i]);
    // }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int ans = 0;
        int th = 0;
        int temp = 0;
        th = (x / 500) * 1000;
        ans += th;
        x %= 500;
        if(x != 0){
            temp = x / 5;
            ans += temp * 5;
        }
        cout << ans;

    return 0;
}


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

int main() {
	int n, x, total = 0, tmp = MAX;
	cin >> n;
	for(int i = 0; i < n; i++) {
		scanf("%d", &x);
		total += x;
		if(x % 10) tmp = min(tmp, x);
	}
	if(total % 10) {
		cout << total << "\n";
	}
	else {
		cout << max(total - tmp, 0);
	}
	return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N,M;cin >> N >> M;
    long long ans = 0;
    priority_queue<long long>Q;
    for(int i = 0;i<N;i++){
        int A;cin >> A;
        Q.push(A);
    }

    for(int i = 0;i<M;i++){
        long long X = Q.top();
        Q.pop();
        Q.push(X/2);
    }

    while(!Q.empty()){
        ans += Q.top();
        Q.pop();
    }

    cout << ans << endl;
    
    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 1400
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=ja 
ALDS1_2_A:バブルソート
*/

#include <bits/stdc++.h>

using namespace std;

void disp(unsigned short int *n, unsigned short int N);
int bubble_sort(unsigned short int *n, unsigned short int N);
int selection_sort(unsigned short int *n, unsigned short int N);


int main(void){

	unsigned short int N;
	scanf("%d", &N);

	unsigned short int n[N];

	for(int i=0; i<N; i++) {
		scanf("%d", &n[i]);
	}

    //int count = bubble_sort(n, N);
    //int count = selection_sort(n, N);
    int count = 0;
    for(int i=0; i<N-1; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if(n[j] < n[minj]){
                minj = j;
            }
        }
        if(minj != i){
            count +=1;
            unsigned int tmp = n[i];
            n[i] = n[minj];
            n[minj] = tmp;
        }
        //printf("i=%d: ", i);
        //disp(n, N);
    }

    disp(n, N);
    printf("%d\n",count);

	return 0;
	
  
}

void disp(unsigned short int *n, unsigned short int N){
	//printf("disp: ");
	for(int i=0; i<N; i++) {
		printf("%d", n[i]);
		if( i != N-1) printf(" ");
	}
	printf("\n");
}

int bubble_sort(unsigned short int *n, unsigned short int N){
    int max = N-1;
    int flag;
    if(N >= 2){
        flag = 1; //ソート終了フラグ
    }else if(N<=1) flag = 0;
    int count=0; //交換回数
    while(flag == 1){
        for(int i=0; i<max; i++){
            if(n[i] > n[i+1]){
                count += 1;
                unsigned short int tmp = n[i];
                n[i] = n[i+1];
                n[i+1] = tmp;
            }
        }
        max = max-1;
        if(max == 0) flag = 0;
    }

    return count;
}

int selection_sort(unsigned short int *n, unsigned short int N){
    int count = 0;
    int flag;
    if(N >= 2){
        flag = 1; //ソート終了フラグ
    }else if(N<=1) flag = 0;


    return count;
}


Measured memory_bytes: 3224
#include <stdio.h>

int main()
{
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int a[100000];
    for(int i=0;i<q;i++) scanf("%d",&a[i]);

    int b[100000]={};//正解した回数
    for(int i=0;i<q;i++)
    {
        b[a[i]-1]++;
    }
    
    for(int i=0;i<n;i++)
    {
        if((k-(q-b[i]))>0) printf("Yes\n");
        else printf("No\n");
        // printf(" %d\n",k-(q-b[i]));
    }
}

Measured memory_bytes: 1280
#include <stdio.h>



int main(void){
  
  int A, B;
  
  scanf("%d %d", &A, &B);
  
  if( A == 1 ) A = 14;
  if( B == 1 ) B = 14;
  
  if( A == B ) puts("Draw");
  else if( A > B ) puts("Alice");
  else{            puts("Bob");}
  
  
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int A, B;
    
    cin >> A >> B;
    
    bool isError = false;
    if (A + B >= 10)
    {
        isError = true;
    }
    
    if (isError)
    {
        printf("error\n");
    }
    else
    {
        printf("%d\n", A + B);
    }
    
    return 0;
}


Measured memory_bytes: 256