akhauriyash/Code-Regression huggingface dataset:
n, k = map(int,input().split())
r,s,p = map(int,input().split())
tlist = list(input())
score = 0

for i in range(k):
    t = tlist[i]
    if t == "r":
        score += p
    elif t == "s":
        score += r
    elif t == "p":
        score += s

for i in range(k,n):
    if tlist[i] != tlist[i-k]:
        if tlist[i] == "r":
            score += p
        elif tlist[i] == "s":
            score += r
        elif tlist[i] == "p":
            score += s
    else:
        tlist[i] = "n"

print(score)

Measured memory_bytes: 49520
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<int> x(n);
  int sum=0;
  rep(i,n){
    cin >> x[i];
    x[i]>k/2 ? sum += k-x[i] : sum += x[i]; 
  }
  cout <<sum*2;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  string S;
  cin >> S;
  int maxLength = 0;
  int length = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      length++;
    }
    else {
      if (maxLength < length) {
        maxLength = length;
      }
      length = 0;
    }
  }
  if (maxLength < length) {
    maxLength = length;
  }
  cout << maxLength << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        for (int i = 0; i < k; i++) {
            if (i % 2 == 0) {
                b += a / 2;
                a /= 2;
            } else {
                a += b / 2;
                b /= 2;
            }
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21972
#include<cstdio>
using namespace std;
int n,m,K;
int main()
{
	int i,j;
	int num;
	scanf("%d%d%d",&n,&m,&K);
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++){
			num=i*m+j*n-2*i*j;
			if(num==K){
				printf("Yes\n");
				return 0;
			}
		}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N, K = list(map(int, input().split()))
E = list(map(lambda x: (float(x) + 1) / 2, input().split()))
res = sum(E[:K])
t = res
for i in range(K, N):
    t += -E[i - K] + E[i]
    res = max(res, t)
print(res)


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 2000005;



vi adj[N];
ll arr[N];


void dfs(int s,int par){
    for(auto ch : adj[s]){
        if(ch == par) continue;
        arr[ch] += arr[s];
        dfs(ch,s);
    }
}

int main(){
    ll n,q,u,v,x;

    cin >> n >> q;

    for(int i = 0;i < n - 1;i++){
        cin >> u >> v;

        u--;v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    for(int i = 0;i < q;i++){
        cin >> u >> x;
        u--;
        arr[u] += x;
    }

    dfs(0,-1);
    for(int i = 0;i < n;i++){
        cout << arr[i] << " ";
    }
}















Measured memory_bytes: 67712
# A×Bを求めてください

# 1.入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a , b)

# 2.受け取った入力値を使って、適切に処理(計算)すること
answer = a * b

# 3.計算した結果を出力すること
print(answer)


Measured memory_bytes: 9080
#include <bits/stdc++.h>
const int MOD = 1e9+7;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ar array
using namespace std;
using P = pair<int,int>;

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

	double X,T;
	cin >> X >> T;

	cout << X/T << endl;
	return 0;
}


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

int main()
{
int N;
cin >> N;
int A[110];
for(int i = 0; i < N; i++) cin >> A[i];
bool J = true;
for(int i = 0; i < N; i++)
{
    if (A[i]%2 == 0)
    {
        if (A[i]%3 != 0 and A[i]%5 != 0)
        {
            J = false;
        }
    }
}

if (J == false) cout << "DENIED" << endl;
else cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
loop do
    n, t, l, b = gets.split.map(&:to_i)
    break if n == 0 && t == 0
    lose = Array.new(n+1,false)
    l.times do
        lose[gets.to_i] = true
    end
    back = Array.new(n+1,false)
    b.times do
        back[gets.to_i] = true
    end
    dp = Array.new(t+2).map{Array.new(n+1, 0.0)}
    dp[0][0] = 1.0

    1.upto(t) do |i|
        n.times do |s|
            1.upto(6) do |d|
                nt = s + d
                nt = n - (nt - n) if nt > n
                if back[nt]
                    dp[i][0] += 1.0/6.0 * dp[i-1][s]
                    dp[i][nt] = 0
                elsif lose[nt]
                    dp[i+1][nt] += 1.0/6.0 * dp[i-1][s]
                else
                    dp[i][nt] += 1.0/6.0 * dp[i-1][s]
                end
            end
        end
    end
    puts sprintf("%.6f",dp.map{|m| m[n]}.inject(:+))
end

Measured memory_bytes: 6604
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main()
{
    io
    ll i,j,n,val[55];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>val[i];
    }
    sort(val,val+n);
    double ans=(double)val[0];
    for(i=1;i<n;i++){
        ans=(double)(ans+(double)val[i])/(double)2;
    }
    cout<<setprecision(10)<<ans;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    double a,b;
    int a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,d1=0,d2=0;
    while(cin>>a>>b)
    {
        if(a<0.2)d1++;
        else if(0.2<=a&&a<0.6)c1++;
        else if(0.6<=a&&a<1.1)b1++;
        else if(1.1<=a)a1++;
        if(b<0.2)d2++;
        else if(0.2<=b&&b<0.6)c2++;
        else if(0.6<=b&&b<1.1)b2++;
        else if(1.1<=b)a2++;
    }
    cout<<a1<<" "<<a2<<endl;
    cout<<b1<<" "<<b2<<endl;
    cout<<c1<<" "<<c2<<endl;
    cout<<d1<<" "<<d2<<endl;
    return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
    public static void main(String[] a) {
        Scanner scan = new Scanner(System.in);
        double price = scan.nextDouble();
        double taxRate = 1.08;
        double pcWithOutTaxF = Math.floor(price / taxRate);
        double pcWithOutTaxC = Math.ceil(price / taxRate);
        double confirmF = Math.floor(pcWithOutTaxF * taxRate);
        double confirmC = Math.floor(pcWithOutTaxC * taxRate);

        if (price == confirmF) {
            System.out.println((int)pcWithOutTaxF);
        } else if (price == confirmC) {
            System.out.println((int)pcWithOutTaxC);
        } else {
            System.out.println(":(\n");
        }
    }
}

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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b;
    }else if(a >= 6){
        cout << b/2;
    }else{
        cout << 0;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  int x;
  cin >> x;
  int max=1;
  for(int num=2;num*num<=x;num++) {
    int sqN=num*num;
    while(sqN<=x) {
      if(max<sqN) {
        max=sqN;
      }
      sqN *= num;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define RANGE(i, x, n) for(long long i = x; i < n; ++i)
using namespace std;

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> P(N, 0);
    REP(i, N) {
        cin >> P[i];
    }
    long long ans = 0;
    REP(i, N - 1) {
        ans += min(B, A * (P[i + 1] - P[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n; cin >> n;
    int cnt = 0;
    rep(i,n){
        int d1,d2; cin >> d1 >> d2;
        if(d1==d2){
            cnt++;
        } else {
            cnt=0;
        }
        if(cnt==3){
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int64_t> hs(n);
	for (auto &h : hs)
	{
		cin >> h;
	}
	vector<int64_t> dp(n, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i + j < n)
			{
				dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b){
		printf("a > b\n");
	} else if (a < b){
	printf("a < b\n");
}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

LDS = deque()
LDS.append(A[0])

for i in range(1,N):
    if LDS[0] >= A[i]:
        LDS.appendleft(A[i])
    else:
        LDS[bisect.bisect_left(LDS,A[i])-1] = A[i]

print(len(LDS))

Measured memory_bytes: 53592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        a:usize,
        b:usize,
        c:usize,
    }
    let ans = if a == b && b == c && a==c {
        "Yes"
    } else{
        "No"
    };
    println!("{}",ans);
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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(void){
  ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;

int wide = A - 2 * B;
int ans;
ans = max(0, wide);

cout << ans << endl;




  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,sum=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x * 2 > (k - x) * 2){
      sum += (k - x) * 2;
    }else{
      sum += x * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long 
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main() {
	long long  n;
	cin >> n;
	vector<ll> s(n + 1, 0);
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		s[i + 1] = s[i] + a;
	}
	sort(s.begin(), s.end());
	ll ans = 0;
	ll st = 0;
	ll ba = s[0];
	for (long long i = 1; i <= n; i++) {
		if (s[i] != ba) {
			st = i;
			ba = s[i];
		}
		ans += i - st;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
int main (){
  int i;
  int n;
  cin>>n;
  printf("%.20f\n",M_PI*n*2);
  //cout<<(double)M_PI*n*2<<endl;
  return 0;
}

Measured memory_bytes: 3764
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil, log2

def main():
  n, k = map(int, input().strip().split())
  p = 1/n
  s = 0
  for x in range(1, n+1):
    if x >= k:
      s += p
    else:
      s += p * (1/2 ** ceil(log2(k/x)))
  print(s)

if __name__=='__main__':
  main()



Measured memory_bytes: 3188
import sys

n = int(input())
l = 0
r = n-1
mid = r // 2
re = [None] * n
print(0, flush=True)
re[0] = input()
if re[0] == "Vacant":
  sys.exit()
print(n-1, flush=True)
re[n-1] = input()
if re[n-1] == "Vacant":
  sys.exit()
print(mid, flush=True)
re[mid] = input()
while re[mid] != "Vacant":
  if re[l] == re[mid]:
    if (mid - l) % 2:
      r = mid
    else:
      l = mid
  else:
    if (mid - l) % 2:
      l = mid
    else:
      r = mid
  mid = (l + r) // 2
  print(mid, flush=True)
  re[mid] = input()
else:
  sys.exit()


Measured memory_bytes: 4424
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    INF = 10 ** 12
    dp = [INF] * n
    dp[0] = 0
    dp[1] = abs(hs[1] - hs[0])

    for i in range(2, n):
        dp[i] = min(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]))
        dp[i] = min(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]))

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84284
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0;
        String S = sc.next();
        for(int i = 0;i < S.length();i++){
            if('+' == S.charAt(i)){
                count++;
            } else count--;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

void long_search(const string& s, const string& t, const int st_start, vector<string>& dp1, vector<string>& dp2){

  if(st_start+1 <= s.size() + t.size() + 2) long_search(s, t, st_start+1, dp1, dp2);

  for(int s_start=0; s_start<min(st_start+1, (int)s.size()); ++s_start){
    int t_start = st_start-s_start;

    if(t_start>=t.size()) continue;

    if(st_start%2==1){
      if(s[s_start] == t[t_start]){
        dp2[s_start] = s[s_start] + dp2[s_start+1];
      }else{
        if(dp1[s_start].size() > dp1[s_start+1].size()){
          dp2[s_start] = dp1[s_start];
        }else{
          dp2[s_start] = dp1[s_start+1];
        }
      }
    }else{
      if(s[s_start] == t[t_start]){
        dp1[s_start] = s[s_start] + dp1[s_start+1];
      }else{
        if(dp2[s_start].size() > dp2[s_start+1].size()){
          dp1[s_start] = dp2[s_start];
        }else{
          dp1[s_start] = dp2[s_start+1];
        }
      }
    }
  }


  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string s, t;
  cin >> s >> t;
  vector<string> dp1(s.size()+t.size()+2, "");
  vector<string> dp2(s.size()+t.size()+2, "");
  long_search(s, t, 0, dp1, dp2);

  cout << dp1[0] << "\n";

  return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
vector<int>g[maxn],vis(maxn);
int n,m;
void run(int u,list<int>&path){
	vis[u] = 1;
	path.push_back(u);
	for(auto v:g[u]){
		if( !vis[v]){
			run(v,path);
			return;
		}
	}
}
	
int32_t main(){
	IOS
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	list<int> l1 , l2 ;
	run(1,l1);
	run(1,l2);
	l2.pop_front();
	cout << ( l1.size() + l2.size() ) << endl;
	for(auto it=l1.rbegin();it!=l1.rend();it++){
		cout << *it <<" ";
	}
	for(auto it=l2.begin();it!=l2.end();it++){
		cout << *it <<" ";
	}
	
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 12632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t A,B,ans=0; cin>>A>>B;
  auto C=B-A+1;
  if(A%2==1){
    ans=(ans^A);
    C--;
  }
  if(B%2==0){
    ans=(ans^B);
    C--;
  }
  C/=2;
  if(C%2==1) ans=(ans^1);
  cout<<ans;
}


Measured memory_bytes: 3604
from bisect import bisect_left
try:
    from collections.abc import Sequence
except:
    from collections import Sequence


class LazySequence(Sequence):
    def __init__(self, f, n):
        self.f = f
        if isinstance(n, int):
            self.r = range(n)
        elif isinstance(n, range):
            self.r = n
        else:
            raise TypeError

    def __len__(self):
        return len(self.r)

    def __getitem__(self, i):
        r = self.r[i]
        if isinstance(r, int):
            return self.f(r)
        else:
            return self.__class__(self.f, r)


N, A, B = map(int, input().split())
D = A - B
H = [int(input()) for _ in range(N)]
H.sort()
l = (H[0] - 1) // A + 1
r = (H[-1] - 1) // B + 1


def isenough(n):
    b = B * n
    for h in H:
        n -= max(0, (h - b - 1) // D + 1)
        if n < 0:
            return False
    return True


a = LazySequence(isenough, r + 1)
ans = bisect_left(a, True, l, r)
print(ans)


Measured memory_bytes: 50264
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
mod = 10**9 +7
dp = [0]*(N+1)
dp[:2]= 1, 1 if 1 not in A else 0 # 最初の2つめは1だが、壊れている場合は0にする
for i in range(2, N+1):
    if i not in A: # 壊れている時はスキップする
        dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[-1])

Measured memory_bytes: 13216
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections,math
sys.setrecursionlimit(1000000)

INF = 2**31-1

N,Q = map(int,sys.stdin.readline().split())
COM = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
i = 1
while i < N:
    i*=2
N = i
MAX_N = 1 << math.ceil(math.log2(N)) # 17
SEG = [0]*(2*MAX_N-1)
#print(N,Q,SEG)
def update(k,a):#0 indexed
    #print(k,a)
    k += N-1
    SEG[k] += a
    while k > 0:
        k = (k-1)//2
        SEG[k] = SEG[k*2+1]+SEG[k*2+2]

def find(a,b,i=0,l=0,r=N):#0 indexed
    #print(i,a,b,l,r)
    if r <= a or  b <= l:
        return 0
    if a <= l and r <= b:
        return SEG[i]
    vl = find(a,b,2*i+1,l,(r+l)//2)
    vr = find(a,b,2*i+2,(r+l)//2,r)
    return vl+vr

#print(N,Q)
for com,x,y in COM:
    if com == 0:
        update(x-1,y)
        #print(0,x,y,SEG)
    else:
        print(find(x-1,y))
        #print(1,x-1,y,SEG)


Measured memory_bytes: 25224
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long sx, sy, tx, ty;
    scan(sx, sy, tx, ty);

    foreach (_; iota(tx - sx))
        write('R');
    foreach (_; iota(ty - sy))
        write('U');

    foreach (_; iota(tx - sx))
        write('L');
    foreach (_; iota(ty - sy))
        write('D');

    write('D');
    foreach (_; iota(tx - sx + 1))
        write('R');
    foreach (_; iota(ty - sy + 1))
        write('U');
    write('L');

    write('U');
    foreach (_; iota(tx - sx + 1))
        write('L');
    foreach (_; iota(ty - sy + 1))
        write('D');
    writeln('R');
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
[N, M] = [int(i) for i in input().split()]
num_dict = {}
for i in range(M):
  [s, c] = [int(i) for i in input().split()]
  if (N != 1) and (s==1) and (c==0):
    print('-1')
    exit()
  if s in num_dict:
    if num_dict[s] != c:
      print('-1')
      exit()
  else:
  	num_dict[s] = c
ans = '0' * N
for key in num_dict.keys():
  ans = ans[:key-1] + str(num_dict[key]) + ans[key:]
if ans == '0':
  pass
elif ans[0] == '0':
  ans = '1' + ans[1:]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int count=0;
		long ans=1;
		long mod=1000000007;
		for(int i=0; i<2*n; i++){
			if(i==0 || i==2*n-1){
				if(s.charAt(i)=='W'){
					System.out.println(0);
					return;
				}
				if(i==0){
					count++;
				}else{
					count--;
				}
			}else if(s.charAt(i)=='B'){
				if(count%2==0){
					count++;
				}else{
					ans=(ans*count)%mod;
					count--;
				}
			}else{
				if(count%2==0){
					ans=(ans*count)%mod;
					count--;
				}else{
					count++;
				}
			}
			if(count<0){
				System.out.println(0);
				return;
			}
		}
		if(count!=0){
			System.out.println(0);
			return;
		}
		for(int i=2; i<=n; i++){
			ans=(ans*i)%mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26544
import math

n=int(input())
machi=[]
for i in range(n):
    temp1,temp2=map(int,input().split())
    machi.append([temp1,temp2])

#print(machi)

bai=math.factorial(n-2)

sum=0

for i in range(n):
    for j in range(n):
        if(i==j):
            continue
        nijou=(machi[i][0]-machi[j][0])**2+(machi[i][1]-machi[j][1])**2
        kyori=nijou**(1/2)
        sum+=kyori*bai

print((n-1)*sum/math.factorial(n))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int r;
    cin>>r;
    cout<<3*r*r;
	return 0;
}


Measured memory_bytes: 256
N, L = gets.split.map(&:to_i)

if L > 0
  puts (L + 1 + L + N - 1) * (N - 1) / 2
else
  if L + N > 0
    puts (L + L + N - 1) * (N) / 2
  else
    puts (L + L + N - 2) * (N - 1) / 2
  end
end

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int MOD=1e9+7,N=1e5+1,M=4e5+100,oo=1e9;


void smain() {


    int x,p;
    cin>>x>>p;
    cout<<(ld)((x/2+x%2)*100)/p;



}



Measured memory_bytes: 3800
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int n, s;
int cnt = 0;

void dfs(int i, int sum, int c)
{
	if (c == n)
	{
		if (s == sum)
		{
			cnt++;
		}
		return;
	}

	if (i > 9)
	{
		return;
	}

	dfs(i + 1, sum, c);

	dfs(i + 1, sum + i, c + 1);

	return;
}

int main()
{
	for (; cin >> n >> s;)
	{
		cnt = 0;
		if (n == 0 && s == 0)
		{
			break;
		}
		dfs(0, 0, 0);

		cout << cnt << endl;
	}
}


Measured memory_bytes: 3008
s = input()
n = len(s)
tile1 = ""
tile2 = ""

for i in range(n):
  if i % 2 == 0:
    tile1 += "0"
    tile2 += "1"
  else:
    tile1 += "1"
    tile2 += "0"

ans1 = 0
ans2 = 0

for i in range(n):
  if s[i] == tile1[i]:
    ans1 += 1
  if s[i] == tile2[i]:
    ans2 += 1
    
print(min(ans1, ans2))

Measured memory_bytes: 3316
a=list(input())
a_pre=a[:len(a)//2]
a_post=a[len(a)//2:]
a_post.reverse()
if a_pre==a_post:
            print('0')
else:
            cnt=0
            for i in range(len(a_pre)):
                        if a_pre[i]!=a_post[i]:
                                    cnt+=1
            print(cnt)                        



Measured memory_bytes: 3060
import java.util.Scanner;


public class Main{
	public static long Knapsack(int W,int n,long[]w,long[]v){
		int i;int j = 0;
		long[][] k=new long[n+1][W+1];
		for(i=0;i<=n;i++){
			for(j=0;j<=W;j++){
		        if(i==0||j==0){
			        k[i][j]= 0;
		        }else{
		        	if(w[i-1]>j){
		        		k[i][j]=k[i-1][j];
		        	}else{
		        		k[i][j]=Math.max(v[i-1]+k[i-1][(int) (j-w[i-1])],k[i-1][j] );
		        	}
		        }
			}
		}return k[i-1][j-1];
	}
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int W=sc.nextInt();
		long []v=new long[n];
		long []w=new long[n];
		for(int i=0;i<n;i++){
			w[i]=sc.nextLong();
			v[i]=sc.nextLong();
		}
		System.out.print(Knapsack(W,n,w,v));
	}
}

Measured memory_bytes: 130980
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
bool prime(ll n){
    for(ll i = 2; i * i <= n; i++)
        if(n % i == 0)
            return false;
    return true;
}
int main()
{
    Hello
    ll a, b;
    cin >> a >> b;
    ll n = max(a, b);
    set <ll> v;
    for(ll i = 1; i * i <= n; i++){
        if(a % i == 0 && b % i == 0 && prime(i))
                v.insert(i);
        if(b % i == 0 && (a) % (b/i) == 0 && prime(b/i))
            v.insert(b/i);
    }
    cout << v.size();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
    {
        cout<<(n-2)*(b-a)+1<<"\n";
    }
    else cout<<0<<"\n";
    return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		long sum = 0L;
		for(int i = 1; i <= N; i++) {
			if(!(i % 3 == 0 || i % 5 == 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 27160
K = int(input())
S = input()
M = K + len(S)
alpha = "abcdefghijklmnopqrstuvwxyz"
mod = int(1e9) + 7 # <-- input modulo
maxf = 2000010           # <-- input factional limitation

def doubling(n, m, modulo=mod):
    y = 1
    base = n
    tmp = m
    while tmp != 0:
        if tmp % 2 == 1:
            y *= base
            if modulo > 0:
                y %= modulo
        base *= base
        if modulo > 0:
            base %= modulo
        tmp //= 2
    return y

def inved(a, modulo=mod):
    x, y, u, v, k, l = 1, 0, 0, 1, a, modulo
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % modulo

fact = [1 for _ in range(maxf+1)]
invf = [1 for _ in range(maxf+1)]

for i in range(maxf):
    fact[i+1] = (fact[i] * (i+1)) % mod
invf[-1] = inved(fact[-1])
for i in range(maxf, 0, -1):
    invf[i-1] = (invf[i] * i) % mod
  
SS = 0
bas = 1
for i in range(M, len(S)-1, -1):
  SS += (bas * invf[i] * invf[M-i]) % mod
  bas *= 25
  bas %= mod
  SS %= mod
print(SS*fact[M]%mod)


Measured memory_bytes: 176028
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <functional>
using namespace std;

int main()
{
	int s,f,e;
	cin >> s;

	f = s/100;
	e = s%100;

	if((0 < f && f <= 12) && (0 < e && e <= 12)){
		cout << "AMBIGUOUS" << endl;
		return 0;
	}else if((f == 0 || 12 < f) && (0 < e && e <= 12)){
		cout << "YYMM" << endl;
		return 0;
	}else if((0 < f && f <= 12) && (e == 0 || 12 < e)){
		cout << "MMYY" << endl;
		return 0;
	}else{
		cout << "NA" << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e5 + 10;

int n, m;
string s;

const int MAX = 1e5 + 5;
const int LIM = 3e5 + 5;        //equals 2 * 2^ceil(log2(n))

int seg[LIM];

//Complexity: O(1)
//Stores what info. segment[i..j] should store
int combine(int &a, int &b) {
   return min(a, b);
}

//Complexity: O(log n)
void update(int t, int i, int j, int x, int y) {
   if (i > x || j < x) {
      return ;
   }
   if (i == j) {
      //base case : leaf node information to be stored here
      seg[t] = y;
      return ;
   }
   int mid = (i + j) / 2;
   update(t*2, i, mid, x, y);
   update(t*2 + 1, mid + 1, j, x, y);
   seg[t] = combine(seg[2*t], seg[2*t+1]);
}

//Complexity: O(log n)
int query(int t, int i, int j, int l, int r) {
   if (l <=i && j <= r) {
      return seg[t];
   }
   int mid = (i + j) / 2;
   if (l <= mid) {
      if (r <= mid) {
         return query(t*2, i, mid, l, r);
      }
      else {
         int a = query(t*2, i, mid, l, r);
         int b = query(t*2 + 1,  mid + 1, j, l, r);
         return combine(a, b);
      }
   }
   else {
      return query(t*2 + 1,  mid + 1, j, l, r);
   }
}

int32_t main(){_

   cin>>n>>m;
   cin >> s;

   vector<int> mi(n+10, inf);

   vector<int> v;

   vector<int> pos[n+10];

   mi[0] = 0;
   pos[0].push_back(0);
   for (int i = 1; i <= min(n, m); ++i)
   {
      mi[i] = 1;
      if(s[i] == '1'){
         mi[i] = inf;
      }
      update(1, 1, n, i, mi[i]);
      if(mi[i] != inf)
         pos[mi[i]].push_back(i);
   }

   for (int i = m+1; i < sz(s); ++i)
   {
      if(s[i] == '1'){
         mi[i] = inf;
      }
      else{
         mi[i] = query(1, 1, n, i-(m), i-1) + 1;
      }
      update(1, 1, n, i, mi[i]);
      // tr(i, mi[i]);
      if(mi[i] <= n+100)
         pos[mi[i]].push_back(i);
   }

   tr(mi);
   if (mi[n] >= 1e7) {
      cout<<-1;
      return 0;
   }

   vector<int> vals;
   int ptr = mi[n];
   vals.push_back(n);
   --ptr;

   for (int i = ptr; i >= 0; --i)
   {
      int start = vals.back();
      int lst = i;
      for (int j = start-1; j >= max(0LL, start-m); --j)
      {
         if(mi[j]+1 == mi[start])
            lst = j;
      }
      vals.push_back(lst);
   }

   vector<int> ok;
   for (int i = 0; i+1 < sz(vals); ++i)
   {
      ok.push_back(vals[i] - vals[i+1]);
   }

   reverse(ok.begin(), ok.end());
   assert(sz(ok) == mi[n]);

   for(auto it: ok)
      cout << it << " ";

   return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

string s;

bool check(int l, int r) {
	for (int i = l; i <= (l+r)/2; ++i) {
		debug(s[i]);
		debug(s[r-i-1]);
		if (s[i] != s[r-i-1]) return false;
	}
	return true;
}

void solve() {
	cin >> s;
	const int n = s.size();
	if (check(0, n) && check(0, (n-1)/2) && check((n+3)/2-1, n)) cout << "Yes";
	else cout << "No";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int getKey(int x,vector<ll> &arr){
    return arr.at(x-1);
}

int getLeft(int x,vector<ll> &arr){
    return arr.at(2*x-1);
}

int getRight(int x,vector<ll> &arr){
    return arr.at(2*x);
}

int getParent(int x,vector<ll> &arr){
    int one_start = x/2;
    return arr.at(one_start - 1);
}


int main(){
    int n;
    cin >> n;
    vector<ll> heap(n);
    for(int i=0;i<n;i++) cin >> heap.at(i);
    for(int i=0;i<n;i++){
        int k = i+1;
        printf("node %d: key = %d, ",k,getKey(k,heap));
        if(k / 2 >= 1){
            printf("parent key = %d, ",getParent(k,heap));
        }
        if(k * 2 <= n){
            printf("left key = %d, ",getLeft(k,heap));
        }
        if(k * 2 + 1 <= n){
            printf("right key = %d, ",getRight(k,heap));
        }
        cout << endl;
    }
}


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

using namespace std;

struct node{
	int sum,pos;
}a[200005];

int n,b[200005],c[200005],i;

bool cmp(node a,node b)
{
	return a.sum>b.sum;
}

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i].sum);
		a[i].pos=i;
	}
	sort(a,a+n,cmp);
	for(i=0;i<n;i++)
	{
		b[i]=1;
		int pos=0;
		while(b[pos])
			pos++;
		c[a[i].pos]=a[pos].sum;
		b[i]=0;
	}
	for(i=0;i<n;i++)
		printf("%d\n",c[i]);
	return 0;
}

Measured memory_bytes: 4736
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
char upperCase(char a){int d = (int)a - 97 + 65;char c = (char)d;return c;} 
char lowerCase(char a){int d = (int)a - 65 + 97;char c = (char)d;return c;}  
bool isInt(char a){int d = (int)a - 48;if(d>=0 && d<=9){return true;}return false;}
//string char_to_string(char a){string d = (1,a);return d;}
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr

//bool bySecond(pair<int,int> a,pair<int,int> b){
//  return a.second < b.second;
//} 
 
 
int main(){
  ll n;
  cin >> n;
  ll ans = n*n;
  cout << ans;
}


 














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

int main()
{
  int64_t N, color = 0;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  multimap<int64_t, int64_t> mp; // top, color
  mp.insert({A[0], 0});
  for (int i = 1; i < N; i++)
  {
    auto it = mp.lower_bound(A.at(i));
    if (it == mp.begin())
    {
      color++;
      mp.insert({A.at(i), color});
    }
    else
    {
      it--;
      auto p = *it;
      mp.erase(it);
      mp.insert({A.at(i), p.second});
    }
  }
  cout << color + 1 << endl;
}

Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main()
{
    int N, X;

    cin >> N >> X;

    int L[N];

    for ( int i = 0; i < N; i ++ ) cin >> L[i];

    int D = 0;
    int count = 1;

    for ( int i = 0; i < N; i ++ ) {
        D = D + L[i];
        if ( D > X ) break;
        count ++;
    }

    cout << count << endl;    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner stdin = new Scanner(System.in);

        long N = stdin.nextLong();
        double sqr = (double)Math.sqrt(N);
        long ans = 0;
       
        for(int i=1;i<=sqr;i++) {
        	if(N%i == 0) {
        		ans = i+N/i;
        	}
        }
        System.out.println(ans-2);
	}
}


Measured memory_bytes: 22608
#include<iostream>
    #include<cmath>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    #include<string>
    using namespace std;
    int a[10000];
    int main()
    {
    	int n,m;
    	cin>>n>>m;
    	for(int i=0;i<n;i++)cin>>a[i];
    	sort(a,a+n);
    	int tem=0;
    	for(int i=0;i<n;i++)
    	{
    		tem+=a[i];
    	}
    	tem=m-tem;
    	cout<<n+(tem/a[0])<<endl;
    	return 0;
     } 

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	ll n;cin>>n;

	for(int i=-1000; i<1000; i++){
		for(int j=-1000; j<1000; j++){
			if(pow(i,5)-pow(j,5) ==n){

				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}




}




Measured memory_bytes: 4112