akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	string s; cin >> s;
	if (s[s.size() - 1] == 's')cout << s + "es" << endl;
	else cout << s + 's' << endl;
}

Measured memory_bytes: 3556
D, G = list(map(int,input().split()))
p = []
c = []

for i in range(D):
    in1, in2 = list(map(int,input().split()))
    p.append(in1)
    c.append(in2)
    
ans = 10 ** 9 + 7
for x in range(2 ** D):
    b = str(format(x, '010b'))
    score = 0
    res = 0
    not_perfect = 0
    for i in range(D):
        if b[-(i + 1)] == "1": 
            score += (p[i] * 100 * (i + 1) + c[i])
            res += p[i]
        else:
            not_perfect = i
    rest = G - score
    if rest > 0:
        s = 100 * (not_perfect + 1)
        for i in range(p[not_perfect]):
            res += 1
            rest -= s
            if rest <= 0:
                break
        if rest > 0:
            res = 10 ** 9 + 7
    ans = min(ans, res)
    
print(ans)

Measured memory_bytes: 42044
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>

long long int mygcd(long long int a, long long int b)
{
    while(a%b != 0)
    {
        long long int t = a%b;
        a = b;
        b = t;
    }
    return b;
}

int cmp(const void* a, const void* b) {return *(long long int*)a > *(long long int*)b ? 1 : -1; }

int main()
{
    int n;
    while(scanf("%d", &n), n)
    {
        long int len = (1+n)*n/2, i;
        long long int b, g = -1, a12 = -1;
        long long int stack[300]; int sp = -1;
        while(len--)
        {
            scanf("%lld", &b);
            if(b%2 == 0)
            {
                ++sp; stack[sp] = b;
            }
            else
            {
                if(a12 == -1) a12 = b;
                else if(b < a12) a12 = b;
            }
        }
        qsort(stack, sp+1, sizeof(stack[0]), cmp);
        g = mygcd(stack[0], stack[1]);
        g /= sqrt(a12/((stack[0]/g)*(stack[1]/g)));
        printf("%lld\n%lld", g, stack[0]/g);
        for(i = 1; i <= sp; i ++) printf(" %lld", stack[i]/g);
        printf("\n");
    }
    return 0;
}

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


int main() {
  int A = 0;
  int B = 0;
  int C = 0;
  cin >> A >> B >> C;
  if ((A == 5 || B == 5 || C == 5) && (A == 7 || B == 7 || C == 7) && A + B + C == 17){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int d;
    cin >> d;
    int last[26] = {0};
    int s[d][26] , c[26];
    for (int i = 0 ; i < 26 ; i++)
        cin >> c[i];
    for (int i = 0 ; i < d ; i++){
        for (int j = 0 ; j < 26 ; j++)
            cin >> s[i][j];
    }
    for (int i = 0 ; i < d ; i++){
        int maks = -2e9 , idx = 0;
        for (int j = 0 ; j < 26 ; j++){
            int nilai = s[i][j] - c[j] * (i - last[j]);
            if (nilai > maks)
                maks = nilai,
                idx = j;
        }
        last[idx] = i + 1;
        cout << idx + 1 << endl;
    }
}


Measured memory_bytes: 3652
//先打出来1-1e5的素数表
//然后莫队
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;

struct node
{
    int l,r,id;
};
node ns[MAXN];
int Belong[MAXN];
int num[MAXN];
int res[MAXN];
bool sure[MAXN];
int block,siz;
int n,m,ans = 0;
int L,R,Q;

bool cmp(const node& a, const node& b)
{
    if(Belong[a.l] == Belong[b.l])
        return a.r < b.r;
    return Belong[a.l] < Belong[b.l];
}

bool notprime[MAXN];//值为false表示素数，值为true表示非素数
void init()
{
    memset(notprime,false,sizeof(notprime));
    notprime[0]=notprime[1]=true;
    for(int i=2; i<MAXN; i++)
        if(!notprime[i])
        {
            if(i>MAXN/i)continue;//防止后面i*i溢出(或者i,j用long long)
        //直接从i*i开始就可以，小于i倍的已经筛选过了,注意是j+=i
            for(int j=i*i; j<MAXN; j+=i)
                notprime[j]=true;
        }
}

void del(int x)
{
    if(sure[x])
        --ans;
}

void add(int x)
{
    if(sure[x])
        ++ans;
}

//打素数表
int main()
{
    init();
    n = MAXN;
    block = sqrt(n);
    siz = n/block;
    if(n%block) ++siz;
    for(int i = 1; i <= n; ++i)
    {
        sure[i] = (!notprime[i]&&!notprime[(i+1)/2]);
        Belong[i] = (i-1)/block + 1;
    }
    scanf("%d",&Q);
    for(int i = 1; i <= Q; ++i)
    {
        scanf("%d %d",&ns[i].l,&ns[i].r);
        ns[i].id = i;
    }
    sort(ns+1,ns+1+Q,cmp);
    L = 1;
    R = 0;
    for(int i = 1; i <= Q; ++i)
    {
        while(L < ns[i].l)
        {
            del(L);
            L++;
        }
        while(L > ns[i].l)
        {
            L--;
            add(L);
        }

        while(R < ns[i].r)
        {
            R++;
            add(R);
        }
        while(R > ns[i].r)
        {
            del(R);
            R--;
        }
        res[ns[i].id] = ans;
    }
    for(int i = 1; i <= Q; ++i)
        printf("%d\n",res[i]);
    return 0;
}




Measured memory_bytes: 2816
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int p[]=new int[n];

        String ans[]={"YES","NO"};

        for (int i=0;i<n;++i)
        {
            p[i]=sc.nextInt();
            if (p[i]!=i+1) ++count;
        }

        if (count==0 || count==2) System.out.println(ans[0]);
        else System.out.println(ans[1]);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,x,m;
	cin>>n>>x>>m;
	ll ans = 0 ;
	if(n<=m){
		for(int i = 0 ;i <n ;i++){
			ans =  ans +x;
			x = (x*x)%m;
		}
		cout<<ans;
		return 0;
	}
	ll vis[m] = {0};
	ll store[m] = {0};
	ll iter = 1;
	while(!vis[x]){
		vis[x] = iter ;
		ans += x;
		store[x] = ans ;
		x = (x*x)%m;
		++iter;
	}
	ll turns = iter - vis[x] ;
	ll cur = ans - store[x] + x ;
	n = n + 1 - iter;
	ans = ans + (n/turns)*cur;
	n = n % turns;
	for(int i = 0 ;i<n;i++){
		ans =  ans + x;
		x = (x*x)%m;
	}
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 5204
import java.util.*;

public class Main {

    /* チェックリスト
     * intの範囲を超えていないか
     * TLEしそうな処理の有無
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] humans = sc.nextLine().split(" ");
        int[] students = new int[n];
        for(int i = 0;i < n;i++){
            int num = Integer.parseInt(humans[i]);
            students[num - 1] = i + 1;
        }
        for(int student : students){
            System.out.print(student+" ");
        }
        System.out.println();
    }
}

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

int main(){
  int x;
  cin >> x;
  if(x) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <atcoder/all>
#include "bits/stdc++.h"
using namespace std;
using namespace atcoder;

int n,q,t,u,v;

int main()
{
	scanf("%d%d",&n,&q);
	auto ds=dsu(n);
	while(q--)
	{
		scanf("%d%d%d",&t,&u,&v);
		if(t==0) ds.merge(u,v);
		else printf("%d\n",ds.same(u,v));
	}
}

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

void solve(long long N, long long M, long long L, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, long long Q, std::vector<long long> s, std::vector<long long> t){

    vector<vector<ll>> dist(N, vector<ll>(N, 1e12));
    
    for (ll i = 0; i < M; i++) {
	dist[A[i]][B[i]] = C[i];
	dist[B[i]][A[i]] = C[i];
    }
    for (ll i = 0; i < N; i++) {
	dist[i][i] = 0;
    }
    auto fw = [&]() {
		  for (ll k = 0; k < N; k++) {
		      for (ll i = 0; i < N; i++) {
			  for (ll j = 0; j < N; j++) {
			      if (dist[i][j] > dist[i][k] + dist[k][j]) {
				  dist[i][j] = dist[i][k] + dist[k][j];
			      }
			  }
		      } 
		  }
	      };
    fw();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (dist[i][j] > L) {
	    dist[i][j] = 1e12;
        } else {
	    dist[i][j] = 1;
        }
      }
    }
    fw();
    
    for (ll q = 0; q < Q; q++) {
      if (dist[s[q]][t[q]] == 1e12) {
	  cout << -1 << endl;
      } else {
	  cout << dist[s[q]][t[q]] - 1 << endl;
      }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
	A[i]--;
	B[i]--;
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(Q);
    std::vector<long long> t(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
	s[i]--;
	t[i]--;
    }
    solve(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s), std::move(t));
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>

#define M 1046527 /* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
	else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for( i = 0; ; i++ ){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h], str) == 0 ){
			return 1;
		}else if( strlen(H[h]) == 0 ){
			return 0;
		}
	}
	return 0;
    

}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for( i = 0; ; i++ ){
		h = (h1(key) + i * h2(key)) % M;
		if( strcmp(H[h], str) == 0 ){
			return 1;
		}else if( strlen(H[h]) == 0 ){
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
	
   

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16020
n, k = map(int, input().split())

ans = 0.0

p1 = min(k-1, n) / n
ans += 1.0 - p1

for i in range(1, min(k-1, n) + 1):
    p2 = 1.0 / n
    j = i
    while j < k:
        p2 *= 0.5
        j *= 2
    ans += p2

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n; cin >> n;
  int x = 7 % n;
  for (int i = 0; i < n; i++){
    if (!x){
      cout << i+1 << endl;
      return 0;
    }
    x = (x*10+7)%n;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3640
# https://atcoder.jp/contests/abc081/tasks/arc086_a

from collections import Counter

n, k = map(int, input().split())
a = list(sorted(map(int, input().split())))
c = Counter(a)
current_k = len(c)
xlst = c.most_common(current_k)[k:]

answer = 0
for x in xlst:
    answer += x[1]

print(answer)


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

int main()
{
    // 頂点数と辺数
    int N, Q;
    cin >> N >> Q;

    int a,b;
    // グラフ入力受取 (ここでは無向グラフを想定)
    vector<vector<int>> G(N+1);
    for (int i = 1; i < N ; ++i) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int p,x;
    vector<vector<pair<int,int>>> C(N+1);
    rep(i,Q){
        cin >> p >> x;
        C[p].push_back(make_pair(p,x));
    }

    // BFS のためのデータ構造
    vector<ll> counter(N+1, 0); // 全頂点を「未訪問」に初期化
    vector<int> dist(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;        
    // 初期条件 (頂点 0 を初期ノードとする)
    rep(i,C[1].size()){
        if(C[1][i].first == 1) counter[1] += C[1][i].second;
    }
    dist[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            counter[nv] = counter[v];
            rep(i,C[nv].size()){
                counter[nv] += C[nv][i].second;
            }
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    rep2(i,1,N+1) cout << counter[i]<< endl;

    return 0;
}

Measured memory_bytes: 27256
#ALDS_11_B - 深さ優先探索
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)#再帰回数の上限

def DFS(u, cnt):
    visited.add(u)
    first_contact = cnt
    
    cnt += 1
    for nb in edge[u]:
        if nb not in visited:
            cnt = DFS(nb, cnt)
    
    stamp[u] = first_contact, cnt
    return cnt+1
    

N = int(input())
edge = [[] for i in range(N)]
for _ in range(N):
    tmp = list(map(int,input().split()))
    if tmp[1] != 0:
        edge[tmp[0]-1] = list(map(lambda x: int(x-1),tmp[2:]))

stamp = [None]*N
visited = set()

c = 1
for i in range(N):
    if i not in visited:
        c = DFS(i, c)
        
for i,s in enumerate(stamp):
    print(i+1,*s)


Measured memory_bytes: 5664
#include<stdio.h>
int main()
{
    int N,K;
    unsigned long long sum1=0,sum2=0,i,m=1000000007,a;
    scanf("%d%d",&N,&K);
    for(i=K;i<=(N+1);i++){
        sum1=(sum1+i)%m;
    }
    for(i=K;i<=(N+1);i++){
        sum2=(sum2+i*(i-1))%m;
    }
    a=(N*sum1+N-K+2-sum2)%m;
    printf("%llu\n",a);
    return 0;
}


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

using namespace std;

int main() {

    string S;
    cin >> S;
    
    int N;
    N = S.length();

    if (S.substr(0, (N - 1)/ 2) == S.substr(((N + 3)/ 2) - 1)) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N, D;
  
  cin >> N >> D;
  
  int hon = 2 * D + 1;
  int res;
  
  if (N%hon == 0) {
    res = N/hon;}
  
  else{
    int rem;
    rem = int(N/hon);
    res = rem + 1;}
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    ll cnt = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      cnt++;
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;


	string str1,str2;
	vector<pair<string , ll>> vec;;
	cin>>str1>>str2;
	ll a  , b ;
	cin>>a>>b ;
	string str3;
	cin>>str3;
	if(str1==str3){
		cout<<a-1<<" "<<b<<endl;
	}
	else{
		cout<<a<<" "<<b-1<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
N,A,B,K=map(int,input().split())
P=998244353
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Fact[0]=1
Finv[0]=1
for i in range(1,N+1):
    Fact[i]=(i*Fact[i-1])%P
    Finv[i]=(Finv[i-1]*inv(i))%P
def NC(k):
    tmp=(Finv[k]*Finv[N-k])%P
    return (Fact[N]*tmp)%P
ans=0
for s in range(N+1):
    t=(K-s*A)//B
    if s*A+t*B==K and 0<=t<=N:
        ans+=(NC(s)*NC(t))%P
print(ans%P)


Measured memory_bytes: 66444
M=10**9+7;F=lambda X:pow(X,M-2,M);H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*F(I*(W+H-B-1-I))%M;Z+=C
print(Z%M)

Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
 
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
 
int main()
{
    int n,m;cin >> n >> m;
    cout << (n*(n-1) + m*(m-1))/2 << endl;
    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();

    int res = 0;
    for(int i = 0; i < n / 2; ++i)
    {
        if(s[i] != s[n - i - 1])
            res++;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3572
import java.util.*;


public class Main {
	
	Scanner cin = new Scanner(System.in);
	
	public static void main(String[] args) {
		new Main().run(); 
	}
	
	public void run() {		
		
		/*input*/
		String str = cin.nextLine();
		
		/*start*/
		
		int[] count = new int[26];
		
		for (int i = 0; i < str.length(); i ++) {
			
			count[str.charAt(i) - 'a'] ++;
		}
		
		String res = "Yes";
		
		for (int c: count) {
			
			if (c % 2 != 0) {
				res = "No";
				break;
			}
		}
		
		/*finish*/
		System.out.println(res);
	}
}



Measured memory_bytes: 23892
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int A, B;
    cin >> A >> B;

    int cnt = 0;
    int socket = 1;
    while (socket < B) {
        socket += A - 1;
        cnt++;
    }

    // cout << socket << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashSet;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (x, y, z, k) = (line[0], line[1], line[2], line[3]);

    let mut a: Vec<u64> = read_as_vec();
    let mut b: Vec<u64> = read_as_vec();
    let mut c: Vec<u64> = read_as_vec();

    a.sort();
    a.reverse();

    b.sort();
    b.reverse();

    c.sort();
    c.reverse();

    let mut heap: BinaryHeap<(u64, usize, usize, usize)> = BinaryHeap::new();

    let mut added_pair: HashSet<(u64, usize, usize, usize)> = HashSet::new();

    heap.push((a[0]+b[0]+c[0], 0, 0, 0));

    let mut counter = 0;
    while counter < k{
        let res = heap.pop().unwrap();
        if added_pair.contains(&res){
            continue;
        }
        added_pair.insert(res);
        println!("{}", res.0);

        if res.1 +1< x{
        heap.push((a[res.1+1]+b[res.2]+c[res.3],
                   res.1+1, res.2, res.3));
        }
        if res.2 + 1 < y{
        heap.push((a[res.1]+b[res.2+1]+c[res.3],
                   res.1, res.2+1, res.3));

        }

        if res.3 + 1 < z{
        heap.push((a[res.1]+b[res.2]+c[res.3+1],
                   res.1, res.2, res.3+1));
        }
        counter += 1;
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
#define Max 100000
#define null (-1)
struct rooted_trees{int parent;int left;int right;};
int depthing(rooted_trees a[],int id){
int dep=0,idd=id;
	
	while(a[idd].parent!=null){
	idd=a[idd].parent;
		dep++;
	}
	return dep;
}
void p_child(rooted_trees a[],int id){
int c=a[id].left;
	printf("[");
	if(c!=null){
    printf("%d",c);
    if(a[c].right!=null)
		printf(", ");
	}
	while(a[c].right!=null){
		if(c==null)
		break;
		if(a[a[c].right].right==null)
		  printf("%d",a[c].right);
		
		else 
		  printf("%d, ",a[c].right);
		c=a[c].right;
	}
	printf("]\n");
}
void p_type(rooted_trees a[],int id){
	if(a[id].parent==null)
	printf("root, ");
	else if(a[id].left==null)
	printf("leaf, ");
	else 
	printf("internal node, ");
}
main(){
	int id,k,c,cpre,i,j,n;
	rooted_trees as[Max];
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    as[i].parent=null;
		as[i].left=null;
		as[i].right=null;
	}
	   
	for(i=0;i<n;i++){
		scanf("%d %d",&id,&k);
		for(j=0;j<k;j++){
			scanf("%d",&c);
			as[c].parent=id;
			if(j==0)
		     as[id].left=c;
			else
			 as[cpre].right=c;
			cpre=c;
		}
	}
	for(i=0;i<n;i++){
	printf("node %d: parent = %d, depth = %d, ",i,as[i].parent,depthing(as,i));
		p_type(as,i);
		p_child(as,i);
	}
	
	return 0;
}



Measured memory_bytes: 4336
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n uint64
	fmt.Scanf("%d", &n)

	alphabets := strings.Split("zabcdefghijklmnopqrstuvwxy", "")

	var answer string
	for {
		answer += alphabets[n%26]

		if n%26 == 0 {
			n--
		}

		if n/26 == 0 {
			break
		} else {
			n = n / 26
		}
	}

	fmt.Println(reverse(answer))

}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 1840
def inserts(N):
    k = 1
    for n in N:
        print(n, end='')
        if k < len(N):
            print(' ', end='')
        k += 1

    print('')
    for i in range(1,len(N)):
        # ?????????????´??????????????????£????????¨?????????
        v = N[i]
        j = i - 1
        while j >= 0 and N[j] > v:
            N[j + 1] = N[j]
            j -= 1
        N[j + 1] = v
        k = 1
        for n in N:
            print(n, end='')
            if k < len(N):
                print(' ', end='')
            k += 1
        print('')


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

inserts(numbers)

Measured memory_bytes: 8484
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _n: usize = read()[0];
    let a: Vec<f64> = read();
    let mul = a.iter().fold(1., |s, &t| s * t);

    println!("{}", mul / a.iter().fold(0., |sum, &x| sum + mul / x));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.endsWith("s")){
			s = s + "es";
		}else{
			s = s + "s";
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 38396
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    const int MAX_A = 3500;
    rep(i, MAX_A) rep(j, MAX_A) {
        ll a = i+1, b = j+1;
        ll tmp1 = n*a*b;
        ll tmp2 = 4*a*b-n*a-n*b;
        if (tmp2 <= 0) continue;
        if (tmp1 % tmp2 == 0) {
            cout << a << " " << b << " " << tmp1/tmp2 << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> P(n);
  int count = 1;
  rep(i,n){
    cin >> P[i];
  }
  int point = P[0];
  for(int i = 1;i<n;++i){
    if(P[i] <= point){
      ++count;
      point = P[i];
    }
  }
  cout << count << endl; 
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans = 0;
  string S;
  cin >> S;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      ans ++;
    }else{
      ans --;
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n],y[n];
    for(int i=0;i<n;i++)
        cin >> x[i];
    for(int i=0;i<n;i++)
        cin >> y[i];
    double a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++) {
        double e=abs(x[i]-y[i]);
        a+=e;
        b+=pow(e,2);
        c+=pow(e,3);
        d=max(d,e);
    }
    b=sqrt(b);
    c=pow(c,1/3.0);
    printf("%.8f\n%.8f\n%.8f\n%.8f\n",a,b,c,d);
}


Measured memory_bytes: 3332
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    int time[200]={0};
    bool yes = true;
    for(int i = 0; i < len; i++){
        time[int(s[i])]++;
    }
    for(int i = int('a'); i < int('z'); i++){
        if(time[i] % 2 != 0)yes = false;
    }
    if(yes == true)cout<<"Yes";
    else cout<<"No";



    return 0;
}


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

int main()
{    
   int n,m;
   cin >> n >> m;
   vector<int> p(m);
   vector<string> s(m);
   rep(i,m) cin >> p[i] >> s[i];

   int ac = 0;
   int wa = 0;
   vector<bool> check(n+1);
   vector<int> tmpWa(n+1);

   rep(i,m){
      
      if(check[p[i]]) continue;

      if(s[i] == "WA") ++tmpWa[p[i]];
      else {
         check[p[i]] = true;
         ++ac;
         wa += tmpWa[p[i]];
      }
   }
   printf("%d %d\n",ac,wa);
}

Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
Scanner kb=new Scanner(System.in);
int a[]={kb.nextInt(),kb.nextInt(),kb.nextInt()};
int num=0;
for(int i=0;i<2;i++){
if(a[0]>a[1]){
	num=a[1];
	a[1]=a[0];
	a[0]=num;
}
if(a[1]>a[2]){
	num=a[2];
	a[2]=a[1];
	a[1]=num;
}
if(a[1]>a[2]){
	num=a[1];
	a[1]=a[2];
	a[2]=num;
}
	}

for(int i=0;i<3;i++){
	System.out.printf("%d", a[i]);
	if(i!=2){
		System.out.print(" ");
	}
}
System.out.println();
	}

}

Measured memory_bytes: 26204
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>
#include <map>

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

using namespace std;

int main() {
    int K, S, cnt = 0;
    scanf("%d %d", &K, &S);
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (S - (i + j) >= 0 && S - (i + j) <= K) cnt++;
        }
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 3796
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = Integer.valueOf(sc.nextInt());
		int W = Integer.valueOf(sc.nextInt());
		if(S > W) {
			System.out.println("safe");
		}else {
			System.out.println("unsafe");
		}
		
	}
}

Measured memory_bytes: 35816
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

string s;
string u = "01+-*()";
bool isnum(char t) {
	return '0' <= t && t <= '9';
}

vector<int> v;


ll ans = -INF;

stack<int> st; int tmp;
ll expr(string &s, int &i);
ll term(string &s, int &i);
ll factor(string &s, int &i);
ll number(string &s, int &i);

bool  valid = true;
ll expr(string &s, int &i) {
	ll x = term(s, i);
	while (i < s.size()&&(s[i]=='+'||s[i]=='-')) {
		tmp++;
		char ope = s[i];
		i++;
		ll x2 = term(s, i);
		if (ope == '-')x -= x2;
		else x += x2;
		if (x < 0 || x >= 1024)valid = false;
	}
	return x;
}
ll term(string &s, int &i) {
	ll x = factor(s, i);
	while (i < s.size() && s[i] == '*') {
		tmp++;
		i++;
		ll x2 = factor(s, i);
		x *= x2;
		if (x < 0 || x >= 1024)valid = false;
	}
	return x;
}
ll factor(string &s, int &i) {
	if (i == s.size()) {
		valid = false; return 0;
	}
	if (isnum(s[i])) {
		return number(s, i);
	}
	else if (s[i] == '(') {
		st.push(tmp); tmp = 0;
		i++;
		ll x = expr(s, i);
		if (i == s.size() || s[i] != ')') {
			valid = false; return 0;
		}
		i++;
		if (tmp == 0) {
			valid = false; return 0;
		}
		tmp = st.top(); st.pop();
		return x;
	}
	else {
		valid = false; return 0;
	}
}
ll number(string &s, int &i) {
	int res = s[i] - '0';
	i++;
	while (i < s.size() && isnum(s[i])) {
		res = 2 * res + (s[i] - '0'); i++;
		if (res < 0 || res >= 1024)valid = false;
	}
	return res;
}
void calc() {
	int i = 0; valid = true;
	ll num = expr(s, i);
	if (i != s.size())valid = false;
	if (num < 0 || num >= 1024)valid = false;
	if (valid) {
		ans = max(ans, num);
	}
}
void dfs(int id) {
	if (id == v.size()) {
		calc(); return;
	}
	rep(j, 7) {
		s[v[id]] = u[j];
		dfs(id + 1);
	}
}

void solve() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '.')v.push_back(i);
	}
	dfs(0);
	if (ans == -INF)ans = -1;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}




Measured memory_bytes: 3296
/*
R         R R R R        R        R R R      R      R    R    R      R    R R R R                                                     
R         R             R R       R    RR    R R    R    R    R R    R    R              
R         R            R   R      R R R      R  R   R    R    R  R   R    R   R R                 
R         R R R       R R R R     R R        R   R  R    R    R   R  R    R     R                       
R         R          R       R    R   RR     R    R R    R    R    R R    R     R           
R R R R   R R R R   R         R   R     RR   R      R    R    R      R    R R R R               

*/


#include<bits/stdc++.h>
using namespace std;
#define  bf            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll            long long
#define  pb            push_back
#define  pr            10
#define  mx            100000 // 10^6
#define  md            1000000007
#define  result(a)     cout<<a<<endl;
#define  forr(a,x)     for(int i=a;i<=x;i++)
#define  input(n,a)    int a[n];for(int i=0;i<n;i++)cin>>a[i];
#define  print(a)      for(auto it:a)cout<<it<<' '; //0-based 
#define  printt(n,a)   for(i=0;i<n;i++)cout<<a[i]<<' '; //1-based 
#define  sz(a)         cout<<a.size()<<endl; 
#define  prefx(n,a)    for(i=1;i<n;i++)a[i]=a[i-1]+a[i]; //0-based
#define  sortt(v)      sort(v.begin(),v.end());
#define  srt(n,a)      sort(a,a+n);
#define  rev(n,a)      reverse(a,a+n);
#define  revr(a)       reverse(a.begin(),a.end());
#define  yes           cout<<"Yes\n";
#define  no            cout<<"No\n";

int main()
{
  int n,sum=0,r;
  cin>>n;
  r = n;
  while(r>0)
  {
    sum+=(r%10);
    r /=10;
  }
  if(n%sum==0){yes;}
  else {no;}
  
}

Measured memory_bytes: 3604
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n = int(input())

    a = b = c = m = 0

    for i in range(n):
        s = input()
        m += s.count('AB')

        if s[-1] == 'A' and s[0] == 'B':
            c += 1
        else:
            a += s[-1] == 'A'
            b += s[0] == 'B'

    if c and a:
        a -= 1
        m += 1

    if c and b:
        b -= 1
        m += 1

    m += max(0, c - 1) + min(a, b)

    print(m)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 33436
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, s=0;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++) cin >> l[i];
  sort(l.begin(), l.end());
  for(int a=0; a<n; a++) for(int b=a+1; b<n; b++) for(int c=b+1;c<n;c++) if(l[a]+l[b]>l[c]) s++;else break;
  cout << s << endl;
}

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

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }
        // int a, b, c - a lot of implementation
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

bool kaibun(string &s) {
  int i = 0;
  int j = s.length() - 1;
  bool flag = true;
  while (i < j) {
    if (s[i] != s[j]) {
      flag = false;
      break;
    }
    i++;
    j--;
  }
  return flag;
}

int add_x(string &s) {
  int i = 0;
  int j = s.length() - 1;
  int ans = 0;
  while (i < j) {
    if (s[i] != s[j]) {
      if (s[i] == 'x') {
        s.insert(j + 1, "x");
        i++;
        ans++;
      } else if (s[j] == 'x') {
        s.insert(i, "x");
        i++;
        ans++;
      } else {
        assert(false);
      }
    } else {
      i++;
      j--;
    }
  }

  return ans;
}

void remove_x(string &s) {
  int i = 0;
  int j = s.size() - 1;
  while (i <= j) {
    if (s[i] == 'x') {
      s.erase(i, 1);
      j--;
    } else {
      i++;
    }
  }
}

int main() {
  string s;
  cin >> s;
  string origin = s;
  remove_x(s);
  bool kaibun_flag = kaibun(s);
  if (kaibun_flag) {
    int ans = add_x(origin);
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    go = [False]*N
    
    roop = [1]
    now = 1
    while True:
        go[now-1] = True
        now = a[now-1]
        if go[now-1]:
            break
        else:
            roop.append(now)
            go[now-1] = True

    ind = roop.index(now)
    r = len(roop)-ind
    if M < ind:
        print(roop[M])
    else:
        M -= ind
        M %= r
        M += ind
        print(roop[M])
    
if __name__ == "__main__":
    main()

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

int main() {
  string s;
  cin >> s;
  int flag = 0;
  int n = s.size();
  if(n%2 != 0){
    flag = 1;
  }
  else{
  for(int i=0;i<n;i++){
    if(i%2 == 0){
      if(s.at(i)!='h'){
        flag = 1;
        break;
      }
    }
     else{
      if(s.at(i)!='i'){
        flag = 1;
        break;
      }
    }
  }
  }
  if(flag == 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int n,q,a[N],x,y,l=1,r,p[N],ans[N],sq,belong[N],num;
struct node{
	int l,r,bel;
	bool operator < (const node& T) const{
		return (belong[l] ^ belong[T.l]) ? belong[l] < belong[T.l] : ((belong[l] & 1) ? r < T.r : r > T.r);
	}
}querry[N];

int cmp(node a,node b){
    if(a.l/sq!=b.l/sq)return a.l/sq<b.l/sq;
    return a.r/sq<b.r/sq;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=q;i++) cin>>x>>y,querry[i]={x,y,i};
    sq=sqrt(n);
	for(int i=1;i<=n;i++) belong[i]=min(sq,(i-1)/sq+1);
	sort(querry+1,querry+1+q,cmp);
	for(int i=1;i<=q;i++){
		while(querry[i].l<l) num+=!p[a[--l]]++;
		while(querry[i].l>l) num-=!--p[a[l++]];
		while(querry[i].r<r) num-=!--p[a[r--]];
		while(querry[i].r>r) num+=!p[a[++r]]++;
		ans[querry[i].bel]=num;
	}
	for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 17412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    bool flag = true;
    rep(i, n - 1) if (s[i + 1] != '9') {
        flag = false;
        break;
    }

    if (flag)
        cout << s[0] - '0' + 9 * (n - 1);
    else
        cout << s[0] - '0' + 9 * (n - 1) - 1;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26;
int c[27];
int s[366][27];
int a[366];
int sat[366]={};
int last[27]={};
int ans[100010]={};
vector<set<int>> st(27);
void Main(){
    cin >> d;
    For(i,1,n+1) cin >> c[i];
    For(i,1,d+1) For(j,1,n+1) cin >> s[i][j];
    For(i,1,d+1) cin >> a[i];
    For(i,1,27){
        st[i].insert(0);
        st[i].insert(d+1);
    }
    For(i,1,d+1){
        st[a[i]].insert(i);
        sat[i] = sat[i-1] + s[i][a[i]];
        last[a[i]] = i;
        For(j,1,n+1){
            sat[i] -= (i-last[j]) * c[j];
        }
    }
    ans[0]=sat[d];
    int m;
    cin >> m;
    For(x,0,m){
        int t,p,q;
        cin >> t >> q;

        p=a[t];
        st[p].erase(t);

        auto itrp = st[p].lower_bound(t), itrq = st[q].lower_bound(t);
        int rp = *itrp, rq = *itrq;
        itrp--;itrq--;
        int lp = *itrp, lq = *itrq;
        
        int diff=s[t][q]-s[t][p];
        diff -= (t-lp) * (rp-t) * c[p];
        diff += (t-lq) * (rq-t) * c[q];
        ans[x+1] = ans[x] + diff;

        a[t]=q;
        st[q].insert(t);
    }
    For(i,1,m+1) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3932
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val p = new Array[Int](N+1)
  val swaps = new Array[(Int, Int)](M)

  for (i <- 1 to N) {
    p(i) = in.next().toInt
  }
  for(i <- 0 until M){
    val a, b = in.next().toInt
    swaps(i) = (a, b)
  }


  //
  val uf = new UnionFind(N+1)

  for ((a, b) <- swaps) {
    uf.connect(a, b)
  }

  var ans = 0
  for(i <- 1 to N) {
    if(uf.isConnect(p(i), i))
      ans += 1
  }

  println(ans)
}


class UnionFind(v: Int){
  // 根であれば *そのグループの要素数(負)* が、子であれば親の番号が入る。
  val uni = Array.fill(v)(-1)

  // 頂点 v の所属するグループを調べる
  def root(v: Int): Int =
    uni(v) < 0 match{
      case true  =>  // v が親の場合
        return v
      case false =>  // v が子の場合
        uni(v) = root(uni(v))  // 親のrootを調べる
        return uni(v)
    }

  // 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す
  def connect(a: Int, b: Int): Boolean = {
    // まずはそれぞれ根の番号に置き換える
    var ra = root(a)
    var rb = root(b)
    if(ra == rb)
      return false  // a と b がそもそも同じグループに属しているなら即終了

    // ra を大きなグループにしたいので、逆であれば入れ替える
    if(uni(ra) > uni(rb)) {  // rbの方が要素数が多ければ
      var tmp = ra
      ra = rb
      rb = tmp
    }

    // ra と rb を結合し、rb の親を ra とする
    uni(ra) += uni(rb)
    uni(rb) = ra
    return true
  }

  // 頂点 a, b が同じグループであるかを調べる
  def isConnect(a: Int, b: Int): Boolean =
    root(a) == root(b)

  // 頂点 a を含むグループの頂点数を調べる
  def size(a: Int): Int = -uni(root(a))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 48304
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N; cin >> N;
    ll ans = 0;
    REP2(i,1,N+1){
      if(i % 5 != 0 && i % 3 != 0) ans += i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    int minday=0;

    for (int i = 1; i < 10000000; i++)
    {
        C-=A;
        if(i%7==0)C-=B;
        
        minday++;
        if(C<=0){printf("%d\n",minday);break;}
    }
}


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

int main() {
    int D, T, S;
    cin >> D >> T >> S;

    //D/S<=T
    if (D <= T * S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624