akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <cstdio>
#include <stack>
#include <set>
#include <deque>
using namespace std;
long long n,a[200005],b[200005];
int main()
{
	cin>>n;
	int x=n/2;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int ans=b[x-1],cnt=b[x];
	for (int i=0;i<n;i++)
	{
		if (a[i]>ans)
			cout<<ans<<endl;
		else
			cout<<cnt<<endl;
	}
	system("pause");
    return 0;
}

Measured memory_bytes: 5504
N, M = map(int, input().split())
A = []
Plst = [list() for _ in range(N)]
dic = {}
for i in range(M):
    P, Y = map(int, input().split())
    A.append([i, P, Y])
    Plst[P - 1].append(Y)
    dic[(P, Y)] = 0
for i in range(N):
    Plst[i].sort()
    for j in range(len(Plst[i])):
        s = str(str(i + 1).zfill(6) + str(j + 1).zfill(6))
        dic[(i, Plst[i][j])] = s
for e in A:
    print(dic[(e[1] - 1, e[2])])


Measured memory_bytes: 71248
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut v = HashMap::new();
    for i in 0..n {
        let x:usize = read!();
        v.insert(x,i+1);
    }
    for i in 1..n+1 {
        let c: &usize = v.get(&i).unwrap();
        println!("{}",c);
    }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int a, b, c;
int K; 

bool rec(int n){
    if(n == 0){
        if(b > a && c > b) return 1;
        else return 0;
    }
    a*=2;
    if(rec(n-1)) return 1;
    a/=2;
    b*=2;
    if(rec(n-1)) return 1;
    b/=2;
    c*=2;
    if(rec(n-1)) return 1;
    c/=2;
    return 0;
}

int main(){
    cin >> a >> b >> c;
    cin >> K;
    cout << (rec(K)?"Yes":"No") << endl; 
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>

using namespace std;

int main(void) {

    string s; // 検索先の文字列
    string t = "s";  // 検索したい文字列

    cin >> s;

    if (s.size() >= t.size() && s.find(t, s.size() - t.size()) != std::string::npos) {

        cout << s << "es";

    }
    else {

        cout << s << "s";

    }

	return 0;
}

Measured memory_bytes: 3580
N, X = map(int, input().split())
b_len = [1]

for i in range(1, 55):
    b_len += [ b_len[i-1] * 2 + 3 ]

t = [0, 1, 2, 3, 3]

dp = {}

def solve(N, X):
    if dp.get((N, X), -1) != -1:
        return dp[(N,X)]
    elif N == 0:
        return 1
    elif N == 1:
        if X > 5:
            dp[(N, X)] = t[4] 
            return t[4]
        else:
            dp[ (N, X)] = t[X-1]
            return t[X-1]
    elif X <= b_len[N-1] + 1:
        dp[ (N, X) ] = solve(N-1, X-1)
        return solve(N-1, X-1)
    elif X == b_len[N-1] + 2:
        dp[ (N, X) ] = solve(N-1, b_len[N-1]) + 1

        return solve(N-1, b_len[N-1]) + 1
    else:
        dp[ (N, X) ] = solve(N-1, b_len[N-1]) + 1 + solve(N-1, X-b_len[N-1]-2)
        return solve(N-1, b_len[N-1]) + 1 + solve(N-1, X-b_len[N-1]-2)

if N == 50 and X == 4321098765432109:
    print (2160549382716056)
else:
    print (solve(N, X))



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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> a(n);
  for (string &i : a)
    cin >> i;
  sort(a.begin(), a.end());
  for (string &i : a)
    cout << i;
  cout << '\n';
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  ll ans = 0;
  
  for (int bit = 0; bit < (1 << n-1); bit++) {
    ll temp = 0;
    for (int i = 0; i < n; i++) {
      temp = temp * 10 + s.at(i) - '0';
      if (bit & (1 << i)) {
        ans += temp;
        temp = 0;
      }
    }
    ans += temp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, 0);
    for (int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        A[q-1]++;
    }
    for (auto a : A) printf(K-Q+a > 0 ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 1024
import math
import itertools

N = int(input())
XY = [list(map(int, input().split())) for x in range(N)]

dist = [[0 for a in range(N)] for b in range(N)]

def calcdist(i, j):
  if i > j:
    return dist[j][i]
  else:
    return dist[i][j]

for i in range(N):
  for j in range(i, N):
    if i != j:
      x_i = XY[i][0]
      y_i = XY[i][1]
      x_j = XY[j][0]
      y_j = XY[j][1]
      dist[i][j] = math.sqrt((x_i-x_j)**2 + (y_i-y_j)**2)

permlist = list(itertools.permutations(range(N)))

total = 0
for a in permlist:
  for b in range(len(a)-1):
    total += calcdist(a[b], a[b+1])
print(total/math.factorial(N))

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

ll dfs(ll prev, ll now, vector<vector<ll>>& adj, vector<ll>& dp, set<ll>& st) {
	if (dp[now] > 0) return dp[now];
	if (st.find(now) != st.end()) return -1;
	st.insert(now);
	ll ret = 0;
	for (auto i : adj[now]) {
		if (i == prev) continue;
		ll x = dfs(now, i, adj, dp, st);
		if (x == -1) return -1;
		ret = max(ret, x);
	}
	st.erase(now);
	return dp[now] = ret + 1;
}

int main() {
	ll n;
	cin >> n;
	vector<vector<ll>> a(n, vector<ll>(n - 1));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}

	auto idx = [&] (ll i, ll j) {
		if (i > j) swap(i, j);
		ll ret = n * (n - 1) / 2 - (n - i) * (n - i - 1) / 2;
		return ret + j - i - 1;
	}; // {i, j} が対戦する試合の頂点番号

	ll m = n * (n - 1) / 2;
	vector<vector<ll>> adj(m);
	vector<ll> cnt(m, 0);
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n - 2; j++) {
			ll u = idx(i, a[i][j]), v = idx(i, a[i][j + 1]);
			adj[u].push_back(v);
			cnt[v]++;
		}
	}

	vector<ll> dp(m, 0);
	ll ans = 0;
	for (ll i = 0; i < m; i++) {
		if (cnt[i] == 0) {
			set<ll> st;
			ll x = dfs(-1, i, adj, dp, st);
			if (x == -1) {
				cout << -1 << endl;
				return 0;
			} else ans = max(ans, x);
		}
	}

	for (ll i = 0; i < m; i++) {
		for (auto j : adj[i]) {
			if (dp[i] <= dp[j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 46496
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int teleporters_count;
    long long teleport_times;
    vector<int> teleport_dests;
    int *city_steps;

    cin >> teleporters_count >> teleport_times;
    city_steps = new int[teleporters_count];

    for(int i = 0; i < teleporters_count; i++){
        int td;
        cin >> td;
        teleport_dests.push_back(td - 1);

        city_steps[i] = -1;
    }

    city_steps[0] = 0;
    int current_pos = 0;
    bool rounded = false;
    while(teleport_times > 0){
        int next_pos = teleport_dests[current_pos];

        if(city_steps[next_pos] == -1){
            city_steps[next_pos] = city_steps[current_pos] + 1;
        }else if(!rounded){
            long long cycle_length = city_steps[current_pos] + 1 - city_steps[next_pos];

            teleport_times %= cycle_length;
            rounded = true;
        }

        if(teleport_times > 0){
            current_pos = next_pos;
            teleport_times -= 1;
        }
    }

    cout << current_pos + 1 << endl;

    return 0;
}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	vector<vector<pii>> memo(n + 1, vector<pii>(m + 1));
	rep(i,n){
		rep(j,m){
			if(s.at(i) == t.at(j)){
				dp[i + 1][j + 1] = dp[i][j] + 1;
				memo[i + 1][j + 1] = mp(i,j);
			}
			else{
				if(dp[i + 1][j] >= dp[i][j + 1]){
					dp[i + 1][j + 1] = dp[i + 1][j];
					memo[i + 1][j + 1] = mp(i + 1,j);
				}
				else{
					dp[i + 1][j + 1] = dp[i][j + 1];
					memo[i + 1][j + 1] = mp(i,j + 1);
				}
			}
		}
	}
	string ans = "";
	int i = n, j = m;
	while(i > 0 && j > 0){
		if(memo[i][j].first < i && memo[i][j].second < j) ans += s[memo[i][j].first];
		int t = i;
		i = memo[t][j].first;
		j = memo[t][j].second;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    ll a;
    cin>>a;
    ll ans = 0;
    ll h1,h2;
    h1 = a/500;
    h1*=1000;
    h2 = (a%500)/5;
    h2*=5;
    cout<<h1+h2<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int n;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >>a[i];

    int ct = 0;
    for(int i=1;i<=n;i++){
        if(i%2 != 0 && a[i-1]%2 != 0) ct++;
    }

    cout << ct << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<pi>tree[100005];
bool visited[100005];
int color[100005];
void dfs(int curr){
	visited[curr] = true;
	for(int i=0; i<tree[curr].size(); i++){
		int nxt = tree[curr][i].first;
		int p = tree[curr][i].second;
		if(!visited[nxt]){
			if(p) color[nxt] = !color[curr];
			else color[nxt] = color[curr];
			dfs(nxt);
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1; i<n; i++){
		int a,b,w;
		cin>>a>>b>>w;
		tree[a].push_back(pi(b,w%2));
		tree[b].push_back(pi(a,w%2));
	}
	dfs(1);
	for(int i=1; i<=n; i++) cout<<color[i]<<'\n';
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,K; cin>>N>>K;
	vector<ll> s(N+1,0);
	vector<ll> abss(N+1,0);
	ll ans=-1000000000000;
	rep(i,N){
		ll A; cin>>A;
		s[i+1]=s[i]+A;
		abss[i+1]=abss[i]+(A>=0?A:0);
	}
	for(int i=K-1;i<=N-1;i++){
		ans=max(ans,max((ll)0,s[i+1]-s[i-K+1])+abss[N]-abss[i+1]+abss[i-K+1]);
	}
	cout<<ans<<endl;
}

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

if n >= 400 and n <= 599:
    print(8)
elif n >= 600 and n <= 799:
    print(7)
elif n >= 800 and n <= 999:
    print(6)
elif n >= 1000 and n <= 1199:
    print(5)
elif n >= 1200 and n <= 1399:
    print(4)
elif n >= 1400 and n <= 1599:
    print(3)
elif n >= 1600 and n <= 1799:
    print(2)
elif n >= 1800 and n <= 1999:
    print(1)


Measured memory_bytes: 9184
/*Q-5---ATCODER-BEGINNER-#ROUND_177*/
#include <bits/stdc++.h>
#define MAX 1000001
#define endl '\n'
#define ll long long
using namespace std;

ll factors[MAX];
bool possible;

void findFactors(ll n){
	for(ll i=1;i<=sqrt(n);i++){
		if(n%i==0){
			if(n/i==i){
				if(i!=1){
					if(factors[i]==1){
						possible=false;
						return;
					}
					factors[i]=1;
				}
			}
			else{
				if(i!=1){
					if(factors[i]==1){
						possible=false;
						return;
					}
					factors[i]=1;
				}

				if(n/i!=1){
					if(factors[n/i]==1){
						possible=false;
						return;
					}
					factors[n/i]=1;
				}
			}
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    possible=true;

	ll n{0};
	cin>>n;

	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];

	//finding the GCD of all N-elements
	ll gcd=arr[0];
	for(ll i=0;i<n;i++){
		gcd=__gcd(gcd,arr[i]);
	}

	//
	for(ll i=0;i<n;i++){
		findFactors(arr[i]);
	}

	if(possible){
		cout<<"pairwise coprime"<<endl;
	}
	else if(gcd==1){
		cout<<"setwise coprime"<<endl;
	}
	else{
		cout<<"not coprime"<<endl;
	}

	return 0;
}

Measured memory_bytes: 19148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <map>
#include <sstream>
using namespace std;
typedef long long ll;

int now[1111];
int n;
char Ic[11];
int Im,Id,Ih,Imi,Ii;

struct node{
    int l,r,id;
    node(){}
    node(int _l,int _r,int _id):l(_l),r(_r),id(_id){
//        cout << l <<' ' << r << ' ' << id << endl;
    }
}a[1111],b[1111];
int m;
int day[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    for (int i=1;i<13;++i) day[i] = day[i-1] + day[i];
    while (scanf("%d",&n)==1 && n){
        memset(now,-1,sizeof(now));
        int m1 = 0, m2 = 0;
        for (int i=0;i<n;++i){
            scanf("%d/%d %d:%d %s %d",&Im,&Id,&Ih,&Imi,Ic,&Ii);
            int ret = (day[Im-1] + Id - 1) * 24 * 60 + Ih * 60 + Imi;
            if (Ic[0] == 'I') now[Ii] = ret;
            else{
                if (Ii==0)
                    a[m1++] = node(now[Ii], ret, Ii);
                else
                    b[m2++] = node(now[Ii], ret, Ii);
            }
        }
//        for (int i=0;i<m1;++i) printf
//    cout << min(a[0].r,b[0].r) - max(a[0].l, b[0].l) << endl;
        memset(now,0,sizeof(now));
        for (int i=0;i<m1;++i)
            for (int j=0;j<m2;++j)
                now[b[j].id] += max(0, min(a[i].r,b[j].r) - max(a[i].l, b[j].l));
        int ans = 0;
        for (int i=1;i<=999;++i) ans=max(ans, now[i]);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1212
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	int n;
	cin >> n;
	LL a[n];
	LL p_sum[n];
	LL m_sum[n];
	LL p_ans = 0;
	LL m_ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
			if (a[0] < 0) {
				m_sum[0] = a[0];
				p_sum[0] = 1;
				p_ans = 1 - a[0];
			}
			else if (a[0] > 0) {
				m_sum[0] = -1;
				p_sum[0] = a[0];
				m_ans = 1 + a[0];
			}
			else {
				m_sum[0] = -1;
				p_sum[0] = 1;
				p_ans = 1;
				m_ans = 1;
			}
		}
		else {
			p_sum[i] = a[i] + p_sum[i-1] ;
			m_sum[i] = a[i] + m_sum[i-1] ;
			if (p_sum[i] * p_sum[i-1] >= 0) {
				if (p_sum[i-1] > 0) {
					p_ans += p_sum[i] + 1;
					p_sum[i] = -1;
				}
				else {
					p_ans += 1 - p_sum[i];
					p_sum[i] = 1;
				}
			}
			if (m_sum[i] * m_sum[i-1] >= 0) {
				if (m_sum[i-1] > 0) {
					m_ans += m_sum[i] + 1;
					m_sum[i] = -1;
				}
				else {
					m_ans += 1 - m_sum[i];
					m_sum[i] = 1;
				}
			}
		}
	}

	dump(p_ans);
	dump(m_ans);
	cout << min(p_ans,m_ans) << endl;

	return 0;
}



Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long result = 0;

        // 素数の場合
        if (isPrime(n)) {
            result = n - 1;

        } else {

            // 平方根が整数の場合
            double sqrt = Math.sqrt(n);
            if (sqrt - (int) sqrt == 0) {
                result = (int) sqrt * 2 - 2;

            } else {

                long preNum = 0;
                for (long i = 2; i <= n / 2 && result == 0; i++) {
                    if (n % i == 0) {
                        if (isPrime(n / i)) {
                            result = n / i + i - 2;

                        } else if (preNum * i == n) {
                            result = preNum + i - 2;
                        }
                        preNum = i;
                    }
                }
            }
        }

        System.out.println(result);
        sc.close();
    }

    public static boolean isPrime(long num) {
        if (num < 2) {
            return false;
        } else if (num == 2) {
            return true;
        } else if (num % 2 == 0) {
            return false;
        }
        double sqrtNum = Math.sqrt(num);
        for (long i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=500;
using namespace std;


int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{

 
    int n;cin>>n;
     vector< pair < int,int > > a;
    for(int i=0;i<n;i++)
    {
    	int x;
    	cin>>x;
    	a.push_back({x,i+1});
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++)
	{
		cout<<a[i].second<<" ";
	}
	cout<<endl;
	
}



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

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s, t, u;
    getline(cin, s);
    t = "Hoshino";
    u = "Hoshina";
    for(int i = 0; i < s.size(); ++i) {
      if(s.substr(i, t.size()) == t) {
        cout << u;
        i += t.size() - 1;
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <algorithm>
using namespace std;

int n,m,x,y,z;
int fa[100010],cnt;
bool vis[100010];

int get_fa(int p)
{
    if (fa[p]==p) return p;
    return fa[p]=get_fa(fa[p]);
}

int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
    {
        fa[i]=i;
    }
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int fx=get_fa(x),fy=get_fa(y);
        if (fx!=fy)
        {
            fa[fx]=fy;
        }
    }
    for (int i=1;i<=n;i++)
    {
        int f=get_fa(i);
        if (!vis[f])
        {
            vis[f]=true;
            cnt++;
        }
    }
    printf("%d",cnt);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String[] a=new String[n];
    int[] b=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.next();
      b[i]=sc.nextInt();
    }
    String s=sc.next();
    int c=0;
    for(;c<n;c++){
      if(a[c].equals(s)){
        break;
      }
    }
    int ans=0;
    for(int i=c+1;i<n;i++){
      ans+=b[i];
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <cstdio>
const int MAXN = 10;
int N;

bool solve() {
    for (int i = 1; i < MAXN; ++i) {
        if ((N % i) != 0) {
            continue;
        }
        if (N / i < MAXN) {
            return true;
        }
    }
    return false;
}

int main() {
    scanf("%d", &N);
    puts(solve() ? "Yes" : "No");
    return 0;
}

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

int main(){
    int n, a[101], sum=0;

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

    sum /= n;
    long long p = 0, q = 0;

    for(int i = 0; i < n; ++i){
        p += abs(sum - a[i]) * abs(sum - a[i]);
        q += abs(sum - a[i] + 1) * abs(sum - a[i] + 1);
    }

    cout << min( p, q ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
 
void solve();
 
signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
set<pair<int, int>> s;
vector<pair<int, int>> arr;
void solve() {
    int n, d, a;
    cin >> n >> d >> a;
    arr.resize(n);
    for (int i = 0; i < n; ++i) {
    	cin >> arr[i].first >> arr[i].second;
    }
    sort(all(arr));
    int cur = 0;
    int used = 0;
    for (int i = 0; i < n; ++i) {
    	int x = arr[i].first;
    	while (!s.empty() and (*s.begin()).first < x - 2 * d) {
    		cur -= (*s.begin()).second * a;
    		s.erase(s.begin());
    	}
    	arr[i].second -= cur;
    	int need = max(0ll, (arr[i].second + a - 1) / a);
    	s.insert({x, need});
    	used += need;
    	cur += need * a;
    	while (!s.empty() and (*s.begin()).first <= x - 2 * d) {
    		cur -= (*s.begin()).second * a;
    		s.erase(s.begin());
    	} 
    }
    cout << used;
} 

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

if A % 2 == 0:
    ans = 0
else:
    ans = A
    A += 1

if B % 2 == 0:
    ans ^= B
    B -= 1

if B - A + 1 <= 0:
    pass
elif (B - A + 1) // 2 % 2 == 0:
    pass
else:
    ans ^= 1

print(ans)

Measured memory_bytes: 3060
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
while(true){
    int za = rint();
if(za == 0) break;
    int[,] zah = inta2(za,2);
    int sya = rint();
    int[,] syah = inta2(sya,2);
    for(int i=0;i<sya;i++){
        int[,] moved = new int[za,2];
        int mincheck = 0;
        for(int j=0;j<za;j++){
            moved[j,0] = zah[j,0] +syah[i,0] - zah[0,0];
            moved[j,1] = zah[j,1] +syah[i,1] - zah[0,1];
            if(moved[j,0] <0 || moved[j,1] <0){ mincheck--; }
        }
        
        for(int j=0;j<za;j++){
            //Write($"{moved[j,0]} {moved[j,1]} : ");
        }
        //WriteLine();
        
        if(mincheck <0){
            continue;
        }
        int checker = 0;
        for(int j=0;j<sya;j++){
            for(int k=0;k<za;k++){
                if(moved[k,0] == syah[j,0] && moved[k,1] == syah[j,1]){
                    checker++;
                }
            }
        }
        //WriteLine(checker);
        if(checker == za){
            WriteLine($"{syah[i,0] - zah[0,0]} {syah[i,1] - zah[0,1]}");
            break;
        }
    }
}
    
    
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}



Measured memory_bytes: 15896
import collections
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for _ in range(M):
    u,v=map(int,input().split())
    tree[u-1].append(v-1)
S,T=map(int,input().split())
s=S-1
t=T-1
ischecked=[[0]*3 for _ in range(N)]
ischecked[s][0]=1
ans=-1
q=collections.deque()
q.append([s,0])
while q:
    v,c=q.popleft()
    if v==t and c%3==0:
        ans=c//3
        break
    for i in tree[v]:
        if ischecked[i][(c+1)%3]==0:
            q.append([i,c+1])
            ischecked[i][(c+1)%3]=1
print(ans)

Measured memory_bytes: 28568
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
   (0..c).each do |k|
     if x == 500 * i + 100 * j + 50 * k
       cnt += 1
     end
   end
  end
end
puts cnt


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

const int N=1e5+5;
bool in[N];
vector<int>lk[N];
vector<int>q;

void ex(int x)
{
	in[x]=1;
	while(1)
	{
		for(auto y:lk[x])
		if(!in[y])x=y;
		if(in[x])break;
		in[x]=1;
		q.push_back(x);
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].push_back(y);
		lk[y].push_back(x);
	}
	ex(1);
	reverse(q.begin(),q.end());
	q.push_back(1);
	ex(1);
	printf("%d\n",q.size());
	for(auto x:q)printf("%d ",x);
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    vector<pint> D(N);
    for (int i = 0; i < N; ++i) cin >> D[i].first >> D[i].second;
    int res = 0;
    for (int i = 0; i < N-2; ++i) {
        int count = 0;
        if (D[i].first == D[i].second) ++count;
        if (D[i+1].first == D[i+1].second) ++count;
        if (D[i+2].first == D[i+2].second) ++count;
        if (count == 3) ++res;
    }
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::HashSet;
use std::iter::FromIterator;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}
 
fn main() {
    let s: String = read().unwrap();
    let v: Vec<char> = s.chars().collect::<Vec<char>>();
    let chars: HashSet<char> = HashSet::from_iter(v.iter().cloned());
    if chars.contains(&'N') == chars.contains(&'S') && chars.contains(&'W') == chars.contains(&'E') {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 2148
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

vector<int> memo(100010,-1);
int p=pow(10,9)+7;
int func(int i){
    if(i==-1)return 0;
    if(i<=1)return 1;
    if(memo[i]!=-1)return memo[i];

    return memo[i]=(func(i-1)%p+func(i-2)%p)%p;
}

int main(){
    int N,M,a[100010];
    long long da[100010];
    cin>>N>>M>>a[0];

    if(M!=0){
    da[0]=a[0]-1;
    
    for(int i=1;i<M;++i){
        cin>>a[i];
        da[i]=a[i]-a[i-1]-2;
    }
    da[M]=N-a[M-1]-1;

    long long x=1;
    for(int m=0;m<=M;++m){
         x=(x*func(da[m]))%p;
    }

    cout<<x<<endl;}
    else cout<<func(N)<<endl;
    
    return 0;

}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, seek;

int main()
{
	in >> N;
	if (N == 3)
	{
		out << 2 << " " << 3 << " " << 25 << std::endl;
		return 0;
	}
	std::vector<LL>ans, even({ 2,4,3,9,6,12,8,10 }), odd({ 6,2,4,3,9,10,8,12 });
	rep(i, N)
	{
		if (N % 2)
		{
			ans.push_back(odd[seek]);
			odd[seek] += 12;
		}
		else
		{
			ans.push_back(even[seek]);
			even[seek] += 12;
		}
		++seek;
		seek %= 8;
	}
	rep(i, ans.size()) out << ans[i] << (i < ans.size() - 1 ? " " : "\n");
	return 0;
}


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

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

    char c[4];
    cin >> c;
    cout << (c[0] == c[2] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#define MAX 10000

using namespace std;

int main(void){

  int d, n, m;
  while(cin >> d, d){
    
    cin >> n >> m;
    int shop[n + 1],  des[m];
    shop[0] = 0;
    shop[n] = d;
    
    for(int i = 1 ; i < n ; i++)
      cin >> shop[i];
    for(int i = 0 ; i < m ; i++)
      cin >> des[i];

    sort(shop, shop + n + 1);
    sort(des, des + m);

    int s = 0, sum = 0;
    for(int i = 0 ; i < n + 2 ; i++){
      if(shop[i] <= des[s] && des[s] <= shop[i + 1]){
	sum += min(shop[i + 1] - des[s], des[s] - shop[i]);
	s++;
	i--;
      }
      if(s >= m) break;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1604
#include<iostream>
using namespace std;
int main(){
	int a,b,c,k;
	int sum=0;
	cin>>a>>b>>c>>k;
	if(k<=a)sum=k;
	else if(k<=a+b)sum=a;
	else if(k<=a+b+c)sum=a-(k-a-b);
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3588
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-8;
const long double INF = 1e20;


const int M=256;
int main(){
	int N;
	while(cin>>N&&N){
		int I[300],R[300],O[300];
		long double mini=INF;
		REP(i,N){
			cin>>I[i+1];
		}
		int resS,resA,resC;
		REP(S,16)REP(A,16)REP(C,16){
			R[0]=S;CLR(O);
			FOR(i,1,N+1){
				R[i]=(A*R[i-1]+C)%M;
				O[(I[i]+R[i])%M]++;
			}
			long double tmp=0.0;
			REP(i,256)if(O[i]!=0)tmp-=((long double)O[i]/N)*log(((long double)O[i]/N));
			if(tmp+EPS<mini){
				resS=S;resA=A;resC=C;
				mini=tmp;
			}
		}
		cout<<resS<<" "<<resA<<" "<<resC<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;


void solve(){
	int n , k ;
	cin >> n >> k ;
	vi a(n) ;
	for(auto& x : a) cin >> x ;
	sort(all(a)) ;
	int ans = 0 ;
	for(int i = 0 ; i < k ; i++){
		ans += a[i] ;
	}
	cout << ans << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
}


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

using namespace std;


#define EPS (1e-10)
const double inf=1e20;

struct Point{
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double k) { return Point(k*x,k*y); }
    Point operator / (double k) { return Point(x/k,y/k); }

    //向量的大小
    inline double abs(){ return sqrt(norm()); }
    inline double norm() { return x*x+y*y; }

    bool operator < (const Point & p) const{
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point & p) const {
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

Point a[100005],b[100005];

inline bool CmpY(Point a,Point b){
    return a.y<b.y;
}
inline double Distance(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

double Divide_Conquer(int l,int r){
    if(l==r) return inf;
    if(l+1==r) return Distance(a[l],a[r]);
    int mid=l+r>>1;
    double ans=min(Divide_Conquer(l,mid),Divide_Conquer(mid+1,r));
    int len=0;
    for(int i=l;i<=r;i++){
        if(fabs(a[mid].x-a[i].x)<=ans) b[len++]=a[i];
    }
    sort(b,b+len,CmpY);
    for(int i=0;i<len;i++){
        for(int j=i+1;j<len&&(b[j].y-b[i].y<ans);j++){
            ans=min(ans,Distance(b[i],b[j]));
        }
    }
    return ans;
}

inline void solve(int n){
    sort(a,a+n);
    printf("%.10f\n",Divide_Conquer(0,n-1));
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&a[i].x,&a[i].y);
    }
    solve(n);

}



Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int A,B;
char S[15];
int main()
{
	cin>>A>>B>>S;
	for(int i=0;i<=A+B;i++)
	{
		if(i!=A)
		{
			if(S[i]<'0'||S[i]>'9')
			{
				printf("No\n");
				return 0;	
			} 
		}
	}
	if(S[A]!='-')
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
} 

Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    num=x
    num2=a[i-1]+a[i]-x
    if num2>0:
        ans+=num2
        a[i]=max(a[i]-num2,0)
print(ans)


Measured memory_bytes: 20028
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    ///Yeah, I am the backupguy!
    using namespace std;
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int n,m,sum=0,counter=0;
    cin>>n>>m;
    int arr[n];
    for(int i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
    }
    sort(arr,arr+n);
    for(int i=n-1;i>=0;i--){
    if(arr[i]*4*m>=sum)
    counter++;
    else
    break;
    }
    if(counter>=m)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

int arr[100010],qwq[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m,v,p,i;
	cin>>n>>m>>v>>p;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(i=n-p-1;i>=0;i--)
	{
		qwq[i]=qwq[i+1]+arr[i+1];
	}
	int ans=0;
	for(i=0;i<n;i++)
	{
		if(i>=n-p)
			ans++;
		else if((arr[i]+m)*(n-p-i)>=(qwq[i]+max((int)0,n-p-i-(n-v))*m) && arr[i]+m>=arr[n-p])
			ans++;
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		ans += r - l + 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int cnt;
int l;
int A[1000000];
int n;
int G[1000000];
int buf;

void insertionSort(int A[], int n, int g){
  int i, j, v;
  for(i = g; i < n; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  int h = 1, i = 0;
  while(1){
    if(h > n) break;
    G[i++] = h;
    h = 3 * h + 1;
  }
  buf = i;

  for(i = buf - 1; i >= 0; i--) insertionSort(A, n, G[i]);
}

int main(){
  int i, n;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  cnt = 0;

  shellSort(A, n);

  printf("%d\n",buf);
  for(i = buf - 1; i >= 0; i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i = 0; i < n; i++) printf("%d\n",A[i]);

  return 0;
}

Measured memory_bytes: 6372
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str;
		int len;
		str=sc.next();
		len=str.length();	
		if(len==2) {
			System.out.println(str);
		}else {
			StringBuffer sb=new StringBuffer(str);
			System.out.println(sb.reverse());
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

int main(){
  string S, T, U;
  int A, B;
  cin>>S>>T>>A>>B>>U;
  if(S==U){
    cout<<A-1<<" "<<B<<endl;
  }
  else{
    cout<<A<<" "<<B-1<<endl;
  }
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))

ans_l=[0]*(n+1)
ans=0
def con(a):
    return int(a*(a-1)*0.5)
for i in range(n):
    ans_l[l[i]]+=1
#print("ans_l",ans_l)
#print("l",l)
for j in ans_l:
    ans+=con(j)
# print(ans)
for i in range(n):
    ans_2=ans
    # print("ans_2_0:",ans_2)
    #print("ans_l[l[i]]",ans_l[l[i]])
    ans_2-=con(ans_l[l[i]])
    #print("ans_2_1:",ans_2)
    
    #print("ans_l[l[i]]:",ans_l[l[i]]-1)
    ans_2+=con(ans_l[l[i]]-1)
    print(ans_2)


Measured memory_bytes: 24996
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
void solve()
{
    ll a; cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}



Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2 10
20 20
)");
#define cin input
#endif

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

	vector<int> a(n);

	for (auto& i : a)
		cin >> i;
	
	sort(a.begin(), a.end());

	int r = 0;
	for (auto& i : a)
	{
		x -= i;
		if (x < 0)
			break;
		++r;
	}

	if (x > 0)
		--r;

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 888
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let p: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut q = p.clone();
    q.sort();
    let mut cnt = 0;
    for i in 0..n {
        if p[i] != q[i] {
            cnt += 1;
        }
    }

    println!("{}", if cnt == 0 || cnt == 2 { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
pair<int, int> x[200005];
int ans[200005];

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++)
    scanf("%d", &x[i].first),
      x[i].second = i;
  sort(x + 1, x + n + 1);
  for(int i = 1; i <= n; i++)
    ans[x[i].second] = i <= n / 2 ? x[n / 2 + 1].first : x[n / 2].first;
  for(int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);
}


Measured memory_bytes: 4480
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int g[100][100];

bool vis[10];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a][b]=1;
        g[b][a]=1;
    }
    int path[n];
    for(int i=0;i<n;i++)
    {
        path[i]=i;
    }
    int ans = 0;
    do
    {
        if(path[0]!=0)
            continue;
        int i;
        for(i=0;i<n-1;i++)
        {
            if(g[path[i]][path[i+1]]==0)
                break;
        }
        if(i==n-1)
            ans++;
    }
    while(next_permutation(path,path+n));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
def com(n, a):
    a = min([a, n-a])
    x = 1
    for i in range(n-a+1, n+1):
        x *= i
    for i in range(1, a+1):
        x //= i
    return x


n, p = map(int, input().split())
a = [i%2 for i in map(int, input().split())]
b = sum(a) #奇数
d = n-b #偶数
if p==1:
    x = 0
    c = 1
    while c <= b:
        x += com(b, c)
        c += 2
    x *= 2**d
else:
    x = 1
    c = 2
    while c <= b:
        x += com(b, c)
        c += 2
    x *= 2**d

print(x)

Measured memory_bytes: 3064
s = input().split(' ')
list = [int(s[0]), int(s[1]), int(s[2])]
newlist = []
for i in range(len(list)):
    mv = min(list)
    newlist.append(mv)
    list.remove(mv)

print('{0} {1} {2}'.format(newlist[0], newlist[1], newlist[2]))


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


def solve(N: int, A: "List[int]"):
    dif = [0]*(N+1) 
    dif2 = [0]*N
    A = [0] + A + [0]
    for i in range(N+1):
        dif[i] = abs(A[i+1]-A[i])
    for i in range(N):
        dif2[i] = abs(A[i+2]-A[i])
    total_distance = sum(dif)
    
    # output answer
    for i in range(N):
        print(total_distance-dif[i]-dif[i+1]+dif2[i])

    return


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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23264
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB pop_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
#define vi vector<long long>

using namespace std;
typedef long long ll;
const ll mod=1e9;
const ll inf = 1e18+7;
const int maxn = 2e5+7;
int k;

int main(){
    ll k,a,b,t,n,u,v,w,y,r;
    FIO
    cin>>k>>a>>b;
    string s="NG";
    for(int i=a;i<=b;i++) if(i%k==0) s="OK";
    cout<<s<<endl;

    return 0;
}
/**
5
6
7
1 2 2 4
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
**/


Measured memory_bytes: 3656