akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin >> s;
  int n = s.size(),i,j,x,y,c = 0;cin >> x >> y;bool RL = true,RF = s[0]=='F';
  vector<int> L,U;
  for(i=0;i<n;i++){
    if(s[i] == 'T'){
      if(RL && c) L.push_back(c);
      else if(!RL && c) U.push_back(c);
      c = 0;RL ^= 1;
    }
    else c++;
  }
  if(RL && c) L.push_back(c);
  else if(!RL && c) U.push_back(c);
  bool dpl[L.size()+1][16001] = {},dpu[U.size()+1][16001] = {};//-8000 is 0,8000 is 16000
  dpl[0][8000] = dpu[0][8000] = 1;
  for(i=0;i<L.size();i++){
    for(j=0;j<=16000;j++){
      if(j-L[i]>=0) dpl[i+1][j] |= dpl[i][j-L[i]];
      if(i==0 && RF) continue;
      if(j+L[i]<=16000) dpl[i+1][j] |= dpl[i][j+L[i]];
    }
  }
  for(i=0;i<U.size();i++){
    for(j=0;j<=16000;j++){
      if(j-U[i]>=0) dpu[i+1][j] |= dpu[i][j-U[i]];
      if(j+U[i]<=16000) dpu[i+1][j] |= dpu[i][j+U[i]];
    }
  }
  cout << ((dpl[L.size()][x+8000] && dpu[U.size()][y+8000]) ? "Yes\n":"No\n");
}

Measured memory_bytes: 62848
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var str1 = line[0][0];
	var str2 = line[1][1];
	var str3 = line[2][2];
	var ans = str1 + str2 + str3;
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	char p[53][53];
	for(int i=0;i<a;i++)
		cin>>p[i];
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
		{
			if(p[i][j]=='#') cout<<"#";
			else
			{
				int count=0;
				if(p[i-1][j-1]=='#') count++;
                if(p[i-1][j]=='#') count++;
                if(p[i-1][j+1]=='#') count++;
                if(p[i][j-1]=='#') count++;
                if(p[i][j+1]=='#') count++;
                if(p[i+1][j-1]=='#') count++;
                if(p[i+1][j]=='#') count++;
                if(p[i+1][j+1]=='#') count++;
                cout<<count;
			}
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    ll x,k,d; cin >> x >> k >> d;

    x = abs(x);
    ll cnt = x/d;
    bool f = false;

    if(cnt > k){
        f = true;
        cnt = k;
    }

    if(f){
        cout << abs(x-k*d) << endl;
    }else if(cnt%2 == k%2){
        cout << abs(x-cnt*d) << endl;
    }else{
        if(cnt+1 <= k){
            cout << abs(x-(cnt+1)*d) << endl;
        }else{
            cout << abs(x-(cnt-1)*d) << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3628
n = gets.chomp.to_i
a = []
a = gets.split.map(&:to_i)
cnt = 0
c = 0
hash = Hash.new(0)
a.each do |i|
    hash[i] += 1
end
#p hash

hash.each do |i, j|
    #p "#{i} #{j}"
    if i > j
        cnt += j
    elsif i < j
        cnt += j-i
    end
   # p cnt
end
p cnt



Measured memory_bytes: 14468
#include <stdio.h>

int main(void)
{
    int n;
    int i,j;
    int sum;
    int x;

    scanf("%d", &n);

    sum = 100000;
    for(i = 1; i <= n; i++){
        sum = sum * 1.05;
        if (sum % 1000 != 0){
            x = 10;
            for (j = 0; j < 3; j++){
                if (sum % x != 0){
                    sum = (sum / 1000) * 1000 + 1000;
                    break;
                }else{
                    x *= 10;
                }
            }

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

    return (0);
}


Measured memory_bytes: 2096
int z[9999],r[9999],x;
int f(int a,int b){
	fflush(!printf("? %d %d\n",a,b));
	scanf("%s",&x);
	return x=='Y';
}
int main(){
	int a,b,c=0,h,i;
	if(scanf("%d%d",&a,&b),a<=b){puts("Impossible");return 0;}
	for(i=a+=b;~--i;)!c||f(i,z[c-1])?(z[c++]=i):c--;
	for(h=*z,i=a;~--i;)r[i]=f(h,i);
	for(printf("! "),i=0;i<a;)printf("%d",r[i++]);
	puts("");
}

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

int main(){
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S % 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << os.str();                            \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

using namespace std;

int main() {
    int a, b, c;
    while (cin >> a >> b >> c) {
        print(a^b^c);
    }
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int n,m;
    cin >> n;
    int t[n];
    rep(i,n)cin >> t[i];
    cin >> m;
    int p[m],x[m];
    rep(i,m)cin >> p[i] >> x[i];

    ll sum=0,tem=0;
    rep(i,n)sum += t[i];
    
    for(int i=0;i<m;i++){
        tem=sum-t[p[i]-1]+x[i];
        cout << tem << endl;
        tem =0;
    }
    
    return 0;
}

Measured memory_bytes: 256
# D - Sum of Large Numbers
from itertools import accumulate


def main():
    N, K = map(int, input().split())
    cumsum_left = tuple(accumulate(range(N + 1)))
    cumsum_right = tuple(accumulate(reversed(range(N + 1))))
    total = 0
    MOD = 10 ** 9 + 7
    for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]):
        total += r - l + 1
        total %= MOD
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33128
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))

		for i in range(100):
			Y = X-i
			if Y not in A:
				print(Y)
				break
			Y = X+i
			if Y not in A:
				print(Y)
				break
resolve()

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
int a[100010],b[100010];
vi edge[100010];
int d1[100010],d2[100010];
void add_edge(int from,int to){
  edge[from].push_back(to);
  edge[to].push_back(from);  
}
//sからの距離をBFSで求める
void bfs1(int s){
  rep(i,N) d1[i]=INF;
  d1[s]=0;
  std::queue<pi> q;
  q.push(mp(s,0));
  while(!q.empty()){
    pi p=q.front();q.pop();
    int f=p.first,s=p.second;
    rep(i,edge[f].size()){
      int e=edge[f][i];
      if(d1[e]==INF){
	d1[e]=s+1;
	q.push(mp(e,d1[e]));
      }
    }
  }
}
void bfs2(int s){
  rep(i,N) d2[i]=INF;
  d2[s]=0;
  std::queue<pi> q;
  q.push(mp(s,0));
  while(!q.empty()){
    pi p=q.front();q.pop();
    int f=p.first,s=p.second;
    rep(i,edge[f].size()){
      int e=edge[f][i];
      if(d2[e]==INF){
	d2[e]=s+1;
	q.push(mp(e,d2[e]));
      }
    }
  }
}
std::string solve(){
  rep(i,N-1) add_edge(a[i],b[i]);
  bfs1(0);bfs2(N-1);
  int Fennec=0,Snuke=0;
  rep(i,N){
    //  std::cout<<i<<d1[i]<<d2[i]<<"\n";
    if(d1[i]<=d2[i]) Fennec++;
    else Snuke++;
  }
  //  prin2(Fennec,Snuke);
  if(Fennec>Snuke) return "Fennec";
  else return "Snuke";
}
int main(){
  cin>>N;
  rep(i,N-1){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  prin(solve());
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

int n,x, arr[10];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
   // freopen("test.txt", "r", stdin);
    cin >> n;
    FOR(i,0,n) {
        cin >> x;
        if (x >= 3200) arr[9]++;
        else arr[x / 400]++;  
    }
    int ans1 = 0, ans2 = 0;
    FOR(i,0,8) {
        ans1 += !!arr[i];
        ans2 += !!arr[i];
    }
    if (ans1 == 0 && arr[9]) ans1++;
    ans2 += arr[9];
    cout << ans1 << " " << ans2;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    string s = to_string(N);
    int res = 0;
    int L = s.size();
    bool ok = 1;
    for (int i = 1;i < L;i++) {
    	if (s[i] != '9') ok = 0;
    }
    if (L == 1) {
    	cout << s[0] - '0' << endl;
    	return 0;
    }
    if (ok) {
    	cout << s[0] - '0' + 9 * (L - 1) << endl;
    	return 0;
    }
    s[0]--;
    cout << (s[0] - '0') + 9 * (L - 1) << endl;
    return 0;
}

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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<ll> A(N);

    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    ll ans = A[0] / 2;
    A[0] %= 2;
    for(int i=1;i<N;i++){
        ll use = min(A[i], A[i-1]);
        A[i] -= use;
        use += A[i] / 2;
        A[i] %= 2;
        ans += use;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        Pattern p = Pattern.compile("[a-z]");
        Matcher m = p.matcher(a);
        System.out.println(m.find() ? "a" : "A");
        scan.close();
    }
}

Measured memory_bytes: 26984
from collections import deque

S = input()
Q = int(input())

t = deque(S)
reverse = False
for _ in range(Q):
    query = input()
    if query[0] == '1':
        reverse = not reverse
    elif query[0] == '2':
        _, F, C = query.split()
        if F == '1':
            if reverse:
                t.append(C)
            else:
                t.appendleft(C)
        elif F == '2':
            if reverse:
                t.appendleft(C)
            else:
                t.append(C)
result = ''.join(t)
if reverse:
    result = result[::-1]
print(result)

Measured memory_bytes: 8564
val M = 1000000007L

fun co(n: Long): Co {
    return Co((n % M + M) % M)
}

fun main(args: Array<String>) {
    val s = readLine()!!
    val dp = Array(s.length + 1) {Array(13){co(0)}}
    dp[0][0] = co(1)
    for (i in 0 until s.length) {
        if (s[i] == '?') {
            for (j in 0 until 13) {
                for (d in 0 until 10) {
                    dp[i+1][(j * 10 + d) % 13] += dp[i][j]
                }
            }
        } else {
            val c = Character.getNumericValue(s[i])
            for (j in 0 until 13) {
                dp[i+1][(j * 10 + c) % 13] += dp[i][j]
            }
        }
    }
    println(dp[s.length][5].n)
}

data class Co(val n: Long) {
    operator fun plus(other: Co): Co {
        return co(n + other.n)
    }
    operator fun minus(other: Co): Co {
        return co(n - other.n)
    }
    operator fun times(other: Co): Co {
        return co(n * other.n)
    }
    operator fun div(other: Co): Co {
        return this * other.pow(M - 2)
    }
    fun pow(k_: Long): Co {
        var k = k_
        var a = this
        var res = co(1)
        while (k > 0) {
            if (k.and(1) == 1L) {
                res *= a
            }
            a *= a
            k = k.shr(1)
        }
        return res
    }
}

Measured memory_bytes: 173120
object Main extends App{
    val n = scala.io.StdIn.readInt
    var tp = 0
    var ans = 0

    for(i<-1 to n by 2){
    	tp = 0
    	for(j<-1 to i){
    		if(i%j == 0){
    			tp += 1
    		}
    	}

    	if(tp == 8){
    		ans += 1
    	}
    }

    println(ans)
}


Measured memory_bytes: 27324
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  const long long mod = 1000000000 + 7;
  long long n, m;
  cin >> n >> m;

  if (abs(n - m) > 1) {
    cout << 0 << endl;
  } else {
    long long ans = 1;
    for (int i = 1; i <= n; i++) {
      ans *= i;
      ans %= mod;
    }
    for (int i = 1; i <= m; i++) {
      ans *= i;
      ans %= mod;
    }
    if (n == m) {
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    string S;
    cin >> S;

    int cnt = 0;
    vector<int> v;
    v.push_back(cnt);
    REP(1, i, S.length()) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            cnt++;
        }

        v.push_back(cnt);
    }

    int l[Q], r[Q];
    REP(0, i, Q) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }

    REP(0, i, Q) {
        int ans = v[r[i]] - v[l[i]];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2296
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[20];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	if(n%2){
		printf("No\n");return 0;
	}
	for(int i=0;i<n;i++){
		if(i%2==0&&in[i]!='h'){
			printf("No\n");return 0;
		}
		if(i%2==1&&in[i]!='i'){
			printf("No\n");return 0;
		}
		
	}printf("Yes\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
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++)

int main() {
  int n;
  cin>>n;
  string s,t;
  cin >> s>>t;
  int co=0;
  int ans=0;
  rep(i,n){
    int co=0;
    rep(j,n-i){
      if(t.at(j)==s.at(j+i)){
        co++;
      }
      else{
        ans=max(ans,co);
        co=0;
      }
    }
    ans=max(ans,co);
  }
  
  cout<<n*2-ans<<endl;
 
}

Measured memory_bytes: 256
DIV = 100000
while 1:
    w, h = map(int, raw_input().split())
    if w == 0: break
    dp = [[[0]*4 for i in range(w + 1)] for j in range(h + 1)]
    dp[1][0][0] = dp[0][1][3] = 1
    for i in range(h):
        for j in range(w):
            dp[i + 1][j][0] += (dp[i][j][0] + dp[i][j][2]) % DIV
            dp[i][j + 1][1] += dp[i][j][0] % DIV
            dp[i + 1][j][2] += dp[i][j][3] % DIV
            dp[i][j + 1][3] += (dp[i][j][1] + dp[i][j][3]) % DIV
    print sum(dp[h - 1][w - 1]) % DIV

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

using namespace std;

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

    bool res = s.size() % 2 == 0;
    for (int i = 0; i < static_cast<int>(s.size()); i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            res = false;
        }
    }

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];

    writeln(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) ? "Yes" : "No");
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int A[N+1], B[N], A_copy[N+1];
  for (int i = 0; i < N + 1; i++) { cin >> A[i]; }
  for (int i = 0; i < N; i++) { cin >> B[i]; }
  copy(A, A+N+1, A_copy);
  for (int i = 0; i < N; i++) {
    if (A[i] >= B[i]) {
      A[i] -= B[i];
      B[i] = 0;
    } else {
      B[i] -= A[i];
      A[i] = 0;
      A[i+1] = max(0, A[i+1] - B[i]);
    }
  }
  long s = 0;
  for (int i = 0; i < N + 1; i++) {
    //cout << A[i] << endl;
    s += A_copy[i] - A[i];
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
struct data{
	int x,y,id;
};
int n,m;
data s[100005];
int kk[100005];
int ans1[100005],ans2[100005];
bool cmp(data x, data y) {
	return x.x<y.x;
}
void print(int x) {
	int digit=0,y=x;
	while(y>0) {
		y/=10;
		digit++;
	}
	for(int i=0; i<6-digit; i++) printf("0");
	printf("%d",x);
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++) {
		scanf("%d%d",&s[i].y,&s[i].x);
		s[i].id=i+1;
	}
	sort(s,s+m,cmp);
	for(int i=0; i<m; i++) {
		ans1[s[i].id]=s[i].y;
		kk[s[i].y]++;
		ans2[s[i].id]=kk[s[i].y];
	}
	for(int i=1; i<=m; i++) {
		print(ans1[i]);
		print(ans2[i]);
		printf("\n");
	}
} 

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

P bino(vector<ll>& array, ll s, ll e){
  ll a = s;
  ll b = e;
  ll base = s == 0 ? 0 : array[s-1];
  if (e - s == 1) {
    return P(array[s] - base, array[e] - array[s]);
  }
  while(b - a > 1){
    ll i = (a + b) / 2;
    ll tmp = array[e] - 2 * array[i] + base;
    if (tmp >= 0){
      a = i;
    }else{
      b = i;
    }
  }

  if (abs(array[e] - 2 * array[a] + base) < abs(array[e] - 2 * array[b] + base)){
    return P(array[a] - base, array[e] - array[a]);
  }else{
    return P(array[b] - base, array[e] - array[b]);
  }
}

int main() {

  ll n;
  cin >> n;
  vector<ll> array(n), summ(n);
  REP(i, n) {
    cin >> array[i];
    if (i != 0) summ[i] = summ[i-1] + array[i];
    else summ[i] = array[i];
  }

  ll j = 0;
  ll l = 2;
  ll ans = 1e9 + 5;
  vector<ll> tmp(4);
  for(ll i = 1; i < n - 2; i++) {

    P p = bino(summ, 0, i);
    P q = bino(summ, i+1, n-1);
    tmp[0] = p.first;
    tmp[1] = p.second;
    tmp[2] = q.first;
    tmp[3] = q.second;
    sort(tmp.begin(), tmp.end());
    ans = min(ans, tmp[3] - tmp[0]);

  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
 
char str[110];
int i,j,k,l,m,n;
int n,e,s,w;
int a[105][7],b[105][7];
int t;
 
void input() {
 
  scanf("%d",&n);
 
  for(j=0;j<n;j++){
  for(i=0;i<6;i++){
    scanf("%d",&a[j][i+1]);
    b[j][i+1] = a[j][i+1];
    // printf("a[%d] = %d\n",i+1,a[i+1]);
  }
  }
}
 
void N() {
  t = a[m][1];
  a[m][1] = a[m][2];
  a[m][2] = a[m][6];
  a[m][6] = a[m][5];
  a[m][5] = t;
}
 
void S() {
  t = a[m][1];
  a[m][1] = a[m][5];
  a[m][5] = a[m][6];
  a[m][6] = a[m][2];
  a[m][2] = t;
}
 
void E() {
  t = a[m][1];
  a[m][1] = a[m][4];
  a[m][4] = a[m][6];
  a[m][6] = a[m][3];
  a[m][3] = t;
}
 
void W() {
  t = a[m][1];
  a[m][1] = a[m][3];
  a[m][3] = a[m][6];
  a[m][6] = a[m][4];
  a[m][4] = t;
}
 
void UF() {
 
  if(a[k][1] == a[m][1]) { // if qu == 1;
    // printf("qu == 1\n");
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][5]) strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
 
 
  }  else if(a[k][1] == a[m][2]) {  // if qu == 2;
    // printf("qu == 2\n");
    if(a[k][2] == a[m][3])  strcpy( str, "NWS");
    else if(a[k][2] == a[m][1] ) strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    N();
 
 
  } else if(a[k][1] == a[m][3]){ // if qu == 3;
    //   printf("qu(%d) == %d\n",qu[k],a[3]);    
    if(a[k][2] == a[m][6])  strcpy( str, "NWS");
    else if(a[k][2] == a[m][5])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][1]) strcpy(str,"NES");
    W();
 
 
  } else if(a[k][1] == a[m][4]) {
    if(a[k][2] == a[m][1]) strcpy( str, "NWS");
    if(a[k][2] == a[m][5])  strcpy(str ,"NEES");
    if(a[k][2] == a[m][6]) strcpy(str,"NES");
    E();
 
 
  } else if(a[k][1] == a[m][5]) {
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][6])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    S();
 
 
  } else if(a[k][1] == a[m][6]) {
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][2])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    N();
    N();
  }
 
 
}
 
 
void output() {
 
  if(l == 6) printf("No\n");
  else printf("Yes\n");
}
 
void IF() {
 
  for(i=0;i<strlen(str);i++) {
 
    if(str[i] == 'N') N();
    else if(str[i] == 'S') S();
    else if(str[i] == 'W') W();
    else if(str[i] == 'E') E();
  }
}
 
int main() {
 
 
  input();
 
  for(k=0;k<n;k++) {
    for(m=0; m<n;m++) {
 
    UF();
     
    IF();
 
    l=0;
 
    if(k != m) {
    for(i=1; i<=6;i++) {
      if(a[k][i] == a[m][i]) l++;
      // printf("{a[%d][%d]=%d}  == {a[%d][%d]=%d} ?\n",k,i,a[k][i],m,i,a[m][i]);
    }
    }
 
    if(l == 6) break;
 
    }
    if(l ==6) break;
  }
 
   
    output();
 
 
 
  //  strlen(?) ???????????????(??°)
 
 
  return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char szInputStr[210];
    int iShaffle;
    int iShaffleStrlen;
    int iCount, iCount2;
    char iSlideTmp;

    while (1) {
        scanf("%s", szInputStr);
        if (strcmp(szInputStr, "-") == 0) break;
        scanf("%d", &iShaffle);
        
        for (iCount = 0; iCount < iShaffle; iCount++) {
            scanf("%d", &iShaffleStrlen);
            while (iShaffleStrlen != 0) {
                iSlideTmp = szInputStr[0];
                for (iCount2 = 1; iCount2 < strlen(szInputStr); iCount2++) {
                    szInputStr[iCount2 - 1] = szInputStr[iCount2];
                }
                szInputStr[strlen(szInputStr) - 1] = iSlideTmp;
                iShaffleStrlen--;
            }
        }
        printf("%s\n", szInputStr);
    }

    return 0;
}


Measured memory_bytes: 2048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BChooseIntegers solver = new BChooseIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BChooseIntegers {
        private static final String YES = "YES";
        private static final String NO = "NO";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int a = in.ints(), b = in.ints(), c = in.ints();
            int gcd = gcd(a, b);
            out.println(c % gcd == 0 ? YES : NO);
        }

        private static int gcd(int a, int b) {
            int t;
            while (a % b > 0) {
                t = b;
                b = a % b;
                a = t;
            }
            return b;
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21332
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 61624
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() 
{
	long long n,w,sum(0);
	cin >> n >> w;
	
	vector<long long>cost(n),weight(n);
	for(int i = 0;i<n;++i){
		cin >> weight[i] >> cost[i];
		sum += cost[i];
	}
	
	vector<long long>v(sum+1,1e9);
	v[0] = 0;
	
	for(int i = 0;i<n;++i){
		
		for(long long j = sum-cost[i];j>=0;--j){
		
			v[j+cost[i]] = min(v[j+cost[i]],v[j] + weight[i]);
			
		}
		
	}
	
	long long ma = 0;
	
	//for(int i = 1;i<=sum;++i)if(v[i] != 1e4)cout << i << ' ' << v[i] << "\n"; 
	//cout << "\n";
	for(long long i = 1;i<=sum;++i)if(v[i] <= w)ma = max(ma,i);
	
	cout << ma;
	
	return 0;
}

Measured memory_bytes: 1024
N = [int(i) for i in str(input())]
m = len(N)
K = int(input())
dp = [[[0 for i in range(K + 1)],[0 for i in range(K + 1)]]   for i in range(m)]
#初期条件
dp[0][1][0] = 1
dp[0][0][1] = 1
dp[0][1][1] = N[0] - 1
for i in range(1,m):
    for t in range(0,min(i+2,K+1)):
        if N[i] != 0:
            if t == 0:
                dp[i][1][t] = dp[i-1][1][t]
            else:
                dp[i][0][t] = dp[i-1][0][t-1]
                dp[i][1][t] = dp[i-1][0][t] + dp[i-1][0][t-1] * (N[i]-1) + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
        else :
            if t == 0:
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] 
            else :
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] + dp[i-1][1][t-1] * 9
print(dp[-1][0][K]+dp[-1][1][K])

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

using namespace std;

int main()
{
   int A[3], ans=0;
   for(int i=0; i<3; i++)
   {
     cin>>A[i];
   }
   sort(A,A+3);
   for(int i=1; i<3; i++)
   {
     ans+=(abs(A[i]-A[i-1]));
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a[500]={0,300000,200000,100000,0};
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==1&&y==1)
    {
        printf("%lld\n",1000000);
    }
    else
        printf("%lld\n",a[x]+a[y]);
    return 0;
}


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

#define ll long long

bool cmp(ll a, ll b)

{
    return a > b;
}

int main()

{
    ll n, h;
    cin >> n >> h;
    ll thrown[n + 5];

    ll mx = INT_MIN;
    for(int i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp >> thrown[i];
        mx = max(tmp, mx);
    }

    sort(thrown, thrown + n, cmp);

    ll cnt = 0, sum = 0;
    for(int i = 0; i < n; i++) {
        if(thrown[i] < mx)
            break;
        sum += thrown[i];
        cnt++;
        if(sum >= h)
            break;
    }

    if(sum < h) {
        cnt = cnt + ( (h - sum) / mx);
        if((h - sum) % mx != 0)
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
ab = list(map(int, input().split()))
a = ab[0]
b = ab[1]
answer = 0

for i in range(40):
    if i != 0:
        a_mod = a % 2 ** (i + 1)
        b_mod = b % 2 ** (i + 1)
        if a_mod > 2 ** i:
            a_mod_1 = 2 ** (i + 1) - a_mod
        else:
            a_mod_1 = 2 ** i
        if b_mod >= 2 ** i:
            b_mod_1 = b_mod - 2 ** i + 1
        else:
            b_mod_1 = 0
        num_of_1 = a_mod_1 + b_mod_1
    else:
        if b % 2 == 1:
            if (b - a) % 4 == 2 or (b - a) % 4 == 3:
                num_of_1 = 0
            else:
                num_of_1 = 1
        else:
            if (b - a) % 4 == 1 or (b - a) % 4 == 2:
                num_of_1 = 1
            else:
                num_of_1 = 0
    answer = answer + (num_of_1 % 2) * (2 ** i)

print(answer)

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

using namespace std;

#define sp << " " <<

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int d,p;
    cin >> d >> p;
    d++;
    if(p>d/2)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
const int maxn = 21;
const ll mod = 1e9 + 7;
ll dp[1 << maxn][maxn + 1];
int v[maxn][maxn];

int count_ones(int mask, int n) {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (mask & (1 << i)) > 0;
  }
  return cnt;
}

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

  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> v[i][j];
  for (int i = 0; i < (1 << n); i++) dp[i][n] = 0;
  dp[(1 << n) - 1][n] = 1;

  for (int i = (1 << n) - 2; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (count_ones(i, n) != j) continue;

      ll& ans = dp[i][j];
      ans = 0;

      for (int k = 0; k < n; k++) {
        if (i & (1 << k)) continue;
        if (!v[j][k]) continue;
        ans += dp[i | (1 << k)][j + 1];
        ans %= mod;
      }
    }
  }
  cout << dp[0][0] << endl;

  return 0;
}


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

int main(){
  long int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= K) {
     cout << K << endl;
  }
  else if (A + B >= K) {
    cout << A << endl;
  }
 
  else {
    cout << A - (K-A-B) << endl;
  }
}

Measured memory_bytes: 3608
a, b, c = map(int, input().split())
 
if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
elif a == b == c:
    print(-1)
else:
    num = 0
    while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
        a, b, c = (b+c)/2, (a+c)/2, (a+b)/2
        num += 1
    print(num)

Measured memory_bytes: 9236
#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++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}
ll exp(ll a, ll b,ll c){
  if(b==0)return 1;
  if(b%2==0){
    ll t =exp(a,b/2,c);
    return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}
const ll big=1000000007;


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int k=(a+d-1)/d;
    int l=(c+b-1)/b;
    if(k>=l)cout << "Yes";
    else cout << "No";
    cout << endl;
}

Measured memory_bytes: 3636
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 4e3 + 10, D = 8e3 + 10;

bool dp[N][D], seen[N][D];

bool solve(vector <int> &a, int i, int j);

int main() {
	string s; int x, y;
	cin >> s >> x >> y;
	int n = s.length(), st = 0;
	while (st < n and s[st] == 'F') {
		--x;
		++st;
	}

	int cur = 0;
	vector <int> moves[2];
	moves[1].push_back(0);
	for (int i = st; i < n; ++i) {
		if (s[i] == 'T') {
			if (moves[cur].empty() or moves[cur].back() > 0) {
				moves[cur].push_back(0);
			}

			while (i < n and s[i] == 'T') {
				cur = 1 - cur;
				++i;
			}
			--i;
		}  else {
			++moves[cur].back();
		}
	}

	bool ans = solve(moves[0], moves[0].size() - 1, abs(x));
	memset(seen, 0, sizeof(seen));
	ans = ans and solve(moves[1], moves[1].size() - 1, abs(y));
	if (ans) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

bool solve(vector <int> &a, int i, int d) {
	if (i < 0) {
		return !d;
	} else if (d >= D) {
		return false;
	} else if (seen[i][d]) {
		return dp[i][d];
	}

	seen[i][d] = true;
	dp[i][d]   = solve(a, i - 1, abs(d + a[i])) or solve(a, i - 1, abs(d - a[i]));
	return dp[i][d];
}

Measured memory_bytes: 53632
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();

		while (true) {
			s = s.substring(0, s.length() - 1);
			if (s.length() % 2 == 0 && (s.substring(0, s.length() / 2) + s.substring(0, s.length() / 2)).equals(s)) {
				System.out.println(s.length());
				return;
			}
		}

	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  string str1,str2,p;
  int q;
  int a,b;
  char t;
  int i,j,k;

  cin >>str1;
  cin >>q;

  for(j=0;j<q;j++){
    cin >>str2;
  
    if(str2=="replace"){
      cin >>a >>b >>p;
      k=0;
      for(i=a;i<=b;i++){
	str1[i]=p[k];
	k++;
      }
    }

    if(str2=="reverse"){
      cin >>a >>b;
      for(i=a;i<=b;i++,a++,b--){
	t=str1[i];
	str1[a]=str1[b];
	str1[b]=t;
      }
    }

    if(str2=="print"){
      cin >>a >>b;
      for(i=a;i<=b;i++){
      cout <<str1[i];
      }
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let ws = sc.vec::<i32>(2);
    let xs = sc.vec::<i32>(2);
    let r: i32 = sc.next();

    for i in 0..2 {
        let x = xs[i];
        let w = ws[i];
        if x < r || w - r < x {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
}



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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int a[m];
  bool cost[n] = {};
  for(int i = 0; i < m; i++) {
    cin >> a[i];
    cost[a[i] - 1] = 1;
  }
  int ans1 = 0, ans2 = 0;
  for(int i = 0; i < x; i++) {
    if(cost[i]) ans1++;
  }
  for(int i = x; i < n; i++) {
    if(cost[i]) ans2++;
  }
  cout << min(ans1, ans2);
  return 0;
}


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

flag = 0
i = 2
a = [n]

while flag==0:


    if n%2==0:
        n = n/2
        if n in a:
            flag += 1
        a.append(n)
    else:
        n = 3*n+1
        if n in a:
            flag += 1
        a.append(n)

    i += 1

print(i-1)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d",&N);

  int count=0;

  for (int i = 1; i <= N; i++) {
    int n;
    scanf("%d",&n);
    if (i % 2 != 0 && n % 2 != 0) {
      count++;
    }
  }
  printf("%d",count);
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

// アルファベット小文字
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
  string s;
  int K;
  cin >> s >> K;
  int N = s.size();
  for (int i=0; i<N; i++) {
    if (('z'-s[i])+1<=K&&s[i]!='a') {
      K -= ('z'-s[i])+1;
      s[i] = 'a';
    }
    if (i==N-1) {
      K %= 26;
      for (int j=0; j<K; j++) {
        if (s[i]=='z') s[i] = 'a';
        else s[i]++;
      }
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3740
from itertools import product
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for i in range(n)]
ans=100000000000000000
for i in product([0,1],repeat=n):
    check=[0]*m
    ans_=0
    for j in range(n):
        if i[j]:
            #(✳︎)
            ans_+=ca[j][0]
            for k in range(m):
                check[k]+=ca[j][k+1]
    if all([l>=x for l in check]):
        ans=min(ans,ans_)
if ans==100000000000000000:
    print(-1)
else:
    print(ans)

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

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

    int d = INT_MAX;
    for (int i = 0, n = s.length() - 3; i <= n; i++) 
        d = min(d, abs(atoi(s.substr(i, 3).c_str()) - 753));

    cout << d << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;
    ll ans = 0;
        ll N = S.size();
        int l = 0,r = N-1;
        vector<ll> len;
        int a = 1;
        for(int i=1;i<N;i++){
            if(S[i-1]==S[i]) a++;
            else{
                len.push_back(a);
                a = 1;
            }
        }
        len.push_back(a);
//        cerr << len.size() << endl;
        if(S[0]!=S[N-1]){
            for(auto x:len) ans += x/2*K;
        }else{
            if(len.size()==1) ans = N*K/2;
            else{
                for(int i=1;i<len.size()-1;i++) ans += len[i]/2*K;
                ans += len[0]/2+len[len.size()-1]/2;
                ans += (len[0]+len[len.size()-1])/2*(K-1);
            }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a, b, c = map(int, input().split())
for i in range(1, 100000):
    if (b*i + c)%a == 0:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 9264
import sys

n=int(input())
min=sys.maxsize
max=-sys.maxsize
sum=0

line=input().rstrip().split()
for i in range(n):
    tmp=int(line[i])
    sum+=tmp
    if max<tmp:
        max=tmp
    if tmp<min:
        min=tmp

print(f"{min} {max} {sum}")



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

int main(){
  string s; cin >> s;
  int ans = 0;
  if(s == "RRR") ans = 3;
  else if(s == "RRS" || s == "SRR") ans = 2;
  else if(s == "SSS") ans = 0;
  else ans = 1;

  cout << ans << endl;

  return 0;
}


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

string a,b="CF"; 
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ 
            bl++;
            if(bl==2)   
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        if(n < 1200)System.out.println("ABC");
        else if (n < 2800)System.out.println("ARC");
        else System.out.println("AGC");
    }
}


Measured memory_bytes: 21844
#include<vector>
#include<cmath>
#include<cstdio>
using ll=long long;
constexpr ll max_xy=1e9;
int main(){
    ll s;
    scanf("%lld",&s);
    ll sqrts=sqrt(s);
    if(sqrts*sqrts==s){
        printf("0 0 0 %lld %lld 0",sqrts,sqrts);
        return 0;
    }
    ll a=sqrts, y=sqrts+1, b=1, x=a*y-s;
    if(x<0){
        a=sqrts+1;
        x=a*y-s;
    }
    printf("0 0 %lld %lld %lld %lld", a,b,x,y);
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np


N, X = map(int, input().split())
L = np.array(list(map(int, input().split())))
L = np.append(0, L)

l_cum = np.cumsum(L)
print(sum(l_cum <= X))






# def main():

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


Measured memory_bytes: 12300