akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main(){
	var C string;

	fmt.Scan(&C);

	ans := succ(C);
	fmt.Println(ans);
}

// 文字列を反転して返す
func reverse(s string) string {
    ans := ""
    for i, _ := range s {
        ans += string(s[len(s)-i-1])
    }
    return string(ans)
}

func succ(s string) string {
    r := reverse(s)
    ans := ""
    carry := 1
    lastLetter := string(r[0])
    for i, _ := range r {
        lastLetter = string(r[i])
        a := lastLetter
        if carry == 1 {
            if lastLetter == "z" {
                a = "a"
                carry = 1
            } else if lastLetter == "Z" {
                a = "A"
                carry = 1
            } else if lastLetter == "9" {
                a = "0"
                carry = 1
            } else {
                if r[i] == 0 {
                    a = "1"
                } else {
                    a = string(r[i] + 1)
                    carry = 0
                }
            }
        }
        ans += a
    }
    if carry == 1 {
        if lastLetter == "9" {
            ans += "1"
        } else if lastLetter == "z" {
            ans += "a"
        } else if lastLetter == "Z" {
            ans += "A"
        }
    }
    return reverse(ans)
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,x,y;
	cin>>a>>b>>c>>d;
	if(a>b) x=b;
	else x=a;
	if(c>d) y=d;
	else y=c;
	cout<<x+y<<endl;
	return 0;
}

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

int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}

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

int main() {
	int N;
	cin >> N;
	cout << lcm(N,2) << endl;
	return 0;
}


Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
P = LIST()
Q = LIST()

for i, p in enumerate(permutations(range(1, N+1))):
	if list(p) == P:
		a = i
	if list(p) == Q:
		b = i
print(abs(a-b))


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
        if (a[i] % 2 ==0) {
            bool A = a[i] % 3 == 0;
            bool B = a[i] % 5 == 0;
            if (A || B) {
                continue;
            } 
            else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
        else {
            continue;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 1e5 + 5;
int dp[N], wt[N], v[N];
void solve(){
	int n, w;
	cin >> n >> w;
	fr(i, 1, n){
		cin >> wt[i] >> v[i];
	}
	fill(dp, dp + N, 1e18);
	dp[0] = 0;
	fr(i, 1, n){
		for(int j = N - 1; j >= 0; j--){
			if(j + v[i] < N)
				dp[j + v[i]] = min(dp[j + v[i]], dp[j] + wt[i]);
		}
	}
	int ans = 0;
	fr(i, 0, N - 1){
		if(dp[i] <= w)
			ans = i;
	}
	cout << ans;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 1024
#a=input()
#K = int(input())
#S = input()

import math

A, B, H, M = map(int, input().split(" "))
#a=[int(_) for _ in input().split(" ")]

h = 360 * H / 12 + 360 / 12 * M /60
m = 360 * M / 60

if abs(h-m) < 180:
    k = abs(h-m)
else:
    k = 360 - abs(h-m)

#print(k)
#print(A**2,B**2,2*A*B*math.cos(math.radians(k)))
ans = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(k)))

#print(a,b)
print(ans)


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

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	if (s.size() != a + b + 1) {
		cout << "No" << endl;
		return 0;
	}
	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < a + b + 1; i++) {
		if (i == a)
			continue;
		if (s[i]<'0' || s[i]>'9') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=105;
double a[N],res;int n;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%lf",&a[i]),res+=1.0/a[i];
	res=1.0/res;
	printf("%.10lf\n",res);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






template<unsigned long long m> class comb_perm{
private:
    int n;
    std::vector<long long> fact, fact_inv;
public:
    comb_perm(): n(0), fact(1), fact_inv(1){
        fact[0] = fact_inv[0] = 1;
    }
    comb_perm(int N): n(N), fact(N+1), fact_inv(N+1){
        fact[0] = fact[1] = fact_inv[0] = fact_inv[1] = 1;
        for(int i(2); i <= n; ++i) fact[i] = fact[i - 1] * i % m;
        for(int i(2); i <= n; ++i) fact_inv[i] = inv(fact[i]);
    }

    void resize(int N){
        fact.resize(N+1);
        fact_inv.resize(N+1);
        if(!n && N){
            fact[1] = fact_inv[1] = 1;
        }
        for(int i(std::max(2, n+1)); i <= N; ++i) fact[i] = fact[i - 1] * i % m;
        for(int i(std::max(2, n+1)); i <= N; ++i) fact_inv[i] = inv(fact[i], m);
        n = N;
    }

    long long power(long long a, unsigned long long b){
        long long ret(1);
        while(b){
            if(b & 1) ret = (ret * a) % m;
            a = (a * a) % m;
            b /= 2;
            if(ret < 0) ret += m;
            if(a < 0) a += m;
        }
        return ret;
    }

    long long inv(long long a){ // GCD(a, m) = 1
        return power(a, m-2);
    }

    long long permutation(int n, int r){
        if(n < r) return 0;
        if(n < 0 || r < 0) return 0;
        long long ret(fact[n]);
        ret = ret * fact_inv[n - r] % m;
        return ret;
    }

    long long combination(int n, int r){
        if(n < r) return 0;
        if(n < 0 || r < 0) return 0;
        long long ret(permutation(n, r));
        return ret * fact_inv[r] % m;
    }

    long long factorise(int a){
        return fact[a];
    }

    long long inv_factorise(int a){
        return fact_inv[a];
    }
};

int main(){
    int n, k; std::cin >> n >> k;
    comb_perm<MOD> cp(k+1);
    long long ans(0);
    for(int i(1); i <= k; ++i){
        int a(((k-i) % 2) ? -1 : 1);
        long long c(cp.combination(k, i));
        c *= cp.power(i, n);
        c %= MOD;
        ans += a*c;
        ans %= MOD;
        if(ans < 0) ans += MOD;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  //ll ans=0;
  cin >> n;
  double a=(ll)(n/2);

  double ans=1.0-a/n;


  cout<<ans<<setprecision(10)<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = input()
unique_S = list(set(list(S)))

sys.exit() if not (2 <= N <= 100) else ''
sys.exit() if len(S) != N else ''
sys.exit() if not S.islower() else ''

result = 0
for I in range(len(S)):
    count = 0
    for J in range(len(unique_S)):
        if ( unique_S[J] in S[0:I] ) and ( unique_S[J] in S[I:] ):
            count += 1
        if result < count:
            result = count

print(result)

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

using namespace std;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> p(N), q(N);
    for(int i=0; i<N; i++) {
        cin >> p[i];
        --p[i];
        q[p[i]] = i;
    }

    UnionFind uf(N);
    while(M--) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        uf.unite(x, y);
    }

    int ans = 0;
    for(int i=0; i<N; i++) {
        if(uf.find(i) == uf.find(q[i])) ++ans;
    }

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


Measured memory_bytes: 1408
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef pair<int, int> PI;
const double EPS = 1e-8;

int N, X, Y;

void input(P &tar){
  int x, y; cin >>x >>y;
  tar.real(x);
  tar.imag(y);
}

int dist2(P &a, P &b){
  return (a.real() - b.real()) * (a.real() - b.real()) + (a.imag() - b.imag()) * (a.imag() - b.imag());
}

int solve(P &c, vector<P> &v){
  priority_queue<PI, vector<PI>, greater<PI> > open;
  vector<int> closed(N, -1);
  REP(i, N) if(dist2(c, v[i]) <= 10 * 10) open.push(PI(0, i));
  int cnt = 0;
  while(!open.empty()){
    ++cnt;
    if(cnt > 1000 * 1000) return -1;
    int t = open.top().first, n = open.top().second; open.pop();
    if(t != 0 && closed[n] != -1 && closed[n] + Y >= t) continue;
    closed[n] = t + X;
    REP(i, N) if(i != n && dist2(v[n], v[i]) <= 50 * 50) open.push(PI(t + X, i));
  }
  int ans = 0;
  REP(i, N) ans = max(ans, closed[i]);
  return ans;
}


int main() {
  int T; cin >>T;
  while(T--){
    cin >>N >>X >>Y;
    P c;
    vector<P> v(N);
    input(c);
    REP(i, N) input(v[i]);
    int ans = solve(c, v);
    if(ans == -1) cout <<"You're always welcome!" <<endl;
    else cout <<ans <<endl;
  }
  return 0;
}

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

const int N=2e5+1;
int n,ar[N],ans,mn=INT_MAX;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ar[i];
    mn=min(mn,ar[i]);
    ans+=bool(mn>=ar[i]);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000

int N;
vector<double> A;
int main()
{

	cin >> N;
	A.resize(N);
    REP(i,N){
    	cin >> A[i];
    }
    int min = N;
    int ans = 0;
    REP(i,N){
    	if(A[i]<=min){
    		ans++;
    		min = A[i];
    	}
    }
    cout << ans;

//	cout << fixed << setprecision(0) <<  N > M ? "No" : "Yes";


}

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

void solve(){
  int n; cin >> n;
  int m = 1046527;
  string a, b;
  vector<string> ans(m, "-1");
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    if(a == "insert"){
      long long int x = 0, ten = 1, y, cnt = 0;
      for(int j = 0; j < b.size(); j++){
        x += (int)(b[j]) * ten;
        ten *= 10;
      }
      y = x % m;
      while(ans[y] != "-1"){
        y = (x % m + cnt * (1 + (x % (m - 1)))) % m;
        cnt++;
      }
      ans[y] = b;
    }
    else{
      long long int x = 0, ten = 1, y, cnt = 0;
      for(int j = 0; j < b.size(); j++){
        x += (int)(b[j]) * ten;
        ten *= 10;
      }
      y = x % m;
      bool ok = false;
      while(ans[y] != "-1"){
        if(ans[y] == b){
          cout << "yes\n";
          ok = true;
          break;
        }
        y = (x % m + cnt * (1 + (x % (m - 1)))) % m;
        cnt++;
      }
      if(ok == false) cout << "no\n";
    }
  }
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 37736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s[3]={"Sunny", "Cloudy", "Rainy"};
  string to;
  cin>>to;
  rep(i,3)if(to==s[i])cout<<s[(i+1)%3]<<endl;
  
  return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static int N = 0;
        static void Main(string[] args)
        {
            var a = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                a.Add(int.Parse(Console.ReadLine()));
            }

            var sum = 0;

            for (int i = 0; i < a.Count; i++)
            {
                if (a[i] % 10 == 0)
                {
                    sum += a[i];
                    a.RemoveAt(i);
                    i--;
                }
            }

            var min = 9;
            var min1Index = -1;
            for (int i = 0; i < a.Count; i++)
            {
                var num1 = a[i] % 10;
                if (num1 <= min)
                {
                    min = num1;
                    min1Index = i;
                }
            }

            if (min1Index != -1)
            {
                sum += a[min1Index];
                a.RemoveAt(min1Index);
            }

            while (a.Count > 0)
            {
                sum += a[0] + (10 - a[0] % 10);
                a.RemoveAt(0);
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
input()
xors = [int(num) for num in input().strip().split(' ')]

totXor = xors[0]

for i in range(1, len(xors)): totXor ^= xors[i]

result = [totXor^xor  for xor in xors]

ans = "";
for result in result:
    ans += str(result)+ " "

print(ans.strip())


Measured memory_bytes: 31420
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    cout << max(A1, max(A2, A3)) - min(A1, min(A2, A3)) << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
 
l = range(1,m+1)
point = 0
for v in itertools.combinations_with_replacement(l,n):
    p = 0
    for a,b,c,d in abcd:
        if v[b-1] - v[a-1] == c:
            p += d
    if p > point: point = p
print(point)

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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j]= f[k]; f[k] = f[l]; f[l] = t;
  }
};

bool eq ( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ ){
    if ( c1.f[i] != c2.f[i] ) return false;
  }
  return true;
}

bool equal ( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ ){
    for ( int j = 0; j < 4; j++ ){
      if ( eq(c1, c2) ) return true;
      c1.roll_z();
    }
    if ( i % 2 == 0 ) c1.roll_y();
    else c1.roll_x();
  }
  return false;
}

Cube C[100]; int n;

bool check(){
  for (int i = 0; i < n-1; i++ ){
    for ( int j = i + 1; j < n; j++ ){
      if ( equal(C[i], C[j]) ) return false;
    }
  }
  return true;
}

int main(){
  cin >> n;

  for (int j = 0; j < n; j++ ){
    for (int i = 0; i < 6; i++ ) cin >> C[j].f[i];
  }

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

  return 0;
}

Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int k = sc.nextInt();

        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < k; i++) {
            pw.print("ACL");
        }
        pw.println();

        pw.flush();
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32984
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define size(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using namespace std;


int N, X;
int m[110];


int main(){
	cin >> N >> X;
	rep(i, 0, N) cin >> m[i];

	sort(&m[0], &m[N]);
	int cnt = 0;
	rep(i, 0, N) X -= m[i];
	cnt += N;

	cnt += (X/m[0]);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


n = int(input())

GRAPH = {i:[] for i in range(1, n + 1)}
EDGES = []
for _ in range(n - 1):
    a, b = map(int, input().split())
    GRAPH[a].append(b)
    GRAPH[b].append(a)
    EDGES.append((a, b))

PREV = {1:0}
Q = [1]
while Q:
    now = Q.pop(0)
    for vertex in GRAPH[now]:
        if vertex == PREV[now]:
            continue
        next = vertex
        PREV[next] = now
        Q.append(next)

COLORS = {(0, 1):0}
Q = [1]
while Q:
    now = Q.pop(0)
    prev = PREV[now]
    a, b = min(now, prev), max(now, prev)
    used = COLORS[(a, b)]
    
    color = 1
    for vertex in GRAPH[now]:
        if vertex == prev:
            continue
        next = vertex
        a, b = min(now, next), max(now, next)
        if color == used:
            color += 1
            COLORS[(a, b)] = color
            color += 1
        else:
            COLORS[(a, b)] = color
            color += 1
        Q.append(next)

print(max(COLORS.values()))
for edge in EDGES:
    print(COLORS[edge])


Measured memory_bytes: 61968
#include<stdio.h>
#include<stdlib.h>
void fun(char *);
void fun(char *s)
{
    int i,k=0;
    char t[20];
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]=='1'||s[i]=='0')
        {
            t[k++]=s[i];
        }
        else
        {
            if(k>0)
            {
                k--;
            }
        }
    }
    if(k>0)
    {
        for(i=0;i<k;i++)
        {
            printf("%c",t[i]);
        }
    }
}
int main()
{
    char a[20];
    scanf("%s",a);
    fun(a);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// priority_queue
type intArray []int

func (h intArray) Len() int {
	return len(h)
}

func (h intArray) Less(i, j int) bool {
	return h[i] > h[j] // 小優先、大優先
}

func (h intArray) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intArray) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intArray) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()

	a := &intArray{}
	heap.Init(a)
	for i := 0; i < n; i++ {
		heap.Push(a, nextInt())
	}

	for i := 0; i < m; i++ {
		heap.Push(a, heap.Pop(a).(int)/2)
	}

	res := 0
	for i := 0; i < n; i++ {
		res += heap.Pop(a).(int)
	}
	fmt.Println(res)
}


Measured memory_bytes: 7552
n=int(input())
x=[int(i) for i in input().split()]

dist=abs(x[0])
for i in range(n-1):
  dist+=abs(x[i]-x[i+1])
dist+=abs(x[-1])

print(dist-abs(x[0])-abs(x[0]-x[1])+abs(x[1]))

for i in range(1,n-1):
  if x[i-1]<=x[i]<=x[i+1] or x[i+1]<=x[i]<=x[i-1]:
    print(dist)
  else:
    print(dist-abs(x[i-1]-x[i])-abs(x[i]-x[i+1])+abs(x[i-1]-x[i+1]))

print(dist-abs(x[-1])-abs(x[-1]-x[-2])+abs(x[-2]))

Measured memory_bytes: 13792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int k; cin >> k;
  string ans = "";
  REP(_, k) ans += "ACL";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { nextInt() }.sorted()
    val M = S.filter { it % 10 != 0 }
    var ans = S.sum()
    var n = 0
    while (ans % 10 == 0 && n < M.size) {
        ans -= M[n]
        n += 1
    }
    println(if (ans % 10 == 0) 0 else ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


Measured memory_bytes: 35856
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <map> 
#include <set>
#include <vector>
#include <list>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define ll long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int gcd(int a, int b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

void solve() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    int pos = S.find("LAVITSEF");

    S.replace(pos, 8, "");
    reverse(S.begin(), S.end());

    cout << S << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;

    solve();
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = []
b = []
ans = []
z = []

for i in range(n):
    t = list(map(int, input().split()))
    a.append(t)
for i in range(m):
    t = list(map(int, input().split()))
    b.append(t)

t = 0
for i in a:
    for x in range(l):
        for k in range(m):
            t += i[k]*b[k][x]            
        else:        
            z.append(t)
            t = 0
    else:
        ans.append(z)
        z =[]

for y in ans:
    print(*y)


Measured memory_bytes: 7052
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == 'AC': ac += 1
    elif s == 'WA': wa += 1
    elif s == 'TLE': tle += 1
    elif s == 'RE': re += 1

print('AC', 'x', ac)
print('WA', 'x', wa)
print('TLE', 'x', tle)
print('RE', 'x', re)


Measured memory_bytes: 9196
while 1:
    n, m = list(map(int, input().split()))
    if n == 0:break
    n_v = [int(input()) for i in range(n)]
    m_v = [int(input()) for i in range(m)]

    n_s = sum(n_v)
    m_s = sum(m_v)

    swap_min = 99999999

    x = n_s - m_s

    res = '-1'
    for nv in n_v:
        for mv in m_v:
            
            if x == 2 * (nv - mv) and swap_min > nv + mv:
                swap_min = nv + mv
                res = '%d %d' % (nv,mv)
    print(res)

Measured memory_bytes: 6720
s=input()+"R"
n=len(s)-1
ans=[0]*n
lenr=1
lenl=0
l_sta=-1
for i in range(1,n+1):
  if s[i-1]=="R" and s[i]=="R":
    lenr+=1
  if s[i-1]=="R" and s[i]=="L":
    ans[i-1]+=(lenr+1)//2
    ans[i]+=lenr//2
    l_sta=i
    lenr=0
    lenl=1
  if s[i-1]=="L" and s[i]=="L":
    lenl+=1
  if s[i-1]=="L" and s[i]=="R":
    ans[l_sta]+=(lenl+1)//2
    ans[l_sta-1]+=lenl//2
    lenr=1
ans_=[]    
for i in range(n):
  ans_.append(str(ans[i]))
print(" ".join(ans_))
  

Measured memory_bytes: 49008
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>

struct POINT_INT32 {
  int x;
  int y;
};

double get_distance(const POINT_INT32& pt1, const POINT_INT32& pt2) {
  return std::sqrt(std::pow(pt1.x - pt2.x, 2) + std::pow(pt1.y - pt2.y, 2));
}

int main(void) {
  int n;
  std::vector<POINT_INT32> pts;

  std::cin >> n;
  for (int i = 0; i < n; i++) {
    POINT_INT32 pt;
    std::cin >> pt.x >> pt.y;
    pts.push_back(pt);
  }

  //double sum = 0.0;
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      //sum += get_distance(pts.at(i), pts.at(j));
      ans += get_distance(pts.at(i), pts.at(j)) * 2 / n;
    }
  }

  //std::cout << 2 * sum / n << std::endl;
  std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <set>
using namespace std;

#define MP make_pair

bool flag[53][53][4];

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

int main(){
	int n,x0,y0,t;
	cin >> n >> x0 >> y0 >> t;
	x0++;
	y0++;
	for(int k=0;k<n;k++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a++;b++;c++;d++;
		if(a==c){
			if(b>d)swap(b,d);
			for(int i=b;i<d;i++){
				flag[a][i][0] = 1;
			}
			for(int i=d;i>b;i--){
				flag[a][i][2] = 1;
			}
		}
		if(b==d){
			if(a>c)swap(a,c);
			for(int i=a;i<c;i++){
				flag[i][b][1] = 1;
			}
			for(int i=c;i>a;i--){
				flag[i][b][3] = 1;
			}
		}
	}
	map<int,int> mp;
	int s = 0;
	for(int i=0;i<t;i++){
		int a;
		cin >> a;
		char b;
		cin >> b;
		s += a;
		if(b=='N'){
			mp[s] = 0;
		}else if(b=='E'){
			mp[s] = 1;
		}else if(b=='S'){
			mp[s] = 2;
		}else{
			mp[s] = 3;
		}
	}
	queue<pair<pair<int,int>,pair<int,int> > >q;
	map<pair<pair<int,int>,pair<int,int> >,bool> m;
	if(flag[x0][y0][0]==1){
		q.push(MP(MP(x0,y0),MP(0,0)));
	}
	if(flag[x0][y0][1]==1){
		q.push(MP(MP(x0,y0),MP(0,1)));
	}
	if(flag[x0][y0][2]==1){
		q.push(MP(MP(x0,y0),MP(0,2)));
	}
	if(flag[x0][y0][3]==1){
		q.push(MP(MP(x0,y0),MP(0,3)));
	}
	set<pair<int,int> > ans;
	while(1){
		auto x = q.front();
		q.pop();
		int a,b,c,d;
		a = x.first.first;
		b = x.first.second;
		c = x.second.first;
		d = x.second.second;
		//cout << a <<" " << b << " " <<c << " " << d << endl;
		if(c>s)break;
		if(c==s){
			ans.insert(MP(a-1,b-1));
		}
		if(mp.find(c+1)!=mp.end()){
			if(d==mp[c+1]){
				for(int i=0;i<4;i++){
					if(i!=d&&(i+4-d)%2==0)continue;
					if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
						m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
						q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
					}
				}
			}else{
				if((d+4-mp[c+1])%2!=0&&flag[a+dx[d]][b+dy[d]][mp[c+1]]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1])));
				}
			}
		}else{
			for(int i=0;i<4;i++){
				if(i!=d&&(i+4-d)%2==0)continue;
				if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
				}
			}
		}
	}
	for(auto x:ans){
		cout << x.first << " " << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 52964
let [| N; K |] = stdin.ReadLine().Split() |> Array.map int
let p = stdin.ReadLine().Split() |> Array.map int

let m =
    p
    |> Array.take K
    |> Array.sum

let rec resolver m t n =
    match n with
    | n when n = N - K + 1 -> ((m + K) |> float) / 2.0
    | _ ->
        let s = t + p.[n + K - 1] - p.[n - 1]
        resolver (max s m) s (n + 1)

resolver m m 1 |> stdout.WriteLine


Measured memory_bytes: 30044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+5,mod=1e9+7;
int dp[105][N];
int num[N];
char s[N];
int dfs(int,int,bool);
int D;
int cal();
int main(){
    scanf("%s%d",s+1,&D);
    int ans=cal();
    ans--;
    ans=(ans%mod+mod)%mod;
    printf("%d",ans);
}
int cal(){
    int n=strlen(s+1);
    for(int i=1;i<=n;i++) num[i]=s[i]-'0';
    reverse(num+1,num+n+1);
    memset(dp,-1,sizeof(dp));
    return dfs(n,0,1);
}
int dfs(int pos,int sum,bool lim){
    if(pos==0) return sum==0;
    if(!lim&&dp[sum][pos]!=-1) return dp[sum][pos];
    int t=lim?num[pos]:9;
    int re=0;
    for(int i=0;i<=t;i++){
        re+=dfs(pos-1,(sum+i)%D,lim&&(i==t));
        re%=mod;
    }
    if(!lim) dp[sum][pos]=re;
    return re;
}



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

struct Plant {
    string name;
    int p;
    int a;
    int b;
    int c;
    int d;
    int e;
    int f;
    int s;
    int m;

    int income;
    double efficiency;

    void va() {
        income = f * m * s - p;
        int sumOfTime = a + b + c + (d + e) * m;
        efficiency = 1.0 * income / sumOfTime;
    }

    bool operator< (const Plant & o) const {
        if (abs(efficiency - o.efficiency) < DBL_EPSILON) {
            return name > o.name;
        }
        else {
            return efficiency < o.efficiency;
        }
    }
};

int main() {
    int n;
    while (cin >> n, n) {
        vector <Plant> p(n);
        rep (i, n) {
            cin >> p[i].name >> p[i].p >> p[i].a
                >> p[i].b >> p[i].c >> p[i].d
                >> p[i].e >> p[i].f >> p[i].s
                >> p[i].m;
            p[i].va();
        }

        sort(p.rbegin(), p.rend());
        rep (i, n) cout << p[i].name << endl;
        cout << "#" << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
int main(){
    queue<P> que;
    queue<P> ans;
    string str;
    int t;
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>str>>t;
        que.push(make_pair(str,t));
    }
    int time=0;
    while(!que.empty()){
        P p=que.front();
        que.pop();
        if(p.second>q){
            p.second-=q;
            time+=q;
            que.push(make_pair(p.first,p.second));
        }
        else if(p.second==q){
            time+=q;
            ans.push(make_pair(p.first,time));
        }
        else{
            time+=p.second;
            ans.push(make_pair(p.first,time));
        }
    }
    while(!ans.empty()){
        P p=ans.front();
        ans.pop();
        cout<<p.first<<" "<<p.second<<endl;
    }
    
    return 0;
}





Measured memory_bytes: 6108
#include<stdio.h>
using namespace std;

int f_max(int,int);
int f_min(int,int);

int main(){
  int n,tmp;
  int min =  1000000;
  int max = -1000000;
  long long int sum=0L;
  scanf("%d",&n);
  for (int i=0;i<n;i++){
    scanf("%d",&tmp);
    sum+=tmp;
    min=f_min(min,tmp);
    max=f_max(max,tmp);
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}

int f_max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int f_min(int a,int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}


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

int main()
{
    int A,B;
 cin>>A>>B;
 int M=max(A,B);
 int N=min(A,B);
 for(int i=0;i<M;i++)
 {
     cout<<N;
 }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N,X,m[100],i,count=0,min=1001;
  scanf("%d %d",&N,&X);
  for(i=0;i<N;i++){
    scanf("%d",&m[i]);
    X -= m[i];
    count++;
    if(m[i] < min){
      min = m[i];
    }
  }
  count += X/min;
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1708
import itertools
n = int(input())
nagoya = [3,5,7]
i = 1
if n < 357:
    print(0)
    exit()
ans = 0
while(i < 99):
    current = list(itertools.product(nagoya,repeat=i))
    for j in range(len(current)):
        h = int("".join(map(str,(list(current[j])))))
        if len(set(str(h))) == 3:
            if n < h:
                print(ans)
                exit()
            else:
                ans += 1
    i += 1

Measured memory_bytes: 13968
#include <stdio.h>
#include <map>
#include <bits/stdc++.h>

template <typename T> inline T min(const T &x, const T &y) { return x < y ? x : y; }
template <typename T> inline T max(const T &x, const T &y) { return x > y ? x : y; }
template <typename T> inline bool cmin(T &x, const T &y) { if (x > y) { x = y; return 1; } return 0; }
template <typename T> inline bool cmax(T &x, const T &y) { if (x < y) { x = y; return 1; } return 0; }
typedef long long ll;
typedef std ::pair<std ::pair<int, int>,  std ::pair<int, int> > pi;
#define mp std::make_pair

int n;
std ::map<pi, int> m;

int main() {
	scanf("%d", &n);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		char s[12]; scanf("%s", s);
		int hash[26]; memset(hash, 0, sizeof(hash));
		for (int j = 0; j < 10; ++j) ++hash[s[j] - 'a'];
		int ji = 1, t1 = 0, t2 = 0, t3 = 0, t4 = 0;
		for (int j = 0; j < 7; ++j) t1 += ji * hash[j], ji *= 11;
		for (int j = 7; j < 14; ++j) t2 += ji * hash[j], ji *= 11;
		for (int j = 14; j < 21; ++j) t3 += ji * hash[j], ji *= 11;
		for (int j = 21; j <= 26; ++j) t4 += ji * hash[j], ji *= 11;
		pi tmp = mp(mp(t1, t2), mp(t3, t4));
		ans += m[tmp];
		++m[tmp];
	}
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 6528
import Text.Printf

op s =
  case s of
    "+" -> (+)
    "-" -> (-)
    "/" -> div
    "*" -> (*)

main = do
  s <- getLine
  let [x,b,y] = words $ s
  let a = read x :: Int
  let c = read y :: Int
  if b == "?" then return ()
  else do
    putStrLn $ show $ (op b) a c
    main

Measured memory_bytes: 4044
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  int i,n;
  double sum = 0;
  double a,average;
  while(1){
    sum = 0;
    int s[1001]={};
    average = 0;
    cin>>n;
    if(n == 0){break;}
  for(i = 0;i < n;i++){
    cin>>s[i];
    sum += s[i];
  }
  average = sum/(double)n;
  sum = 0;
  for(i = 0;i < n;i++){
    sum += pow(((double)s[i]-average),2.0);
  }
  a = sqrt(sum/(double)n);
  cout<<fixed<<setprecision(4)<<a<<endl;
}
  return 0;
}

Measured memory_bytes: 3264
a,b,c=map(int,input().split())
list=[]
if(a==b):
    print(a)
if(b-a<c):
    c=b-a
for i in range(c):
    list.append(a+i)
    list.append(b-i)
list=sorted(set(list))
for j in range(len(list)):
    print(list[j])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k)cout<<s;
    else
    {
            for(int i=0;i<k;i++)cout<<s[i];
            cout<<"...";
    }

}


Measured memory_bytes: 3620
l, r = map(int, input().split())

if r - l >= 2019:
    ans = 0
else:
    ans = 2019
    flag = False
    for i in range(l, r):
        for j in range(i+1, r+1):
            m = (i * j) % 2019
            ans = min(ans, m)
            if ans == 0:
                flag = True
                break
        if flag:
            break

print(ans)

Measured memory_bytes: 39664
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 210000;

int dp[N][5];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	string s;
	cin >> s;
	for (int i = 1; i <= 4 && i <= s.size(); ++i)
		dp[i][i] = 1;
	for (int i = 1; i < s.size(); ++i)
		for (int j = 1; j <= 4 && i + j <= s.size(); ++j) {
			for (int k = 1; k <= 4 && k <= i; ++k) {
				if (dp[i][k] != 0) {
					if (s.substr(i - k, k) != s.substr(i, j))
						dp[i + j][j] = max(dp[i + j][j], dp[i][k] + 1);
				}
			}
		}
	int ans = 0;
	for (int i = 1; i <= 4; ++i)
		ans = max(ans, dp[s.size()][i]);
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 4628
n = int(input())
d = {}
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s not in d:
        d[s] = [[p, i+1]]
    else:
        d[s] += [[p, i+1]]

for key in sorted(d.keys()):
    for dk in sorted(d[key], reverse=True):
        print(dk[1])

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

int main() {
  int n,d; cin>>n>>d;
  int cnt=0;
  vector<vector<int>> x(n,vector<int>(d));
  for(int i=0;i<n;i++) for(int j=0;j<d;j++) cin>>x[i][j];
  for(int i=0;i<n;i++) {
    for(int j=i;j<n;j++) {
      int sum=0;
      for(int k=0;k<d;k++) {
        sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(int l=1;l*l<=sum;l++) {
        if(l*l==sum) cnt++;
      }
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3584
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = A[-1]
flag = 0
for i in range(N-2,-1,-1):
    if A[i]==A[i+1] or A[i]>A[i+1]:
        cnt += A[i]
    elif A[i] == A[i+1]-1:
        continue
    else:
        flag = 1
        break
if A[0]!=0:
    flag = 1
if flag==0:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 87680
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
	
	int num;
	int l;
	vector<int> val;
	int ans;
	
	scanf("%d", &num);
	for(int i=0; i<num; i++){
		scanf("%d", &l);
		val.push_back(l);
	}
	
	sort(val.begin(), val.end());	
	val[val.size()-1] /= 2;
	
	printf("%d\n", accumulate(val.begin(), val.end(), 0));
	
	return 0;
	
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=list(map(int,input()))
sp_list=[]
sum=0
sum_0=0
for i in range(n):
  if s[i]==1:
    sum+=1
    if sum_0>0:
      sp_list.append(sum_0)
    sum_0=0
    if i==(n-1):
      sp_list.append(sum)
  else:
    if i==0:
      sp_list.append(0)
    if i>0 and sum>0:
      sp_list.append(sum)
    sum_0+=1
    sum=0
    if i==(n-1):
      sp_list.append(sum_0)
      sp_list.append(0)
sum_list=[0]
sum=0
for i in range(len(sp_list)):
  sum+=sp_list[i]
  sum_list.append(sum)
length=min(k,len(sum_list))
if 2*k+1>=len(sum_list):
  print(sum_list[-1])
else:
  temp=0
  for i in range((len(sum_list)-2*k)//2):
    if temp<(sum_list[2*i+2*k+1]-sum_list[2*i]):
      temp=(sum_list[2*i+2*k+1]-sum_list[i*2])
  print(temp)

Measured memory_bytes: 8616
#include<bits/stdc++.h>
#define rg register
using namespace std;
const int mod=1e9+7;
#define _ 2001
int n, k, f[_][_], sum[_*_], inv[_*_];
int qp(int x, int y){
	int ans=1;
	while(y){
		if(y&1)ans=1ll*ans*x%mod;
		x=1ll*x*x%mod, y>>=1;
	}return ans;
}
int C(int m, int r){return 1ll*sum[m]*inv[r]%mod*inv[m-r]%mod;}
int main(){
	scanf("%d%d", &n, &k);
	if(k==1){puts("1"); return 0;}
	inv[0]=inv[1]=sum[0]=sum[1]=1;
	for(rg int i=2; i<=n*k; ++i)
		sum[i]=1ll*sum[i-1]*i%mod, inv[i]=qp(sum[i], mod-2);
	f[0][0]=1;
	for(int i=1; i<=n; ++i)
		for(int j=0; j<=i; ++j){
			f[i][j]=f[i-1][j];
			if(j)(f[i][j]+=1ll*C((n-j+1)*(k-1)+n-i-1, k-2)*f[i][j-1]%mod)%=mod;
		}
	for(int i=2; i<=n; ++i)
		f[n][n]=1ll*f[n][n]*i%mod;
	printf("%d", f[n][n]);
}


Measured memory_bytes: 47104
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, K;
   cin >> N >> K;
   int ans = 0;
   int tmp;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      ans += min(K - tmp, tmp) * 2;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args :Array<String>){
    val cin = Scanner(System.`in`)
    val data = mutableListOf<Long>()
    var n :Int = cin.nextInt()
    
    while(n > 0){
	data.add(cin.nextLong())
	n--
    }

    data.sort()
    println("${data.min()} ${data.max()} ${data.sum()}")
}




Measured memory_bytes: 43436
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
			int i = 1;
			while (true) {
            // 入力されるxを定義
            int x = scanner.nextInt();
            if (x == 0) {
            	break;
            }
            System.out.println("Case " + i + ": " + x);
            i++;
			}
	}
}



Measured memory_bytes: 40892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		if(Math.abs(a-c)<=d || Math.abs(a-b)<=d && Math.abs(b-c)<=d ) System.out.println("Yes"); 
		else System.out.println("No");
	}

}


Measured memory_bytes: 26972
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
ll s[200005];
ll p[200005];
int main()
{
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    for (int i = 1; i <= n; i++)
    {
        s[i] = p[i] + s[i - 1];
    }
    ll maxx = 0;
    for (int i = k; i <= n; i++)
        maxx = max(maxx, s[i] - s[i - k]);
    printf("%.12lf\n", (double)(maxx + k) / 2);
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: i64,
    }

    let mut ans = 0;

    for x in 1..n + 1 {
        if x.to_string().len() % 2 != 0 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352