akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int H,W,M; cin >> H >> W >> M;
    int row[300300];
    int column[300300];
    set<pair<int,int>> item;
    Fill(row, 0);
    Fill(column, 0);
    rep(i,0,M){
        int h,w; cin >> h >> w;
        row[--h]++;
        column[--w]++;
        item.insert({h,w});
    }

    int rowmx = 0;
    int columnmx = 0;
    rep(i,0,H){
        if(row[i] > rowmx) rowmx = row[i];
    }
    rep(i,0,W){
        if(column[i] > columnmx) columnmx = column[i];
    }

    vector<int> R;
    vector<int> C;
    rep(i,0,H){
        if(row[i] == rowmx) R.pb(i);
    }
    rep(i,0,W){
        if(column[i] == columnmx) C.pb(i);
    }
    
    for(int i:R){
        for(int j:C){
            if(item.count({i,j})) continue;
            else{
                cout << rowmx + columnmx << endl;
                return 0;
            }
        }
    }

    cout << rowmx + columnmx - 1 << endl;
    return 0;
}


Measured memory_bytes: 23768
#include <iostream>
#include <vector>
#include <climits>

int main () {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> coins;
    std::vector<int> min_coins(n + 1, int(1e9));
    min_coins[0] = 0;

    for (int i = 0; i < m; ++i) {
        int coin;
        std::cin >> coin;
        if (coin <= n) {
            coins.push_back(coin);
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int c : coins) {
            if (i + c > n) continue;
            min_coins[i + c] = std::min(min_coins[i + c], min_coins[i] + 1);
        }
    }

    std::cout << min_coins[n] << std::endl;

    return 0;
}



Measured memory_bytes: 3184
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    
    ll alice,bob;cin>>alice>>bob;
    if(alice==1)alice+=100;if(bob==1)bob+=100;
    ll a=100000000000000000000;
    for(long long int i=1;i<=a;i++){
        alice++;
        bob++;
    }
    if(alice==bob)printf("Draw");
    else if(alice<bob)printf("Bob");
    else printf("Alice");
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int A,B,C,a;
	scanf("%d%d%d",&A,&B,&C);
	a=A;
	A=B;
	B=a;
	a=A;
	A=C;
	C=a;
	printf("%d %d %d",A,B,C);
	return 0;
}


Measured memory_bytes: 1692
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int val[15][15][15];
int n, m, q;
int ans;
void dfs(int cur, vector<int>& vec, int u, int res){
	if(u == n){
		ans = max(ans, res);
		return;
	}
	for(int i = cur; i <= m; i++){
		vec.pb(i);
		int tmp = 0;
		for(int j = 0; j < u; j++){
			tmp += val[j+1][u+1][i - vec[j]];
		}
		dfs(i, vec, u+1, res+tmp);
		vec.pop_back();
	}
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin>>n>>m>>q;
	for(int i = 0; i < q; i++){
		int a, b, c, d; cin>>a>>b>>c>>d;
		val[a][b][c] = d;
	}
	for(int i = 1; i <= m; i++){
		vector<int> vec; vec.pb(i);
		dfs(i, vec, 1, 0);
	}
	cout<<ans<<endl;
}

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

int main(void) {
	int n;//??°????????°
	int i,j;//????????????
	int k;//??????????±?
	int a = 0;//?´???°?????°
	
	scanf("%d",&n);
	
	
	for(i=0;i<n;i++){
		scanf("%d",&k);
		//printf("%d\n",k);
		
		if (k == 2 || k == 3) a++;
		else if (k % 2 == 0 || k < 2){}
		else {
			for(j=3;j<=sqrt(k);j+=2){
				if (k % j == 0) break;
				else{}
			}
			if(k % j != 0)a++;
			else{}
		}
	}
	
	printf("%d\n",a);

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,ans=0,A=0,B=0,C=0;
  cin>>N;
  for(int k=0;k<N;k++){
    string S;
    cin>>S;
    int a=0,b=0;
    for(int i=0;i<S.size()-1;i++)
      if(S.substr(i,2)=="AB")
        ans++;
    if(S[0]=='B' && S[S.size()-1]=='A')
      C++;
    if(S[0]=='B')
      B++;
    if(S[S.size()-1]=='A')
      A++;
  }
  if(A==C && B==C && C>0)
    cout<<ans+C-1<<endl;
  else
    cout<<ans+min(A,B)<<endl;
}

Measured memory_bytes: 3584
module ABC136

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: count_uneven
  private :: is_uneven_num
  private :: is_even

  ! contained <subroutine>s and <function>s are below
  contains
  
  subroutine task_B (val_range)

    ! arguments for this <subroutine>
    integer(INT32), intent(in) :: val_range

    ! variables for this <subroutine>
    integer(INT32) :: val_order
    integer(INT32) :: val_range_bffr

    val_range_bffr = val_range
    val_order      = 0_INT32

    do while (val_range_bffr .ge. 10_INT32)
      val_range_bffr = val_range_bffr / 10_INT32
      val_order      = val_order + 1_INT32
    end do

    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') count_uneven(val_range, val_order)
    
    ! STEP.END
    return

  end subroutine task_B

  pure function count_uneven (val_range, val_order) result (num_uneven_integers)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_range
    integer(INT32), intent(in) :: val_order

    ! return value of this <function>
    integer(INT32) :: num_uneven_integers

    ! support variables for this <function>
    integer(INT32) :: itr

    ! STEP.01
    ! initialize the return value of this <function>
    num_uneven_integers = 0_INT32

    ! STEP.02
    ! count up the number of uneven integers
    do itr = 1_INT32, val_range
      if ( is_uneven_num(val_target = itr, len_str = val_order + 1_INT32) ) then
        num_uneven_integers = num_uneven_integers + 1_INT32
      end if
    end do

    ! STEP.END
    return

  end function count_uneven

  pure function is_uneven_num (val_target, len_str) result(stat)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_target
    integer(INT32), intent(in) :: len_str

    ! return value of this <function>
    logical :: stat

    ! variables for this <function>
    character(len=len_str, kind=1) :: str_target

    write(unit=str_target, fmt='(I0)') val_target
    stat = .not. is_even( len_trim(str_target) )
    return

  end function is_uneven_num

  pure function is_even (val_target) result(stat)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_target

    ! return value of this <function>
    logical :: stat

    stat = mod(val_target, 2_INT32) .eq. 0_INT32
    return

  end function is_even

end module ABC136

program main

  ! <module>s to import
  use,     intrinsic :: iso_fortran_env
  use, non_intrinsic :: ABC136

  ! variables for this <program>
  integer(INT32) :: N

  read(unit=INPUT_UNIT, fmt=*) N
  
  call task_B (N)

end program main

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

int main() {

  int N, M;
  cin >> N >> M;

  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }

  int answer = 0;

  // X を小さい順に並び替える
  sort(X.begin(), X.end());

  vector<int> distance(M-1);

  // 各点の距離を配列に入れる
  for (int i = 0; i < M -1; i++){
    distance[i] = abs(X[i] - X[i + 1]);
  }

  // 距離を短い順に並び替える
  sort(distance.begin(), distance.end());

  // 小さい順に (M - N) 個分移動させる
  for (int i = 0; i < M - N; i++) {
    answer += distance[i];
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1024
N = int(input())
h = list(map(int,input().split()))
dp = []

for i in range(N):
  if i <1:
    dp.append(0)
  elif i == 1:
    dp.append(abs(h[i]-h[i-1]))
  else:
    dp.append(min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) )

print(dp[-1])


Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	ll n,q; cin >> n >> q;
	ll ans = (n-2) * (n-2);
	set<P> y, x;
	y.emplace(n,n);
	x.emplace(n,n);
	rep(i,q){
		ll t,p; cin >> t >> p;
		if(t == 1){
			auto itr = x.upper_bound(P(p,inf));
			ans -= (*itr).second - 2;
			y.emplace((*itr).second, p);
		}else{
			auto itr = y.upper_bound(P(p,inf));
			ans -= (*itr).second - 2;
			x.emplace((*itr).second, p);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 16116
local t = {}
local any = 0
for i = 1, 8 do t[i] = false end
local n = io.read("*n")
for i = 1, n do
  local a = io.read("*n")
  local pos = 1 + math.floor(a / 400)
  if pos <= 8 then
    t[pos] = true
  else
    any = any + 1
  end
end
local normal = 0
for i = 1, 8 do if t[i] then normal = normal + 1 end end
if normal == 0 then
  print(1 .. " " .. any)
else
  print(normal .. " " .. normal + any)
end


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

int		viewcounter(int *H, int N)
{
	int		i;
	int		j;
	int		count;

	i = 0;
	count = 0;
	while (i < N)
	{
		j = i;
		while (0 <= j)
		{
			// printf("%d:%d\n",H[i],H[j]);
			if (H[i] < H[j])
				break;
			j--;
		}
		if (j == -1)
			count++;
		i++;
	}
	return (count);
}

int		main(void)
{
	int		i;
	int		*H;
	int		N;

	i = 0;
	scanf("%d", &N);
	H = (int *)malloc(sizeof(int) * (N));
	while (i + 1< N)
	{
		scanf("%d ", &H[i]);
		i++;
	}
	scanf("%d", &H[i]);
	printf("%d",viewcounter(H, N));
	free(H);
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
//#define m 1000000007
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp>     //required
// using namespace __gnu_pbds;              //required
// using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set<int> s;
// ordered_set<int>::iterator itr;
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    int n;
    char qw;
    cin >> qw;
    if (qw >= 'a')
        cout << "a"
             << "\n ";
    else
        cout
            << "A"
            << "\n";

    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInput_long()[0];
            long sum = 0;
            for (int a = 1; a <= N; a++)
            {
                long count = (long)N / a;
                long l = a * count;
                var add =(long)( (a + l)*count / 2);
                sum += add;
            }
            Console.WriteLine(sum);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

Measured memory_bytes: 27528
uses math;
var n,m,i,j:longint;
    a,t:array[0..1010]of int64;
    aa,tt,ka,kt,l,r,mid,ans:int64;

begin
readln(n);
for i:=1 to n do readln(a[i],t[i]);
l:=0;r:=1100000000000000000 div (a[n]+t[n]);
ans:=r+1;
while l<=r do begin
  mid:=(l+r)div 2;
  aa:=mid*a[n];tt:=mid*t[n];
  for j:=n-1 downto 1 do begin
    ka:=(aa div a[j]);
    kt:=tt div t[j];
    if ka<kt then begin aa:=(aa div a[j])*a[j];tt:=(aa div a[j])*t[j];end
             else begin tt:=(tt div t[j])*t[j];aa:=(tt div t[j])*a[j];end;
    if (aa=0)or(tt=0) then break;
  end;
  if (aa=0)or(tt=0) then l:=mid+1 else begin ans:=min(ans,mid);r:=mid-1;end;
end;
writeln(ans*(a[n]+t[n]));
end.


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

string s;
int a,b;

bool ism(int k){
        return (0 < k && k <=12);
}


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

        cin >> s;

        a = (s[0] - '0')*10 + s[1]-'0';
        b = (s[2] - '0')*10 + s[3]-'0';

        debug(a);
        debug(b);

        if (ism(a) && ism(b)) {
                cout << "AMBIGUOUS" << endl;
        } else if (ism(a)) {
                cout << "MMYY" << endl;
        } else if (ism(b)) {
                cout << "YYMM" << endl;
        } else {
                cout << "NA" << endl;
        }


        return 0;
}


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

int main(){
string S;
  bool a = true;
  cin >> S;
  for(int i =0;i < S.size()-1;++i){
  if(S.at(i) == S.at(i +1))
     a = false;
  }
    if(a == true)
     cout << "Good" << endl;
     else
     cout << "Bad" << endl;



}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);

   if(a<=b && b<=c) {
      printf("%d %d %d\n", a, b, c);
   } else if(b<=a && a<=c) {
      printf("%d %d %d\n", b, a, c);
   } else if(c<=a && a<=b) {
      printf("%d %d %d\n", c, a, b);
   } else if(b<=c && c<=a) {
      printf("%d %d %d\n", b, c, a);
   } else if(a<=c && c<=b) {
      printf("%d %d %d\n", a, c, b);
   } else if(b<=a && c<=b) {
      printf("%d %d %d\n", c, b, a);
   }

   return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        String s = ns();
        String t = ns();
        String ss = s+s;
        HashMap<Character,ArrayList<Integer>> smap = new HashMap<>();
        for (int i = 0; i < ss.length(); i++) {
            smap.putIfAbsent(ss.charAt(i), new ArrayList<>());
            smap.get(ss.charAt(i)).add(i);
        }

        int sc = 0;
        long ans = 0;
        for (int i = 0; i < t.length(); i++) {
            char ti = t.charAt(i);
            if(!smap.containsKey(ti)){
                ans = -1;
                break;
            }
            ArrayList<Integer> locs = smap.get(ti);
            // System.out.println(locs);
            int lb = Collections.binarySearch(locs, sc);
            // System.out.println(lb);
            if(lb >= 0) lb = lb;
            else lb = ~lb;
            // System.out.println(lb);
            ans += locs.get(lb)+1-sc;
            // System.out.println(ans);
            sc = locs.get(lb)+1;
            if(sc>s.length()){
                sc-=s.length();
            }
            // System.out.println(sc);
        }

 
        out.println(ans);
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 53352
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; let result = jumban (a,b,c)
  ; putStrLn result
  }


jumban :: (Int,Int,Int) -> String
jumban (x,y,z)
  | x < y && y < z = "Yes"
  | otherwise      = "No"

getInts :: IO [Int]
getInts = map read . words <$> getLine

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

int main() {
  string s;cin>>s;
  int n=s.size();
  rep(i,n){
    s.pop_back();
    int x=s.size();
    if(s.substr(0,x/2)==s.substr(x/2)){
      cout<<s.size()<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long mod_inv(long long n)
{
    long long left=MOD-2;  // define MOD!
    long long num=n;
    long long ans=1;
    while(left!=0)
    {
        if(left%2==1)ans=(ans*num)%MOD;
        left/=2;
        num=(num*num)%MOD;
    }
    return ans;
}

int main()
{
  long long n,a,b;cin>>n>>a>>b;
  long long ans=1;
  long long ks=2;
  long long nn=n;
  long long i;
  while(nn>0)
  {
    if(nn%2==1)ans=(ans*ks)%MOD;
    ks=(ks*ks)%MOD;
    nn/=2;
  }
  ans=(ans+MOD-1)%MOD;
  long long comb=1;
  for(i=1;i<=a;i++)
  {
    comb=comb*((n+1-i)*mod_inv(i)%MOD);
    comb%=MOD;
  }
  ans=(ans-comb+MOD)%MOD;
  comb=1;
  for(i=1;i<=b;i++)
  {
    comb=comb*((n+1-i)*mod_inv(i)%MOD);
    comb%=MOD;
  }
  ans=(ans-comb+MOD)%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 300007
using namespace std;
int n,len;
int a[Maxn],t[Maxn],type[Maxn];
int main()
{
	scanf("%d%d",&n,&len);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&t[i]);
	long long ans=1;
	for (int i=1;i<=n;i++)
	{
		ans+=t[i]/(2*len);
		t[i]%=(2*len);
	}
	for (int i=1;i<=n;i++)
		if (t[i]!=0)
		{
			if (t[i]<=a[i]*2) type[i]|=1;
			if (t[i]<=(len-a[i])*2) type[i]|=2;
			++ans;
		}
	if (type[n]&2)
	{
		--ans;
		type[n]=0;
	}
	int cnt1=0,cnt2=0;
	for (int i=n;i;i--)
		if (type[i]>0)
		{
			if (type[i]==1)
			{
				if (cnt1)
				{
					--cnt1;
					--ans;
				} else if (cnt2)
				{
					--cnt2;
					++cnt1;
				}
			} else if (type[i]==2) ++cnt1;
			else
			{
				if (cnt1)
				{
					--cnt1;
					++cnt2;
					--ans;
				} else ++cnt1;
			}
		}
	printf("%lld\n",2LL*ans*len);
	return 0;
}


Measured memory_bytes: 3712
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	vector<int> a(4);
	for(int &i:a)i=in();
	int ans=a[0]*a[3];
	ans=max(a[0]*a[2],ans);
	ans=max(a[1]*a[2],ans);
	ans=max(a[1]*a[3],ans);
	cout<<ans;
	
	
}


Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		sc.close();
		if(S == 25) {
			System.out.println("Christmas");
		}else if(S == 24) {
			System.out.println("Christmas Eve");
		}else if(S == 23) {
			System.out.println("Christmas Eve Eve");
		}else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}

}

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

int main() {
  int sum=0;
  int N,A,B;
  cin >> N >> A >> B;
  for(int i=1;i<=N;++i) {
    int a = (int)(i / 10000) % 10;
    int b = (int)(i / 1000) % 10;
    int c = (int)(i / 100) % 10;
    int d = (int)(i / 10) % 10;
    int e = i % 10;
    //cout << i << endl;
    //cout << d << endl;
    
    if( A <= a+b+c+d+e && a+b+c+d+e <= B ){
      //cout << i << endl;
      sum+=i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long ans=0,h,peo=1;
    cin>>h;
    while(1){
        if(h==1){
            break;
        }
        ans+=peo;
        peo*=2;
        h/=2;
    }
    cout<<ans+peo<<endl;
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <string>
#include <iostream>
using namespace std;
#define f(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rf(i, a, b) for (int(i) = (a)-1; (i) >= (b); (i)--)
#define CLEAR(a) memset((a), 0, sizeof(a))
#define INF 1000000000
#define lli long long int
#define ull unsigned long long int
#define ALL(c) (c).begin(), (c).end()

#define mod 1000000007

int abs(int a, int b) { return a - b < 0 ? b - a : a - b; }
int main(void)
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    string s,s1="R",s2="RR",s3="RRR";
    cin >> s;
    int val = 0;
    if (s.find(s1) != string::npos) val=1;
    if (s.find(s2) != string::npos) val=2;
    if (s.find(s3) != string::npos) val=3;
    cout<<val;
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
//#define TEST
vector<ll> v;

void dfs(int k, ll x)
{
    // 初期値 x: 1 ~ 9
    v.push_back(x);
    if(k>=9) return;
    // 1の位
	int a=x%10;
    // 桁下がりしない数 0でない
    // x:10倍した数: 10, 20, 30,..., 90 + 前後の数
    if(a){
		dfs(k+1, x*10+a-1);
	}
	dfs(k+1, x*10+a);
    // 桁上がりしない数 9でない
	if(a<9){
		dfs(k+1, x*10+a+1);
	}
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    ll K;
    cin >> K;
    for(int i=1; i<=9; i++) dfs(0, i);
    // std::unique
    // 隣り合った重複要素を除いた要素を、範囲の先頭に集める
    // この関数によってコンテナから直接要素が削除され、コンテナの要素数が減るようなことはない
    // 戻り値：重複を除いた範囲の、末尾の次を指すイテレータ
	//v.erase(unique(v.begin(), v.end()), v.end());
	//手に入れた　v には順序の不整合や重複があるので除く
	sort(v.begin(), v.end());
    cout<<v[K-1]<<endl;

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i=0; i<n; i++) cin >> vec.at(i);
    long long ans = 200*200*100;

    int cnt;
    for (int i=-100; i<101; i++) {
        cnt = 0;
        for (int j=0; j<n; j++) {
            cnt += pow(vec.at(j)-i, 2);
        }
        if (cnt<ans) ans = cnt;
    }
    cout << ans << endl;
}


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

int main() {
	int times;
    cin >> times;
    
    int ans = 0;
    for(int i = 0; i < times; i++) {
    	int num;
        cin >> num;
    
    	int tempAns = 0;
    	while(num % 2 == 0) {
        	num /= 2;
        	tempAns++;
        }
        if(i == 0 || ans > tempAns) ans = tempAns;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 4e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e18;
const int LG = 21;


int cnt[N];

void solve()
{
	int l, r, d;
	cin >> l >> r >> d;
	int ret = 0;
	for(int i = l; i <= r; i++)
	{
		ret += (i % d == 0);
	}
	cout << ret << endl;
}
 
int32_t main() 
{	

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3628
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i", $n);
  $s = trim(fgets(STDIN));

  $open = 0;
  $close = 0;
  $i = 0;
  while ($i < $n)
  {
      if ($s[$i] === '(')
      {
          ++$close;
      }
      else if (/* $s[$i] === ')' && */ $close > 0)
      {
          --$close;
      }
      else
      {
          ++$open;
      }

      ++$i;
  }

  $left = [];
  while ($open > 0)
  {
      $left[--$open] = '(';
  }
  $right = [];
  while ($close > 0)
  {
      $right[--$close] = ')';
  }
  echo implode("", $left), $s, implode("", $right), PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define PB push_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
const int maxn=2e5;

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=100000;i++){
		if(floor((double)i*0.08)==a&&floor((double)i*0.1)==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	string S, ans;
	cin >> S;

	for (int i = 0; i < 1 << 3; ++i){
		int sum = S[0] - '0';
		string tmp;
		tmp = S[0];
		for (int b = 0; b < 3; ++b){			
			if (i >> b & 1){
				tmp += '+';
				sum += S[b + 1] - '0';
			}
			else{
				tmp += '-';
				sum -= S[b + 1] - '0';
			}
			tmp += S[b + 1];
		}
		if (sum == 7){
			ans = tmp;
			break;
		}
	}
	ans += "=7";
	cout << ans << endl;

	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

vvint G;
bitset<100005> flag;

void dfs(int u) {
	if (flag[u]) return;
	flag[u] = true;
	for (auto &v : G[u]) dfs(v);
}
void Main() {
	int N, M; cin >> N >> M;
	G = vvint(N);
	while (M--) {
		int a, b, c; cin >> a >> b >> c; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (!flag[i]) {
			dfs(i); cnt++;
		}
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

int N;

ll solve() {
    ll ans = 0;
    ll ten = 10, now_keta = 1;
    for (int i = 1; i <= N; i++) {
        if (i / now_keta >= 10) now_keta *= 10;
        if (i % 10 == 0) continue;
        // 先頭の桁
        ll a = i / now_keta;
        //cout << a << endl;
        // 末尾の桁
        ll b = i % 10;
        //cout << b << endl;
        /*ll tmp = b * ten + a, cnt = 1, keta = 1;
        if (a == b) ans++;
        while (tmp <= N) {
            
            ans++;
            cnt++;
            if (cnt)
        }*/
        // 先頭の桁と末尾の桁が同じ場合は、1桁の数字をカウントする
        if (a == b) ans++;
        // Nより大きくなるのは何桁目かを見る
        int keta = 0, kakeru = 0;//, keta_old = keta, kakeru_old = kakeru;
        ll tmp = b * 10 + a;//, tmp_old = tmp;
        while (tmp <= N) {
            //if (kakeru == 0) ans++;
            //else ans += 9 * kakeru / 10 + 1;
            //cout << i << endl;
            //cout << tmp << endl;
            //cout << kakeru << endl;
            ans += 9 * kakeru / 10 + 1;
            //keta_old = keta;
            //kakeru_old = kakeru;
            //tmp_old = tmp;
            keta++;
            kakeru += pow(10, keta);
            //cout << kakeru << endl;
            tmp = b * pow(10, keta+1) + 9 * kakeru + a;
            //cout << i << endl;
            //cout << tmp_old << endl;
        }
        //cout << i << endl;
        //cout << tmp << endl;
        if ((N - (b * pow(10, keta + 1) + a)) >= 0) ans += ll(N - (b * pow(10, keta + 1) + a)) / 10 + 1;
        /*if ((b * pow(10, keta+1) + a) > N) continue;
        else {
            //cout << i << endl;
            //cout << (b * pow(10, keta+1) + a) << endl;
            //cout << N - (b * pow(10, keta + 1) + a) << endl;
            ans += (N - (b * pow(10, keta+1) + a)) / 10 + 1;
        }*/
        // にぶたん !!やる必要なし!!
        /*ll left = b * pow(10, keta+1) + a, right = tmp;
        ll mid;
        while (left < right) {
            mid = (left + right) / 2;
            if (mid < N) left = mid + 1;
            else if (mid > N) right = mid;
            else break;
        }
        //cout << mid << endl;
        //cout << right - left << endl;
        if (left != b * pow(10, keta + 1) + a) {
            cout << i << endl;
            cout << b * pow(10, keta + 1) + a << endl;
            cout << (mid - b * pow(10, keta + 1) - a) << endl;
            cout << (mid - b * pow(10, keta + 1) - a) / 10 + 1 << endl;
            ans += (mid - b * pow(10, keta + 1) - a) / 10 + 1;
        }*/
    }
    return ans;
}

int main(){
    cin >> N;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3988
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int square;
    int len;
    
    scanf("%d %d",&a,&b);
    square = a * b;
    len = 2 * (a + b);
    printf("%d %d\n",square,len);
    return (0);
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

const int INF = 4e18;

int n, t, q;
int a[100010], d[100010], x[1010], ans[1010];

int stoppoint(int who)
{
  if(d[who] == 1){
    if(d[who + 1] == 2){
      return (a[who] + a[who + 1]) / 2;
    }
    else{
      return stoppoint(who + 1);
    }
  }
  else{
    if(d[who - 1] == 1){
      return (a[who] + a[who - 1]) / 2;
    }
    else{
      return stoppoint(who - 1);
    }
  }
}

signed main()
{
  scanf("%lld%lld%lld", &n, &t, &q);
  for(int i = 1; i <= n; i++){
    scanf("%lld%lld", &a[i], &d[i]);
  }
  for(int i = 1; i <= q; i++){
    scanf("%lld", &x[i]);
  }

  a[0] = -INF, d[0] = 1;
  a[n + 1] = INF, d[n + 1] = 2;

  for(int i = 1; i <= q; i++){
    int stp = stoppoint(x[i]);

    if(abs(a[x[i]] - stp) <= t){
      ans[i] = stp;
    }
    else{
      if(d[x[i]] == 1){
	ans[i] = a[x[i]] + t;
      }
      else{
	ans[i] = a[x[i]] - t;
      }
    }
  }

  for(int i = 1; i <= q; i++){
    printf("%lld\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 4716
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int k,s;
	cin>>k>>s;
	int ans=0;
	for (int x=0; x<=k; ++x)
	{
		for (int y=0; y<=k; ++y)
		{
			int z=s-(x+y);
			if(z >= 0 && z <= k)
			{
				++ans;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
H = np.array([ir() for _ in range(N)])
H.sort()
Hdiff = H[K-1:] - H[:-(K-1)]
answer = Hdiff.min()
print(answer)


Measured memory_bytes: 20572
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

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

    int A, B; cin >> A >> B;
    string S; cin >> S;

    bool isOK = true;
    rep(i,A+B+1){
        if (i != A){
            if ('0' > S[i] || S[i] > '9'){
                isOK = false;
            }
        }
        else{
            if (S[i] != '-'){
                isOK = false;
            }
        }
        
    }

    if (isOK) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int l[100];
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l, l + n, greater<int>());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto s = readln().chomp().to!(char[]);
    auto k = readLong();
    int next(int n) {
        while(n < s.length && s[n] == 'a') {
            ++n;
        }
        return n;
    }
    int i = next(0);
    while(k >= 26) {
        if(i < s.length) {
            k -= 'z'-s[i] + 1;
            s[i] = 'a';
            i = next(i);
        } else {
            k %= 26;
        }
    }
    while(k > 0) {
        if(i < s.length) {
            if(k >= 'z'-s[i]+1) {
                k -= 'z'-s[i]+1;
                s[i] = 'a';
            }
            i = next(i+1);
        } else {
            s[$-1] += k;
            k = 0;
        }
    }
    writeln(s.to!string);
}



Measured memory_bytes: 672
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N,ans=0;
    unsigned int L[100];

    cin>>N;

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

    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            if(L[j]<L[i]){
                int a=L[j];
                L[j]=L[i];
                L[i]=a;
            }
        }
    }

    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if((L[k] < L[i]+L[j])&&(L[i]!=L[j])&&(L[j]!=L[k])){
                    ans++;
                }
            }
        }
    }
    
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
	var n, m int64
	fmt.Scan(&n)
	fmt.Scan(&m)

	var ans int64
	if n * 2 >= m {
		ans = m / 2
	} else {
		ans = (n * 2 + m) / 4
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) {
        cin >> A[i];
    }
    vll ans(N);
    ans[0] = 0;
    int mult = 1;
    rep(i, N) {
        ans[0] += ll(A[i]) * ll(mult);
        mult *= -1;
    }
    REP(i, 1, N) {
        ans[i] = 2 * ll(A[i - 1]) - ans[i - 1];
    }
    rep(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
    int n = 0;
    cin >> n;
    vector<int> hi;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        cin >> x;
        hi.push_back(x);
    }
    vector<int> mxC;
    mxC.push_back(0);
    mxC.push_back(abs(hi[1]-hi[0]));
    for (int i = 2; i < n; ++i) {
        mxC.push_back(min(mxC[i-1]+abs(hi[i]-hi[i-1]), mxC[i-2]+abs(hi[i]-hi[i-2])));
    }
    cout << mxC[n-1];
    return 0;
}


Measured memory_bytes: 4324
loop do
  n, r = gets.split.map(&:to_i)
  break if r == 0 && n == 0
  cards = n.downto(1).to_a
  r.times do
    p, c = gets.split.map(&:to_i)
    cs = cards.slice!(p-1, c)
    cards = cs + cards
  end
  puts cards[0]
end


Measured memory_bytes: 7304
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>s(H);
  for(int i=0;i<H;i++){
    cin>>s[i];
  }
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#'){cnt++;}
    }
  }

  vector<int> dx={0,0,-1,1};
  vector<int> dy={-1,1,0,0};

  vector<vector<int>>dist(H,vector<int>(W,-1));
  queue<pair<int,int>>q;
  q.push(make_pair(0,0));
  dist[0][0]=0;
  while(!q.empty()){
    auto p=q.front();q.pop();
    int y=p.first,x=p.second;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny>=H||ny<0||nx>=W||nx<0){continue;}
      if(s[ny][nx]=='#'){continue;}
      if(dist[ny][nx]!=-1){continue;}
      dist[ny][nx]=dist[y][x]+1;
      q.push(make_pair(ny,nx));
    }
  }
  if(dist[H-1][W-1]==-1){cout<<-1<<endl;}
  else{cout<<H*W-cnt-(dist[H-1][W-1]+1)<<endl;}
  return 0;  
}

Measured memory_bytes: 3608
using System;
using System.Linq;
class ans4B
{
    static void Main()
    {
        var r = double.Parse(Console.ReadLine());
        var p = 3.141592653589;
        Console.WriteLine(((r * r) * p).ToString("f6") + " " +  ((r * 2) * p).ToString("f6"));
    }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int a,b, c; cin>>a>>b>>c;
  if(a+b+c>=22){
    cout<<"bust"<<endl;
  }
  else{
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,a,b;
int ans;
int f(ll x){
	int res=1;
	ll y=10;
	while(x/y){
		res++;
		y*=10;
	}
	return res;
}
int main(){
	scanf("%lld",&n);
	a=sqrt(n);
	for(;n%a;a--);
	b=n/a;
	printf("%d\n",max(f(a),f(b)));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[100000];
	vint Asort;
	scan(N);
	rep(i,N){
		scan(A[i]);
		Asort.push_back(A[i]);
	}
	sort(Asort.begin(),Asort.end());
	int count=0;
	int nownum=0;
	int numcount=0;
	rep(i,N){
		if(Asort[i]==nownum){
			numcount++;
		}
		else{
			if(numcount%2==1) count++;
			nownum=Asort[i];
			numcount=1;
		}
	}
	if(numcount%2==1) count++;
	prin(count);

	return 0;
}


Measured memory_bytes: 1148