akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout <<  #x << " " << x <<endl;
int ara[1000005];
int main()
{
	string s;
	cin >> s;
	int c = 0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
			c++;
		else {
			int r = (c+1)/2;
			int l = c/2;
			ara[i+1] += l;
			ara[i] += r;
			
			/*debug(i);
			debug(l);
			debug(r);
			*/

			c = 0;
		}
	}
	ara[s.size()]+=c;
	//for(int i=0;i<s.size();i++)cout << ara[i+1] << " " ;
	//	cout << endl;
	c = 0;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='L')
			c++;
		else 
		{
			int r = c/2;
			int l = (c+1)/2;
			ara[i+2] += l;
			ara[i+1] += r;
			c = 0;
		}
	}
	ara[1]+=c;
	for(int i=0;i<s.size();i++)cout << ara[i+1] << " " ;
}

Measured memory_bytes: 1024
N,M = map(int,input().split())
H  = list(map(int,input().split()))

a = [0] * M
b = [0] * M
X = [0] * N
for i in range(M):
    a[i],b[i] = map(int, input().split())
    if H[a[i]-1] > H[b[i]-1]:
        X[b[i]-1] += 1
    elif H[a[i]-1] < H[b[i]-1]:
        X[a[i]-1] += 1
    else:
        X[a[i]-1] += 1
        X[b[i]-1] += 1

Y = [i for i in X if i == 0]
print(len(Y))


Measured memory_bytes: 22244
#coding: UTF-8
N=int(input())
p=[int(input()) for i in range(0,N)]
maxv=p[1]-p[0]
buy=p[0]
for i in range(1,N):
    if p[i]-buy>maxv:
        maxv=p[i]-buy
    if p[i]<buy:
        buy=p[i]
print(maxv)

Measured memory_bytes: 15604
def resolve():
    lower = "abcdefghijklmnopqrstuvwxyz"
    N = int(input())

    ans = ""
    while N:
        N -= 1
        idx = N%26
        ans += lower[idx]
        N //= 26
    print(ans[::-1])

if __name__ == "__main__":
    resolve()


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

int main(){
    int n;
    long int s;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    s = 0;
    for(int i = 0; i < n; i++){
        s += a.at(i);
    }
    cout << a.at(0) << " " << a.at(n - 1) << " " << s << endl;
}


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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	
	int AB = A+B;
	int CD = C+D;
	
	if(AB ==CD) cout << "Balanced";
	else if (AB > CD) cout << "Left";
	else cout << "Right";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>

int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    
 
       ll n,k;
       cin>>n>>k;
       ll ans =0;
       ll a[n];

       fori(0,n){
        cin>>a[i];
      
       }
       sort(a,a+n);
       fori(0,k)ans+=a[i];
        
        cout<<ans<<"\n";
      
 

     
 
return 0;
}     

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

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

int main(){
  int w,h;

  while(cin>>w>>h,w||h){
    string s;
    int d = 0;
    int x=1,y=1;

    while(cin>>s,s!="STOP"){
      int nx=x,ny=y;

      if(s[0] == 'F'){
        int dist;
        cin>>dist;
        nx = x + dist * dx[d];
        ny = y + dist * dy[d];
      }
      else if(s[0] == 'B'){
        int dist;
        cin>>dist;
        nx = x + dist * dx[(d+2)%4];
        ny = y + dist * dy[(d+2)%4];
      }
      else if(s[0] == 'R'){
        d = (d + 1) % 4;
      }
      else{
        d = (d + 3) % 4;
      }

      if(nx < 1) nx = 1;
      else if(nx > w) nx = w;
      if(ny < 1) ny = 1;
      else if(ny > h) ny = h;
      x = nx;
      y = ny;
    }

    cout<<x<<" "<<y<<endl;
  }
}

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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f;

void no() {
	cout << -1 << endl;
	exit(0);
}
ll v[N];

int main() {
	ll max = 1e18;
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	ll ans = 1;
	int flag = 0;
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		flag = flag or (v[i] == 0);
	}

	if(flag) {
		cout << 0 << endl;
		return 0;
	}

	for(int i = 0; i < n; i++) {
		ll a = v[i];
		if(ans > max/a) no();
		ans *= a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4396
#include<cstdio>
#include<stdio.h>

int A[1000000], n;

// 二分探索
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return mid;  // key を発見
		if (key > A[mid]) left = mid + 1;  // 後半を探索
		else if (key < A[mid]) right = mid;  // 前半を探索
	}
	return 0;
}


int main() {
	int i, q, k, res, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &k);
		if (binarySearch(k)) sum++;
	}
	printf("%d\n", sum);

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[a.size() - 1] - a[0] << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return (a.first*b.second) < (a.second*b.first);
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}
int main(){
    fastio;
    //clock_t tm = clock();
    int n;string s;
    cin>>n;
    cin>>s;
    vi g[10];
    int ans=0;
    f(i,0,n){
        int x = s[i]-'0';
        g[x].pb(i);
    }
    f(i,0,1001){
        int cp=i;
        int x=cp%10,y=(cp/10)%10,z=(cp/100);
        if(!g[x].empty()){
            int t1=g[x][0];
            if(!g[y].empty()){
                int t2=upper_bound(all(g[y]),t1)-g[y].begin();
                if(t2!=int(g[y].size())){
                    if(!g[z].empty()) {
                        int t3 = upper_bound(all(g[z]), g[y][t2]) - g[z].begin();
                        if (t3 != int(g[z].size())) {
                            ans++;
                        }
                    }
                }
            }
        }
    }
    //int cp=729;
    //cout<<cp%10<<(cp/10)%10<<(cp/100)<<endl;
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 512
b = 0

n = gets.to_i
xs = gets.split.map(&:to_i)
ys = gets.split.map(&:to_i)
ts = xs.zip(ys).map{|x,y| x-y}.sort.reverse

ts.each_with_index do |d, i|

  if d > 0
    if i == n-1
      puts :No
      exit
    end
    b += d  # +2*b

  elsif d < 0

    k = [(-d)/2, b].min
    b -= k

  end

end

if b == 0
  puts :Yes
else
  puts :No
end


Measured memory_bytes: 4472
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int l = 0, r = w, shita = 0, ue = h;

    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1) {
            l = max(l, x);
        }
        else if(a == 2) {
            r = min(r, x);
        }
        else if(a == 3) {
            shita = max(shita, y);
        }
        else {
            ue = min(ue, y);
        }
    }

    if(r <= l || ue <= shita) {
        cout << 0;
    }
    else {
        cout << (r - l)*(ue - shita);
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

int sum(int n) {
  int res = 0;
  while (n) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

signed main() {
  int n;
  cin >> n;
  if (n % sum(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	int ar[n];
	for(int i=0;i<n;++i){
		cin >> ar[i];
	}
	int b=1,c=0;
	for(int i=0;i<n;++i){
		if(ar[i]==b){
			b++;
		}else if(ar[i]!=b){
			c++;
		}
	}
	if(b>1){
		cout << c << endl;
	}else{
		cout << -1;
	}
	
return 0;
}

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

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

impl<R: Read> Scanner<R> {
    fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
    fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut sss = Vec::new();
    for _ in 0..m {
        let k: usize = sc.read();
        let mut ss = Vec::new();
        for _ in 0..k {
            ss.push(sc.read::<usize>());
        }
        sss.push(ss);
    }
    let mut pp = Vec::new();
    for _ in 0..m {
        pp.push(sc.read::<usize>());
    }

    let mut res = 0;
    let mut b: usize = 0;
    while b < (1usize << n) {
        let mut num = 0;
        for (i, ss) in sss.iter().enumerate() {
            let mut cnt = 0;
            for s in ss {
                if b & (1usize << (s-1)) != 0 {
                    cnt += 1;
                }
            }
            if cnt % 2 == pp[i] {
                num += 1;
            }
        }
        if num == m {
            res += 1;
        }
        b += 1;
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>>v;
  rep(i,n){
    ll a;cin>>a;
    v.push_back(make_pair(a,1));
  }
  rep(i,m){
    ll b,c;cin>>b>>c;
    v.push_back(make_pair(c,b));
  }
  sort(all(v),greater<>());

  ll num=0;
  ll ans=0;
  for(ll i=0;num!=n;i++){
    // cout<<v[i].first<<endl;
    if(v[i].second+num<n){
      num+=v[i].second;
      ans+=v[i].first*v[i].second;
    }else{
      ans+=v[i].first*(n-num);
      num=n;
    }
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 6256
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(old, cnt)
  check = 14.times.map{ [false] * 8 }
  res = 0
  (1..12).each do |i|
    (1..6).each do |j|
      if !check[i][j] && old[i][j] =~ /[^O.]/
        puyo_connector(i, j, old){ |arr|
          if arr.size >= 4
            arr.each do |s, t|
              D.each do |x, y|
                p, q = s + x, t + y
                check[p][q] = true if old[p][q] == 'O'
              end
              check[s][t] = true
            end
            res = 1
          end
        }
      end
    end
  end
  fld = puyo_eraser(old, check)
  if res == 1 then puyo_rensa(fld, cnt + 1)
  else cnt
  end
end

def puyo_connector(i, j, fld)
  check = 14.times.map{ [false] * 8 }
  arr = [[i, j]]
  ret = [[i, j]]
  check[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !check[p][q] && fld[i][j] == fld[p][q]
        check[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret)
end

def puyo_eraser(fld, check)
  fld = fld.transpose
  check = check.transpose
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless check[i][j] }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  fld.transpose
end

gets.to_i.times do
  fld = 14.times.map{ ['.'] * 8 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[i+1][j+1] = c
    end
  end
  p puyo_rensa(fld, 0)
end

Measured memory_bytes: 9432
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static class Task {
        int tq, dl;
        public Task(int timeReq, int deadLine){
            tq = timeReq;
            dl = deadLine;
        }
    }
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int tCur, tReq = 0;
        boolean poss = true;
        ArrayList<Task> tasks = new ArrayList<>();
        for (int i = 0; i < n; i++){
            tasks.add(new Task(in.nextInt(), in.nextInt()));
        }
        tasks.sort(new Comparator<Task>() {
            @Override
            public int compare(Task o1, Task o2) {
                return o1.dl == o2.dl ? 0 : o1.dl > o2.dl ? 1 : -1;
            }
        });
        for (int i = 0; i < n; i++){
            Task temp = tasks.get(i);
            tCur = temp.dl;
            tReq += temp.tq;
            if (tReq > tCur){
                poss = false;
                break;
            }
        }
        System.out.println(poss ? "Yes" : "No");
    }
}


Measured memory_bytes: 106208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;


template<typename CONTAINER>
void bubble_sort(CONTAINER & iterable){
    int N = iterable.size();
    for (int i = 0; i != N; ++i){
        for (int j = N - 1; j != i; --j){
            if (iterable[j] < iterable[j-1]) swap(iterable[j], iterable[j - 1]);
        }
    }
}


template<typename CONTAINER>
void selection_sort(CONTAINER & iterable){
    int N = iterable.size();
    for (int i = 0; i != N; ++i){
        int mini = i;
        for (int j = i; j != N; ++j){
            if (iterable[j] < iterable[mini]) mini = j;
        }
        swap(iterable[i], iterable[mini]);
    }
}

struct Card
{
    char suit;
    int value;
    char str_repr[3];

    Card(char* str): suit(str[0]), value(atoi(&str[1])){
        str_repr[0] = str[0];
        str_repr[1] = str[1];
        str_repr[2] = '\0';
    }

    bool operator==(Card rhs){
        return suit == rhs.suit && value == rhs.value;
    }
    
    bool operator<(Card rhs){
        return value < rhs.value;
    }
    
    operator const char*() const{
        return str_repr;
    }

};


template<typename T>
void display_contents(const T & container){
    cout << *(container.cbegin());
    for (auto it = container.cbegin() + 1; it != container.cend(); ++it){
        cout << ' ' << *it;
    }
    cout << endl;
}

int  main()
{
    int N = 0;
    cin >> N;
    vector<Card> cards;
    for (auto i = 0; i != N; ++i){
        char card[3];
        cin >> card;
        cards.emplace_back(card);
    }
    vector<Card> cards1{cards};
    vector<Card> cards2{cards};
    bubble_sort(cards1);
    display_contents(cards1);
    cout << "Stable" << endl;
    selection_sort(cards2);
    display_contents(cards2);
    if (equal(cards1.begin(), cards1.end(), cards2.begin())){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var (
		r      int
		result string
	)
	fmt.Scan(&r)

	if r < 1200 {
		result = "ABC"
	} else if r < 2800 {
		result = "ARC"
	} else {
		result = "AGC"
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    map<ll, ll> num_count;
    rep(i, n){
        int inp;
        cin >> inp;
        num_count[inp] ++;
    }

    ll sum = 0;
    for(auto itr = num_count.begin(); itr != num_count.end(); itr++){
        if(itr->second < itr->first){
            sum += itr->second;
        }else{
            sum += itr->second - itr->first;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 6272
#include <stdio.h>
#include <string.h>
int main()
{
  char buf[10005];
  int i,j,k;
  while((scanf("%s",buf)) != EOF){
    j = k = 0;
    for(i=0;i<strlen(buf)-2;i++){
      if(buf[i+1] == 'O' && buf[i+2] == 'I'){
	if(buf[i] == 'J') j++;
	if(buf[i] == 'I') k++;
      }
    }
    printf("%d\n%d\n",j,k);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  double tmp, avg = 0;
  vector<double> A;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    avg += tmp;
    A.push_back(tmp);
  }
  avg     = round(avg / N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (A[i] - avg) * (A[i] - avg);
  }
  cout << ans << endl;
  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 ans=0;

        int a=sc.nextInt();
        int b=sc.nextInt();
        int x=sc.nextInt();

        if(a>(b*2))
        {
            int n=x/500;
            ans=b*n;
            if (x%500!=0) { ans+=b;}
        }else
        {
            int n=x/1000;
            ans=a*n;
            if(x%1000!=0)
            {
                if (x%1000<=500) 
                {
                    if (a<b) {ans+=a;}
                    else {ans+=b;}
                }
                else {ans+=a;}
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 26316
program kadai
    implicit none
integer  ::  N,i
character(len=100)  ::  S

read(*,*) N
read(*,*) S

if (mod(N,2)==1) then
    write(*,*) "No"
    stop
end if

do i=1,N/2
    if (S(i:i) /= S((N/2)+i:(N/2)+i)) then
        write(*,*) "No"
        stop
    end if
end do

write(*,*) "Yes"

stop
contains
end program kadai


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,n,m) for(int i=n;i<=m;i++)
using namespace std;
int main() {
    int ledo[2]={0,0},riup[2],n;
    cin>>riup[0]>>riup[1]>>n;
    FOR(i,1,n){
        int num[4];
        cin>>num[1]>>num[2]>>num[3];
        switch (num[3]) {
            case 1:if(num[1]>ledo[0])ledo[0]=num[1];
                break;
            case 2:if(num[1]<riup[0])riup[0]=num[1];
                break;
            case 3:if(num[2]>ledo[1])ledo[1]=num[2];
                break;
            case 4:if(num[2]<riup[1])riup[1]=num[2];
                break;
        }
    }

    if(riup[0]<=ledo[0]||riup[1]<=ledo[1])cout<<"0"<<endl;
    else cout<<(riup[1]-ledo[1])*(riup[0]-ledo[0])<<endl;

    return 0;
}


Measured memory_bytes: 3508
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(void)
{
  int n;
  int i;
  cin>>n;
  rep(i,n){
    double x1,x2,x3,x4;
	double y1,y2,y3,y4;
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
	if(abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1))<1e-10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1224
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int res=0;
    for(int i=0;i+3<=n;i++){
        if(s.substr(i,3)=="ABC") res++;
    }
    cout<<res<<endl;
    
    return 0;
}


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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,k;
    cin>>n>>k;

    vector<int> a(n);
    for(int& x : a)
    {
        cin>>x;
    }

    bool dp[1000001];
    memset(dp,0,sizeof(dp));

    f1(stones,1,k)
    {
        for(auto x : a)
        {
            if(stones >= x && !dp[stones-x])
            {
                dp[stones] = true;
            }
        }
    }

    cout<<(dp[k]?"First":"Second");
}

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

int main() {
    int x, y;
    cin >> x >> y;
    if(x==2 || y==2){
        if(x==y) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(x==4 || x==6 || x==9 || x==11){
        if(y==4 || y==6 || y==9 || y==11) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(y==4 || y==6 || y==9 || y==11) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
check=[]
s=input()
check.append(s)
ans=0
for i in range(n-1):
  keep=s[-1]
  s=input()
  if keep != s[0]:
    ans=1
  if str(s) in check:
    ans = 1
  else:
    check.append(s)
print(["Yes","No"][ans])

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

using namespace std;

#define ldouble long double
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, k, a[100001] = {};
    llong imomushi = 0, sum_of_plus = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> a[i];
        if (i < k) {
            imomushi += a[i];
        } else {
            if (a[i] > 0) sum_of_plus += a[i];
        }
    }

    priority_queue<llong> ans;
    rep(i, n - k + 1) {
        if (i != 0) {
            int next = a[k - 1 + i], prev = a[i - 1];
            imomushi += next - prev;
            if (next > 0) sum_of_plus -= next;
            if (prev > 0) sum_of_plus += prev;
        }
        ans.push(max((llong)0, imomushi) + sum_of_plus);
    }

    cout << ans.top() << endl;

    return 0;
}

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

using namespace std;



#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define fi first
#define se second
#define pb push_back
typedef long long LL;
const LL INF = 1e10;

template<typename T>
bool chmin(T& l,T r){
    bool ret = l>r;
    if(ret)l=r;
    return ret;
}

void solve(int n){
    vector<int> p(n);
    vector<int> t(n);
    REP(i,n)cin>>p[i]>>t[i];
    vector<LL> dp(4,INF);
    dp[1]=p[0];
    if(p[0]>t[0]){
        cout<<"NG 1"<<endl;
        return;
    }
    FOR(i,1,n){
        vector<LL> nxt(4,INF);
        LL tt = t[i]-t[i-1]; 
        LL dd = abs(p[i]-p[i-1]);
        FOR(j,1,3){
            if(tt>=dd*(j+1))
                chmin(nxt[j+1],dp[j]+dd);
        }
        FOR(j,1,4){
            if(tt>=p[i-1]*(j+1)+p[i])
                chmin(nxt[1],dp[j]+p[i-1]+p[i]);
        }
        if(min({nxt[0],nxt[1],nxt[2],nxt[3]})==INF){
            cout<<"NG "<<i+1<<endl;
            return;
        }
            
        swap(dp,nxt);
        //REP(j,4)cout<<dp[j]<<" ";cout<<endl;
    }
    LL ret=INF;
    REP(i,4)chmin(ret,dp[i]+p.back());
    cout<<"OK "<<ret<<endl;
}
int main(){
    int n;
    while(cin>>n,n)solve(n);
    return 0;
}

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

 int main(){
     int N;cin>>N;
     int Y;cin>>Y;
     for(int i=0;i<=N;i++){
         for(int j=0;j<=N-i;j++){
             int l=N-i-j;
             if(10000*i+5000*j+1000*l==Y){
                 cout<<i<<" "<<j<<" "<<l<<endl;
               return 0;
             }
         }
     }

     cout<<-1<<" "<<-1<<" "<<-1<<endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000
#define mod 1000000007
#define int long long int

signed main(void)
{
    int n, m;
    cin >> n >> m;
    int x[n];
    int y[m];
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    int sumx = 0, sumy = 0;
    for( int i = 0; i < n; i++){
        sumx += i*x[i] - (n-i-1)*x[i];
    }
    for( int i = 0; i < m; i++){
        sumy += i*y[i] - (m-i-1)*y[i];
    }
    sumx = sumx % mod;
    sumy = sumy % mod;
    cout << (sumx * sumy) % mod << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

int n;

int len(int x) {
	int res;
	for(res=0; x; x/=10) res++;
	return res;
}

int main() {
	int i, k;
	int ans=0;
	
	scanf("%d", &n);
	for(i=1; i<=n; i++) ans+=len(i)&1;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
class Point implements Comparable<Point> {
  int a, b;
  Point (int a, int b) {
    this.a = a;
    this.b = b;
  }
 
  public int hashCode() {
    return ((a & 0xFFFF0000) | (b>>16)) ^ ((b & 0xFFFF0000) | (a>>16));
  }
 
  public boolean equals(Object object) {
    Point point = (Point)object;
    return this.a == point.a && this.b == point.b;
  }

  public int compareTo(Point p) {
    if (this.a != p.a) {
      return this.a - p.a;
    }
    return this.b - p.b;
  }
}
 
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int h = s.nextInt();
    int w = s.nextInt();
    int n = s.nextInt();
    HashMap<Point, Integer> map = new HashMap<Point, Integer>();
//    TreeMap<Point, Integer> map = new TreeMap<Point, Integer>();
    for (int i = 0; i < n; i++) {
      int a = s.nextInt() - 1;
      int b = s.nextInt() - 1;
      for (int da = Math.max(0, a - 2); da <= Math.min(h - 3, a); da++) {
        for (int db = Math.max(0, b - 2); db <= Math.min(w - 3, b); db++) {
          Point p = new Point(da, db);
          if (map.get(p) == null) {
            map.put(p, 1);
          } else {
            map.put(p, map.get(p) + 1);
          }
        }
      }
    }
    long[] output = new long[10];
    output[0] = (long)(h - 2) * (long)(w - 2);
    for (int value : map.values()) {
      output[0]--;
      output[value]++;
    }
    for (long value : output) {
      System.out.println(value);
    }
  }
}


Measured memory_bytes: 226708
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
string str;
int n;
int mxpos[26][200005];
int dp[200005];
int main()
{
	cin>>str;
	n=str.size();
	memset(mxpos,23,sizeof(mxpos));
	for(int i=0;i<n;i++)
		mxpos[str[i]-'a'][i]=i;
	for(int i=0;i<26;i++)
		for(int j=n-2;j>=0;j--)
			mxpos[i][j]=min(mxpos[i][j],mxpos[i][j+1]);
	for(int i=n-1;i>=0;i--)
	{
		int gg=1234567;
		for(int j=0;j<26;j++)
		{
			if(mxpos[j][i+1]<1234567)
				gg=min(gg,dp[mxpos[j][i+1]]);
			else
				gg=0;
		}
		if(gg==1234567)	gg=0;
		dp[i]=gg+1;//cout<<i<<' '<<str[i]<<' '<<dp[i]<<endl;
	}
	for(int j=0;j<26;j++)
		if(mxpos[j][0]>1234567)
		{
			cout<<(char(j+'a'))<<endl;
			return 0;
		}
	bool fg=0;
	int st=0;
	int mxv=123456;
	for(int i=0;i<26;i++)
		mxv=min(mxv,dp[mxpos[i][0]]);//cout<<mxv<<endl;
//	cout<<"WTF"<<mxpos[0][0]<<endl;
	for(int j=0;j<26;j++)
		if(mxv==dp[mxpos[j][0]])
		{//cout<<"WTF"<<dp[0]<<' '<<j<<' '<<mxpos[j][0]<<' '<<dp[mxpos[j][0]]<<endl;
			st=mxpos[j][0];
			break;
		}
//	st=mxpos[0][0];
	for(int i=st;i<=n && fg==0;)
	{
		cout<<str[i];
		for(int j=0;j<26;j++)
		{
			if(mxpos[j][i+1]<1234567)
			{
				if(dp[i]==dp[mxpos[j][i+1]]+1)
				{
					i=mxpos[j][i+1];
					break;
				}
			}
			else
			{
				cout<<(char(j+'a'))<<endl;
				fg=1;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 21636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	int k,s;
	cin>>k>>s;
	
	int cnt=0;
	for(int a=0;a<=k;++a){
		for(int b=0;b<=k;++b){
			int c=s-(a+b);
			if(0<=c&&c<=k) cnt++;
		}
	}
	
	cout<<cnt<<endl;
	return 0;
}//解説参考.

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

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	int p = min({A,B,C});
	int r = max({A,B,C});
	int q = A+B+C-p-r;

	if (p==q) {
		cout << r-q << endl;
		return 0;
	}
	if (q==r) {
		cout << (q-p+1)/2 + (q-p)%2 << endl;
		return 0;
	}

	int ans = (q-p+1)/2 + (q-p)%2;
	ans += r-q;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n)  for(int i = 0; i < (n); ++i)
#define rrep(n) for(int i = (n-1); i >= 0; --i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    ll n; cin >> n;
    vector<ll> abc(5);

    rep(5) cin >> abc[i];

    // vector<ll> current(6);
    // ll ans = 0;
    // current[0] = n;

    // // for(auto i: current) cout << i << " ";
    // // cout << endl;

    // while(current[5] < n) {
    //     rrep(5) {
    //         if(current[i] <= 0) {
    //             continue;
    //         }
    //         else if(current[i] >= abc[i]) {
    //             current[i]   -= abc[i];
    //             current[i+1] += abc[i];
    //         }else {
    //             current[i+1] += current[i];
    //             current[i] = 0;
    //         }
    //     }

    //     ans++;

    //     // for(auto i: current) cout << i << " ";
    //     // cout << endl;
    // }

    // ボトルネックになる部分(X)を考える
    // ceil(n / X) + 4
    // (i - 1) + (5 - i)から導出
    // ↑誰も乗らない時間
    Sort(abc);
    long double mn = abc[0];
    pout(0, ceil(n / mn) + 4);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 1000000007;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> bool chmax(T &a, const T & b) {
    if (a<b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> bool chmin(T &a, const T & b) {
    if (a>b) {
        a = b;
        return true;
    }
    return false;
}

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;

int gcd(int a, int b) {
    if (b > a) {
        int c = b;
        b = a;
        a = c;
    }
    int r = a % b;
    if (r == 0) return b;
    return gcd(b, r);
}

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    ll res = 1;
    vi c = {0, 0, 0};
    REP(i, n) {
        int cnt = 0;
        int ind = -1;
        REP(j, 3) {
            if (a[i] == c[j]) {
                cnt += 1;
                if (ind < 0) ind = j;
            }
        }
        res *= cnt;
        res %= mod;
        if (ind < 0) res = 0;
        else c[ind] += 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
X, Y, A, B, C = sys.stdin.readline().split()
X = int(X)
Y = int(Y)
C = int(C)
scoreA = list(map(int, sys.stdin.readline().split()))
scoreB = list(map(int, sys.stdin.readline().split()))
scoreC = list(map(int, sys.stdin.readline().split()))
scoreA.sort(reverse=True)
scoreB.sort(reverse=True)
scoreC.sort(reverse=True)
scoreA = scoreA[:X]
scoreB = scoreB[:Y]
scoreAll = scoreA + scoreB + scoreC
scoreAll.sort(reverse=True)
print(sum(scoreAll[:X+Y]))


Measured memory_bytes: 23312
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    ll x[n+2];
    ll sum=0;
    x[0]=0;x[n+1]=0;
    rep(i,n){
        cin >> x[i+1];
        sum+=abs(x[i+1]-x[i]);
    }
  sum+=abs(x[n+1]-x[n]);
    rep(i,n){
        ll ans=sum;
        ans-=(abs(x[i+1]-x[i])+abs(x[i+2]-x[i+1])-abs(x[i+2]-x[i]));
        kaku(ans);
    }
}

int main(){
    solve();
}




//




Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		
		BufferedReader vf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(vf.readLine());
		int k = Integer.parseInt(vf.readLine());
		
		int ans=1;
		
		for(int i=0;i<n;i++) {
			if(ans<k)ans*=2;
			else ans+=k;
		}
		System.out.println(ans);
		
	}
	/*public int soN(int a) {
		return a*2;
	}
	
	public int soK(int a, int b) {
		return a+b;
	}*/

}


Measured memory_bytes: 21204
#include <iostream>

using namespace std;

int main(){
    int sum, x, d;
    while(cin >> d){
        sum = 0;
        for(int i=1;(x=(i*d))<600;i++){
            sum += x*x;
        }
        sum *= d;
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    n = n%10;
    if(n==3) cout << "bon" << endl;
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    ans=n*(n-1)/2;
    Cout(ans);
    return 0;
}

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

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

    vector<P> vec;

    ll a = 2;
    while (N >= a * a) {
        ll num_a = 0;
        while (N % a == 0) {
            N /= a;
            num_a++;
        }
        if (num_a > 0) vec.push_back(make_pair(a, num_a));
        a++;
    }
    vec.push_back(make_pair(N, 1));

    ll ans = 0;
    for (auto v : vec) {
        if (v.first == 1) continue;
        int num_a = v.second;
        for (int i=1; i<=num_a; i++) {
            if (num_a - i >= 0) {
                ans++;
                num_a -= i;
            }
            else break;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 3e5+10;
int ans[N];
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b;cin>>n>>a>>b;
    if((n<a+b-1)||a*b<n)
        return cout<<-1,0;
    a--;
    bool ok=0;
    for(int i=1;i<=n&&!ok;i+=b,a--){
        deque<int> vec={i};
        for(int j=i+1;!ok&&j<=i+b-1;j++)
            vec.push_front(j),ok|=(n-j==a);
        for(int j=0;j<vec.size();j++)
            ans[i+j]=vec[j];
    }
    for(int i=1;i<=n;i++)
        cout<<(ans[i]>0?ans[i]:i)<<" ";
}





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


ll d[100010];
ll n,m,s,t;

class Dijkstra {
public:
    struct edge { long long v, dist; };

    struct state {
        long long v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const long long INF = (1LL << 60);
    long long N;
    vector< vector<edge> > E;

    Dijkstra(long long n): N(n), E(n) {}

    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
    }

    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    //Sを始点として、他の頂点への最短経路を探す
    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }
};



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    cin>>n>>m>>s>>t;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    if(s>t){
        cout << 0 << endl;
        return 0;
    }
    Dijkstra di(n);
    s--,t--;
    vector<array<ll,2>> x;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        int g=b;
        if(a<=s) a=s;
        if(b>=t) b=t;
        if(b==t) x.push_back({a,d[g]});
        di.add_directed_edge(a,b,d[g]);
    }
    ll ans = 1e15;
    vector<ll> v = di.shortest_path(s);
    vector<ll> y(n,1e15);
    ll mi = 1e18;
    sort(x.begin(),x.end());
    for(int i=1;i<x.size();i++){
        mi = min(mi,x[i-1][1]);
        for(int j=x[i-1][0];j<=x[i][0];j++){
            y[j] = mi;
        }
    }
    mi = min(mi,x[x.size()-1][1]);
    for(int j=x[x.size()-1][0];j<=t;j++){
        y[j] = mi;
    }
    y[t] = 0;
    for(int i=s;i<=t;i++){
        ans = min(ans, v[i] + y[i]);
        //cerr << v[i] << " " << y[i] << endl;
    }
    cout << ans << endl;
}


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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   ll ans = 0;
   for(int i = 1 ; i <= n ; i++){
      int num = n / i;
      ans += 1ll * i * num * (num + 1) / 2;
   }
   cout << ans;
   return 0;
}


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

int Deg[5];
set<int> Flag;
int Cnt;

int main(int argc, char *argv[]) {
    for (int i = 1; i <= 4; ++i) Flag.insert(i);
    for (int i = 0, A, B; i < 3; ++i) {
        scanf("%d%d", &A, &B);
        Deg[A]++; Deg[B]++;
        Flag.erase(A); Flag.erase(B);
    }
    if (!Flag.empty()) {
        printf("NO\n");
        return 0;
    }
    for (int i = 1; i <= 4; ++i) {
        if (Deg[i] & 1) {
            Cnt++;
        }
    }
    if (Cnt != 2) printf("NO\n");
    else printf("YES\n");
    return 0;
}



Measured memory_bytes: 256
import io.StdIn.{readInt, readLine}
import math.{sqrt, pow}
object Main extends App {
  val n = readInt
  val xys = for (_ <- 1 to n) yield readLine.split(" ").map(_.toInt)

  def dis(p1: Array[Int], p2: Array[Int]) =
    sqrt(pow(p1.head-p2.head, 2)+pow(p1.last-p2.last, 2))

  val distances = for (route <- xys.permutations; edge <- route.sliding(2))
    yield dis(edge.head, edge.last)

  val result = (distances.sum) / ((1 to n).product)
  println(result)
}

Measured memory_bytes: 65740
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		a[A-1]=i;
	}
	int t=1,res=0;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			res=max(res,t);
			t=0;
		}
		t++;
	}
	res=max(res,t);
	cout<<n-res<<endl;
}

Measured memory_bytes: 1024
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

l = 10**9
for i in range(len(h)):
    tmp = abs(a - (t - h[i]*0.006))
    if l > tmp:
        l = tmp
        ans = i+1
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S,T;
    cin >> S >> T;
    int ans=0;
    REP(i,0,3){
        if(S[i]==T[i])ans++;
    }  
    P(ans);
}

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


int main(void) {

	string source, check;
	bool flag;
	int count = 0;
	cin >> source >> check;
	if (source.size() < check.size()) return 0;
	for (int i = 0; i < source.size(); i++) {
		if (check.at(0) == source.at(i)) {
			flag = true;
			for (int j = 0; j < check.size(); j++) {
				if (i + j < source.size()) {
					if (source.at(i + j) != check.at(j)) { flag = false; break; }
				}
				else {  flag = false;  break;  }
			}
			if (flag) {
				count++;
				cout << i << endl;
			}
		}
	}


}



Measured memory_bytes: 3228