akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int h, w;

bool v(int a, int b) {
	if (a < 0 || b < 0) return false;
	if (a >= h || b >= w) return false;
	return true;
}

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

int main() {
    
    
    cin >> h >> w;
    string arr[h];
    for (int i=0; i<h; i++) cin >> arr[i];
    for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			if (arr[i][j] == '.') {
				int co = 0;
				for (int k=0; k<8; k++) {
					int ik = i + dx[k];
					int jk = j + dy[k];
					if (v(ik, jk) && arr[ik][jk] == '#') co++; 
				}
				arr[i][j] = ((char) ('0' + co));
			}
		}
	}
	for (int i=0; i<h; i++) {
		cout << arr[i] << endl;
	}
	
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s, t; cin >> s >> t;
  int sn = s.size();
  string ans = "No";
  rep(i,sn) {
    if (s == t) ans = "Yes";
    s =  s.back() + s.substr(0,sn-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int a[101][101];

int main(void){
    int n,j,i;
    int u,k,t;
    
    
    
    scanf("%d",&n);
    
    for(i=1;j<=n;i++){
        for(j=1;j<=n;j++){
            a[i][j]=0;
        }
    }
    
    for(i=1;i<=n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
       for(j=1;j<=k;j++){
        scanf("%d",&t);
            a[i][t]=1;
        }
        
    }


    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            
            printf("%d",a[i][j]);
            if(j!=n)printf(" ");
        }
        printf("\n");
    }
    
    return 0;
}

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

using namespace std;

#define MAX_N 100
#define MAX_V 200
#define INF 1e9

int V,match[MAX_V];
vector<int> G[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int u = G[v][i],w = match[u];
    if(w < 0 || (!used[w] && dfs(w))){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0 ; v < V ; v++){
    if(match[v] < 0){
      memset(used,false,sizeof(used));
      if(dfs(v)){ res++; }
    }
  }
  return res;
}

int main(){
  int X,Y,E,x,y;
  cin >> X >> Y >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> x >> y;
    add_edge(x,X+y);
  }
  V = X+Y;
  cout << bipartite_matching() << endl;
  return 0;
}

Measured memory_bytes: 1344
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

const int MAXV=60;
const int MAXE=1e4;

struct Edge{
	int from;
	int to;
	Edge* next;
};
Edge E[MAXE];
Edge* head[MAXV];
Edge* prt[MAXV];
Edge* top=E;

int v;
int e;
int ans;
int clk;
int dfn[MAXV];
int low[MAXV];

void Tarjan(int,int);
void Insert(int,int);

int main(){
	int a,b;
	scanf("%d%d",&v,&e);
	for(int i=0;i<e;i++){
		scanf("%d%d",&a,&b);
		Insert(a,b);
		Insert(b,a);
	}
	Tarjan(1,0);
	printf("%d\n",ans);
	return 0;
}

inline void Insert(int from,int to){
	top->from=from;
	top->to=to;
	top->next=head[from];
	head[from]=top++;
}

void Tarjan(int root,int prt)
{
    dfn[root]=low[root]=++clk;
    for(Edge* i=head[root];i!=NULL;i=i->next){
    	if(dfn[i->to]==0){
    		Tarjan(i->to,root);
    		low[root]=std::min(low[root],low[i->to]);
    		if(dfn[root]<low[i->to])
    			ans++;
    	}
    	else if(dfn[i->to]<dfn[root]&&i->to!=prt)
    		low[root]=std::min(low[root],dfn[i->to]);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long k;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    bool visit[n]={};
    vector<int>start;
    vector<int>syuki;
    int p=0;//現在位置
    while(visit[p]==0){
        visit[p]=1;
        start.push_back(p);
        p=a[p];
    }
    int x=p;//周期スタート
    syuki.push_back(p);
    p=a[p];
    while(p!=x){
        syuki.push_back(p);
        p=a[p];
    }
    if(k<start.size())cout<<start[k]+1<<endl;
    else cout<<syuki[(k-start.size())%syuki.size()]+1<<endl;
    return 0;
}

Measured memory_bytes: 6428
s = input()
count = 0
for i in range(len(s)):
    if (i+1) % 2 != 0 and (s[i] == 'R' or s[i] == 'U' or s[i] == 'D'):
        count += 1
    elif (i+1) % 2 == 0 and (s[i] == 'L' or s[i] == 'U' or s[i] == 'D'):
        count += 1
if count == len(s):
    print('Yes')
else:
    print('No') 

Measured memory_bytes: 3064
import collections

n = int(input())
a = list(map(int, input().split()))

b = [0] * n
c = [0] * n
for i in range(n):
  b[i] = a[i] + (i + 1)
  c[i] = (i + 1) - a[i]

ans = 0
cCc = collections.Counter(c)
# print(cCc)
for k, v in collections.Counter(b).items():
  if v != 0 and k in cCc:
    # print(k,v,cCc[k])
    ans += v * cCc[k]

print(ans)


Measured memory_bytes: 63320
S = input()

even = 0
odd = 0
l = S.index('L')
r = S.index('R')
ans = [0] * len(S)

for i in range(len(S) - 1):
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
    if S[i] == 'R' and S[i + 1] == 'L':
        l = i
        r = i + 1
        if i % 2 == 0:
            ans[i] += even
            ans[i + 1] += odd
        else:
            ans[i] += odd
            ans[i + 1] += even
        even = 0
        odd = 0
    elif S[i] == 'L' and S[i + 1] == 'R':
        if l % 2 == 0:
            ans[l] += even
            ans[l + 1] += odd
        else:
            ans[l] += odd
            ans[l + 1] += even
        even = 0
        odd = 0


if (len(S) - 1 - l) % 2 == 0:
    ans[l] += 1
else:
    ans[r] += 1

if l % 2 == 0:
    ans[l] += even
    ans[l + 1] += odd
else:
    ans[l] += odd
    ans[l + 1] += even

print(' '.join(map(str, ans)))

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

bool judge(string x){
    int n=(int)x.size();
    for(int i=0;n-1>i;i++){
        
        if(x[i]!=x[n-1-i]){
            return false;
        }
    }
    return true;
}

int main(){
    
    string s,t,u;
    cin >> s;
    int n=(int)s.size();
    
    for(int i=0;(n-2)/2+1>i;i++){
        
        t+=s[i];
    }
    
    for(int i=(n+2)/2;n>i;i++){
           
           u+=s[i];
       }
    
    if(judge(s)&&judge(t)&&judge(u)){
        
        cout << "Yes"<< endl;
    }
    
    else{
        
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vpint sho[15];
	int A[15];
	scan(N);
	rep(i,N){
		scan(A[i]);
		rep(j,A[i]){
			int x,y;
			scan(x>>y);
			x--;
			sho[i].push_back({x,y});
		}
	}
	int bitall=(1<<N);
	int ans=0;
	rep(bit,bitall){
		int flag=1;
		bool truth[15]={};
		int cnt=0;
		rep(i,N){
			if((bit>>i)&1){
				truth[i]=1;
				cnt++;
			}
		}
		rep(i,N){
			if(truth[i]){
				rep(j,sho[i].size()){
					int x=sho[i][j].first,y=sho[i][j].second;
					if(truth[x]!=y) flag=0;
				}
			}
		}
		if(flag) ans=max(ans,cnt);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] w = new int[n];
		for(int i=0;i<n;i++) w[i] = in.nextInt();
		int s1 = w[0];
		int s2 = 0;
		for(int i=1;i<n;i++) s2 += w[i];
		int ans = Math.abs(s1-s2);
		for(int i=1;i<n-1;i++) {
			s1 += w[i];
			s2 -= w[i];
			ans = Math.min(ans, Math.abs(s1-s2));
		}
		System.out.println(ans);
		
		
		in.close();

	}

}


Measured memory_bytes: 23892
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k,*ppp = get_all_int()

sum_ = sum(ppp[:k])
maxs = sum_
maxt = 0

tail = 0
while tail+k < len(ppp):
    sum_ -= ppp[tail]
    sum_ += ppp[tail+k]
    tail += 1
    if sum_ > maxs:
        maxs = sum_
        maxt = tail

ans = 0
for p in ppp[maxt:maxt+k]:
    ans += (p+1)/2

print(ans)

Measured memory_bytes: 78876
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }

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

	map<int, int> m;

	repeat(i, N) {
		int n;
		cin >> n;
		m[n] = i+1;
	}

	for(auto it: m) {
		cout << it.second << endl;
	}
	
	return 0;
}


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

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

	int A[30][30];
	vector<int> K(N);

	for (int i = 0; i < N; i++) {
		cin >> K.at(i);
		for (int j = 0; j < K.at(i); j++) {
			cin >> A[i][j];
		}
	}
	bool flag = true;
	int ans = 0;

	for (int i = 1; i <= M; i++) {
		flag = true;
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < K.at(j); k++) {
				if (A[j][k] == i) {
					//cout << "A" << j << k << "==" << i << endl;
					break;
				}
				if (k==K.at(j)-1) {
					flag = false;
				}
			}
			if (flag == false)break;

			if (j == N - 1) {
				ans++;
			}
		}

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

Measured memory_bytes: 256
n = int(input())
a = tuple(map(int, input().split()))
occur = [0 for i in range(n + 1)]
MOD = 1000000007
for i in range(n + 1):
    if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]]
    else: occur[a[i]] = i + 1
inv = [0 if i > 2 else 1 for i in range(n + 2)]
pinv = [0 if i > 2 else 1 for i in range(n + 2)]
perm = [0 if i > 2 else 1 for i in range(n + 2)]
for i in range(2, n + 2):
    inv[i] = -int(MOD / i) * inv[MOD % i] + MOD
    pinv[i] = pinv[i - 1] * inv[i] % MOD
    perm[i] = perm[i - 1] * i % MOD
def C(n, m):
    return (perm[m] * pinv[n] % MOD) * pinv[m - n] % MOD if n <= m else 0
for i in range(1, n + 2):
    temp = C(i, n + 1) - C(i - 1, val)
    if temp < 0: temp += MOD
    print(temp)


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

int main()
{
        int a[102][102];
        int cost[102][102];
        for (int i = 0; i < 102; ++i) {
                for (int j = 0; j < 102; ++j) {
                        a[i][j] = -1;
                }
        }
        int H, W;
        cin >> H >> W;
        for (int i = 1; i <= H; ++i) {
                std::string s;
                cin >> s;
                for (int j = 1; j <= W; ++j) {
                        a[i][j] = s[j-1] == '.' ? 0 : 1;
                }
        }
        for (int i = 1; i <= H; ++i) {
                for(int j = 1; j <= W; ++j) {
                        if (i == 1 && j == 1) {
                                cost[i][j] = a[i][j];
                                continue;
                        }
                        if (a[i-1][j] == -1) {
                                cost[i][j] = cost[i][j-1] + (a[i][j-1] == 0 && a[i][j] == 1);
                        }
                        else if (a[i][j-1] == -1) {
                                cost[i][j] = cost[i-1][j] + (a[i-1][j] == 0 && a[i][j] == 1);
                        }
                        else {
                                int t = cost[i][j-1] + (a[i][j-1] == 0 && a[i][j] == 1);
                                int y = cost[i-1][j] + (a[i-1][j] == 0 && a[i][j] == 1);
                                cost[i][j] = (t < y) ? t : y;
                        }

                }
        }
        cout << cost[H][W] << endl;

}


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

    using namespace std;

    int main() {
        string s;
        cin >> s;
        bool valid = true;
        if (s[0] != 'A') valid = false;
        int C_cnt = 0;
        for (int i = 2; i + 1 < s.length(); i++) {
            if (s[i] == 'C') {
                C_cnt++;
            }
        }
        if (C_cnt != 1) valid = false;
        C_cnt = 0;
        int A_cnt = 0;
        for (char c: s) {
            if (c == 'A') {
                A_cnt++;
            }
            else if (c == 'C') {
                C_cnt++;
            }
            else if (isupper(c)) {
                valid = false;
                break;
            }
        }
        if (A_cnt != 1 or C_cnt != 1) valid = false;
        if (valid) {
            cout << "AC";
        }
        else {
            cout << "WA";
        }
        return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int h, r;

  scanf("%d%d", &h, &r);
  if(h+r > 0){
    printf("1\n");
  }else if(h+r < 0){
    printf("-1\n");
  }else{
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

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

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

  int n, k;
  cin >> n >> k;

  if((n - 1) * (n - 2) / 2 < k){
    cout << -1 << endl;
    return 0;
  }

  vector< pii > edges;
  for(int i = 1; i <= n - 1; i++){
    edges.push_back(make_pair(0, i));
  }

  int c = ((n - 1) * (n - 2) / 2) - k;
  int count = 0;
  for(int i = 1; i <= n - 1 && count < c; i++){
    for(int j = i + 1; j <= n - 1 && count < c; j++){
      edges.push_back(make_pair(i, j));
      ++count;
    }
  }

  string buf = to_string(edges.size()) + "\n";
  for(pii edge: edges){
    buf += to_string(edge.first + 1) + " " + to_string(edge.second + 1) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ng := make(map[int]bool)
	var d int
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		ng[d] = true
	}

	for i := n; i <= 100000; i++ {
		ok := true
		s := strconv.Itoa(i)
		for j := 0; j < len(s); j++ {
			d := int(s[j] - '0')
			if ng[d] {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println(i)
			return
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  
  int min_num = P.at(0);
  int count = 1;
  for (int i = 0; i < N; i++) {
    if (min_num > P.at(i)) {
      min_num = P.at(i);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<set>
#include<utility>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<cinttypes>
#include<stack>
using namespace std;

typedef long long ll;


#define ceil(a,b)  ( !(a%b) ? a/b : a/b+1 )
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define endl '\n' 
#define debug(a) cin>>#a>>a;
//vector<ll> primes{ }

int gcd( int a, int b ) { return !a ? b : gcd( b%a, a); }
int lcm( int a, int b ) { return (a*b)/gcd(a,b); } 

int main(){
    int t;
    cin>>t;
    int c1,c2,c3,c4;
    c1=c2=c3=c4=0;
    while(t--){
        string s;
        cin>>s;
        if( s == "AC" )
            c1++;
        else if( s == "WA" )
            c2++;
        else if( s == "TLE" )
            c3++;
        else
            c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;    
}


Measured memory_bytes: 3624
// include
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<string>
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;


int main(void) {
	double n, k;
	ll ans;
	cin >> n >> k;
	ans = k * pow(k - 1, n - 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  std::cout << (B % A == 0 ? A + B : B - A) << std::endl;

  return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << 800 * n - 200 * (n / 15) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A') {
    cout << "No" << endl;
  } else if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B') {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using graph = vector<vector<char>>;

int main(){
  string s;cin>>s;
  ll n=s.size()+1;
  vector<ll> v(n,-1);
  
  rep(i,n){
    if(i==0&&s.at(0)=='<'){v[i]=0;}
    else if(i==n-1&&s.at(n-2)=='>'){v[i]=0;}
    if (i>0&&i<n-1){
      if(s.at(i-1)=='>' && s.at(i)=='<'){
      v[i]=0;
      }
    }
    
    if(v[i]==0){
      ll j=i;
      if(j<n-1){
        while(s.at(j)=='<'){
          v[j+1]=v[j]+1;j++;
          if(j==n-1){break;}
        }
      }
               
      j=i;
      if(j>0){
        while(s.at(j-1)=='>'){
          v[j-1]=v[j]+1;j--;
          if(j==0){break;}
        }
      }
    }
  }
  rep(i,n-2){
    
   if(s.at(i)=='<'&&s.at(i+1)=='>'){v[i+1]=max(v[i],v[i+2])+1;}
  }
  ll ans=0;
  rep(i,n)ans+=v[i];
  cout<<ans;

}




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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const ll INF = 1e10;


int main() {
    int Q; cin >> Q;
    priority_queue<ll> ql;
    priority_queue<ll, vll, greater<ll>> qr;

    ll x , m;
    ll qlsum = 0, qrsum = 0, bsum = 0;
    int type;

    rep(i, Q) {
        cin >> type;

        if (type == 2) {
            x = ql.top();
            m = bsum + (x * (ll)ql.size() - qlsum) + (qrsum - x * (ll)qr.size());
            cout << x << " " << m << endl;
            continue;
        }
        else {
            ll a, b; cin >> a >> b;
            bsum += b;

            if (i == 0) {
                ql.push(a); qlsum += a;
                continue;
            }

            if (ql.size() > qr.size()) {
                ll u = ql.top();
                if (a >= u) {
                    qr.push(a); qrsum += a;
                }
                else {
                    ql.pop(); ql.push(a); qlsum += a - u;
                    qr.push(u); qrsum += u;
                }
            }
            else {
                ll v = qr.top();
                if(a <= v){
                    ql.push(a); qlsum += a;
                }
                else{
                    qr.pop(); qr.push(a); qrsum += a - v;
                    ql.push(v); qlsum += v;
                }

            }


        }

    }

}




Measured memory_bytes: 3952
N, M = map(int, input().split())
A, B = [], []
dic = {i:[] for i in range(1, N+1)}
for _ in range(M):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)

node = [float('inf')] * N
node[0] = 0 #1までの距離
route = [0]*N #ランプ置く部屋
rooms = [1] #次調べる部屋
st = {1}

for r1 in rooms:
    for r2 in dic[r1]:
        if node[r1-1] + 1 <= node[r2-1]:
            node[r2-1] = node[r1-1] + 1
            route[r2-1] = r1
            if not r2 in st:
                rooms.append(r2)
                st.add(r2)
            try:
                dic[r2].remove(r1)
            except:
                continue

if float('inf') in node:
    print('No')
else:
    print('Yes')
    for i in route[1:]:
        print(i)


Measured memory_bytes: 48904
import Data.List

(|>) :: a -> (a -> b) -> b
infixl 1 |>
x |> f = f x

($>) :: (Functor m) => m a -> (a -> b) -> m b
infixl 1 $>
x $> f = fmap f x

calc :: [Int] -> Int
calc xs = let len = length xs
              num = xs !! 0
              in (if len >= num then len - num else len)

main = do
    n <- getLine
    ax <- getLine $> words $> map read :: IO [Int]
    ax |> sort |> group |> map calc |> sum |> print

Measured memory_bytes: 39548
#include <iostream>

using namespace std;

int a, b, c;

int main()
{
    cin >> a;
    cin >> b;
    cin >> c;
    
    if (a+b+c == 17)
    {
        if (a==5||a==7)
        {
            if (b==5||b==7)
            {
                if (c==5||c==7)
                {
                    cout << "YES\n";
                }
                else
                {
                    cout << "NO\n";
                }
            }
            else
            {
                cout << "NO\n";
            }
        }
        else
        {
            cout << "NO\n";
        }
        
    }
    else
    {
        cout << "NO\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
N,A = map(int,input().split())
X = list(map(int, input().split()))

for i in range(N):
    X[i] -= A

dp = [[0 for _ in range(100*N+1)] for _ in range(N+1)]
dp[0][50*N] = 1

for i in range(1,N+1):
    for summ in range(2*50*N+1):
        if 0 <= summ-X[i-1] <= 100*N:
            dp[i][summ] = dp[i-1][summ] + dp[i-1][summ-X[i-1]]
        else:
            dp[i][summ] = dp[i-1][summ]
            
print(dp[N][50*N]-1)

Measured memory_bytes: 5744
#include <stdio.h>

int main(){
  char S[1000];
  char s[2] = "s";
  char es[3] = "es";
  int i=0;
  scanf("%s",S);
  
  while(S[i++] != 0);

  if(S[i-2] == 's'){
  	printf("%s%s\n",S,es);
  }else{
    printf("%s%s\n",S,s);
  }
  return 0;
}

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

int main(){
  int imp;
  int cord;
  int sum;
  
  cin >> imp >> cord;
  if(imp == 1){
    sum = sum + 300000;
  }
  else if(imp == 2){
    sum = sum + 200000;
  }
  else if(imp == 3){
    sum = sum + 100000;
  }
    if(cord == 1){
    sum = sum + 300000;
  }
  else if(cord == 2){
    sum = sum + 200000;
  }
  else if(cord == 3){
    sum = sum + 100000;
  }
  
  if(imp + cord == 2){
    sum = sum + 400000;
    }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;cin>>N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i]>>h[i];
  }
  int CX=0,CY=0,AH=0;
  for(int cx=0;cx<=100;cx++){
    for(int cy=0;cy<=100;cy++){
      int H=0;
      for(int i=0;i<N;i++){
        if(h[i]==0)continue;
        H=abs(x[i]-cx)+abs(y[i]-cy)+h[i];
        if(H>100)break;
        break;
      }
      bool ok=true;
      for(int i=0;i<N;i++){
        if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0)){
          ok=false;
        }
      }
      if(ok){
        AH=H;
        CX=cx;CY=cy;
      }
    }
  }
  cout<<CX<<" "<<CY<<" "<<AH<<endl;
}


Measured memory_bytes: 3624
H,W = map(int,input().split())
S = [input() for i in range(H)]
T = [[0 for i in range(W)] for j in range(H)]
# print(S)
# print(T)
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            T[i][j]="#"
            for il in range(max(0,i-1),min(i+1,H-1)+1):
                for jl in range(max(0, j-1), min(j+1, W-1)+1):
                    # print(i,j,il,jl)
                    if S[il][jl] is not "#":
                        T[il][jl]+=1


for i in range(H):
    print(''.join(map(str, T[i])))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int a,b,c,d[100];

int main(){
	for(int i=0;i<100;i++){
		d[i]=0;
	}
	cin >> a >> b >> c;
	for(int i=0;1;i++){
		d[(a*i)%b]+=1;
		if((a*i)%b==c){
			cout << "YES" << endl;
			return 0;
		}
		for(int i=0;i<100;i++){
			if(d[i]==2){
				cout << "NO" << endl;
				return 0;
			}
		}
	} 
	return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin>>N;
    for(int i=0;i<3;i++){
        int a;
        a=N%10;
        if(a==7){
            cout<<"Yes"<<endl;
            exit(0);
        }
        N/=10;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt = 0, ele;
    for(int i = 1;i <= n;i ++) {
        cin >> ele;
        if(i % 2 == 1 && ele % 2 == 1) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
A,B,K = map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

AAA =make_divisors(A)
BBB =make_divisors(B)

CCC = []

for i in range(len(AAA)):
    if AAA[i] in BBB:
        CCC.append(AAA[i])

CCC = sorted(CCC,reverse=True)
#print(CCC)
print(CCC[K-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=22,mod=1e9+7;
ll a[inf][inf],n,dp[(1<<inf)];

int solve(int pos,int mask){
    if(pos==n)
        return 1;

    ll &ret=dp[mask];
    if(ret!=-1)
        return ret;

    ret=0;
    for(int i=0;i<n;i++){
        if( ((1ll<<i)&mask) || (a[pos][i]==0) )
            continue;

        ret=(ret+solve(pos+1,mask|(1<<i)))%mod;
    }
    return ret;
}

int main(){
    cin>>n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];

    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0)<<endl;
}


Measured memory_bytes: 33024
#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

typedef long long LL;
const int maxn = 1e5+30;
int n, id=0, cnt=0, Next[maxn], in[maxn], out[maxn], son[maxn], zhong[maxn];
int msize = 0x3f3f3f3f, mid;
LL ans = 0;
struct node{int e, w, next;}edge[maxn<<1];
void add_edge(int u, int v, int w)
{
    edge[cnt] = {v, w, Next[u]};
    Next[u] = cnt++;
    edge[cnt] = {u, w, Next[v]};
    Next[v] = cnt++;
}
void dfs(int cur, int pre, int w)
{
    in[cur] = ++id;
    int imax = 0;
    for(int i=Next[cur]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].e;
        if(v == pre) continue;
        dfs(v, cur, edge[i].w);
        son[cur] += son[v] + 1;
        imax = max(imax, son[v]+1);
    }
    out[cur] = id;
    int imin = min(out[cur]-in[cur]+1, n-out[cur]+in[cur]-1);
    ans = ans + (LL)imin*w*2;
    imax = max(imax, n-1-son[cur]);
    zhong[cur] = imax;
    if(imax < msize)
    {
        msize = imax;
        mid = cur;
    }
}
int main()
{
	int i,j,k;
    memset(Next, -1, sizeof(Next));
    read(n);
    for(i=1; i<n; ++i)
    {
    	int a,b,c;
		read(a),read(b),read(c);
        add_edge(a, b, c);
    }
    dfs(1, 0, 0);
    int com = 0x3f3f3f3f;
    for(i=Next[mid]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].e;
        com = min(com, edge[i].w);
        if(zhong[v] == zhong[mid])
        {
            ans -= edge[i].w;
            print(ans),putc('\n');
            return 0;
        }
    }
    print(ans-com),putc('\n');
    return 0;
}


Measured memory_bytes: 15232
#include <stdio.h>
int main()
{
char s[100000];
int n,i,j,x,y;
scanf("%s",s);
for(i=0;1;i++){
if(s[i]=='\0'){n=i;break;}
}
x=0;y=0;
for(i=0;i<n;i+=2){
if(s[i]=='0') x++;
if(s[i+1]=='1') x++;
}
for(i=0;i<n;i+=2){
if(s[i]=='1') y++;
if(s[i+1]=='0') y++;
}
j=(x<y)?x:y;
printf("%d",j);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans=0;
    rep(i, n-1){
        for(int j=i+1; j<n; j++){
            ans += v[i]*v[j];
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
    //dp[i] denotes the minimum cost to reach ith stone
    // 0 < i < n - 1 are the stones
    //We are asked to dind the cost to reach last stone i.e dp[n - 1]
    //Initially there is infinite cost to reach ith stones
    vector<int> dp(n, INT_MAX);
  
    //To reach first stone there is no cost. SO dp[0] = 0
    dp[0] = 0;
   //To reach second stone the frog can jump from 0th stone costing dp[1] = abs(h[1] - h[0])
    dp[1] = abs(h[1] - h[0]);
    
    //For every other stones 2 <= i < n, the frog can jump from the (i - 1), (i - 2)...(i - k)th stones 
    for(int i = 2; i < n; i++){
      for(int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++){
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
      }
    }
    //Print minm cost to reach (n - 1)th stone
    cout << dp[n - 1];
    return 0;
}


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

// color -1: 未訪問, 0:白, 1:黒
void dfs(vector<vector<P>> &G, vector<int> &C, int v, int color){
    C[v] = color;
    for(auto pair : G[v]){
        if(C[pair.first] != -1) continue; // 訪問済
        dfs(G, C, pair.first, (pair.second % 2 == 0) ? color : (1 - color));
    }
}

int main(){
    int N; cin >> N;
    vector<vector<P>> graph(N);
    rep(i, N-1){
        int u, v, w;
        cin >> u >> v >> w;
        graph[u-1].push_back(P(v-1, w));
        graph[v-1].push_back(P(u-1, w));
    }

    vector<int> colors;
    colors.assign(N, -1);
    rep(i, N){
        if(colors[i] != -1) continue;
        dfs(graph, colors, i, 0);
    }
    rep(i, N) cout << colors[i] << endl;
}

Measured memory_bytes: 13060
#include<stdio.h>





int main(void){


 char str[1010];


int i,sum;





scanf("%s",str);


 while(str[0]!='0'){


 i=0; sum=0;


while(str[i]){


 sum+=str[i]-'0';i++;


}


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


scanf("%s",str);


}


return 0;


}

Measured memory_bytes: 536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n - 2; i++) {
            if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2])
                    || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
                count++;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 22608
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

bool check(string x)
{
    if (x.length()==1)
        return true;

    int sz = x.length();
    sz--;

    repa(i,0,sz)
        if (x[i]!=x[sz-i])
            return false;

    return true;
}

signed main()
{
    IOS;
    
    string s;
    cin>>s;

    string buf,temp;

    int lim = s.length()/2;

    for (int i=0; i<lim; i++)
        buf+=s[i];

    for (int i=lim+1; i<s.length(); i++)
        temp+=s[i];

    if (check(temp) && check(buf) && check(s))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}   

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


s=[]
d={}
total=0
for i in range(n):
  s.append(list(input()))
  s[i].sort()
  ssort=''.join(s[i])
  if ssort in d:
    total += d[ssort]
    d[ssort]+=1
  
  else:
    d[ssort]=1

print(total)

Measured memory_bytes: 36660
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= base;
	}
	return ans;
}



static void A_task();

#if 1
int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}
#endif

static void A_task()
{
	int A, B;
	get2int(A, B);

	printf("%d\n", std::max({ A + B, A - B, A * B }));
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a+b)%2 != 0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int dp[1005][1005] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string x, y;
		cin >> x >> y;
		for (int j = 0; j < 1005; j++)
			for (int k = 0; k < 1005; k++) dp[j][k] = 0;
		for (int j = 1; j <= x.size(); j++) {
			for (int k = 1; k <= y.size(); k++) {
				dp[j][k] = max(dp[j][k - 1], dp[j - 1][k]);
				if (x[j - 1] == y[k - 1]) {
					dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + 1);
				}
			}
		}
		cout << dp[x.size()][y.size()] << endl;
	}
	return 0;
}


Measured memory_bytes: 7112
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;



int main(void){
    ll a;
    long double b;
    cin >> a >> b;
    ll x=b*100+.5;
    cout << (a*x)/100;

    return 0;
}

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

int main() {
	int n; scanf("%d%*c", &n);
	rep(i, n) {
		string s; getline(cin, s);
		regex re("Hoshino");
		cout << regex_replace(s, re, "Hoshina") << endl;
	}
}



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


int main(){
  int a,b;
  cin >> a >> b;
  int sa=b-a;
  int s=0;
  for(int i=1;i<sa;++i){
    s+=i;
  }
  cout << s-a << endl;
  return 0;
}


Measured memory_bytes: 3600
h, w = gets.split.map(&:to_i)
board = []
possibility = true

h.times do
  board << gets.chomp.split("")
end

h.times do |i|
  if possibility && i != h - 1
    rightest_trace = w - board[i].reverse.index("#") - 1
    next_leftest_trace = board[i + 1].index("#")
    possibility = false unless next_leftest_trace == rightest_trace
  end
end

puts possibility ? "Possible" : "Impossible"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X>> Y;
    
    if(X < Y){
        swap(X,Y);swap(A,B);
    }
    
    int ans = A*X+B*Y;
    
    ans = min(ans, C*Y*2 + A*(X-Y));
    
    ans = min(ans, C*2*X);
    
    

    out(ans);


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    long long K;
    cin >> N >> K;
    vector<pair<int, int> > pairVec;
    REP(i,N){
        int a,b;
        cin >> a >> b;
        pairVec.push_back(make_pair(a,b));
    }
    sort(pairVec.begin(),pairVec.end());
    REP(i,N){
        K-=pairVec[i].second;
        if(K<=0){
            cout << pairVec[i].first << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1400
from math import *

def trycut(val):
	if val == 0 : return float('inf')
	ret = 0
	for i in range(n):
		ret += ceil(a[i]/val)-1
	return ret 

n,k=map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 1000000000
ans  =-1

while low <= high:
	mid = (low + high)//2
	cut = trycut(mid)
	if cut <= k:
		high = mid-1
		ans = mid
	else:
		low =  mid+1
print(ans)




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

int main(){
    int x, y;
    cin >> x >> y; x--; y--;
    vector<int> z = {300000, 200000, 100000};
    int ans = 0;
    if (x < 3) ans += z[x];
    if (y < 3) ans += z[y];
    if (x == 0 && y == 0) ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 10**9+7
class mint:
    def __init__(self, x):
        self.x = x % MOD if isinstance(x, int) else int(x) % MOD
    def __str__(self):
        return str(self.x)
    __repr__ = __str__
    def __iadd__(self, other):
        self.x += other.x if isinstance(other, mint) else other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __isub__(self, other):
        self.x += MOD-other.x if isinstance(other, mint) else MOD-other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __imul__(self, other):
        self.x *= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __imod__(self, other):
        self.x %= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __add__(self, other):
        return (
            mint(self.x + other.x) if isinstance(other, mint) else
            mint(self.x + other)
        )
    def __sub__(self, other):
        return (
            mint(self.x - other.x) if isinstance(other, mint) else
            mint(self.x - other)
        )
    def __mul__(self, other):
        return (
            mint(self.x * other.x) if isinstance(other, mint) else
            mint(self.x * other)
        )
    def __mod__(self, other):
        return (
            mint(self.x % other.x) if isinstance(other, mint) else
            mint(self.x % other)
        )
    def __truediv__(self, other):
        return (
            mint(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(self.x * pow(other, MOD - 2, MOD))
        )
    def __pow__(self, other):
        return (
            mint(pow(self.x, other.x, MOD)) if isinstance(other, mint) else
            mint(pow(self.x, other, MOD))
        )
    __radd__ = __add__
    def __rsub__(self, other):
        return (
            mint(other.x - self.x) if isinstance(other, mint) else
            mint(other - self.x)
        )
    __rmul__ = __mul__
    def __rmod__(self, other):
        return (
            mint(other.x % self.x) if isinstance(other, mint) else
            mint(other % self.x)
        )
    def __rtruediv__(self, other):
        return (
            mint(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(other * pow(self.x, MOD - 2, MOD))
        )
    def __rpow__(self, other):
        return (
            mint(pow(other.x, self.x, MOD)) if isinstance(other, mint) else
            mint(pow(other, self.x, MOD))
        )
n,k = map(int, input().split())
ansls = [mint(0) for _ in range(k+1)]

for i in reversed(range(1,k+1)):
    ansls[i] = mint(pow(k//i, n, MOD))
    for j in range(2*i,k+1,i):
        ansls[i] -= ansls[j]

ans = mint(0)
for i in range(k+1):
    ans += ansls[i]*i

print(ans)



Measured memory_bytes: 82628
#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> v;
long long ans=0;
long long sti(int l,int r){
	long long sum=0;
	for(int i=l;i<=r;i++){
		sum=sum*10+s[i]-'0';
	}
	return sum;
}
void dfs(){
	if(v.size()+1==s.size()){
		long long l=0,sum=0;
		for(int i=0;i<s.size()-1;i++){
			if(v[i]==1){
				sum+=sti(l,i);
				l=i+1;
			}
		}
		sum+=sti(l,s.size()-1);
		//cout<<sum<<endl;
		ans+=sum;
	}else{
		v.push_back(0);
		dfs();
		v.pop_back();
		v.push_back(1);
		dfs();
		v.pop_back();
	}
}
int main(){
	cin>>s;
	dfs();
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=320,M=N*N,mo=998244353;

int n,a[N];
ll f[M],g[M];

int main()
{
	scanf("%d",&n);
	int zh=0;
	fo(i,1,n)scanf("%d",&a[i]),zh=zh+a[i];
	int ha=(zh+1)>>1;
	int lj=0;
	f[0]=g[0]=1;
	fo(i,1,n){
		lj=lj+a[i];
		fd(l,lj,a[i])f[l]=(f[l]*2+f[l-a[i]])%mo,g[l]=(g[l]+g[l-a[i]])%mo;
		fd(l,a[i]-1,0)f[l]=f[l]*2%mo;
	}
	ll ans=0;
	fo(l,ha,zh)ans=(ans+f[l])%mo;
	ll zg=1;
	fo(i,1,n)zg=zg*3%mo;
	ans=(mo+zg-ans*3%mo)%mo;
	if(ha*2==zh)ans=(ans+3*g[ha])%mo;
	cout<<ans;
}

Measured memory_bytes: 1664