akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int n = sc.nextInt();
        sc.nextLine();
        List<List<Character>> S = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            List<Character> l = new ArrayList<>();
            String s = sc.nextLine();
            for (int j = 0; j < s.length(); ++j) {
                l.add(s.charAt(j));
            }
            Collections.sort(l);
            S.add(l);
        }
        int minLen;
        List<Character> ans = new ArrayList<>();
        do {
            minLen = Integer.MAX_VALUE;
            for (int i = 0; i < n; ++i) {
                minLen = Math.min(minLen, S.get(i).size());
            }
 
            if (minLen > 0) {
                int minCh = S.get(0).get(0);
                for (int i = 1; i < n; ++i) {
                    minCh = Math.min(minCh, S.get(i).get(0));
                }
                boolean ok = true;
                for (int i = 0; i < n; ++i) {
                    if (S.get(i).get(0) != minCh) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    ans.add((char)minCh);
                }
                for (int i = 0; i < n; ++i) {
                    if (S.get(i).get(0) == minCh) {
                        S.get(i).remove(0);
                    }
                }
            }
        } while (minLen > 0);
        Collections.sort(ans);
        for (char ch : ans) {
            _out.print(ch);
        }
        _out.println();
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int main(){
  char s[11];  scanf("%s", s);
  int flag = 1;
  if(s[0] != 'A'){
    flag = 0;
  }else{
    int ccount = 0;
    for(int i=2; i<strlen(s)-1; i++)
      if(s[i] == 'C')  ccount++;
    if(ccount != 1){
      flag = 0;
    }else{
      for(int i=1; i<strlen(s); i++)
	if(!(s[i]=='C' || (s[i]!='C' && (int)s[i] >= 97 && (int)s[i] <= 122) )){
	  flag = 0;
	  break;
	}
    }
  }
  if(flag)
    printf("AC\n");
  else
    printf("WA\n");
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define MOD 1000000007
#define PI 3.1415926535

int main(void) {
  int N;
  cin >> N;
  N %= 10;

  if (N == 3)
    cout << "bon" << endl;
  else if (N == 0 || N == 1 || N == 6 || N == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}


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

int main(){
   
    int N;
    int K;
    cin>>N>>K;
    vector<int> S(K);
    for(int i=0;i<K;i++){
        cin>>S[i];
    }
    bool flag=true;
    for(int i=N;flag;i++){
       flag=false;
        int ii=i;
        for(int j=0;ii!=0;j++){
            for(int k=0;k<K;k++){
                if(ii%10==S[k]){
                    flag=true;
                    break;
                }
        }
            ii/=10;
        }
        if(!flag) cout<<i<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vii;
int n,m[3],a;
int main()
{
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		a%4==0?m[2]++:(a%2==0?m[1]++:m[0]++);
	}
	if(m[1]>0) m[0]++;
	if(m[2]>m[0]-2) puts("Yes");
	else puts("No"); 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------


int main(){
    ll n; cin >> n;
    ll a[5];
    FOR(i,0,4){
        cin >> a[i];
    }
    ll mn = LINF;
    FOR(i,0,4){
        if(mn > a[i]) mn = a[i];
    }
    ll ans;
    if(n%mn == 0){
        ans = 5 + n/mn-1;
    }
    else ans = 5 + n/mn;
    cout << ans;
    /*
    ll mn = LINF;
    ll ans = 5;
    FOR(i,1,5){
        if(mn > a[i]){
            ans += n/a[i] + 1;
            ans 
        }
    }*/
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <regex>

/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;



using ll = long long;
using ull = unsigned long long;
constexpr ll N = 2e5;

constexpr ull max_num = 1e18;
ull a[N];
*/

using ull = unsigned long long;
using ll = long long;

using namespace std;


int main() {
   
	int a;
	cin >> a;
	
	cout << a + a * a + a * a * a;
	
	return 0;
	
}


Measured memory_bytes: 3192
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int K, R;
    cin >> K >> R;
    K = min(K, 10);
    cout << R + 100 * (10 - K) << endl;
    return 0;
};

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (a <= x && x <= a + b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

int main() {
	int i, j;
	
	cout << "";
	cin >> i >> j;
	if (1 <= i and i <= 10000 and 1 <= j and j <= 10000) {
		if (i*j % 2 == 1) {
			cout << "Odd";
		}
		else {
			cout << "Even";
		};
	};
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100000
#define Q 100000

int BinarySearch(int*, int, int);

int main() {
  int S[N];
  int T[Q];
  int i,j,x,y,res,count = 0;

  scanf("%d",&x);
  for(i = 0; i < x; i++) {
    scanf("%d",&S[i]);
  }

  scanf("%d",&y);
  for(i = 0; i < y; i++) {
    scanf("%d",&T[i]);
  }

  for(i = 0; i < y; i++) {
    res = BinarySearch(S,T[i],x);
    if(res != -1) {
      count++;
    }
  }

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

  return 0;
}

int BinarySearch(int *S, int a, int x) {
  int right = x,left = 0,mid;

  while(left < right) {
    mid = (left + right) / 2;
    if(S[mid] == a) {
      return mid;
    }else if(a < S[mid]) {
      right = mid;
    }else{
      left = mid + 1;
    }
  }
    return -1;
  }
				

  

  
  



Measured memory_bytes: 2288
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        REP (i, N) par[i] = i;
    }

    ll root (ll x) {
        if (par[x] == x) return x;
         return par[x] = root(par[x]);
    }

    void unite (ll x, ll y) {
         ll rx = root(x);
         ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    ll N;
    cin >> N;
    vector<pair<ll, ll>> cox(N), coy(N);
    REP (i, N) {
        ll x, y;
        cin >> x >> y;
        cox[i] = make_pair(x, i);
        coy[i] = make_pair(y, i);
    }

    sort(cox.begin(), cox.end());
    sort(coy.begin(), coy.end());

    // Kruskal's Algorithm
    priority_queue<tuple<ll, ll, ll>> edge;
    UnionFind tree(N);
    REP (i, N-1) {
        edge.push(make_tuple(cox[i].first - cox[i+1].first,
            cox[i].second, cox[i+1].second));
        edge.push(make_tuple(coy[i].first - coy[i+1].first,
            coy[i].second, coy[i+1].second));
    }
    
    ll count = 0;
    ll ans = 0;
    while (count < N - 1) {
        auto e = edge.top();
        edge.pop();
        ll cost = get<0>(e) * -1;
        ll a = get<1>(e);
        ll b = get<2>(e);
        if (!tree.same(a, b)) {
            ans += cost;
            count++;
            tree.unite(a, b);
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 12272
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    p = list(map(int, readline().split()))
    p = [x - 1 for x in p]
    c = list(map(int, readline().split()))
    ans = -INF

    for i in range(n):
        cur = i
        nx = -1
        cnt = 0
        score_dict = dict()
        score_dict[0] = 0
        score = 0
        rem = k
        while rem > 0 and nx != i:
            cnt += 1
            rem -= 1
            nx = p[cur]
            score += c[nx]
            score_dict[cnt] = score
            ans = max(ans, score)
            cur = nx

        if rem > 0 and score > 0:
            loop = (rem - 1) // cnt
            if loop > 0:
                score += score * loop
                rem -= loop * cnt
            for j in range(rem + 1):
                st = score + score_dict[j]
                ans = max(ans, st)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 169572
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++) 
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
int a[1005];
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main(int argc, char** argv) {
	ll n,k;
	cin>>n>>k;
	cout<<min(((n+k)%k+k)%k,abs(k-(n+k)%k+k)%k);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int n,b,f,r,v;
    int res[4][3][10]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        res[b-1][f-1][r-1]+=v;
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<3;k++){
            for(int l=0;l<10;l++){
                cout<<" "<<res[j][k][l];
            }
            cout<<endl;
        }
        if(j!=3)
        cout<<"####################"<<endl;
    }
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(){
	
	int count , n , a , min = 10000000 , max = -10000000;
	long long int sum = 0;
	
	scanf("%d",&n);
		
	for(count = 0; count <  n; count++){
		
		scanf("%d",&a);
		
		if( min > a ) {
			min = a;
		}
		
		
		if( max < a ){
			max = a;
		}
		
		sum = sum + a;
	}
	
	
	printf("%d %d %lld\n", min , max , sum);
	
	return 0;
}
// int ??´??°
// char ??????
// double ???????°???°???
/*d = a / b;
r = a % b;
f = 1.0 * a / b;
// f = (double)a / b;*/

Measured memory_bytes: 600
#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++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  
  int btn=1,cnt=0;
  while(btn!=2){
    btn = a[btn-1];
    cnt++;
    if(cnt > n){
      cnt = -1;
      break;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  char s[3]={};
  int i,k;
  scanf("%s",s);
  if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
    k=3;}
  else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S'||s[0]=='S'&&s[1]=='R'&&s[2]=='R'){
    k=2;}
  //else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R'){
    //k=2;}
  else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S'){
    k=0;}
  else{
    k=1;}
  printf("%d",k);
  return 0;
}

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

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> d = divisor(n);
    long long ans = 1000000000000ll;
    for (int i = 0; i < (int)d.size(); i++) {
        long long a = n / d.at(i) - 1 + d.at(i) - 1;
        ans = min(ans, a);
    }
    cout << ans << endl;
}  

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long A = 1;
            long i = 1;
            while(i <= N/i)
            {
                if(N%i == 0)
                {
                    A = i ;
                }
                i++;
            }
            long B = N / A;
            long judger = B/10;
            long counter = 1;
            while (judger > 0)
            {
                judger = judger / 10;
                counter++;
            }
            Console.WriteLine(counter);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 6010
#define mod 1000000007
#define int ll
struct S{
	int cost,v;
}s[N];
int n,t,a[N];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>t;
	repeat(i,0,n){
		cin>>s[i].cost>>s[i].v;
	}
	sort(s,s+n,[](S x,S y){return x.cost<y.cost;});
	repeat(i,0,n){
		repeat_back(j,0,t)
			a[j+s[i].cost]=max(a[j+s[i].cost],a[j]+s[i].v);
	}
	int ans=0;
	repeat(i,0,N)
		ans=max(ans,a[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n;
    vector<pair<string, pair<int, int>>> v;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        int a;
        cin >> s >> a;
        v.push_back({s, {-a, i + 1}});
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++)
        cout << v[i].second.second << endl;
    return 0;
}


Measured memory_bytes: 3664
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	N := sc.readInt()
	var L []int
	for i := 0; i < N; i++ {
		L = append(L, sc.readInt())
	}
	var sum int
	var res bool
	sortedL := sort(L)
	for i := 0; i < N; i++ {
		if i == N-1 {
			if sum <= sortedL[i] {
				res = false
			} else {
				res = true
			}
		} else {
			sum += sortedL[i]
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sliceMin(s []int) int {
	result := math.MaxInt64
	for _, v := range s {
		if v < result {
			result = v
		}
	}
	return result
}

func sliceMax(s []int) int {
	result := math.MinInt64
	for _, v := range s {
		if v > result {
			result = v
		}
	}
	return result
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sort(values []int) (ret []int) {
	// 要素数が 1 以下の配列はそれ以上細分化してソートする必要がない
	if len(values) < 2 {
		return values
	}

	// 配列の先頭をピボット (基準値) に選ぶ
	pivot := values[0]

	// ピボットを基準にして値の大小で配列をふたつに分割する
	left := []int{}
	right := []int{}
	for _, v := range values[1:] {
		if v > pivot {
			right = append(right, v)
		} else {
			left = append(left, v)
		}
	}

	// 分割した配列をそれぞれ再帰的にソートする
	left = sort(left)
	right = sort(right)

	/*
	   left(小さい) + pivot(基準値) + right(大きい) の順番で配列を組み立てる
	   ここが実際のソート処理
	*/
	ret = append(left, pivot)
	ret = append(ret, right...)

	return
}


Measured memory_bytes: 640
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
		System.out.println(Math.min(N*A, B));
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35860
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  int key;
  scanf("%d", &n);
  
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(i=2;i<=n;i++){
    key = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N;
		cin >> N;

		long ans = 0;
		long sum = 0;
		for( int i = 0; i < N; ++i ) {
			int a;
			cin >> a;
			if( a == 0 ) {
				ans += sum / 2;
				sum = 0;
			}
			else {
				sum += a;
			}
		}
		ans += sum / 2;
		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 8
void rotate(char data[N][N],char data1[N][N]){
  int i,j;
  for (i=0;i<N;i++){
    for (j=0;j<N;j++)
      data1[i][j]=data[N-j-1][i];
  }
}

int main(){
  int i,j,k;
  char data[N][N],data1[N][N];
  for (i=0;i<N;i++)
    scanf("%s",data[i]);

  for (k=1;k<=3;k++){
    rotate(data,data1);
    printf("%d\n",90*k);
    for (i=0;i<N;i++){
      for (j=0;j<N;j++){
        printf("%c",data1[i][j]);
        data[i][j]=data1[i][j];
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main(){
    int groupNumber = 0;
    cin >> groupNumber;
    
    int seatHead = 0;
    int seatTail = 0;
    
    int seatNumber = 0;
    static int seatSum = 0;
    
    for(int i=0; i<groupNumber; ++i){
        cin >> seatHead >> seatTail;
        seatNumber = seatTail - (seatHead - 1);
        seatSum += seatNumber;
    }
    
    cout << seatSum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll n, m;
ll root[500000];
ll sz[500000];
vector<ll> ans;
vector<pii> v;
ll res = 0;

int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

void Merge(int a, int b)
{
    a = Root(a);
    b = Root(b);
    if (a == b) return;
    if (sz[a] <= sz[b])
    {
        res += sz[a] * sz[b];
        sz[b] += sz[a];
        root[a] = b;
    }
    else
    {
        res += sz[a] * sz[b];
        sz[a] += sz[b];
        root[b] = a;
    }
}

signed main()
{
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 100; i >= 1; i--)
    {
        if (a % i == 0 && b % i == 0) k--;
        if (k == 0)
        {
            cout << i;
            re 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007



const int N = 200005;

int vis[N];

void solve()
{
	ll n,k;
	
	cin>>n>>k;
	
	int a[n+1];
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	
	ll tot = 1;
	
	vis[1] = 1;
	
	int id = 1;
	
	while(vis[a[id]] == 0)
	{
		id = a[id];
		
		vis[id] = 1;
		
		tot++;
	}
	
	if(k < tot)
	{
		
		fill(vis,0);
		
		vis[1] = 1;
	
		id = 1;
		
		k--;
		
		while(vis[a[id]] == 0)
		{
			if(k == 0)	
			{
				cout<<a[id];
				return;
			}
			
			id = a[id];
			
			vis[id] = 1;
			
			k--;
		}
	}
	else
	{
		fill(vis,0);
		
		vis[1] = 1;
	
		id = 1;
		
		while(vis[a[id]] == 0)
		{
			id = a[id];
			
			vis[id] = 1;
		}
		
		fill(vis,0);
		
		id = a[id];
		
		vis[id] = 1;
		
		vector<int> seq;
		
		seq.pb(id);
		
		while(vis[a[id]] == 0)
		{
			id = a[id];
			
			vis[id] = 1;
			
			seq.pb(id);
		}
		
		k = k - tot + seq.size();
		
		cout<<seq[k%seq.size()];
		
		return;
	}
}


signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 8416
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll odd[1010101];
ll al[1010101];

int main(){
	rep(i,1e6+1){
		al[i] = inf;
		odd[i] = inf;
	}
	al[0] = 0;
	odd[0] = 0;
	REP(i,1,200){
		rep(j,1e6){
			ll t = i*(i+1)*(i+2)/6;
			if(t+j > 1e6) break;
			if(t & 1) chmin(odd[t+j], odd[j]+1);
			chmin(al[t+j],al[j]+1);
		}
	}
	while(1){
		ll n; cin >> n;
		if(!n) break;
		print2(al[n], odd[n]);
	}
}


Measured memory_bytes: 18700
S = input()
N = len(S)

if S != ''.join(list(reversed(S))):
    print('No')
    exit()

M = S[:(N - 1) // 2]
if M != ''.join(list(reversed(M))):
    print('No')
    exit()

M = S[(N + 3) // 2 - 1:]
if M != ''.join(list(reversed(M))):
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1000000007;

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

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

	ll ans = 0;
	for (ll keta = 0; keta < 61; ++keta){
		ll n0 = 0;
		ll n1 = 0;
		for (int ii = 0; ii < N; ++ii){
			if (A[ii] & 1){
				n1++;
			} else {
				n0++;
			}
			A[ii] /= 2;
		}
		ll base = (1LL<<keta) % MOD;
		ll ptn = (n0*n1) % MOD;
		ans = (ans + ptn*base) % MOD;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
const int M=100010;

int main(){
	int even[M]={},odd[M]={};
	int n; 
	
	cin >>n;
	for(int i=0;i<n;i++){
		int v;
		cin >>v;
		if(i%2==0)
			even[v]++;
		else
			odd[v]++;
	}
	int max1=0;
	int max2=0;
	for(int i=0;i<M;i++)
		if(even[max1]<even[i])
			max1=i;
	for(int i=0;i<M;i++)
		if(odd[max2]<odd[i]&&max1!=i)
			max2=i;
	int cnt1=even[max1]+odd[max2];

	max1=0;max2=0;
	for(int i=0;i<M;i++)
		if(odd[max1]<odd[i])
			max1=i;
	for(int i=0;i<M;i++)
		if(even[max2]<even[i]&&max1!=i)
			max2 =i;
	int cnt2=odd[max1]+even[max2];
	cout << min(n-cnt1,n-cnt2)<< endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    if k == 0:
        print(n ** 2)
        exit()

    res = 0
    for b in range(1, n + 1):
        res += n // b * max(0, b - k)
        res += max(0, n % b + 1 - k)
    print(res)


if __name__ == '__main__':
    resolve()


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

// 1-indexed
// 親nodeはk/2, 子nodeは2kと2k+1
// update(k,x): k番目の要素をxに更新
// query(a,b): 区間[a:b)に対して二項演算した結果を返す
// operator[k]: k番目の要素を返す

template <typename T>
class SegmentTree {
    using F = function<T(T, T)>;
    int n;
    F f;
    T t;
    vector <T> dat;

public:
    SegmentTree() {};
    SegmentTree(F f, T t) : f(f), t(t) {}

    void init(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        dat.assign(n << 1, t);
    }

    void build(const vector <T> &v) {
        auto n_ = (int)v.size();
        init(n_);
        for (int i = 0; i < n_; i++) dat[n + i] = v[i];
        for (int i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }

    void set_val(int k, T x) {
        dat[k += n] = x;
        while (k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }

    T query(int a, int b) {
        T vl = t, vr = t;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, dat[l++]);
            if (r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
void AOJ_DSL_2_A() {
    ll n, q, c, x, y;
    cin >> n >> q;
    auto f = [](int a, int b) { return min(a, b); };
    SegmentTree<int> seg(f, 2147483647);
    seg.build(vector<int>(n, 2147483647));
    while (q--) {
        cin >> c >> x >> y;
        if (c) cout << seg.query(x, y + 1) << "\n";
        else seg.set_val(x, y);
    }
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
void AOJ_DSL_2_B() {
    ll n, q, c, x, y;
    cin >> n >> q;
    auto f = [](ll a, ll b) { return a + b; };
    SegmentTree<ll> seg(f, 0);
    seg.build(vector<ll>(n, 0LL));
    while (q--) {
        cin >> c >> x >> y;
        if (c) cout << seg.query(x - 1, y) << "\n";
        else seg.set_val(x, seg.query(x, x + 1) + y);
    }
}


// verified
//   https://atcoder.jp/contests/abc125/tasks/abc125_c
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
void AtCoder_2019_4_27_C() {
    int n, a;
    cin >> n;
    SegmentTree<int> seg(gcd, 0);
    for (int i = 0; i < n; i++) { cin >> a; seg.set_val(i, a); }
    int ans = 1;
    for (int i = 0; i < n; i++) ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, n)));
    cout << ans << "\n";
}

int main() {
    AOJ_DSL_2_A();
    // AOJ_DSL_2_B();
    // AtCoder_2019_4_27_C();
    return 0;
}


Measured memory_bytes: 4072
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;
#define DEBUG 0

int n;
const int N_MAX = 100001;
vector<pair<int, int>>even(N_MAX), odd(N_MAX);

int main() {
	cin >> n;
	int N = n / 2;
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		if (i % 2 == 0) { 
			even[num].first += 1; 
			even[num].second = num;
		}
		else {
			odd[num].first += 1;
			odd[num].second = num;
		}
	}
	sort(even.begin(), even.end(), greater<pair<int, int>>());
	sort(odd.begin(), odd.end(), greater<pair<int,int>>());
	if (DEBUG) cout << "even[0]:" << even[0].second << endl;
	if (DEBUG) cout << "even[1]:" << even[0].second << endl;
	if (DEBUG) cout << "odd[0]:" << odd[0].second << endl;
	if (DEBUG) cout << "odd[1]:" << odd[0].second << endl;
	if (even[0].second != odd[0].second) {
		cout << (N - even[0].first) + (N - odd[0].first) << endl;
	}
	else {
		cout << min(((N - even[0].first) + (N - odd[1].first)), (N - even[1].first) + (N - odd[0].first));
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> a(n);
    int difference = 0;
    REP(i, n){
        a.at(i) = i + 1;
        cin >> p.at(i);
        if(a.at(i) != p.at(i)) difference++;
    }
    cout << (difference == 2 || difference == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int> 
#define int long long 
#define pii pair<int,int>
//int dp[100001][2];
//bool visited[100001];
int solve(vec v[],int n,int i,int c,int** dp,bool visited[]){
	if(i>n) return 0;
	if(dp[i][c]!=-1) return dp[i][c]%mod;
	//cout<<i<<endl;
	int ans=0;
	dp[i][c]=1;
	bool child=false;
	visited[i]=true;
	for(int j=0;j<v[i].size();j++){
		if(!visited[v[i][j]]){
			child=true;
			if(c==0){
				dp[i][c]*=(solve(v,n,v[i][j],c,dp,visited)%mod+solve(v,n,v[i][j],c^1,dp,visited)%mod);
				dp[i][c]%=mod;
			}
			else{
				dp[i][c]*=solve(v,n,v[i][j],c^1,dp,visited)%mod;
				dp[i][c]%=mod;
			}
		}
	}
	visited[i]=false;
	return (dp[i][c]%mod);
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		vec v[n+1];
		rep(i,n-1){
			int a,b;
			cin>>a>>b;
			v[a].pb(b);
			v[b].pb(a);
		}
		int **dp=new int *[n+1];
		rep(i,n+1){
			dp[i]=new int[2];
			rep(j,2){
				dp[i][j]=-1;
			//	cout<<dp[i][j]<<endl;
			}
		}
		bool *visited=new bool[n+1];
		rep(i,n+1){
			visited[i]=false;
		}

		cout<<(solve(v,n,1,0,dp,visited)%mod+solve(v,n,1,1,dp,visited)%mod)%mod<<endl;
		//cout<<dp[5][0]<<" "<<dp[5][1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 20864
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,h, ans = 0;
    cin >> n >> h;
    vector<int> a(n), b(n);
    rep(n) cin >> a[i] >> b[i];
    sort(rall(b));

    int d = *max_element(all(a));
    rep(n){
        if(h <= 0 || d > b[i]) break;
        h -= b[i];
        ans++;
    }
    if(h > 0){
        ans += (h+d-1)/d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
max = -10**9
for i in range(5):
  n,k = map(int,input().split())
  if n==0 and k == 0:
    break
  else:
    b = []*n
    sum = 0
    max = -10**9
    for i in range(n):
      a = int(input())
      b.append(sum+a)
      sum += a
    for j in range(len(b)-k):
      if max<b[j+k]-b[j]:
        max = b[j+k]-b[j]
    print(max)


Measured memory_bytes: 9648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
ll power_of_2_not_less(ll n)
{
	if(!n)
	{
		return 1;
	}
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
bool check(string s,ll l,ll r)
{
	l -- ;
	r -- ;
	while(l<r)
	{
		if(s[l]!=s[r])
		{
			return 0;
		}
		l++;
		r--;
	}
	return 1;
}
int main(void)
{
	fastio
	string s;
	cin>>s;
	ll N = s.size();
	if(check(s,1,N) && check(s,1,((N-1)/2)) && check(s,(N+3)/2,N))
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>
#include<atcoder/segtree>




using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}




void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int N = 300000 + 10;
    segtree<int, op, e> seg(300000 + 10);
    for (int i = 0; i < n; ++i) {
        int x = max(a[i] - k, 0);
        int y = min(a[i] + k, N - 1);
        int m = seg.prod(x, y + 1);
        seg.set(a[i], m + 1);

    }
    cout << seg.prod(0, N) << endl;
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

int main() {
  string A, B;
  cin >> A;
  cin >> B;
  string flag = "No";
  int size = A.size();

  for(int i = 0; i <= size; i++){
    if(A == B){
      flag = "Yes";
      break;
    }else{
      char temp = A.back();
      A.pop_back();
      A = temp + A;
    }
    //cout << A << endl;
  }

  cout << flag << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdint.h>

#include <iostream>

using namespace std;

int64_t Gcd(int64_t a, int64_t b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}

int64_t Lcm(int64_t a, int64_t b) { return a / Gcd(a, b) * b; }

int64_t Cnt(int64_t a, int64_t b, int64_t x) {
  int64_t i = (a + x - 1) / x;
  int64_t j = b / x;
  return j - i + 1;
}

int main(void) {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << B - A + 1 - (Cnt(A, B, C) + Cnt(A, B, D) - Cnt(A, B, Lcm(C, D)))
       << endl;
  return 0;
}


Measured memory_bytes: 3644
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
A.sort()
ans = 1
if A[-1]==0 and K&1: print(0);exit()
if A[-1]<0 and K&1:
    for i in range(N-1,N-1-K,-1):
        ans =(ans*A[i])%mod
    print(ans)
    exit()
l,r = 0,N-1
if K&1:
    ans *= A[-1]
    r-=1
    K-=1
p = K//2
for i in range(p):
    lp = A[l]*A[l+1]
    rp = A[r]*A[r-1]
    if lp>rp:
        ans = (ans*lp)%mod
        l += 2
    else:
        ans = (ans*rp)%mod
        r-=2
print(ans%mod)


Measured memory_bytes: 93740
import numpy as np
#入力
N = input()
A = input()
#入力値を取り出す
x = np.array(list(map(int,A.split( ))))
j = []
for i in range(len(x)):
    j = np.append(j,np.max(x))
    y = np.where(x == np.max(x))[0][0]
    x[y] = 0
print(int(np.sum(j[::2])-np.sum(j[1::2])))


Measured memory_bytes: 12396
n=int(input())
A=[int(i) for i in input().split()]
q=int(input())

tab=[0 for i in range(10**5+1)]

s=0
for ele in A:
    tab[ele]+=1
    s+=ele

for i in range(q):
    b,c=map(int,input().split())
    cnt=tab[b]
    tab[b]=0
    tab[c]+=cnt
    s+=(c-b)*cnt
    print(s)

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

using namespace std;

int main() {
    string str;
    cin >> str;
    int A[4][2];
    
    for (int i =0;  i<4;  i++) {
        A[i][0] = str[i] - '0';
        A[i][1] = -A[i][0];
    }
    
    int result;
    string PM = "+-";
    string op[4] = {""};
    
    for (int j=0; j <2; j++) {
        for (int k=0; k <2; k++) {
            for (int l=0; l<2; l++) {
                    
                result = A[0][0]+A[1][j]+A[2][k]+A[3][l];
                    
                if(result == 7) {
                        op[1]=PM[j];
                        op[2]=PM[k];
                        op[3]=PM[l];
                        break;
                }
            }
        }
    }
    
    cout << A[0][0] << op[1] <<A[1][0] << op[2] <<A[2][0] << op[3] <<A[3][0] << "=" << 7 <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()

{
	string s;
	cin	>> s;
	
	int A=0, B=0;
	int answer;
	for (unsigned int i = 0; i < s.size(); ++i) {
		if (s[i] == 'A')
		{
			A = i;
			break;
		}
	}

	for (int j = s.size()-1; j > -1; --j) {
		if (s[j] == 'Z')
		{
			B = j;
			break;
		}
	}

	answer = B-A+1;
	cout << answer << endl;
	return 0;

}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

void brute() { int a, b, n; }

void solution() {
  int n, m;
  cin >> n >> m;
  n = m * 2 + 1;
  int mid = (n / 2) + 1;
  for (int l = 1, r = mid; l < r; l++, r--) {
    cout << l << " " << r << endl;
    m--;
    if (m == 0) break;
  }
  for (int l = mid + 1, r = n; l < r; l++, r--) {
    cout << l << " " << r << endl;
    m--;
    if (m == 0) break;
  }
}

int32_t main() {
  DESYNC;
  solution();
}


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

typedef vector<int> V;

int N;
int M;
int ans;
int fact;
int D[114];
int A[114];
int dp[114][114514];
int nxt[114514][10];
V perm;
vector<V> perms;
map<V, int> rev;

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%d", &D[i]);
    M = max(M, D[i]+1);
  }
  M = min(M, N);

  for (int i=0; i<N; i++) {
    scanf("%d", &A[i]);
  }
  //reverse(A, A+N);
  //reverse(D, D+N);

  fact = 1;
  for (int i=0; i<M; i++) {
    perm.emplace_back(i);
    fact *= i+1;
  }

  for (int i=0; i<fact; i++) {
    rev[perm] = i;
    perms.emplace_back(perm);
    next_permutation(perm.begin(), perm.end());
  }

  for (int idx=0; idx<fact; idx++) {
    auto &perm = perms[idx];
    for (int k=0; k<=M; k++) {
      V nperm;
      for (int l=0; l<k; l++) {
        int p = perm[l];
        if (p > 0) nperm.emplace_back(p-1);
      }
      nperm.emplace_back(M-1);
      for (int l=k; l<M; l++) {
        int p = perm[l];
        if (p > 0) nperm.emplace_back(p-1);
      }
      assert(rev.count(nperm));
      nxt[idx][k] = rev[nperm];
    }
  }

  for (int idx=0; idx<fact; idx++) {
    int initial = 0;
    int conv[10] = {};
    
    for (int p : perms[idx]) {
      initial += conv[p];
      for (int k=0; k<M; k++) {
        if (p-D[p] <= k && k <= p+D[p]) conv[k] += A[p];
      }
    }

    dp[M-1][idx] = initial;
    ans = max(ans, initial);
  }

  for (int i=M; i<N; i++) {
    for (int j=0; j<fact; j++) {
      auto &perm = perms[j];
      for (int k=0; k<=M; k++) {
        int conv = 0;
        for (int l=0; l<k; l++) {
          int p = perm[l];
          if (M <= p+D[i-M+p]) conv += A[i-M+p];
        }

        int lack = 0;
        for (int l=k; l<M; l++) {
          int p = perm[l];
          if (M-D[i] <= p) lack += A[i];
        }

        int nj = nxt[j][k];
        dp[i][nj] = max(dp[i][nj], dp[i-1][j]+conv+lack);
        ans = max(ans, dp[i][nj]);
      }
    }
  }

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

Measured memory_bytes: 27400