akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
  int N,K,H;
  cin>>N>>K;
  string S;
  cin>>S;
  H = N+2*K+2;
  vector <int> v(H);
  for (int i = 0; i < H; i++) v[i] = N;
  v[0] = 0;
  int j = 1;
  for (int i = 1; i < N; i++) {
    if (S[i] != S[i-1])  {
      v[j] = i;
      j++;
    }
  }
  int ans;
  ans = 0;
  for (int i = 0; i < j; i++) {
    if (S[v[i]]=='0') ans = max(v[i+2*K]-v[i],ans);
    else if (S[v[i]]=='1') ans = max(v[i+2*K+1]-v[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr ll INF=1000000000000000000;
#define pb push_back
struct edge{int to,silver;ll cost;};
#define PP pair<ll,P>
int n,m,s,c[50];
ll d[50];
ll dist[50][2501];
vector<edge>v[50];
void dijkstra(){
    rep(i,50){
        rep(j,2501){
            dist[i][j]=INF;
        }
    }
    priority_queue<PP,vector<PP>,greater<PP>>q;
    q.push({0,{0,s}});
    dist[0][s]=0;
    while(!q.empty()){
        PP p=q.top();
        q.pop();
        if(dist[p.se.fi][p.se.se]!=p.fi)continue;
        for(int i=0;p.se.se+c[p.se.fi]*i<=2500;i++){
            for(edge e:v[p.se.fi]){
                if(p.se.se+c[p.se.fi]*i-e.silver<0)continue;
                if(dist[e.to][p.se.se+c[p.se.fi]*i-e.silver]>p.fi+d[p.se.fi]*i+e.cost){
                    dist[e.to][p.se.se+c[p.se.fi]*i-e.silver]=p.fi+d[p.se.fi]*i+e.cost;
                    q.push({dist[e.to][p.se.se+c[p.se.fi]*i-e.silver],{e.to,p.se.se+c[p.se.fi]*i-e.silver}});
                }
            }
        }
    }
}
int main(){
    cin>>n>>m>>s;
    chmin(s,2500);
    rep(i,m){
        int u,w,a;
        ll b;
        cin>>u>>w>>a>>b;
        u--,w--;
        v[u].pb({w,a,b});
        v[w].pb({u,a,b});
    }
    rep(i,n)cin>>c[i]>>d[i];
    dijkstra();
    rep(i,n){
        if(i){
            ll ans=INF;
            rep(j,2501)chmin(ans,dist[i][j]);
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 135228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  string s; cin >> s;
  ll sizeofs = s.size();
  ll count = 0;
  bool flag = true;
  vector<ll> ans(sizeofs,0);
  ll tmp = 0;
  
  rep(i,sizeofs) {
    char current = s.at(i);
    
    if(flag) {
      if(current == 'L') {
        //cout << i << ' ' << count << endl;
        ans.at(i - 1) += count / 2;
        ans.at(i) += count / 2;
        if(count % 2 != 0) ans.at(i - 1)++;
        count = 0;
        flag = false;
        tmp = i;
        if(i == sizeofs - 1) {
          ans.at(i)++;
        }
      }
    }
    else if(!flag) {
      if(current == 'R') {
        //cout << i << ' ' << count << endl;
        ans.at(tmp) += count / 2;
        ans.at(tmp - 1) += count / 2;
        if(count % 2 != 0) ans.at(tmp)++;
        count = 0;
        flag = true;
      }
      else if(i == sizeofs - 1) {
        count++;
        //cout << i << ' ' << count << endl;
        ans.at(tmp) += count / 2;
        ans.at(tmp - 1) += count / 2;
        if(count % 2 != 0) ans.at(tmp)++;
      }
      //cout << i << endl;
    }

    count++;
  }

  rep(i,sizeofs) cout << ans.at(i) << ' ';
  cout << endl;
}


Measured memory_bytes: 4288
n = int(input())
tarray = input().split(' ')
array = [int(i) for i in tarray]

cnt = 0
for i in range(1,n+1):
	if i != array[i-1]:
		cnt += 1

if (cnt == 0) or (cnt == 2):
  	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,k;
   cin >> a >> b >> c >> k;
   long long ans =0;
   if(a <= k){
       ans += a;
       k -= a;
   }
   else {
       ans += k;
       cout << ans << endl;
       return 0;
   }
   if(b <= k){
       
       k -= b;
   }
   else{
       cout << ans << endl;
       return 0; 
   }
   ans -= k;
   cout << ans << endl;
   
   
}

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

template<typename ... Ts> void read(Ts& ...vs){(std::cin >> ... >> vs);}
template<typename T> void write(const T& v){std::cout << v << std::endl;}

int main()
{
    std::int64_t N, K;
    read(N, K);

    write(std::min(N % K, std::abs(N % K - K)));

    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int N;
int edge[51][51];
int M;
int u[20];
int v[20];

vector<int> T[51];
vector<int> th[20];

void input()
{
	int a, b;

	cin >> N;
	rep(i, N - 1) {
		cin >> a >> b;
		edge[a][b] = i;
		edge[b][a] = i;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	cin >> M;
	rep(i, M) cin >> u[i] >> v[i];
}

bool visited[51];
int cost[51];

void set_th(int index)
{
	int src = u[index];
	int dest = v[index];
	queue<int> q;

	repc(i, 1, N) visited[i] = false;
	
	cost[src] = 0;
	visited[src] = true;
	q.push(src);

	while (!q.empty()) {
		int current = q.front(); q.pop();
		int size = T[current].size();

		rep(i, size) {
			int next = T[current][i];

			if (!visited[next]) {
				cost[next] = cost[current] + 1;
				visited[next] = true;
				q.push(next);
			}
		}
	}

	repc(i, 1, N) visited[i] = false;
	visited[dest] = true;
	q.push(dest);

	while (!q.empty()) {
		int current = q.front(); q.pop();
		int size = T[current].size();

		rep(i, size) {
			int next = T[current][i];

			if (cost[next] == cost[current] - 1) {
				th[index].push_back(edge[current][next]);
				q.push(next);
			}
		}
	}
}

bool sel[50];

ll solve()
{
	ll ans = 1;

	rep(i, N - 1) ans *= 2;
	rep(i, M) set_th(i);

	int LOOP = 1;
	int END = (1 << M);

	while (LOOP < END) {
		int unused = 0;
		int cnt = 0;
		int id = 0;
		ll adjust = 1;

		rep(i, N - 1) sel[i] = false;

		rep(i, M) {
			if (((LOOP >> id) & 1) == 1) {
				int size = th[id].size();
				cnt++;

				rep(j, size) {
					sel[th[id][j]] = true;
				}
			}
			id++;
		}

		rep(i, N - 1) if (sel[i]) unused++;

		rep(i, N - 1 - unused) adjust *= 2;

		if (cnt % 2 == 1) ans -= adjust;
		else ans += adjust;

		LOOP++;
	}

	return ans;
}

int main()
{
	input();

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
prev = -1
ans = 0
for i in range(n):
  manzoku = B[A[i]-1]
  if prev+1 == A[i]:
    manzoku += C[prev-1]
  prev = A[i]
  ans += manzoku
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n+1), suf = {0};
    for (int q = 0; q < n+1; q++){
        cin >> a[q];
    }
    for (int q = n; q > -1; q--){
        suf.push_back(suf.back()+a[q]);
    }
    reverse(suf.begin(), suf.end());
    int sum1 = 0, now = 1;
    for (int q = 0; q < n+1; q++){
        sum1 += now;
        if (now < a[q]){
            cout << -1 << endl;
            return 0;
        }
        now = min(2*now-2*a[q], suf[q+1]);
    }
    cout << sum1 << endl;
    return 0;
}


Measured memory_bytes: 5064
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextUint64() uint64 {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.ParseUint(sc.Text(), 0, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	h := nextUint64()
	count := 1
	ans := 0
	for h > 0 {
		h = h / 2
		ans += count
		count *= 2
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
typedef long long ll;

int main() {
    int n;
    while(~scanf("%d", &n)) {
        if(n == 1) {
            printf("Hello World\n");
        } else {
            int a, b;
            scanf("%d %d", &a, &b);
            printf("%d\n", a + b);
        }
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding : utf-8 -*-

def gcd(num_a, num_b):
    if num_b == 0:
        return num_a
    elif num_a == 0:
        return num_b

    if num_a < num_b:
        return gcd(num_a, num_b % num_a)
    else:
        return gcd(num_b, num_a % num_b)

num_a, num_b = [int(x) for i, x in enumerate(input().split()) if i < 2]
print(gcd(num_a, num_b))

Measured memory_bytes: 7692
#include<stdio.h>
int main()
{
    int a[3005];
    int n;
    scanf("%d",&n);
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        ans += (a[i] - 1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n, m = map(int, input().split())

cnt_ac = 0
cnt_wa = 0
ac_set = set()
wa_dict = dict()

for i in range(m):
    str_list = input().split()
    p = int(str_list[0])
    s = str_list[1]
    if p not in ac_set:
        if s == 'AC':
            cnt_ac = cnt_ac + 1
            if p in wa_dict:
                cnt_wa = cnt_wa + wa_dict[p]
            ac_set.add(p)
        else:
            if p in wa_dict:
                wa_dict[p] = wa_dict[p] + 1
            else:
                wa_dict[p] = 1

print(str(cnt_ac) + ' ' + str(cnt_wa))


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

vector<unsigned long long> next_p_mod(unsigned N, long long mod) { //next_permutation
  vector<unsigned long long> Next_p(N);
  unsigned long long Next_p_buff = 1;
  for (int i = 0; i < N; i++)
  {
    Next_p_buff *= (i + 1) % mod;
    Next_p.at(i) = Next_p_buff % mod;
  }
  return Next_p;
}
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod) {
   unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v,unsigned long long mod) {
  //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
    }
  }
}
// a^{-1} mod を計算する
unsigned long long modinv(unsigned long long a, unsigned long long mod) {
    return modpow(a, mod - 2, mod);
}


// modinv
/*void modinv(unsigned long long N, unsigned long long mod,unsigned long long *inv) {
 // unsigned long long inv[N] ;
  for (unsigned long long i = 1; i < N; i++) {
    inv[i] = (i == 1) ? 1 : (mod - (mod / i) * inv[mod % i] % mod);
    assert(inv[i] * i % mod == 1);
  }
  //return 0;
}*/

int main() {
  unsigned long long N, A,B;
  unsigned long long mod = 1000000000 + 7;
  cin >> N >> A>>B;
  unsigned long long ca,cb;
  ca=A*N;
  cb=B;
  if(ca>cb){
    cout<<cb<<endl;
  }else{
    cout<<ca<<endl;
  } 
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

const int maxn = 2e5 + 5;
long long sum[maxn],a[maxn],vis[maxn];

int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= n;i++){
		sum[i] = sum[i - 1] + a[i];
	}
	for(int i = 1;i <= n - 1;i++){
		vis[i] = abs(sum[n] - sum[i] - sum[i]);
	}
	sort(vis + 1,vis + n);
	cout << vis[1];
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define MAX 1000005
#define MAX_NIGHTS 301
#define MOD 998244353
int main()
{
    long long int H,W;
    scanf("%lld %lld",&H,&W);
    long long int ans=(H*W)/2;
    if(!(H%2==0||W%2==0)) ans++;
    if(H==1||W==1)
    {
        printf("1");
        return 0;
    }
    printf("%lld",ans);
    return 0;
}


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

int main()
{
    ll n, k , ans = 0;
    cin>>n>>k;
    if(n % k == 0)
        cout<<0;
    else
    {
        if(n < k )
        {
            ans = min(n , abs(n-k));
        }
        else
        {
            ll tmp = n / k;
            n = n - (tmp * k);
            ans = min(n , abs(n - k));
        }
        cout<<ans;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(a) int((a).size())
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
using namespace std;
using LL = long long;
using PII = pair<int, int>;
LL inv(LL x, LL m) { return x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }


int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
        if (1LL * i * m % n == 0) {
            int j = 1LL * i * m / n;
            if (j < m && s[i] != t[j]) {
                return !printf("-1\n");
            }
        }
    }
    cout << 1LL * n* m / __gcd(n, m) << endl;
    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int q; cin >> q;
    deque<int> a;
    REP(i, q){
        int op; cin >> op;
        int d, x;
        switch(op){
            case 0:
                cin >> d >> x;
                if(!d) a.push_front(x);
                else a.push_back(x);
                break;
            case 1:
                cin >> d;
                cout << a[d] << "\n";
                break;
            case 2:
                cin >> d;
                if(!d) a.pop_front();
                else a.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 4624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s, t;
  cin >> s >> t;

  ll cnt = 0;
  for (ll i = 0; i <ll(s.size())-ll(t.size())+1; i++) {
    ll tmp = 0;
    for(ll j = 0; j < ll(t.size()); j++) {
      if (t[j] == s[i+j]) tmp++;
    }
    chmax(cnt, tmp);
  }

  cout << ll(t.size()) - cnt << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int N, A[10010];

int min() {
  int candMin = A[0];
  for (int i=0;i<N;i++) {
    if (candMin > A[i])
      candMin = A[i];
  }
  return candMin;
}

int max() {
  int candMax = A[0];
  for (int i=0;i<N;i++) {
    if (candMax < A[i])
      candMax = A[i];
  }
  return candMax;
}

long sum() {
  long s = 0;
  for (int i=0;i<N;i++) {
    s += A[i];
  }
  return s;
}

int main() {
  cin >> N;
  for (int i=0;i<N;i++)
    cin >> A[i];
  cout << min() << " " << max() << " " << sum() << endl;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 100005 ;
using namespace std ;

int n, m, a[N] ;
ll bit[2][N] ;

void put(int c, int x, int y) {
    for ( ; x <= m ; x += x & (- x)) {
        bit[c][x] += y ;
    }
}

ll get(int c, int x) {
    ll ret = 0 ;
    for ( ; x ; x -= x & (- x)) {
        ret += bit[c][x] ;
    }
    return ret ;
}

void solve(int l, int r, int ave) {
    put(0, l, 1) ;
    put(1, l, ave) ;
    put(0, r + 1, - 1) ;
    put(1, r + 1, - ave) ;
}

int main() {
    scanf("%d%d", &n, &m) ;
    rep(i, 1, n) {
        scanf("%d", &a[i]) ;
    }
    ll ans = 0 ;
    rep(i, 1, n - 1) {
        int x = a[i], y = a[i + 1] ;
        if (x == y) continue ;
        if (x < y) {
            ans += y - x ;
            solve(x + 1, y, - x - 1) ;
        } else {
            ans += m - x + y ;
            if (x < m) {
                solve(x + 1, m, - x - 1) ;
            }
            solve(1, y, m - x - 1) ;
        }
    }
    ll mx = 0 ;
    rep(i, 1, m) {
        mx = max(mx, get(0, i) * i + get(1, i)) ;
    }
    printf("%lld\n", ans - mx) ;
    return 0 ; 
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	string sd,t;
	cin >> sd >> t;
	vector<string> s;
	for(int i=0;i<sd.length()-t.length()+1;i++){
		bool tmp=true;
		for(int j=0;j<t.length();j++){
			if(!(sd[i+j]==t[j] || sd[i+j]=='?')){
				tmp=false;
				break;
			}
		}
		if(tmp){
			string ss=sd;
			for(int k=0;k<sd.length();k++){
				if(i<=k && k<i+t.length()) ss[k]=t[k-i];
				else if(sd[k]=='?') ss[k]='a';
				else ss[k]=sd[k];
			}
			s.push_back(ss);
		}
	}
	if(s.size()==0) cout << "UNRESTORABLE" << endl;
	else{
		sort(s.begin(),s.end());
		cout << s[0] << endl;
	}
}


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

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

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

  int age;
  cin >> age;

  if (age == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }

  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	num, _ := strconv.Atoi(s)

	var ret, i int
	for i = 1; i <= num; i++ {
		if i%3 == 0 {
			continue
		}
		if i%5 == 0 {
			continue
		}
		ret = ret + i
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1820
#include<stdio.h>
int main()
{
    long long int n,i,sum=0;
    scanf("%lli",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
        {
            sum=sum;
        }
        else
        {
            sum=sum+i;
        }
    }
    printf("%lli\n",sum);
    return 0;
}


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

const int maxn = 200010;
int n, a[maxn], b[maxn], c[maxn], d[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &b[i]);
    }
    int ans = 0;
    for (int i = 0; i <= 28; i++) {
        int P = 1 << (i + 1);
        for (int j = 1; j <= n; j++) {
            c[j] = a[j] % P, d[j] = b[j] % P;
        }
        sort(c + 1, c + n + 1, greater<int>());
        sort(d + 1, d + n + 1);
        auto query = [&](int x) {
            long long ans = 0;
            for (int i = 1, j = 0; i <= n; i++) {
                while (j < n && c[i] + d[j + 1] < x) j++;
                ans += j;
            }
            return ans;
        };
        long long sum = query((1 << i) * 2) - query(1 << i);
        sum += query((1 << i) * 4) - query((1 << i) * 3);
        if (sum & 1) ans ^= (1 << i);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(void){
    int k;
    cin >> k;
    vector<vector<int>> vect(k, vector<int>(k));
    for (int i = 0; i < k; i++){
        for(int j = 0; j < k; j++){
            vect.at(i).at(j) = gcd(i+1,j+1);
        }
    }
    
    int count = 0;
    for (int l=0; l < k; l++){
        for (int i = 0; i < k; i++){
           for(int j = 0; j < k; j++){
                count += vect.at(l).at(vect.at(i).at(j) - 1);
            }
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 3828
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()

	s := sc.NextLine()
	ss := strings.Split(s, "/")
	y, _ := strconv.Atoi(ss[0])
	if y > 2019 {
		fmt.Printf("%+v\n", "TBD") // output for debug
		return
	} else if y < 2019 {
		fmt.Printf("%+v\n", "Heisei") // output for debug
		return
	}
	m, _ := strconv.Atoi(ss[1])
	if m > 4 {
		fmt.Printf("%+v\n", "TBD") // output for debug
		return
	} else if y < 4 {
		fmt.Printf("%+v\n", "Heisei") // output for debug
		return
	}
	fmt.Printf("%+v\n", "Heisei") // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
#define pb push_back
using namespace std;
vector<ll>adj[100005];
vector<ll>indegree(100005,0),dp(100005,-1);
ll dfs(ll node)
{
    if(adj[node].size()==0)
    return dp[node]=1;
    if(dp[node]!=-1)
    return dp[node];
    ll x=0;
    for(auto u:adj[node])
    {
        if(dp[u]==-1)
        x=max(x,dfs(u));
        else
        x=max(x,dp[u]);
    }
    return dp[node]=x+1;
}
int main() {
    ll n,m,i,x,y;cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
        indegree[y]++;
    }
    ll  ans=0;
    for(i=1;i<=n;i++)
    {
        if(indegree[i]==0)
        {
            dfs(i);
        }
        ans=max(ans,dp[i]);
    }
    cout<<ans-1;
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    int N, k;
    cin >> N >> k;
    // N = 100000;
    // k =   5;
    double y2 = 1.0 / N;
    double y = 0;
    int t;
    for (int n = 1; n <= N; n++){
        t = n;
        if (n >= k){
            y += y2;
            continue;
        }
        double x = log((double)k / (double)n) / log(2);
        int by;
        if (x - int(x) == 0){
            by = int(x);
        }
        else{
            by = int(x) + 1;
        }
        // cout << by << endl;
        // cout << by << endl;
        // by回連続で0にならない確率
        // cout << pow(0.5, (double)by) << endl;;
        if (pow((long double)0.5, (long double)by) > 1){
            cout << by;
            return 0;
        }
        y += y2 * pow((long double)0.5, (long double)by);
    }

    cout << setprecision(12) << y << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		String s = nextString();

		int ed=s.length()-1;
		int st=0;
		int ans=0;
		while(st<ed) {
			if(s.charAt(st)==s.charAt(ed)) {
				st++;
				ed--;
			}else {
				if(s.charAt(st)=='x') {
					st++;
					ans++;
				}else if(s.charAt(ed)=='x') {
					ed--;
					ans++;
				}else {
					pw.println(-1);
					return;
				}
			}
		}
		pw.println(ans);
	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25044
#include <iostream>
#include <cmath>

int parseInt(std::string str);
void notHeisei() {
    std::cout << "TBD" << std::endl;
}
void isHeisei() {
    std::cout << "Heisei" << std::endl;
}

int main() {
    std::string s;
    std::cin >> s;

    std::string date[3];
    int tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '/') {
            tmp += 1;
        } else {
            date[tmp].push_back(s[i]);
        }
    }

    if (parseInt(date[0]) < 2019) {
        isHeisei();
    } else if (parseInt(date[0]) == 2019 && parseInt(date[1]) < 5) {
        isHeisei();
    } else {
        notHeisei();
    }
}

int parseInt(std::string str) {
    int result = 0;

    int index = 0;
    for (int i = str.size(); i > 0; i--) {
        int num;
        switch (str[index]) {
            case '0':
                num = 0; break;
            case '1':
                num = 1; break;
            case '2':
                num = 2; break;
            case '3':
                num = 3; break;
            case '4':
                num = 4; break;
            case '5':
                num = 5; break;
            case '6':
                num = 6; break;
            case '7':
                num = 7; break;
            case '8':
                num = 8; break;
            case '9':
                num = 9; break;
        }
        result += num * std::pow(10, i - 1);
        index++;
    }

    return result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T; cin >> N >> T;
  int ans = INF32;
  for (int i = 0; i < N; i++) {
    int c, t; cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == INF32)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace::std;

void inputNums(vector<int> &nums){
  string input;


  getline(cin, input);

  stringstream ss(input);

  string buf;

  while(!ss.eof()){
    ss >> buf;
    nums.push_back(stoi(buf));
  }

}

int main(void){
  int a,b;

  cin >> a;
  cin >> b;



  cout << (a-1)*(b-1)<< endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,t[111],v[111],v2[111];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i],t[i]*=2;
	for(int i=0;i<n;i++)cin>>v[i],v[i]*=2;
	for(int j=n;j--;)v2[j]=min({v[j],v[j+1],v2[j+1]+t[j+1]});
	int now=0;
	long ans=0;
	for(int i=0;i<n;i++)
	{
		//cout<<now<<" "<<v[i]<<" "<<v2[i]<<endl;
		int left=v[i]-now;
		int right=v[i]-v2[i];
		//cout<<left<<" "<<right<<endl;
		if(left+right<=t[i])
		{
			ans+=v[i]*t[i]-right*right/2-left*left/2;
		}
		else if(t[i]<left&&now+t[i]<=v2[i])
		{
			ans+=t[i]*t[i]/2+now*t[i];
		}
		else
		{
			int x=(v2[i]+t[i]-now)/2;
			//now+x==v2[i]+(t[i]-x)<=>2*x==v2[i]+t[i]-now
			long get=(x*x+(t[i]-x)*(t[i]-x))/2;
			long Min=min(now,v2[i]);
			get+=(now-Min)*x+(v2[i]-Min)*(t[i]-x);
			ans+=get+Min*t[i];
		}
		//cout<<ans<<endl<<endl;
		now=min(now+t[i],v2[i]);
	}
	cout<<fixed<<setprecision(15)<<(double)ans/4<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int ans = -1;
void cost(int bam[], int n, int a, int b, int c, int x, int o, int t, int w)
{
    if(x == n)
    {
        if(o == -1 || t == -1 || w == -1)
        {
            return;
        }
        int sub = (o + t + w) * 10 + abs(a) + abs(b) + abs(c);
        if(ans == -1)
        {
            ans = sub;
        }
        if(sub < ans)
        {
            ans = sub;
        }
        return;
    }
    a -= bam[x];
    o++;
    cost(bam, n, a, b, c, x+1, o, t, w);
    o--;
    a += bam[x];
    b -= bam[x];
    t++;
    cost(bam, n, a, b, c, x+1, o, t, w);
    t--;
    b += bam[x];
    c -= bam[x];
    w++;
    cost(bam, n, a, b, c, x+1, o, t, w);
    w--;
    c += bam[x];
    cost(bam, n, a, b, c, x+1, o, t, w);
}
int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    int bam[n];
    for(int i = 0; i < n; i++)
    {
        cin >> bam[i];
    }
    cost(bam, n, a, b, c, 0, -1, -1, -1);
    cout << ans << endl;
    return 0;
}


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

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

    bool okay = false;

    while (n)
    {
        int d = n % 10;
        if (d == 7)
        {
            okay = true;
            break;
        }
        n /= 10;
    }

    if (okay)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3104
s1 = str(input())
s2 = str(input())
T = str(input())
#N, K = s1.split(' ')
N, K = list(map(int, s1.split(' ')))
R,S,P = list(map(int, s2.split(' ')))

win = {'r' : 'p', 's': 'r', 'p' : 's'}
point = {'r' : R, 's' : S, 'p' : P}
rsp = ['r', 's', 'p']
def calc_score(substr):
#    actions = []
    my_prev = win[substr[0]]
    score = point[my_prev]
    for idx in range(1, len(substr) - 1):
        my_now = win[substr[idx]]
        if my_now != my_prev:
            score += point[my_now]
        else:
            my_next = win[substr[idx + 1]]
            for elem in rsp:
                if elem != my_prev and elem != my_next:
                    my_now = elem # lose with elem with no score
                    break
#        actions.append(my_now)
        my_prev = my_now
#    print(actions)
    my_now = win[substr[-1]]
    if my_now != my_prev:
        score += point[my_now]
    return score

all_score = 0
for offset in range(K):
    all_score += calc_score(T[offset::K])

print(all_score)



Measured memory_bytes: 3316
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

typedef vector<pair<int, int>> FACTORS;

class Sieve {
public:
    Sieve(int size) : sieve(size+1) {
        sieve[0] = -1;
        sieve[1] = -1;
        for (int i = 2; i <= size; ++i) {
            if (!sieve[i]) {
                sieve[i] = i;
                for (LL j = (LL) i * i; j <= (LL) size; j += i) {
                    if (!sieve[j]) {
                        sieve[j] = i;
                    }
                }
            }
        }
    }

    bool isPrime(int x) {
        return (sieve[x] == x);
    }

private:
    vector<int> sieve;
};


int memo[1000];

int countAux(int p) 
{
    int ret = memo[p];
    if (!ret) {
        int mn = 1;
        int q = p;
        while (mn <= q) {
            ++ret;
            q -= mn;
            ++mn;
        }
        memo[p] = ret;
    }
    return ret;
}

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

    Sieve s(1000000);

    LL N;
    cin >> N;

    map<int, int> factors;
    for (int f = 2; ((LL)f)*((LL)f) <= N; ++f) {
        if (s.isPrime(f)) {
            while (N % f == 0) {
                N /= f;
                ++factors[f];
            }
        }
    }
    if (1LL < N) {
        ++factors[N];
    }

    int ans = 0;
    for (auto p: factors) {
        ans += countAux(p.second);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,q,u,v;
ll x,cnt[maxn],sum;
void solve(){
	sum -= cnt[u] * u;
	sum += cnt[u] * v;
	cnt[v] += cnt[u];
	cnt[u] = 0;
	cout << sum << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,0,n-1){
		cin >> x;
		sum += x;
		cnt[x]++;
	}	
	cin >> q;
	while(q--){
		cin >> u >> v;
		solve();
	}
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    vector<int>a(5);
    for(int i=0;i<5;i++){
        cin >> a.at(i);
        if(a.at(i)==0){
            cout <<i+1<<endl;
            return 0;
        }
    }

}
    



Measured memory_bytes: 3568
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	S, T := sc.Next(), sc.Next()

	mpA := map[byte]int{}
	for i := 0; i < len(S); i++ {
		mpA[S[i]]++
	}
	mpB := map[byte]int{}
	for i := 0; i < len(T); i++ {
		mpB[T[i]]++
	}

	A := make([]int, 26)

	i := 0
	for _, v := range mpA {
		A[i] = v
		i++
	}

	B := make([]int, 26)

	i = 0
	for _, v := range mpB {
		B[i] = v
		i++
	}

	sort.Ints(A)
	sort.Ints(B)
	for i := 0; i < 26; i++ {
		if A[i] != B[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 3328
using System;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(new Calu().calu(Console.ReadLine().Split(' ').Select(int.Parse).ToArray()));
        }

        public class Calu{
            public int calu(int[] a){
                return a.Sum() % 24;
            }
        }
    }

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int X;
    cin >> X;
    vector<bool> check(X + 1, false);
    check[1] = true;

    int b = 2;
    while (b * b <= X) {
        int k = b * b;
        while (k <= X) {
            check[k] = true;
            k *= b;
        }
        b++;
    }

    for (int i = X; i >= 0; i--) {
        if (check[i]) {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;

int main(){
  int memo_tf[222][222]={};
  int memo[222][222]={};
  int A[222],B[222],C[222],T[222];
  int N,D;
  int ab[222][222]={};

  scanf("%d %d",&D,&N);
  for(int i=0;i<D;i++){
    scanf("%d",&T[i]);
  }
  for(int i=0;i<N;i++){
    scanf("%d %d %d",&A[i],&B[i],&C[i]);
  }

  for(int i=0;i<D;i++){
    for(int j=0;j<N;j++){
      if(A[j]<=T[i] && T[i]<=B[j]){
	memo_tf[i][j]=1;
      }
    }
  }
  
  int sum=0;

  for(int i=1;i<D;i++){
    for(int j=0;j<N;j++){
      if(memo_tf[i][j]==1){
	int max=0;
	for(int k=0;k<N;k++){
	  if(memo_tf[i-1][k]==1){
	    if(ab[k][j]==0){
	      ab[k][j]=abs(C[k]-C[j]);
	      ab[j][k]=ab[k][j];
	    }
	    if(max<(memo[i-1][k]+ab[k][j])){
	      max=memo[i-1][k]+ab[k][j];
	    }
	  }
	}
	memo[i][j]=max;
      }
      if(sum<memo[i][j]){
	sum=memo[i][j];
      }
    }
  }

  /*
  for(int i=0;i<D;i++){
    for(int j=0;j<N;j++){
      printf("%2d ",memo[i][j]);
    }
    printf("\n");
  }
  */  

  printf("%d\n",sum);


  return 0;
}

Measured memory_bytes: 1776
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> input(n,0);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> input.at(i);
  }
  
  int max = 0;
  for (int i = 0; i < n; i++) {
    if(i < m){
      sum += input[i];
    }else{
      sum = sum - input[i-m] + input[i];
    }
    if(sum > max) max = sum;
  }
  
  cout << (max + m)/2;
  
  if((max + m)%2 != 0)
    cout << ".5";
  
  cout << endl;
  
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int m, h;
  while (cin >> s) { 
    if (s == "-") {
      break;
    }
    cin >> m;
    while (m--) {
      cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }
    cout << s << '\n';
  }
  return 0;
}



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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<vector<int>> coords;
    for (int i = 0; i < n; ++i) {
        int x, y, h; cin >> x >> y >> h;
        vector<int> tmp = {x, y, h};
        coords.PB(tmp);
    }
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int H;
            bool works = true;
            for (auto i : coords) {
                int x = i[0];
                int y = i[1];
                int h = i[2];
                if (h > 0) {
                    H = abs(x - cx) + abs(y - cy) + h;
                    break;
                }
            }
            for (auto i : coords) {
                int x = i[0];
                int y = i[1];
                int h = i[2];
                if (h > 0) {
                    if (H - abs(x - cx) - abs(y - cy) != h) {
                        works = false;
                        break;
                    }
                } else {
                    if (H - abs(x - cx) - abs(y - cy) > 0) {
                        works = false;
                        break;
                    }
                }
            }
            if (works) {
                cout << cx << " " << cy << " " << H << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3612
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define  arysort(v) sort(v.begin(), v.end())
#define  aryreverse(v) reverse(v.begin(),v.end())
#define  arysum(v) accumulate(v.begin(), v.end(), 0)
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  int n, x;
  cin >> n >> x;

  vector<vector<int>> ary(n, vector<int>(2, 0));
  rep(i, n) {
    ary[i][0] = i + 1;
    ary[i][1] = n - ary[i][0];
  }

  int cnt = n + 1;
  rep(i, x) {
    int tmp;
    cin >> tmp;
    tmp -= 1;

    cnt += 1;
    ary[tmp][1] = cnt;
  }

  sort(ary.begin(), ary.end(), [](auto const& a, auto const& b){return a[1] > b[1];});
  rep(i, n) cout << ary[i][0] << endl;

  return 0;
}



Measured memory_bytes: 13708
#include<bits/stdc++.h>
using namespace std;
int main(){
 vector<int> vec(3);
 for(int i=0; i<3; i++){
  cin >> vec.at(i);
 }
 sort(vec.begin(),vec.end());
 cout << vec.at(0) << " ";
 cout << vec.at(1)  << " ";
 cout << vec.at(2) << endl;
} 


Measured memory_bytes: 3144
#!/usr/bin/env python3
t = open(0).read()
c1 = c2 = c3 = 0
for s in t.split():
    if s[-1] == "A" and s[0] == "B":
        c1 += 1
    elif s[-1] == "A":
        c2 += 1
    elif s[0] == "B":
        c3 += 1
if c1:
    a = c1 + min(c2, c3) if c2 + c3 > 0 else c1 - 1
else:
    a = min(c2, c3)

print(t.count("AB") + a)

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();

        for (int i = 0; i < Math.max(a, b); i++) {
            System.out.print(Math.min(a,b));
        }
        System.out.println();
    }
}


Measured memory_bytes: 23124