akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int input(){
    int a;
    cin>>a;
    return a;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdin);
    int x,y,a,b,c;
    while(cin>>x>>y>>a>>b>>c){
        int n=x+y;
        priority_queue<int>P,Q,T;
        while(a--)P.push(input());
        while(b--)Q.push(input());
        while(x--){T.push(P.top());P.pop();}
        while(y--){T.push(Q.top());Q.pop();}
        while(c--)T.push(input());
        ll rs=0;
        while(n--){
            rs+=T.top();
            T.pop();
        }
        cout<<rs<<endl;
    }

    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long M = 5000000000000000;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll K;
    cin >> K;
    ll ans = 0;
    REP(i,S.size()){
        ll cnt = 1;
        int num = ctoi(S[i]);
        if(num == 1){
            ans += 1;
            if(ans >= K){
                cout << num << endl;
                return 0;
            }
            continue;
        }
        REP(j,M){
            cnt *= num;
            if(ans + cnt >= K){
                cout << num << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;


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

	int t1, t2;
	t1 = n / 500;
	t2 = n % 500;

	n -= t1 * 500;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
	
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.util.Arrays.fill;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		int b[] = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = scanInt();
			if (b[i] != a[i] && 2 * b[i] >= a[i]) {
				out.print("-1");
				return;
			}
		}
		long cur = (1L << 50) - 1;
		boolean set[] = new boolean[51];
		bit: for (int bit = 49; bit >= 0; --bit) {
			long test = cur & ~(1L << bit);
			for (int i = 0; i < n; i++) {
				fill(set, false);
				set[a[i]] = true;
				for (int j = 49; j >= 0; j--) {
					if ((test & (1L << j)) != 0) {
						for (int k = j + 1; k <= 50; k++) {
							if (set[k]) {
								set[k % (j + 1)] = true;
							}
						}
					}
				}
				if (!set[b[i]]) {
//					System.err.println(test + " " + i);
					continue bit;
				}
			}
			cur = test;
		}
		out.print(cur << 1);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 24276
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, *A = map(int, read().split())
A.sort()
print(A[-1]-A[0])


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  double n,cnt =0; 
  cin>>n;
  for(int i=1 ; i <= n ; i++){
  	if(i%2==1){ 
      cnt = cnt + 1;
    }
  }
  //cout<< cnt << " " << n << endl;
  double a = (cnt/n);
  //cout<<a;
  cout<<fixed<<setprecision(6)<< a;
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}

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


def solve(N: int):
    print(180*(N-2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
using namespace std;

int main() {
	int A,B,K;
	cin >> A >> B >> K;
	if ((B - A + 1) < 2*K){
		for(int i=A; i < B+1; i++){
			cout << i << endl;
		}
	}
	else{
		for(int i=A; i < A+K; i++){
			cout << i << endl;
		}
		for(int i=B-K+1; i < B+1; i++){
			cout << i << endl;
		}
	}
	return 0;
}


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

using namespace std;

int main() {
	long R[200000], m=-1000000000, min;
	int i, j, N;
	cin >> N;
	cin >> min;
	for (j = 0; j<N-1; j++) {
		cin >> R[j];
		if(R[j]-min>m) m = R[j] - min;
		if (min  > R[j]) min = R[j];
	}
	cout << m << endl;
}

Measured memory_bytes: 2724
# coding: utf-8
# Your code here!

class Node:
    def __init__(self,key):
        self.key=key
        self.parent=self.left=self.right=None
    

class BST:
    def __init__(self):
        self.root=None
    def insert(self,key):
        node=Node(key)
        insert(self,node)


def insert(t,z):
    x=t.root
    y=None
    while x:
        y=x
        if z.key<x.key:
            x=x.left
        else:
            x=x.right
    z.parent=y
    
    if y==None:
        t.root=z
    elif z.key<y.key:
        y.left=z
    else:
        y.right=z

def preorder(x):
    print(" "+str(x.key),end="")
    if x.left != None:
        preorder(x.left)
    if x.right != None:
        preorder(x.right)
        
def inorder(x):
    if x.left != None:
        inorder(x.left)
    print(" "+str(x.key),end="")
    if x.right != None:
        inorder(x.right)

def find(t,k):
    while t:
        if t.key==k:
            return True
        if t.key > k:
            t=t.left
        else:
            t=t.right
    return False



n=int(input())
t=BST()
for i in range(n):
    tmp=input().split()
    if tmp[0]=="insert":
        t.insert(int(tmp[1]))
        
    elif tmp[0]=="find":
        if find(t.root,int(tmp[1])):
            print("yes")
        else:
            print("no")
        
    else:
        inorder(t.root)
        print("")
        preorder(t.root)
        print("")



Measured memory_bytes: 85228
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int M = sc.nextInt();

		long[] a = new long[A];
		long min_a = Long.MAX_VALUE / 2;
		for(int i=0; i<A; i++) {
			a[i] = sc.nextLong();
			min_a = Math.min(min_a, a[i]);
		}

		long[] b = new long[B];
		long min_b = Long.MAX_VALUE / 2;
		for(int i=0; i<B; i++) {
			b[i] = sc.nextLong();
			min_b = Math.min(min_b, b[i]);
		}

		long ans = min_a + min_b;
		for(int i=0; i<M; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			long c = sc.nextLong();

			ans = Math.min(ans, a[x-1]+b[y-1]-c);
		}


		System.out.println(ans);
	}

}


Measured memory_bytes: 136768
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))

fun solve(sc: Scanner): String {
    val N = sc.nextInt()
    val A = (1..N).map { sc.nextLong() }
    val nA = A.count()
    val MOD = 1000000007L

    var ans: Long = 0L
    for (b in 0..60) {
        val bn = 1L shl b
        val n0 = A.count { it and bn == 0L }.toLong()
        ans += (bn % MOD) * (n0 * (nA - n0) % MOD)
        ans %= MOD
    }

    return ans.toString()
}


Measured memory_bytes: 115636
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          Console.WriteLine(48-Input.ScanInt());
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=(m); (i)<(ll)(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin,(a).end

ll partition(vector<ll> &a, const ll p, const ll r){
  ll x = a[r];
  ll i = p-1;
  FOR(j,p,r){
    if(a[j] <= x) swap(a[++i], a[j]);
  }
  swap(a[i+1], a[r]);
  return i+1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll border = partition(a, 0, n-1);
  REP(i,n){
    if(i) cout << " ";
    if(i == border) cout << "[" << a[i] << "]";
    else cout << a[i];
  }
  cout << "\n";
  
  return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<vector>
using namespace std;
vector<int> adj_list[100005];
bool biper=true;
int check[100005]={0};
void DFS(int v){
	if(!biper){
		return;
	}
	for(int i=0; i<adj_list[v].size(); i++){
		if(check[adj_list[v][i]]==check[v]){
			biper=false;
			return;
		}else if(check[adj_list[v][i]]!=0){
			continue;
		}
		if(check[v]==1){
			check[adj_list[v][i]]=2;
			DFS(adj_list[v][i]);
		}else{
			check[adj_list[v][i]]=1;
			DFS(adj_list[v][i]);
		}
	}
	
}
int main(){
	long long int N, M;
	scanf("%lld %lld", &N, &M);
	for(int i=0; i<M; i++){
		int temp1, temp2;
		scanf("%d %d", &temp1, &temp2);
		temp1--;
		temp2--;
		adj_list[temp1].push_back(temp2);
		adj_list[temp2].push_back(temp1);
	}
	check[0]=1;
	DFS(0);
	if(!biper){
		printf("%lld", N*(N-1)/2-M);
	}else{
		int A=0;
		for(int i=0; i<N; i++){
			if(check[i]==1){
				A++;
			}
		}
		printf("%lld", A*(N-A)-M);
	}
}

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

enum {WIN, LOSE, DRAW};

int main() {
	for(int n; cin >> n && n;) {
		vector<pair<int, int>> ranking; // score, ID
		vector<char> names(n);

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

			int score = 0;
			for(int j = 0; j < n - 1; ++j) {
				int result;
				cin >> result;

				switch(result) {
				case WIN:
					score += 100;
					break;
				case LOSE:
					break;
				case DRAW:
					score += 1;
					break;
				default:
					assert(false);
				}
			}

			ranking.emplace_back(-score, i);
		}

		sort(ranking.begin(), ranking.end());

		for(const auto &team : ranking) {
			cout << names[team.second] << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int d = 0;
  int ans = 1;
  for (int i = 1; i < N; i++)
  {
    if (d == 0)
    {
      if (A[i - 1] < A[i])
        d = 1;
      else if (A[i - 1] > A[i])
        d = -1;
    }
    else if (0 < d && A[i - 1] > A[i])
    {
      ans++;
      d = 0;
    }
    else if (d < 0 && A[i - 1] < A[i])
    {
      ans++;
      d = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    int ans = (n % 2 == 0)
            ?n / 2
            :(n + 1) / 2;
    co(ans);
    return 0;
}

Measured memory_bytes: 256
mod=998244353


##mod,nについての制約は自分でいかに記入する

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 #あるかずxのn乗をmodで割ったあまりを返す関数pow_cal(x,n,mod)
def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(4*10**5,mod)
B=find_inv_power(4*10**5,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)



N,M,K=map(int,input().split())
dp=[0 for i in range(N+1)]
#dp[x]=塗り方でダブりが、ｘ通りになるものの個数
ans=M*pow(M-1,N-1,mod)

for i in range(1,K+1):
    ans+=M*combi(N-1,i,mod)*pow(M-1,N-1-i,mod)
print(ans%mod)


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

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

  if(A>=K){
    cout << A-K << ' ' << B << endl;
  }
  else{
    if(A+B>K){
      cout << '0' << ' ' << B-(K-A) << endl;
    }
    else{
      cout << '0' << ' ' << '0' << endl;
    }
  }
}


Measured memory_bytes: 256
n = gets.to_i
C_0,C_1,C_2,C_3 = 0,0,0,0
n.times do
  s = gets.chomp()
  if s == 'AC'
    C_0 += 1
  elsif s == 'WA'
    C_1 += 1
  elsif s == 'TLE'
    C_2 += 1
  else
    C_3 += 1
  end
end

print('AC x ',C_0, "\n")
print('WA x ',C_1,"\n")
print('TLE x ',C_2,"\n")
print('RE x ', C_3,"\n")

Measured memory_bytes: 20748
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[3001][3001];
void solve(string& s, int n)
{
    dp[n][0] = (s[n-2] == '>' ) ? 1 : 0;
    dp[n][1] = (s[n-2] == '<' ) ? 1 : 0;
    for(int i = n - 1; i >= 2; i--)
    {
        int total = n - i + 1;
        for(int g = 0; g <= total; g++)
        {
            if(g == 0)
            {
                if(i == n)continue;
                dp[i][g] = 0;
                if(s[i-2] == '<' )
                    continue;
                for(int j = 1; j <= total; j++)
                {
                    dp[i][g] = (dp[i][g] + dp[i+1][total-j]) % mod;
                }
            }
            else
            {
                if(s[i-2] == '>')
                     dp[i][g] = (mod + dp[i][g-1] - dp[i+1][g-1]) % mod;
                else
                    dp[i][g] = (dp[i][g-1] + dp[i+1][g-1]) % mod;
            }
        }

    }
}

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

   ll ans = 0;
   solve(s,n);
   for(int gr = n-1; gr >= 0; gr--)
        ans = (ans + dp[2][gr]) % mod;
   cout << ans;
   return 0;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
int main(){

     long long int a,b,c,d,e,f,i,j,k,x,y,t=0;
     vector<int> v;
     vector<int> v1;
     vector<int> v2;
     vector<int>::iterator it;
     set<int> st;
     cin>>a>>b;
     for(i=0;i<b;i++){
        cin>>c;
        v.push_back(c);

     }
 for(auto it=v.begin();it!=v.end();it++){
    t+=*it;
 }
if(t>=a){
    cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;


    return 0;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int a,b;
map<string,int>mp;
string s[105];
int main(){
	int n;
	cin>>n;
	rep(i,1,n)
	{
		cin>>s[i];
		if(mp.count(s[i])){cout<<"No";return 0;}
		int sz=s[i-1].size();
		if(i>1&&s[i][0]!=s[i-1][sz-1]){cout<<"No";return 0;}
		mp[s[i]]=1;
	}
	cout<<"Yes";
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int countd(int N)
{
    int ub = sqrt(N);
    int count = 0;
    for (int i = 1; i < ub; i++)
    {
        int i2 = i * i;
        int j = i;
        int k = floor (sqrt(N-i2));
        while (j <= k)
        {
            int j2 = j * j;
            int k2 = k * k;
            int sum = i2 + j2 + k2;
            if (sum < N)
            j ++;
            else if (sum > N)
            k --;
            else
            {
                int x,y,z;
                x=(i-j+k)/2;
                y=(i+j-k)/2;
                z=(j+k-i)/2;
                if(x<=0 || y<=0 || z<=0)
                {
                    j++;
                    continue;
                }
                if(x==y && y==z)
                    count++;
                else
                {
                    if(x==y)
                        count+=3;
                    else if(x==z)
                        count+=3;
                    else if(y==z)
                        count+=3;
                    else
                        count+=6;
                }
                j ++;
            }
        }
    }
    return count;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cout<<countd(2*i)<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

const int MAX = 510000;
constexpr int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

signed main()
{
    int n,m;
    cin>>n>>m;
    vector<int>v;
    int cnt=2;
    while(cnt*cnt<=m){
        if(m%cnt==0){
            m/=cnt;
            v.push_back(cnt);
           
        }
        else cnt++;
    }
    if(m!=1) v.push_back(m);
    set<int>st(v.begin(),v.end());
    vector<int>w(st.begin(),st.end());
    map<int,int>mp;
    for (int i = 0; i < v.size(); i++)
    {
        mp[v[i]]++;
    }
   // show(w);
    COMinit();
    int res=1;
    for (int i = 0; i < w.size(); i++)
    {
        int x=mp[w[i]];
      //  cerr<<x<<endl;
        res*=COM(x+n-1,x);
        res%=MOD;
    }
    cout<<res<<endl;

    
    
    
  
    return 0;
}

Measured memory_bytes: 12160
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

N, M = map(int, input().split())
X = list(map(int, input().split()))

if N>= M:
    print(0)
    exit()

X.sort()

# 各コマの距離を求める
cost = [0] * (M-1)
for i in range(1, M):
    cost[i-1] = X[i] - X[i-1]

cost.sort()
for i in range(N-1):
    cost.pop()

print(sum(cost))

Measured memory_bytes: 13948
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int f = 0, ch = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
#define int ll
#define N (400005)
int a[N], n;
inline int calc(int x){
	int ans = 0;
	for(int i = 1; i <= n; i++) ans += abs(a[i] - (x + i));
	return ans;
}
main(){
	read(n);
	for(int i = 1; i <= n; i++) read(a[i]);
	int l = -inf, r = inf;
	for(int t = 0; t < 100; t++){
		int m = (r - l + 1) / 3;
		int m1 = l + m, m2 = r - m;
		if(calc(m1) < calc(m2)) r = m2; else l = m1;
	}
	cout << calc(l);
	return 0;
}

Measured memory_bytes: 1792
#200329C
K, N = map(int, input().split())
A = list(map(int,input().split()))

MaxD = 0
B = sorted(A)
for i in range(N-1):
    D = B[i+1] - B[i]
    if D > MaxD:
        MaxD = D

if K - B[N-1] + B[0] > MaxD:
    MaxD = K-B[N-1]+B[0]

print(int(K-MaxD))

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

int main(){
    int n, r = 0;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    for(int i = 0; i < n; i++)cin >> b[i];
    for(int i = 0; i < n-1; i++)cin >> c[i];
    r += b[a[0]];
    for(int i = 1; i < n; i++){
        r += b[a[i]];
        if(a[i] - a[i-1] == 1)r += c[a[i-1]];
    }
    cout << r << '\n';
}


Measured memory_bytes: 256
N = input()
if int(N[-1]) == 2 or int(N[-1]) == 4 or int(N[-1]) == 5 or int(N[-1]) == 7 or int(N[-1]) == 9:
    print("hon")
elif int(N[-1]) == 0 or int(N[-1]) == 1 or int(N[-1]) == 6 or int(N[-1]) == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> d(n);
    rep(i,k) {
        int m;
        cin >> m;
        rep(j,m){
            int a;
            cin >>  a;
            d[a-1] = 1;
    }
    }
    int cnt = 0;
    rep(i,n) {
        if(d[i] == 0){
            cnt++;
        }
    }
     cout << cnt << endl;
    
return 0;
}


Measured memory_bytes: 3580
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> A(n);
  for(int i=0;i<n;++i) cin >> A.at(i);

  ll ans=0;
  for(int i=1;i<n;++i){
    if(A.at(i-1)>A.at(i)){
      ans+=(A.at(i-1)-A.at(i));
      A.at(i)=A.at(i-1);
    }
  }

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


Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<class T>
struct CumulativeSum2D{
    vector<vector<T>> data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}

    void add(int x, int y, T z){
        ++x, ++y;
        if(x >= data.size() || y >= data[0].size()) return;
        data[x][y] += z;
    }

    void build(){
        for(int i = 1; i < data.size(); ++i){
            for(int j = 1; j < data[i].size(); ++j){
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    T query(int sx, int sy, int gx, int gy){
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

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

    int n, k;
    cin >> n >> k;
    CumulativeSum2D<int> S(k * 2, k * 2);
    for(int i = 0; i < n; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B')    x += k;
        x %= k * 2, y %= k * 2;
        S.add(x, y, 1);
    }
    S.build();
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, i + k, j + k);
            X += S.query(0, 0, i, j);
            X += S.query(i + k, 0, k * 2, j);
            X += S.query(0, j + k, i, k * 2);
            X += S.query(i + k, j + k, k * 2, k * 2);
            chmax(ans, X);
        }
    }
    for(int i = k; i <= k * 2; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, k * 2, j + k);
            X += S.query(i - k, 0, i, j);
            X += S.query(i - k, j + k, i, k * 2);
            X += S.query(0, j, i - k, j + k);
            chmax(ans, X);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 18996
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0073
public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[][] cs = new char[8][8];
	public static void main(String[] args) {
		while (true) {
			int x = sc.nextInt(), h = sc.nextInt();
			if (x == 0 && h == 0) break;
			double dx = (double)x, dh = (double)h;
			double S = dx * dx +
					( ( 2 * dx * sqrt(dx * dx + 4 * dh * dh) ) / 2 );
			System.out.printf("%.6f", S);System.out.println();
		}
	}
	
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <regex>
using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)

typedef long long ll;

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

    cout << "Christmas";
    D=abs(25-D);
    if(D!=0) FOR(i,0,D) cout<<" Eve";
    cout<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)
typedef long long ll;

vector<int> g[200005];
ll val[200005];

void dfs(int p, int c, ll sum){
  val[c] += sum;
  for(auto v : g[c]){
    if(v!=p){
      dfs(c, v, val[c]);
    }
  }
}

int main(int argc, char *argv[]) {
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i=0;i<q;i++){
    int p,x;cin>>p>>x;
    p--;
    val[p] += x;
  }
  dfs(-1, 0, 0);

  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<val[i];
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	vi v(3);
	int a,b,c; cin>>v[0]>>v[1]>>v[2];
	sort(all(v));
	cout<<v[0]+v[1];
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	map<pi, int> cnt;
	int nm = 0;
	while(true){
		int a1 = a, b1 = b, c1 = c;
		if((a1 & 1) || (b1 & 1) || (c1 & 1)){
			cout << nm << endl;
			return 0;
		}
		b1 = c / 2 + a / 2;
		a1 = c / 2 + b / 2;
		c1 = a / 2 + b / 2;
		if(cnt[mp(a1, b1)]){
			cout << -1 << endl;
			return 0;
		}
		cnt[mp(a1, b1)] = 1;
		a = a1, b = b1, c = c1;
		nm++;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define ll long long
#define MAXN 100000
using namespace std;



int main() {
    string S;
    cin>>S;
    bool ok=false;
    for(int i=0;i<S.size()-1;i++) {
        if (S[i]=='A' && S[i+1]=='C')
            ok=true;
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int count = 0;
  vector<char> data(n);
  rep(i,n) cin >> data[i];
  rep(i,n - 2) {
    if(data[i] == 'A' && data[i + 1] == 'B' && data[i + 2] == 'C') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/*BubbleSort(A)
1 for i = 0 to A.length-1
2     for j = A.length-1 downto i+1
3         if A[j] < A[j-1]
4             swap A[j] and A[j-1]*/
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    int n,a[100];
    int i,j,mi,t,s;
    while(scanf("%d",&n)!=EOF)
    {
        s=0;
        for(i=0;i<n;i++)
         {
             scanf("%d",&a[i]);
         }
         for(i=0;i<n;i++)
         {
             for(j=n-1;j>i;j--)
             {
                 if(a[j]<a[j-1])
                 {
                     t=a[j];
                     a[j]=a[j-1];
                     a[j-1]=t;
                     s++;
                 }
             }
         }
         for(i=0;i<n;i++)
        {
            if(i!=n-1)  printf("%d ",a[i]);
            else  printf("%d\n",a[i]);
        }
        printf("%d\n",s);

    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    //for(int i = 0; i < n; i++)cout << a[i] << ' ';
    //cout << endl;
    priority_queue<ll, vector<ll>> que;
    que.push(a[n-1]);
    ll ans = 0;
    for(int i = n-2; i >= 0; i--){
        ll p = que.top();
        que.pop();
        ans += p;
    //    cout << p << endl;
        que.push(a[i]);
        que.push(a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6928
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		String[] inputs = input.split("");
		List<String> line = new ArrayList<String>();
		for(String c : inputs){
			if(c.equals("0") || c.equals("1")){
				line.add(c);
			}else{
				if(!line.isEmpty()){
					line.remove(line.size()-1);
				}
			}
		}
		System.out.println(String.join("", line));
	}

}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
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; }
ll read() { ll u, k = scanf(" %lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 600000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
vec<int>e[700000];
signed main() {
	int n, m;
	cin >> n >> m;
	vec<int>a(3 * n + 3, inf);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		e[u * 3].pb(v * 3 + 1);
		e[u * 3 + 1].pb(v * 3 + 2);
		e[u * 3 + 2].pb(v * 3);
	}
	int s, t;
	cin >> s >> t;
	a[s * 3] = 0;
	pri_que<H, vec<H>, greater<H>>p;
	p.push(H{ 0,s * 3 });
	while (!p.empty()) {
		H t = p.top(); p.pop();
		for (auto g : e[t.sc]) {
			if (a[g] > a[t.sc] + 1) {
				a[g] = a[t.sc] + 1;
				p.push(H{ a[g],g });
			}
		}
	}
	if (a[t * 3] == inf) cout << -1 << endl;
	else cout << a[t * 3] / 3 << endl;
}

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

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

    static class BStringPalindrome {
        public boolean isPalindrome(String s) {
            if (s.length() <= 1)
                return true;
            return s.charAt(0) == s.charAt(s.length() - 1) && isPalindrome(s.substring(1, s.length() - 1));
        }

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            String s = sc.next();
            if (isPalindrome(s) && isPalindrome(s.substring(0, (s.length() - 1) / 2)) && isPalindrome(s.substring(((s.length() + 3) / 2) - 1)))
                pw.println("Yes");
            else
                pw.println("No");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 23380
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
sys.setrecursionlimit(10**7)

N, K = map(int, input().split())
a = map(int, input().split())
a = [a-1 for a in a]

first = 0
second = 0
cnt = 0
visited = [0] * N
city = [None] * N

def nex_node(x):
    global first
    global second
    global cnt
    city[cnt] = x
    cnt += 1

    if visited[x] > 0:
        first = visited[x]
        second = cnt
        val = K - first +1
        idx = val % (second - first)
        # print(first, second, idx)
        # print(city)
        print(city[first - 1 +idx] + 1)
        sys.exit()

    visited[x] = cnt

    # print(x, cnt, a[x])
    if cnt == K:
        # print(city)
        print(a[x]+1)
        sys.exit()
    if a[x] == x:
        print(x+1)
        sys.exit()

    nex_node(a[x])


nex_node(0)


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

int a[12][12];
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  ll inf = 2e6;
  ll ans = -1;
  rep(i, 1 << n) {
    vector<int> und(m);
    ll mon = 0;
    rep(j, n) {
      if (i & 1 << j) {
        rep(k, m) und[k] += a[j][k];
        mon += c[j];
      }
    }
    bool flg = true;
    rep(j, m) {
      if (und[j] < x) flg = false;
    }

    if (flg) {
      if (ans == -1)
        ans = mon;
      else
        ans = min(ans, mon);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();
const unsigned long long int ULLINF = numeric_limits<unsigned long long int>::max();

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){

	LL n, m;
    cin >> n >> m;

    UnionFind tree(n);

    REP(i,m) {
        LL num1, num2;
        cin >> num1 >> num2;
        tree.unite(num1-1, num2-1);
    }

    VLL v(n, -1);

    for (LL i=0; i<n; i++) {
        LL r = tree.root(i);
        if (v[r] == -1) v[r] = 1;
        else v[r] += 1;
    }

    LL ans = 0;
    for (LL i=0; i<n; i++) {
        // cout << i+1 <<  ":" << v[i] << endl;
        ans = max(ans, v[i]);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11752
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  ll n, a[100010], b[100010];
  scanf("%lld", &n);
  REP(i, n + 1) scanf("%lld", &a[i]);
  REP(i, n) scanf("%lld", &b[i]);

  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] + a[i + 1] < b[i]){
      ans += a[i] + a[i + 1];
      a[i] = 0; a[i + 1] = 0;
    }
    else{
      ans += b[i];
      if(b[i] >= a[i]){
	a[i + 1] -= b[i] - a[i];
	a[i] = 0;
      }else{
	a[i] -= b[i];
      }
    }
    
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1664
N = int(input())
S, T  = input().split()

S_list = list(S)
T_list = list(T)
U_list = []
for i in range(N):
    U_list.append(S_list[i])
    U_list.append(T_list[i])

U = ''.join(U_list)
print(U)

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

// 組合せを素数で割った値を求める
const int MAX = 1e6;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, y;
  cin >> x >> y;
  
  if(y > 2 * x || 2 * y < x || (x + y) % 3 != 0){
    cout << 0 << "\n";
    return 0;
  }
  
  COMinit();
  
  long long ans = COM((x + y) / 3, (2 * y - x) / 3);
  
  cout << ans << "\n";
}

Measured memory_bytes: 23680