akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define loops(i, s, n) for (int i = s; i < n; i++)
#define loop(i, n) for (int i = 0; i < n; i++)
#define eps 1e-9
#define loopitr(mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define even_set 0xAAAAAAAA ... 1010101010
#define odd_set 0x55555555 ... 01010101
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vall(v) v.begin(), v.end()
#define mkp make_pair
#define ret return
#define cont continue
#define ff first
#define ss second
#define cnt_bits __builtin_popcount
const int mod = 1000000007;

int main()
{

    fastio;

    int n;
    cin >> n;
    ll arr[n];
    loop(j, n)
    {
        cin >> arr[j];
    }

    ll dp[n];
    dp[0] = 0;
    for(int i =1;i<n;i++){
        dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
        if(i-2 >=0)
          dp[i] = min(dp[i], dp[i-2] + abs(arr[i] - arr[i-2]));
    }

    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll a, b , k; cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << " " << b << endl;
    } else if (k <= a + b) {
        cout << 0 << " " << b - (k - a)<< endl;
    } else {
        cout << 0 << " " << 0<< endl;
    }
    return 0;
}


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

int main(){
    ll a, b ,k;
    cin >> a >> b >> k;

    if(a >= k){
        cout << a - k <<  " " << b << endl;
    }else{
        ll m = k - a;
        if(b >= m){
            cout << 0 << " " << b - m << endl;
        }else{
            cout << 0 << " " << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005
#define mod 1000000007

ll dp[105][MAX] = {0};
// dp[i][j] -> no of ways to dist j candies in first i children
// total ways to dist o candies in 0 children is 1 dp[0][0]=1;
// whereas total ways to dist 0 cand in i(i>0) child is 0 as we cant give them any candy

/*
now dp[i][j] = dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j-2]+....+dp[i-1][j-arr[i]] (till when i-arr[i] exist)
explanation: -> we check hoe mays to dist j candies in i-1 children + no of ways to dist j-1 candies to i-1 children and son on
as we can dist 0 to arr[i] candies to each ith child, bcoz of this we check (i-1,k)+(i-1,k-1)+ .. 

Now:

dp[i][k] = dp[i-1][k]+dp[i-1][k-1]+...+dp[i-1][k-arr[i]]
dp[i][k-1] = (dp[i-1][k-1]+dp[i-1][k-2]+...+dp[i-1][k-arr[i]])+dp[i-1][k-1-arr[i]];

using these we cn fig that:
(dp[i-1][k-1]+...+dp[i-1][k-arr[i]]) = dp[i][k-1]-dp[i-1][k-arr[i]-1]

hence dp[i][k] = dp[i-1][k]+dp[i][k-1]-dp[i-1][k-arr[i]-1];
*/

int *arr;

int main(){
    int n, k;
    cin>>n>>k;
    arr = new int[n+1];
    ip(arr, n);
    
    for(int i=0; i<=n; i++){
        for(int j=0; j<=k; j++){
            if(i==0){
                if(j==0) dp[i][j]=1;
                else dp[i][j]=0;
            }
            else if(j==0){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j] = (mod+dp[i-1][j]+dp[i][j-1] -((j-arr[i]-1)>=0?dp[i-1][j-arr[i]-1]:0))%mod;
            }
        }
    }

    cout<<dp[n][k]<<endl;
    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MOD = 1e9+7;
const int MAXN = 1e5+5;
int dp[105][MAXN];

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

    int n,k; cin>>n>>k;
    vi a = readVector<int>(n);

    dp[0][k]=1;

    FOR(i,n) {
        int ps[MAXN];
        ps[0]=dp[i][0];
        RNG(j,1,k)
            ps[j] = ( ps[j-1]+dp[i][j] ) % MOD;

        FOR(j,k+1) {
            int me = min(k, j+a[i]);
            dp[i+1][j] += ps[me] - (j>0 ? ps[j-1] : 0);
            dp[i+1][j] %= MOD;
            dp[i+1][j] += MOD;
            dp[i+1][j] %= MOD;
        }
    }

    cout<<dp[n][0]<<endl;


    return 0;
}



Measured memory_bytes: 41216
#include<stdio.h>
int main()
{
    int a,b,n;
    scanf("%d%d",&a,&b);
    n=a+b;
    if(n<23)
    {
        printf("%d",n);
    }
    else if(n>23)
    {
        printf("%d",(n-24));
    }
    else
    {
        printf("%d",a+b);
    }
   return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

//Cut the Cakes
public class Main{
	
	static class C implements Comparable<C>{
		public int w;
		public int d;
		public int cutTime;
		public C(int w, int d, int cutTime) {
			this.w = w;
			this.d = d;
			this.cutTime = cutTime;
		}
		public int compareTo(C o) {
			if(cutTime==o.cutTime)return w*d-o.w*o.d;
			return cutTime-o.cutTime;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			int d = sc.nextInt();
			if((n|w|d)==0)break;
			C[] cake = new C[1];
			cake[0] = new C(w, d, 0);
			for(int i=1;i<=n;i++){
				C[] next = new C[i+1];
				int id = sc.nextInt()-1;
				int s = sc.nextInt();
				C target = cake[id];
				int j=0;
				for(int k=0;k<i;k++){
					if(k!=id)next[j++]=cake[k];
				}
				s %= 2*(target.w+target.d);
				if(0<=s&&s<=target.w){
					next[j++] = new C(target.w-s, target.d, i);
					next[j++] = new C(s, target.d, i);
				}
				else if(target.w <= s && s <= target.w + target.d){
					next[j++] = new C(target.w, s-target.w, i);
					next[j++] = new C(target.w, target.d-(s-target.w), i);
				}
				else if(target.w + target.d <= s && s <= target.w*2 + target.d){
					next[j++] = new C(s-(target.w+target.d), target.d, i);
					next[j++] = new C(target.w-(s-(target.w+target.d)), target.d, i);
				}
				else {
					next[j++] = new C(target.w, s-(target.w*2+target.d), i);
					next[j++] = new C(target.w, target.d-(s-(target.w*2+target.d)), i);
				}
				cake = next;
				Arrays.sort(cake);
			}
			Arrays.sort(cake, new Comparator<C>() {
				public int compare(C o1, C o2) {
					return o1.w*o1.d-o2.w*o2.d;
				}
			});
			for(int i=0;i<cake.length;i++){
				if(i==0)System.out.print(cake[i].w*cake[i].d);
				else System.out.print(" " + cake[i].w*cake[i].d);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI=3.14159265358979323846;

int main()
{
    int X,N;

    cin >> X >>N;


    vector<int> P(100);


    for(int i=0;i<=101;i++){

        P[i] = i;
    }


    for(int i=0;i<N;i++){

        int a;
        cin >>a;

        P[a] = -100000;
    }

    sort(P.begin(),P.end());

    int smallest = 10000;
    int nob = 1000;
    for(int i=0;i<=101;i++){


        int tmp =abs(X -P[i]);
        if(smallest > tmp){

            smallest = tmp;
            nob = P[i];


        }


    }


    cout << nob << endl;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
xn = list(map(int, input().split()))
yn = list(map(int, input().split()))

Dp1, Dp2, Dp3, Dpinf = [0.0]*4

for (x, y) in zip(xn, yn):
    a = abs(x-y)
    Dp1 += a
    Dp2 += a**2
    Dp3 += a**3
    Dpinf = a if a > Dpinf else Dpinf

Dp2 = Dp2**(1/2)
Dp3 = Dp3**(1/3)

print(Dp1, Dp2, Dp3, Dpinf, sep='\n')

Measured memory_bytes: 7744
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int h, w, ans;
string s[2005];
int tmp[4][2005][2005];

int main() {

	cin >> h >> w;
	rep(i, h)cin >> s[i];

	rep(i, h) {
		rep(j, w) {
			if (j == 0) {
				if (s[i][j] != '#') {
					tmp[0][i][j] = 1;
				}
			}
			else {
				if (s[i][j] == '#') {
					tmp[0][i][j] = 0;
				}
				else {
					tmp[0][i][j] = tmp[0][i][j - 1] + 1;
				}
			}
		}
	}

	rep(i, w) {
		rep(j, h) {
			if (j == 0) {
				if (s[j][i] != '#') {
					tmp[1][j][i] = 1;
				}
			}
			else {
				if (s[j][i] == '#') {
					tmp[1][j][i] = 0;
				}
				else {
					tmp[1][j][i] = tmp[1][j - 1][i] + 1;
				}
			}
		}
	}

	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			if (j == w - 1) {
				if (s[i][j] != '#') {
					tmp[2][i][j] = 1;
				}
			}
			else {
				if (s[i][j] == '#') {
					tmp[2][i][j] = 0;
				}
				else {
					tmp[2][i][j] = tmp[2][i][j + 1] + 1;
				}
			}
		}
	}

	for (int i = w - 1; i >= 0; i--) {
		for (int j = h - 1; j >= 0; j--) {
			if (j == h - 1) {
				if (s[j][i] != '#') {
					tmp[3][j][i] = 1;
				}
			}
			else {
				if (s[j][i] == '#') {
					tmp[3][j][i] = 0;
				}
				else {
					tmp[3][j][i] = tmp[3][j + 1][i] + 1;
				}
			}
		}
	}

	rep(i, h) {
		rep(j, w) {
			int sum = tmp[3][i][j] + tmp[2][i][j] + tmp[1][i][j] + tmp[0][i][j] - 3;
			ans = max(ans, sum);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 67072
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for(int i = 1; i <= N; i++)
            A[i] = sc.nextInt();
        A[0] = -1;
        sc.close();

        long ans = 0;
        for(int i = N; i >= 1; i--){
            if(A[i] > A[i-1]+1){
                ans = -1;
                break;
            } else {
                if(A[i] == A[i-1]+1 && i!=1)
                    ans++;
                else
                    ans += A[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 86624
#!/usr/bin/env python3
import sys


def f(x):
    ans = chr(x[0] + ord('a') - 1)
    

def solve(N: int):
    '''
    >>> solve(1)
    'a'
    >>> solve(26)
    'z'
    >>> solve(18278)
    'zzz'
    >>> solve(475255)
    'aaaaa'
    '''
    ans = []
    n = N
    while n > 0:
        ans.append((n-1)%26)
        n = (n-1) // 26
    return "".join(map(lambda x: chr(x+ord('a')), reversed(ans)))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()


Measured memory_bytes: 17544
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_H = 50;
int H, W;
char s[MAX_H][MAX_H];
int w_count;
int d_min[MAX_H][MAX_H];

int bfs() {
    queue<P> que;
    REP(i, H) REP(j, W) d_min[i][j] = INF;
    que.push(P(0, 0)), d_min[0][0] = 0;

    // queが空でない限り
    while (!que.empty()) {
        // 一番近いところのを取り出す．
        P p = que.front();
        que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;
        // 近傍4カ所を調べる
        REP(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            // 移動可能なマスの場合
            if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] != '#' &&
                d_min[nx][ny] == INF) {
                // queに入れて，最小値更新
                que.push(P(nx, ny));
                d_min[nx][ny] = d_min[p.first][p.second] + 1;
            }
        }
    }
    return d_min[H - 1][W - 1];
}

void solve() {
    int res = bfs();
    if (res == INF) cout << -1 << endl;
    else cout << w_count - res - 1 << endl;
}

int main() {
    cin >> H >> W;
    REP(i, H) REP(j, W) {
            cin >> s[i][j];
            if (s[i][j] == '.') w_count++;
        }
    solve();
    return 0;
}

Measured memory_bytes: 256
n,W=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[float('inf') for _ in range(10**5+1)] for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
    weight,value=a[i]
    for j in range(10**5+1):
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        if j+value<=10**5:
            dp[i+1][j+value]=min(dp[i][j+value],dp[i][j]+weight)
for i in range(10**5+1):
    if dp[-1][-i-1]<=W:
        print(10**5-i)
        break

Measured memory_bytes: 269996
// 2014/07/11 Tazoe

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

	string a[4];
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	a[3] = "100000001";

	for(int i=3; i<n; i++){
		string s;
		cin >> s;

		for(int j=0; j<4; j++){
			if(s.size()<a[j].size() || (s.size()==a[j].size() && s<a[j])){
				swap(s, a[j]);
			}
		}
	}

	string aa[12];
	int k = 0;
	for(int i=0; i<4; i++){
		for(int j=0; j<4; j++){
			if(i==j)
				continue;

			aa[k++] = a[i]+a[j];
		}
	}

	for(int i=0; i<11; i++){
		for(int j=i+1; j<12; j++){
			if(aa[j].size()<aa[i].size() || (aa[j].size()==aa[i].size() && aa[j]<aa[i])){
				swap(aa[i], aa[j]);
			}
		}
	}

	cout << aa[2] << endl;

	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int main() {
    LL n,modFour=0,modTwo=0;
    cin >> n;
    for(LL i=0;i<n;i++)
    {
        LL a; cin >> a;
        if(a%4==0)
            modFour++;
        else if(a%2==0)
            modTwo++;
    }
    LL count = modFour+(modTwo/2);
    if(count>=n/2)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}





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

using namespace std;

int main() {
    long long int n,m;
    cin>>n>>m;
    long long int sum = 0;
    for(int c=0;c<m;c++) {
        long long z;
        cin>>z;
        sum+=z;
    }
    cout<<max(-1LL,n-sum);
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b, k;
    cin >> a >> b;

    if ((a - b) % 2 != 0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (a + b) / 2 << endl;
    }
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	bool flag = true;
	int N;
	
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		int A;
		cin>>A;
		if(A%2 == 0) {
			if(A%3 == 0 || A %5 == 0) {
			} else flag = false;
		}
	}
	
	
	cout<<(flag?"APPROVED":"DENIED ")<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(C: str):
    ans=ord(C)
    ans+=1
    print(chr(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n,k, cnt;
    string s;
    cin >> n >> k >> s;
    char prev = s[0];

    cnt = 1;
    for(int i = 1; i < n; i++){
        if(s[i] != prev) cnt++;
        prev = s[i];
    }
    while(k > 0 && cnt > 2){
        cnt -= 2;
        k--;
    }
    if(k > 0 && cnt == 2){
        cnt--;
    }
    cout << n - 1 - (cnt - 1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;

int main(){
    int n,k; cin >> n >> k;
    double prob = 0;
    // diceでiが出る
    for(int i = 1; i <= n;i++){
        int point = i;
        double tmpprob = 1.0/n;
        while(point < k){
            point *= 2;
            tmpprob /= 2;
        }
        prob += tmpprob;
    }
    printf("%.10lf\n", prob);
    // cout << prob << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	vector<int>a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[2] - a[0] << endl;
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n, k; cin >> n >> k;
    V<ll> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    ll ans = INF;
    for(int l = 0; l <= n - k; l++){
        ll r = l + k - 1;
        ans = min(ans, abs(x[l]) + abs(x[l] - x[r]));
        ans = min(ans, abs(x[r]) + abs(x[l] - x[r]));
    }
    cout << ans << endl;

}


Measured memory_bytes: 1024
from sys import stdin

def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri():
    return int(input())

L = [0] * 5
for i in range(5):
    L[i] = ri()
K = ri()

print("Yay!" if L[4] - L[0] <= K else ":(" )


Measured memory_bytes: 3060
N = int(input())
S = {}
for i in range(N):
    s = input()
    S[s] = S.get(s, 0) + 1

keys = list(S.keys())
keys.sort(key=lambda x: -S[x])

top_mode = S[keys[0]]

ans = []
for i in range(len(keys)):
    if top_mode == S[keys[i]]:
        ans.append(keys[i])

ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

using namespace std;


void solve() {
    int n; cin >> n;
    string s,t;
    cin >> s >> t;
    auto get_cut = [&](auto& s){
        vector<int> cut;
        char las = '0';
        for (int i = 0; i < n; i++) {
            if (s[i] != las) {
                cut.emplace_back(i);
            }
            las = s[i];
        }
        return cut;
    };
    auto a = get_cut(s);
    auto b = get_cut(t);
    while (a.size() < b.size()) {
        a.emplace_back(n);
    }
    while (b.size() < a.size()) {
        b.emplace_back(n);
    }
    if (a.size()&1) {
        a.emplace_back(n);
        b.emplace_back(n);
    }
    int m = a.size();
    int mi = 1<<30;
    for (int l = -m; l <= m; l+=2) {
        int r = l+m;
        int d = 0;
        for (int i = 0; i+r < m; i++) {
            d += a[i];
        }
        for (int i = m-l; i < m; i++) {
            d += n - a[i];
        }
        for (int j = 0; j < l; j++) {
            d += b[j];
        }
        for (int j = r; j < m; j++) {
            d += n - b[j];
        }
        for (int i = 0; i < m; i++) {
            if (0 <= i+l && i+l < m) {
                d += abs(a[i] - b[i+l]);
            }
        }
        mi = min(mi, d);
    }
    cout << mi;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
typedef long long ll;
const int N = 51;
ll bu[N], p[N];
ll recursive(int n, ll x) {
    if (n == 0) { //level 0 burger
        return 1; //is p
    }
    if (x == 1) { //bottom (not level 0 burger)
        return 0; //is b
    } else if (x <= bu[n] / 2) { //切り捨てで真ん中の1個左まで
        return recursive(n - 1, x - 1);
    } else if (x == bu[n] / 2 + 1) {
        return 1 + recursive(n - 1, x - 2);
    }
    return p[n - 1] + 1 + recursive(n - 1, x - bu[n - 1] - 2);
}
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll x;
    cin >> n >> x;
    p[0] = 1;
    bu[0] = 1;
    for (int i = 1; i < N; ++i) {
        bu[i] = 2 * bu[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }
    cout << recursive(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import itertools

N = int(input())
n = []
for i in range(N):
  n.append(list(map(int, input().split())))
cnt = 0

m = []
l = 1
for i in range(N):
  m.append(int(i))

for i in range(1,N+1):
  l *= i

for j in itertools.permutations(m):
  for i in range(N-1):
     cnt = cnt + math.sqrt(((n[j[i]][0]-n[j[i+1]][0])**2)+((n[j[i]][1]-n[j[i+1]][1])**2))

print(cnt/l)

Measured memory_bytes: 40556
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		String T=stdIn.next();
		if(S.equals(T.substring(0,T.length()-1)))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[6];
  for(int i=0; i<6; i++) cin >> a[i];
  sort(a,a+4);
  sort(a+4,a+6,greater<int>());
  int ans=0;
  for(int i=1; i<5; i++) ans+=a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"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;}
int main(){
    ll a,b;
    cin >> a >> b;
    ll g  =gcd(a,b);
    ll ans = 1;
    for(ll i=2;i*i<=g;i++){
        if(g%i!=0)continue;
        ans++;
        while(g%i==0){
            g/=i;
        }
    }
    if(g!=1)ans++;
    cout << ans << endl;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  t=S()

  for i in range(len(s)-len(t)+1)[::-1]:
    x=s[i:i+len(t)]
    f=True
    for j in range(len(t)):
      if t[j]!=x[j] and x[j]!='?':
        f=False

    if f:
      return s[:i].replace('?','a')+t+s[i+len(t):].replace('?','a')

  return 'UNRESTORABLE'

print(main())


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

int main() {
    int N, T;
    cin >> N >> T;

    map<int, int> root;
    for (int i = 0; i < N; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (root.find(ci) == root.end()) {
            root[ci] = ti;
        } else if (root[ci] > ti) {
            root[ci] = ti;
        }
    }

    int ans = 0;
    for (auto rooti : root) {
        if (rooti.second <= T) {
            ans = rooti.first;
            break;
        }
    }

    if (ans != 0) {
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,d,n;
    while(scanf("%d%d",&a,&b), a != 0){
    	d = 0;
        switch (a){
            case 2:
                    d = d + 31;
                    break;
            case 3:
                    d = d + 60;
                    break;
            case 4:
                    d = d + 91;
                    break;
            case 5:
                    d = d + 121;
                    break;
            case 6:
                    d = d + 152;
                    break;
            case 7:
                    d = d + 182;
                    break;
            case 8:
                    d = d + 213;
                    break;
            case 9:
                    d = d + 244;
                    break;
            case 10:
                    d = d + 274;
                    break;
            case 11:
                    d = d + 305;
                    break;
            case 12:
                    d = d + 335;
                    break;
            default:
                    d = d + 0;
                    break;
        }
        d = d + b;
        n = d % 7;
        switch (n){
            case 1:
                    printf("Thursday\n");
                    break;
            case 2:
                    printf("Friday\n");
                    break;
            case 3:
                    printf("Saturday\n");
                    break;
            case 4:
                    printf("Sunday\n");
                    break;
            case 5:
                    printf("Monday\n");
                    break;
            case 6:
                    printf("Tuesday\n");
                    break;
            default:
                    printf("Wednesday\n");
                    break;
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    int n;
    cin >> n;
    int flag = 0;
    int a = n%10;
    int b = n%100/10;
    int c = n/100;
    if(a==7||b==7||c==7) flag = 1;
    if(flag==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(int argc,char* argv[]){
  int n,i;
  double x1,y1,r1,x2,y2,r2;
  double dist = 0; //from A

  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2);
    
    dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    
    if(dist > (r1 + r2)){
      printf("0\n");
      continue;
    }
    
    if(r1 > (dist + r2)){
      printf("2\n");
      continue;
    }

    if(r2 > (dist + r1)){
      printf("-2\n");
      continue;
    }

    printf("1\n");
    
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int x[400001];
    std::cin >> n;
    int t=200000;
    int a=t+1,b=t;
    int g;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        if(i%2==0){
            x[a]=tmp;
            a++;
        }else{
            x[b]=tmp;
            b--;
        }
        g=i;
    }
    if(g%2==0){
        for (int i =a-1; i > b; i--) {
            std::cout <<  x[i] <<" ";
        }
    }else{
        for (int i = b+1; i < a; i++) {
                std::cout <<  x[i] <<" ";
        }
    }
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>

using namespace std;

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

long long p[30];

long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  long long n, m;
  for (;;) {
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    rep (i, m) cin >> p[i];
    double res = 0;
    long long count = 0;
    rep (bit, 1 << m) {
      long long b = bit;
      long long lcm = 1;
      while (b) {
	long long ctz = __builtin_ctz(b);
	b ^= 1 << ctz;
	lcm = lcm * p[ctz] / gcd(lcm, p[ctz]);
      }
      long long c = (1 - __builtin_parity(bit) * 2) * n / lcm;
      //cout << bit << " " << c * (n + lcm) / 2 << endl;
      count += c;
      res += c * (n + lcm) / 2;
    }
    if (count > 0) res /= count;
    else res = 0;
    printf("%.12lf\n", res);
  }
}

Measured memory_bytes: 908
#include <cstdio>

int main(void)
{
    int n, b, f, r, v, num[12][10];
    for(int i=0; i<12; i++)
        for(int j=0; j<10; j++)
            num[i][j] = 0;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        num[3*(b-1)+f-1][r-1] += v;
    }
    for(int i=0; i<12; i++)
    {
        for(int j=0; j<10; j++) printf(" %d", num[i][j]);
        printf("\n");
        if(i == 11) break;
        if(i%3 == 2) printf("####################\n");

    }

    return 0;
}


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

int main(){
	int n;
  	cin>>n;
  	while(n>1){
    	if(n%10==7){
        	cout<<"Yes";
          	return 0;
        }
      	n/=10;
    }
  	cout<<"No";
  	return 0;
}

Measured memory_bytes: 3636
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	
	int n;
	deque<ll> a;

	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	
	/*
	ll begin = a[0], end = a[n-1];
	a.push_front(end);
	a.push_back(begin);
	bool ok = true;
	
	for (int i = 1; i < n+1; ++i) {
		ll self = a[i];
		ll l = a[i-1];
		ll r = a[i + 1];
		ll target = l ^ r;
		if (self != target) ok = false;
	}
	*/
	ll target = a[0];
	for(int i = 1; i < n; ++i) {
		target = target ^ a[i];
	}
	if (!target) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using static System.Math;

namespace ConsoleApp15
{
    class Class55
    {
        static void Main()
        {
            var nd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = nd[0], d = nd[1];
            double[][] x = new double[n][];
            for(int i = 0; i < n; i++)
            {
                x[i] = Console.ReadLine().Split().Select(double.Parse).ToArray();
            }

            int count = 0;
            for(int i = 0; i < n - 1; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    double m = 0;
                    for(int k = 0; k < d; k++)
                    {
                        m += Pow(x[i][k] - x[j][k], 2);
                    }
                    m = Sqrt(m);
                    if (m == Floor(m)) count++;
                }
            }
            Console.WriteLine(count);
        }
        
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
struct edge{ll from,to,cost;};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,a,b,c,r;
    cin>>n>>m>>r;
    ll d[n];
    bool maki;
    vector<edge> g;
    for(int i=0;i<n;i++)d[i]=mod*mod;
    d[r]=0;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        g.push_back({a,b,c});
    }
    for(int i=0;i<n*2;i++){
    	maki=false;
        for(int j=0;j<m;j++){
            if(d[g[j].from]!=mod*mod&&d[g[j].to]>d[g[j].from]+g[j].cost){
                d[g[j].to]=d[g[j].from]+g[j].cost;
                maki=true;
            }
        }
    }
    if(maki){
    	cout << "NEGATIVE CYCLE" <<endl;
    	return 0;
    }
    for(int i=0;i<n;i++){
    	if(d[i]==mod*mod){
    		cout << "INF" <<endl;
    	}else{
    		cout << d[i] <<endl;
    	}
    }
    return 0;
}



Measured memory_bytes: 3256
tmp = list(map(int, input().split()))
l = tmp[0]
r = tmp[1]

ans = 2019
if (l // 2019) == (r // 2019):
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      rem = i * j % 2019
      if rem < ans:
        ans = rem
else:
  ans = 0

print(ans)

Measured memory_bytes: 40684
import java.util.*;
 
public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      
      int groupX = getGroup(x);
      int groupY = getGroup(y);
      
      if (groupX == groupY){

        System.out.print("Yes");
      }
      else{
        System.out.print("No");
      }
	}
  
  	public static int getGroup( int input ){
      int group1[] = {1,3,5,7,8,10,12};
      int group2[] = {4,6,9,11};
      int group3[] = {2};
      
      if (check( input, group1))	return 1;
      if (check( input, group2))	return 2;
      if (check( input, group3))	return 3;
         
      return 0;
    }
    public static boolean check( int input, int group[] ){
   
      for ( int n = 0; n < group.length; n++ ){
        if ( group[n] == input ){
         return true; 
        }
      }
      return false;
    }
}

Measured memory_bytes: 21584
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    cnt4 = 0
    cnt2 = 0
    _cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt4 += 1
            continue
        if a % 2 == 0:
            cnt2 += 1
            continue
        _cnt += 1
    if cnt2 > 0 and cnt2 % 2 != 0:
        cnt2 -= 1
        _cnt += 1
    print("Yes" if cnt4+1 >= _cnt else "No")




if '__main__' == __name__:
    resolve()

Measured memory_bytes: 62704
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n,p;
    while (cin >> n >> p) {
        if(n == 0 && p == 0)return 0;
        vector<int> peo(n);
        int i = 0;
        int ans = p;
        while(1){
            if(p == 0){
                p = peo.at(i%n);
                peo.at(i%n) = 0;
            }else{
                peo.at(i%n)++;
                p--;
            }
            if(peo.at(i%n) == ans){
                cout<<i%n<<endl;
                break;
            }
            i++;
        }
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    s = min({s,2*h,4*q});
    if(2*s <= d){
        cout << n*s << endl;
    }else{
        cout << (n/2)*d + (n%2)*s << endl;
    }
    return 0;
}

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

int main(){
  double A, B, C;
  int inC;
  
  cin >> A >> B;
  C = (A + B) / 2.0;
  inC = C;
  if(inC < C){
    inC = inC + 1;
  }
  cout << inC << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		int pos = buf.find("Hoshino");
		while(true){
			pos = buf.find("Hoshino", pos);
			if(pos == std::string::npos){ break; }
			buf[pos + 6] = 'a';
			pos += 6;
		}
		std::cout << buf << std::endl;
	}


#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}



Measured memory_bytes: 3056
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	int N;
	cin >>N>> S;
	int L = S.size();
	for (int i = 0; i < L; ++i) {
		int a=S[i]+N;
		if (a > 90) {
			a = a - 26;
		}
		cout << char(a);
	
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 998244353;
constexpr long long inf = 3e18;

template<typename Monoid,typename OperatorMonoid,typename F,typename G,typename H>
struct Segtree{
	int size=1;
	vector<Monoid>dat;
	vector<OperatorMonoid>lazy;
	const F f;
	const G g;
	const H h;
	Monoid M;
	OperatorMonoid OM;
	void set(int a,Monoid x){
		dat[a+size-1]=x;
	}
	void init(){
		for(int i=size-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	void eval(int k,int l,int r){
		if(lazy[k]!=OM){
			dat[k]=g(dat[k],lazy[k],(r-l));
			if(r-l>1){
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			lazy[k]=OM;
		}
	}
	void update(int a,int b,OperatorMonoid M,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=h(lazy[k],M);
			eval(k,l,r);
			return;
		}
		update(a,b,M,k*2+1,l,(l+r)/2);
		update(a,b,M,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return M;
		if(a<=l&&r<=b)return dat[k];
		Monoid lv=query(a,b,k*2+1,l,(l+r)/2);
		Monoid rv=query(a,b,k*2+2,(l+r)/2,r);
		return f(lv,rv);
	}
	template<class C>
	int minLeft(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int lv=minLeft(a,b,check,x,k*2+1,l,(l+r)/2);
		if(lv!=-1)return lv;
		return minLeft(a,b,check,x,k*2+2,(l+r)/2,r);
	}
	template<class C>
	int maxRight(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int rv=maxRight(a,b,check,x,k*2+2,(l+r)/2,r);
		if(rv!=-1)return rv;
		return maxRight(a,b,check,x,k*2+1,l,(l+r)/2);
	}
	Segtree(int x,F f,G g,H h,Monoid M,OperatorMonoid OM)
	:f(f),g(g),h(h),M(M),OM(OM){
		while(size<x)size*=2;
		dat.resize(size*2-1,M);
		lazy.resize(size*2-1,OM);
	}
};

auto f=[](int a,int b)->int{return (a+b)%mod;};
auto g=[](int a,P b,int sz)->int{return (a*b.first+b.second*sz)%mod;};
auto h=[](P a,P b)->P{return P(a.first*b.first%mod,(a.second*b.first+b.second)%mod);};

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;
	cin>>N>>Q;
	Segtree<int,P,decltype(f),decltype(g),decltype(h)>segtree(N,f,g,h,0,P(1,0));
	rep(i,N){
		int a;cin>>a;
		segtree.set(i,a);
	}
	segtree.init();
	while(Q--){
		int t;cin>>t;
		if(!t){
			int l,r,b,c;cin>>l>>r>>b>>c;
			segtree.update(l,r,P(b,c));
		}else {
			int l,r;cin>>l>>r;
			cout<<segtree.query(l,r)<<"\n";
		}
	}
}

Measured memory_bytes: 27724
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  int n,sum=0;
  int b[105],a[105]={};

  cin>>n;

  for(int i=0; i<n-1; i++){
    cin>>b[i];
  }
  a[0]=b[0];
  a[1]=b[0];
  for(int i=1; i<n-1; i++){
    a[i]=min(a[i],b[i]);
    a[i+1]=b[i];
  }

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


  cout<<sum<<'\n';

  return 0;
}


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

int main(){
    int n, A[45];
    cin >> n;
    A[0] = 1;
    A[1] = 1;
    for(int i = 2; i <= n; i++) A[i] = A[i-1] + A[i-2];
    cout << A[n] << endl;
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;
            bool ok = false;
            for(int i = 0; i < n; i++)
            {
                int[] In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (In[0] == In[1]) cnt++;
                else cnt =0;
                if (cnt == 3) ok = true;
            }
            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28264
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<char> p(n);
  REP(i,n) cin >> p[i];
  
  vector<char> q(n);
  REP(i,n) cin >> q[i];
  
  vector<int> v(n);
  REP(i, n) v[i] = i + 1;

  vector<string> s;

  int j = 0;
  do{
    s.push_back("");
    REP(i, n) s[j] += to_string(v[i]);
    j++;
  }while(next_permutation(v.begin(), v.end()));

  sort(s.begin(), s.end());
  string sp = "", sq = "";
  REP(i, n){
    sp += p[i];
    sq += q[i];
  }

  int a, b;
  REP(i, s.size()){
    if(s[i] == sp){
      a = i + 1;
    }
    if(s[i] == sq){
      b = i + 1;
    }
  }

  cout << abs(a - b) << endl;

  return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define foi for(int i=0; i<n; i++)
#define foj for(int j=0; j<n; j++)
#define ll long long int
#define vi vector<int>
#define maxn 200005
#define mod 1000000007
using namespace std;

int cnt[30];
char c;
int main() {
    int n;
    cin >> n;
    foi {
        cin >> c;
        cnt[c-'a']++;
    }
    ll ans=1;
    for (int i=0; i<26; i++) {
        ans=ans*(cnt[i]+1)%mod;
    }
    ans--;
    if (ans<0) ans+=mod;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256