akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    int right = 0;
    ll sum = 0;
    ll ans = 0;
    for(int left=0;left<N;left++){
        while(right < N && (sum ^ A[right]) == (sum + A[right])){
            sum += A[right];
            right++;
        }
        ans += right - left;
        if(left == right) right++;
        else sum -= A[left];
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

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

int main() {
    int n;
    cin >> n;
    int a,b,c,d;
    d=n%10;
    n=n/10;
    c=n%10;
    n=n/10;
    b=n%10;
    n=n/10;
    a=n%10;
    if(a+b+c+d==7) cout << a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7 <<endl;
    else if(a-b+c+d==7) cout << a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7 <<endl;
    else if(a+b-c+d==7) cout << a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7 <<endl;
    else if(a+b+c-d==7) cout << a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7 <<endl;
    else if(a-b-c+d==7) cout << a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7 <<endl;
    else if(a-b+c-d==7) cout << a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7 <<endl;
    else if(a+b-c-d==7) cout << a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7 <<endl;
    else cout << a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7 <<endl;
}

Measured memory_bytes: 256
extension String: CollectionType {} // splitを使うためのおまじない

let N: Int = Int(readLine()!)!
let K: Int = Int(readLine()!)!
let X: Int = Int(readLine()!)!
let Y: Int = Int(readLine()!)!
//let a: [Int] = readLine()!.split(" ").map { Int($0)! }
//print(a)
var ans: Int = X*min(N,K)
if N>K {
    ans+=(N-K)*Y
}
print(ans)

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

using i64 = long long;

int main() {
  int n;
  std::cin >> n;
  int m = n / 2;
  int t = n - m * 2 + 2;
  std::vector<i64> a(n);
  for (auto &e : a)
    std::cin >> e;
  
  std::vector<i64> dp(t, 0);
  for (int i = 0; i < m; i += 1) {
    for (int j = 0; j < t; j += 1)
      dp[j] += a[2 * i + j];
    for (int j = 1; j < t; j += 1)
      dp[j] = std::max(dp[j], dp[j - 1]);
  }
  std::cout << dp.back() << "\n";
}
  

Measured memory_bytes: 4844
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,n;
  int *x;

  scanf("%d",&n);

  x=(int *)malloc(sizeof(int)*n);

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

  for(i=n-1;i>=0;i--){
    printf("%d%c",x[i],(i==0?'\n':' '));
  }

  free(x);
  
  return 0;
}

Measured memory_bytes: 596
import sys

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    V, E = map(int, input().split())
    uf = UnionFind(V)
    edges = []
    for _ in range(E):
        s, t, w = map(int, input().split())
        edges.append((w, s, t))
    
    edges.sort()

    cost = 0
    for edge in edges:
        w, s, t = edge
        if not uf.same(s, t):
            cost += w
            uf.union(s, t)
    print(cost)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 23284
#include<iostream>
#include<stdio.h>

#define     MAX_COUNT_W     30
#define     MAX_COUNT_N     30

using namespace std;

void myswap(int *,int *);

int main(){
	int w,n,a,b,i;
	int *pAmida;

	// w (縦棒の本数) と n (横棒の本数) を入力
	cin >> w >> n;

	// 入力のチェック
	if((w <= 0) || (w > ((int)(MAX_COUNT_W)))){
		cerr << "縦棒の本数が範囲外です" << endl;
		return -1;
	}
	if((n <= 0) || (n > ((int)(MAX_COUNT_N)))){
		cerr << "横棒の本数が範囲外です" << endl;
		return -1;
	}

	// あみだくじ 領域の確保
	pAmida = new int[w];

	// あみだくじ 領域の初期化
	for(i=0;i<w;i++){
		*(pAmida + i) = i + 1;
	}

	// あみだくじ 処理
	for(i=0;i<n;i++){
		// 横棒の入力
		scanf("%d,%d",&a,&b);
		// 入力のチェック
		if((a <= 0) || (a > w) || (b <= 0) || (b > w)){
			cerr << "棒に来る数字が範囲外です" << endl;
			i--;
		}else{
			// 前処理
			a--;
			b--;
			// 交換
			myswap(pAmida + a,pAmida + b);
		}
	}

	// 出力
	for(i=0;i<w;i++){
		cout << *(pAmida + i) << endl;
	}

	// あみだくじ 領域の解放
	delete [] pAmida;

	return 0;
}

void myswap(int *a,int *b){
	*a += *b;
	*b -= *a;
	*b *= (-1);
	*a -= *b;
}

Measured memory_bytes: 1240
#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 main(){
	ll n;
	cin >> n;
	if(n%2 == 1){
		cout << 0 << endl;
	}else{
		ll n0 = n;
		ll ans = 0;
		ll k = 10;
		while(k <= n){
			n0 = n;
			ans += n0/k;
			k *= 5;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double v1, v2;
		int d;
		double t;
		String[] s;
		int[] a;
		int sum;
		
		while(scan.hasNext()){
			s = scan.next().split(",");
			a = new int[11];
			sum = 0;
			
			for(int i = 0; i < 10; i++){
				a[i]=Integer.parseInt(s[i]);
				sum += a[i];
			}
			
			v1 = Double.parseDouble(s[10]);
			v2 = Double.parseDouble(s[11]);
			d = 0;
			
			for(int i = 0; i < 10; i++){
				d += a[i];
				t = d / v1;
				if(d + t*v2 >= sum){
					System.out.println( i + 1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 25988
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main(void)
{
	int n;
	std::cin >> n;
	
	std::vector<int> A(n + 1), B(n + 1, 0), C(10001, 0);
	
	for(int i = 0; i < n; ++i)
	{
		std::cin >> A[i + 1];
		C[A[i + 1]]++;
	}
	
	for(int i = 1; i <= 10000; ++i)
	{
		C[i] += C[i - 1];
	}
	
	for(int j = n; j >= 1; j--)
	{
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	
	for(int i = 1; i <= n; ++i)
	{
		if( i > 1 ) std::cout << " ";
		std::cout << B[i];
	}
	
	std::cout << std::endl;
	
	return 0;
}



Measured memory_bytes: 18388
#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct Data {
    int** data;
};

vector<string> split(string s, string c) {
    vector<string> ret;
    for (int i = 0, n; i <= s.length(); i = n + 1) {
        n = s.find_first_of(c, i);
        if (n == string::npos) {
            n = s.length();
        }
        string tmp = s.substr(i, n - i);
        ret.push_back(tmp);
    }
    return ret;
}

int partial_sum(int i, int j, Data* d) {
    int sum = 0;
    for (int k = 0; k <= i; k++) {
        for (int l = 0; l <= j; l++) {
            sum += d->data[k][l];
        }
    }
    return sum;
}

int** precompute(int n, Data* d) {
    int** memo = new int*[n];
    for (int i = 0; i < n; i++) {
        memo[i] = new int[n];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            memo[i][j] = partial_sum(i, j, d);
        }
    }
    return memo;
}

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

    int** data = new int*[n];
    for (int i = 0; i < n; i++) {
        data[i] = new int[n];
    }

    Data d;
    d.data = data;

    for (int i = 0; i < n; i++) {
        string strRow = "";
        getline(cin, strRow);
        vector<string> row = split(strRow, " ");
        for (int j = 0; j < row.size(); j++) {
            data[i][j] = stoi(row[j]);
        }
    }

    int** memo = precompute(n, &d);

/*
    cout << endl << endl;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << memo[i][j] << " ";
        }
        cout << endl;
    }
*/

    long max = -1000000000000;

    long sum = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = i; k < n; k++) {
                for (int l = j; l < n; l++) {
                    if (i == 0 && j == 0) {
                        sum = memo[k][l];
                    } else if (i == 0) {
                        sum = memo[k][l] - memo[k][j - 1];
                    } else if (j == 0) {
                        sum = memo[k][l] - memo[i - 1][l];
                    } else {
                        sum = memo[k][l] - memo[i - 1][l] - memo[k][j - 1] + memo[i - 1][j - 1];
                    }
                    max = sum > max ? sum : max;
                }
            }
        }
    }

     cout << max << endl;
}

Measured memory_bytes: 1316
# -*- coding: utf-8 -*-
import sys
import math

def main():
  # Xはもっとも近い整数，Nは与えられるP
  X = int(input())

  if X % 2 ==0:
    # listを取得
    arr = list(map(int, input().split()))
    arr = sorted(arr, reverse=True)

    nu = X/2
    arr2 = arr[0:int(nu)]
    print(sum(arr2)*2-arr2[0])
  else:
    arr = list(map(int, input().split()))
    arr = sorted(arr, reverse=True)

    nu = int(math.floor(X/2))
    arr2 = arr[0:nu]
    print(sum(arr2)*2+arr[nu]-arr2[0])

  
  # 正常終了
  sys.exit()

if __name__ == '__main__':
    main()

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

id=list(input())

nums=[0]

for i in id:
    if i=="I":
        nums.append(1)

    else:
        nums.append(-1)

ans=[]

for i in range(len(nums)-1):
    ans.append(nums[i]+nums[i+1])
    nums[i+1]=nums[i]+nums[i+1]

if max(ans)<0:
    print("0")

else:
    print(max(ans))
    

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

using namespace std;

int main() {
    int k, a, b;
    cin>>k>>a>>b;
    if((b-a)<(k-1)&&(a%k>0)&&((a%k)<=(b%k)))
    cout<<"NG";
    else
    cout<<"OK";
    
    
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
    double k,i,n;
	while(cin >> n) {
		if (n==-1) break;
		k=0;
		for (i=2;i<=n;i++) k+=asin(1/sqrt(i));
		cout << cos(k)*sqrt(n) << endl;
		cout << sin(k)*sqrt(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1316
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
cnt = np.zeros(N+1, dtype=np.int64)

for a in A:
	cnt[a] += 1

for c in cnt[1:]:
	print(c)

Measured memory_bytes: 50888
#include <iostream>
#include <cstdio>

const int MAXN = 3000;
const int MOD = 1e9 + 7;

int n, m, ans;
int dp[MAXN | 1][MAXN | 1][2];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i <= n; ++i) dp[0][i][i == 0] = 1;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j <= n; ++j) {
			for (int k = 0; k <= 1; ++k) {
				if (k == 0 && j == 0) continue;
				if (j > 0) {
					int kk = k | (j == 1);
					dp[i + 1][j - 1][kk] = (dp[i + 1][j - 1][kk] + dp[i][j][k]) % MOD;
					dp[i + 1][j][kk] = (dp[i + 1][j][kk] + dp[i][j][k]) % MOD;
				}
				if (j < n) {
					dp[i + 1][j + 1][k] = (dp[i + 1][j + 1][k] + dp[i][j][k]) % MOD;
					dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % MOD;
				}
			}
		}
	}
	for (int i = 0; i <= n; ++i) ans = (ans + dp[m][i][1]) % MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
const int maxn=1e6+5;
int sum[4005][4005][2]={0},node[4005][4005][2]={0};

LL sum1(int a,int b,int c,int d) {return sum[a][b][0]+sum[c][d][0]-sum[a][d][0]-sum[c][b][0];}
LL sum2(int a,int b,int c,int d) {return sum[a][b][1]+sum[c][d][1]-sum[a][d][1]-sum[c][b][1];}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n,k,cnt=1;
    cin>>n>>k;k*=2;
    LL x,y;
    char c;
    for(int i=1;i<=n;i++) {
        cin>>x>>y>>c;
        x%=k;y%=k;
        if(c=='B') {
            node[x][y][0]++;
            node[x+k][y][0]++;
            node[x][y+k][0]++;
            node[x+k][y+k][0]++;
        }
        else {
            node[x][y][1]++;
            node[x+k][y][1]++;
            node[x][y+k][1]++;
            node[x+k][y+k][1]++;
        }
    }
    for(int i=1;i<=2*k;i++) {
        for(int j=1;j<=2*k;j++) {
            sum[i][j][0]=sum[i-1][j][0]+sum[i][j-1][0]-sum[i-1][j-1][0]+node[i][j][0];
            sum[i][j][1]=sum[i-1][j][1]+sum[i][j-1][1]-sum[i-1][j-1][1]+node[i][j][1];
        }
    }
    LL ans=0;
    for(int x=0;x<=k;x++) {
        for(int y=0;y<=k;y++) {
            LL temp=sum1(x,y,x+k/2,y+k/2)+sum1(x+k/2,y+k/2,x+k,y+k)+sum2(x+k/2,y,x+k,y+k/2)+sum2(x,y+k/2,x+k/2,y+k);
            ans=max(ans,temp);
            //cout<<ans<<endl;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 250752
import sys
from math import gcd
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    vec1 = [0] * (N + 1)
    vec2 = [0] * (N + 1)
    for i in range(N):
        vec1[i + 1] = gcd(vec1[i], A[i])
    for i in range(N - 1, -1, -1):
        vec2[i] = gcd(vec2[i + 1], A[i])

    ans = 0
    for i in range(N):
        g = gcd(vec1[i], vec2[i + 1])
        if ans < g:
            ans = g

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 21028
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToList();
        Console.WriteLine(a.Sum() - n);
    }
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

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

		int ret = 0;
		vector<int> m(n);
		while(true){
			rep(i, v.size()){
				int count = 0;
				rep(j, v.size()) if(v[i] == v[j]) count++;
				m[i] = count;
			}

			bool p = true;
			rep(i, v.size()) if(m[i] != v[i]){p = false; break;}
			if(p) break;
			rep(i, v.size()) v[i] = m[i];
			ret++;
		}
		cout << ret << endl;
		rep(i, v.size()) cout << (i == 0 ? "" : " ") << v[i];
		cout << endl;
	}
}

Measured memory_bytes: 1192
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
plus = []
zero = []
minus = []
ans = 1

for k in range(N):
  if A[k] > 0:
    plus.append(A[k])
  elif A[k] < 0:
    minus.append(-1 * A[k])
  else:
    zero.append(A[k])
plus.sort(reverse = True)
minus.sort(reverse = True)
lp = len(plus)
lm = len(minus)

if len(zero) + K > N:
  print(0)
  exit()
elif lp == 0: 
  if K % 2 == 1:
    if len(zero) > 0:
      print(0)
      exit()
    else:
      for k in range(K):
        ans = ans * (-1) * minus[- k - 1] % mod  
      print(ans)
      exit()
  else:
    for k in range(K):
      ans = ans * (-1) * minus[k] % mod
    print(ans)
    exit()
elif lm == 0:
  for k in range(K):
    ans = ans * plus[k] % mod
  print(ans)
  exit()

p = 0
m = 0
for k in range(K):
  if plus[p] >= minus[m]:
    p += 1
    if p == lp:
      m = K - p  
      break
  else:
    m += 1
    if m == lm:
      p = K - m
      break

def main(mp, mm, plus, minus, mod, K):
  ans = 1
  for k in range(mp):
    ans = ans * plus[k] % mod
  for k in range(mm):
    ans = ans * (-1) * minus[k] % mod
  print(ans)
  exit()

if m%2 == 0:
  main(p, m, plus, minus, mod, K)
else:
  if p == lp:
    if m != lm:
      main(p - 1, m + 1, plus, minus, mod, K)
    else:
      if len(zero) > 0:
        print(0)
        exit()
      else:
        main(p, m, plus, minus, mod, K)
  elif m == lm:
    main(p + 1, m - 1, plus, minus, mod, K)
  elif p == 0:
    main(p + 1, m - 1, plus, minus, mod, K)
  else:
    if plus[p] * plus[p - 1] > minus[m - 1] * minus[m]:
      main(p + 1, m - 1, plus, minus, mod, K)
    else:
      main(p - 1, m + 1, plus, minus, mod, K)

Measured memory_bytes: 31944
#include<bits/stdc++.h>
    #define mod (1000000007)
    typedef long long ll;
    using namespace std;
    int a[110000];
    int main()
    {
    	int n,x,ans;
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++) scanf("%d",&x),a[x]++;
    	ans=a[0]+a[1];
    	for(int i=1;i<100000;i++) ans=max(ans,a[i-1]+a[i]+a[i+1]);
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 640
def resolve():
	a,b = list(map(int,input().strip().split()))
	product = a*b

	if product%2==0:
		print('Even')
	else:
		print('Odd')

# import sys
# from io import StringIO
# import unittest


# class TestClass(unittest.TestCase):
#     def assertIO(self, input, output):
#         stdout, stdin = sys.stdout, sys.stdin
#         sys.stdout, sys.stdin = StringIO(), StringIO(input)
#         resolve()
#         sys.stdout.seek(0)
#         out = sys.stdout.read()[:-1]
#         sys.stdout, sys.stdin = stdout, stdin
#         self.assertEqual(out, output)
#     def test_入力例_1(self):
#         input = """3 4"""
#         output = """Even"""
#         self.assertIO(input, output)
#     def test_入力例_2(self):
#         input = """1 21"""
#         output = """Odd"""
#         self.assertIO(input, output)

# if __name__ == "__main__":
#     unittest.main()

if __name__ == "__main__":
    resolve()

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

bool pali(string s) {
  string t = s;
  reverse(all(t));
  return t == s;
}

void solve() {
  string s;
  cin >> s;
  int N = s.size();
  if (pali(s) && pali(s.substr(0, (N - 1) / 2)) && pali(s.substr((N + 1) / 2)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
N, M=map(int, input().split())
A=list(map(int, input().split()))

from heapq import heappush, heappop

class MaxHeap:
  def __init__(self, li):
    self.hp = []
    for e in li:
      heappush(self.hp, -e)

  def push(self, x):
    heappush(self.hp, -x)

  def pop(self):
    ret = heappop(self.hp)
    ret *= -1
    return ret

  def seak(self):
    return -self.hp[0]

  def sum(self):
    return -sum(self.hp)

AMH=MaxHeap(A)
for i in range(M):
  a=AMH.pop()
  a=a//2
  AMH.push(a)
  
print(AMH.sum())

Measured memory_bytes: 14224
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int n;
      cin>>n;
      vector<double> v(n);
      for (int i = 0; i < n; ++i)
      {
        cin>>v[i];
      }
      sort(v.begin(), v.end());
      while(v.size()!=1){
        double x=v[0],y=v[1];
        v.erase(v.begin(),v.begin()+2);
        v.emplace_back(x/2+y/2);
        sort(v.begin(), v.end());
      }
      cout<<v[0];
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }



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

ll lcm(ll a, ll b){
	return a / gcd(a,b) * b;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;cin >> a >> b;
	cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
# B - FizzBuzz Sum

# 1～Nまでのループで、3でも5でも割り切れない数の総和を求める

N = int(input())
answer = 0

for i in range(1, N + 1):
    if (i % 3 != 0) and (i % 5 != 0):
        answer += i

print(answer)


Measured memory_bytes: 9060
def fact(n, a=1)
  return a if n == 0
  fact(n-1, n*a)
end

n = gets.chomp.to_i
x = $stdin.gets.chomp.split(' ').map(&:to_i)
y = $stdin.gets.chomp.split(' ').map(&:to_i)
a, b = 1, 1
x1 = Array.new
y1 = Array.new
x.length.times do |i|
  m = 0
  n = x.pop
  x1.each do |j|
    if n > j
      m = m + 1
    end
  end
  a = a + m * fact(x1.length)
  x1.push(n)
end
  
y.length.times do |i|
  m = 0
  n = y.pop
  y1.each do |j|
    if n > j
      m = m + 1
    end
  end
  b = b + m * fact(y1.length)
  y1.push(n)
end
#p a
#p b
p (a-b).abs

Measured memory_bytes: 1788
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];
    let c = line[2];
    let d = line[3];
    let e = line[4];
    let f = line[5];

    let mut memo = vec![vec![false; 3010]; 3010];
    memo[0][0] = true;
    let mut res = (100 * a,0);
    for i in 0..f+1 {
        for j in 0..e*i/100+1 {
            if memo[i][j] {
                if j * (res.0 + res.1) > res.1 * (i + j) {
                    res.0 = i;
                    res.1 = j;
                }
                if i + 100 * a + j <= f {
                    memo[i+100*a][j] = true;
                }
                if i + 100 * b + j <= f {
                    memo[i+100*b][j] = true;
                }
                if i + c + j <= f && j + c <= e * i / 100 {
                    memo[i][j+c] = true;
                }
                if i + d + j <= f && j + d <= e * i / 100 {
                    memo[i][j+d] = true;
                }
            }
        }
    }
    println!("{} {}", res.0 + res.1, res.1);
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int c = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x < K - x) {
      c += (2 * x);
    } else {
      c += (2 *(K - x));
    }
  }
  cout << c << endl;
}



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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> c(100001, 0);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    c[a + 1]++;
  }
  
  int m = 0;
  for(int i = 1; i <= 99999; i++){
    m = max(c[i - 1] + c[i] + c[i + 1], m);
  }
  
  cout << m << endl;
  
  return 0;
}

Measured memory_bytes: 1152
# coding: utf-8
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]

for i in range(M):
    A,B=map(int,input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

ans=[-1 for i in range(N)]
queue=deque()
queue.append(0)

while len(queue)>0:
    u=queue.popleft()
    near_u=G[u]
    for k in range(len(near_u)):
        if ans[near_u[k]]==-1:
            ans[near_u[k]]=u+1
            queue.append(near_u[k])

print("Yes")
for i in range(1,N):
    print(ans[i])

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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    vector<ll> v(n);
    for(ll i = 0; i < n; ++i){
        cin >> v[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        for(ll j = i + 1; j < n; ++j){
            ans += v[i] * v[j];
        }
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
ans=0

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]="HIT"
                
if A[0][0]==A[0][1]==A[0][2]=="HIT":
        ans=1
if A[1][0]==A[1][1]==A[1][2]=="HIT":
        ans=1
if A[2][0]==A[2][1]==A[2][2]=="HIT":
        ans=1
if A[0][0]==A[1][0]==A[2][0]=="HIT":
        ans=1
if A[0][1]==A[1][1]==A[2][1]=="HIT":
        ans=1
if A[0][2]==A[1][2]==A[2][2]=="HIT":
        ans=1
if A[0][0]==A[1][1]==A[2][2]=="HIT":
        ans=1
if A[0][2]==A[1][1]==A[2][0]=="HIT":
        ans=1
        
print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include<stdio.h>
 int main(void)
 {
     int N,X,i,V;
     int D[101],L[101];

     scanf("%d%d",&N,&X);

     for(i=1;i<=N;i++)
       scanf("%d",&L[i-1]);

     for(i=1;i<=N;i++){
         D[0]=0;
         D[i]=D[i-1]+L[i-1];
     }

     for(i=0;i<=N;i++)
         if(D[i]<=X) V++;

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

     return 0;
 }



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    // 入力がaのときの偶奇を返す
    auto func = [](vector<ll> a) {
        const ll n = a.size();
        ll sum = 0;
        REP(i, n) if(a[i]==1) sum ^= (((n-1)&i)==i);
        return sum;
    };

    vector<ll> a(n);
    REP(i, n) a[i] = s[i]-'1';

    if(func(a) == 1) {
        cout << "1\n";
    } else {
        bool exist = false;
        REP(i, n) if(a[i]==1) exist = true;
        if(exist) {
            cout << "0\n";
        } else {
            REP(i, n) if(a[i]==2) a[i]--;
            if(func(a)) cout << "2\n";
            else cout << "0\n";
        }
    }

    return 0;
}

Measured memory_bytes: 17052
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		int n=ir.nextInt();
		int m=ir.nextInt();
		int t=ir.nextInt();
		int[] a=new int[n+2];
		for(int i=1;i<=n;i++)
			a[i]=ir.nextInt();
		a[n+1]=t;
		n+=2;
		int ans=0;
		for(int i=0;i<n-1;i++){
			if(i!=0&&i!=n-2){
				if(a[i+1]-a[i]>m*2){
					ans+=a[i+1]-a[i]-m*2;
				}
			}
			else{
				if(a[i+1]-a[i]>m){
					ans+=a[i+1]-a[i]-m;
				}
			}
		}
		out.println(ans);
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

		public boolean hasNext(){skip(); return hasNextByte();}

		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public double nextDouble(){return Double.parseDouble(next());}

		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}

		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 24508
from bisect import bisect_left,bisect_right
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())))
low = -1
high = A[-1]+M
while high-low>1:
    mid = (low+high)//2
    indL = bisect_left(A,mid-M)
    indR = bisect_right(A,mid)
    if indL>N-P:
        high = mid
        continue
    if indR<N-P+1:
        low = mid
        continue
    tot = M*V
    i = indL
    while i<N-P+1:
        if tot-(mid-A[i])<0:break
        tot -= mid-A[i]
        i += 1
    if i<N-P+1 or 0<=tot<=M*(P-1+indL):
        high = mid
    else:
        low = mid
ind = bisect_left(A,high-M)
print(N-ind)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int h, w;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
string s[55];
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w;
	FOR(i, h) cin >> s[i];
	FOR(x, h) FOR(y, w) {
		if (s[x][y] == '#') continue;
		int cnt = 0;
		FOR(i, 8) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx >= 0 && nx < h && ny >= 0 && ny < w) {
				if (s[nx][ny] == '#') cnt++;
			}
			s[x][y] = (char)('0'+cnt);
		}
	}
	FOR(i, h) cout << s[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define MOD2 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll std::vector<int>

int main()
{   
    IOS;
        #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
        #endif


    ll n;
    cin >> n;
    std::vector<ll> v(n);
    ll z = 0, ov;
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        if(v[i] == 0)
            z = 1;
        

    }
    ll res = 1;
    if(z) {
        cout << 0;
        return 0;
    }
    //
    for(auto it : v) {
        
        if(it <= 1000000000000000000 / res) {
            res *= it;
        }
        else {
            cout << -1;
            return 0;
        }
    }
  
    
    cout << res;

        
        
    


return 0;
}

Measured memory_bytes: 3980
#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;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
void solve()
{
	int n;
	cin >> n;
	int ans = 0;
	int a, b;
	vector<pair<int,int>> v;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		v.pb({a, b});
	}
	for (int i = 0; i < n; i++)
	{
		a = v[i].F;
		b = v[i].S;
		if (a == b)
			ans++;
		else
		{
			ans = 0;
		}
		if (ans >= 3)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3544
import bisect

N = int( input() )
a = list( map(int, input().split()) )

a.sort()
bp = bisect.bisect_right( a, 1e+5 )

ans = 0
ans += len( a[bp:] )

num = [0] * (100001)
for i in a[:bp]: num[i] += 1

for i in range(len(num)):
    if num[i] > i: ans += num[i] - i
    if num[i] < i: ans += num[i]

print( ans )

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double MOD = 0.00000001;

signed main(){
    int n;
    cin >> n;
    if(n&1){
        cout << "No";
        return 0;
    }
    string s;
    cin >> s;
    for(int i = 0;i<s.size()/2;i++){
        if(s[i] != s[i+n/2]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	ll N,C,K; cin >> N >> C >> K;
	vector<ll> T(N);
	rep(i,N) cin >> T[i];

	sort(all(T));
	int cnt = 0;
	int per = 0;
	int S = -1;
	rep(i,N) {
		if (per == C || S < T[i]) {
			cnt++;
            per = 1;
			S = T[i] + K;
		} else per++;
	}

	cout << cnt << endl;
}




Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
typedef struct node* Node;
Node rootnode,NIL;


Node getMinimum(Node node){
  while(node->left!=NIL)
    node=node->left;
  return node;
}

Node getSuccessor(Node node){
  Node delete=node->parent;
  if(node->right!=NIL)
    return getMinimum(node->right);

  while(delete!=NIL && node==delete->right){
    node=delete;
    delete=delete->parent;
  }
  return delete;
}

Node Find(Node node,int key){
  while(node!=NIL && node->key!=key){
    if(node->key<key)
      node=node->right;
    else
      node=node->left;
  }
  return node;
}

void Insert(int key){
  Node node=rootnode,z,y=NIL;
  z=(Node)malloc(sizeof(struct node));
  z->key=key;
  z->left=NIL;
  z->right=NIL;

  while(node!=NIL){
    y=node;
    if(key>node->key)
      node=node->right;
    else
      node=node->left;
  }
  z->parent=y;
  if(y==NIL)rootnode=z;
  else{
    if(key>y->key)
      y->right=z;
    else
      y->left=z;
  }
}

void Preorder(Node node){
  printf(" %d",node->key);
  if(node->left!=NIL)
    Preorder(node->left);
  if(node->right!=NIL)
    Preorder(node->right);
}
void Inorder(Node node){
  if(node->left!=NIL)
    Inorder(node->left);
  printf(" %d",node->key);
  if(node->right!=NIL)
    Inorder(node->right);
}

void Delete(Node node){
  Node delete;
  Node child;

  if(node->left==NIL || node->right==NIL)
    delete=node;
  else
    delete=getSuccessor(node);
   
  
  //setting child
  if(delete->left!=NIL)
    child=delete->left;
  else
    child=delete->right;
  
  if(child!=NIL)
    child->parent=delete->parent;
  
  
  //if deletenode is rootnode
  if(delete->parent==NIL)
    rootnode=child;
  //deletenode is not rootnode
  else{
    if(delete->parent->left==delete)
      delete->parent->left=child;
    else
      delete->parent->right=child;
  }

  if(delete!=node)
    node->key=delete->key;
  free(delete);
}

int main(void){
  int n,i,key;
  char command[6];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      Insert(key);
    }
    else if(command[0]=='p'){
      Inorder(rootnode);
      printf("\n");
      Preorder(rootnode);
      printf("\n");
    }
    else if(command[0]=='f'){
      scanf("%d",&key);
      if(Find(rootnode,key)!=NIL)
	printf("yes\n");
      else printf("no\n");
    }
    else if(command[0]=='d'){
      scanf("%d",&key);
      Delete(Find(rootnode,key));
    }
  }

  return 0;
}


Measured memory_bytes: 20448
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
    elif op == '+':
        print(int(a+b))
    elif op == '-':
        print(int(a-b))
    elif op == '*':
        print(int(a*b))
    elif op == '/':
        print(int(a/b))


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p 998244353

typedef struct {
	int a;
	int b;
	int c;
}tuple;

int ABS(int a){
	return a >= 0 ? a : -a;
}

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed compare_tuple(const void *_a, const void *_b){
	tuple a = *(tuple *)_a, b = *(tuple *)_b;
	if(a.a != b.a){
		return a.a - b.a;
	}
	else{
		return a.b - b.b;
	}
}

int search(tuple *tps, int L, tuple tp){
	if(L == 0){
		return -1;
	}
	int l = -1, h, r = L - 1;
	while(r - l > 1){
		h = (l + r) / 2;
		if(compare_tuple(&tps[h], &tp) < 0){
			l = h;
		}
		else{
			r = h;
		}
	}
	if(compare_tuple(&tps[r], &tp) == 0){
		return tps[r].c;
	}
	else{
		return -1;
	}
}

int coefficient(int c, int d, int b){
	if(c == -1 && d == -1){
		return 2;
	}
	else if(c == -1 || d == -1){
		return 1;
	}
	else if((c ^ d) == b){
		return 1;
	}
	else{
		return 0;
	}
}

signed main(){
	int N, M, a, b, c, i, j, k;
	scanf("%lld%lld", &N, &M);
	tuple *in = (tuple *)malloc(sizeof(tuple) * M);
	tuple *out = (tuple *)malloc(sizeof(tuple) * M);
	for(i = 0, j = 0, k = 0; i < M; i++){
		scanf("%lld%lld%lld", &a, &b, &c);
		a--;
		b--;
		if(ABS(a - b) < 3){
			in[j] = (tuple){a, b, c};
			j++;
		}
		else{
			out[k] = (tuple){a, b, c};
			k++;
		}
	}
	int L_in = j, L_out = k;
	qsort(in, L_in, sizeof(tuple), compare_tuple);
	qsort(out, L_out, sizeof(tuple), compare_tuple);

	int f, rest;
	for(i = 0, j = 0, f = 1; i < L_out; i++){
		c = search(out, L_out, (tuple){out[i].b, out[i].a, 0});
		if(c == -1){
			j++;
		}
		else if(out[i].a < out[i].b){
			if((out[i].c ^ c) == 0){
				j++;
			}
			else{
				f = 0;
			}
		}
	}
	if(f == 0){
		rest = 0;
	}
	else{
		rest = power(2, ((N - 2) * (N - 3)) / 2 - j);
	}
//	printf("j = %lld\n", j);
//	printf("rest = %lld\n", rest);

	int **dp = (int **)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		dp[i] = (int *)malloc(sizeof(int) * 2);
		for(j = 0; j < 2; j++){
			dp[i][j] = 0;
		}
	}
	int c0, c10, c11, c20, c21;
	c0 = search(in, L_in, (tuple){0, 0, 0});
	if(c0 == -1 || c0 == 0){
		dp[0][0] = 1;
	}
	if(c0 == -1 || c0 == 1){
		dp[0][1] = 1;
	}
	int k0, k1;
	for(i = 1; i < N; i++){
		c0 = search(in, L_in, (tuple){i, i, 0});
		c10 = search(in, L_in, (tuple){i, i - 1, 0});
		c11 = search(in, L_in, (tuple){i - 1, i, 0});
		c20 = search(in, L_in, (tuple){i + 1, i - 1, 0});
		c21 = search(in, L_in, (tuple){i - 1, i + 1, 0});
		if(c0 == -1 || c0 == 0){
			k0 = coefficient(c10, c11, 0) * coefficient(c20, c21, 0);
			k1 = coefficient(c10, c11, 1) * coefficient(c20, c21, 0);
			dp[i][0] = MOD(k0 * dp[i - 1][0] + k1 * dp[i - 1][1]);
		}
		if(c0 == -1 || c0 == 1){
			k0 = coefficient(c10, c11, 1) * coefficient(c20, c21, 1);
			k1 = coefficient(c10, c11, 0) * coefficient(c20, c21, 1);
			dp[i][1] = MOD(k0 * dp[i - 1][0] + k1 * dp[i - 1][1]);
		}
	}
/*	for(i = 0; i < N; i++){
		printf("dp[%lld] = (%lld, %lld)\n", i, dp[i][0], dp[i][1]);
	}
*/	printf("%lld\n", MOD(MOD((dp[N - 1][0] + dp[N - 1][1]) * power(2, p - 2)) * rest));
	return 0;
}

Measured memory_bytes: 5224
A = Array.new(N=gets.to_i) { gets.split.map(&:to_i) }
c = t = 0
A.permutation(N) { |a|
	d = []
	a.each_cons(2) { |a,b| 
		d << a.zip(b).map {|a,b| (a-b)**2}.inject(&:+) ** 0.5 
	}
	t += d.sort!.inject(&:+)
	c += 1
}
p t/c

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    char s[100005];
    scanf("%s", s);
    int ans = 1;
    char now = s[0];
    for(int i = 0; i < n; ++i)
    {
        if(s[i] == now)
            continue;
        else
        {
            ++ans;
            now = s[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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



void trace(int A[], int N){
    for (int k = 0; k < N-1; k++){
        cout << A[k] << " "; 
    }
    cout << A[N-1] << "\n";
}


int main(){

    int N;
    int A[100];
    cin >> N;
    for (int i =0; i < N; i++) cin >> A[i];
    trace(A,N);
    for (int i =1; i < N; i++){
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }


}


Measured memory_bytes: 3100
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; string S; cin>>N>>S;

    for (int i = 0; i < S.length(); ++i) {
        printf("%c", (S[i]+N)>90?65+(S[i]+N)-91:S[i]+N);
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {

long long int n,s=0,t=0,rem=0;
scanf("%lld",&n);
t=n;

while(t>0){
    rem=t%10;
    s+=rem;
    t=t/10;
}
if(n%s==0){
    printf("Yes");
}
else
printf("No");

return 0;

    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C){
		disp("Yes"); 
	}
	else {
		disp("No");
	}
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

r = s.count('R')
g = s.count('G')
b = s.count('B')

if n < 4
  puts 0
  exit
end

ans = r*g*b
(0..n-3).each do |i|
  (i+1..n-2).each do |j|
    k = j*2-i
    if k >= n
      break
    end
    if s[i] != s[j] && s[i] != s[k] && s[j] != s[k]
      ans -= 1
    end
  end
end
puts ans

Measured memory_bytes: 14320
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n;
int a[N];
set < int > pos;
map < int, int > val;


int ok(int x){
  pos.clear(), val.clear();
  for(int i = 2; i <= n; ++i){
    if(a[i] > a[i - 1]){
      continue;
    } else{
      while(!pos.empty() && *pos.rbegin() > a[i]){
        val.erase(*pos.rbegin());
        pos.erase(--pos.end());
      }
      for(int j = a[i]; j >= 1; --j){
        val[j]++;
        if(val[j] == x){
          if(x == 1) return 0;
          if(j == 1) return 0;
          val[j] = 0;
          pos.erase(j);
          val.erase(j);
        } else{
          pos.insert(j);
          break;
        }
      }
    }
  }
  return 1;
}

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
  }
  int ans = n;
  for(int j = (1 << 20); j > 0; j >>= 1){
    if(ans > j && ok(ans - j)){
      ans -= j;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int a, b;
	cin >> a >> b;
	if (a < b)
	{
		for (int i = 0; i < b; i++)
			cout << a;
	}
	else
	{
		for (int i = 0; i < a; i++)
			cout << b;
	}
	cout << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)
if s == s[::-1] and s[:(n - 1) // 2] == s[:(n - 1) // 2][::-1] \
        and s[(n + 3) // 2 - 1:] == s[(n + 3) // 2 - 1:][::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9108